Bug 1370034 - Add -moz-window-opacity property, style system parts (excluding stylo). r=dbaron
authorMarkus Stange <mstange@themasta.com>
Sun, 18 Jun 2017 21:04:40 -0400
changeset 364593 c99450001fa1d422a7568ecf6a9d65a376dcee00
parent 364592 afb0e8bf4fccd832404982e80ca4b363551b19d5
child 364594 28e733821d73b4087c1dfd94fedcc652824a9f6a
push id32049
push usercbook@mozilla.com
push dateMon, 19 Jun 2017 11:36:23 +0000
treeherdermozilla-central@26d62a1ac0e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1370034
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1370034 - Add -moz-window-opacity property, style system parts (excluding stylo). r=dbaron MozReview-Commit-ID: J2SPMzh0I9C
devtools/shared/css/generated/properties-db.js
layout/base/RestyleManager.cpp
layout/base/nsChangeHint.h
layout/generic/nsIFrame.h
layout/style/nsCSSPropList.h
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
layout/style/nsComputedDOMStylePropertyList.h
layout/style/nsRuleNode.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/style/test/ListCSSProperties.cpp
layout/style/test/property_database.js
--- a/devtools/shared/css/generated/properties-db.js
+++ b/devtools/shared/css/generated/properties-db.js
@@ -1496,16 +1496,30 @@ exports.CSS_PROPERTIES = {
       "default",
       "drag",
       "inherit",
       "initial",
       "no-drag",
       "unset"
     ]
   },
+  "-moz-window-opacity": {
+    "isInherited": false,
+    "subproperties": [
+      "-moz-window-opacity"
+    ],
+    "supports": [
+      7
+    ],
+    "values": [
+      "inherit",
+      "initial",
+      "unset"
+    ]
+  },
   "-webkit-align-content": {
     "isInherited": false,
     "subproperties": [
       "align-content"
     ],
     "supports": [],
     "values": [
       "baseline",
@@ -3145,16 +3159,17 @@ exports.CSS_PROPERTIES = {
       "vector-effect",
       "vertical-align",
       "visibility",
       "white-space",
       "width",
       "will-change",
       "-moz-window-dragging",
       "-moz-window-shadow",
+      "-moz-window-opacity",
       "word-break",
       "word-spacing",
       "overflow-wrap",
       "writing-mode",
       "z-index"
     ],
     "supports": [
       1,
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -454,16 +454,17 @@ RestyleManager::ChangeHintToString(nsCha
     "UpdateSubtreeOverflow", "UpdatePostTransformOverflow",
     "UpdateParentOverflow",
     "ChildrenOnlyTransform", "RecomputePosition", "UpdateContainingBlock",
     "BorderStyleNoneChange", "UpdateTextPath", "SchedulePaint",
     "NeutralChange", "InvalidateRenderingObservers",
     "ReflowChangesSizeOrPosition", "UpdateComputedBSize",
     "UpdateUsesOpacity", "UpdateBackgroundPosition",
     "AddOrRemoveTransform", "CSSOverflowChange",
+    "UpdateWidgetProperties"
   };
   static_assert(nsChangeHint_AllHints == (1 << ArrayLength(names)) - 1,
                 "Name list doesn't match change hints.");
   uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
   uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
   if ((hint & NS_STYLE_HINT_REFLOW) == NS_STYLE_HINT_REFLOW) {
     result.AppendLiteral("NS_STYLE_HINT_REFLOW");
     hint = hint & ~NS_STYLE_HINT_REFLOW;
@@ -1708,16 +1709,19 @@ RestyleManager::ProcessRestyledFrames(ns
             }
           }
         }
       }
       if ((hint & nsChangeHint_UpdateCursor) && !didUpdateCursor) {
         presContext->PresShell()->SynthesizeMouseMove(false);
         didUpdateCursor = true;
       }
+      if (hint & nsChangeHint_UpdateWidgetProperties) {
+        frame->UpdateWidgetProperties();
+      }
     }
   }
 
   frameConstructor->EndUpdate();
   mDestroyedFrames.reset(nullptr);
 
 #ifdef DEBUG
   // Verify the style tree.  Note that this needs to happen once we've
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -227,32 +227,38 @@ enum nsChangeHint : uint32_t {
    *
    * In most cases, this is equivalent to nsChangeHint_ReconstructFrame. But
    * in some special cases where the change is really targeting the viewport's
    * scrollframe, this is instead equivalent to nsChangeHint_AllReflowHints
    * (because the viewport always has an associated scrollframe).
    */
   nsChangeHint_CSSOverflowChange = 1 << 28,
 
+  /**
+   * Indicates that nsIFrame::UpdateWidgetProperties needs to be called.
+   * This is used for -moz-window-* properties.
+   */
+  nsChangeHint_UpdateWidgetProperties = 1 << 29,
+
   // IMPORTANT NOTE: When adding a new hint, you will need to add it to
   // one of:
   //
   //   * nsChangeHint_Hints_NeverHandledForDescendants
   //   * nsChangeHint_Hints_AlwaysHandledForDescendants
   //   * nsChangeHint_Hints_SometimesHandledForDescendants
   //
   // and you also may need to handle it in NS_HintsNotHandledForDescendantsIn.
   //
   // Please also add it to RestyleManager::ChangeHintToString and
   // modify nsChangeHint_AllHints below accordingly.
 
   /**
    * Dummy hint value for all hints. It exists for compile time check.
    */
-  nsChangeHint_AllHints = (1 << 29) - 1,
+  nsChangeHint_AllHints = (1 << 30) - 1,
 };
 
 // Redefine these operators to return nothing. This will catch any use
 // of these operators on hints. We should not be using these operators
 // on nsChangeHints
 inline void operator<(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator>(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator!=(nsChangeHint s1, nsChangeHint s2) {}
@@ -344,17 +350,18 @@ inline nsChangeHint operator^=(nsChangeH
   nsChangeHint_UpdateContainingBlock |                     \
   nsChangeHint_UpdateEffects |                             \
   nsChangeHint_UpdateOpacityLayer |                        \
   nsChangeHint_UpdateOverflow |                            \
   nsChangeHint_UpdateParentOverflow |                      \
   nsChangeHint_UpdatePostTransformOverflow |               \
   nsChangeHint_UpdateTransformLayer |                      \
   nsChangeHint_UpdateUsesOpacity |                         \
-  nsChangeHint_AddOrRemoveTransform                        \
+  nsChangeHint_AddOrRemoveTransform |                      \
+  nsChangeHint_UpdateWidgetProperties                      \
 )
 
 // The change hints that are sometimes considered to be handled for descendants.
 #define nsChangeHint_Hints_SometimesHandledForDescendants (\
   nsChangeHint_ClearAncestorIntrinsics |                   \
   nsChangeHint_NeedReflow |                                \
   nsChangeHint_ReflowChangesSizeOrPosition                 \
 )
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3929,16 +3929,18 @@ public:
     return StyleDisplay()->BackfaceIsHidden();
   }
 
   /**
    * Returns true if the frame is scrolled out of view.
    */
   bool IsScrolledOutOfView();
 
