From 77d52c0a79f4d80d4544d8f0de45910fa8742452 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Wed, 27 Jan 2016 11:58:33 +0100 Subject: [PATCH] Bug 1241275 - Change the way -moz-window-dragging works. r=heycam,roc This adds the value -moz-window-dragging: default as the initial value of the property, and makes it a [reset] property. This allows us to change the way the window dragging region is calculated: Elements with -moz-window-dragging: no-drag will now always be undraggable, even if they are overlapped by -moz-window-dragging: drag elements. That way we can keep the region calculation simple and don't have to add code to respect z-ordering. --HG-- extra : commitid : GX3ApAyzKi7 extra : rebase_source : 61cab4e535c6c5da75fe79eb1886b6c5b7d136ea extra : amend_source : 0f461782b8f65eca1009c2f6c192b5b80b908233 --- layout/base/nsDisplayList.cpp | 18 ++++++++++++++++-- layout/base/nsDisplayList.h | 6 ++++-- layout/style/nsCSSPropList.h | 2 +- layout/style/nsCSSProps.cpp | 1 + layout/style/nsComputedDOMStyle.cpp | 2 +- layout/style/nsRuleNode.cpp | 14 +++++++------- layout/style/nsStyleConsts.h | 5 +++-- layout/style/nsStyleStruct.cpp | 13 +++++++------ layout/style/nsStyleStruct.h | 2 +- layout/style/test/property_database.js | 6 +++--- 10 files changed, 44 insertions(+), 25 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index dd0976aeeca0..4829c9777fef 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -1181,6 +1181,13 @@ nsDisplayListBuilder::AdjustWindowDraggingRegion(nsIFrame* aFrame) return; } + const nsStyleUIReset* styleUI = aFrame->StyleUIReset(); + if (styleUI->mWindowDragging == NS_STYLE_WINDOW_DRAGGING_DEFAULT) { + // This frame has the default value and doesn't influence the window + // dragging region. + return; + } + LayoutDeviceToLayoutDeviceMatrix4x4 referenceFrameToRootReferenceFrame; // The const_cast is for nsLayoutUtils::GetTransformToAncestor. @@ -1230,16 +1237,23 @@ nsDisplayListBuilder::AdjustWindowDraggingRegion(nsIFrame* aFrame) transformedDevPixelBorderBox.Round(); LayoutDeviceIntRect transformedDevPixelBorderBoxInt; if (transformedDevPixelBorderBox.ToIntRect(&transformedDevPixelBorderBoxInt)) { - const nsStyleUserInterface* styleUI = aFrame->StyleUserInterface(); if (styleUI->mWindowDragging == NS_STYLE_WINDOW_DRAGGING_DRAG) { mWindowDraggingRegion.OrWith(transformedDevPixelBorderBoxInt); } else { - mWindowDraggingRegion.SubOut(transformedDevPixelBorderBoxInt); + mWindowNoDraggingRegion.OrWith(transformedDevPixelBorderBoxInt); } } } } +LayoutDeviceIntRegion +nsDisplayListBuilder::GetWindowDraggingRegion() const +{ + LayoutDeviceIntRegion result; + result.Sub(mWindowDraggingRegion, mWindowNoDraggingRegion);; + return result; +} + const uint32_t gWillChangeAreaMultiplier = 3; static uint32_t GetWillChangeCost(const nsSize& aSize) { // There's significant overhead for each layer created from Gecko diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index e642f95c85bf..c730e9db3b73 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -614,11 +614,12 @@ public: * Adjusts mWindowDraggingRegion to take into account aFrame. If aFrame's * -moz-window-dragging value is |drag|, its border box is added to the * collected dragging region; if the value is |no-drag|, the border box is - * subtracted from the region. + * subtracted from the region; if the value is |default|, that frame does + * not influence the window dragging region. */ void AdjustWindowDraggingRegion(nsIFrame* aFrame); - const LayoutDeviceIntRegion& GetWindowDraggingRegion() { return mWindowDraggingRegion; } + LayoutDeviceIntRegion GetWindowDraggingRegion() const; /** * Allocate memory in our arena. It will only be freed when this display list @@ -1227,6 +1228,7 @@ private: nsRegion mWindowExcludeGlassRegion; nsRegion mWindowOpaqueRegion; LayoutDeviceIntRegion mWindowDraggingRegion; + LayoutDeviceIntRegion mWindowNoDraggingRegion; // The display item for the Windows window glass background, if any nsDisplayItem* mGlassDisplayItem; // When encountering inactive layers, we need to hoist scroll info items diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 1e6e611a1f59..097efda7c075 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -3674,7 +3674,7 @@ CSS_PROP_POSITION( kWidthKTable, offsetof(nsStylePosition, mWidth), eStyleAnimType_Coord) -CSS_PROP_USERINTERFACE( +CSS_PROP_UIRESET( -moz-window-dragging, _moz_window_dragging, CSS_PROP_DOMPROP_PREFIXED(WindowDragging), diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 5d1dea9adb3d..c1241b55a32d 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -2116,6 +2116,7 @@ const KTableEntry nsCSSProps::kWidthKTable[] = { }; const KTableEntry nsCSSProps::kWindowDraggingKTable[] = { + { eCSSKeyword_default, NS_STYLE_WINDOW_DRAGGING_DEFAULT }, { eCSSKeyword_drag, NS_STYLE_WINDOW_DRAGGING_DRAG }, { eCSSKeyword_no_drag, NS_STYLE_WINDOW_DRAGGING_NO_DRAG }, { eCSSKeyword_UNKNOWN, -1 } diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index b9d9dc34c788..0dd0d51c4669 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -3844,7 +3844,7 @@ nsComputedDOMStyle::DoGetWindowDragging() { RefPtr val = new nsROCSSPrimitiveValue; val->SetIdent( - nsCSSProps::ValueToKeywordEnum(StyleUserInterface()->mWindowDragging, + nsCSSProps::ValueToKeywordEnum(StyleUIReset()->mWindowDragging, nsCSSProps::kWindowDraggingKTable)); return val.forget(); } diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index f35694f6c5f7..72526d02d504 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4863,13 +4863,6 @@ nsRuleNode::ComputeUserInterfaceData(void* aStartStruct, parentUI->mUserFocus, NS_STYLE_USER_FOCUS_NONE, 0, 0, 0, 0); - // -moz-window-dragging: enum, inherit, initial - SetDiscrete(*aRuleData->ValueForWindowDragging(), - ui->mWindowDragging, conditions, - SETDSC_ENUMERATED | SETDSC_UNSET_INHERIT, - parentUI->mWindowDragging, - NS_STYLE_WINDOW_DRAGGING_NO_DRAG, 0, 0, 0, 0); - COMPUTE_END_INHERITED(UserInterface, ui) } @@ -4905,6 +4898,13 @@ nsRuleNode::ComputeUIResetData(void* aStartStruct, parentUI->mForceBrokenImageIcon, 0, 0, 0, 0, 0); + // -moz-window-dragging: enum, inherit, initial + SetDiscrete(*aRuleData->ValueForWindowDragging(), + ui->mWindowDragging, conditions, + SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL, + parentUI->mWindowDragging, + NS_STYLE_WINDOW_DRAGGING_DEFAULT, 0, 0, 0, 0); + // -moz-window-shadow: enum, inherit, initial SetDiscrete(*aRuleData->ValueForWindowShadow(), ui->mWindowShadow, conditions, diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index a2efa958f3da..ffa27adf5d5e 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -120,8 +120,9 @@ enum class StyleBoxSizing : uint8_t { #define NS_STYLE_USER_MODIFY_WRITE_ONLY 2 // -moz-window-dragging -#define NS_STYLE_WINDOW_DRAGGING_DRAG 0 -#define NS_STYLE_WINDOW_DRAGGING_NO_DRAG 1 +#define NS_STYLE_WINDOW_DRAGGING_DEFAULT 0 +#define NS_STYLE_WINDOW_DRAGGING_DRAG 1 +#define NS_STYLE_WINDOW_DRAGGING_NO_DRAG 2 // box-align #define NS_STYLE_BOX_ALIGN_STRETCH 0 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 1384b78eb2a8..c0cdab7efca0 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -3789,7 +3789,6 @@ nsStyleUserInterface::nsStyleUserInterface(void) mUserInput = NS_STYLE_USER_INPUT_AUTO; mUserModify = NS_STYLE_USER_MODIFY_READ_ONLY; mUserFocus = NS_STYLE_USER_FOCUS_NONE; - mWindowDragging = NS_STYLE_WINDOW_DRAGGING_NO_DRAG; mCursor = NS_STYLE_CURSOR_AUTO; // fix for bugzilla bug 51113 @@ -3801,7 +3800,6 @@ nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource) mUserInput(aSource.mUserInput), mUserModify(aSource.mUserModify), mUserFocus(aSource.mUserFocus), - mWindowDragging(aSource.mWindowDragging), mCursor(aSource.mCursor) { MOZ_COUNT_CTOR(nsStyleUserInterface); @@ -3841,10 +3839,6 @@ nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aO NS_UpdateHint(hint, nsChangeHint_NeutralChange); } - if (mWindowDragging != aOther.mWindowDragging) { - NS_UpdateHint(hint, nsChangeHint_SchedulePaint); - } - return hint; } @@ -3873,6 +3867,7 @@ nsStyleUIReset::nsStyleUIReset(void) mUserSelect = NS_STYLE_USER_SELECT_AUTO; mForceBrokenImageIcon = 0; mIMEMode = NS_STYLE_IME_MODE_AUTO; + mWindowDragging = NS_STYLE_WINDOW_DRAGGING_DEFAULT; mWindowShadow = NS_STYLE_WINDOW_SHADOW_DEFAULT; } @@ -3882,6 +3877,7 @@ nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource) mUserSelect = aSource.mUserSelect; mForceBrokenImageIcon = aSource.mForceBrokenImageIcon; mIMEMode = aSource.mIMEMode; + mWindowDragging = aSource.mWindowDragging; mWindowShadow = aSource.mWindowShadow; } @@ -3903,6 +3899,11 @@ nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const } if (mUserSelect != aOther.mUserSelect) return NS_STYLE_HINT_VISUAL; + + if (mWindowDragging != aOther.mWindowDragging) { + return nsChangeHint_SchedulePaint; + } + return NS_STYLE_HINT_NONE; } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 5217d95ed6d7..00501a57fffe 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -2951,6 +2951,7 @@ struct nsStyleUIReset uint8_t mUserSelect; // [reset] (selection-style) uint8_t mForceBrokenImageIcon; // [reset] (0 if not forcing, otherwise forcing) uint8_t mIMEMode; // [reset] + uint8_t mWindowDragging; // [reset] uint8_t mWindowShadow; // [reset] }; @@ -3017,7 +3018,6 @@ struct nsStyleUserInterface uint8_t mUserInput; // [inherited] uint8_t mUserModify; // [inherited] (modify-content) uint8_t mUserFocus; // [inherited] (auto-select) - uint8_t mWindowDragging; // [inherited] uint8_t mCursor; // [inherited] See nsStyleConsts.h diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 65fedf5984f2..ca2697872d71 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -4434,10 +4434,10 @@ var gCSSProperties = { }, "-moz-window-dragging": { domProp: "MozWindowDragging", - inherited: true, + inherited: false, type: CSS_TYPE_LONGHAND, - initial_values: [ "no-drag" ], - other_values: [ "drag" ], + initial_values: [ "default" ], + other_values: [ "drag", "no-drag" ], invalid_values: [ "none" ] }, "align-content": {