Bug 1471114 part 3 - Drop the reference to getter functions we don't call. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Tue, 26 Jun 2018 18:09:13 +1000
changeset 811142 82ce1f7b7fd21c406cf61726c78de5f120028e35
parent 811141 879a7265c35f51c5954d8a44ccd374a606ecba0e
child 811143 7f167f9affd954da907d1da307ebc82be4b85911
push id114203
push userxquan@mozilla.com
push dateWed, 27 Jun 2018 00:38:52 +0000
reviewersemilio
bugs1471114
milestone63.0a1
Bug 1471114 part 3 - Drop the reference to getter functions we don't call. r?emilio MozReview-Commit-ID: IbBayOwsjNX
layout/style/GenerateComputedDOMStyleGenerated.py
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
--- a/layout/style/GenerateComputedDOMStyleGenerated.py
+++ b/layout/style/GenerateComputedDOMStyleGenerated.py
@@ -23,30 +23,31 @@ static constexpr Entry kEntries[] = {
         # Gecko put then later so we do so as well. See w3c/csswg-drafts#2827.
         order = p.name.startswith("-")
         return (order, p.name)
 
     # Some special cases we may get rid of later. See bug 1471423.
     def method(p):
         if p.id.startswith("margin_"):
             return "{}Width".format(p.method)
-        if p.id == "ime_mode":
-            return "IMEMode"
-        if p.id == "float":
-            return "Float"
         if p.id.startswith("_moz_"):
             method = p.method[3:]
         else:
             method = p.method
         if p.id.startswith("_moz_outline_radius_"):
             method = method.replace("left", "Left")
             method = method.replace("right", "Right")
         return method
 
     properties = runpy.run_path(dataFile)["data"]
     properties = filter(exposed_on_getcs, properties)
     properties.sort(key=order_key)
 
-    TEMPLATE = "  {{ eCSSProperty_{}, &nsComputedDOMStyle::DoGet{} }},\n"
+    TEMPLATE = "  {{ eCSSProperty_{}, &nsComputedDOMStyle::{} }},\n"
     for p in properties:
-        output.write(TEMPLATE.format(p.id, method(p)))
+        m = "DoGet" + method(p)
+        # Put a dummy getter here instead of nullptr because MSVC seems
+        # to have bug which ruins the table when we put nullptr for
+        # pointer-to-member-function. See bug 1471426.
+        m = "DummyGetter" if "SerializedByServo" in p.flags else m
+        output.write(TEMPLATE.format(p.id, m))
 
     output.write("};\n")
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -471,16 +471,17 @@ nsComputedDOMStyle::GetPropertyValue(con
       nsString text;
       value->GetCssText(text, rv);
       aReturn.Assign(text);
       return rv.StealNSResult();
     }
     return NS_OK;
   }
 
+  MOZ_ASSERT(entry->mGetter == &nsComputedDOMStyle::DummyGetter);
   Servo_GetPropertyValue(mComputedStyle, prop, &aReturn);
   return NS_OK;
 }
 
 /* static */
 already_AddRefed<ComputedStyle>
 nsComputedDOMStyle::GetComputedStyle(Element* aElement,
                                      nsAtom* aPseudo,
@@ -7144,16 +7145,22 @@ nsComputedDOMStyle::DoGetAnimationPlaySt
       nsCSSProps::ValueToKeywordEnum(animation->GetPlayState(),
                                      nsCSSProps::kAnimationPlayStateKTable));
     valueList->AppendCSSValue(playState.forget());
   } while (++i < display->mAnimationPlayStateCount);
 
   return valueList.forget();
 }
 
+already_AddRefed<CSSValue>
+nsComputedDOMStyle::DummyGetter()
+{
+  MOZ_CRASH("DummyGetter is not supposed to be invoked");
+}
+
 static void
 MarkComputedStyleMapDirty(const char* aPref, void* aData)
 {
   static_cast<ComputedStyleMap*>(aData)->MarkDirty();
 }
 
 void
 nsComputedDOMStyle::ParentChainChanged(nsIContent* aContent)
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -607,16 +607,20 @@ private:
 
   already_AddRefed<CSSValue> DoGetClipPath();
   already_AddRefed<CSSValue> DoGetFilter();
   already_AddRefed<CSSValue> DoGetMaskType();
   already_AddRefed<CSSValue> DoGetPaintOrder();
 
   already_AddRefed<CSSValue> DoGetContextProperties();
 
+  // For working around a MSVC bug. See related comment in
+  // GenerateComputedDOMStyleGenerated.py.
+  already_AddRefed<CSSValue> DummyGetter();
+
   /* Helper functions */
   void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
   void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue,
                                 const mozilla::StyleComplexColor& aColor);
   void SetValueForWidgetColor(nsROCSSPrimitiveValue* aValue,
                               const mozilla::StyleComplexColor& aColor,
                               uint8_t aWidgetType);
   void SetValueToStyleImage(const nsStyleImage& aStyleImage,