Bug 1851577 - Remove support for the drawintitlebar attribute. r=smaug

It was replaced by chromemargin, but some leftovers remained in the
tree.

Differential Revision: https://phabricator.services.mozilla.com/D187440
This commit is contained in:
Emilio Cobos Álvarez 2023-09-05 13:26:46 +00:00
parent f71f056ccf
commit 02cec2af35
10 changed files with 84 additions and 125 deletions

View File

@ -64,34 +64,6 @@ nsIWidget* ChromeObserver::GetWindowWidget() {
return nullptr;
}
class SetDrawInTitleBarEvent : public Runnable {
public:
SetDrawInTitleBarEvent(nsIWidget* aWidget, bool aState)
: mozilla::Runnable("SetDrawInTitleBarEvent"),
mWidget(aWidget),
mState(aState) {}
NS_IMETHOD Run() override {
NS_ASSERTION(mWidget,
"You shouldn't call this runnable with a null widget!");
mWidget->SetDrawsInTitlebar(mState);
return NS_OK;
}
private:
nsCOMPtr<nsIWidget> mWidget;
bool mState;
};
void ChromeObserver::SetDrawsInTitlebar(bool aState) {
nsIWidget* mainWidget = GetWindowWidget();
if (mainWidget) {
nsContentUtils::AddScriptRunner(
new SetDrawInTitleBarEvent(mainWidget, aState));
}
}
void ChromeObserver::SetDrawsTitle(bool aState) {
nsIWidget* mainWidget = GetWindowWidget();
if (mainWidget) {
@ -159,8 +131,6 @@ void ChromeObserver::AttributeChanged(dom::Element* aElement,
// any root node (windows, dialogs, etc)
else if (aName == nsGkAtoms::title) {
mDocument->NotifyPossibleTitleChange(false);
} else if (aName == nsGkAtoms::drawintitlebar) {
SetDrawsInTitlebar(value->Equals(u"true"_ns, eCaseMatters));
} else if (aName == nsGkAtoms::drawtitle) {
SetDrawsTitle(value->Equals(u"true"_ns, eCaseMatters));
} else if (aName == nsGkAtoms::localedir) {
@ -184,8 +154,6 @@ void ChromeObserver::AttributeChanged(dom::Element* aElement,
} else if (aName == nsGkAtoms::lwtheme) {
// if the lwtheme changed, make sure to restyle appropriately
mDocument->ResetDocumentLWTheme();
} else if (aName == nsGkAtoms::drawintitlebar) {
SetDrawsInTitlebar(false);
} else if (aName == nsGkAtoms::drawtitle) {
SetDrawsTitle(false);
}

View File

@ -26,7 +26,6 @@ class ChromeObserver final : public nsStubMutationObserver {
protected:
nsIWidget* GetWindowWidget();
void SetDrawsInTitlebar(bool aState);
void SetDrawsTitle(bool aState);
void SetChromeMargins(const nsAttrValue* aValue);
nsresult HideWindowChrome(bool aShouldHide);

View File

@ -66,13 +66,13 @@ typedef struct _nsCocoaWindowList {
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
- (BOOL)drawsContentsIntoWindowFrame;
// These two methods are like contentRectForFrameRect and frameRectForContentRect,
// but they deal with the rect of the window's "main ChildView" instead of the
// rect of the window's content view. The two are sometimes sized differently: The
// window's content view always covers the entire window, whereas the ChildView
// only covers the full window when drawsContentsIntoWindowFrame is YES. When
// drawsContentsIntoWindowFrame is NO, there's a titlebar-sized gap above the
// ChildView within the content view.
// These two methods are like contentRectForFrameRect and
// frameRectForContentRect, but they deal with the rect of the window's "main
// ChildView" instead of the rect of the window's content view. The two are
// sometimes sized differently: The window's content view always covers the
// entire window, whereas the ChildView only covers the full window when
// drawsContentsIntoWindowFrame is YES. When drawsContentsIntoWindowFrame is NO,
// there's a titlebar-sized gap above the ChildView within the content view.
- (NSRect)childViewRectForFrameRect:(NSRect)aFrameRect;
- (NSRect)frameRectForChildViewRect:(NSRect)aChildViewRect;
@ -127,8 +127,10 @@ typedef struct _nsCocoaWindowList {
- (BOOL)bottomCornerRounded;
// Present in the same form on OS X since at least OS X 10.5.
- (NSRect)contentRectForFrameRect:(NSRect)windowFrame styleMask:(NSUInteger)windowStyle;
- (NSRect)frameRectForContentRect:(NSRect)windowContentRect styleMask:(NSUInteger)windowStyle;
- (NSRect)contentRectForFrameRect:(NSRect)windowFrame
styleMask:(NSUInteger)windowStyle;
- (NSRect)frameRectForContentRect:(NSRect)windowContentRect
styleMask:(NSUInteger)windowStyle;
// Present since at least OS X 10.5. The OS calls this method on NSWindow
// (and its subclasses) to find out which NSFrameView subclass to instantiate
@ -228,10 +230,13 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSPIWIDGETCOCOA; // semicolon for clang-format bug 1629756
[[nodiscard]] virtual nsresult Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
const DesktopIntRect& aRect, InitData* = nullptr) override;
[[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
nsNativeWidget aNativeParent,
const DesktopIntRect& aRect,
InitData* = nullptr) override;
[[nodiscard]] virtual nsresult Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
[[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
nsNativeWidget aNativeParent,
const LayoutDeviceIntRect& aRect,
InitData* = nullptr) override;
@ -265,20 +270,26 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
virtual void HideWindowChrome(bool aShouldHide) override;
virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage, uint16_t aDuration,
nsISupports* aData, nsIRunnable* aCallback) override;
virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
uint16_t aDuration,
nsISupports* aData,
nsIRunnable* aCallback) override;
virtual void CleanupFullscreenTransition() override;
nsresult MakeFullScreen(bool aFullScreen) final;
nsresult MakeFullScreenWithNativeTransition(bool aFullScreen) final;
NSAnimation* FullscreenTransitionAnimation() const { return mFullscreenTransitionAnimation; }
NSAnimation* FullscreenTransitionAnimation() const {
return mFullscreenTransitionAnimation;
}
void ReleaseFullscreenTransitionAnimation() {
MOZ_ASSERT(mFullscreenTransitionAnimation, "Should only be called when there is animation");
MOZ_ASSERT(mFullscreenTransitionAnimation,
"Should only be called when there is animation");
[mFullscreenTransitionAnimation release];
mFullscreenTransitionAnimation = nil;
}
virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
virtual void Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override;
virtual void Resize(double aX, double aY, double aWidth, double aHeight,
bool aRepaint) override;
NSRect GetClientCocoaRect();
virtual LayoutDeviceIntRect GetClientBounds() override;
virtual LayoutDeviceIntRect GetScreenBounds() override;
@ -299,7 +310,8 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
virtual WindowRenderer* GetWindowRenderer() override;
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus) override;
virtual void CaptureRollupEvents(bool aDoCapture) override;
[[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) override;
virtual bool HasPendingInputEvent() override;
@ -307,34 +319,35 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
virtual void SetTransparencyMode(TransparencyMode aMode) override;
virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) override;
virtual void SetWindowOpacity(float aOpacity) override;
virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) override;
virtual void SetWindowTransform(
const mozilla::gfx::Matrix& aTransform) override;
virtual void SetInputRegion(const InputRegion&) override;
virtual void SetColorScheme(const mozilla::Maybe<mozilla::ColorScheme>&) override;
virtual void SetColorScheme(
const mozilla::Maybe<mozilla::ColorScheme>&) override;
virtual void SetShowsToolbarButton(bool aShow) override;
virtual void SetSupportsNativeFullscreen(bool aShow) override;
virtual void SetWindowAnimationType(WindowAnimationType aType) override;
virtual void SetDrawsTitle(bool aDrawTitle) override;
virtual nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) override;
virtual void SetDrawsInTitlebar(bool aState) override;
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
NativeMouseMessage aNativeMessage,
mozilla::MouseButton aButton,
nsIWidget::Modifiers aModifierFlags,
nsIObserver* aObserver) override;
virtual nsresult SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint,
uint32_t aNativeMessage, double aDeltaX,
double aDeltaY, double aDeltaZ,
uint32_t aModifierFlags,
uint32_t aAdditionalFlags,
nsIObserver* aObserver) override;
void SetDrawsInTitlebar(bool aState);
virtual void UpdateThemeGeometries(
const nsTArray<ThemeGeometry>& aThemeGeometries) override;
virtual nsresult SynthesizeNativeMouseEvent(
LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
nsIObserver* aObserver) override;
virtual nsresult SynthesizeNativeMouseScrollEvent(
LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
uint32_t aAdditionalFlags, nsIObserver* aObserver) override;
virtual void LockAspectRatio(bool aShouldLock) override;
void DispatchSizeModeEvent();
void DispatchOcclusionEvent();
// be notified that a some form of drag event needs to go into Gecko
virtual bool DragEvent(unsigned int aMessage, mozilla::gfx::Point aMouseGlobal,
virtual bool DragEvent(unsigned int aMessage,
mozilla::gfx::Point aMouseGlobal,
UInt16 aKeyModifiers);
bool HasModalDescendents() { return mNumModalDescendents > 0; }
@ -347,7 +360,8 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
const InputContextAction& aAction) override;
virtual InputContext GetInputContext() override { return mInputContext; }
MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
mozilla::NativeKeyBindingsType aType, const mozilla::WidgetKeyboardEvent& aEvent,
mozilla::NativeKeyBindingsType aType,
const mozilla::WidgetKeyboardEvent& aEvent,
nsTArray<mozilla::CommandInt>& aCommands) override;
void SetPopupWindowLevel();
@ -392,15 +406,15 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
protected:
virtual ~nsCocoaWindow();
nsresult CreateNativeWindow(const NSRect& aRect, BorderStyle aBorderStyle, bool aRectIsFrameRect,
bool aIsPrivateBrowsing);
nsresult CreateNativeWindow(const NSRect& aRect, BorderStyle aBorderStyle,
bool aRectIsFrameRect, bool aIsPrivateBrowsing);
nsresult CreatePopupContentView(const LayoutDeviceIntRect& aRect, InitData*);
void DestroyNativeWindow();
void UpdateBounds();
int32_t GetWorkspaceID();
void DoResize(double aX, double aY, double aWidth, double aHeight, bool aRepaint,
bool aConstrainToCurrentScreen);
void DoResize(double aX, double aY, double aWidth, double aHeight,
bool aRepaint, bool aConstrainToCurrentScreen);
void UpdateFullscreenState(bool aFullScreen, bool aNativeMode);
nsresult DoMakeFullScreen(bool aFullScreen, bool aUseSystemTransition);
@ -409,13 +423,16 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
return nsIWidget::CreateTopLevelWindow();
}
nsIWidget* mParent; // if we're a popup, this is our parent [WEAK]
nsIWidget* mAncestorLink; // link to traverse ancestors [WEAK]
BaseWindow* mWindow; // our cocoa window [STRONG]
WindowDelegate* mDelegate; // our delegate for processing window msgs [STRONG]
nsIWidget* mParent; // if we're a popup, this is our parent [WEAK]
nsIWidget* mAncestorLink; // link to traverse ancestors [WEAK]
BaseWindow* mWindow; // our cocoa window [STRONG]
WindowDelegate*
mDelegate; // our delegate for processing window msgs [STRONG]
RefPtr<nsMenuBarX> mMenuBar;
NSWindow* mSheetWindowParent; // if this is a sheet, this is the NSWindow it's attached to
nsChildView* mPopupContentView; // if this is a popup, this is its content widget
NSWindow* mSheetWindowParent; // if this is a sheet, this is the NSWindow
// it's attached to
nsChildView*
mPopupContentView; // if this is a popup, this is its content widget
// if this is a toplevel window, and there is any ongoing fullscreen
// transition, it is the animation object.
NSAnimation* mFullscreenTransitionAnimation;
@ -432,7 +449,8 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
nsSizeMode mSizeMode;
bool mInFullScreenMode;
// Whether we are currently using native fullscreen. It could be false because
// we are in the emulated fullscreen where we do not use the native fullscreen.
// we are in the emulated fullscreen where we do not use the native
// fullscreen.
bool mInNativeFullScreenMode;
mozilla::Maybe<TransitionType> mTransitionCurrent;
@ -441,11 +459,13 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
// Sometimes we add a transition that wasn't requested by a caller. We do this
// to manage transitions between states that otherwise would be rejected by
// Cocoa. When we do this, it's useful to know when we are handling an added
// transition because we don't want to send size mode events when they execute.
// transition because we don't want to send size mode events when they
// execute.
bool mIsTransitionCurrentAdded = false;
// Whether we are treating the next resize as the start of a fullscreen transition.
// If we are, which direction are we going: Fullscreen or Windowed.
// Whether we are treating the next resize as the start of a fullscreen
// transition. If we are, which direction are we going: Fullscreen or
// Windowed.
mozilla::Maybe<TransitionType> mUpdateFullscreenOnResize;
bool IsInTransition() { return mTransitionCurrent.isSome(); }
@ -454,9 +474,9 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
bool mInProcessTransitions = false;
// While running an emulated fullscreen transition, we want to suppress sending
// size mode events due to window resizing. We fix it up at the end when the
// transition is complete.
// While running an emulated fullscreen transition, we want to suppress
// sending size mode events due to window resizing. We fix it up at the end
// when the transition is complete.
bool mSuppressSizeModeEvents = false;
// Ignore occlusion events caused by displaying the temporary fullscreen

