зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1872399 - Clean-up -moz-window-shadow set-up. r=dholbert
-moz-window-shadow is a chrome-only property (not exposed to the web), and chrome stylesheets only use the none value to disable the default behavior. Split the style property (default/none) from the actual widget behavior. This is useful because I want to add a distinction between natively-styled menupopups and other panels in the following commit. While at it rename default to "auto" which is a more common name in CSS for something like this. We have no use case for removing the shadow of a top-level window, so remove it to simplify the code. Differential Revision: https://phabricator.services.mozilla.com/D197454
This commit is contained in:
Родитель
f9e6ed2f41
Коммит
35c465dca0
|
@ -11604,9 +11604,7 @@ void PresShell::SyncWindowProperties(bool aSync) {
|
|||
auto* canvas = GetCanvasFrame();
|
||||
widget::TransparencyMode mode = nsLayoutUtils::GetFrameTransparency(
|
||||
canvas ? canvas : rootFrame, rootFrame);
|
||||
StyleWindowShadow shadow = rootFrame->StyleUIReset()->mWindowShadow;
|
||||
windowWidget->SetTransparencyMode(mode);
|
||||
windowWidget->SetWindowShadowStyle(shadow);
|
||||
|
||||
// For macOS, apply color scheme overrides to the top level window widget.
|
||||
if (auto scheme = pc->GetOverriddenOrEmbedderColorScheme()) {
|
||||
|
|
|
@ -475,18 +475,10 @@ enum class StyleImeMode : uint8_t {
|
|||
|
||||
// See nsStyleSVG
|
||||
|
||||
/*
|
||||
* -moz-window-shadow
|
||||
* Also used in widget code
|
||||
*/
|
||||
// -moz-window-shadow
|
||||
enum class StyleWindowShadow : uint8_t {
|
||||
Auto,
|
||||
None,
|
||||
Default,
|
||||
|
||||
// These can't be specified in CSS, they get computed from the "default"
|
||||
// value.
|
||||
Menu,
|
||||
Tooltip,
|
||||
};
|
||||
|
||||
// dominant-baseline
|
||||
|
|
|
@ -3064,7 +3064,7 @@ nsStyleUIReset::nsStyleUIReset()
|
|||
mMozSubtreeHiddenOnlyVisually(false),
|
||||
mIMEMode(StyleImeMode::Auto),
|
||||
mWindowDragging(StyleWindowDragging::Default),
|
||||
mWindowShadow(StyleWindowShadow::Default),
|
||||
mWindowShadow(StyleWindowShadow::Auto),
|
||||
mWindowOpacity(1.0),
|
||||
mMozWindowInputRegionMargin(StyleLength::Zero()),
|
||||
mWindowTransformOrigin{LengthPercentage::FromPercentage(0.5),
|
||||
|
|
|
@ -369,19 +369,20 @@ bool nsMenuPopupFrame::IsMouseTransparent() const {
|
|||
return ::IsMouseTransparent(*Style());
|
||||
}
|
||||
|
||||
StyleWindowShadow nsMenuPopupFrame::GetShadowStyle() const {
|
||||
WindowShadow nsMenuPopupFrame::GetShadowStyle() const {
|
||||
StyleWindowShadow shadow = StyleUIReset()->mWindowShadow;
|
||||
if (shadow != StyleWindowShadow::Default) {
|
||||
return shadow;
|
||||
if (shadow != StyleWindowShadow::Auto) {
|
||||
MOZ_ASSERT(shadow == StyleWindowShadow::None);
|
||||
return WindowShadow::None;
|
||||
}
|
||||
|
||||
switch (StyleDisplay()->EffectiveAppearance()) {
|
||||
case StyleAppearance::Tooltip:
|
||||
return StyleWindowShadow::Tooltip;
|
||||
return WindowShadow::Tooltip;
|
||||
case StyleAppearance::Menupopup:
|
||||
return StyleWindowShadow::Menu;
|
||||
return WindowShadow::Menu;
|
||||
default:
|
||||
return StyleWindowShadow::Default;
|
||||
return WindowShadow::Menu;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "mozilla/StaticPrefs_ui.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsXULPopupManager.h"
|
||||
|
@ -29,6 +28,7 @@ class nsIWidget;
|
|||
|
||||
namespace mozilla {
|
||||
class PresShell;
|
||||
enum class WindowShadow : uint8_t;
|
||||
namespace dom {
|
||||
class KeyboardEvent;
|
||||
class XULButtonElement;
|
||||
|
@ -219,7 +219,7 @@ class nsMenuPopupFrame final : public nsBlockFrame {
|
|||
MOZ_CAN_RUN_SCRIPT void EnsureActiveMenuListItemIsVisible();
|
||||
|
||||
nsresult CreateWidgetForView(nsView* aView);
|
||||
mozilla::StyleWindowShadow GetShadowStyle() const;
|
||||
mozilla::WindowShadow GetShadowStyle() const;
|
||||
|
||||
void DidSetComputedStyle(ComputedStyle* aOldStyle) override;
|
||||
|
||||
|
|
|
@ -55,15 +55,14 @@ ${helpers.single_keyword(
|
|||
affects="paint",
|
||||
)}
|
||||
|
||||
// TODO(emilio): Maybe make shadow behavior on macOS match Linux / Windows, and remove this
|
||||
// property.
|
||||
// TODO(emilio): Maybe make shadow behavior on macOS match Linux / Windows, and remove this? But
|
||||
// that requires making -moz-window-input-region-margin work there...
|
||||
${helpers.single_keyword(
|
||||
"-moz-window-shadow",
|
||||
"default none",
|
||||
"auto none",
|
||||
engines="gecko",
|
||||
gecko_ffi_name="mWindowShadow",
|
||||
gecko_enum_prefix="StyleWindowShadow",
|
||||
gecko_inexhaustive=True,
|
||||
animation_value_type="discrete",
|
||||
enabled_in="chrome",
|
||||
spec="None (Nonstandard internal property)",
|
||||
|
|
|
@ -107,8 +107,8 @@ typedef struct _nsCocoaWindowList {
|
|||
|
||||
- (NSRect)getAndResetNativeDirtyRect;
|
||||
|
||||
- (void)setEffectViewWrapperForStyle:(mozilla::StyleWindowShadow)aStyle;
|
||||
@property(nonatomic) mozilla::StyleWindowShadow shadowStyle;
|
||||
- (void)setEffectViewWrapperForStyle:(mozilla::WindowShadow)aStyle;
|
||||
@property(nonatomic) mozilla::WindowShadow shadowStyle;
|
||||
|
||||
- (void)releaseJSObjects;
|
||||
|
||||
|
@ -316,7 +316,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
virtual bool HasPendingInputEvent() override;
|
||||
virtual TransparencyMode GetTransparencyMode() override;
|
||||
virtual void SetTransparencyMode(TransparencyMode aMode) override;
|
||||
virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) override;
|
||||
virtual void SetWindowShadowStyle(mozilla::WindowShadow aStyle) override;
|
||||
virtual void SetWindowOpacity(float aOpacity) override;
|
||||
virtual void SetWindowTransform(
|
||||
const mozilla::gfx::Matrix& aTransform) override;
|
||||
|
@ -434,8 +434,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
// if this is a toplevel window, and there is any ongoing fullscreen
|
||||
// transition, it is the animation object.
|
||||
NSAnimation* mFullscreenTransitionAnimation;
|
||||
mozilla::StyleWindowShadow mShadowStyle;
|
||||
BOOL mIsShadowStyleSet;
|
||||
mozilla::WindowShadow mShadowStyle;
|
||||
|
||||
CGFloat mBackingScaleFactor;
|
||||
CGFloat mAspectRatio;
|
||||
|
|
|
@ -142,8 +142,7 @@ nsCocoaWindow::nsCocoaWindow()
|
|||
mSheetWindowParent(nil),
|
||||
mPopupContentView(nil),
|
||||
mFullscreenTransitionAnimation(nil),
|
||||
mShadowStyle(StyleWindowShadow::Default),
|
||||
mIsShadowStyleSet(NO),
|
||||
mShadowStyle(WindowShadow::None),
|
||||
mBackingScaleFactor(0.0),
|
||||
mAnimationType(nsIWidget::eGenericWindowAnimation),
|
||||
mWindowMadeHere(false),
|
||||
|
@ -2682,10 +2681,10 @@ bool nsCocoaWindow::HasPendingInputEvent() {
|
|||
return nsChildView::DoHasPendingInputEvent();
|
||||
}
|
||||
|
||||
void nsCocoaWindow::SetWindowShadowStyle(StyleWindowShadow aStyle) {
|
||||
void nsCocoaWindow::SetWindowShadowStyle(WindowShadow aStyle) {
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
|
||||
if (mShadowStyle == aStyle && mIsShadowStyleSet) {
|
||||
if (mShadowStyle == aStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2697,8 +2696,7 @@ void nsCocoaWindow::SetWindowShadowStyle(StyleWindowShadow aStyle) {
|
|||
|
||||
mWindow.shadowStyle = mShadowStyle;
|
||||
[mWindow setEffectViewWrapperForStyle:mShadowStyle];
|
||||
[mWindow setHasShadow:aStyle != StyleWindowShadow::None];
|
||||
mIsShadowStyleSet = YES;
|
||||
[mWindow setHasShadow:aStyle != WindowShadow::None];
|
||||
|
||||
NS_OBJC_END_TRY_IGNORE_BLOCK;
|
||||
}
|
||||
|
@ -3618,12 +3616,11 @@ static NSImage* GetMenuMaskImage() {
|
|||
[super setContentView:aNewWrapper];
|
||||
}
|
||||
|
||||
- (void)setEffectViewWrapperForStyle:(StyleWindowShadow)aStyle {
|
||||
if (aStyle == StyleWindowShadow::Menu ||
|
||||
aStyle == StyleWindowShadow::Tooltip) {
|
||||
- (void)setEffectViewWrapperForStyle:(WindowShadow)aStyle {
|
||||
if (aStyle == WindowShadow::Menu || aStyle == WindowShadow::Tooltip) {
|
||||
// Add an effect view wrapper so that the OS draws the appropriate
|
||||
// vibrancy effect and window border.
|
||||
BOOL isMenu = aStyle == StyleWindowShadow::Menu;
|
||||
BOOL isMenu = aStyle == WindowShadow::Menu;
|
||||
NSView* effectView = VibrancyManager::CreateEffectView(
|
||||
isMenu ? VibrancyType::MENU : VibrancyType::TOOLTIP, YES);
|
||||
if (isMenu) {
|
||||
|
@ -4442,14 +4439,13 @@ static const NSUInteger kWindowShadowOptionsTooltip = 4;
|
|||
}
|
||||
|
||||
switch (self.shadowStyle) {
|
||||
case StyleWindowShadow::None:
|
||||
case WindowShadow::None:
|
||||
return kWindowShadowOptionsNoShadow;
|
||||
|
||||
case StyleWindowShadow::Default: // we treat "default" as "default panel"
|
||||
case StyleWindowShadow::Menu:
|
||||
case WindowShadow::Menu:
|
||||
return kWindowShadowOptionsMenu;
|
||||
|
||||
case StyleWindowShadow::Tooltip:
|
||||
case WindowShadow::Tooltip:
|
||||
return kWindowShadowOptionsTooltip;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
|
|||
}
|
||||
void SetTransparencyMode(TransparencyMode aMode) override;
|
||||
TransparencyMode GetTransparencyMode() override;
|
||||
void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) override {}
|
||||
void SetWindowShadowStyle(mozilla::WindowShadow) override {}
|
||||
void SetShowsToolbarButton(bool aShow) override {}
|
||||
void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) override {}
|
||||
void SetWindowAnimationType(WindowAnimationType aType) override {}
|
||||
|
|
|
@ -58,11 +58,15 @@ class WidgetGUIEvent;
|
|||
class WidgetInputEvent;
|
||||
class WidgetKeyboardEvent;
|
||||
struct FontRange;
|
||||
|
||||
enum class StyleWindowShadow : uint8_t;
|
||||
enum class ColorScheme : uint8_t;
|
||||
enum class WindowButtonType : uint8_t;
|
||||
|
||||
enum class WindowShadow : uint8_t {
|
||||
None,
|
||||
Menu,
|
||||
Tooltip,
|
||||
};
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
namespace ipc {
|
||||
class Shmem;
|
||||
|
@ -1046,7 +1050,7 @@ class nsIWidget : public nsISupports {
|
|||
*
|
||||
* Ignored on child widgets and on non-Mac platforms.
|
||||
*/
|
||||
virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) = 0;
|
||||
virtual void SetWindowShadowStyle(mozilla::WindowShadow aStyle) = 0;
|
||||
|
||||
/**
|
||||
* Set the opacity of the window.
|
||||
|
|
Загрузка…
Ссылка в новой задаче