Bug 1380133 - Part 6: Add a PeekStyleXXXFromComputedValues to nsStyleContext/FakeStyleContext. draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 17 Jul 2017 13:08:07 +0800
changeset 609638 3c259dc7f1c5a674b53fe40157efe548d995b24e
parent 609637 14d376496480334a3a0108265932617206baac3c
child 609639 a9860d977e97ee29c12c3e45e167e944050c0b65
push id68611
push userbmo:cam@mcc.id.au
push dateMon, 17 Jul 2017 05:09:54 +0000
bugs1380133
milestone56.0a1
Bug 1380133 - Part 6: Add a PeekStyleXXXFromComputedValues to nsStyleContext/FakeStyleContext. MozReview-Commit-ID: BswhWCmpjyN
layout/style/nsStyleContext.cpp
layout/style/nsStyleContext.h
layout/style/nsStyleContextInlines.h
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -510,16 +510,19 @@ public:
   const nsStyle##name_ * Style##name_() {                                     \
     return Servo_RawGetStyle##name_(mComputedValues);                         \
   }                                                                           \
   const nsStyle##name_ * ThreadsafeStyle##name_() {                           \
     return Style##name_();                                                    \
   }                                                                           \
   const nsStyle##name_* PeekStyle##name_() {                                  \
     return mBits & NS_STYLE_INHERIT_BIT(name_) ? Style##name_() : nullptr;    \
+  }                                                                           \
+  const nsStyle##name_* PeekStyle##name_##FromComputedValues() {              \
+    return Style##name_();                                                    \
   }
   #include "nsStyleStructList.h"
   #undef STYLE_STRUCT
 
   bool EqualCustomProperties(FakeStyleContext* aOther)
   {
     return Servo_RawComputedValues_EqualCustomProperties(
         mComputedValues, aOther->mComputedValues);
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -308,16 +308,25 @@ public:
    * Perhaps this shouldn't be a public nsStyleContext API.
    */
   #define STYLE_STRUCT(name_, checkdata_cb_)  \
     inline const nsStyle##name_ * PeekStyle##name_();
   #include "nsStyleStructList.h"
   #undef STYLE_STRUCT
 
   /**
+   * Gets the struct from the ServoComputedValues without caching it on the
+   * style context.
+   */
+  #define STYLE_STRUCT(name_, checkdata_cb_)  \
+    inline const nsStyle##name_ * PeekStyle##name_##FromComputedValues();
+  #include "nsStyleStructList.h"
+  #undef STYLE_STRUCT
+
+  /**
    * Compute the style changes needed during restyling when this style
    * context is being replaced by aNewContext.  (This is nonsymmetric since
    * we optimize by skipping comparison for styles that have never been
    * requested.)
    *
    * This method returns a change hint (see nsChangeHint.h).  All change
    * hints apply to the frame and its later continuations or ib-split
    * siblings.  Most (all of those except the "NotHandledForDescendants"
--- a/layout/style/nsStyleContextInlines.h
+++ b/layout/style/nsStyleContextInlines.h
@@ -46,16 +46,20 @@ const nsStyle##name_ *                  
 nsStyleContext::ThreadsafeStyle##name_() {                      \
   if (mozilla::ServoStyleSet::IsInServoTraversal()) {           \
     return Servo_GetStyle##name_(AsServo()->ComputedValues());  \
   }                                                             \
   return Style##name_();                                        \
 }                                                               \
 const nsStyle##name_ * nsStyleContext::PeekStyle##name_() {     \
   return DoGetStyle##name_<false>();                            \
+}                                                               \
+const nsStyle##name_*                                           \
+nsStyleContext::PeekStyle##name_##FromComputedValues() {        \
+  return Servo_GetStyle##name_(AsServo()->ComputedValues());    \
 }
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
 
 // Helper functions for GetStyle* and PeekStyle*
 #define STYLE_STRUCT_INHERITED(name_, checkdata_cb_)                \
 template<bool aComputeData>                                         \
 const nsStyle##name_ * nsStyleContext::DoGetStyle##name_() {        \