commit 1d93d8f2aefe636d33f04b1664b032bf0f7af726 parent 0bcf09bf79d82b0628078a17c087e0c87128bd3d Author: Emilio Cobos Álvarez <emilio@crisal.io> Date: Fri, 28 Nov 2025 15:04:37 +0000 Bug 337801 - Rename nsView to PresShellWidgetListener, and remove the view/ dir. r=jwatt Since that's what it does now. Also clean-up a little bit while at it. Differential Revision: https://phabricator.services.mozilla.com/D274410 Diffstat:
24 files changed, 425 insertions(+), 622 deletions(-)
diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp @@ -59,7 +59,6 @@ #include "nsPresContext.h" #include "nsIFrame.h" #include "nsTextFrame.h" -#include "nsView.h" #include "nsIDocShellTreeItem.h" #include "nsStyleStructInlines.h" #include "nsFocusManager.h" diff --git a/accessible/ios/RootAccessibleWrap.mm b/accessible/ios/RootAccessibleWrap.mm @@ -13,7 +13,6 @@ #include "nsCOMPtr.h" #include "nsObjCExceptions.h" #include "nsIFrame.h" -#include "nsView.h" #include "nsIWidget.h" using namespace mozilla; diff --git a/accessible/mac/RootAccessibleWrap.mm b/accessible/mac/RootAccessibleWrap.mm @@ -13,7 +13,6 @@ #include "nsCOMPtr.h" #include "nsObjCExceptions.h" #include "nsIFrame.h" -#include "nsView.h" #include "nsIWidget.h" using namespace mozilla; diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp @@ -20,6 +20,7 @@ #include "mozilla/Components.h" #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" +#include "mozilla/PresShellWidgetListener.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/RefPtr.h" #include "mozilla/StaticPrefs_browser.h" @@ -66,7 +67,6 @@ #include "nsSandboxFlags.h" #include "nsString.h" #include "nsStringFwd.h" -#include "nsView.h" #include "nsWidgetsCID.h" using namespace mozilla; using namespace mozilla::css; @@ -914,7 +914,7 @@ nsresult nsContentSink::WillParseImpl(void) { uint32_t currentTime = PR_IntervalToMicroseconds(PR_IntervalNow()); if (StaticPrefs::content_sink_enable_perf_mode() == 0) { - uint32_t lastEventTime = nsView::GetLastUserEventTime(); + uint32_t lastEventTime = PresShellWidgetListener::GetLastUserEventTime(); bool newDynLower = mDocument->IsInBackgroundWindow() || ((currentTime - mBeginLoadTime) > StaticPrefs::content_sink_initial_perf_time() && diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp @@ -983,7 +983,6 @@ bool nsFrameLoader::Show(nsSubDocumentFrame* aFrame) { } } aFrame->EnsureEmbeddingPresShell(presShell); - MOZ_DIAGNOSTIC_ASSERT(presShell->GetRootView()); } RefPtr<nsDocShell> baseWindow = GetDocShell(); diff --git a/dom/xul/ChromeObserver.cpp b/dom/xul/ChromeObserver.cpp @@ -15,7 +15,6 @@ #include "nsIMutationObserver.h" #include "nsIWidget.h" #include "nsPresContext.h" -#include "nsView.h" #include "nsXULElement.h" namespace mozilla::dom { diff --git a/gfx/layers/ipc/SharedSurfacesChild.cpp b/gfx/layers/ipc/SharedSurfacesChild.cpp @@ -17,7 +17,6 @@ #include "mozilla/StaticPrefs_image.h" #include "mozilla/PresShell.h" #include "nsRefreshDriver.h" -#include "nsView.h" namespace mozilla { namespace layers { diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp @@ -17,6 +17,7 @@ #include "OverflowChangedTracker.h" #include "PLDHashTable.h" #include "PositionedEventTargeting.h" +#include "PresShellWidgetListener.h" #include "ScrollSnap.h" #include "StickyScrollContainer.h" #include "Units.h" @@ -197,7 +198,6 @@ #include "nsTransitionManager.h" #include "nsTreeBodyFrame.h" #include "nsTreeColumns.h" -#include "nsView.h" #include "nsViewportInfo.h" #include "nsWindowSizes.h" #include "nsXPCOM.h" @@ -784,17 +784,16 @@ PresShell::~PresShell() { } /** - * Initialize the presentation shell. Create view manager and style - * manager. + * Initialize the presentation shell. * Note this can't be merged into our constructor because caret initialization * calls AddRef() on us. */ void PresShell::Init(nsPresContext* aPresContext) { MOZ_ASSERT(mDocument); MOZ_ASSERT(aPresContext); - MOZ_ASSERT(!mRootView, "Already initialized"); + MOZ_ASSERT(!mWidgetListener, "Already initialized"); - mRootView = MakeUnique<nsView>(this); + mWidgetListener = MakeUnique<PresShellWidgetListener>(this); // mDocument is now set. It might have a display document whose "need layout/ // style" flush flags are not set, but ours will be set. To keep these @@ -1254,7 +1253,7 @@ void PresShell::Destroy() { mAccessibleCaretEventHub = nullptr; } - mRootView = nullptr; + mWidgetListener = nullptr; if (mPresContext) { // We hold a reference to the pres context, and it holds a weak link back @@ -3802,7 +3801,7 @@ void PresShell::ScrollFrameIntoVisualViewport(Maybe<nsPoint>& aDestination, // Offset the position:fixed element position by the layout scroll // position because the position:fixed origin (0, 0) is the layout scroll // position. Otherwise if we've already scrolled, this scrollIntoView - // operaiton will jump back to near (0, 0) position. + // operation will jump back to near (0, 0) position. // Bug 1947470: We need to calculate the destination with `WhereToScroll` // options. const nsPoint layoutOffset = rootScrollContainer->GetScrollPosition(); @@ -4392,7 +4391,7 @@ void PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush) { } MOZ_DIAGNOSTIC_ASSERT(!mIsDestroying || !isSafeToFlush); - MOZ_DIAGNOSTIC_ASSERT(mIsDestroying || mRootView); + MOZ_DIAGNOSTIC_ASSERT(mIsDestroying || mWidgetListener); MOZ_DIAGNOSTIC_ASSERT(mIsDestroying || mDocument->HasShellOrBFCacheEntry()); if (!isSafeToFlush) { @@ -5635,10 +5634,7 @@ nsIWidget* PresShell::GetNearestWidget() const { } nsIWidget* PresShell::GetOwnWidget() const { - if (mRootView) { - return mRootView->GetWidget(); - } - return nullptr; + return mWidgetListener ? mWidgetListener->GetWidget() : nullptr; } bool PresShell::AsyncPanZoomEnabled() { @@ -8625,7 +8621,7 @@ nsIFrame* PresShell::EventHandler::ComputeRootFrameToHandleEventWithPopup( nsPresContext* rootPresContext = framePresContext->GetRootPresContext(); NS_ASSERTION(rootPresContext == GetPresContext()->GetRootPresContext(), "How did we end up outside the connected " - "prescontext/viewmanager hierarchy?"); + "prescontext hierarchy?"); nsIFrame* popupFrame = nsLayoutUtils::GetPopupFrameForEventCoordinates( rootPresContext, aGUIEvent); if (!popupFrame) { @@ -10115,8 +10111,8 @@ void PresShell::WillPaint() { // check mIsActive before making any of the more expensive calls such // as GetRootPresContext, for the case of a browser with a large // number of tabs. - // Don't bother doing anything if some viewmanager in our tree is painting - // while we still have painting suppressed or we are not active. + // Don't bother doing anything if we still have painting suppressed or we are + // not active. if (!mIsActive || mPaintingSuppressed || !IsVisible()) { return; } @@ -11984,7 +11980,7 @@ void PresShell::MaybeRecreateMobileViewportManager(bool aAfterInitialization) { if (mMobileViewportManager) { mMobileViewportManager->SetInitialViewport(); } else { - // Force a reflow to our correct view manager size. + // Force a reflow to our correct layout viewport size. ForceResizeReflowWithCurrentDimensions(); } // After we clear out the MVM and the MVMContext, also reset the diff --git a/layout/base/PresShell.h b/layout/base/PresShell.h @@ -77,7 +77,6 @@ class nsRefreshDriver; class nsRegion; class nsTextFrame; class nsSubDocumentFrame; -class nsView; class nsWindowSizes; class WeakFrame; class ZoomConstraintsClient; @@ -95,6 +94,7 @@ class GeckoMVMContext; class nsDisplayList; class nsDisplayListBuilder; class OverflowChangedTracker; +class PresShellWidgetListener; class ProfileChunkedBuffer; class ScrollContainerFrame; class StyleSheet; @@ -311,7 +311,9 @@ class PresShell final : public nsStubDocumentObserver, */ PresShell* GetRootPresShell() const; - nsView* GetRootView() const { return mRootView.get(); } + PresShellWidgetListener* GetWidgetListener() const { + return mWidgetListener.get(); + } nsRefreshDriver* GetRefreshDriver() const; @@ -3204,8 +3206,7 @@ class PresShell final : public nsStubDocumentObserver, MOZ_KNOWN_LIVE RefPtr<nsPresContext> const mPresContext; UniquePtr<nsCSSFrameConstructor> mFrameConstructor; // The object responsible for listening to widget events. - // TODO(emilio): Find a better name or remove altogether. - UniquePtr<nsView> mRootView; + UniquePtr<PresShellWidgetListener> mWidgetListener; RefPtr<nsFrameSelection> mSelection; // The frame selection that last took focus on this shell, which we need to // hide if we focus another selection. May or may not be the same as diff --git a/layout/base/PresShellWidgetListener.cpp b/layout/base/PresShellWidgetListener.cpp @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "PresShellWidgetListener.h" + +#include "WindowRenderer.h" +#include "mozilla/BasicEvents.h" +#include "mozilla/PresShell.h" +#include "mozilla/StartupTimeline.h" +#include "mozilla/StaticPrefs_layout.h" +#include "mozilla/dom/BrowserParent.h" +#include "mozilla/dom/Document.h" +#include "mozilla/widget/Screen.h" +#include "nsContentUtils.h" // for nsAutoScriptBlocker +#include "nsDeviceContext.h" +#include "nsDocShell.h" +#include "nsIFrame.h" +#include "nsIWidget.h" +#include "nsIWidgetListener.h" +#include "nsLayoutUtils.h" +#include "nsXULPopupManager.h" + +using namespace mozilla; +using namespace mozilla::widget; + +static uint32_t gLastUserEventTime = 0; +static void MaybeUpdateLastUserEventTime(WidgetGUIEvent* aEvent) { + WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); + if ((mouseEvent && + // Ignore mouse events that we synthesize. + mouseEvent->mReason == WidgetMouseEvent::eReal && + // Ignore mouse exit and enter (we'll get moves if the user + // is really moving the mouse) since we get them when we + // create and destroy widgets. + mouseEvent->mMessage != eMouseExitFromWidget && + mouseEvent->mMessage != eMouseEnterIntoWidget) || + aEvent->HasKeyEventMessage() || aEvent->HasIMEEventMessage()) { + gLastUserEventTime = PR_IntervalToMicroseconds(PR_IntervalNow()); + } +} + +uint32_t PresShellWidgetListener::GetLastUserEventTime() { + return gLastUserEventTime; +} + +PresShellWidgetListener::PresShellWidgetListener(PresShell* aPs) + : mPresShell(aPs) { + MOZ_COUNT_CTOR(PresShellWidgetListener); +} + +PresShellWidgetListener::~PresShellWidgetListener() { + MOZ_COUNT_DTOR(PresShellWidgetListener); + + if (mPreviousWindow) { + mPreviousWindow->SetPreviouslyAttachedWidgetListener(nullptr); + } + + // Destroy and release the widget + DetachWidget(); +} + +void PresShellWidgetListener::DetachWidget() { + if (mWindow) { + mWindow->SetAttachedWidgetListener(nullptr); + mWindow = nullptr; + } +} + +// Attach to a top level widget and start receiving mirrored events. +void PresShellWidgetListener::AttachToTopLevelWidget(nsIWidget* aWidget) { + MOZ_ASSERT(aWidget, "null widget ptr"); + MOZ_ASSERT(!aWidget->GetWidgetListener() || + aWidget->GetWidgetListener()->GetAppWindow(), + "Expect a top level widget"); + + /// XXXjimm This is a temporary workaround to an issue w/document + // viewer (bug 513162). + if (nsIWidgetListener* listener = aWidget->GetAttachedWidgetListener()) { + if (auto* old = listener->GetAsPresShellWidgetListener()) { + old->DetachFromTopLevelWidget(); + } + } + + mWindow = aWidget; + + mWindow->SetAttachedWidgetListener(this); + if (mWindow->GetWindowType() != WindowType::Invisible) { + mWindow->AsyncEnableDragDrop(true); + } +} + +// Detach us from an attached widget. +void PresShellWidgetListener::DetachFromTopLevelWidget() { + MOZ_ASSERT(mWindow, "null mWindow for DetachFromTopLevelWidget!"); + + mWindow->SetAttachedWidgetListener(nullptr); + if (nsIWidgetListener* listener = + mWindow->GetPreviouslyAttachedWidgetListener()) { + if (auto* previousListener = listener->GetAsPresShellWidgetListener()) { + // Ensure the listener doesn't think it's being used anymore + previousListener->mPreviousWindow = nullptr; + } + } + + // If the new pres shell is paint suppressed then the window + // will want to use us instead until that's done + mWindow->SetPreviouslyAttachedWidgetListener(this); + mPreviousWindow = std::move(mWindow); + MOZ_ASSERT(!mWindow); +} + +PresShell* PresShellWidgetListener::GetPresShell() { return mPresShell; } + +bool PresShellWidgetListener::WindowResized(nsIWidget* aWidget, int32_t aWidth, + int32_t aHeight) { + RefPtr<PresShell> ps = GetPresShell(); + if (!ps) { + return false; + } + + nsPresContext* pc = ps->GetPresContext(); + if (!pc) { + return false; + } + + // ensure DPI is up-to-date, in case of window being opened and sized + // on a non-default-dpi display (bug 829963) + pc->DeviceContext()->CheckDPIChange(); + int32_t p2a = pc->AppUnitsPerDevPixel(); + if (auto* frame = ps->GetRootFrame()) { + // Usually the resize would deal with this, but there are some cases (like + // web-extension popups) where frames might already be correctly sized etc + // due to a call to e.g. nsDocumentViewer::GetContentSize or so. + frame->InvalidateFrame(); + } + const LayoutDeviceIntSize size(aWidth, aHeight); + ps->SetLayoutViewportSize(LayoutDeviceIntSize::ToAppUnits(size, p2a), + /* aDelay = */ false); + + if (nsXULPopupManager* pm = nsXULPopupManager::GetInstance()) { + pm->AdjustPopupsOnWindowChange(ps); + } + + return true; +} + +void PresShellWidgetListener::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) { + MOZ_ASSERT(XRE_IsParentProcess(), + "Should be only called for the browser parent process"); + CallOnAllRemoteChildren( + [aHeight](dom::BrowserParent* aBrowserParent) -> CallState { + aBrowserParent->DynamicToolbarMaxHeightChanged(aHeight); + return CallState::Continue; + }); +} + +void PresShellWidgetListener::DynamicToolbarOffsetChanged(ScreenIntCoord aOffset) { + MOZ_ASSERT(XRE_IsParentProcess(), + "Should be only called for the browser parent process"); + CallOnAllRemoteChildren( + [aOffset](dom::BrowserParent* aBrowserParent) -> CallState { + // Skip background tabs. + if (!aBrowserParent->GetDocShellIsActive()) { + return CallState::Continue; + } + + aBrowserParent->DynamicToolbarOffsetChanged(aOffset); + return CallState::Stop; + }); +} + +void PresShellWidgetListener::KeyboardHeightChanged(ScreenIntCoord aHeight) { + MOZ_ASSERT(XRE_IsParentProcess(), + "Should be only called for the browser parent process"); +#ifdef MOZ_WIDGET_ANDROID + CallOnAllRemoteChildren( + [aHeight](dom::BrowserParent* aBrowserParent) -> CallState { + // Skip background tabs. + if (!aBrowserParent->GetDocShellIsActive()) { + return CallState::Continue; + } + + aBrowserParent->KeyboardHeightChanged(aHeight); + return CallState::Stop; + }); +#endif +} + +void PresShellWidgetListener::AndroidPipModeChanged(bool aPipMode) { + MOZ_ASSERT(XRE_IsParentProcess(), + "Should be only called for the browser parent process"); +#ifdef MOZ_WIDGET_ANDROID + CallOnAllRemoteChildren( + [aPipMode](dom::BrowserParent* aBrowserParent) -> CallState { + aBrowserParent->AndroidPipModeChanged(aPipMode); + return CallState::Continue; + }); +#endif +} + +void PresShellWidgetListener::PaintWindow(nsIWidget* aWidget) { + RefPtr ps = GetPresShell(); + if (!ps) { + return; + } + RefPtr renderer = aWidget->GetWindowRenderer(); + if (!renderer->NeedsWidgetInvalidation()) { + ps->PaintSynchronously(); + renderer->FlushRendering(wr::RenderReasons::WIDGET); + } else { + ps->SyncPaintFallback(ps->GetRootFrame(), renderer); + } + mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT); + ps->DidPaintWindow(); +} + +void PresShellWidgetListener::DidCompositeWindow( + mozilla::layers::TransactionId aTransactionId, + const TimeStamp& aCompositeStart, const TimeStamp& aCompositeEnd) { + PresShell* presShell = GetPresShell(); + if (!presShell) { + return; + } + + nsAutoScriptBlocker scriptBlocker; + + nsPresContext* context = presShell->GetPresContext(); + nsRootPresContext* rootContext = context->GetRootPresContext(); + if (rootContext) { + rootContext->NotifyDidPaintForSubtree(aTransactionId, aCompositeEnd); + } + + mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT2, + aCompositeEnd); +} + +nsEventStatus PresShellWidgetListener::HandleEvent(WidgetGUIEvent* aEvent) { + MOZ_ASSERT(aEvent->mWidget, "null widget ptr"); + + nsEventStatus result = nsEventStatus_eIgnore; + MaybeUpdateLastUserEventTime(aEvent); + if (RefPtr<PresShell> ps = GetPresShell()) { + if (nsIFrame* root = ps->GetRootFrame()) { + ps->HandleEvent(root, aEvent, false, &result); + } + } + return result; +} + +void PresShellWidgetListener::SafeAreaInsetsChanged( + const LayoutDeviceIntMargin& aSafeAreaInsets) { + PresShell* presShell = GetPresShell(); + if (!presShell) { + return; + } + + LayoutDeviceIntMargin windowSafeAreaInsets; + const LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds(); + if (nsCOMPtr<nsIScreen> screen = mWindow->GetWidgetScreen()) { + windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( + screen, aSafeAreaInsets, windowRect); + } + + presShell->GetPresContext()->SetSafeAreaInsets(windowSafeAreaInsets); + + // https://github.com/w3c/csswg-drafts/issues/4670 + // Actually we don't set this value on sub document. This behaviour is + // same as Blink. + CallOnAllRemoteChildren( + [windowSafeAreaInsets](dom::BrowserParent* aBrowserParent) -> CallState { + (void)aBrowserParent->SendSafeAreaInsetsChanged(windowSafeAreaInsets); + return CallState::Continue; + }); +} + +bool PresShellWidgetListener::IsPrimaryFramePaintSuppressed() const { + return StaticPrefs::layout_show_previous_page() && mPresShell && + mPresShell->IsPaintingSuppressed(); +} + +void PresShellWidgetListener::CallOnAllRemoteChildren( + const std::function<CallState(dom::BrowserParent*)>& aCallback) { + PresShell* presShell = GetPresShell(); + if (!presShell) { + return; + } + + dom::Document* document = presShell->GetDocument(); + if (!document) { + return; + } + + nsPIDOMWindowOuter* window = document->GetWindow(); + if (!window) { + return; + } + + nsContentUtils::CallOnAllRemoteChildren(window, aCallback); +} diff --git a/layout/base/PresShellWidgetListener.h b/layout/base/PresShellWidgetListener.h @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_PresShellWidgetListener_h__ +#define mozilla_PresShellWidgetListener_h__ + +#include "Units.h" +#include "mozilla/Attributes.h" +#include "mozilla/CallState.h" +#include "nsCOMPtr.h" +#include "nsIWidgetListener.h" + +class nsIWidget; + +namespace mozilla { +class PresShell; +namespace dom { +class BrowserParent; +} // namespace dom +namespace widget { +struct InitData; +enum class TransparencyMode : uint8_t; +enum class WindowType : uint8_t; +} // namespace widget + +class PresShellWidgetListener final : public nsIWidgetListener { + public: + // Stops listening to mWidget and clears it. + void DetachWidget(); + + /** + * Attach/detach a top level widget. Attaching allows the shell to begin + * receiving gecko events. The underlying base window associated with the + * widget will continues to receive events it expects. + * + * An attached widget will not be destroyed when we are destroyed, + * allowing the recycling of a single top level widget over multiple pres + * shells. + * + * @param aWidget The widget to attach to / detach from. + */ + void AttachToTopLevelWidget(nsIWidget* aWidget); + void DetachFromTopLevelWidget(); + + static uint32_t GetLastUserEventTime(); + + nsIWidget* GetWidget() const { return mWindow; } + bool HasWidget() const { return !!mWindow; } + + // nsIWidgetListener + mozilla::PresShell* GetPresShell() override; + PresShellWidgetListener* GetAsPresShellWidgetListener() override { + return this; + } + bool IsPaintSuppressed() const override { + return IsPrimaryFramePaintSuppressed(); + } + bool WindowResized(nsIWidget* aWidget, int32_t aWidth, + int32_t aHeight) override; + void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight) override; + void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset) override; + void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight) override; + void AndroidPipModeChanged(bool) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + void PaintWindow(nsIWidget* aWidget) override; + void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId, + const mozilla::TimeStamp& aCompositeStart, + const mozilla::TimeStamp& aCompositeEnd) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + nsEventStatus HandleEvent(mozilla::WidgetGUIEvent*) override; + void SafeAreaInsetsChanged(const mozilla::LayoutDeviceIntMargin&) override; + + explicit PresShellWidgetListener(mozilla::PresShell*); + virtual ~PresShellWidgetListener(); + + bool IsPrimaryFramePaintSuppressed() const; + + private: + void CallOnAllRemoteChildren( + const std::function<mozilla::CallState(mozilla::dom::BrowserParent*)>& + aCallback); + + mozilla::PresShell* mPresShell = nullptr; + nsCOMPtr<nsIWidget> mWindow; + nsCOMPtr<nsIWidget> mPreviousWindow; +}; + +} // namespace mozilla + +#endif diff --git a/layout/base/ZoomConstraintsClient.cpp b/layout/base/ZoomConstraintsClient.cpp @@ -22,7 +22,6 @@ #include "nsIFrame.h" #include "nsLayoutUtils.h" #include "nsPoint.h" -#include "nsView.h" #include "nsViewportInfo.h" static mozilla::LazyLogModule sApzZoomLog("apz.zoom"); diff --git a/layout/base/moz.build b/layout/base/moz.build @@ -75,6 +75,7 @@ EXPORTS.mozilla += [ "PresShell.h", "PresShellForwards.h", "PresShellInlines.h", + "PresShellWidgetListener.h", "RelativeTo.h", "RenderingPhase.h", "ScrollStyles.h", @@ -118,6 +119,7 @@ UNIFIED_SOURCES += [ "nsRefreshObservers.cpp", "PositionedEventTargeting.cpp", "PresShell.cpp", + "PresShellWidgetListener.cpp", "ScrollStyles.cpp", "ShapeUtils.cpp", "StackArena.cpp", @@ -151,7 +153,6 @@ LOCAL_INCLUDES += [ "/dom/html", "/dom/svg", "/dom/xul", - "/view", ] if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp @@ -8,22 +8,18 @@ #include "gfxContext.h" #include "mozilla/PresShell.h" +#include "mozilla/PresShellWidgetListener.h" #include "mozilla/RestyleManager.h" #include "mozilla/ServoStyleSet.h" -#include "mozilla/StaticPrefs_print.h" #include "mozilla/dom/AutoSuppressEventHandlingAndSuspend.h" #include "mozilla/dom/BeforeUnloadEvent.h" #include "mozilla/dom/BrowsingContext.h" -#include "mozilla/dom/ContentChild.h" -#include "mozilla/dom/DocGroup.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/FragmentDirective.h" #include "mozilla/dom/PopupBlocker.h" #include "mozilla/dom/Selection.h" -#include "mozilla/widget/Screen.h" #include "nsCOMPtr.h" -#include "nsCRT.h" #include "nsContentUtils.h" #include "nsDeviceContext.h" #include "nsFrameSelection.h" @@ -34,10 +30,8 @@ #include "nsIFrame.h" #include "nsIScreen.h" #include "nsISelectionListener.h" -#include "nsIWritablePropertyBag2.h" #include "nsPresContext.h" #include "nsReadableUtils.h" -#include "nsString.h" #include "nsStubMutationObserver.h" #include "nsSubDocumentFrame.h" #include "nsThreadUtils.h" @@ -89,7 +83,6 @@ #include "nsPageSequenceFrame.h" #include "nsSandboxFlags.h" #include "nsStyleSheetService.h" -#include "nsView.h" #include "nsXULPopupManager.h" //-------------------------- @@ -2136,9 +2129,9 @@ nsDocumentViewer::ClearHistoryEntry() { void nsDocumentViewer::DetachFromTopLevelWidget() { if (mPresShell) { - nsView* oldView = mPresShell->GetRootView(); - if (oldView && oldView->HasWidget()) { - oldView->DetachFromTopLevelWidget(); + if (auto* listener = mPresShell->GetWidgetListener(); + listener && listener->HasWidget()) { + listener->DetachFromTopLevelWidget(); } } } @@ -2146,8 +2139,8 @@ void nsDocumentViewer::DetachFromTopLevelWidget() { void nsDocumentViewer::AttachToTopLevelWidget() { DetachFromTopLevelWidget(); if (mPresShell && mParentWidget) { - nsView* view = mPresShell->GetRootView(); - view->AttachToTopLevelWidget(mParentWidget); + auto* listener = mPresShell->GetWidgetListener(); + listener->AttachToTopLevelWidget(mParentWidget); mWindow = mParentWidget; } } diff --git a/layout/build/moz.build b/layout/build/moz.build @@ -52,7 +52,6 @@ LOCAL_INCLUDES += [ "/netwerk/cookie", "/parser/htmlparser", "/toolkit/components/sessionstore", - "/view", ] if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp @@ -63,7 +63,6 @@ #include "nsStyleStructInlines.h" #include "nsTransitionManager.h" #include "nsUnicharUtils.h" -#include "nsView.h" #include "nsWidgetsCID.h" #include "nsXULPopupManager.h" diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild @@ -105,7 +105,6 @@ DIRS += [ "/gfx", "/image", "/dom", - "/view", "/widget", "/editor", "/layout", diff --git a/view/moz.build b/view/moz.build @@ -1,20 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -with Files("**"): - BUG_COMPONENT = ("Core", "Web Painting") - -EXPORTS += [ - "nsView.h", -] - -UNIFIED_SOURCES += [ - "nsView.cpp", -] - -include("/ipc/chromium/chromium-config.mozbuild") - -FINAL_LIBRARY = "xul" diff --git a/view/nsView.cpp b/view/nsView.cpp @@ -1,327 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsView.h" - -#include "nsDeviceContext.h" -#include "mozilla/BasicEvents.h" -#include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/Poison.h" -#include "mozilla/PresShell.h" -#include "mozilla/StaticPrefs_layout.h" -#include "mozilla/dom/Document.h" -#include "mozilla/dom/BrowserParent.h" -#include "mozilla/widget/Screen.h" -#include "nsIWidget.h" -#include "nsIFrame.h" -#include "nsXULPopupManager.h" -#include "nsIWidgetListener.h" -#include "nsContentUtils.h" // for nsAutoScriptBlocker -#include "nsDocShell.h" -#include "nsLayoutUtils.h" -#include "WindowRenderer.h" -#include "mozilla/StartupTimeline.h" - -using namespace mozilla; -using namespace mozilla::widget; - -static uint32_t gLastUserEventTime = 0; -static void MaybeUpdateLastUserEventTime(WidgetGUIEvent* aEvent) { - WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); - if ((mouseEvent && - // Ignore mouse events that we synthesize. - mouseEvent->mReason == WidgetMouseEvent::eReal && - // Ignore mouse exit and enter (we'll get moves if the user - // is really moving the mouse) since we get them when we - // create and destroy widgets. - mouseEvent->mMessage != eMouseExitFromWidget && - mouseEvent->mMessage != eMouseEnterIntoWidget) || - aEvent->HasKeyEventMessage() || aEvent->HasIMEEventMessage()) { - gLastUserEventTime = PR_IntervalToMicroseconds(PR_IntervalNow()); - } -} - -uint32_t nsView::GetLastUserEventTime() { return gLastUserEventTime; } - -nsView::nsView(PresShell* aPs) : mPresShell(aPs) { MOZ_COUNT_CTOR(nsView); } - -nsView::~nsView() { - MOZ_COUNT_DTOR(nsView); - - if (mPreviousWindow) { - mPreviousWindow->SetPreviouslyAttachedWidgetListener(nullptr); - } - - // Destroy and release the widget - DetachWidget(); -} - -void nsView::DetachWidget() { - if (mWindow) { - // If we are not attached to a base window, we're going to tear down our - // widget here. However, if we're attached to somebody elses widget, we - // want to leave the widget alone: don't reset the client data or call - // Destroy. Just clear our event view ptr and free our reference to it. - mWindow->SetAttachedWidgetListener(nullptr); - mWindow = nullptr; - } -} - -void nsView::Destroy() { - this->~nsView(); - mozWritePoison(this, sizeof(*this)); - nsView::operator delete(this); -} - -// Attach to a top level widget and start receiving mirrored events. -void nsView::AttachToTopLevelWidget(nsIWidget* aWidget) { - MOZ_ASSERT(aWidget, "null widget ptr"); -#ifdef DEBUG - nsIWidgetListener* parentListener = aWidget->GetWidgetListener(); - MOZ_ASSERT(!parentListener || parentListener->GetAppWindow(), - "Expect a top level widget"); - MOZ_ASSERT(!parentListener || !parentListener->GetAsMenuPopupFrame(), - "Expect a top level widget"); -#endif - - /// XXXjimm This is a temporary workaround to an issue w/document - // viewer (bug 513162). - if (nsIWidgetListener* listener = aWidget->GetAttachedWidgetListener()) { - if (nsView* oldView = listener->GetView()) { - oldView->DetachFromTopLevelWidget(); - } - } - - mWindow = aWidget; - - mWindow->SetAttachedWidgetListener(this); - if (mWindow->GetWindowType() != WindowType::Invisible) { - mWindow->AsyncEnableDragDrop(true); - } -} - -// Detach this view from an attached widget. -void nsView::DetachFromTopLevelWidget() { - MOZ_ASSERT(mWindow, "null mWindow for DetachFromTopLevelWidget!"); - - mWindow->SetAttachedWidgetListener(nullptr); - if (nsIWidgetListener* listener = - mWindow->GetPreviouslyAttachedWidgetListener()) { - if (nsView* view = listener->GetView()) { - // Ensure the listener doesn't think it's being used anymore - view->mPreviousWindow = nullptr; - } - } - - // If the new view's frame is paint suppressed then the window - // will want to use us instead until that's done - mWindow->SetPreviouslyAttachedWidgetListener(this); - - mPreviousWindow = mWindow; - mWindow = nullptr; -} - -#ifdef DEBUG -void nsView::List(FILE* out, int32_t aIndent) const { - int32_t i; - for (i = aIndent; --i >= 0;) fputs(" ", out); - fprintf(out, "%p ", (void*)this); - if (mWindow) { - nsrefcnt widgetRefCnt = mWindow.get()->AddRef() - 1; - mWindow.get()->Release(); - fprintf(out, "(widget=%p[%" PRIuPTR "] pos=%s) ", (void*)mWindow, - widgetRefCnt, ToString(mWindow->GetBounds()).c_str()); - } - for (i = aIndent; --i >= 0;) fputs(" ", out); - fputs(">\n", out); -} -#endif // DEBUG - -PresShell* nsView::GetPresShell() { return mPresShell; } - -bool nsView::WindowResized(nsIWidget* aWidget, int32_t aWidth, - int32_t aHeight) { - RefPtr<PresShell> ps = GetPresShell(); - if (!ps) { - return false; - } - - nsPresContext* pc = ps->GetPresContext(); - if (!pc) { - return false; - } - - // ensure DPI is up-to-date, in case of window being opened and sized - // on a non-default-dpi display (bug 829963) - pc->DeviceContext()->CheckDPIChange(); - int32_t p2a = pc->AppUnitsPerDevPixel(); - if (auto* frame = ps->GetRootFrame()) { - // Usually the resize would deal with this, but there are some cases (like - // web-extension popups) where frames might already be correctly sized etc - // due to a call to e.g. nsDocumentViewer::GetContentSize or so. - frame->InvalidateFrame(); - } - const LayoutDeviceIntSize size(aWidth, aHeight); - ps->SetLayoutViewportSize(LayoutDeviceIntSize::ToAppUnits(size, p2a), - /* aDelay = */ false); - - if (nsXULPopupManager* pm = nsXULPopupManager::GetInstance()) { - pm->AdjustPopupsOnWindowChange(ps); - } - - return true; -} - -#ifdef MOZ_WIDGET_ANDROID -void nsView::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) { - MOZ_ASSERT(XRE_IsParentProcess(), - "Should be only called for the browser parent process"); - CallOnAllRemoteChildren( - [aHeight](dom::BrowserParent* aBrowserParent) -> CallState { - aBrowserParent->DynamicToolbarMaxHeightChanged(aHeight); - return CallState::Continue; - }); -} - -void nsView::DynamicToolbarOffsetChanged(ScreenIntCoord aOffset) { - MOZ_ASSERT(XRE_IsParentProcess(), - "Should be only called for the browser parent process"); - CallOnAllRemoteChildren( - [aOffset](dom::BrowserParent* aBrowserParent) -> CallState { - // Skip background tabs. - if (!aBrowserParent->GetDocShellIsActive()) { - return CallState::Continue; - } - - aBrowserParent->DynamicToolbarOffsetChanged(aOffset); - return CallState::Stop; - }); -} - -void nsView::KeyboardHeightChanged(ScreenIntCoord aHeight) { - MOZ_ASSERT(XRE_IsParentProcess(), - "Should be only called for the browser parent process"); - CallOnAllRemoteChildren( - [aHeight](dom::BrowserParent* aBrowserParent) -> CallState { - // Skip background tabs. - if (!aBrowserParent->GetDocShellIsActive()) { - return CallState::Continue; - } - - aBrowserParent->KeyboardHeightChanged(aHeight); - return CallState::Stop; - }); -} - -void nsView::AndroidPipModeChanged(bool aPipMode) { - MOZ_ASSERT(XRE_IsParentProcess(), - "Should be only called for the browser parent process"); - CallOnAllRemoteChildren( - [aPipMode](dom::BrowserParent* aBrowserParent) -> CallState { - aBrowserParent->AndroidPipModeChanged(aPipMode); - return CallState::Continue; - }); -} -#endif - -void nsView::PaintWindow(nsIWidget* aWidget) { - RefPtr ps = GetPresShell(); - if (!ps) { - return; - } - RefPtr renderer = aWidget->GetWindowRenderer(); - if (!renderer->NeedsWidgetInvalidation()) { - ps->PaintSynchronously(); - renderer->FlushRendering(wr::RenderReasons::WIDGET); - } else { - ps->SyncPaintFallback(ps->GetRootFrame(), renderer); - } - mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT); - ps->DidPaintWindow(); -} - -void nsView::DidCompositeWindow(mozilla::layers::TransactionId aTransactionId, - const TimeStamp& aCompositeStart, - const TimeStamp& aCompositeEnd) { - PresShell* presShell = GetPresShell(); - if (!presShell) { - return; - } - - nsAutoScriptBlocker scriptBlocker; - - nsPresContext* context = presShell->GetPresContext(); - nsRootPresContext* rootContext = context->GetRootPresContext(); - if (rootContext) { - rootContext->NotifyDidPaintForSubtree(aTransactionId, aCompositeEnd); - } - - mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT2, - aCompositeEnd); -} - -nsEventStatus nsView::HandleEvent(WidgetGUIEvent* aEvent) { - MOZ_ASSERT(aEvent->mWidget, "null widget ptr"); - - nsEventStatus result = nsEventStatus_eIgnore; - MaybeUpdateLastUserEventTime(aEvent); - if (RefPtr<PresShell> ps = GetPresShell()) { - if (nsIFrame* root = ps->GetRootFrame()) { - ps->HandleEvent(root, aEvent, false, &result); - } - } - return result; -} - -void nsView::SafeAreaInsetsChanged( - const LayoutDeviceIntMargin& aSafeAreaInsets) { - PresShell* presShell = GetPresShell(); - if (!presShell) { - return; - } - - LayoutDeviceIntMargin windowSafeAreaInsets; - const LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds(); - if (nsCOMPtr<nsIScreen> screen = mWindow->GetWidgetScreen()) { - windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( - screen, aSafeAreaInsets, windowRect); - } - - presShell->GetPresContext()->SetSafeAreaInsets(windowSafeAreaInsets); - - // https://github.com/w3c/csswg-drafts/issues/4670 - // Actually we don't set this value on sub document. This behaviour is - // same as Blink. - CallOnAllRemoteChildren( - [windowSafeAreaInsets](dom::BrowserParent* aBrowserParent) -> CallState { - (void)aBrowserParent->SendSafeAreaInsetsChanged(windowSafeAreaInsets); - return CallState::Continue; - }); -} - -bool nsView::IsPrimaryFramePaintSuppressed() const { - return StaticPrefs::layout_show_previous_page() && mPresShell && - mPresShell->IsPaintingSuppressed(); -} - -void nsView::CallOnAllRemoteChildren( - const std::function<CallState(dom::BrowserParent*)>& aCallback) { - PresShell* presShell = GetPresShell(); - if (!presShell) { - return; - } - - dom::Document* document = presShell->GetDocument(); - if (!document) { - return; - } - - nsPIDOMWindowOuter* window = document->GetWindow(); - if (!window) { - return; - } - - nsContentUtils::CallOnAllRemoteChildren(window, aCallback); -} diff --git a/view/nsView.h b/view/nsView.h @@ -1,210 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsView_h__ -#define nsView_h__ - -#include "nsRect.h" -#include "nsCOMPtr.h" -#include "nsIWidgetListener.h" -#include "Units.h" -#include "mozilla/Attributes.h" -#include "mozilla/CallState.h" -#include "mozilla/EventForwards.h" - -class nsViewManager; -class nsIWidget; -class nsIFrame; - -namespace mozilla { -class PresShell; -namespace dom { -class BrowserParent; -} // namespace dom -namespace widget { -struct InitData; -enum class TransparencyMode : uint8_t; -enum class WindowType : uint8_t; -} // namespace widget -} // namespace mozilla - -/** - * nsView's serve two main purposes: 1) a bridge between nsIFrame's and - * nsIWidget's, 2) linking the frame tree of a(n) (in-process) subdocument with - * its parent document frame tree. Historically views were used for more things, - * but their role has been reduced, and could be reduced to nothing in the - * future (bug 337801 tracks removing views). Views are generally associated - * with a frame. A view that does not have a frame is called an anonymous view. - * Some frames also have associated widgets (think os level windows). If a frame - * has a widget it must also have a view, but not all frames with views will - * have widgets. - * - * Only four types of frames can have a view: root frames (ViewportFrame), - * subdocument frames (nsSubDocumentFrame), - * menu popup frames (nsMenuPopupFrame), and list control frames - * (nsListControlFrame). Root frames and subdocument frames have views to link - * the two documents together (the frame trees do not link up otherwise). - * Menu popup frames, and list control frames have views because - * they (sometimes) need to create widgets. - * Menu popup frames handles xul popups, which is anything - * where we need content to go over top the main window at an os level. List - * control frames handle select popups/dropdowns in non-e10s mode. - * - * The term "root view" refers to the root view of a document. Just like root - * frames, root views can have parent views. Only the root view of the root - * document in the process will not have a parent. - * - * All views are created by their frames except root views. Root views are - * special. Root views are created in nsDocumentViewer::MakeWindow before the - * root frame is created, so the root view will not have a frame very early in - * document creation. - * - * Subdocument frames have an anonymous (no frame associated - * with it) inner view that is a child of their "outer" view. - * - * On a subdocument frame the inner view serves as the parent of the - * root view of the subdocument. The outer and inner view of the subdocument - * frame belong to the subdocument frame and hence to the parent document. The - * root view of the subdocument belongs to the subdocument. - * nsLayoutUtils::GetCrossDocParentFrame and nsPresContext::GetParentPresContext - * depend on this view structure and are the main way that we traverse across - * the document boundary in layout. - * - * When the load of a new document is started in the subdocument, the creation - * of the new subdocument and destruction of the old subdocument are not - * linked. (This creation and destruction is handled in nsDocumentViewer.cpp.) - * This means that the old and new document will both exist at the same time - * during the loading of the new document. During this period the inner view of - * the subdocument parent will be the parent of two root views. This means that - * during this period there is a choice for which subdocument we draw, - * nsSubDocumentFrame::GetSubdocumentPresShellForPainting is what makes that - * choice. Note that this might not be a totally free choice, ie there might be - * hidden dependencies and bugs if the way we choose is changed. - * - * One thing that is special about the root view of a chrome window is that - * instead of creating a widget for the view, they can "attach" to the - * existing widget that was created by appshell code or something else. (see - * nsDocumentViewer::ShouldAttachToTopLevel) - */ - -//---------------------------------------------------------------------- - -/** - * View interface - * - * Views are NOT reference counted. Use the Destroy() member function to - * destroy a view. - * - * The lifetime of the view hierarchy is bounded by the lifetime of the - * view manager that owns the views. - * - * Most of the methods here are read-only. To set the corresponding properties - * of a view, go through nsViewManager. - */ - -class nsView final : public nsIWidgetListener { - public: - friend class nsViewManager; - - typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect; - typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion; - - void operator delete(void* ptr) { ::operator delete(ptr); } - - /** - * Destroy the view. - * - * The view destroys its child views, and destroys and releases its - * widget (if it has one). - * - * Also informs the view manager that the view is destroyed by calling - * SetRootView(NULL) if the view is the root view and calling RemoveChild() - * otherwise. - */ - void Destroy(); - - // Stops listening to mWidget and clears it. - void DetachWidget(); - - /** - * Attach/detach a top level widget from this view. When attached, the view - * updates the widget's device context and allows the view to begin receiving - * gecko events. The underlying base window associated with the widget will - * continues to receive events it expects. - * - * An attached widget will not be destroyed when the view is destroyed, - * allowing the recycling of a single top level widget over multiple views. - * - * @param aWidget The widget to attach to / detach from. - */ - void AttachToTopLevelWidget(nsIWidget* aWidget); - void DetachFromTopLevelWidget(); - - static uint32_t GetLastUserEventTime(); - - /** - * In 4.0, the "cutout" nature of a view is queryable. - * If we believe that all cutout view have a native widget, this - * could be a replacement. - * @param aWidget out parameter for widget that this view contains, - * or nullptr if there is none. - */ - nsIWidget* GetWidget() const { return mWindow; } - - /** - * Returns true if the view has a widget associated with it. - */ - bool HasWidget() const { return mWindow != nullptr; } - -#ifdef DEBUG - /** - * Output debug info to FILE - * @param out output file handle - * @param aIndent indentation depth - * NOTE: virtual so that debugging tools not linked into gklayout can access - * it - */ - virtual void List(FILE* out, int32_t aIndent = 0) const; -#endif // DEBUG - - // nsIWidgetListener - mozilla::PresShell* GetPresShell() override; - nsView* GetView() override { return this; } - bool IsPaintSuppressed() const override { - return IsPrimaryFramePaintSuppressed(); - } - bool WindowResized(nsIWidget* aWidget, int32_t aWidth, - int32_t aHeight) override; -#ifdef MOZ_WIDGET_ANDROID - void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight) override; - void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset) override; - void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight) override; - void AndroidPipModeChanged(bool) override; -#endif - MOZ_CAN_RUN_SCRIPT_BOUNDARY - void PaintWindow(nsIWidget* aWidget) override; - void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId, - const mozilla::TimeStamp& aCompositeStart, - const mozilla::TimeStamp& aCompositeEnd) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - nsEventStatus HandleEvent(mozilla::WidgetGUIEvent*) override; - void SafeAreaInsetsChanged(const mozilla::LayoutDeviceIntMargin&) override; - - explicit nsView(mozilla::PresShell*); - virtual ~nsView(); - - bool IsPrimaryFramePaintSuppressed() const; - - private: - void CallOnAllRemoteChildren( - const std::function<mozilla::CallState(mozilla::dom::BrowserParent*)>& - aCallback); - - mozilla::PresShell* mPresShell = nullptr; - nsCOMPtr<nsIWidget> mWindow; - nsCOMPtr<nsIWidget> mPreviousWindow; -}; - -#endif diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp @@ -5,32 +5,21 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "base/basictypes.h" - #include "gfxPlatform.h" #include "nsRefreshDriver.h" #include "mozilla/dom/BrowserChild.h" #include "mozilla/EventForwards.h" -#include "mozilla/gfx/gfxVars.h" #include "mozilla/IMEStateManager.h" -#include "mozilla/layers/APZChild.h" #include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/NativeKeyBindingsType.h" -#include "mozilla/Preferences.h" #include "mozilla/PresShell.h" #include "mozilla/SchedulerGroup.h" -#include "mozilla/StaticPrefs_browser.h" -#include "mozilla/StaticPrefs_gfx.h" #include "mozilla/TextComposition.h" #include "mozilla/TextEventDispatcher.h" #include "mozilla/TextEvents.h" #include "PuppetWidget.h" #include "nsContentUtils.h" -#include "nsView.h" -#include "nsIWidgetListener.h" #include "imgIContainer.h" -#include "nsXPLookAndFeel.h" -#include "nsPrintfCString.h" using namespace mozilla; using namespace mozilla::dom; diff --git a/widget/TextEventDispatcher.cpp b/widget/TextEventDispatcher.cpp @@ -9,13 +9,10 @@ #include "PuppetWidget.h" #include "TextEvents.h" -#include "mozilla/Preferences.h" #include "mozilla/StaticPrefs_dom.h" #include "nsCharTraits.h" #include "nsIFrame.h" #include "nsIWidget.h" -#include "nsPIDOMWindow.h" -#include "nsView.h" namespace mozilla { namespace widget { diff --git a/widget/moz.build b/widget/moz.build @@ -366,7 +366,6 @@ LOCAL_INCLUDES += [ "/layout/painting", "/layout/xul", "/layout/xul/tree/", - "/view", "/widget", "/widget/headless", ] diff --git a/widget/nsIWidgetListener.h b/widget/nsIWidgetListener.h @@ -21,6 +21,7 @@ class nsMenuPopupFrame; namespace mozilla { class PresShell; +class PresShellWidgetListener; } // namespace mozilla /** @@ -42,8 +43,10 @@ class nsIWidgetListener { */ virtual nsIAppWindow* GetAppWindow() { return nullptr; } - /** If this listener is for a view, return it. */ - virtual nsView* GetView() { return nullptr; } + /** If this listener is for a pres shell, return it. */ + virtual mozilla::PresShellWidgetListener* GetAsPresShellWidgetListener() { + return nullptr; + } /** If this listener is for an nsMenuPopupFrame, return it. */ virtual nsMenuPopupFrame* GetAsMenuPopupFrame() { return nullptr; } @@ -78,11 +81,9 @@ class nsIWidgetListener { virtual void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight) { } virtual void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset) {} -#ifdef MOZ_WIDGET_ANDROID /** Called when the software keyboard appears/disappears. */ virtual void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight) {} virtual void AndroidPipModeChanged(bool) {} -#endif /** Called when the macOS titlebar is shown while in fullscreen. */ virtual void MacFullscreenMenubarOverlapChanged(