Bug 1380133 - Part 6: Add a PeekStyleXXXFromComputedValues to nsStyleContext/FakeStyleContext.
MozReview-Commit-ID: BswhWCmpjyN
--- 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_() { \