Bug 1919165 - Remove support for WindowType::Child, which is now unused. r=stransky
We don't take this codepath anymore in any platform. Windows and GTK were already asserting against it. Differential Revision: https://phabricator.services.mozilla.com/D245640
This commit is contained in:
@@ -2405,33 +2405,10 @@ nsRect nsLayoutUtils::TransformFrameRectToAncestor(
|
||||
NSFloatPixelsToAppUnits(float(result.height), destAppUnitsPerDevPixel));
|
||||
}
|
||||
|
||||
static LayoutDeviceIntPoint GetWidgetOffset(nsIWidget* aWidget,
|
||||
nsIWidget*& aRootWidget) {
|
||||
LayoutDeviceIntPoint offset(0, 0);
|
||||
while (aWidget->GetWindowType() == widget::WindowType::Child) {
|
||||
nsIWidget* parent = aWidget->GetParent();
|
||||
if (!parent) {
|
||||
break;
|
||||
}
|
||||
LayoutDeviceIntRect bounds = aWidget->GetBounds();
|
||||
offset += bounds.TopLeft();
|
||||
aWidget = parent;
|
||||
}
|
||||
aRootWidget = aWidget;
|
||||
return offset;
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint nsLayoutUtils::WidgetToWidgetOffset(nsIWidget* aFrom,
|
||||
nsIWidget* aTo) {
|
||||
nsIWidget* fromRoot;
|
||||
LayoutDeviceIntPoint fromOffset = GetWidgetOffset(aFrom, fromRoot);
|
||||
nsIWidget* toRoot;
|
||||
LayoutDeviceIntPoint toOffset = GetWidgetOffset(aTo, toRoot);
|
||||
|
||||
if (fromRoot != toRoot) {
|
||||
fromOffset = aFrom->WidgetToScreenOffset();
|
||||
toOffset = aTo->WidgetToScreenOffset();
|
||||
}
|
||||
auto fromOffset = aFrom->WidgetToScreenOffset();
|
||||
auto toOffset = aTo->WidgetToScreenOffset();
|
||||
return fromOffset - toOffset;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ nsWebBrowser::nsWebBrowser(int aItemType)
|
||||
mShouldEnableHistory(true),
|
||||
mWillChangeProcess(false),
|
||||
mProgressListener(nullptr),
|
||||
mWidgetListenerDelegate(this),
|
||||
mBackgroundColor(0),
|
||||
mPersistCurrentState(nsIWebBrowserPersist::PERSIST_STATE_READY),
|
||||
mPersistResult(NS_OK),
|
||||
@@ -73,25 +72,8 @@ nsWebBrowser::nsWebBrowser(int aItemType)
|
||||
nsWebBrowser::~nsWebBrowser() { InternalDestroy(); }
|
||||
|
||||
nsIWidget* nsWebBrowser::EnsureWidget() {
|
||||
if (mParentWidget) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mParentWidget);
|
||||
return mParentWidget;
|
||||
}
|
||||
|
||||
mInternalWidget = nsIWidget::CreateChildWindow();
|
||||
if (NS_WARN_IF(!mInternalWidget)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
widget::InitData widgetInit;
|
||||
widgetInit.mClipChildren = true;
|
||||
widgetInit.mWindowType = widget::WindowType::Child;
|
||||
LayoutDeviceIntRect bounds(0, 0, 0, 0);
|
||||
|
||||
mInternalWidget->SetWidgetListener(&mWidgetListenerDelegate);
|
||||
NS_ENSURE_SUCCESS(mInternalWidget->Create(mParentWidget, bounds, &widgetInit),
|
||||
nullptr);
|
||||
|
||||
return mInternalWidget;
|
||||
}
|
||||
|
||||
/* static */
|
||||
@@ -163,12 +145,6 @@ already_AddRefed<nsWebBrowser> nsWebBrowser::Create(
|
||||
}
|
||||
|
||||
void nsWebBrowser::InternalDestroy() {
|
||||
if (mInternalWidget) {
|
||||
mInternalWidget->SetWidgetListener(nullptr);
|
||||
mInternalWidget->Destroy();
|
||||
mInternalWidget = nullptr; // Force release here.
|
||||
}
|
||||
|
||||
SetDocShell(nullptr);
|
||||
|
||||
if (mDocShellTreeOwner) {
|
||||
@@ -941,14 +917,7 @@ nsWebBrowser::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX,
|
||||
int32_t doc_x = aX;
|
||||
int32_t doc_y = aY;
|
||||
|
||||
// If there is an internal widget we need to make the docShell coordinates
|
||||
// relative to the internal widget rather than the calling app's parent.
|
||||
// We also need to resize our widget then.
|
||||
if (mInternalWidget) {
|
||||
doc_x = doc_y = 0;
|
||||
mInternalWidget->Resize(aX, aY, aCX, aCY,
|
||||
!!(aFlags & nsIBaseWindow::eRepaint));
|
||||
}
|
||||
// Now reposition/ resize the doc
|
||||
NS_ENSURE_SUCCESS(
|
||||
mDocShell->SetPositionAndSize(doc_x, doc_y, aCX, aCY, aFlags),
|
||||
@@ -960,24 +929,6 @@ nsWebBrowser::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX,
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::GetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aCX,
|
||||
int32_t* aCY) {
|
||||
if (mInternalWidget) {
|
||||
LayoutDeviceIntRect bounds = mInternalWidget->GetBounds();
|
||||
|
||||
if (aX) {
|
||||
*aX = bounds.X();
|
||||
}
|
||||
if (aY) {
|
||||
*aY = bounds.Y();
|
||||
}
|
||||
if (aCX) {
|
||||
*aCX = bounds.Width();
|
||||
}
|
||||
if (aCY) {
|
||||
*aCY = bounds.Height();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Can directly return this as it is the
|
||||
// same interface, thus same returns.
|
||||
return mDocShell->GetPositionAndSize(aX, aY, aCX, aCY);
|
||||
@@ -1041,9 +992,6 @@ NS_IMETHODIMP
|
||||
nsWebBrowser::SetVisibility(bool aVisibility) {
|
||||
if (mDocShell) {
|
||||
NS_ENSURE_SUCCESS(mDocShell->SetVisibility(aVisibility), NS_ERROR_FAILURE);
|
||||
if (mInternalWidget) {
|
||||
mInternalWidget->Show(aVisibility);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -1051,35 +999,18 @@ nsWebBrowser::SetVisibility(bool aVisibility) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::GetEnabled(bool* aEnabled) {
|
||||
if (mInternalWidget) {
|
||||
*aEnabled = mInternalWidget->IsEnabled();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::SetEnabled(bool aEnabled) {
|
||||
if (mInternalWidget) {
|
||||
mInternalWidget->Enable(aEnabled);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::GetMainWidget(nsIWidget** aMainWidget) {
|
||||
NS_ENSURE_ARG_POINTER(aMainWidget);
|
||||
|
||||
if (mInternalWidget) {
|
||||
*aMainWidget = mInternalWidget;
|
||||
} else {
|
||||
*aMainWidget = mParentWidget;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aMainWidget);
|
||||
|
||||
NS_IF_ADDREF(*aMainWidget = mParentWidget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1143,42 +1074,6 @@ void nsWebBrowser::EnsureDocShellTreeOwner() {
|
||||
mDocShellTreeOwner->WebBrowser(this);
|
||||
}
|
||||
|
||||
void nsWebBrowser::WindowActivated() {
|
||||
#if defined(DEBUG_smaug)
|
||||
RefPtr<dom::Document> document = mDocShell->GetDocument();
|
||||
nsAutoString documentURI;
|
||||
document->GetDocumentURI(documentURI);
|
||||
printf("nsWebBrowser::NS_ACTIVATE %p %s\n", (void*)this,
|
||||
NS_ConvertUTF16toUTF8(documentURI).get());
|
||||
#endif
|
||||
FocusActivate(nsFocusManager::GenerateFocusActionId());
|
||||
}
|
||||
|
||||
void nsWebBrowser::WindowDeactivated() {
|
||||
#if defined(DEBUG_smaug)
|
||||
RefPtr<dom::Document> document = mDocShell->GetDocument();
|
||||
nsAutoString documentURI;
|
||||
document->GetDocumentURI(documentURI);
|
||||
printf("nsWebBrowser::NS_DEACTIVATE %p %s\n", (void*)this,
|
||||
NS_ConvertUTF16toUTF8(documentURI).get());
|
||||
#endif
|
||||
FocusDeactivate(nsFocusManager::GenerateFocusActionId());
|
||||
}
|
||||
|
||||
bool nsWebBrowser::PaintWindow(nsIWidget* aWidget,
|
||||
LayoutDeviceIntRegion aRegion) {
|
||||
WindowRenderer* renderer = aWidget->GetWindowRenderer();
|
||||
NS_ASSERTION(renderer, "Must be in paint event");
|
||||
if (FallbackRenderer* fallback = renderer->AsFallback()) {
|
||||
if (fallback->BeginTransaction()) {
|
||||
fallback->EndTransactionWithColor(aRegion.GetBounds().ToUnknownRect(),
|
||||
ToDeviceColor(mBackgroundColor));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void nsWebBrowser::FocusActivate(uint64_t aActionId) {
|
||||
if (RefPtr<nsFocusManager> fm = nsFocusManager::GetFocusManager()) {
|
||||
if (nsCOMPtr<nsPIDOMWindowOuter> window = GetWindow()) {
|
||||
@@ -1201,19 +1096,3 @@ void nsWebBrowser::SetWillChangeProcess() {
|
||||
nsDocShell::Cast(mDocShell)->SetWillChangeProcess();
|
||||
}
|
||||
}
|
||||
|
||||
void nsWebBrowser::WidgetListenerDelegate::WindowActivated() {
|
||||
RefPtr<nsWebBrowser> holder = mWebBrowser;
|
||||
holder->WindowActivated();
|
||||
}
|
||||
|
||||
void nsWebBrowser::WidgetListenerDelegate::WindowDeactivated() {
|
||||
RefPtr<nsWebBrowser> holder = mWebBrowser;
|
||||
holder->WindowDeactivated();
|
||||
}
|
||||
|
||||
bool nsWebBrowser::WidgetListenerDelegate::PaintWindow(
|
||||
nsIWidget* aWidget, mozilla::LayoutDeviceIntRegion aRegion) {
|
||||
RefPtr<nsWebBrowser> holder = mWebBrowser;
|
||||
return holder->PaintWindow(aWidget, aRegion);
|
||||
}
|
||||
|
||||
@@ -72,24 +72,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
friend class nsDocShellTreeOwner;
|
||||
|
||||
public:
|
||||
// The implementation of non-refcounted nsIWidgetListener, which would hold a
|
||||
// strong reference on stack before calling nsWebBrowser's
|
||||
// MOZ_CAN_RUN_SCRIPT methods.
|
||||
class WidgetListenerDelegate : public nsIWidgetListener {
|
||||
public:
|
||||
explicit WidgetListenerDelegate(nsWebBrowser* aWebBrowser)
|
||||
: mWebBrowser(aWebBrowser) {}
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void WindowActivated() override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void WindowDeactivated() override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual bool PaintWindow(
|
||||
nsIWidget* aWidget, mozilla::LayoutDeviceIntRegion aRegion) override;
|
||||
|
||||
private:
|
||||
// The lifetime of WidgetListenerDelegate is bound to nsWebBrowser so we
|
||||
// just use raw pointer here.
|
||||
nsWebBrowser* mWebBrowser;
|
||||
};
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsWebBrowser, nsIWebBrowser)
|
||||
|
||||
@@ -122,13 +104,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
void EnsureDocShellTreeOwner();
|
||||
|
||||
nsIWidget* EnsureWidget();
|
||||
|
||||
// nsIWidgetListener methods for WidgetListenerDelegate.
|
||||
MOZ_CAN_RUN_SCRIPT void WindowActivated();
|
||||
MOZ_CAN_RUN_SCRIPT void WindowDeactivated();
|
||||
MOZ_CAN_RUN_SCRIPT bool PaintWindow(nsIWidget* aWidget,
|
||||
mozilla::LayoutDeviceIntRegion aRegion);
|
||||
|
||||
explicit nsWebBrowser(int aItemType);
|
||||
|
||||
protected:
|
||||
@@ -136,7 +111,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
RefPtr<nsDocShell> mDocShell;
|
||||
mozilla::OriginAttributes mOriginAttributes;
|
||||
|
||||
nsCOMPtr<nsIWidget> mInternalWidget;
|
||||
nsCOMPtr<nsIWindowWatcher> mWWatch;
|
||||
const uint32_t mContentType;
|
||||
bool mShouldEnableHistory;
|
||||
@@ -145,8 +119,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
|
||||
WidgetListenerDelegate mWidgetListenerDelegate;
|
||||
|
||||
// cached background color
|
||||
nscolor mBackgroundColor;
|
||||
|
||||
|
||||
@@ -467,7 +467,6 @@ void nsView::RemoveChild(nsView* child) {
|
||||
|
||||
struct DefaultWidgetInitData : public widget::InitData {
|
||||
DefaultWidgetInitData() : widget::InitData() {
|
||||
mWindowType = WindowType::Child;
|
||||
mClipChildren = true;
|
||||
mClipSiblings = true;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,8 @@ namespace mozilla::widget {
|
||||
// Window types
|
||||
enum class WindowType : uint8_t {
|
||||
TopLevel, // default top level window
|
||||
Dialog, // top level window but usually handled differently
|
||||
// by the OS
|
||||
Dialog, // top level window but usually handled differently by the OS
|
||||
Popup, // used for combo boxes, etc
|
||||
Child, // child windows (contained inside a window on the
|
||||
// desktop (has no border))
|
||||
Invisible, // a special hidden window (not to be created by arbitrary code)
|
||||
};
|
||||
|
||||
@@ -77,7 +74,7 @@ enum class TransparencyMode : uint8_t {
|
||||
// Basic struct for widget initialization data.
|
||||
// @see Create member function of nsIWidget
|
||||
struct InitData {
|
||||
WindowType mWindowType = WindowType::Child;
|
||||
WindowType mWindowType = WindowType::TopLevel;
|
||||
BorderStyle mBorderStyle = BorderStyle::Default;
|
||||
PopupType mPopupHint = PopupType::Panel;
|
||||
PopupLevel mPopupLevel = PopupLevel::Top;
|
||||
|
||||
@@ -4552,9 +4552,6 @@ DesktopToLayoutDeviceScale ParentBackingScaleFactor(nsIWidget* aParent) {
|
||||
static DesktopRect GetWidgetScreenRectForChildren(nsIWidget* aWidget) {
|
||||
mozilla::DesktopToLayoutDeviceScale scale =
|
||||
aWidget->GetDesktopToDeviceScale();
|
||||
if (aWidget->GetWindowType() == WindowType::Child) {
|
||||
return aWidget->GetScreenBounds() / scale;
|
||||
}
|
||||
return aWidget->GetClientBounds() / scale;
|
||||
}
|
||||
|
||||
@@ -4686,7 +4683,6 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect& aRect,
|
||||
// Configure the window we will create based on the window type.
|
||||
switch (mWindowType) {
|
||||
case WindowType::Invisible:
|
||||
case WindowType::Child:
|
||||
break;
|
||||
case WindowType::Popup:
|
||||
if (aBorderStyle != BorderStyle::Default &&
|
||||
@@ -4978,9 +4974,6 @@ void nsCocoaWindow::SetModal(bool aModal) {
|
||||
// (similar) event loops).
|
||||
for (auto* ancestorWidget = mParent; ancestorWidget;
|
||||
ancestorWidget = ancestorWidget->GetParent()) {
|
||||
if (ancestorWidget->GetWindowType() == WindowType::Child) {
|
||||
continue;
|
||||
}
|
||||
auto* ancestor = static_cast<nsCocoaWindow*>(ancestorWidget);
|
||||
const bool changed = aModal ? ancestor->mNumModalDescendants++ == 0
|
||||
: --ancestor->mNumModalDescendants == 0;
|
||||
|
||||
@@ -467,7 +467,6 @@ nsWindow::nsWindow()
|
||||
mConfiguredClearColor(false),
|
||||
mGotNonBlankPaint(false),
|
||||
mNeedsToRetryCapturingMouse(false) {
|
||||
mWindowType = WindowType::Child;
|
||||
mSizeConstraints.mMaxSize = GetSafeWindowSize(mSizeConstraints.mMaxSize);
|
||||
|
||||
if (!gGlobalsInitialized) {
|
||||
@@ -6016,8 +6015,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
|
||||
auto* parentnsWindow = static_cast<nsWindow*>(aParent);
|
||||
LOG(" parent window [%p]", parentnsWindow);
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(mWindowType != WindowType::Child);
|
||||
|
||||
MOZ_ASSERT_IF(mWindowType == WindowType::Popup, parentnsWindow);
|
||||
|
||||
if (mWindowType != WindowType::Dialog && mWindowType != WindowType::Popup &&
|
||||
|
||||
@@ -516,10 +516,9 @@ already_AddRefed<nsIWidget> nsBaseWidget::CreateChild(
|
||||
|
||||
// Attach a view to our widget which we'll send events to.
|
||||
void nsBaseWidget::AttachViewToTopLevel(bool aUseAttachedEvents) {
|
||||
NS_ASSERTION((mWindowType == WindowType::TopLevel ||
|
||||
NS_ASSERTION(mWindowType == WindowType::TopLevel ||
|
||||
mWindowType == WindowType::Dialog ||
|
||||
mWindowType == WindowType::Invisible ||
|
||||
mWindowType == WindowType::Child),
|
||||
mWindowType == WindowType::Invisible,
|
||||
"Can't attach to window of that type");
|
||||
|
||||
mUseAttachedEvents = aUseAttachedEvents;
|
||||
@@ -969,8 +968,8 @@ bool nsBaseWidget::UseAPZ() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Always use APZ for top-level windows
|
||||
if (mWindowType == WindowType::TopLevel || mWindowType == WindowType::Child) {
|
||||
// Always use APZ for top-level windows. XXX what about Dialog?
|
||||
if (mWindowType == WindowType::TopLevel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -986,7 +985,9 @@ bool nsBaseWidget::UseAPZ() const {
|
||||
if (HasRemoteContent()) {
|
||||
return mWindowType == WindowType::Dialog ||
|
||||
mWindowType == WindowType::Popup;
|
||||
} else if (StaticPrefs::apz_popups_without_remote_enabled()) {
|
||||
}
|
||||
|
||||
if (StaticPrefs::apz_popups_without_remote_enabled()) {
|
||||
return mWindowType == WindowType::Popup;
|
||||
}
|
||||
|
||||
|
||||
@@ -2094,7 +2094,7 @@ class nsIWidget : public nsISupports {
|
||||
nsIWidget* MOZ_NON_OWNING_REF mParent = nullptr;
|
||||
// When Destroy() is called, the sub class should set this true.
|
||||
bool mOnDestroyCalled = false;
|
||||
WindowType mWindowType = WindowType::Child;
|
||||
WindowType mWindowType = WindowType::TopLevel;
|
||||
WidgetType mWidgetType = WidgetType::Native;
|
||||
};
|
||||
|
||||
|
||||
@@ -671,8 +671,6 @@ nsWindow::nsWindow()
|
||||
mCachedHitTestTime(TimeStamp::Now()),
|
||||
mSizeConstraintsScale(GetDefaultScale().scale),
|
||||
mDesktopId("DesktopIdMutex") {
|
||||
MOZ_ASSERT(mWindowType == WindowType::Child);
|
||||
|
||||
if (!gInitializedVirtualDesktopManager) {
|
||||
TaskController::Get()->AddTask(
|
||||
MakeAndAddRef<InitializeVirtualDesktopManagerTask>());
|
||||
@@ -873,7 +871,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
|
||||
if (!aInitData) aInitData = &defaultInitData;
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(aInitData->mWindowType != WindowType::Invisible);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aInitData->mWindowType != WindowType::Child);
|
||||
|
||||
mBounds = aRect;
|
||||
|
||||
@@ -1310,10 +1307,6 @@ static DWORD WindowStylesRemovedForBorderStyle(BorderStyle aStyle) {
|
||||
DWORD nsWindow::WindowStyle() {
|
||||
DWORD style;
|
||||
switch (mWindowType) {
|
||||
case WindowType::Child:
|
||||
style = WS_OVERLAPPED;
|
||||
break;
|
||||
|
||||
case WindowType::Dialog:
|
||||
style = WS_OVERLAPPED | WS_BORDER | WS_DLGFRAME | WS_SYSMENU |
|
||||
DS_MODALFRAME | WS_CLIPCHILDREN;
|
||||
@@ -1345,8 +1338,6 @@ DWORD nsWindow::WindowStyle() {
|
||||
// Return nsWindow extended styles
|
||||
DWORD nsWindow::WindowExStyle() {
|
||||
switch (mWindowType) {
|
||||
case WindowType::Child:
|
||||
return 0;
|
||||
case WindowType::Popup: {
|
||||
DWORD extendedStyle = WS_EX_TOOLWINDOW;
|
||||
if (mPopupLevel == PopupLevel::Top) {
|
||||
|
||||
Reference in New Issue
Block a user