Bug 1448690: Remove IsStyledByServo. r=xidorn

MozReview-Commit-ID: I3MDbo2Yu7d
This commit is contained in:
Emilio Cobos Álvarez 2018-03-25 19:42:10 +02:00
Родитель 2265ef0801
Коммит 8fcda0e92d
33 изменённых файлов: 166 добавлений и 353 удалений

Просмотреть файл

@ -1009,7 +1009,6 @@ KeyframeEffectReadOnly::GetKeyframes(JSContext*& aCx,
return;
}
bool isServo = mDocument->IsStyledByServo();
bool isCSSAnimation = mAnimation && mAnimation->AsCSSAnimation();
// For Servo, when we have CSS Animation @keyframes with variables, we convert
@ -1024,7 +1023,7 @@ KeyframeEffectReadOnly::GetKeyframes(JSContext*& aCx,
// enough context to do so). For that we need to grab the style context so we
// know what custom property values to provide.
RefPtr<ComputedStyle> computedStyle;
if (isServo && isCSSAnimation) {
if (isCSSAnimation) {
// The following will flush style but that's ok since if you update
// a variable's computed value, you expect to see that updated value in the
// result of getKeyframes().
@ -1065,7 +1064,7 @@ KeyframeEffectReadOnly::GetKeyframes(JSContext*& aCx,
// keyframe are stored in a servo's declaration block. Find the declaration
// block to resolve CSS variables in the keyframe.
// This workaround will be solved by bug 1391537.
if (isServo && isCSSAnimation) {
if (isCSSAnimation) {
for (const PropertyValuePair& propertyValue : keyframe.mPropertyValues) {
if (propertyValue.mProperty ==
nsCSSPropertyID::eCSSPropertyExtra_variable) {
@ -1078,31 +1077,27 @@ KeyframeEffectReadOnly::GetKeyframes(JSContext*& aCx,
JS::Rooted<JSObject*> keyframeObject(aCx, &keyframeJSValue.toObject());
for (const PropertyValuePair& propertyValue : keyframe.mPropertyValues) {
nsAutoString stringValue;
if (isServo) {
// Don't serialize the custom properties for this keyframe.
if (propertyValue.mProperty ==
nsCSSPropertyID::eCSSPropertyExtra_variable) {
continue;
}
if (propertyValue.mServoDeclarationBlock) {
Servo_DeclarationBlock_SerializeOneValue(
propertyValue.mServoDeclarationBlock,
propertyValue.mProperty,
&stringValue,
computedStyle,
customProperties);
} else {
RawServoAnimationValue* value =
mBaseStyleValuesForServo.GetWeak(propertyValue.mProperty);
if (value) {
Servo_AnimationValue_Serialize(value,
propertyValue.mProperty,
&stringValue);
}
}
// Don't serialize the custom properties for this keyframe.
if (propertyValue.mProperty ==
nsCSSPropertyID::eCSSPropertyExtra_variable) {
continue;
}
if (propertyValue.mServoDeclarationBlock) {
Servo_DeclarationBlock_SerializeOneValue(
propertyValue.mServoDeclarationBlock,
propertyValue.mProperty,
&stringValue,
computedStyle,
customProperties);
} else {
MOZ_CRASH("old style system disabled");
RawServoAnimationValue* value =
mBaseStyleValuesForServo.GetWeak(propertyValue.mProperty);
if (value) {
Servo_AnimationValue_Serialize(value,
propertyValue.mProperty,
&stringValue);
}
}
const char* name = nsCSSProps::PropertyIDLName(propertyValue.mProperty);

Просмотреть файл

@ -261,14 +261,10 @@ public:
{
AnimationValue result;
bool hasProperty = false;
if (mDocument->IsStyledByServo()) {
// We cannot use getters_AddRefs on RawServoAnimationValue because it is
// an incomplete type, so Get() doesn't work. Instead, use GetWeak, and
// then assign the raw pointer to a RefPtr.
result.mServo = mBaseStyleValuesForServo.GetWeak(aProperty, &hasProperty);
} else {
MOZ_CRASH("old style system disabled");
}
// We cannot use getters_AddRefs on RawServoAnimationValue because it is
// an incomplete type, so Get() doesn't work. Instead, use GetWeak, and
// then assign the raw pointer to a RefPtr.
result.mServo = mBaseStyleValuesForServo.GetWeak(aProperty, &hasProperty);
MOZ_ASSERT(hasProperty || result.IsNull());
return result;
}

Просмотреть файл

@ -877,21 +877,17 @@ MakePropertyValuePair(nsCSSPropertyID aProperty, const nsAString& aStringValue,
MOZ_ASSERT(aDocument);
Maybe<PropertyValuePair> result;
if (aDocument->GetStyleBackendType() == StyleBackendType::Servo) {
ServoCSSParser::ParsingEnvironment env =
ServoCSSParser::GetParsingEnvironment(aDocument);
RefPtr<RawServoDeclarationBlock> servoDeclarationBlock =
ServoCSSParser::ParseProperty(aProperty, aStringValue, env);
ServoCSSParser::ParsingEnvironment env =
ServoCSSParser::GetParsingEnvironment(aDocument);
RefPtr<RawServoDeclarationBlock> servoDeclarationBlock =
ServoCSSParser::ParseProperty(aProperty, aStringValue, env);
if (servoDeclarationBlock) {
result.emplace(aProperty, Move(servoDeclarationBlock));
} else {
ReportInvalidPropertyValueToConsole(aProperty, aStringValue, aDocument);
}
return result;
if (servoDeclarationBlock) {
result.emplace(aProperty, Move(servoDeclarationBlock));
} else {
ReportInvalidPropertyValueToConsole(aProperty, aStringValue, aDocument);
}
MOZ_CRASH("old style system disabled");
return result;
}
/**
@ -948,7 +944,6 @@ GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
const ComputedStyle* aComputedStyle)
{
MOZ_ASSERT(aElement);
MOZ_ASSERT(aElement->IsStyledByServo());
nsTArray<ComputedKeyframeValues> result;
@ -1468,8 +1463,6 @@ RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes,
}
};
StyleBackendType styleBackend = aDocument->GetStyleBackendType();
for (size_t i = 0, len = aKeyframes.Length(); i < len; i++) {
const Keyframe& frame = aKeyframes[i];
@ -1486,12 +1479,7 @@ RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes,
for (const PropertyValuePair& pair : frame.mPropertyValues) {
if (nsCSSProps::IsShorthand(pair.mProperty)) {
if (styleBackend == StyleBackendType::Gecko) {
MOZ_CRASH("old style system disabled");
}
MOZ_ASSERT(styleBackend != StyleBackendType::Servo ||
pair.mServoDeclarationBlock);
MOZ_ASSERT(pair.mServoDeclarationBlock);
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(
prop, pair.mProperty, CSSEnabledState::eForAllContent) {
addToPropertySets(*prop, offsetToUse);

Просмотреть файл

@ -116,24 +116,18 @@ TimingParams::ParseEasing(const nsAString& aEasing,
{
MOZ_ASSERT(aDocument);
if (aDocument->IsStyledByServo()) {
nsTimingFunction timingFunction;
RefPtr<URLExtraData> url = ServoCSSParser::GetURLExtraData(aDocument);
if (!ServoCSSParser::ParseEasing(aEasing, url, timingFunction)) {
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(aEasing);
return Nothing();
}
if (timingFunction.mType == nsTimingFunction::Type::Linear) {
return Nothing();
}
return Some(ComputedTimingFunction(timingFunction));
nsTimingFunction timingFunction;
RefPtr<URLExtraData> url = ServoCSSParser::GetURLExtraData(aDocument);
if (!ServoCSSParser::ParseEasing(aEasing, url, timingFunction)) {
aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(aEasing);
return Nothing();
}
MOZ_CRASH("old style system disabled");
if (timingFunction.mType == nsTimingFunction::Type::Linear) {
return Nothing();
}
return Nothing();
return Some(ComputedTimingFunction(timingFunction));
}
bool

Просмотреть файл

@ -116,12 +116,8 @@ DOMIntersectionObserver::Constructor(const mozilla::dom::GlobalObject& aGlobal,
bool
DOMIntersectionObserver::SetRootMargin(const nsAString& aString)
{
if (mDocument && mDocument->IsStyledByServo()) {
return ServoCSSParser::ParseIntersectionObserverRootMargin(aString,
&mRootMargin);
}
MOZ_CRASH("old style system disabled");
return ServoCSSParser::ParseIntersectionObserverRootMargin(aString,
&mRootMargin);
}
void

Просмотреть файл

@ -344,28 +344,17 @@ DOMMatrixReadOnly::Stringify(nsAString& aResult)
aResult = matrixStr;
}
static bool
IsStyledByServo(JSContext* aContext)
{
nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(aContext);
nsIDocument* doc = win ? win->GetDoc() : nullptr;
return doc ? doc->IsStyledByServo() : false;
}
already_AddRefed<DOMMatrix>
DOMMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports(),
IsStyledByServo(aGlobal.Context()));
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
return obj.forget();
}
already_AddRefed<DOMMatrix>
DOMMatrix::Constructor(const GlobalObject& aGlobal, const nsAString& aTransformList, ErrorResult& aRv)
{
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports(),
IsStyledByServo(aGlobal.Context()));
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
obj = obj->SetMatrixValue(aTransformList, aRv);
return obj.forget();
}
@ -411,8 +400,7 @@ template <typename T> void SetDataInMatrix(DOMMatrix* aMatrix, const T* aData, i
already_AddRefed<DOMMatrix>
DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv)
{
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports(),
IsStyledByServo(aGlobal.Context()));
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
aArray32.ComputeLengthAndData();
SetDataInMatrix(obj, aArray32.Data(), aArray32.Length(), aRv);
@ -422,8 +410,7 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float32Array& aArray32
already_AddRefed<DOMMatrix>
DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv)
{
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports(),
IsStyledByServo(aGlobal.Context()));
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
aArray64.ComputeLengthAndData();
SetDataInMatrix(obj, aArray64.Data(), aArray64.Length(), aRv);
@ -433,8 +420,7 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float64Array& aArray64
already_AddRefed<DOMMatrix>
DOMMatrix::Constructor(const GlobalObject& aGlobal, const Sequence<double>& aNumberSequence, ErrorResult& aRv)
{
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports(),
IsStyledByServo(aGlobal.Context()));
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
SetDataInMatrix(obj, aNumberSequence.Elements(), aNumberSequence.Length(), aRv);
return obj.forget();
@ -677,15 +663,11 @@ DOMMatrix::SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv)
gfx::Matrix4x4 transform;
bool contains3dTransform = false;
if (mIsServo) {
if (!ServoCSSParser::ParseTransformIntoMatrix(aTransformList,
contains3dTransform,
transform.components)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return nullptr;
}
} else {
MOZ_CRASH("old style system disabled");
if (!ServoCSSParser::ParseTransformIntoMatrix(aTransformList,
contains3dTransform,
transform.components)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return nullptr;
}
if (!contains3dTransform) {

Просмотреть файл

@ -28,13 +28,14 @@ struct DOMPointInit;
class DOMMatrixReadOnly : public nsWrapperCache
{
public:
DOMMatrixReadOnly(nsISupports* aParent, bool aIsServo)
: mParent(aParent), mMatrix2D(new gfx::Matrix()), mIsServo(aIsServo)
explicit DOMMatrixReadOnly(nsISupports* aParent)
: mParent(aParent)
, mMatrix2D(new gfx::Matrix())
{
}
DOMMatrixReadOnly(nsISupports* aParent, const DOMMatrixReadOnly& other)
: mParent(aParent), mIsServo(other.mIsServo)
: mParent(aParent)
{
if (other.mMatrix2D) {
mMatrix2D = new gfx::Matrix(*other.mMatrix2D);
@ -43,10 +44,8 @@ public:
}
}
DOMMatrixReadOnly(nsISupports* aParent,
const gfx::Matrix4x4& aMatrix,
bool aIsServo)
: mParent(aParent), mIsServo(aIsServo)
DOMMatrixReadOnly(nsISupports* aParent, const gfx::Matrix4x4& aMatrix)
: mParent(aParent)
{
mMatrix3D = new gfx::Matrix4x4(aMatrix);
}
@ -143,7 +142,6 @@ protected:
nsCOMPtr<nsISupports> mParent;
nsAutoPtr<gfx::Matrix> mMatrix2D;
nsAutoPtr<gfx::Matrix4x4> mMatrix3D;
bool mIsServo;
virtual ~DOMMatrixReadOnly() {}
@ -156,16 +154,16 @@ private:
class DOMMatrix : public DOMMatrixReadOnly
{
public:
DOMMatrix(nsISupports* aParent, bool aIsServo)
: DOMMatrixReadOnly(aParent, aIsServo)
explicit DOMMatrix(nsISupports* aParent)
: DOMMatrixReadOnly(aParent)
{}
DOMMatrix(nsISupports* aParent, const DOMMatrixReadOnly& other)
: DOMMatrixReadOnly(aParent, other)
{}
DOMMatrix(nsISupports* aParent, const gfx::Matrix4x4& aMatrix, bool aIsServo)
: DOMMatrixReadOnly(aParent, aMatrix, aIsServo)
DOMMatrix(nsISupports* aParent, const gfx::Matrix4x4& aMatrix)
: DOMMatrixReadOnly(aParent, aMatrix)
{}
static already_AddRefed<DOMMatrix>

Просмотреть файл

@ -1885,10 +1885,9 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
if (HasServoData()) {
MOZ_ASSERT(document);
MOZ_ASSERT(IsInAnonymousSubtree());
MOZ_ASSERT(document && document->IsStyledByServo());
}
if (document && document->IsStyledByServo()) {
if (document) {
ClearServoData(document);
}
@ -2060,7 +2059,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
shadowRoot->SetIsComposedDocParticipant(false);
}
MOZ_ASSERT_IF(IsStyledByServo(), !HasAnyOfFlags(kAllServoDescendantBits));
MOZ_ASSERT(!HasAnyOfFlags(kAllServoDescendantBits));
MOZ_ASSERT(!document || document->GetServoRestyleRoot() != this);
}
@ -3633,7 +3632,7 @@ Element::GetTransformToAncestor(Element& aAncestor)
ancestorFrame, nsIFrame::IN_CSS_UNITS).GetMatrix();
}
DOMMatrixReadOnly* matrix = new DOMMatrix(this, transform, IsStyledByServo());
DOMMatrixReadOnly* matrix = new DOMMatrix(this, transform);
RefPtr<DOMMatrixReadOnly> result(matrix);
return result.forget();
}
@ -3650,7 +3649,7 @@ Element::GetTransformToParent()
parentFrame, nsIFrame::IN_CSS_UNITS).GetMatrix();
}
DOMMatrixReadOnly* matrix = new DOMMatrix(this, transform, IsStyledByServo());
DOMMatrixReadOnly* matrix = new DOMMatrix(this, transform);
RefPtr<DOMMatrixReadOnly> result(matrix);
return result.forget();
}
@ -3665,7 +3664,7 @@ Element::GetTransformToViewport()
nsLayoutUtils::GetDisplayRootFrame(primaryFrame), nsIFrame::IN_CSS_UNITS).GetMatrix();
}
DOMMatrixReadOnly* matrix = new DOMMatrix(this, transform, IsStyledByServo());
DOMMatrixReadOnly* matrix = new DOMMatrix(this, transform);
RefPtr<DOMMatrixReadOnly> result(matrix);
return result.forget();
}
@ -4300,7 +4299,6 @@ Element::UpdateIntersectionObservation(DOMIntersectionObserver* aObserver, int32
void
Element::ClearServoData(nsIDocument* aDoc) {
MOZ_ASSERT(IsStyledByServo());
MOZ_ASSERT(aDoc);
if (HasServoData()) {
Servo_Element_ClearData(this);
@ -4492,7 +4490,6 @@ static void
NoteDirtyElement(Element* aElement, uint32_t aBits)
{
MOZ_ASSERT(aElement->IsInComposedDoc());
MOZ_ASSERT(aElement->IsStyledByServo());
// Check the existing root early on, since it may allow us to short-circuit
// before examining the parent chain.

Просмотреть файл

@ -469,32 +469,26 @@ public:
bool HasDirtyDescendantsForServo() const
{
MOZ_ASSERT(IsStyledByServo());
return HasFlag(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
void SetHasDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
SetFlags(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
void UnsetHasDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
UnsetFlags(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
bool HasAnimationOnlyDirtyDescendantsForServo() const {
MOZ_ASSERT(IsStyledByServo());
return HasFlag(ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO);
}
void SetHasAnimationOnlyDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
SetFlags(ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO);
}
void UnsetHasAnimationOnlyDirtyDescendantsForServo() {
MOZ_ASSERT(IsStyledByServo());
UnsetFlags(ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO);
}

Просмотреть файл

@ -1253,7 +1253,7 @@ FragmentOrElement::DestroyContent()
//
// TODO(emilio): I suspect this can be asserted against instead, with a bit of
// effort to avoid calling nsDocument::Destroy with a shell...
if (IsElement() && document->IsStyledByServo()) {
if (IsElement()) {
AsElement()->ClearServoData();
}

Просмотреть файл

@ -240,13 +240,9 @@ ResponsiveImageSelector::SetSizesFromDescriptor(const nsAString & aSizes)
{
ClearSelectedCandidate();
if (Document()->IsStyledByServo()) {
NS_ConvertUTF16toUTF8 sizes(aSizes);
mServoSourceSizeList.reset(Servo_SourceSizeList_Parse(&sizes));
return !!mServoSourceSizeList;
}
MOZ_CRASH("old style system disabled");
NS_ConvertUTF16toUTF8 sizes(aSizes);
mServoSourceSizeList.reset(Servo_SourceSizeList_Parse(&sizes));
return !!mServoSourceSizeList;
}
void
@ -444,13 +440,9 @@ ResponsiveImageSelector::ComputeFinalWidthForCurrentViewport(double *aWidth)
if (!pctx) {
return false;
}
nscoord effectiveWidth;
if (doc->IsStyledByServo()) {
effectiveWidth = presShell->StyleSet()->AsServo()->EvaluateSourceSizeList(
nscoord effectiveWidth =
presShell->StyleSet()->AsServo()->EvaluateSourceSizeList(
mServoSourceSizeList.get());
} else {
MOZ_CRASH("old style system disabled");
}
*aWidth = nsPresContext::AppUnitsToDoubleCSSPixels(std::max(effectiveWidth, 0));
return true;

Просмотреть файл

@ -17,14 +17,6 @@ namespace dom {
static const double sRadPerDegree = 2.0 * M_PI / 360.0;
static bool
IsStyledByServo(JSContext* aContext)
{
nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(aContext);
nsIDocument* doc = win ? win->GetDoc() : nullptr;
return doc ? doc->IsStyledByServo() : false;
}
bool
WebKitCSSMatrix::FeatureEnabled(JSContext* aCx, JSObject* aObj)
{
@ -35,9 +27,7 @@ WebKitCSSMatrix::FeatureEnabled(JSContext* aCx, JSObject* aObj)
already_AddRefed<WebKitCSSMatrix>
WebKitCSSMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{
RefPtr<WebKitCSSMatrix> obj =
new WebKitCSSMatrix(aGlobal.GetAsSupports(),
IsStyledByServo(aGlobal.Context()));
RefPtr<WebKitCSSMatrix> obj = new WebKitCSSMatrix(aGlobal.GetAsSupports());
return obj.forget();
}
@ -45,9 +35,7 @@ already_AddRefed<WebKitCSSMatrix>
WebKitCSSMatrix::Constructor(const GlobalObject& aGlobal,
const nsAString& aTransformList, ErrorResult& aRv)
{
RefPtr<WebKitCSSMatrix> obj =
new WebKitCSSMatrix(aGlobal.GetAsSupports(),
IsStyledByServo(aGlobal.Context()));
RefPtr<WebKitCSSMatrix> obj = new WebKitCSSMatrix(aGlobal.GetAsSupports());
obj = obj->SetMatrixValue(aTransformList, aRv);
return obj.forget();
}

Просмотреть файл

@ -15,8 +15,8 @@ namespace dom {
class WebKitCSSMatrix final : public DOMMatrix
{
public:
WebKitCSSMatrix(nsISupports* aParent, bool aIsServo)
: DOMMatrix(aParent, aIsServo)
explicit WebKitCSSMatrix(nsISupports* aParent)
: DOMMatrix(aParent)
{}
WebKitCSSMatrix(nsISupports* aParent, const DOMMatrixReadOnly& other)

Просмотреть файл

@ -4360,8 +4360,7 @@ nsDOMWindowUtils::EnsureDirtyRootFrame()
NS_IMETHODIMP
nsDOMWindowUtils::GetIsStyledByServo(bool* aStyledByServo)
{
nsIDocument* doc = GetDocument();
*aStyledByServo = doc && doc->IsStyledByServo();
*aStyledByServo = true;
return NS_OK;
}

Просмотреть файл

@ -4020,10 +4020,8 @@ nsIDocument::DeleteShell()
UpdateFrameRequestCallbackSchedulingState(oldShell);
mStyleSetFilled = false;
if (IsStyledByServo()) {
ClearStaleServoData();
AssertNoStaleServoDataIn(static_cast<nsINode&>(*this));
}
ClearStaleServoData();
AssertNoStaleServoDataIn(static_cast<nsINode&>(*this));
}
void
@ -4306,7 +4304,6 @@ void
nsIDocument::AddOnDemandBuiltInUASheet(StyleSheet* aSheet)
{
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(aSheet));
MOZ_DIAGNOSTIC_ASSERT(aSheet->IsServo() == IsStyledByServo());
// Prepend here so that we store the sheets in mOnDemandBuiltInUASheets in
// the same order that they should end up in the style set.
@ -4330,7 +4327,6 @@ nsIDocument::AddOnDemandBuiltInUASheet(StyleSheet* aSheet)
void
nsIDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
{
MOZ_DIAGNOSTIC_ASSERT(aSheet->IsServo() == IsStyledByServo());
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->AddDocStyleSheet(aSheet, this);
@ -4385,7 +4381,6 @@ void
nsIDocument::AddStyleSheet(StyleSheet* aSheet)
{
MOZ_ASSERT(aSheet);
MOZ_DIAGNOSTIC_ASSERT(aSheet->IsServo() == IsStyledByServo());
mStyleSheets.AppendElement(aSheet);
aSheet->SetAssociatedDocument(this, StyleSheet::OwnedByDocument);
@ -4451,7 +4446,6 @@ nsIDocument::UpdateStyleSheets(nsTArray<RefPtr<StyleSheet>>& aOldSheets,
// Now put the new one in its place. If it's null, just ignore it.
StyleSheet* newSheet = aNewSheets[i];
if (newSheet) {
MOZ_DIAGNOSTIC_ASSERT(newSheet->IsServo() == IsStyledByServo());
mStyleSheets.InsertElementAt(oldIndex, newSheet);
newSheet->SetAssociatedDocument(this, StyleSheet::OwnedByDocument);
if (newSheet->IsApplicable()) {
@ -4469,7 +4463,6 @@ void
nsIDocument::InsertStyleSheetAt(StyleSheet* aSheet, size_t aIndex)
{
MOZ_ASSERT(aSheet);
MOZ_DIAGNOSTIC_ASSERT(aSheet->IsServo() == IsStyledByServo());
// FIXME(emilio): Stop touching DocumentOrShadowRoot's members directly, and use an
// accessor.
@ -4491,9 +4484,6 @@ nsIDocument::SetStyleSheetApplicableState(StyleSheet* aSheet, bool aApplicable)
NS_PRECONDITION(aSheet, "null arg");
// If we're actually in the document style sheet list
//
// FIXME(emilio): Shadow DOM.
MOZ_DIAGNOSTIC_ASSERT(aSheet->IsServo() == IsStyledByServo());
if (mStyleSheets.IndexOf(aSheet) != mStyleSheets.NoIndex) {
if (aApplicable) {
AddStyleSheetToStyleSets(aSheet);

Просмотреть файл

@ -1742,11 +1742,6 @@ public:
return mozilla::StyleBackendType::Servo;
}
bool IsStyledByServo() const
{
return GetStyleBackendType() == mozilla::StyleBackendType::Servo;
}
/**
* Get this document's StyleImageLoader. This is guaranteed to not return null.
*/

Просмотреть файл

@ -2484,7 +2484,6 @@ nsINode::ParseServoSelectorList(
ErrorResult& aRv)
{
nsIDocument* doc = OwnerDoc();
MOZ_ASSERT(doc->IsStyledByServo());
nsIDocument::SelectorCache& cache =
doc->GetSelectorCache(mozilla::StyleBackendType::Servo);
@ -2754,12 +2753,6 @@ nsINode::IsNodeApzAwareInternal() const
return EventTarget::IsApzAware();
}
bool
nsINode::IsStyledByServo() const
{
return OwnerDoc()->IsStyledByServo();
}
DocGroup*
nsINode::GetDocGroup() const
{

Просмотреть файл

@ -1039,12 +1039,6 @@ public:
virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override;
virtual nsIGlobalObject* GetOwnerGlobal() const override;
/**
* Returns true if this is a node belonging to a document that uses the Servo
* style system.
*/
bool IsStyledByServo() const;
/**
* Adds a mutation observer to be notified when this node, or any of its
* descendants, are modified. The node will hold a weak reference to the
@ -2074,10 +2068,7 @@ protected:
const ServoFunctor& aServoFunctor,
const GeckoFunctor& aGeckoFunctor)
{
if (IsStyledByServo()) {
return aServoFunctor(ParseServoSelectorList(aSelectorString, aRv));
}
MOZ_CRASH("old style system disabled");
return aServoFunctor(ParseServoSelectorList(aSelectorString, aRv));
}
public:

Просмотреть файл

@ -1090,24 +1090,16 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal,
// -moz-binding is blacklisted.
bool didSanitize = false;
// Create a sheet to hold the parsed CSS
RefPtr<StyleSheet> sheet;
if (aDocument->IsStyledByServo()) {
sheet = new ServoStyleSheet(mozilla::css::eAuthorSheetFeatures,
CORS_NONE, aDocument->GetReferrerPolicy(),
SRIMetadata());
} else {
MOZ_CRASH("old style system disabled");
}
RefPtr<StyleSheet> sheet =
new ServoStyleSheet(mozilla::css::eAuthorSheetFeatures,
CORS_NONE, aDocument->GetReferrerPolicy(),
SRIMetadata());
sheet->SetURIs(aDocument->GetDocumentURI(), nullptr, aBaseURI);
sheet->SetPrincipal(aDocument->NodePrincipal());
if (aDocument->IsStyledByServo()) {
sheet->AsServo()->ParseSheetSync(
aDocument->CSSLoader(), NS_ConvertUTF16toUTF8(aOriginal),
aDocument->GetDocumentURI(), aBaseURI, aDocument->NodePrincipal(),
/* aLoadData = */ nullptr, 0, aDocument->GetCompatibilityMode());
} else {
MOZ_CRASH("old style system disabled");
}
sheet->AsServo()->ParseSheetSync(
aDocument->CSSLoader(), NS_ConvertUTF16toUTF8(aOriginal),
aDocument->GetDocumentURI(), aBaseURI, aDocument->NodePrincipal(),
/* aLoadData = */ nullptr, 0, aDocument->GetCompatibilityMode());
NS_ENSURE_SUCCESS(rv, true);
// Mark the sheet as complete.
MOZ_ASSERT(!sheet->HasForcedUniqueInner(),
@ -1177,20 +1169,16 @@ nsTreeSanitizer::SanitizeAttributes(mozilla::dom::Element* aElement,
if (kNameSpaceID_None == attrNs) {
if (aAllowStyle && nsGkAtoms::style == attrLocal) {
RefPtr<DeclarationBlock> decl;
nsAutoString value;
aElement->GetAttr(attrNs, attrLocal, value);
nsIDocument* document = aElement->OwnerDoc();
if (document->IsStyledByServo()) {
RefPtr<URLExtraData> urlExtra(aElement->GetURLDataForStyleAttr());
decl = ServoDeclarationBlock::FromCssText(
value,
urlExtra,
document->GetCompatibilityMode(),
document->CSSLoader());
} else {
MOZ_CRASH("old style system disabled");
}
RefPtr<URLExtraData> urlExtra(aElement->GetURLDataForStyleAttr());
RefPtr<DeclarationBlock> decl =
ServoDeclarationBlock::FromCssText(
value,
urlExtra,
document->GetCompatibilityMode(),
document->CSSLoader());
if (decl) {
if (SanitizeStyleDeclaration(decl)) {
nsAutoString cleanValue;

Просмотреть файл

@ -1916,7 +1916,7 @@ interface nsIDOMWindowUtils : nsISupports {
/**
* Whether the current document is styled by Servo's style engine.
*
* This calls nsIDocument::IsStyledByServo().
* Always true, pending removal.
*/
readonly attribute boolean isStyledByServo;

Просмотреть файл

@ -67,15 +67,11 @@ nsSMILCSSProperty::GetBaseValue() const
}
AnimationValue computedValue;
if (mElement->IsStyledByServo()) {
computedValue.mServo =
Servo_ComputedValues_ExtractAnimationValue(mBaseComputedStyle, mPropID)
.Consume();
if (!computedValue.mServo) {
return baseValue;
}
} else {
MOZ_CRASH("old style system disabled");
computedValue.mServo =
Servo_ComputedValues_ExtractAnimationValue(mBaseComputedStyle, mPropID)
.Consume();
if (!computedValue.mServo) {
return baseValue;
}
baseValue =

Просмотреть файл

@ -696,16 +696,6 @@ nsBindingManager::EnumerateBoundContentBindings(
return true;
}
bool
nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext,
mozilla::MediaFeatureChangeReason aReason)
{
MOZ_ASSERT(!mDocument->IsStyledByServo());
MOZ_CRASH("old style system disabled");
return false;
}
void
nsBindingManager::AppendAllSheets(nsTArray<StyleSheet*>& aArray)
{

Просмотреть файл

@ -125,17 +125,9 @@ public:
nsresult GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult);
// Do any processing that needs to happen as a result of a change in the
// characteristics of the medium, and return whether this rule processor's
// rules or the servo style set have changed (e.g., because of media
// queries).
bool MediumFeaturesChanged(nsPresContext* aPresContext,
mozilla::MediaFeatureChangeReason);
void AppendAllSheets(nsTArray<mozilla::StyleSheet*>& aArray);
void Traverse(nsIContent *aContent,
nsCycleCollectionTraversalCallback &cb);
void Traverse(nsIContent *aContent, nsCycleCollectionTraversalCallback &cb);
NS_DECL_CYCLE_COLLECTION_CLASS(nsBindingManager)

Просмотреть файл

@ -105,17 +105,10 @@ nsXBLPrototypeResources::FlushSkinSheets()
mStyleSheetList.AppendElement(newSheet);
}
if (doc->IsStyledByServo()) {
// There may be no shell during unlink.
//
// FIXME(emilio): We shouldn't skip shadow root style updates just because?
// Though during unlink is fine I guess...
if (auto* shell = doc->GetShell()) {
MOZ_ASSERT(shell->GetPresContext());
ComputeServoStyles(*shell->StyleSet()->AsServo());
}
} else {
MOZ_CRASH("old style system disabled");
// There may be no shell during unlink.
if (auto* shell = doc->GetShell()) {
MOZ_ASSERT(shell->GetPresContext());
ComputeServoStyles(*shell->StyleSet()->AsServo());
}
return NS_OK;

Просмотреть файл

@ -389,7 +389,7 @@ nsXBLService::IsChromeOrResourceURI(nsIURI* aURI)
static void
EnsureSubtreeStyled(Element* aElement)
{
if (!aElement->IsStyledByServo() || !aElement->HasServoData()) {
if (!aElement->HasServoData()) {
return;
}

Просмотреть файл

@ -2960,26 +2960,24 @@ PresShell::DestroyFramesForAndRestyle(Element* aElement)
++mChangeNestCount;
const bool didReconstruct = FrameConstructor()->DestroyFramesFor(aElement);
if (aElement->IsStyledByServo()) {
if (aElement->GetFlattenedTreeParentNode()) {
// The element is still in the flat tree, but their children may not be
// anymore in a second.
//
// This is the case of a new shadow root or XBL binding about to be
// attached.
//
// Clear the style data from all the flattened tree descendants, but _not_
// from us, since otherwise we wouldn't see the reframe.
//
// FIXME(emilio): It'd be more ergonomic to just map the no data -> data
// case to a reframe from the style system.
ServoRestyleManager::ClearServoDataFromSubtree(
aElement, ServoRestyleManager::IncludeRoot::No);
} else {
// This is the case of an element that was redistributed but is no longer
// bound to any insertion point. Just forget about all the data.
ServoRestyleManager::ClearServoDataFromSubtree(aElement);
}
if (aElement->GetFlattenedTreeParentNode()) {
// The element is still in the flat tree, but their children may not be
// anymore in a second.
//
// This is the case of a new shadow root or XBL binding about to be
// attached.
//
// Clear the style data from all the flattened tree descendants, but _not_
// from us, since otherwise we wouldn't see the reframe.
//
// FIXME(emilio): It'd be more ergonomic to just map the no data -> data
// case to a reframe from the style system.
ServoRestyleManager::ClearServoDataFromSubtree(
aElement, ServoRestyleManager::IncludeRoot::No);
} else {
// This is the case of an element that was redistributed but is no longer
// bound to any insertion point. Just forget about all the data.
ServoRestyleManager::ClearServoDataFromSubtree(aElement);
}
auto changeHint = didReconstruct

Просмотреть файл

@ -846,11 +846,9 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
// most of the time.
//
// FIXME(emilio): I'm pretty sure this doesn't happen after bug 1414999.
if (mDocument->IsStyledByServo()) {
Element* root = mDocument->GetRootElement();
if (root && root->HasServoData()) {
ServoRestyleManager::ClearServoDataFromSubtree(root);
}
Element* root = mDocument->GetRootElement();
if (root && root->HasServoData()) {
ServoRestyleManager::ClearServoDataFromSubtree(root);
}
if (mDeviceContext->SetFullZoom(mFullZoom))
@ -1076,12 +1074,13 @@ nsPresContext::DoChangeCharSet(NotNull<const Encoding*> aCharSet)
{
UpdateCharSet(aCharSet);
mDeviceContext->FlushFontCache();
// In Stylo, if a document contains one or more <script> elements, frame
// construction might happen earlier than the UpdateCharSet(), so we need to
// restyle descendants to make their style data up-to-date.
RebuildAllStyleData(NS_STYLE_HINT_REFLOW,
mDocument->IsStyledByServo()
? eRestyle_ForceDescendants : nsRestyleHint(0));
// If a document contains one or more <script> elements, frame construction
// might happen earlier than the UpdateCharSet(), so we need to restyle
// descendants to make their style data up-to-date.
//
// FIXME(emilio): Revisit whether this is true after bug 1438911.
RebuildAllStyleData(NS_STYLE_HINT_REFLOW, eRestyle_ForceDescendants);
}
void

Просмотреть файл

@ -33,7 +33,6 @@ nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChange
aFrame->PresContext()->FrameConstructor()->
GetDisplayContentsStyleFor(aContent->GetParent())) ||
(aContent->IsNodeOfType(nsINode::eTEXT) &&
aContent->IsStyledByServo() &&
aContent->HasFlag(NODE_NEEDS_FRAME) &&
aHint & nsChangeHint_ReconstructFrame),
"Shouldn't be trying to restyle non-elements directly, "

Просмотреть файл

@ -537,12 +537,8 @@ FontFace::ParseDescriptor(nsCSSFontDesc aDescID,
nsCOMPtr<nsIURI> docURI = window->GetDocumentURI();
nsCOMPtr<nsIURI> base = window->GetDocBaseURI();
if (mFontFaceSet->Document()->IsStyledByServo()) {
RefPtr<URLExtraData> url = new URLExtraData(base, docURI, principal);
return ServoCSSParser::ParseFontDescriptor(aDescID, aString, url, aResult);
}
MOZ_CRASH("old style system disabled");
RefPtr<URLExtraData> url = new URLExtraData(base, docURI, principal);
return ServoCSSParser::ParseFontDescriptor(aDescID, aString, url, aResult);
}
void

Просмотреть файл

@ -205,23 +205,18 @@ FontFaceSet::ParseFontShorthandForMatching(
uint8_t& aStyle,
ErrorResult& aRv)
{
if (mDocument->IsStyledByServo()) {
nsCSSValue style;
nsCSSValue stretch;
nsCSSValue weight;
RefPtr<URLExtraData> url = ServoCSSParser::GetURLExtraData(mDocument);
if (!ServoCSSParser::ParseFontShorthandForMatching(
aFont, url, aFamilyList, style, stretch, weight)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}
aWeight = weight.GetIntValue();
aStretch = stretch.GetIntValue();
aStyle = style.GetIntValue();
nsCSSValue style;
nsCSSValue stretch;
nsCSSValue weight;
RefPtr<URLExtraData> url = ServoCSSParser::GetURLExtraData(mDocument);
if (!ServoCSSParser::ParseFontShorthandForMatching(
aFont, url, aFamilyList, style, stretch, weight)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}
MOZ_CRASH("old style system disabled");
aWeight = weight.GetIntValue();
aStretch = stretch.GetIntValue();
aStyle = style.GetIntValue();
}
static bool

Просмотреть файл

@ -124,16 +124,9 @@ nsCSSCounterStyleRule::GetName(nsAString& aName)
void
nsCSSCounterStyleRule::SetName(const nsAString& aName)
{
RefPtr<nsAtom> name;
nsIDocument* doc = GetDocument();
if (!doc || doc->IsStyledByServo()) {
name = ServoCSSParser::ParseCounterStyleName(aName);
} else {
MOZ_CRASH("old style system disabled");
}
if (name) {
if (RefPtr<nsAtom> name = ServoCSSParser::ParseCounterStyleName(aName)) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, true);
mName = name;

Просмотреть файл

@ -138,12 +138,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation)
}
// cannot fail
RefPtr<DeclarationBlock> decl;
if (mElement->IsStyledByServo()) {
decl = new ServoDeclarationBlock();
} else {
MOZ_CRASH("old style system disabled");
}
RefPtr<DeclarationBlock> decl = new ServoDeclarationBlock();
// this *can* fail (inside SetAttrAndNotify, at least).
nsresult rv;

Просмотреть файл

@ -113,18 +113,14 @@ ElementPropertyTransition::UpdateStartValueFromReplacedTransition()
const AnimationValue& replacedFrom = mReplacedTransition->mFromValue;
const AnimationValue& replacedTo = mReplacedTransition->mToValue;
AnimationValue startValue;
if (mDocument->IsStyledByServo()) {
startValue.mServo =
Servo_AnimationValues_Interpolate(replacedFrom.mServo,
replacedTo.mServo,
valuePosition).Consume();
if (startValue.mServo) {
mKeyframes[0].mPropertyValues[0].mServoDeclarationBlock =
Servo_AnimationValue_Uncompute(startValue.mServo).Consume();
mProperties[0].mSegments[0].mFromValue = Move(startValue);
}
} else {
MOZ_CRASH("old style system disabled");
startValue.mServo =
Servo_AnimationValues_Interpolate(replacedFrom.mServo,
replacedTo.mServo,
valuePosition).Consume();
if (startValue.mServo) {
mKeyframes[0].mPropertyValues[0].mServoDeclarationBlock =
Servo_AnimationValue_Uncompute(startValue.mServo).Consume();
mProperties[0].mSegments[0].mFromValue = Move(startValue);
}
}
@ -633,14 +629,9 @@ GetTransitionKeyframes(nsCSSPropertyID aProperty,
}
static bool
IsTransitionable(nsCSSPropertyID aProperty, bool aIsServo)
IsTransitionable(nsCSSPropertyID aProperty)
{
if (aIsServo) {
return Servo_Property_IsTransitionable(aProperty);
}
// FIXME: This should also exclude discretely-animated properties.
return nsCSSProps::kAnimTypeTable[aProperty] != eStyleAnimType_None;
return Servo_Property_IsTransitionable(aProperty);
}
template<typename StyleType>
@ -678,7 +669,7 @@ nsTransitionManager::ConsiderInitiatingTransition(
return;
}
if (!IsTransitionable(aProperty, aElement->IsStyledByServo())) {
if (!IsTransitionable(aProperty)) {
return;
}