From 1606970601065364bc12d9b101e25a254f7041db Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 10 Jun 2015 15:55:34 -0400 Subject: [PATCH] Back out 3 csets from bug 1125325 for introducing bug 1173224. r=me --- dom/base/nsContentUtils.cpp | 13 ----- dom/base/nsContentUtils.h | 3 - dom/base/nsPIWindowRoot.h | 20 +------ dom/base/nsWindowRoot.cpp | 41 -------------- dom/base/nsWindowRoot.h | 8 --- dom/ipc/PBrowser.ipdl | 3 +- dom/ipc/TabChild.cpp | 103 +++++++++++----------------------- dom/ipc/TabChild.h | 18 ++---- dom/ipc/TabParent.cpp | 36 +----------- layout/base/UnitTransforms.h | 5 +- layout/base/nsPresContext.cpp | 34 ++--------- layout/base/nsPresContext.h | 6 -- 12 files changed, 48 insertions(+), 242 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index bc885a5b581..447f5ec099d 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -7787,16 +7787,3 @@ nsContentUtils::FirePageShowEvent(nsIDocShellTreeItem* aItem, doc->OnPageShow(true, aChromeEventHandler); } } - -/* static */ -already_AddRefed -nsContentUtils::GetWindowRoot(nsIDocument* aDoc) -{ - if (aDoc) { - nsPIDOMWindow* win = aDoc->GetWindow(); - if (win) { - return win->GetTopWindowRoot(); - } - } - return nullptr; -} diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 3c294b83495..8a1e68447f6 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -99,7 +99,6 @@ class nsViewportInfo; class nsWrapperCache; class nsAttrValue; class nsITransferable; -class nsPIWindowRoot; struct JSPropertyDescriptor; struct JSRuntime; @@ -2364,8 +2363,6 @@ public: static void FirePageHideEvent(nsIDocShellTreeItem* aItem, mozilla::dom::EventTarget* aChromeEventHandler); - static already_AddRefed GetWindowRoot(nsIDocument* aDoc); - private: static bool InitializeEventTable(); diff --git a/dom/base/nsPIWindowRoot.h b/dom/base/nsPIWindowRoot.h index f040318384e..e37802f67f0 100644 --- a/dom/base/nsPIWindowRoot.h +++ b/dom/base/nsPIWindowRoot.h @@ -9,21 +9,14 @@ #include "nsISupports.h" #include "mozilla/dom/EventTarget.h" -#include "nsWeakReference.h" class nsPIDOMWindow; class nsIControllers; class nsIController; -namespace mozilla { -namespace dom { -class TabParent; -} -} - #define NS_IWINDOWROOT_IID \ -{ 0x238edca0, 0xb30d, 0x46d3, \ - { 0xb2, 0x6a, 0x17, 0xb6, 0x21, 0x28, 0x89, 0x7e } } +{ 0x728a2682, 0x55c0, 0x4860, \ + { 0x82, 0x6b, 0x0c, 0x30, 0x0a, 0xac, 0xaa, 0x60 } } class nsPIWindowRoot : public mozilla::dom::EventTarget { @@ -45,15 +38,6 @@ public: virtual void SetParentTarget(mozilla::dom::EventTarget* aTarget) = 0; virtual mozilla::dom::EventTarget* GetParentTarget() = 0; - - // Stores a weak reference to the browser. - virtual void AddBrowser(mozilla::dom::TabParent* aBrowser) = 0; - virtual void RemoveBrowser(mozilla::dom::TabParent* aBrowser) = 0; - - typedef void (*BrowserEnumerator)(mozilla::dom::TabParent* aTab, void* aArg); - - // Enumerate all stored browsers that for which the weak reference is valid. - virtual void EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsPIWindowRoot, NS_IWINDOWROOT_IID) diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index c5d7e231b7a..7b85a089a74 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -24,7 +24,6 @@ #include "nsIController.h" #include "xpcpublic.h" #include "nsCycleCollectionParticipant.h" -#include "mozilla/dom/TabParent.h" #ifdef MOZ_XUL #include "nsIDOMXULElement.h" @@ -386,46 +385,6 @@ nsWindowRoot::WrapObject(JSContext* aCx, JS::Handle aGivenProto) return mozilla::dom::WindowRootBinding::Wrap(aCx, this, aGivenProto); } -void -nsWindowRoot::AddBrowser(mozilla::dom::TabParent* aBrowser) -{ - nsWeakPtr weakBrowser = do_GetWeakReference(static_cast(aBrowser)); - mWeakBrowsers.PutEntry(weakBrowser); -} - -void -nsWindowRoot::RemoveBrowser(mozilla::dom::TabParent* aBrowser) -{ - nsWeakPtr weakBrowser = do_GetWeakReference(static_cast(aBrowser)); - mWeakBrowsers.RemoveEntry(weakBrowser); -} - -static PLDHashOperator -WeakBrowserEnumFunc(nsRefPtrHashKey* aKey, void* aArg) -{ - nsTArray>* tabParents = - static_cast>*>(aArg); - nsCOMPtr tabParent(do_QueryReferent((*aKey).GetKey())); - TabParent* tab = TabParent::GetFrom(tabParent); - if (tab) { - tabParents->AppendElement(tab); - } - return PL_DHASH_NEXT; -} - -void -nsWindowRoot::EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) -{ - // Collect strong references to all browsers in a separate array in - // case aEnumFunc alters mWeakBrowsers. - nsTArray> tabParents; - mWeakBrowsers.EnumerateEntries(WeakBrowserEnumFunc, &tabParents); - - for (uint32_t i = 0; i < tabParents.Length(); ++i) { - aEnumFunc(tabParents[i], aArg); - } -} - /////////////////////////////////////////////////////////////////////////////////// already_AddRefed diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h index 203ef2c63b9..49686ad3ee6 100644 --- a/dom/base/nsWindowRoot.h +++ b/dom/base/nsWindowRoot.h @@ -69,10 +69,6 @@ public: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsWindowRoot, nsIDOMEventTarget) - virtual void AddBrowser(mozilla::dom::TabParent* aBrowser) override; - virtual void RemoveBrowser(mozilla::dom::TabParent* aBrowser) override; - virtual void EnumerateBrowsers(BrowserEnumerator aEnumFunc, void *aArg) override; - protected: virtual ~nsWindowRoot(); @@ -88,10 +84,6 @@ protected: nsCOMPtr mPopupNode; // [OWNER] nsCOMPtr mParent; - - // The TabParents that are currently registered with this top-level window. - typedef nsTHashtable> WeakBrowserTable; - WeakBrowserTable mWeakBrowsers; }; extern already_AddRefed diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 93817672255..e81e9685a9a 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -25,7 +25,6 @@ using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h"; using class mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h"; using struct gfxSize from "gfxPoint.h"; using CSSRect from "Units.h"; -using CSSSize from "Units.h"; using LayoutDeviceIntRect from "Units.h"; using mozilla::LayoutDeviceIntPoint from "Units.h"; using ScreenIntSize from "Units.h"; @@ -549,7 +548,7 @@ child: CacheFileDescriptor(nsString path, FileDescriptor fd); - UpdateDimensions(CSSRect rect, CSSSize size, ScreenOrientation orientation, + UpdateDimensions(IntRect rect, ScreenIntSize size, ScreenOrientation orientation, LayoutDeviceIntPoint chromeDisp) compressall; UpdateFrame(FrameMetrics frame); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 7956b6d8dfa..b17208f8c15 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -92,7 +92,6 @@ #include "nsIPermissionManager.h" #include "nsIScriptError.h" #include "mozilla/EventForwards.h" -#include "nsDeviceContext.h" #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") @@ -166,6 +165,7 @@ NS_IMPL_ISUPPORTS(TabChild::DelayedFireContextMenuEvent, TabChildBase::TabChildBase() : mContentDocumentIsDisplayed(false) , mTabChildGlobal(nullptr) + , mInnerSize(0, 0) { mozilla::HoldJSObjects(this); } @@ -236,11 +236,9 @@ TabChildBase::InitializeRootMetrics() mLastRootMetrics.SetViewport(CSSRect(CSSPoint(), kDefaultViewportSize)); mLastRootMetrics.SetCompositionBounds(ParentLayerRect( ParentLayerPoint(), - ParentLayerSize( - ViewAs(GetInnerSize(), - PixelCastJustification::ScreenIsParentLayerForRoot)))); + ParentLayerSize(ViewAs(mInnerSize, PixelCastJustification::ScreenIsParentLayerForRoot)))); mLastRootMetrics.SetZoom(CSSToParentLayerScale2D( - ConvertScaleForRoot(CalculateIntrinsicScale(GetInnerSize(), kDefaultViewportSize)))); + ConvertScaleForRoot(CalculateIntrinsicScale(mInnerSize, kDefaultViewportSize)))); mLastRootMetrics.SetDevPixelsPerCSSPixel(WebWidget()->GetDefaultScale()); // We use ParentLayerToLayerScale(1) below in order to turn the // async zoom amount into the gecko zoom amount. @@ -301,14 +299,14 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) } TABC_LOG("HandlePossibleViewportChange aOldScreenSize=%s mInnerSize=%s\n", - Stringify(aOldScreenSize).c_str(), Stringify(GetInnerSize()).c_str()); + Stringify(aOldScreenSize).c_str(), Stringify(mInnerSize).c_str()); nsCOMPtr document(GetDocument()); if (!document) { return false; } - nsViewportInfo viewportInfo = nsContentUtils::GetViewportInfo(document, GetInnerSize()); + nsViewportInfo viewportInfo = nsContentUtils::GetViewportInfo(document, mInnerSize); uint32_t presShellId = 0; mozilla::layers::FrameMetrics::ViewID viewId = FrameMetrics::NULL_SCROLL_ID; bool scrollIdentifiersValid = APZCCallbackHelper::GetOrCreateScrollIdentifiers( @@ -325,8 +323,8 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) constraints); } - float screenW = GetInnerSize().width; - float screenH = GetInnerSize().height; + float screenW = mInnerSize.width; + float screenH = mInnerSize.height; CSSSize viewport(viewportInfo.GetSize()); // We're not being displayed in any way; don't bother doing anything because @@ -360,15 +358,15 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) ScreenIntSize oldScreenSize = aOldScreenSize; if (oldScreenSize == ScreenIntSize()) { - oldScreenSize = GetInnerSize(); + oldScreenSize = mInnerSize; } FrameMetrics metrics(mLastRootMetrics); metrics.SetViewport(CSSRect(CSSPoint(), viewport)); - // Calculate the composition bounds based on the inner size, excluding the sizes + // Calculate the composition bounds based on mInnerSize, excluding the sizes // of the scrollbars if they are not overlay scrollbars. - ScreenSize compositionSize(GetInnerSize()); + ScreenSize compositionSize(mInnerSize); nsCOMPtr shell = GetPresShell(); if (shell) { nsMargin scrollbarsAppUnits = @@ -382,9 +380,7 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) metrics.SetCompositionBounds(ParentLayerRect( ParentLayerPoint(), - ParentLayerSize( - ViewAs(GetInnerSize(), - PixelCastJustification::ScreenIsParentLayerForRoot)))); + ParentLayerSize(ViewAs(compositionSize, PixelCastJustification::ScreenIsParentLayerForRoot)))); metrics.SetRootCompositionSize( ScreenSize(compositionSize) * ScreenToLayoutDeviceScale(1.0f) / metrics.GetDevPixelsPerCSSPixel()); @@ -401,7 +397,7 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) // within the screen width. Note that "actual content" may be different with // respect to CSS pixels because of the CSS viewport size changing. CSSToScreenScale oldIntrinsicScale = CalculateIntrinsicScale(oldScreenSize, oldBrowserSize); - CSSToScreenScale newIntrinsicScale = CalculateIntrinsicScale(GetInnerSize(), viewport); + CSSToScreenScale newIntrinsicScale = CalculateIntrinsicScale(mInnerSize, viewport); metrics.ZoomBy(newIntrinsicScale.scale / oldIntrinsicScale.scale); // Changing the zoom when we're not doing a first paint will get ignored @@ -885,6 +881,7 @@ TabChild::TabChild(nsIContentChild* aManager, , mManager(aManager) , mChromeFlags(aChromeFlags) , mLayersId(0) + , mOuterRect(0, 0, 0, 0) , mActivePointerId(-1) , mAppPackageFileDescriptorRecved(false) , mLastBackgroundColor(NS_RGB(255, 255, 255)) @@ -925,9 +922,9 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent) if (eventType.EqualsLiteral("DOMMetaAdded")) { // This meta data may or may not have been a meta viewport tag. If it was, // we should handle it immediately. - HandlePossibleViewportChange(GetInnerSize()); + HandlePossibleViewportChange(mInnerSize); } else if (eventType.EqualsLiteral("FullZoomChange")) { - HandlePossibleViewportChange(GetInnerSize()); + HandlePossibleViewportChange(mInnerSize); } return NS_OK; @@ -969,14 +966,14 @@ TabChild::Observe(nsISupports *aSubject, // In some cases before-first-paint gets called before // RecvUpdateDimensions is called and therefore before we have an - // inner size value set. In such cases defer initializing the viewport + // mInnerSize value set. In such cases defer initializing the viewport // until we we get an inner size. if (HasValidInnerSize()) { InitializeRootMetrics(); if (shell) { nsLayoutUtils::SetResolutionAndScaleTo(shell, mLastRootMetrics.GetPresShellResolution()); } - HandlePossibleViewportChange(GetInnerSize()); + HandlePossibleViewportChange(mInnerSize); } } } @@ -1316,18 +1313,17 @@ NS_IMETHODIMP TabChild::GetDimensions(uint32_t aFlags, int32_t* aX, int32_t* aY, int32_t* aCx, int32_t* aCy) { - ScreenIntRect rect = GetOuterRect(); if (aX) { - *aX = rect.x; + *aX = mOuterRect.x; } if (aY) { - *aY = rect.y; + *aY = mOuterRect.y; } if (aCx) { - *aCx = rect.width; + *aCx = mOuterRect.width; } if (aCy) { - *aCy = rect.height; + *aCy = mOuterRect.height; } return NS_OK; @@ -2054,41 +2050,37 @@ TabChild::RecvShow(const ScreenIntSize& aSize, } bool -TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, - const ScreenOrientation& orientation, - const LayoutDeviceIntPoint& chromeDisp) +TabChild::RecvUpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size, + const ScreenOrientation& orientation, const LayoutDeviceIntPoint& chromeDisp) { if (!mRemoteFrame) { return true; } - mUnscaledOuterRect = rect; + mOuterRect = rect; mChromeDisp = chromeDisp; bool initialSizing = !HasValidInnerSize() && (size.width != 0 && size.height != 0); - - mOrientation = orientation; - ScreenIntSize oldScreenSize = GetInnerSize(); - SetUnscaledInnerSize(size); - ScreenIntSize screenSize = GetInnerSize(); bool sizeChanged = true; if (initialSizing) { mHasValidInnerSize = true; - } else if (screenSize == oldScreenSize) { + } else if (mInnerSize == size) { sizeChanged = false; } - ScreenIntRect screenRect = GetOuterRect(); - mWidget->Resize(screenRect.x + chromeDisp.x, screenRect.y + chromeDisp.y, - screenSize.width, screenSize.height, true); + mOrientation = orientation; + ScreenIntSize oldScreenSize = mInnerSize; + mInnerSize = size; + mWidget->Resize(rect.x + chromeDisp.x, rect.y + chromeDisp.y, size.width, size.height, + true); nsCOMPtr baseWin = do_QueryInterface(WebNavigation()); - baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, + baseWin->SetPositionAndSize(0, 0, size.width, size.height, true); if (initialSizing && mContentDocumentIsDisplayed) { - // If this is the first time we're getting a valid inner size, and the + // If this is the first time we're getting a valid mInnerSize, and the // before-first-paint event has already been handled, then we need to set // up our default viewport here. See the corresponding call to // InitializeRootMetrics in the before-first-paint handler. @@ -3252,7 +3244,6 @@ TabChild::RecvRequestNotifyAfterRemotePaint() bool TabChild::RecvUIResolutionChanged() { - ScreenIntSize oldScreenSize = GetInnerSize(); mDPI = 0; mDefaultScale = 0; static_cast(mWidget.get())->ClearBackingScaleCache(); @@ -3261,21 +3252,9 @@ TabChild::RecvUIResolutionChanged() if (presShell) { nsRefPtr presContext = presShell->GetPresContext(); if (presContext) { - presContext->UIResolutionChangedSync(); + presContext->UIResolutionChanged(); } } - - ScreenIntSize screenSize = GetInnerSize(); - if (mHasValidInnerSize && oldScreenSize != screenSize) { - ScreenIntRect screenRect = GetOuterRect(); - mWidget->Resize(screenRect.x + mChromeDisp.x, screenRect.y + mChromeDisp.y, - screenSize.width, screenSize.height, true); - - nsCOMPtr baseWin = do_QueryInterface(WebNavigation()); - baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, - true); - } - return true; } @@ -3337,22 +3316,6 @@ TabChild::CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut) return rv; } -ScreenIntSize -TabChild::GetInnerSize() -{ - LayoutDeviceIntSize innerSize = - RoundedToInt(mUnscaledInnerSize * mWidget->GetDefaultScale()); - return ViewAs(innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims); -}; - -ScreenIntRect -TabChild::GetOuterRect() -{ - LayoutDeviceIntRect outerRect = - RoundedToInt(mUnscaledOuterRect * mWidget->GetDefaultScale()); - return ViewAs(outerRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims); -} - TabChildGlobal::TabChildGlobal(TabChildBase* aTabChild) : mTabChild(aTabChild) { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index d980c93b458..38bc979302a 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -189,8 +189,6 @@ public: const bool& aIsRoot, const mozilla::layers::ZoomConstraints& aConstraints) = 0; - virtual ScreenIntSize GetInnerSize() = 0; - protected: virtual ~TabChildBase(); CSSSize GetPageSize(nsCOMPtr aDocument, const CSSSize& aViewport); @@ -224,6 +222,7 @@ protected: CSSSize mOldViewportSize; bool mContentDocumentIsDisplayed; nsRefPtr mTabChildGlobal; + ScreenIntSize mInnerSize; mozilla::layers::FrameMetrics mLastRootMetrics; nsCOMPtr mWebBrowserChrome; }; @@ -320,8 +319,8 @@ public: const uint64_t& aLayersId, PRenderFrameChild* aRenderFrame, const bool& aParentIsActive) override; - virtual bool RecvUpdateDimensions(const CSSRect& rect, - const CSSSize& size, + virtual bool RecvUpdateDimensions(const nsIntRect& rect, + const ScreenIntSize& size, const ScreenOrientation& orientation, const LayoutDeviceIntPoint& chromeDisp) override; virtual bool RecvUpdateFrame(const layers::FrameMetrics& aFrameMetrics) override; @@ -511,8 +510,6 @@ public: } bool AsyncPanZoomEnabled() { return mAsyncPanZoomEnabled; } - virtual ScreenIntSize GetInnerSize() override; - protected: virtual ~TabChild(); @@ -602,12 +599,6 @@ private: void SetTabId(const TabId& aTabId); - ScreenIntRect GetOuterRect(); - - void SetUnscaledInnerSize(const CSSSize& aSize) { - mUnscaledInnerSize = aSize; - } - class CachedFileDescriptorInfo; class CachedFileDescriptorCallbackRunnable; class DelayedDeleteRunnable; @@ -620,7 +611,7 @@ private: nsRefPtr mManager; uint32_t mChromeFlags; uint64_t mLayersId; - CSSRect mUnscaledOuterRect; + nsIntRect mOuterRect; // When we're tracking a possible tap gesture, this is the "down" // point of the touchstart. LayoutDevicePoint mGestureDownPoint; @@ -655,7 +646,6 @@ private: bool mIPCOpen; bool mParentIsActive; bool mAsyncPanZoomEnabled; - CSSSize mUnscaledInnerSize; DISALLOW_EVIL_CONSTRUCTORS(TabChild); }; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 169e20814ae..8482d64d976 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -90,7 +90,6 @@ #include "nsPIWindowRoot.h" #include "gfxDrawable.h" #include "ImageOps.h" -#include "UnitTransforms.h" #include using namespace mozilla::dom; @@ -334,27 +333,9 @@ TabParent::SetOwnerElement(Element* aElement) // If we held previous content then unregister for its events. RemoveWindowListeners(); - // If we change top-level documents then we need to change our - // registration with them. - nsRefPtr curTopLevelWin, newTopLevelWin; - if (mFrameElement) { - curTopLevelWin = nsContentUtils::GetWindowRoot(mFrameElement->OwnerDoc()); - } - if (aElement) { - newTopLevelWin = nsContentUtils::GetWindowRoot(aElement->OwnerDoc()); - } - bool isSameTopLevelWin = curTopLevelWin == newTopLevelWin; - if (curTopLevelWin && !isSameTopLevelWin) { - curTopLevelWin->RemoveBrowser(this); - } - // Update to the new content, and register to listen for events from it. mFrameElement = aElement; - if (newTopLevelWin && !isSameTopLevelWin) { - newTopLevelWin->AddBrowser(this); - } - AddWindowListeners(); TryCacheDPIAndScale(); } @@ -985,21 +966,7 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size) mOrientation = orientation; mChromeOffset = chromeOffset; - CSSToLayoutDeviceScale widgetScale; - if (widget) { - widgetScale = widget->GetDefaultScale(); - } - - LayoutDeviceIntRect devicePixelRect = - ViewAs(mRect, - PixelCastJustification::LayoutDeviceIsScreenForTabDims); - LayoutDeviceIntSize devicePixelSize = - ViewAs(mDimensions.ToUnknownSize(), - PixelCastJustification::LayoutDeviceIsScreenForTabDims); - - CSSRect unscaledRect = devicePixelRect / widgetScale; - CSSSize unscaledSize = devicePixelSize / widgetScale; - unused << SendUpdateDimensions(unscaledRect, unscaledSize, orientation, chromeOffset); + unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, mChromeOffset); } } @@ -1018,7 +985,6 @@ TabParent::UIResolutionChanged() // TryCacheDPIAndScale()'s cache is keyed off of // mDPI being greater than 0, so this invalidates it. mDPI = -1; - TryCacheDPIAndScale(); unused << SendUIResolutionChanged(); } } diff --git a/layout/base/UnitTransforms.h b/layout/base/UnitTransforms.h index 63f78c4463f..37485510530 100644 --- a/layout/base/UnitTransforms.h +++ b/layout/base/UnitTransforms.h @@ -37,10 +37,7 @@ enum class PixelCastJustification : uint8_t { // technically in screen pixels, as it has not yet accounted for any // asynchronous transforms. This justification is for viewing the initial // reference point as a screen point. - LayoutDeviceToScreenForUntransformedEvent, - // Similar to LayoutDeviceToScreenForUntransformedEvent, PBrowser handles - // some widget/tab dimension information as the OS does -- in screen units. - LayoutDeviceIsScreenForTabDims + LayoutDeviceToScreenForUntransformedEvent }; template diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index d1f42fa799e..ca100444300 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1798,15 +1798,6 @@ nsPresContext::UIResolutionChanged() } } -void -nsPresContext::UIResolutionChangedSync() -{ - if (!mPendingUIResolutionChanged) { - mPendingUIResolutionChanged = true; - UIResolutionChangedInternal(); - } -} - /*static*/ bool nsPresContext::UIResolutionChangedSubdocumentCallback(nsIDocument* aDocument, void* aData) @@ -1822,24 +1813,9 @@ nsPresContext::UIResolutionChangedSubdocumentCallback(nsIDocument* aDocument, } static void -NotifyTabUIResolutionChanged(TabParent* aTab, void *aArg) +NotifyUIResolutionChanged(TabParent* aTabParent, void* aArg) { - aTab->UIResolutionChanged(); -} - -static void -NotifyChildrenUIResolutionChanged(nsIDOMWindow* aWindow) -{ - nsCOMPtr piWin = do_QueryInterface(aWindow); - if (!piWin) { - return; - } - nsCOMPtr doc = piWin->GetExtantDoc(); - nsRefPtr topLevelWin = nsContentUtils::GetWindowRoot(doc); - if (!topLevelWin) { - return; - } - topLevelWin->EnumerateBrowsers(NotifyTabUIResolutionChanged, nullptr); + aTabParent->UIResolutionChanged(); } void @@ -1852,8 +1828,10 @@ nsPresContext::UIResolutionChangedInternal() AppUnitsPerDevPixelChanged(); } - // Recursively notify all remote leaf descendants of the change. - NotifyChildrenUIResolutionChanged(mDocument->GetWindow()); + // Recursively notify all remote leaf descendants that the + // resolution of the user interface has changed. + nsContentUtils::CallOnAllRemoteChildren(mDocument->GetWindow(), + NotifyUIResolutionChanged, nullptr); mDocument->EnumerateSubDocuments(UIResolutionChangedSubdocumentCallback, nullptr); diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index a3ede02d9ef..e072c96e9ab 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -791,15 +791,9 @@ public: * Notify the pres context that the resolution of the user interface has * changed. This happens if a window is moved between HiDPI and non-HiDPI * displays, so that the ratio of points to device pixels changes. - * The notification happens asynchronously. */ void UIResolutionChanged(); - /* - * Like UIResolutionChanged() but invalidates values immediately. - */ - void UIResolutionChangedSync(); - /* * Notify the pres context that a system color has changed */