author | Manish Goregaokar <manishearth@gmail.com> |
Mon, 17 Jul 2017 11:42:12 -0700 | |
changeset 369314 | bbad2cf92d8726f1f739045685a9159bfc75d687 |
parent 369313 | c55df972f7c3ee0ec11e4b2841e20b7d0b1a0fd8 |
child 369315 | 25132d80a89e37e7c02fc2f44b7463ccdaf0a85e |
push id | 32194 |
push user | ryanvm@gmail.com |
push date | Tue, 18 Jul 2017 14:46:42 +0000 |
treeherder | mozilla-central@8ff4f17b266d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bholley |
bugs | 1367904 |
milestone | 56.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
|
--- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -3043,17 +3043,17 @@ CanvasRenderingContext2D::ParseFilter(co ResolveFilterStyleForServo(aString, parentStyle, presShell, aError); if (!computedValues) { return false; } - const nsStyleEffects* effects = Servo_GetStyleEffects(computedValues->ComputedValues()); + const nsStyleEffects* effects = computedValues->ComputedValues()->GetStyleEffects(); // XXX: This mFilters is a one shot object, we probably could avoid copying. aFilterChain = effects->mFilters; return true; } void CanvasRenderingContext2D::SetFilter(const nsAString& aFilter, ErrorResult& aError) { @@ -3963,17 +3963,17 @@ CanvasRenderingContext2D::SetFontInterna computedValues = GetFontStyleForServo(mCanvasElement, aFont, presShell, usedFont, aError); if (!computedValues) { return false; } - fontStyle = Servo_GetStyleFont(computedValues->ComputedValues()); + fontStyle = computedValues->ComputedValues()->GetStyleFont(); } else { sc = GetFontStyleContext(mCanvasElement, aFont, presShell, usedFont, aError); if (!sc) { return false;
--- a/layout/base/ServoRestyleManager.cpp +++ b/layout/base/ServoRestyleManager.cpp @@ -7,16 +7,17 @@ #include "mozilla/ServoRestyleManager.h" #include "mozilla/AutoRestyleTimelineMarker.h" #include "mozilla/AutoTimelineMarker.h" #include "mozilla/DocumentStyleRootIterator.h" #include "mozilla/ServoBindings.h" #include "mozilla/ServoStyleSet.h" #include "mozilla/ServoStyleContext.h" +#include "mozilla/ServoStyleContextInlines.h" #include "mozilla/Unused.h" #include "mozilla/ViewportFrame.h" #include "mozilla/dom/ChildIterator.h" #include "mozilla/dom/ElementInlines.h" #include "nsBlockFrame.h" #include "nsBulletFrame.h" #include "nsPlaceholderFrame.h" #include "nsContentUtils.h"
--- a/layout/generic/ViewportFrame.cpp +++ b/layout/generic/ViewportFrame.cpp @@ -14,16 +14,17 @@ #include "nsGkAtoms.h" #include "nsIScrollableFrame.h" #include "nsSubDocumentFrame.h" #include "nsCanvasFrame.h" #include "nsAbsoluteContainingBlock.h" #include "GeckoProfiler.h" #include "nsIMozBrowserFrame.h" #include "nsPlaceholderFrame.h" +#include "mozilla/ServoStyleContextInlines.h" using namespace mozilla; typedef nsAbsoluteContainingBlock::AbsPosReflowFlags AbsPosReflowFlags; ViewportFrame* NS_NewViewportFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { return new (aPresShell) ViewportFrame(aContext);
--- a/layout/style/ServoBindingList.h +++ b/layout/style/ServoBindingList.h @@ -582,22 +582,16 @@ SERVO_BINDING_FUNC(Servo_GetCustomProper SERVO_BINDING_FUNC(Servo_GetCustomPropertiesCount, uint32_t, ServoComputedValuesBorrowed computed_values) SERVO_BINDING_FUNC(Servo_GetCustomPropertyNameAt, bool, ServoComputedValuesBorrowed, uint32_t index, nsAString* name) -// Style-struct management. -#define STYLE_STRUCT(name, checkdata_cb) \ - struct nsStyle##name; \ - SERVO_BINDING_FUNC(Servo_GetStyle##name, const nsStyle##name*, \ - ServoComputedValuesBorrowedOrNull computed_values) -#include "nsStyleStructList.h" -#undef STYLE_STRUCT +SERVO_BINDING_FUNC(Servo_GetEmptyVariables, const nsStyleVariables*) // AddRef / Release functions #define SERVO_ARC_TYPE(name_, type_) \ SERVO_BINDING_FUNC(Servo_##name_##_AddRef, void, type_##Borrowed) \ SERVO_BINDING_FUNC(Servo_##name_##_Release, void, type_##Borrowed) #include "mozilla/ServoArcTypeList.h" #undef SERVO_ARC_TYPE
--- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -222,16 +222,21 @@ Gecko_ServoStyleContext_Init(ServoStyleC new (KnownNotNull, aContext) ServoStyleContext(parent, pres, aPseudoTag, aPseudoType, ServoComputedValuesForgotten(aValues)); } ServoComputedValues::ServoComputedValues(const ServoComputedValuesForgotten aValue) { PodAssign(this, aValue.mPtr); } +const nsStyleVariables* ServoComputedValues::GetStyleVariables() const +{ + return Servo_GetEmptyVariables(); +} + void Gecko_ServoStyleContext_Destroy(ServoStyleContext* aContext) { aContext->~ServoStyleContext(); } void Gecko_ConstructStyleChildrenIterator(
--- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -69,16 +69,23 @@ struct nsStyleDisplay; class nsXBLBinding; namespace mozilla { #define STYLE_STRUCT(name_, checkdata_cb_) struct Gecko##name_ {nsStyle##name_ gecko;}; #include "nsStyleStructList.h" #undef STYLE_STRUCT } +#define STYLE_STRUCT(name_, checkdata_cb_) \ + const nsStyle##name_* ServoComputedValues::GetStyle##name_() const { return &name_.mPtr->gecko; } +#define STYLE_STRUCT_LIST_IGNORE_VARIABLES +#include "nsStyleStructList.h" +#undef STYLE_STRUCT +#undef STYLE_STRUCT_LIST_IGNORE_VARIABLES + #define NS_DECL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \ void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr); \ void Gecko_Release##name_##ArbitraryThread(class_* aPtr); #define NS_IMPL_THREADSAFE_FFI_REFCOUNTING(class_, name_) \ static_assert(class_::HasThreadSafeRefCnt::value, \ "NS_DECL_THREADSAFE_FFI_REFCOUNTING can only be used with " \ "classes that have thread-safe refcounting"); \ void Gecko_AddRef##name_##ArbitraryThread(class_* aPtr) \
--- a/layout/style/ServoStyleContext.h +++ b/layout/style/ServoStyleContext.h @@ -34,32 +34,17 @@ public: void Release() { Servo_StyleContext_Release(this); } /** * Makes this context match |aOther| in terms of which style structs have * been resolved. */ - void ResolveSameStructsAs(nsPresContext* aPresContext, const ServoStyleContext* aOther) { - // Only resolve structs that are not already resolved in this struct. - uint64_t ourBits = mBits & NS_STYLE_INHERIT_MASK; - uint64_t otherBits = aOther->mBits & NS_STYLE_INHERIT_MASK; - uint64_t newBits = otherBits & ~ourBits & NS_STYLE_INHERIT_MASK; - - #define STYLE_STRUCT(name_, checkdata_cb) \ - if (nsStyle##name_::kHasFinishStyle && newBits & NS_STYLE_INHERIT_BIT(name_)) { \ - const nsStyle##name_* data = Servo_GetStyle##name_(ComputedValues()); \ - const_cast<nsStyle##name_*>(data)->FinishStyle(aPresContext); \ - } - #include "nsStyleStructList.h" - #undef STYLE_STRUCT - - mBits |= newBits; - } + inline void ResolveSameStructsAs(nsPresContext* aPresContext, const ServoStyleContext* aOther); private: nsPresContext* mPresContext; ServoComputedValues mSource; }; }
new file mode 100644 --- /dev/null +++ b/layout/style/ServoStyleContextInlines.h @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ContextInlines_h +#define mozilla_ContextInlines_h + + +#include "nsStyleStruct.h" +#include "ServoBindings.h" +#include "mozilla/ServoStyleContext.h" + +namespace mozilla { + +void +ServoStyleContext::ResolveSameStructsAs(nsPresContext* aPresContext, const ServoStyleContext* aOther) +{ + // Only resolve structs that are not already resolved in this struct. + uint64_t ourBits = mBits & NS_STYLE_INHERIT_MASK; + uint64_t otherBits = aOther->mBits & NS_STYLE_INHERIT_MASK; + uint64_t newBits = otherBits & ~ourBits & NS_STYLE_INHERIT_MASK; + +#define STYLE_STRUCT(name_, checkdata_cb) \ + if (nsStyle##name_::kHasFinishStyle && newBits & NS_STYLE_INHERIT_BIT(name_)) { \ + const nsStyle##name_* data = ComputedValues()->GetStyle##name_(); \ + const_cast<nsStyle##name_*>(data)->FinishStyle(aPresContext); \ + } +#include "nsStyleStructList.h" +#undef STYLE_STRUCT + + mBits |= newBits; +} + +} // namespace mozilla + +#endif // mozilla_ContextInlines_h \ No newline at end of file
--- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -869,18 +869,18 @@ ServoStyleSet::ProbePseudoElementStyle(E } // For :before and :after pseudo-elements, having display: none or no // 'content' property is equivalent to not having the pseudo-element // at all. bool isBeforeOrAfter = aType == CSSPseudoElementType::before || aType == CSSPseudoElementType::after; if (isBeforeOrAfter) { - const nsStyleDisplay* display = Servo_GetStyleDisplay(computedValues->ComputedValues()); - const nsStyleContent* content = Servo_GetStyleContent(computedValues->ComputedValues()); + const nsStyleDisplay* display = computedValues->ComputedValues()->GetStyleDisplay(); + const nsStyleContent* content = computedValues->ComputedValues()->GetStyleContent(); // XXXldb What is contentCount for |content: ""|? if (display->mDisplay == StyleDisplay::None || content->ContentCount() == 0) { return nullptr; } } return GetContext(computedValues.forget(), aParentContext, pseudoTag, aType,
--- a/layout/style/ServoTypes.h +++ b/layout/style/ServoTypes.h @@ -182,21 +182,24 @@ struct ServoComputedValuesForgotten { /** * We want C++ to be abe to read the style struct fields of ComputedValues * so we define this type on the C++ side and use the bindgenned version * on the Rust side. * */ struct ServoComputedValues { -#define STYLE_STRUCT(name_, checkdata_cb_) mozilla::ServoRawOffsetArc<mozilla::Gecko##name_> name_; +#define STYLE_STRUCT(name_, checkdata_cb_) \ + mozilla::ServoRawOffsetArc<mozilla::Gecko##name_> name_; \ + inline const nsStyle##name_* GetStyle##name_() const; #define STYLE_STRUCT_LIST_IGNORE_VARIABLES #include "nsStyleStructList.h" #undef STYLE_STRUCT - #undef STYLE_STRUCT_LIST_IGNORE_VARIABLES +#undef STYLE_STRUCT_LIST_IGNORE_VARIABLES + const nsStyleVariables* GetStyleVariables() const; mozilla::ServoCustomPropertiesMap custom_properties; mozilla::ServoWritingMode writing_mode; mozilla::ServoFontComputationData font_computation_data; /// The rule node representing the ordered list of rules matched for this /// node. Can be None for default values and text nodes. This is /// essentially an optimization to avoid referencing the root rule node. mozilla::ServoRuleNode rules; /// The element's computed values if visited, only computed if there's a
--- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -114,16 +114,17 @@ EXPORTS.mozilla += [ 'ServoKeyframesRule.h', 'ServoMediaList.h', 'ServoMediaRule.h', 'ServoNamespaceRule.h', 'ServoPageRule.h', 'ServoPropPrefList.h', 'ServoSpecifiedValues.h', 'ServoStyleContext.h', + 'ServoStyleContextInlines.h', 'ServoStyleRule.h', 'ServoStyleSet.h', 'ServoStyleSheet.h', 'ServoSupportsRule.h', 'ServoTypes.h', 'ServoUtils.h', 'SheetType.h', 'StyleAnimationValue.h',
--- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -1030,17 +1030,17 @@ nsAnimationManager::UpdateAnimations( StopAnimationsForElement(aElement, aPseudoType); return; } NonOwningAnimationTarget target(aElement, aPseudoType); ServoCSSAnimationBuilder builder(aStyleContext); const nsStyleDisplay *disp = - Servo_GetStyleDisplay(aStyleContext->ComputedValues()); + aStyleContext->ComputedValues()->GetStyleDisplay(); DoUpdateAnimations(target, *disp, builder); } template<class BuilderType> void nsAnimationManager::DoUpdateAnimations( const NonOwningAnimationTarget& aTarget, const nsStyleDisplay& aStyleDisplay,
--- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -246,17 +246,17 @@ nsStyleContext::CalcStyleDifferenceInter PR_BEGIN_MACRO \ const nsStyle##struct_* this##struct_ = PeekStyle##struct_(); \ bool unrequestedStruct; \ if (this##struct_) { \ unrequestedStruct = false; \ structsFound |= NS_STYLE_INHERIT_BIT(struct_); \ } else if (checkUnrequestedServoStructs) { \ this##struct_ = \ - Servo_GetStyle##struct_(AsServo()->ComputedValues()); \ + AsServo()->ComputedValues()->GetStyle##struct_(); \ unrequestedStruct = true; \ } else { \ unrequestedStruct = false; \ } \ if (this##struct_) { \ const nsStyle##struct_* other##struct_ = aNewContext->Style##struct_(); \ if (this##struct_ == other##struct_) { \ /* The very same struct, so we know that there will be no */ \ @@ -492,20 +492,20 @@ public: // RefPtr<ServoComputedValues> visitedComputedValues = // Servo_ComputedValues_GetVisitedStyle(mComputedValues).Consume(); // But what's the best way to create the nsStyleContext? return nullptr; } #define STYLE_STRUCT(name_, checkdata_cb_) \ const nsStyle##name_ * Style##name_() { \ - return Servo_GetStyle##name_(mComputedValues); \ + return mComputedValues->GetStyle##name_(); \ } \ const nsStyle##name_ * ThreadsafeStyle##name_() { \ - return Servo_GetStyle##name_(mComputedValues); \ + return mComputedValues->GetStyle##name_(); \ } #include "nsStyleStructList.h" #undef STYLE_STRUCT const ServoComputedValues* ComputedValues() { return mComputedValues; } private: const ServoComputedValues* MOZ_NON_OWNING_REF mComputedValues;
--- a/layout/style/nsStyleContext.h +++ b/layout/style/nsStyleContext.h @@ -23,22 +23,16 @@ namespace mozilla { enum class CSSPseudoElementType : uint8_t; class GeckoStyleContext; class ServoStyleContext; } // namespace mozilla extern "C" { void Servo_StyleContext_AddRef(mozilla::ServoStyleContext* aContext); void Servo_StyleContext_Release(mozilla::ServoStyleContext* aContext); -#define STYLE_STRUCT(name_, checkdata_cb_) \ - struct nsStyle##name_; \ - const nsStyle##name_* Servo_GetStyle##name_( \ - ServoComputedValuesBorrowedOrNull computed_values); -#include "nsStyleStructList.h" -#undef STYLE_STRUCT } /** * An nsStyleContext represents the computed style data for an element. * The computed style data are stored in a set of structs (see * nsStyleStruct.h) that are cached either on the style context or in * the rule tree (see nsRuleNode.h for a description of this caching and * how the cached structs are shared). @@ -346,28 +340,17 @@ protected: nsIAtom* aPseudoTag, mozilla::CSSPseudoElementType aPseudoType); // Helper post-contruct hook. void FinishConstruction(); void SetStyleBits(); - const void* StyleStructFromServoComputedValues(nsStyleStructID aSID) { - switch (aSID) { -#define STYLE_STRUCT(name_, checkdata_cb_) \ - case eStyleStruct_##name_: \ - return Servo_GetStyle##name_(ComputedValues()); -#include "nsStyleStructList.h" -#undef STYLE_STRUCT - default: - MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value"); - return nullptr; - } - } + inline const void* StyleStructFromServoComputedValues(nsStyleStructID aSID); // Helper functions for GetStyle* and PeekStyle* #define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \ template<bool aComputeData> \ const nsStyle##name_ * DoGetStyle##name_(); #define STYLE_STRUCT_RESET(name_, checkdata_cb_) \ template<bool aComputeData> \ const nsStyle##name_ * DoGetStyle##name_();
--- a/layout/style/nsStyleContextInlines.h +++ b/layout/style/nsStyleContextInlines.h @@ -13,16 +13,17 @@ #ifndef nsStyleContextInlines_h #define nsStyleContextInlines_h #include "nsStyleContext.h" #include "mozilla/ServoStyleContext.h" #include "mozilla/GeckoStyleContext.h" #include "mozilla/ServoUtils.h" +#include "mozilla/ServoBindings.h" MOZ_DEFINE_STYLO_METHODS(nsStyleContext, mozilla::GeckoStyleContext, mozilla::ServoStyleContext); nsRuleNode* nsStyleContext::RuleNode() { @@ -52,17 +53,17 @@ nsStyleContext::Release() #define STYLE_STRUCT(name_, checkdata_cb_) \ const nsStyle##name_ * \ nsStyleContext::Style##name_() { \ return DoGetStyle##name_<true>(); \ } \ const nsStyle##name_ * \ nsStyleContext::ThreadsafeStyle##name_() { \ if (mozilla::ServoStyleSet::IsInServoTraversal()) { \ - return Servo_GetStyle##name_(AsServo()->ComputedValues()); \ + return AsServo()->ComputedValues()->GetStyle##name_(); \ } \ return Style##name_(); \ } \ const nsStyle##name_ * nsStyleContext::PeekStyle##name_() { \ return DoGetStyle##name_<false>(); \ } #include "nsStyleStructList.h" #undef STYLE_STRUCT @@ -125,17 +126,17 @@ const nsStyle##name_ * nsStyleContext::D } \ \ const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_));\ if (!aComputeData && needToCompute) { \ return nullptr; \ } \ \ const nsStyle##name_* data = \ - Servo_GetStyle##name_(servo->ComputedValues()); \ + servo->ComputedValues()->GetStyle##name_(); \ /* perform any remaining main thread work on the struct */ \ if (needToCompute) { \ MOZ_ASSERT(NS_IsMainThread()); \ MOZ_ASSERT(!mozilla::ServoStyleSet::IsInServoTraversal()); \ const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext()); \ /* the ServoStyleContext owns the struct */ \ AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \ } \ @@ -158,17 +159,17 @@ const nsStyle##name_ * nsStyleContext::D return gecko->RuleNode()->GetStyle##name_<aComputeData>(this->AsGecko()); \ } \ auto servo = AsServo(); \ const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_)); \ if (!aComputeData && needToCompute) { \ return nullptr; \ } \ const nsStyle##name_* data = \ - Servo_GetStyle##name_(servo->ComputedValues()); \ + servo->ComputedValues()->GetStyle##name_(); \ /* perform any remaining main thread work on the struct */ \ if (needToCompute) { \ const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext()); \ /* the ServoStyleContext owns the struct */ \ AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \ } \ return data; \ } @@ -203,10 +204,25 @@ nsStyleContext::IsLinkContext() const void nsStyleContext::StartBackgroundImageLoads() { // Just get our background struct; that should do the trick StyleBackground(); } +const void* +nsStyleContext::StyleStructFromServoComputedValues(nsStyleStructID aSID) +{ + switch (aSID) { +#define STYLE_STRUCT(name_, checkdata_cb_) \ + case eStyleStruct_##name_: \ + return ComputedValues()->GetStyle##name_(); +#include "nsStyleStructList.h" +#undef STYLE_STRUCT + default: + MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value"); + return nullptr; + } +} + #endif // nsStyleContextInlines_h
--- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -629,17 +629,18 @@ nsTransitionManager::UpdateTransitions( { if (!mPresContext->IsDynamic()) { // For print or print preview, ignore transitions. return false; } CSSTransitionCollection* collection = CSSTransitionCollection::GetAnimationCollection(aElement, aPseudoType); - const nsStyleDisplay *disp = Servo_GetStyleDisplay(aNewStyle->ComputedValues()); + const nsStyleDisplay *disp = + aNewStyle->ComputedValues()->GetStyleDisplay(); return DoUpdateTransitions(disp, aElement, aPseudoType, collection, aOldStyle, aNewStyle); } template<typename StyleType> bool