+  virtual void UpdateWidgetProperties() {}
+
   /**
    * @return true iff this frame has one or more associated image requests.
    * @see mozilla::css::ImageLoader.
    */
   bool HasImageRequest() const { return mHasImageRequest; }
 
   /**
    * Update this frame's image request state.
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -4489,16 +4489,26 @@ CSS_PROP_UIRESET(
     CSS_PROPERTY_INTERNAL |
         CSS_PROPERTY_PARSE_VALUE |
         CSS_PROPERTY_ENABLED_IN_UA_SHEETS_AND_CHROME,
     "",
     VARIANT_HK,
     kWindowShadowKTable,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_None)
+CSS_PROP_UIRESET(
+    -moz-window-opacity,
+    _moz_window_opacity,
+    CSS_PROP_DOMPROP_PREFIXED(WindowOpacity),
+    CSS_PROPERTY_INTERNAL | CSS_PROPERTY_PARSE_VALUE,
+    "",
+    VARIANT_HN,
+    nullptr,
+    offsetof(nsStyleUIReset, mWindowOpacity),
+    eStyleAnimType_float)
 #endif // CSS_PROP_LIST_EXCLUDE_INTERNAL
 CSS_PROP_TEXT(
     word-break,
     word_break,
     WordBreak,
     CSS_PROPERTY_PARSE_VALUE,
     "",
     VARIANT_HK,
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -4222,16 +4222,24 @@ nsComputedDOMStyle::DoGetWindowShadow()
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(
     nsCSSProps::ValueToKeywordEnum(StyleUIReset()->mWindowShadow,
                                    nsCSSProps::kWindowShadowKTable));
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
+nsComputedDOMStyle::DoGetWindowOpacity()
+{
+  RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
+  val->SetNumber(StyleUIReset()->mWindowOpacity);
+  return val.forget();
+}
+
+already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetWordBreak()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(
     nsCSSProps::ValueToKeywordEnum(StyleText()->mWordBreak,
                                    nsCSSProps::kWordBreakKTable));
   return val.forget();
 }
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -523,16 +523,17 @@ private:
   already_AddRefed<CSSValue> DoGetCursor();
   already_AddRefed<CSSValue> DoGetForceBrokenImageIcon();
   already_AddRefed<CSSValue> DoGetIMEMode();
   already_AddRefed<CSSValue> DoGetUserFocus();
   already_AddRefed<CSSValue> DoGetUserInput();
   already_AddRefed<CSSValue> DoGetUserModify();
   already_AddRefed<CSSValue> DoGetUserSelect();
   already_AddRefed<CSSValue> DoGetWindowDragging();
+  already_AddRefed<CSSValue> DoGetWindowOpacity();
 
   /* Column properties */
   already_AddRefed<CSSValue> DoGetColumnCount();
   already_AddRefed<CSSValue> DoGetColumnFill();
   already_AddRefed<CSSValue> DoGetColumnSpan();
   already_AddRefed<CSSValue> DoGetColumnWidth();
   already_AddRefed<CSSValue> DoGetColumnGap();
   already_AddRefed<CSSValue> DoGetColumnRuleWidth();