View File

@ -366,7 +366,7 @@ class nsWindow final : public nsBaseWidget {
mozilla::widget::CompositorWidgetInitData* aInitData) override;
nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) override;
void SetDrawsInTitlebar(bool aState) override;
void SetDrawsInTitlebar(bool aState);
mozilla::LayoutDeviceIntCoord GetTitlebarRadius();
LayoutDeviceIntRect GetTitlebarRect();
void UpdateWindowDraggingRegion(

View File

@ -270,7 +270,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
}
bool HasPendingInputEvent() override;
void SetIcon(const nsAString& aIconSpec) override {}
void SetDrawsInTitlebar(bool aState) override {}
bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override;
void FreeNativeData(void* data, uint32_t aDataType) override {}
nsresult ActivateNativeMenuItemAt(const nsAString& indexString) override {

View File

@ -1428,19 +1428,6 @@ class nsIWidget : public nsISupports {
*/
virtual bool HasPendingInputEvent() = 0;
/**
* If set to true, the window will draw its contents into the titlebar
* instead of below it.
*
* Ignored on any platform that does not support it. Ignored by widgets that
* do not represent windows.
* May result in a resize event, so should only be called from places where
* reflow and painting is allowed.
*
* @param aState Whether drawing into the titlebar should be activated.
*/
virtual void SetDrawsInTitlebar(bool aState) = 0;
/*
* Determine whether the widget shows a resize widget. If it does,
* aResizerRect returns the resizer's rect.

View File

@ -43,13 +43,13 @@ async function start() {
await waitForEvent(window, "focus");
var oldOuterWidth = window.outerWidth, oldOuterHeight = window.outerHeight;
var oldInnerWidth = window.innerWidth, oldInnerHeight = window.innerHeight;
document.documentElement.setAttribute("drawintitlebar", "true");
document.documentElement.setAttribute("chromemargin", "0,0,0,0");
await executeSoon();
is(window.outerWidth, oldOuterWidth, "drawintitlebar shouldn't change the window's outerWidth");
is(window.outerHeight, oldOuterHeight, "drawintitlebar shouldn't change the window's outerHeight");
is(window.innerWidth, oldOuterWidth, "if drawintitlebar is set, innerWidth and outerWidth should be the same");
is(window.innerHeight, oldOuterHeight, "if drawintitlebar is set, innerHeight and outerHeight should be the same");
is(window.outerWidth, oldOuterWidth, "chromemargin shouldn't change the window's outerWidth");
is(window.outerHeight, oldOuterHeight, "chromemargin shouldn't change the window's outerHeight");
is(window.innerWidth, oldOuterWidth, "if chromemargin is set, innerWidth and outerWidth should be the same");
is(window.innerHeight, oldOuterHeight, "if chromemargin is set, innerHeight and outerHeight should be the same");
// Wait for going full screen and back.
let sizemodeChange = waitForEvent(window, "sizemodechange");
@ -62,13 +62,13 @@ async function start() {
is(window.outerHeight, oldOuterHeight, "wrong outerHeight after fullscreen mode");
is(window.innerWidth, oldOuterWidth, "wrong innerWidth after fullscreen mode");
is(window.innerHeight, oldOuterHeight, "wrong innerHeight after fullscreen mode");
document.documentElement.removeAttribute("drawintitlebar");
document.documentElement.removeAttribute("chromemargin");
await executeSoon();
is(window.outerWidth, oldOuterWidth, "wrong outerWidth after removing drawintitlebar");
is(window.outerHeight, oldOuterHeight, "wrong outerHeight after removing drawintitlebar");
is(window.innerWidth, oldInnerWidth, "wrong innerWidth after removing drawintitlebar");
is(window.innerHeight, oldInnerHeight, "wrong innerHeight after removing drawintitlebar");
is(window.outerWidth, oldOuterWidth, "wrong outerWidth after removing chromemargin");
is(window.outerHeight, oldOuterHeight, "wrong outerHeight after removing chromemargin");
is(window.innerWidth, oldInnerWidth, "wrong innerWidth after removing chromemargin");
is(window.innerHeight, oldInnerHeight, "wrong innerHeight after removing chromemargin");
window.arguments[0].SimpleTest.finish();
window.close();
}

View File

@ -2359,8 +2359,7 @@ void nsWindow::SetFocus(Raise aRaise, mozilla::dom::CallerType aCallerType) {
* SECTION: Bounds
*
* GetBounds, GetClientBounds, GetScreenBounds,
* GetRestoredBounds, GetClientOffset
* SetDrawsInTitlebar, SetNonClientMargins
* GetRestoredBounds, GetClientOffset, SetNonClientMargins
*
* Bound calculations.
*
@ -2512,17 +2511,6 @@ LayoutDeviceIntPoint nsWindow::GetClientOffset() {
pt.y - LayoutDeviceIntCoord(r1.top));
}
void nsWindow::SetDrawsInTitlebar(bool aState) {
nsWindow* window = GetTopLevelWindow(true);
if (window && window != this) {
return window->SetDrawsInTitlebar(aState);
}
// top, right, bottom, left
SetNonClientMargins(aState ? LayoutDeviceIntMargin(0, -1, -1, -1)
: LayoutDeviceIntMargin(-1, -1, -1, -1));
}
void nsWindow::ResetLayout() {
// This will trigger a frame changed event, triggering
// nc calc size and a sizemode gecko event.

View File

@ -277,7 +277,6 @@ class nsWindow final : public nsBaseWidget {
TransparencyMode GetTransparencyMode() override;
nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) override;
void SetResizeMargin(mozilla::LayoutDeviceIntCoord aResizeMargin) override;
void SetDrawsInTitlebar(bool aState) override;
void UpdateWindowDraggingRegion(
const LayoutDeviceIntRegion& aRegion) override;

View File

@ -403,7 +403,6 @@ STATIC_ATOMS = [
Atom("draggable", "draggable"),
Atom("dragging", "dragging"),
Atom("dragSession", "dragSession"),
Atom("drawintitlebar", "drawintitlebar"),
Atom("drawtitle", "drawtitle"),
Atom("dropAfter", "dropAfter"),
Atom("dropBefore", "dropBefore"),