--- a/layout/style/nsComputedDOMStylePropertyList.h
+++ b/layout/style/nsComputedDOMStylePropertyList.h
@@ -300,16 +300,17 @@ COMPUTED_STYLE_PROP(_moz_stack_sizing,  
 COMPUTED_STYLE_PROP(_moz_tab_size,                 TabSize)
 COMPUTED_STYLE_PROP(_moz_text_size_adjust,         TextSizeAdjust)
 COMPUTED_STYLE_PROP(_moz_user_focus,               UserFocus)
 COMPUTED_STYLE_PROP(_moz_user_input,               UserInput)
 COMPUTED_STYLE_PROP(_moz_user_modify,              UserModify)
 COMPUTED_STYLE_PROP(_moz_user_select,              UserSelect)
 COMPUTED_STYLE_PROP(_moz_window_dragging,          WindowDragging)
 COMPUTED_STYLE_PROP(_moz_window_shadow,            WindowShadow)
+COMPUTED_STYLE_PROP(_moz_window_opacity,           WindowOpacity)
 
 /* ********************************** *\
  * Implementations of -webkit- styles *
 \* ********************************** */
 
 COMPUTED_STYLE_PROP(_webkit_text_fill_color,       WebkitTextFillColor)
 //// COMPUTED_STYLE_PROP(webkit-text-stroke,       WebkitTextStroke)
 COMPUTED_STYLE_PROP(_webkit_text_stroke_color,     WebkitTextStrokeColor)
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -5270,16 +5270,22 @@ nsRuleNode::ComputeUIResetData(void* aSt
 
   // -moz-window-shadow: enum, inherit, initial
   SetValue(*aRuleData->ValueForWindowShadow(),
            ui->mWindowShadow, conditions,
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parentUI->mWindowShadow,
            NS_STYLE_WINDOW_SHADOW_DEFAULT);
 
+  // -moz-window-opacity: factor, inherit, initial
+  SetFactor(*aRuleData->ValueForWindowOpacity(),
+            ui->mWindowOpacity, conditions,
+            parentUI->mWindowOpacity, 1.0f,
+            SETFCT_OPACITY | SETFCT_UNSET_INITIAL);
+
   COMPUTE_END_RESET(UIReset, ui)
 }
 
 // Information about each transition or animation property that is
 // constant.
 struct TransitionPropInfo {
   nsCSSPropertyID property;
   // Location of the count of the property's computed value.
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -4321,61 +4321,69 @@ nsStyleUserInterface::CalcDifference(con
 //
 
 nsStyleUIReset::nsStyleUIReset(const nsPresContext* aContext)
   : mUserSelect(StyleUserSelect::Auto)
   , mForceBrokenImageIcon(0)
   , mIMEMode(NS_STYLE_IME_MODE_AUTO)
   , mWindowDragging(StyleWindowDragging::Default)
   , mWindowShadow(NS_STYLE_WINDOW_SHADOW_DEFAULT)
+  , mWindowOpacity(1.0)
 {
   MOZ_COUNT_CTOR(nsStyleUIReset);
 }
 
 nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
   : mUserSelect(aSource.mUserSelect)
   , mForceBrokenImageIcon(aSource.mForceBrokenImageIcon)
   , mIMEMode(aSource.mIMEMode)
   , mWindowDragging(aSource.mWindowDragging)
   , mWindowShadow(aSource.mWindowShadow)
+  , mWindowOpacity(aSource.mWindowOpacity)
 {
   MOZ_COUNT_CTOR(nsStyleUIReset);
 }
 
 nsStyleUIReset::~nsStyleUIReset()
 {
   MOZ_COUNT_DTOR(nsStyleUIReset);
 }
 
 nsChangeHint
 nsStyleUIReset::CalcDifference(const nsStyleUIReset& aNewData) const
 {
-  // ignore mIMEMode
+  nsChangeHint hint = nsChangeHint(0);
+
   if (mForceBrokenImageIcon != aNewData.mForceBrokenImageIcon) {
-    return nsChangeHint_ReconstructFrame;
+    hint |= nsChangeHint_ReconstructFrame;
   }
   if (mWindowShadow != aNewData.mWindowShadow) {
     // We really need just an nsChangeHint_SyncFrameView, except
     // on an ancestor of the frame, so we get that by doing a
     // reflow.
-    return NS_STYLE_HINT_REFLOW;
+    hint |= NS_STYLE_HINT_REFLOW;
   }
   if (mUserSelect != aNewData.mUserSelect) {
-    return NS_STYLE_HINT_VISUAL;
+    hint |= NS_STYLE_HINT_VISUAL;
   }
 
   if (mWindowDragging != aNewData.mWindowDragging) {
-    return nsChangeHint_SchedulePaint;
-  }
-
-  if (mIMEMode != aNewData.mIMEMode) {
-    return nsChangeHint_NeutralChange;
-  }
-
-  return nsChangeHint(0);
+    hint |= nsChangeHint_SchedulePaint;
+  }
+
+  if (mWindowOpacity != aNewData.mWindowOpacity) {
+    hint |= nsChangeHint_UpdateWidgetProperties;
+  }
+
+  if (!hint &&
+      mIMEMode != aNewData.mIMEMode) {
+    hint |= nsChangeHint_NeutralChange;
+  }
+
+  return hint;
 }
 
 //-----------------------
 // nsStyleVariables
 //
 
 nsStyleVariables::nsStyleVariables()
 {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3223,16 +3223,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
 
   nsChangeHint CalcDifference(const nsStyleUIReset& aNewData) const;
 
   mozilla::StyleUserSelect     mUserSelect;     // [reset](selection-style)
   uint8_t mForceBrokenImageIcon; // [reset] (0 if not forcing, otherwise forcing)
   uint8_t                      mIMEMode;        // [reset]
   mozilla::StyleWindowDragging mWindowDragging; // [reset]
   uint8_t                      mWindowShadow;   // [reset]
+  float                        mWindowOpacity;  // [reset]
 };
 
 struct nsCursorImage
 {
   bool mHaveHotspot;
   float mHotspotX, mHotspotY;
   RefPtr<nsStyleImageRequest> mImage;
 
--- a/layout/style/test/ListCSSProperties.cpp
+++ b/layout/style/test/ListCSSProperties.cpp
@@ -110,16 +110,17 @@ const char *gInaccessibleProperties[] = 
     "-moz-control-character-visibility",
     "-moz-script-level", // parsed by UA sheets only
     "-moz-script-size-multiplier",
     "-moz-script-min-size",
     "-moz-math-variant",
     "-moz-math-display", // parsed by UA sheets only
     "-moz-top-layer", // parsed by UA sheets only
     "-moz-min-font-size-ratio", // parsed by UA sheets only
+    "-moz-window-opacity", // chrome-only internal properties
     "-moz-window-shadow" // chrome-only internal properties
 };
 
 inline int
 is_inaccessible(const char* aPropName)
 {
     for (unsigned j = 0; j < MOZ_ARRAY_LENGTH(gInaccessibleProperties); ++j) {
         if (strcmp(aPropName, gInaccessibleProperties[j]) == 0)
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -7900,16 +7900,25 @@ if (false) {
     //domProp: "MozWindowShadow",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
     initial_values: [ "default" ],
     other_values: [ "none", "menu", "tooltip", "sheet" ],
     invalid_values: []
   };
 
+  gCSSProperties["-moz-window-opacity"] = {
+    // domProp: "MozWindowOpacity",
+    inherited: false,
+    type: CSS_TYPE_LONGHAND,
+    initial_values: [ "1", "17", "397.376", "3e1", "3e+1", "3e0", "3e+0", "3e-0" ],
+    other_values: [ "0", "0.4", "0.0000", "-3", "3e-1" ],
+    invalid_values: [ "0px", "1px", "20%", "default", "auto" ]
+  };
+
   gCSSProperties["-moz-context-properties"] = {
     //domProp: "MozContextProperties",
     inherited: true,
     type: CSS_TYPE_LONGHAND,
     initial_values: [ "none" ],
     other_values: [ "fill", "stroke", "fill, stroke", "fill, stroke, fill", "fill, foo", "foo" ],
     invalid_values: [ "default", "fill, auto", "all, stroke", "none, fill", "fill, none", "fill, default", "2px" ]
   };