Issue #2112 - Part 5: Remove Servo from forwarding code used by magic pointer classes

This commit is contained in:
FranklinDM
2024-03-25 02:02:08 +08:00
committed by roytam1
parent b1c9206051
commit a93a7bed47
52 changed files with 278 additions and 1120 deletions
-6
View File
@@ -202,9 +202,6 @@ EffectCompositor::RequestRestyle(dom::Element* aElement,
if (aRestyleType == RestyleType::Layer) {
// Prompt layers to re-sync their animations.
MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
"stylo: Servo-backed style system should not be using "
"EffectCompositor");
mPresContext->RestyleManager()->AsGecko()->IncrementAnimationGeneration();
EffectSet* effectSet =
EffectSet::GetEffectSet(aElement, aPseudoType);
@@ -317,9 +314,6 @@ EffectCompositor::GetAnimationRule(dom::Element* aElement,
return nullptr;
}
MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
"stylo: Servo-backed style system should not be using "
"EffectCompositor");
if (mPresContext->RestyleManager()->AsGecko()->SkipAnimationRules()) {
// We don't need to worry about updating mElementsToRestyle in this case
// since this is not the animation restyle we requested when we called
-3
View File
@@ -110,9 +110,6 @@ EffectSet::DestroyEffectSet(dom::Element* aElement,
void
EffectSet::UpdateAnimationGeneration(nsPresContext* aPresContext)
{
MOZ_ASSERT(aPresContext->RestyleManager()->IsGecko(),
"stylo: Servo-backed style system should not be using "
"EffectSet");
mAnimationGeneration =
aPresContext->RestyleManager()->AsGecko()->GetAnimationGeneration();
}
+2 -9
View File
@@ -296,10 +296,7 @@ KeyframeEffectReadOnly::UpdateProperties(nsStyleContext* aStyleContext)
runningOnCompositorProperties.HasProperty(property.mProperty);
}
// FIXME (bug 1303235): Do this for Servo too
if (aStyleContext->PresContext()->StyleSet()->IsGecko()) {
CalculateCumulativeChangeHint(aStyleContext);
}
CalculateCumulativeChangeHint(aStyleContext);
MarkCascadeNeedsUpdate();
@@ -1286,8 +1283,6 @@ CreateStyleContextForAnimationValue(nsCSSPropertyID aProperty,
nsCOMArray<nsIStyleRule> rules;
rules.AppendObject(styleRule);
MOZ_ASSERT(aBaseStyleContext->PresContext()->StyleSet()->IsGecko(),
"ServoStyleSet should not use StyleAnimationValue for animations");
nsStyleSet* styleSet =
aBaseStyleContext->PresContext()->StyleSet()->AsGecko();
@@ -1362,10 +1357,8 @@ KeyframeEffectReadOnly::CanIgnoreIfNotVisible() const
return false;
}
// FIXME (bug 1303235): We don't calculate mCumulativeChangeHint for
// the Servo backend yet
nsPresContext* presContext = GetPresContext();
if (!presContext || presContext->StyleSet()->IsServo()) {
if (!presContext) {
return false;
}
+20 -76
View File
@@ -9,7 +9,6 @@
#include "mozilla/Move.h"
#include "mozilla/Preferences.h"
#include "mozilla/RangedArray.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/TimingParams.h"
#include "mozilla/dom/BaseKeyframeTypesBinding.h" // For FastBaseKeyframe etc.
@@ -321,10 +320,6 @@ public:
inline bool
IsInvalidValuePair(const PropertyValuePair& aPair, StyleBackendType aBackend)
{
if (aBackend == StyleBackendType::Servo) {
return !aPair.mServoDeclarationBlock;
}
// There are three types of values we store as token streams:
//
// * Shorthand values (where we manually extract the token stream's string
@@ -610,11 +605,6 @@ KeyframeUtils::GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
ComputedKeyframeValues* computedValues = result.AppendElement();
for (const PropertyValuePair& pair :
PropertyPriorityIterator(frame.mPropertyValues)) {
MOZ_ASSERT(!pair.mServoDeclarationBlock ||
styleBackend == StyleBackendType::Servo,
"Animation values were parsed using Servo backend but target"
" element is not using Servo backend?");
if (IsInvalidValuePair(pair, styleBackend)) {
continue;
}
@@ -623,33 +613,25 @@ KeyframeUtils::GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
// a KeyframeValueEntry for each value.
nsTArray<PropertyStyleAnimationValuePair> values;
if (styleBackend == StyleBackendType::Servo) {
// For shorthands, we store the string as a token stream so we need to
// extract that first.
if (nsCSSProps::IsShorthand(pair.mProperty)) {
nsCSSValueTokenStream* tokenStream = pair.mValue.GetTokenStreamValue();
if (!StyleAnimationValue::ComputeValues(pair.mProperty,
CSSEnabledState::eForAllContent, aStyleContext,
*pair.mServoDeclarationBlock, values)) {
CSSEnabledState::eForAllContent, aElement, aStyleContext,
tokenStream->mTokenStream, /* aUseSVGMode */ false, values) ||
IsComputeValuesFailureKey(pair)) {
continue;
}
} else {
// For shorthands, we store the string as a token stream so we need to
// extract that first.
if (nsCSSProps::IsShorthand(pair.mProperty)) {
nsCSSValueTokenStream* tokenStream = pair.mValue.GetTokenStreamValue();
if (!StyleAnimationValue::ComputeValues(pair.mProperty,
CSSEnabledState::eForAllContent, aElement, aStyleContext,
tokenStream->mTokenStream, /* aUseSVGMode */ false, values) ||
IsComputeValuesFailureKey(pair)) {
continue;
}
} else {
if (!StyleAnimationValue::ComputeValues(pair.mProperty,
CSSEnabledState::eForAllContent, aElement, aStyleContext,
pair.mValue, /* aUseSVGMode */ false, values)) {
continue;
}
MOZ_ASSERT(values.Length() == 1,
"Longhand properties should produce a single"
" StyleAnimationValue");
if (!StyleAnimationValue::ComputeValues(pair.mProperty,
CSSEnabledState::eForAllContent, aElement, aStyleContext,
pair.mValue, /* aUseSVGMode */ false, values)) {
continue;
}
MOZ_ASSERT(values.Length() == 1,
"Longhand properties should produce a single"
" StyleAnimationValue");
}
for (auto& value : values) {
@@ -999,30 +981,6 @@ MakePropertyValuePair(nsCSSPropertyID aProperty, const nsAString& aStringValue,
result.mProperty = aProperty;
if (aDocument->GetStyleBackendType() == StyleBackendType::Servo) {
nsCString name = nsCSSProps::GetStringValue(aProperty);
NS_ConvertUTF16toUTF8 value(aStringValue);
RefPtr<ThreadSafeURIHolder> base =
new ThreadSafeURIHolder(aDocument->GetDocumentURI());
RefPtr<ThreadSafeURIHolder> referrer =
new ThreadSafeURIHolder(aDocument->GetDocumentURI());
RefPtr<ThreadSafePrincipalHolder> principal =
new ThreadSafePrincipalHolder(aDocument->NodePrincipal());
nsCString baseString;
aDocument->GetDocumentURI()->GetSpec(baseString);
RefPtr<RawServoDeclarationBlock> servoDeclarationBlock =
Servo_ParseProperty(&name, &value, &baseString,
base, referrer, principal).Consume();
if (servoDeclarationBlock) {
result.mServoDeclarationBlock = servoDeclarationBlock.forget();
return result;
}
}
nsCSSValue value;
if (!nsCSSProps::IsShorthand(aProperty)) {
aParser.ParseLonghandProperty(aProperty,
@@ -1054,13 +1012,6 @@ MakePropertyValuePair(nsCSSPropertyID aProperty, const nsAString& aStringValue,
"The shorthand property of a token stream should be initialized"
" to unknown");
value.SetTokenStreamValue(tokenStream);
} else {
// If we succeeded in parsing with Gecko, but not Servo the animation is
// not going to work since, for the purposes of animation, we're going to
// ignore |mValue| when the backend is Servo.
NS_WARNING_ASSERTION(aDocument->GetStyleBackendType() !=
StyleBackendType::Servo,
"Gecko succeeded in parsing where Servo failed");
}
result.mValue = value;
@@ -1434,20 +1385,13 @@ HasImplicitKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
}
if (nsCSSProps::IsShorthand(pair.mProperty)) {
if (styleBackend == StyleBackendType::Gecko) {
nsCSSValueTokenStream* tokenStream =
pair.mValue.GetTokenStreamValue();
nsCSSParser parser(aDocument->CSSLoader());
if (!parser.IsValueValidForProperty(pair.mProperty,
tokenStream->mTokenStream)) {
continue;
}
nsCSSValueTokenStream* tokenStream =
pair.mValue.GetTokenStreamValue();
nsCSSParser parser(aDocument->CSSLoader());
if (!parser.IsValueValidForProperty(pair.mProperty,
tokenStream->mTokenStream)) {
continue;
}
// For the Servo backend, invalid shorthand values are represented by
// a null mServoDeclarationBlock member which we skip above in
// IsInvalidValuePair.
MOZ_ASSERT(styleBackend != StyleBackendType::Servo ||
pair.mServoDeclarationBlock);
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(
prop, pair.mProperty, CSSEnabledState::eForAllContent) {
addToPropertySets(*prop, offsetToUse);
+4 -8
View File
@@ -1749,14 +1749,10 @@ nsAttrValue::ParseStyleAttribute(const nsAString& aString,
}
RefPtr<DeclarationBlock> decl;
if (ownerDoc->GetStyleBackendType() == StyleBackendType::Servo) {
decl = ServoDeclarationBlock::FromCssText(aString);
} else {
css::Loader* cssLoader = ownerDoc->CSSLoader();
nsCSSParser cssParser(cssLoader);
decl = cssParser.ParseStyleAttribute(aString, docURI, baseURI,
aElement->NodePrincipal());
}
css::Loader* cssLoader = ownerDoc->CSSLoader();
nsCSSParser cssParser(cssLoader);
decl = cssParser.ParseStyleAttribute(aString, docURI, baseURI,
aElement->NodePrincipal());
if (!decl) {
return false;
}
+24 -65
View File
@@ -1153,10 +1153,6 @@ nsDOMStyleSheetSetList::EnsureFresh()
StyleSheet* sheet = mDocument->SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam ServoStyleSheets don't expose their title yet.
if (sheet->IsServo()) {
NS_ERROR("stylo: ServoStyleSets don't expose their title yet");
continue;
}
sheet->AsGecko()->GetTitle(title);
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
return;
@@ -2193,23 +2189,18 @@ nsDocument::FillStyleSet(StyleSetHandle aStyleSet)
}
}
if (aStyleSet->IsGecko()) {
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
}
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
} else {
NS_WARNING("stylo: Not yet checking nsStyleSheetService for Servo-backed "
"documents. See bug 1290224");
}
AppendSheetsToStyleSet(aStyleSet, mAdditionalSheets[eAgentSheet],
@@ -3850,11 +3841,7 @@ nsDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
className##Init init; \
init.mBubbles = true; \
init.mCancelable = true; \
/* XXXheycam ServoStyleSheet doesn't implement DOM interfaces yet */ \
if (aSheet->IsServo()) { \
NS_ERROR("stylo: can't dispatch events for ServoStyleSheets yet"); \
} \
init.mStylesheet = aSheet->IsGecko() ? aSheet->AsGecko() : nullptr; \
init.mStylesheet = aSheet->AsGecko(); \
init.memberName = argName; \
\
RefPtr<className> event = \
@@ -5623,12 +5610,6 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam Make this work with ServoStyleSheets.
if (sheet->IsServo()) {
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
continue;
}
bool disabled;
sheet->AsGecko()->GetDisabled(&disabled);
if (disabled) {
@@ -5743,12 +5724,6 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
// XXXheycam Make this work with ServoStyleSheets.
if (sheet->IsServo()) {
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
continue;
}
sheet->AsGecko()->GetTitle(title);
if (!title.IsEmpty()) {
sheet->AsGecko()->SetEnabled(title.Equals(aSheetSet));
@@ -9471,17 +9446,12 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
RefPtr<StyleSheet> sheet = SheetAt(i);
if (sheet) {
if (sheet->IsApplicable()) {
// XXXheycam Need to make ServoStyleSheet cloning work.
if (sheet->IsGecko()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddStyleSheet(clonedSheet);
}
} else {
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddStyleSheet(clonedSheet);
}
}
}
@@ -9491,17 +9461,12 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
for (StyleSheet* sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
if (sheet) {
if (sheet->IsApplicable()) {
// XXXheycam Need to make ServoStyleSheet cloning work.
if (sheet->IsGecko()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
}
} else {
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
}
}
}
@@ -12203,14 +12168,8 @@ nsIDocument::FlushUserFontSet()
nsTArray<nsFontFaceRuleContainer> rules;
nsIPresShell* shell = GetShell();
if (shell) {
// XXXheycam ServoStyleSets don't support exposing @font-face rules yet.
if (shell->StyleSet()->IsGecko()) {
if (!shell->StyleSet()->AsGecko()->AppendFontFaceRules(rules)) {
return;
}
} else {
NS_WARNING("stylo: ServoStyleSets cannot handle @font-face rules yet. "
"See bug 1290237.");
if (!shell->StyleSet()->AsGecko()->AppendFontFaceRules(rules)) {
return;
}
}
+1 -12
View File
@@ -319,14 +319,9 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
return NS_OK;
}
// XXXheycam ServoStyleSheets do not support <style scoped>.
Element* oldScopeElement = nullptr;
if (mStyleSheet) {
if (mStyleSheet->IsServo()) {
NS_WARNING("stylo: ServoStyleSheets don't support <style scoped>");
} else {
oldScopeElement = mStyleSheet->AsGecko()->GetScopeElement();
}
oldScopeElement = mStyleSheet->AsGecko()->GetScopeElement();
}
if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
@@ -488,12 +483,6 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
return;
}
if (mStyleSheet->IsServo()) {
// XXXheycam ServoStyleSheets don't support <style scoped>.
NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
return;
}
CSSStyleSheet* sheet = mStyleSheet->AsGecko();
nsCOMPtr<nsIContent> thisContent;
-3
View File
@@ -929,9 +929,6 @@ nsSVGElement::WalkAnimatedContentStyleRules(nsRuleWalker* aRuleWalker)
// apply the SMILOverrideStyle.)
RestyleManagerHandle restyleManager =
aRuleWalker->PresContext()->RestyleManager();
MOZ_ASSERT(restyleManager->IsGecko(),
"stylo: Servo-backed style system should not be calling "
"WalkAnimatedContentStyleRules");
if (!restyleManager->AsGecko()->SkipAnimationRules()) {
// update/walk the animated content style rule.
css::StyleRule* animContentStyleRule = GetAnimatedContentStyleRule();
-9
View File
@@ -420,15 +420,6 @@ nsXBLBinding::GenerateAnonymousContent()
if (mContent)
mContent->UnsetAttr(namespaceID, name, false);
}
// Now that we've finished shuffling the tree around, go ahead and restyle it
// since frame construction is about to happen.
nsIPresShell* presShell = mBoundElement->OwnerDoc()->GetShell();
ServoStyleSet* servoSet = presShell->StyleSet()->GetAsServo();
if (servoSet) {
mBoundElement->SetHasDirtyDescendantsForServo();
servoSet->StyleNewChildren(mBoundElement);
}
}
nsIURI*
-4
View File
@@ -147,10 +147,6 @@ nsXBLPrototypeResources::GatherRuleProcessor()
{
nsTArray<RefPtr<CSSStyleSheet>> sheets(mStyleSheetList.Length());
for (StyleSheet* sheet : mStyleSheetList) {
MOZ_ASSERT(sheet->IsGecko(),
"GatherRuleProcessor must only be called for "
"nsXBLPrototypeResources objects with Gecko-flavored style "
"backends");
sheets.AppendElement(sheet->AsGecko());
}
mRuleProcessor = new nsCSSRuleProcessor(Move(sheets),
-4
View File
@@ -552,10 +552,6 @@ CSSEditUtils::GetCSSInlinePropertyBase(nsINode* aNode,
if (!decl) {
return NS_OK;
}
if (decl->IsServo()) {
MOZ_CRASH("stylo: not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsCSSPropertyID prop =
nsCSSProps::LookupProperty(nsDependentAtomString(aProperty),
CSSEnabledState::eForAllContent);
-10
View File
@@ -2907,11 +2907,6 @@ HTMLEditor::EnableStyleSheet(const nsAString& aURL,
nsCOMPtr<nsIDocument> document = GetDocument();
sheet->SetAssociatedDocument(document, StyleSheet::NotOwnedByDocument);
if (sheet->IsServo()) {
// XXXheycam ServoStyleSheets don't support being enabled/disabled yet.
NS_ERROR("stylo: ServoStyleSheets can't be disabled yet");
return NS_ERROR_FAILURE;
}
return sheet->AsGecko()->SetDisabled(!aEnable);
}
@@ -2929,11 +2924,6 @@ HTMLEditor::EnableExistingStyleSheet(const nsAString& aURL)
nsCOMPtr<nsIDocument> document = GetDocument();
sheet->SetAssociatedDocument(document, StyleSheet::NotOwnedByDocument);
if (sheet->IsServo()) {
// XXXheycam ServoStyleSheets don't support being enabled/disabled yet.
NS_ERROR("stylo: ServoStyleSheets can't be disabled yet");
return true;
}
sheet->AsGecko()->SetDisabled(false);
return true;
}
-3
View File
@@ -3877,9 +3877,6 @@ RestyleManager::ComputeAndProcessStyleChange(nsStyleContext* aNewContext,
nsStyleSet*
ElementRestyler::StyleSet() const
{
MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
"ElementRestyler should only be used with a Gecko-flavored "
"style backend");
return mPresContext->StyleSet()->AsGecko();
}
-3
View File
@@ -458,9 +458,6 @@ public:
private:
inline nsStyleSet* StyleSet() const {
MOZ_ASSERT(PresContext()->StyleSet()->IsGecko(),
"RestyleManager should only be used with a Gecko-flavored "
"style backend");
return PresContext()->StyleSet()->AsGecko();
}
-8
View File
@@ -115,14 +115,6 @@ protected:
return PresContext()->FrameConstructor();
}
inline bool IsGecko() const {
return !IsServo();
}
inline bool IsServo() const {
return false;
}
private:
nsPresContext* mPresContext; // weak, can be null after Disconnect().
uint32_t mRestyleGeneration;
+3 -26
View File
@@ -48,47 +48,24 @@ public:
public:
friend class ::mozilla::RestyleManagerHandle;
bool IsGecko() const { return !IsServo(); }
bool IsServo() const
{
MOZ_ASSERT(mValue, "RestyleManagerHandle null pointer dereference");
return false;
}
StyleBackendType BackendType() const
{
return IsGecko() ? StyleBackendType::Gecko :
StyleBackendType::Servo;
return StyleBackendType::Gecko;
}
RestyleManager* AsGecko()
{
MOZ_ASSERT(IsGecko());
return reinterpret_cast<RestyleManager*>(mValue);
}
ServoRestyleManager* AsServo()
{
MOZ_ASSERT(IsServo());
return reinterpret_cast<ServoRestyleManager*>(mValue & ~SERVO_BIT);
}
RestyleManager* GetAsGecko() { return IsGecko() ? AsGecko() : nullptr; }
ServoRestyleManager* GetAsServo() { return IsServo() ? AsServo() : nullptr; }
RestyleManager* GetAsGecko() { return AsGecko(); }
const RestyleManager* AsGecko() const
{
return const_cast<Ptr*>(this)->AsGecko();
}
const ServoRestyleManager* AsServo() const
{
MOZ_ASSERT(IsServo());
return const_cast<Ptr*>(this)->AsServo();
}
const RestyleManager* GetAsGecko() const { return IsGecko() ? AsGecko() : nullptr; }
const ServoRestyleManager* GetAsServo() const { return IsServo() ? AsServo() : nullptr; }
const RestyleManager* GetAsGecko() const { return AsGecko(); }
// These inline methods are defined in RestyleManagerHandleInlines.h.
inline MozExternalRefCountType AddRef();
+26 -39
View File
@@ -7,35 +7,25 @@
#define mozilla_RestyleManagerHandleInlines_h
#include "mozilla/RestyleManager.h"
#include "mozilla/ServoRestyleManager.h"
#define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \
if (IsGecko()) { \
return AsGecko()->method_ geckoargs_; \
} else { \
return AsServo()->method_ servoargs_; \
}
#define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_)
namespace mozilla {
MozExternalRefCountType
RestyleManagerHandle::Ptr::AddRef()
{
FORWARD(AddRef, ());
return AsGecko()->AddRef();
}
MozExternalRefCountType
RestyleManagerHandle::Ptr::Release()
{
FORWARD(Release, ());
return AsGecko()->Release();
}
void
RestyleManagerHandle::Ptr::Disconnect()
{
FORWARD(Disconnect, ());
AsGecko()->Disconnect();
}
void
@@ -43,20 +33,20 @@ RestyleManagerHandle::Ptr::PostRestyleEvent(dom::Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)
{
FORWARD(PostRestyleEvent, (aElement, aRestyleHint, aMinChangeHint));
AsGecko()->PostRestyleEvent(aElement, aRestyleHint, aMinChangeHint);
}
void
RestyleManagerHandle::Ptr::PostRestyleEventForLazyConstruction()
{
FORWARD(PostRestyleEventForLazyConstruction, ());
AsGecko()->PostRestyleEventForLazyConstruction();
}
void
RestyleManagerHandle::Ptr::RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)
{
FORWARD(RebuildAllStyleData, (aExtraHint, aRestyleHint));
AsGecko()->RebuildAllStyleData(aExtraHint, aRestyleHint);
}
void
@@ -64,39 +54,39 @@ RestyleManagerHandle::Ptr::PostRebuildAllStyleDataEvent(
nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)
{
FORWARD(PostRebuildAllStyleDataEvent, (aExtraHint, aRestyleHint));
AsGecko()->PostRebuildAllStyleDataEvent(aExtraHint, aRestyleHint);
}
void
RestyleManagerHandle::Ptr::ProcessPendingRestyles()
{
FORWARD(ProcessPendingRestyles, ());
AsGecko()->ProcessPendingRestyles();
}
nsresult
RestyleManagerHandle::Ptr::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
{
FORWARD(ProcessRestyledFrames, (aChangeList));
return AsGecko()->ProcessRestyledFrames(aChangeList);
}
void
RestyleManagerHandle::Ptr::FlushOverflowChangedTracker()
{
FORWARD(FlushOverflowChangedTracker, ());
AsGecko()->FlushOverflowChangedTracker();
}
void
RestyleManagerHandle::Ptr::ContentInserted(nsINode* aContainer,
nsIContent* aChild)
{
FORWARD(ContentInserted, (aContainer, aChild));
AsGecko()->ContentInserted(aContainer, aChild);
}
void
RestyleManagerHandle::Ptr::ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent)
{
FORWARD(ContentAppended, (aContainer, aFirstNewContent));
AsGecko()->ContentAppended(aContainer, aFirstNewContent);
}
void
@@ -104,28 +94,28 @@ RestyleManagerHandle::Ptr::ContentRemoved(nsINode* aContainer,
nsIContent* aOldChild,
nsIContent* aFollowingSibling)
{
FORWARD(ContentRemoved, (aContainer, aOldChild, aFollowingSibling));
AsGecko()->ContentRemoved(aContainer, aOldChild, aFollowingSibling);
}
void
RestyleManagerHandle::Ptr::RestyleForInsertOrChange(nsINode* aContainer,
nsIContent* aChild)
{
FORWARD(RestyleForInsertOrChange, (aContainer, aChild));
AsGecko()->RestyleForInsertOrChange(aContainer, aChild);
}
void
RestyleManagerHandle::Ptr::RestyleForAppend(nsIContent* aContainer,
nsIContent* aFirstNewContent)
{
FORWARD(RestyleForAppend, (aContainer, aFirstNewContent));
AsGecko()->RestyleForAppend(aContainer, aFirstNewContent);
}
void
RestyleManagerHandle::Ptr::ContentStateChanged(nsIContent* aContent,
EventStates aStateMask)
{
FORWARD(ContentStateChanged, (aContent, aStateMask));
AsGecko()->ContentStateChanged(aContent, aStateMask);
}
void
@@ -135,8 +125,8 @@ RestyleManagerHandle::Ptr::AttributeWillChange(dom::Element* aElement,
int32_t aModType,
const nsAttrValue* aNewValue)
{
FORWARD(AttributeWillChange, (aElement, aNameSpaceID, aAttribute, aModType,
aNewValue));
AsGecko()->AttributeWillChange(aElement, aNameSpaceID, aAttribute, aModType,
aNewValue);
}
void
@@ -146,49 +136,46 @@ RestyleManagerHandle::Ptr::AttributeChanged(dom::Element* aElement,
int32_t aModType,
const nsAttrValue* aOldValue)
{
FORWARD(AttributeChanged, (aElement, aNameSpaceID, aAttribute, aModType,
aOldValue));
AsGecko()->AttributeChanged(aElement, aNameSpaceID, aAttribute, aModType,
aOldValue);
}
nsresult
RestyleManagerHandle::Ptr::ReparentStyleContext(nsIFrame* aFrame)
{
FORWARD(ReparentStyleContext, (aFrame));
return AsGecko()->ReparentStyleContext(aFrame);
}
bool
RestyleManagerHandle::Ptr::HasPendingRestyles()
{
FORWARD(HasPendingRestyles, ());
return AsGecko()->HasPendingRestyles();
}
uint64_t
RestyleManagerHandle::Ptr::GetRestyleGeneration() const
{
FORWARD(GetRestyleGeneration, ());
return AsGecko()->GetRestyleGeneration();
}
uint32_t
RestyleManagerHandle::Ptr::GetHoverGeneration() const
{
FORWARD(GetHoverGeneration, ());
return AsGecko()->GetHoverGeneration();
}
void
RestyleManagerHandle::Ptr::SetObservingRefreshDriver(bool aObserving)
{
FORWARD(SetObservingRefreshDriver, (aObserving));
AsGecko()->SetObservingRefreshDriver(aObserving);
}
void
RestyleManagerHandle::Ptr::NotifyDestroyingFrame(nsIFrame* aFrame)
{
FORWARD(NotifyDestroyingFrame, (aFrame));
AsGecko()->NotifyDestroyingFrame(aFrame);
}
} // namespace mozilla
#undef FORWARD
#undef FORWARD_CONCRETE
#endif // mozilla_RestyleManagerHandleInlines_h
+1 -21
View File
@@ -2698,13 +2698,7 @@ nsCSSFrameConstructor::ConstructRootFrame()
// Set up our style rule observer.
// XXXbz wouldn't this make more sense as part of presshell init?
if (styleSet->IsGecko()) {
// XXXheycam We don't support XBL bindings providing style to
// ServoStyleSets yet.
styleSet->AsGecko()->SetBindingManager(mDocument->BindingManager());
} else {
NS_WARNING("stylo: cannot get ServoStyleSheets from XBL bindings yet. See bug 1290276.");
}
styleSet->AsGecko()->SetBindingManager(mDocument->BindingManager());
// --------- BUILD VIEWPORT -----------
RefPtr<nsStyleContext> viewportPseudoStyle =
@@ -4246,15 +4240,6 @@ nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent,
}
}
if (ServoStyleSet* styleSet = mPresShell->StyleSet()->GetAsServo()) {
// Eagerly compute styles for the anonymous content tree.
for (auto& info : aContent) {
if (info.mContent->IsElement()) {
styleSet->StyleNewSubtree(info.mContent);
}
}
}
return NS_OK;
}
@@ -10537,11 +10522,6 @@ nsCSSFrameConstructor::AddFCItemsForAnonymousContent(
TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper
parentDisplayBasedStyleFixupSkipper(aState.mTreeMatchContext);
// Make sure we eagerly performed the servo cascade when the anonymous
// nodes were created.
MOZ_ASSERT_IF(content->IsStyledByServo() && content->IsElement(),
content->AsElement()->HasServoData());
// Determine whether this NAC is pseudo-implementing.
nsIAtom* pseudo = nullptr;
if (content->IsElement()) {
+8 -19
View File
@@ -5,7 +5,6 @@
/* container for a document and its presentation */
#include "mozilla/ServoStyleSet.h"
#include "nsAutoPtr.h"
#include "nscore.h"
#include "nsCOMPtr.h"
@@ -2279,12 +2278,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
StyleBackendType backendType = aDocument->GetStyleBackendType();
StyleSetHandle styleSet;
if (backendType == StyleBackendType::Gecko) {
styleSet = new nsStyleSet();
} else {
styleSet = new ServoStyleSet();
}
StyleSetHandle styleSet = new nsStyleSet();
styleSet->BeginUpdate();
@@ -2440,19 +2434,14 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
}
}
if (styleSet->IsGecko()) {
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) {
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
}
for (StyleSheet* sheet : Reversed(*sheetService->UserStyleSheets())) {
styleSet->PrependStyleSheet(SheetType::User, sheet);
}
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) {
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
}
for (StyleSheet* sheet : Reversed(*sheetService->UserStyleSheets())) {
styleSet->PrependStyleSheet(SheetType::User, sheet);
}
} else {
NS_WARNING("stylo: Not yet checking nsStyleSheetService for Servo-backed "
"documents. See bug 1290224");
}
// Caller will handle calling EndUpdate, per contract.
+6 -17
View File
@@ -894,14 +894,10 @@ nsPresContext::AttachShell(nsIPresShell* aShell, StyleBackendType aBackendType)
MOZ_ASSERT(!mShell);
mShell = aShell;
if (aBackendType == StyleBackendType::Servo) {
mRestyleManager = new ServoRestyleManager(this);
} else {
// Since RestyleManager is also the name of a method of nsPresContext,
// it is necessary to prefix the class with the mozilla namespace
// here.
mRestyleManager = new mozilla::RestyleManager(this);
}
// Since RestyleManager is also the name of a method of nsPresContext,
// it is necessary to prefix the class with the mozilla namespace
// here.
mRestyleManager = new mozilla::RestyleManager(this);
// Since CounterStyleManager is also the name of a method of
// nsPresContext, it is necessary to prefix the class with the mozilla
@@ -1886,15 +1882,8 @@ nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
// MediumFeaturesChanged updates the applied rules, so it always gets called.
if (mShell) {
// XXXheycam ServoStyleSets don't support responding to medium
// changes yet.
if (mShell->StyleSet()->IsGecko()) {
if (mShell->StyleSet()->AsGecko()->MediumFeaturesChanged()) {
aRestyleHint |= eRestyle_Subtree;
}
} else {
NS_WARNING("stylo: ServoStyleSets don't support responding to medium "
"changes yet. See bug 1290228.");
if (mShell->StyleSet()->AsGecko()->MediumFeaturesChanged()) {
aRestyleHint |= eRestyle_Subtree;
}
}
+5 -43
View File
@@ -569,10 +569,6 @@ static void
VerifyStyleTree(nsPresContext* aPresContext, nsFrameManager* aFrameManager)
{
if (nsFrame::GetVerifyStyleTreeEnable()) {
if (aPresContext->RestyleManager()->IsServo()) {
NS_ERROR("stylo: cannot verify style tree with a ServoRestyleManager");
return;
}
nsIFrame* rootFrame = aFrameManager->GetRootFrame();
aPresContext->RestyleManager()->AsGecko()->DebugVerifyStyleTree(rootFrame);
}
@@ -893,8 +889,7 @@ PresShell::Init(nsIDocument* aDocument,
// Bind the context to the presentation shell.
mPresContext = aPresContext;
StyleBackendType backend = aStyleSet->IsServo() ? StyleBackendType::Servo
: StyleBackendType::Gecko;
StyleBackendType backend = StyleBackendType::Gecko;
aPresContext->AttachShell(this, backend);
// Now we can initialize the style set. Make sure to set the member before
@@ -1425,11 +1420,6 @@ PresShell::RemovePreferenceStyles()
void
PresShell::AddUserSheet(nsISupports* aSheet)
{
if (mStyleSet->IsServo()) {
NS_ERROR("stylo: nsStyleSheetService doesn't handle ServoStyleSheets yet");
return;
}
// Make sure this does what nsDocumentViewer::CreateStyleSet does wrt
// ordering. We want this new sheet to come after all the existing stylesheet
// service sheets, but before other user sheets; see nsIStyleSheetService.idl
@@ -1692,17 +1682,6 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight)
mPresContext->SetVisibleArea(nsRect(0, 0, aWidth, aHeight));
if (mStyleSet->IsServo() && mDocument->GetRootElement()) {
// If we have the root element already, go ahead style it along with any
// descendants.
//
// Some things, like nsDocumentViewer::GetPageMode, recreate the PresShell
// while keeping the content tree alive (see bug 1292280) - so we
// unconditionally mark the root as dirty.
mDocument->GetRootElement()->SetIsDirtyForServo();
mStyleSet->AsServo()->StyleDocument(/* aLeaveDirtyBits = */ false);
}
// Get the root frame from the frame manager
// XXXbz it would be nice to move this somewhere else... like frame manager
// Init(), say. But we need to make sure our views are all set up by the
@@ -4508,15 +4487,9 @@ PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet)
if (mStylesHaveChanged)
return;
if (aStyleSheet->IsGecko()) {
// XXXheycam ServoStyleSheets don't support <style scoped> yet.
Element* scopeElement = aStyleSheet->AsGecko()->GetScopeElement();
if (scopeElement) {
mChangedScopeStyleRoots.AppendElement(scopeElement);
return;
}
} else {
NS_WARNING("stylo: ServoStyleSheets don't support <style scoped>");
Element* scopeElement = aStyleSheet->AsGecko()->GetScopeElement();
if (scopeElement) {
mChangedScopeStyleRoots.AppendElement(scopeElement);
return;
}
@@ -6773,10 +6746,7 @@ FlushThrottledStyles(nsIDocument *aDocument, void *aData)
if (shell && shell->IsVisible()) {
nsPresContext* presContext = shell->GetPresContext();
if (presContext) {
if (presContext->RestyleManager()->IsGecko()) {
// XXX stylo: ServoRestyleManager doesn't support animations yet.
presContext->RestyleManager()->AsGecko()->UpdateOnlyAnimationStyles();
}
presContext->RestyleManager()->AsGecko()->UpdateOnlyAnimationStyles();
}
}
@@ -9519,10 +9489,6 @@ PresShell::Observe(nsISupports* aSubject,
nsAutoScriptBlocker scriptBlocker;
++mChangeNestCount;
RestyleManagerHandle restyleManager = mPresContext->RestyleManager();
if (restyleManager->IsServo()) {
MOZ_CRASH("stylo: PresShell::Observe(\"chrome-flush-skin-caches\") "
"not implemented for Servo-backed style system");
}
restyleManager->AsGecko()->ProcessRestyledFrames(changeList);
restyleManager->AsGecko()->FlushOverflowChangedTracker();
--mChangeNestCount;
@@ -10004,10 +9970,6 @@ PresShell::VerifyIncrementalReflow()
// Create a new presentation shell to view the document. Use the
// exact same style information that this document has.
if (mStyleSet->IsServo()) {
NS_WARNING("VerifyIncrementalReflow cannot handle ServoStyleSets");
return true;
}
nsAutoPtr<nsStyleSet> newSet(CloneStyleSet(mStyleSet->AsGecko()));
nsCOMPtr<nsIPresShell> sh = mDocument->CreateShell(cx, vm, newSet.get());
NS_ENSURE_TRUE(sh, false);
+6 -21
View File
@@ -176,16 +176,10 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI,
// We're guaranteed that the new sheet is the last sheet in
// mSheets[aSheetType]
// XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
// we'll need to include them in the notification.
StyleSheet* sheet = mSheets[aSheetType].LastElement();
if (sheet->IsGecko()) {
CSSStyleSheet* cssSheet = sheet->AsGecko();
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
message, nullptr);
} else {
NS_ERROR("stylo: can't notify observers of ServoStyleSheets");
}
CSSStyleSheet* cssSheet = sheet->AsGecko();
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
message, nullptr);
}
if (XRE_IsParentProcess()) {
@@ -294,9 +288,6 @@ nsStyleSheetService::PreloadSheet(nsIURI *aSheetURI, uint32_t aSheetType,
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true, &sheet);
NS_ENSURE_SUCCESS(rv, rv);
MOZ_ASSERT(sheet->IsGecko(),
"stylo: didn't expect Loader to create a ServoStyleSheet");
RefPtr<CSSStyleSheet> cssSheet = sheet->AsGecko();
cssSheet.forget(aSheet);
@@ -331,15 +322,9 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType)
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
if (serv) {
// XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
// we'll need to include them in the notification.
if (sheet->IsGecko()) {
CSSStyleSheet* cssSheet = sheet->AsGecko();
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
message, nullptr);
} else {
NS_ERROR("stylo: can't notify observers of ServoStyleSheets");
}
CSSStyleSheet* cssSheet = sheet->AsGecko();
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
message, nullptr);
}
if (XRE_IsParentProcess()) {
+9 -18
View File
@@ -676,15 +676,10 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
// and not only those whose current style involves CSS transitions,
// because what matters is whether the new style (not the old)
// specifies CSS transitions.
if (presContext->RestyleManager()->IsGecko()) {
// stylo: ServoRestyleManager does not handle transitions yet, and when
// it does it probably won't need to track reframed style contexts to
// initiate transitions correctly.
RestyleManager::ReframingStyleContexts* rsc =
presContext->RestyleManager()->AsGecko()->GetReframingStyleContexts();
if (rsc) {
rsc->Put(mContent, mStyleContext);
}
RestyleManager::ReframingStyleContexts* rsc =
presContext->RestyleManager()->AsGecko()->GetReframingStyleContexts();
if (rsc) {
rsc->Put(mContent, mStyleContext);
}
}
@@ -692,15 +687,11 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
EffectSet::GetEffectSet(this)) {
// If no new frame for this element is created by the end of the
// restyling process, stop animations and transitions for this frame
if (presContext->RestyleManager()->IsGecko()) {
RestyleManager::AnimationsWithDestroyedFrame* adf =
presContext->RestyleManager()->AsGecko()->GetAnimationsWithDestroyedFrame();
// AnimationsWithDestroyedFrame only lives during the restyling process.
if (adf) {
adf->Put(mContent, mStyleContext);
}
} else {
NS_ERROR("stylo: ServoRestyleManager does not support animations yet");
RestyleManager::AnimationsWithDestroyedFrame* adf =
presContext->RestyleManager()->AsGecko()->GetAnimationsWithDestroyedFrame();
// AnimationsWithDestroyedFrame only lives during the restyling process.
if (adf) {
adf->Put(mContent, mStyleContext);
}
}
+8 -12
View File
@@ -96,20 +96,16 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
}
if (styleSet->IsGecko()) {
AutoTArray<CSSStyleSheet*, 32> xblSheetArray;
styleSet->AsGecko()->AppendAllXBLStyleSheets(xblSheetArray);
AutoTArray<CSSStyleSheet*, 32> xblSheetArray;
styleSet->AsGecko()->AppendAllXBLStyleSheets(xblSheetArray);
// The XBL stylesheet array will quite often be full of duplicates. Cope:
nsTHashtable<nsPtrHashKey<CSSStyleSheet>> sheetSet;
for (CSSStyleSheet* sheet : xblSheetArray) {
if (!sheetSet.Contains(sheet)) {
sheetSet.PutEntry(sheet);
sheets.AppendElement(sheet);
}
// The XBL stylesheet array will quite often be full of duplicates. Cope:
nsTHashtable<nsPtrHashKey<CSSStyleSheet>> sheetSet;
for (CSSStyleSheet* sheet : xblSheetArray) {
if (!sheetSet.Contains(sheet)) {
sheetSet.PutEntry(sheet);
sheets.AppendElement(sheet);
}
} else {
NS_WARNING("stylo: XBL style sheets not supported yet");
}
}
-4
View File
@@ -137,10 +137,6 @@ void
AnimationCollection<AnimationType>::UpdateCheckGeneration(
nsPresContext* aPresContext)
{
if (aPresContext->RestyleManager()->IsServo()) {
// stylo: ServoRestyleManager does not support animations yet.
return;
}
mCheckGeneration =
aPresContext->RestyleManager()->AsGecko()->GetAnimationGeneration();
}
-3
View File
@@ -1929,9 +1929,6 @@ CSSStyleSheet::StyleSheetLoaded(StyleSheet* aSheet,
bool aWasAlternate,
nsresult aStatus)
{
MOZ_ASSERT(aSheet->IsGecko(),
"why we were called back with a ServoStyleSheet?");
CSSStyleSheet* sheet = aSheet->AsGecko();
if (sheet->GetParentSheet() == nullptr) {
+4 -10
View File
@@ -2030,11 +2030,8 @@ CounterStyleManager::BuildCounterStyle(const nsSubstring& aName)
// but the user-defined names case-sensitive.
// XXXheycam ServoStyleSets do not support custom counter styles yet.
StyleSetHandle styleSet = mPresContext->StyleSet();
NS_ASSERTION(styleSet->IsGecko(),
"stylo: ServoStyleSets do not support custom counter "
"styles yet");
nsCSSCounterStyleRule* rule = styleSet->IsGecko() ?
styleSet->AsGecko()->CounterStyleRuleForName(aName) : nullptr;
nsCSSCounterStyleRule* rule =
styleSet->AsGecko()->CounterStyleRuleForName(aName);
if (rule) {
data = new (mPresContext) CustomCounterStyle(aName, this, rule);
} else {
@@ -2076,11 +2073,8 @@ CounterStyleManager::NotifyRuleChanged()
bool toBeRemoved = false;
// XXXheycam ServoStyleSets do not support custom counter styles yet.
StyleSetHandle styleSet = mPresContext->StyleSet();
NS_ASSERTION(styleSet->IsGecko(),
"stylo: ServoStyleSets do not support custom counter "
"styles yet");
nsCSSCounterStyleRule* newRule = styleSet->IsGecko() ?
styleSet->AsGecko()->CounterStyleRuleForName(iter.Key()) : nullptr;
nsCSSCounterStyleRule* newRule =
styleSet->AsGecko()->CounterStyleRuleForName(iter.Key());
if (!newRule) {
if (style->IsCustomStyle()) {
toBeRemoved = true;
+1 -1
View File
@@ -37,7 +37,7 @@ protected:
: DeclarationBlock(aCopy.mType) {}
public:
MOZ_DECL_STYLO_METHODS(css::Declaration, ServoDeclarationBlock)
MOZ_DECL_STYLO_METHODS(css::Declaration)
inline MozExternalRefCountType AddRef();
inline MozExternalRefCountType Release();
+14 -21
View File
@@ -7,33 +7,28 @@
#define mozilla_DeclarationBlockInlines_h
#include "mozilla/css/Declaration.h"
#include "mozilla/ServoDeclarationBlock.h"
namespace mozilla {
MOZ_DEFINE_STYLO_METHODS(DeclarationBlock, css::Declaration, ServoDeclarationBlock)
MOZ_DEFINE_STYLO_METHODS(DeclarationBlock, css::Declaration)
MozExternalRefCountType
DeclarationBlock::AddRef()
{
MOZ_STYLO_FORWARD(AddRef, ())
return AsGecko()->AddRef();
}
MozExternalRefCountType
DeclarationBlock::Release()
{
MOZ_STYLO_FORWARD(Release, ())
return AsGecko()->Release();
}
already_AddRefed<DeclarationBlock>
DeclarationBlock::Clone() const
{
RefPtr<DeclarationBlock> result;
if (IsGecko()) {
result = new css::Declaration(*AsGecko());
} else {
result = new ServoDeclarationBlock(*AsServo());
}
result = new css::Declaration(*AsGecko());
return result.forget();
}
@@ -41,9 +36,7 @@ already_AddRefed<DeclarationBlock>
DeclarationBlock::EnsureMutable()
{
#ifdef DEBUG
if (IsGecko()) {
AsGecko()->AssertNotExpanded();
}
AsGecko()->AssertNotExpanded();
#endif
if (!IsMutable()) {
return Clone();
@@ -54,58 +47,58 @@ DeclarationBlock::EnsureMutable()
void
DeclarationBlock::ToString(nsAString& aString) const
{
MOZ_STYLO_FORWARD(ToString, (aString))
AsGecko()->ToString(aString);
}
uint32_t
DeclarationBlock::Count() const
{
MOZ_STYLO_FORWARD(Count, ())
return AsGecko()->Count();
}
bool
DeclarationBlock::GetNthProperty(uint32_t aIndex, nsAString& aReturn) const
{
MOZ_STYLO_FORWARD(GetNthProperty, (aIndex, aReturn))
return AsGecko()->GetNthProperty(aIndex, aReturn);
}
void
DeclarationBlock::GetPropertyValue(const nsAString& aProperty,
nsAString& aValue) const
{
MOZ_STYLO_FORWARD(GetPropertyValue, (aProperty, aValue))
AsGecko()->GetPropertyValue(aProperty, aValue);
}
void
DeclarationBlock::GetPropertyValueByID(nsCSSPropertyID aPropID,
nsAString& aValue) const
{
MOZ_STYLO_FORWARD(GetPropertyValueByID, (aPropID, aValue))
AsGecko()->GetPropertyValueByID(aPropID, aValue);
}
void
DeclarationBlock::GetAuthoredPropertyValue(const nsAString& aProperty,
nsAString& aValue) const
{
MOZ_STYLO_FORWARD(GetAuthoredPropertyValue, (aProperty, aValue))
AsGecko()->GetAuthoredPropertyValue(aProperty, aValue);
}
bool
DeclarationBlock::GetPropertyIsImportant(const nsAString& aProperty) const
{
MOZ_STYLO_FORWARD(GetPropertyIsImportant, (aProperty))
return AsGecko()->GetPropertyIsImportant(aProperty);
}
void
DeclarationBlock::RemoveProperty(const nsAString& aProperty)
{
MOZ_STYLO_FORWARD(RemoveProperty, (aProperty))
AsGecko()->RemoveProperty(aProperty);
}
void
DeclarationBlock::RemovePropertyByID(nsCSSPropertyID aProperty)
{
MOZ_STYLO_FORWARD(RemovePropertyByID, (aProperty))
AsGecko()->RemovePropertyByID(aProperty);
}
} // namespace mozilla
+38 -83
View File
@@ -1130,10 +1130,6 @@ Loader::CreateSheet(nsIURI* aURI,
}
if (sheet) {
if (sheet->IsServo()) {
MOZ_CRASH("stylo: can't clone ServoStyleSheets yet");
}
// This sheet came from the XUL cache or our per-document hashtable; it
// better be a complete sheet.
NS_ASSERTION(sheet->AsGecko()->IsComplete(),
@@ -1193,9 +1189,6 @@ Loader::CreateSheet(nsIURI* aURI,
if (sheet) {
// The sheet we have now should be either incomplete or unmodified
if (sheet->IsServo()) {
MOZ_CRASH("stylo: can't clone ServoStyleSheets yet");
}
NS_ASSERTION(!sheet->AsGecko()->IsModified() ||
!sheet->AsGecko()->IsComplete(),
"Unexpected modified complete sheet");
@@ -1252,11 +1245,7 @@ Loader::CreateSheet(nsIURI* aURI,
&sriMetadata);
}
if (GetStyleBackendType() == StyleBackendType::Gecko) {
*aSheet = new CSSStyleSheet(aParsingMode, aCORSMode, aReferrerPolicy, sriMetadata);
} else {
*aSheet = new ServoStyleSheet(aParsingMode, aCORSMode, aReferrerPolicy, sriMetadata);
}
*aSheet = new CSSStyleSheet(aParsingMode, aCORSMode, aReferrerPolicy, sriMetadata);
(*aSheet)->SetURIs(sheetURI, originalURI, baseURI);
}
@@ -1283,12 +1272,6 @@ Loader::PrepareSheet(StyleSheet* aSheet,
{
NS_PRECONDITION(aSheet, "Must have a sheet!");
// XXXheycam Need to set media, title, etc. on ServoStyleSheets.
if (aSheet->IsServo()) {
NS_WARNING("stylo: should set metadata on ServoStyleSheets. See bug 1290209.");
return;
}
CSSStyleSheet* sheet = aSheet->AsGecko();
RefPtr<nsMediaList> mediaList(aMediaList);
@@ -1414,12 +1397,6 @@ Loader::InsertChildSheet(StyleSheet* aSheet,
NS_PRECONDITION(aParentSheet, "Need a parent to insert into");
NS_PRECONDITION(aParentSheet, "How did we get imported?");
// XXXheycam The InsertChildSheet API doesn't work with ServoStyleSheets,
// since they won't have Gecko ImportRules in them.
if (aSheet->IsServo()) {
return NS_ERROR_FAILURE;
}
// child sheets should always start out enabled, even if they got
// cloned off of top-level sheets which were disabled
aSheet->AsGecko()->SetEnabled(true);
@@ -1766,17 +1743,10 @@ Loader::ParseSheet(const nsAString& aInput,
nsresult rv;
if (aLoadData->mSheet->IsGecko()) {
nsCSSParser parser(this, aLoadData->mSheet->AsGecko());
rv = parser.ParseSheet(aInput, sheetURI, baseURI,
aLoadData->mSheet->Principal(),
aLoadData->mLineNumber);
} else {
rv =
aLoadData->mSheet->AsServo()->ParseSheet(aInput, sheetURI, baseURI,
aLoadData->mSheet->Principal(),
aLoadData->mLineNumber);
}
nsCSSParser parser(this, aLoadData->mSheet->AsGecko());
rv = parser.ParseSheet(aInput, sheetURI, baseURI,
aLoadData->mSheet->Principal(),
aLoadData->mLineNumber);
mParsingDatas.RemoveElementAt(mParsingDatas.Length() - 1);
@@ -1813,10 +1783,6 @@ Loader::SheetComplete(SheetLoadData* aLoadData, nsresult aStatus)
{
LOG(("css::Loader::SheetComplete"));
if (aLoadData->mSheet->IsServo() && NS_FAILED(aStatus)) {
aLoadData->mSheet->AsServo()->LoadFailed();
}
// 8 is probably big enough for all our common cases. It's not likely that
// imports will nest more than 8 deep, and multiple sheets with the same URI
// are rare.
@@ -1893,8 +1859,7 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
// If mSheetAlreadyComplete, then the sheet could well be modified between
// when we posted the async call to SheetComplete and now, since the sheet
// was page-accessible during that whole time.
MOZ_ASSERT(!(data->mSheet->IsGecko() &&
data->mSheet->AsGecko()->IsModified()),
MOZ_ASSERT(!data->mSheet->AsGecko()->IsModified(),
"should not get marked modified during parsing");
data->mSheet->SetComplete();
data->ScheduleLoadEventIfNeeded(aStatus);
@@ -1935,43 +1900,38 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
// one of the sheets that will be kept alive by a document or
// parent sheet anyway, so that if someone then accesses it via
// CSSOM we won't have extra clones of the inner lying around.
if (aLoadData->mSheet->IsGecko()) {
data = aLoadData;
CSSStyleSheet* sheet = aLoadData->mSheet->AsGecko();
while (data) {
if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
sheet = data->mSheet->AsGecko();
break;
}
data = data->mNext;
data = aLoadData;
CSSStyleSheet* sheet = aLoadData->mSheet->AsGecko();
while (data) {
if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
sheet = data->mSheet->AsGecko();
break;
}
#ifdef MOZ_XUL
if (IsChromeURI(aLoadData->mURI)) {
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
if (cache && cache->IsEnabled()) {
if (!cache->GetStyleSheet(aLoadData->mURI)) {
LOG((" Putting sheet in XUL prototype cache"));
NS_ASSERTION(sheet->IsComplete(),
"Should only be caching complete sheets");
cache->PutStyleSheet(sheet);
}
}
}
else {
#endif
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
aLoadData->mLoaderPrincipal,
aLoadData->mSheet->GetCORSMode(),
aLoadData->mSheet->GetReferrerPolicy());
NS_ASSERTION(sheet->IsComplete(),
"Should only be caching complete sheets");
mSheets->mCompleteSheets.Put(&key, sheet);
#ifdef MOZ_XUL
}
#endif
} else {
NS_WARNING("stylo: Stylesheet caching not yet supported - see bug 1290218.");
data = data->mNext;
}
#ifdef MOZ_XUL
if (IsChromeURI(aLoadData->mURI)) {
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
if (cache && cache->IsEnabled()) {
if (!cache->GetStyleSheet(aLoadData->mURI)) {
LOG((" Putting sheet in XUL prototype cache"));
NS_ASSERTION(sheet->IsComplete(),
"Should only be caching complete sheets");
cache->PutStyleSheet(sheet);
}
}
} else {
#endif
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
aLoadData->mLoaderPrincipal,
aLoadData->mSheet->GetCORSMode(),
aLoadData->mSheet->GetReferrerPolicy());
NS_ASSERTION(sheet->IsComplete(),
"Should only be caching complete sheets");
mSheets->mCompleteSheets.Put(&key, sheet);
#ifdef MOZ_XUL
}
#endif
}
NS_RELEASE(aLoadData); // this will release parents and siblings and all that
@@ -2258,9 +2218,6 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet,
LOG((" No parent load; must be CSSOM"));
// No parent load data, so the sheet will need to be notified when
// we finish, if it can be, if we do the load asynchronously.
// XXXheycam ServoStyleSheet doesn't implement nsICSSLoaderObserver yet.
MOZ_ASSERT(aParentSheet->IsGecko(),
"stylo: ServoStyleSheets don't support child sheet loading yet");
observer = aParentSheet->AsGecko();
}
@@ -2628,10 +2585,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Loader)
!iter.Done();
iter.Next()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "Sheet cache nsCSSLoader");
if (iter.UserData()->IsGecko()) {
CSSStyleSheet* sheet = iter.UserData()->AsGecko();
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet));
}
CSSStyleSheet* sheet = iter.UserData()->AsGecko();
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet));
}
}
nsTObserverArray<nsCOMPtr<nsICSSLoaderObserver>>::ForwardIterator
+3 -44
View File
@@ -10,66 +10,25 @@
#include "mozilla/TypeTraits.h"
# define MOZ_DECL_STYLO_CHECK_METHODS \
bool IsGecko() const { return true; } \
bool IsServo() const { return false; }
/**
* Macro used in a base class of |geckotype_| and |servotype_|.
* The class should define |StyleBackendType mType;| itself.
*/
#define MOZ_DECL_STYLO_METHODS(geckotype_, servotype_) \
MOZ_DECL_STYLO_CHECK_METHODS \
#define MOZ_DECL_STYLO_METHODS(geckotype_) \
inline geckotype_* AsGecko(); \
inline servotype_* AsServo(); \
inline const geckotype_* AsGecko() const; \
inline const servotype_* AsServo() const;
inline const geckotype_* AsGecko() const;
/**
* Macro used in inline header of class |type_| with its Gecko and Servo
* subclasses named |geckotype_| and |servotype_| correspondingly for
* implementing the inline methods defined by MOZ_DECL_STYLO_METHODS.
*/
#define MOZ_DEFINE_STYLO_METHODS(type_, geckotype_, servotype_) \
#define MOZ_DEFINE_STYLO_METHODS(type_, geckotype_) \
geckotype_* type_::AsGecko() { \
MOZ_ASSERT(IsGecko()); \
return static_cast<geckotype_*>(this); \
} \
servotype_* type_::AsServo() { \
MOZ_ASSERT(IsServo()); \
return static_cast<servotype_*>(this); \
} \
const geckotype_* type_::AsGecko() const { \
MOZ_ASSERT(IsGecko()); \
return static_cast<const geckotype_*>(this); \
} \
const servotype_* type_::AsServo() const { \
MOZ_ASSERT(IsServo()); \
return static_cast<const servotype_*>(this); \
}
#define MOZ_STYLO_THIS_TYPE mozilla::RemovePointer<decltype(this)>::Type
#define MOZ_STYLO_GECKO_TYPE mozilla::RemovePointer<decltype(AsGecko())>::Type
#define MOZ_STYLO_SERVO_TYPE mozilla::RemovePointer<decltype(AsServo())>::Type
/**
* Macro used to forward a method call to the concrete method defined by
* the Servo or Gecko implementation. The class of the method using it
* should use MOZ_DECL_STYLO_METHODS to define basic stylo methods.
*/
#define MOZ_STYLO_FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \
static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::method_), \
decltype(&MOZ_STYLO_GECKO_TYPE::method_)> \
::value, "Gecko subclass should define its own " #method_); \
static_assert(!mozilla::IsSame<decltype(&MOZ_STYLO_THIS_TYPE::method_), \
decltype(&MOZ_STYLO_SERVO_TYPE::method_)> \
::value, "Servo subclass should define its own " #method_); \
if (IsServo()) { \
return AsServo()->method_ servoargs_; \
} \
return AsGecko()->method_ geckoargs_;
#define MOZ_STYLO_FORWARD(method_, args_) \
MOZ_STYLO_FORWARD_CONCRETE(method_, args_, args_)
#endif // mozilla_ServoUtils_h
-42
View File
@@ -26,7 +26,6 @@
#include "mozilla/dom/Element.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Likely.h"
#include "mozilla/ServoBindings.h" // RawServoDeclarationBlock
#include "gfxMatrix.h"
#include "gfxQuaternion.h"
#include "nsIDocument.h"
@@ -3262,8 +3261,6 @@ ComputeValuesFromStyleRule(nsCSSPropertyID aProperty,
return false;
}
MOZ_ASSERT(aStyleContext->PresContext()->StyleSet()->IsGecko(),
"ServoStyleSet should not use StyleAnimationValue for animations");
nsStyleSet* styleSet = aStyleContext->PresContext()->StyleSet()->AsGecko();
RefPtr<nsStyleContext> tmpStyleContext;
@@ -3426,45 +3423,6 @@ StyleAnimationValue::ComputeValues(
aResult);
}
/* static */ bool
StyleAnimationValue::ComputeValues(
nsCSSPropertyID aProperty,
CSSEnabledState aEnabledState,
nsStyleContext* aStyleContext,
const RawServoDeclarationBlock& aDeclarations,
nsTArray<PropertyStyleAnimationValuePair>& aValues)
{
MOZ_ASSERT(aStyleContext->PresContext()->StyleSet()->IsServo(),
"Should be using ServoStyleSet if we have a"
" RawServoDeclarationBlock");
if (!nsCSSProps::IsEnabled(aProperty, aEnabledState)) {
return false;
}
const ServoComputedValues* previousStyle =
aStyleContext->StyleSource().AsServoComputedValues();
// FIXME: Servo bindings don't yet represent const-ness so we just
// cast it away for now.
auto declarations = const_cast<RawServoDeclarationBlock*>(&aDeclarations);
RefPtr<ServoComputedValues> computedValues =
Servo_RestyleWithAddedDeclaration(declarations, previousStyle).Consume();
if (!computedValues) {
return false;
}
RefPtr<nsStyleContext> tmpStyleContext =
NS_NewStyleContext(aStyleContext, aStyleContext->PresContext(),
aStyleContext->GetPseudo(),
aStyleContext->GetPseudoType(),
computedValues.forget(),
false /* skipFixup */);
return ComputeValuesFromStyleContext(aProperty, aEnabledState,
tmpStyleContext, aValues);
}
bool
StyleAnimationValue::UncomputeValue(nsCSSPropertyID aProperty,
const StyleAnimationValue& aComputedValue,
-12
View File
@@ -21,7 +21,6 @@
class nsIFrame;
class nsStyleContext;
class gfx3DMatrix;
struct RawServoDeclarationBlock;
namespace mozilla {
@@ -240,17 +239,6 @@ public:
bool aUseSVGMode,
nsTArray<PropertyStyleAnimationValuePair>& aResult);
/**
* A variant of ComputeValues that takes a RawServoDeclarationBlock
* as the specified value.
*/
static MOZ_MUST_USE bool
ComputeValues(nsCSSPropertyID aProperty,
mozilla::CSSEnabledState aEnabledState,
nsStyleContext* aStyleContext,
const RawServoDeclarationBlock& aDeclarations,
nsTArray<PropertyStyleAnimationValuePair>& aValues);
/**
* Creates a specified value for the given computed value.
*
+3 -47
View File
@@ -33,53 +33,21 @@ struct NonOwningStyleContextSource
: mBits(reinterpret_cast<uintptr_t>(aComputedValues) | 1) {}
bool operator==(const NonOwningStyleContextSource& aOther) const {
MOZ_ASSERT(IsServoComputedValues() == aOther.IsServoComputedValues(),
"Comparing Servo to Gecko - probably a bug");
// TODO: remove this servo-specific function.
return mBits == aOther.mBits;
}
bool operator!=(const NonOwningStyleContextSource& aOther) const {
return !(*this == aOther);
}
// We intentionally avoid exposing IsGeckoRuleNode() here, because that would
// encourage callers to do:
//
// if (source.IsGeckoRuleNode()) {
// // Code that we would run unconditionally if it weren't for Servo.
// }
//
// We want these branches to compile away when MOZ_STYLO is disabled, but that
// won't happen if there's an implicit null-check.
bool IsNull() const { return !mBits; }
bool IsGeckoRuleNodeOrNull() const { return !IsServoComputedValues(); }
bool IsServoComputedValues() const {
return false;
}
nsRuleNode* AsGeckoRuleNode() const {
MOZ_ASSERT(IsGeckoRuleNodeOrNull() && !IsNull());
return reinterpret_cast<nsRuleNode*>(mBits);
}
const ServoComputedValues* AsServoComputedValues() const {
MOZ_ASSERT(IsServoComputedValues());
return reinterpret_cast<ServoComputedValues*>(mBits & ~1);
}
bool MatchesNoRules() const {
if (IsGeckoRuleNodeOrNull()) {
return AsGeckoRuleNode()->IsRoot();
}
// Just assume a Servo-backed StyleContextSource always matches some rules.
//
// MatchesNoRules is used to ensure style contexts that match no rules
// go into a separate mEmptyChild list on their parent. This is only used
// as an optimization so that calling FindChildWithRules for style context
// sharing is faster for text nodes (which match no rules, and are common).
// Since Servo will handle sharing for us, there's no need to split children
// into two lists.
return false;
return AsGeckoRuleNode()->IsRoot();
}
private:
@@ -118,12 +86,8 @@ struct OwningStyleContextSource
MOZ_COUNT_DTOR(OwningStyleContextSource);
if (mRaw.IsNull()) {
// We must have invoked the move constructor.
} else if (IsGeckoRuleNode()) {
RefPtr<nsRuleNode> releaseme = dont_AddRef(AsGeckoRuleNode());
} else {
MOZ_ASSERT(IsServoComputedValues());
RefPtr<ServoComputedValues> releaseme =
dont_AddRef(AsServoComputedValues());
RefPtr<nsRuleNode> releaseme = dont_AddRef(AsGeckoRuleNode());
}
}
@@ -134,17 +98,9 @@ struct OwningStyleContextSource
return !(*this == aOther);
}
bool IsNull() const { return mRaw.IsNull(); }
bool IsGeckoRuleNode() const {
MOZ_ASSERT(!mRaw.IsNull());
return mRaw.IsGeckoRuleNodeOrNull();
}
bool IsServoComputedValues() const { return mRaw.IsServoComputedValues(); }
NonOwningStyleContextSource AsRaw() const { return mRaw; }
nsRuleNode* AsGeckoRuleNode() const { return mRaw.AsGeckoRuleNode(); }
ServoComputedValues* AsServoComputedValues() const {
return const_cast<ServoComputedValues*>(mRaw.AsServoComputedValues());
}
bool MatchesNoRules() const { return mRaw.MatchesNoRules(); }
+7 -45
View File
@@ -17,7 +17,6 @@
namespace mozilla {
class CSSStyleSheet;
class ServoStyleSet;
namespace dom {
class Element;
} // namespace dom
@@ -32,11 +31,8 @@ struct TreeMatchContext;
namespace mozilla {
#define SERVO_BIT 0x1
/**
* Smart pointer class that can hold a pointer to either an nsStyleSet
* or a ServoStyleSet.
* Smart pointer class that can hold a pointer to an nsStyleSet.
*/
class StyleSetHandle
{
@@ -50,55 +46,32 @@ public:
public:
friend class ::mozilla::StyleSetHandle;
bool IsGecko() const { return !IsServo(); }
bool IsServo() const
{
MOZ_ASSERT(mValue, "StyleSetHandle null pointer dereference");
return false;
}
StyleBackendType BackendType() const
{
return IsGecko() ? StyleBackendType::Gecko :
StyleBackendType::Servo;
return StyleBackendType::Gecko;
}
nsStyleSet* AsGecko()
{
MOZ_ASSERT(IsGecko());
return reinterpret_cast<nsStyleSet*>(mValue);
}
ServoStyleSet* AsServo()
{
MOZ_ASSERT(IsServo());
return reinterpret_cast<ServoStyleSet*>(mValue & ~SERVO_BIT);
}
nsStyleSet* GetAsGecko() { return IsGecko() ? AsGecko() : nullptr; }
ServoStyleSet* GetAsServo() { return IsServo() ? AsServo() : nullptr; }
nsStyleSet* GetAsGecko() { return AsGecko(); }
const nsStyleSet* AsGecko() const
{
return const_cast<Ptr*>(this)->AsGecko();
}
const ServoStyleSet* AsServo() const
{
MOZ_ASSERT(IsServo());
return const_cast<Ptr*>(this)->AsServo();
}
const nsStyleSet* GetAsGecko() const { return IsGecko() ? AsGecko() : nullptr; }
const ServoStyleSet* GetAsServo() const { return IsServo() ? AsServo() : nullptr; }
const nsStyleSet* GetAsGecko() const { return AsGecko(); }
// These inline methods are defined in StyleSetHandleInlines.h.
inline void Delete();
// Style set interface. These inline methods are defined in
// StyleSetHandleInlines.h and just forward to the underlying
// nsStyleSet or ServoStyleSet. See corresponding comments in
// nsStyleSet.h for descriptions of these methods.
// nsStyleSet. See corresponding comments in nsStyleSet.h for
// descriptions of these methods.
inline void Init(nsPresContext* aPresContext);
inline void BeginShutdown();
@@ -161,7 +134,7 @@ public:
inline void RootStyleContextRemoved();
private:
// Stores a pointer to an nsStyleSet or a ServoStyleSet. The least
// Stores a pointer to an nsStyleSet. The least
// significant bit is 0 for the former, 1 for the latter. This is
// valid as the least significant bit will never be used for a pointer
// value on platforms we care about.
@@ -171,22 +144,13 @@ public:
StyleSetHandle() { mPtr.mValue = 0; }
StyleSetHandle(const StyleSetHandle& aOth) { mPtr.mValue = aOth.mPtr.mValue; }
MOZ_IMPLICIT StyleSetHandle(nsStyleSet* aSet) { *this = aSet; }
MOZ_IMPLICIT StyleSetHandle(ServoStyleSet* aSet) { *this = aSet; }
StyleSetHandle& operator=(nsStyleSet* aStyleSet)
{
MOZ_ASSERT(!(reinterpret_cast<uintptr_t>(aStyleSet) & SERVO_BIT),
"least significant bit shouldn't be set; we use it for state");
mPtr.mValue = reinterpret_cast<uintptr_t>(aStyleSet);
return *this;
}
StyleSetHandle& operator=(ServoStyleSet* aStyleSet)
{
MOZ_CRASH("should not have a ServoStyleSet object when MOZ_STYLO is "
"disabled");
}
// Make StyleSetHandle usable in boolean contexts.
explicit operator bool() const { return !!mPtr.mValue; }
bool operator!() const { return !mPtr.mValue; }
@@ -199,8 +163,6 @@ private:
Ptr mPtr;
};
#undef SERVO_BIT
} // namespace mozilla
#endif // mozilla_StyleSetHandle_h
+35 -75
View File
@@ -7,72 +7,58 @@
#define mozilla_StyleSetHandleInlines_h
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/ServoStyleSet.h"
#include "nsStyleSet.h"
#define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \
if (IsGecko()) { \
return AsGecko()->method_ geckoargs_; \
} else { \
return AsServo()->method_ servoargs_; \
}
#define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_)
namespace mozilla {
void
StyleSetHandle::Ptr::Delete()
{
if (mValue) {
if (IsGecko()) {
delete AsGecko();
} else {
delete AsServo();
}
delete AsGecko();
}
}
void
StyleSetHandle::Ptr::Init(nsPresContext* aPresContext)
{
FORWARD(Init, (aPresContext));
AsGecko()->Init(aPresContext);
}
void
StyleSetHandle::Ptr::BeginShutdown()
{
FORWARD(BeginShutdown, ());
AsGecko()->BeginShutdown();
}
void
StyleSetHandle::Ptr::Shutdown()
{
FORWARD(Shutdown, ());
AsGecko()->Shutdown();
}
bool
StyleSetHandle::Ptr::GetAuthorStyleDisabled() const
{
FORWARD(GetAuthorStyleDisabled, ());
return AsGecko()->GetAuthorStyleDisabled();
}
nsresult
StyleSetHandle::Ptr::SetAuthorStyleDisabled(bool aStyleDisabled)
{
FORWARD(SetAuthorStyleDisabled, (aStyleDisabled));
return AsGecko()->SetAuthorStyleDisabled(aStyleDisabled);
}
void
StyleSetHandle::Ptr::BeginUpdate()
{
FORWARD(BeginUpdate, ());
AsGecko()->BeginUpdate();
}
nsresult
StyleSetHandle::Ptr::EndUpdate()
{
FORWARD(EndUpdate, ());
return AsGecko()->EndUpdate();
}
// resolve a style context
@@ -80,7 +66,7 @@ already_AddRefed<nsStyleContext>
StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement,
nsStyleContext* aParentContext)
{
FORWARD(ResolveStyleFor, (aElement, aParentContext));
return AsGecko()->ResolveStyleFor(aElement, aParentContext);
}
already_AddRefed<nsStyleContext>
@@ -88,20 +74,20 @@ StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement,
nsStyleContext* aParentContext,
TreeMatchContext& aTreeMatchContext)
{
FORWARD(ResolveStyleFor, (aElement, aParentContext, aTreeMatchContext));
return AsGecko()->ResolveStyleFor(aElement, aParentContext, aTreeMatchContext);
}
already_AddRefed<nsStyleContext>
StyleSetHandle::Ptr::ResolveStyleForText(nsIContent* aTextNode,
nsStyleContext* aParentContext)
{
FORWARD(ResolveStyleForText, (aTextNode, aParentContext));
return AsGecko()->ResolveStyleForText(aTextNode, aParentContext);
}
already_AddRefed<nsStyleContext>
StyleSetHandle::Ptr::ResolveStyleForOtherNonElement(nsStyleContext* aParentContext)
{
FORWARD(ResolveStyleForOtherNonElement, (aParentContext));
return AsGecko()->ResolveStyleForOtherNonElement(aParentContext);
}
already_AddRefed<nsStyleContext>
@@ -110,8 +96,8 @@ StyleSetHandle::Ptr::ResolvePseudoElementStyle(dom::Element* aParentElement,
nsStyleContext* aParentContext,
dom::Element* aPseudoElement)
{
FORWARD(ResolvePseudoElementStyle, (aParentElement, aType, aParentContext,
aPseudoElement));
return AsGecko()->ResolvePseudoElementStyle(
aParentElement, aType, aParentContext, aPseudoElement);
}
// aFlags is an nsStyleSet flags bitfield
@@ -120,48 +106,37 @@ StyleSetHandle::Ptr::ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag,
nsStyleContext* aParentContext,
uint32_t aFlags)
{
FORWARD(ResolveAnonymousBoxStyle, (aPseudoTag, aParentContext, aFlags));
return AsGecko()->ResolveAnonymousBoxStyle(aPseudoTag, aParentContext, aFlags);
}
// manage the set of style sheets in the style set
nsresult
StyleSetHandle::Ptr::AppendStyleSheet(SheetType aType, StyleSheet* aSheet)
{
FORWARD_CONCRETE(AppendStyleSheet, (aType, aSheet->AsGecko()),
(aType, aSheet->AsServo()));
return AsGecko()->AppendStyleSheet(aType, aSheet->AsGecko());
}
nsresult
StyleSetHandle::Ptr::PrependStyleSheet(SheetType aType, StyleSheet* aSheet)
{
FORWARD_CONCRETE(PrependStyleSheet, (aType, aSheet->AsGecko()),
(aType, aSheet->AsServo()));
return AsGecko()->PrependStyleSheet(aType, aSheet->AsGecko());
}
nsresult
StyleSetHandle::Ptr::RemoveStyleSheet(SheetType aType, StyleSheet* aSheet)
{
FORWARD_CONCRETE(RemoveStyleSheet, (aType, aSheet->AsGecko()),
(aType, aSheet->AsServo()));
return AsGecko()->RemoveStyleSheet(aType, aSheet->AsGecko());
}
nsresult
StyleSetHandle::Ptr::ReplaceSheets(SheetType aType,
const nsTArray<RefPtr<StyleSheet>>& aNewSheets)
{
if (IsGecko()) {
nsTArray<RefPtr<CSSStyleSheet>> newSheets(aNewSheets.Length());
for (auto& sheet : aNewSheets) {
newSheets.AppendElement(sheet->AsGecko());
}
return AsGecko()->ReplaceSheets(aType, newSheets);
} else {
nsTArray<RefPtr<ServoStyleSheet>> newSheets(aNewSheets.Length());
for (auto& sheet : aNewSheets) {
newSheets.AppendElement(sheet->AsServo());
}
return AsServo()->ReplaceSheets(aType, newSheets);
nsTArray<RefPtr<CSSStyleSheet>> newSheets(aNewSheets.Length());
for (auto& sheet : aNewSheets) {
newSheets.AppendElement(sheet->AsGecko());
}
return AsGecko()->ReplaceSheets(aType, newSheets);
}
nsresult
@@ -169,37 +144,33 @@ StyleSetHandle::Ptr::InsertStyleSheetBefore(SheetType aType,
StyleSheet* aNewSheet,
StyleSheet* aReferenceSheet)
{
FORWARD_CONCRETE(
InsertStyleSheetBefore,
(aType, aNewSheet->AsGecko(), aReferenceSheet->AsGecko()),
(aType, aReferenceSheet->AsServo(), aReferenceSheet->AsServo()));
return AsGecko()->InsertStyleSheetBefore(
aType, aNewSheet->AsGecko(), aReferenceSheet->AsGecko());
}
int32_t
StyleSetHandle::Ptr::SheetCount(SheetType aType) const
{
FORWARD(SheetCount, (aType));
return AsGecko()->SheetCount(aType);
}
StyleSheet*
StyleSetHandle::Ptr::StyleSheetAt(SheetType aType, int32_t aIndex) const
{
FORWARD(StyleSheetAt, (aType, aIndex));
return AsGecko()->StyleSheetAt(aType, aIndex);
}
nsresult
StyleSetHandle::Ptr::RemoveDocStyleSheet(StyleSheet* aSheet)
{
FORWARD_CONCRETE(RemoveDocStyleSheet, (aSheet->AsGecko()),
(aSheet->AsServo()));
return AsGecko()->RemoveDocStyleSheet(aSheet->AsGecko());
}
nsresult
StyleSetHandle::Ptr::AddDocStyleSheet(StyleSheet* aSheet,
nsIDocument* aDocument)
{
FORWARD_CONCRETE(AddDocStyleSheet, (aSheet->AsGecko(), aDocument),
(aSheet->AsServo(), aDocument));
return AsGecko()->AddDocStyleSheet(aSheet->AsGecko(), aDocument);
}
// check whether there is ::before/::after style for an element
@@ -208,7 +179,7 @@ StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement,
CSSPseudoElementType aType,
nsStyleContext* aParentContext)
{
FORWARD(ProbePseudoElementStyle, (aParentElement, aType, aParentContext));
return AsGecko()->ProbePseudoElementStyle(aParentElement, aType, aParentContext);
}
already_AddRefed<nsStyleContext>
@@ -218,15 +189,15 @@ StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement,
TreeMatchContext& aTreeMatchContext,
dom::Element* aPseudoElement)
{
FORWARD(ProbePseudoElementStyle, (aParentElement, aType, aParentContext,
aTreeMatchContext, aPseudoElement));
return AsGecko()->ProbePseudoElementStyle(
aParentElement, aType, aParentContext, aTreeMatchContext, aPseudoElement);
}
nsRestyleHint
StyleSetHandle::Ptr::HasStateDependentStyle(dom::Element* aElement,
EventStates aStateMask)
{
FORWARD(HasStateDependentStyle, (aElement, aStateMask));
return AsGecko()->HasStateDependentStyle(aElement, aStateMask);
}
nsRestyleHint
@@ -235,32 +206,21 @@ StyleSetHandle::Ptr::HasStateDependentStyle(dom::Element* aElement,
dom::Element* aPseudoElement,
EventStates aStateMask)
{
FORWARD(HasStateDependentStyle, (aElement, aPseudoType, aPseudoElement,
aStateMask));
return AsGecko()->HasStateDependentStyle(aElement, aPseudoType, aPseudoElement, aStateMask);
}
void
StyleSetHandle::Ptr::RootStyleContextAdded()
{
if (IsGecko()) {
AsGecko()->RootStyleContextAdded();
} else {
// Not needed.
}
AsGecko()->RootStyleContextAdded();
}
void
StyleSetHandle::Ptr::RootStyleContextRemoved()
{
if (IsGecko()) {
RootStyleContextAdded();
} else {
// Not needed.
}
RootStyleContextAdded();
}
} // namespace mozilla
#undef FORWARD
#endif // mozilla_StyleSetHandleInlines_h
+6 -18
View File
@@ -82,7 +82,7 @@ StyleSheet::IsComplete() const
void
StyleSheet::SetComplete()
{
NS_ASSERTION(!IsGecko() || !AsGecko()->mDirty,
NS_ASSERTION(!AsGecko()->mDirty,
"Can't set a dirty sheet complete!");
SheetInfo().mComplete = true;
if (mDocument && !mDisabled) {
@@ -138,11 +138,7 @@ StyleSheet::SetDisabled(bool aDisabled)
{
// DOM method, so handle BeginUpdate/EndUpdate
MOZ_AUTO_DOC_UPDATE(mDocument, UPDATE_STYLE, true);
if (IsGecko()) {
AsGecko()->SetEnabled(!aDisabled);
} else {
MOZ_CRASH("stylo: unimplemented SetEnabled");
}
AsGecko()->SetEnabled(!aDisabled);
return NS_OK;
}
@@ -229,12 +225,6 @@ StyleSheet::DeleteRule(uint32_t aIndex)
// WebIDL CSSStyleSheet API
#define FORWARD_INTERNAL(method_, args_) \
if (IsServo()) { \
return AsServo()->method_ args_; \
} \
return AsGecko()->method_ args_;
dom::CSSRuleList*
StyleSheet::GetCssRules(nsIPrincipal& aSubjectPrincipal,
ErrorResult& aRv)
@@ -242,7 +232,7 @@ StyleSheet::GetCssRules(nsIPrincipal& aSubjectPrincipal,
if (!AreRulesAvailable(aSubjectPrincipal, aRv)) {
return nullptr;
}
FORWARD_INTERNAL(GetCssRulesInternal, (aRv))
return AsGecko()->GetCssRulesInternal(aRv);
}
uint32_t
@@ -253,7 +243,7 @@ StyleSheet::InsertRule(const nsAString& aRule, uint32_t aIndex,
if (!AreRulesAvailable(aSubjectPrincipal, aRv)) {
return 0;
}
FORWARD_INTERNAL(InsertRuleInternal, (aRule, aIndex, aRv))
return AsGecko()->InsertRuleInternal(aRule, aIndex, aRv);
}
void
@@ -264,7 +254,7 @@ StyleSheet::DeleteRule(uint32_t aIndex,
if (!AreRulesAvailable(aSubjectPrincipal, aRv)) {
return;
}
FORWARD_INTERNAL(DeleteRuleInternal, (aIndex, aRv))
AsGecko()->DeleteRuleInternal(aIndex, aRv);
}
int32_t
@@ -288,13 +278,11 @@ StyleSheet::AddRule(const nsAString& aSelector, const nsAString& aBlock,
auto index =
aIndex.WasPassed() ? aIndex.Value() : GetCssRules(aSubjectPrincipal, aRv)->Length();
FORWARD_INTERNAL(InsertRuleInternal, (rule, index, aRv));
return AsGecko()->InsertRuleInternal(rule, index, aRv);
// As per Microsoft documentation, always return -1.
return -1;
}
#undef FORWARD_INTERNAL
void
StyleSheet::SubjectSubsumesInnerPrincipal(nsIPrincipal& aSubjectPrincipal,
ErrorResult& aRv)
+1 -1
View File
@@ -66,7 +66,7 @@ public:
bool IsComplete() const;
void SetComplete();
MOZ_DECL_STYLO_METHODS(CSSStyleSheet, ServoStyleSheet)
MOZ_DECL_STYLO_METHODS(CSSStyleSheet)
// Whether the sheet is for an inline <style> element.
inline bool IsInline() const;
+10 -18
View File
@@ -7,28 +7,21 @@
#define mozilla_StyleSheetInlines_h
#include "mozilla/StyleSheetInfo.h"
#include "mozilla/ServoStyleSheet.h"
#include "mozilla/CSSStyleSheet.h"
namespace mozilla {
MOZ_DEFINE_STYLO_METHODS(StyleSheet, CSSStyleSheet, ServoStyleSheet)
MOZ_DEFINE_STYLO_METHODS(StyleSheet, CSSStyleSheet)
StyleSheetInfo&
StyleSheet::SheetInfo()
{
if (IsServo()) {
return AsServo()->mSheetInfo;
}
return *AsGecko()->mInner;
}
const StyleSheetInfo&
StyleSheet::SheetInfo() const
{
if (IsServo()) {
return AsServo()->mSheetInfo;
}
return *AsGecko()->mInner;
}
@@ -78,7 +71,7 @@ StyleSheet::IsApplicable() const
bool
StyleSheet::HasRules() const
{
MOZ_STYLO_FORWARD(HasRules, ())
return AsGecko()->HasRules();
}
void
@@ -86,19 +79,19 @@ StyleSheet::SetAssociatedDocument(nsIDocument* aDocument,
DocumentAssociationMode aAssociationMode)
{
MOZ_ASSERT(aDocument);
MOZ_STYLO_FORWARD(SetAssociatedDocument, (aDocument, aAssociationMode))
AsGecko()->SetAssociatedDocument(aDocument, aAssociationMode);
}
void
StyleSheet::ClearAssociatedDocument()
{
MOZ_STYLO_FORWARD(SetAssociatedDocument, (nullptr, NotOwnedByDocument));
AsGecko()->SetAssociatedDocument(nullptr, NotOwnedByDocument);
}
StyleSheet*
StyleSheet::GetParentSheet() const
{
MOZ_STYLO_FORWARD(GetParentSheet, ())
return AsGecko()->GetParentSheet();
}
StyleSheet*
@@ -119,8 +112,7 @@ StyleSheet::GetParentObject() const
void
StyleSheet::AppendStyleSheet(StyleSheet* aSheet)
{
MOZ_STYLO_FORWARD_CONCRETE(AppendStyleSheet,
(aSheet->AsGecko()), (aSheet->AsServo()))
AsGecko()->AppendStyleSheet(aSheet->AsGecko());
}
nsIPrincipal*
@@ -163,19 +155,19 @@ StyleSheet::GetIntegrity(dom::SRIMetadata& aResult) const
size_t
StyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
MOZ_STYLO_FORWARD(SizeOfIncludingThis, (aMallocSizeOf))
return AsGecko()->SizeOfIncludingThis(aMallocSizeOf);
}
#ifdef DEBUG
void
StyleSheet::List(FILE* aOut, int32_t aIndex) const
{
MOZ_STYLO_FORWARD(List, (aOut, aIndex))
AsGecko()->List(aOut, aIndex);
}
#endif
void StyleSheet::WillDirty() { MOZ_STYLO_FORWARD(WillDirty, ()) }
void StyleSheet::DidDirty() { MOZ_STYLO_FORWARD(DidDirty, ()) }
void StyleSheet::WillDirty() { AsGecko()->WillDirty(); }
void StyleSheet::DidDirty() { AsGecko()->DidDirty(); }
}
-9
View File
@@ -525,9 +525,6 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext,
nsCOMArray<nsIStyleRule> rules;
rules.AppendObject(aKeyframeDeclaration);
MOZ_ASSERT(aPresContext->StyleSet()->IsGecko(),
"ServoStyleSet should not use nsAnimationManager for "
"animations");
RefPtr<nsStyleContext> resultStrong = aPresContext->StyleSet()->AsGecko()->
ResolveStyleByAddingRules(aParentStyleContext, rules);
mCache.Put(aKeyframeDeclaration, resultStrong);
@@ -1055,9 +1052,6 @@ CSSAnimationBuilder::GetComputedValue(nsPresContext* aPresContext,
StyleAnimationValue computedValue;
if (!mStyleWithoutAnimation) {
MOZ_ASSERT(aPresContext->StyleSet()->IsGecko(),
"ServoStyleSet should not use nsAnimationManager for "
"animations");
mStyleWithoutAnimation = aPresContext->StyleSet()->AsGecko()->
ResolveStyleWithoutAnimation(mTarget, mStyleContext,
eRestyle_AllHintsWithAnimations);
@@ -1101,9 +1095,6 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
// "none" which is represented by an empty name in the StyleAnimation.
// Since such animations neither affect style nor dispatch events, we do
// not generate a corresponding CSSAnimation for them.
MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
"ServoStyleSet should not use nsAnimationManager for "
"animations");
nsCSSKeyframesRule* rule =
src.GetName().IsEmpty()
? nullptr
+1 -9
View File
@@ -523,11 +523,6 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement,
}
if (aStyleType == eDefaultOnly) {
if (styleSet->IsServo()) {
NS_ERROR("stylo: ServoStyleSets cannot supply UA-only styles yet");
return nullptr;
}
// We really only want the user and UA rules. Filter out the other ones.
nsTArray< nsCOMPtr<nsIStyleRule> > rules;
for (nsRuleNode* ruleNode = sc->RuleNode();
@@ -653,10 +648,7 @@ MustReresolveStyle(const nsStyleContext* aContext)
MOZ_ASSERT(aContext);
if (aContext->HasPseudoElementData()) {
if (!aContext->GetPseudo() ||
aContext->StyleSource().IsServoComputedValues()) {
// TODO(emilio): When ::first-line is supported in Servo, we may want to
// fix this to avoid re-resolving pseudo-element styles.
if (!aContext->GetPseudo()) {
return true;
}
+18 -36
View File
@@ -131,21 +131,17 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
RefPtr<DeclarationBlock> newdecl;
if (olddecl->IsServo()) {
newdecl = ServoDeclarationBlock::FromCssText(aCssText);
} else {
RefPtr<css::Declaration> decl(new css::Declaration());
decl->InitializeEmpty();
nsCSSParser cssParser(env.mCSSLoader);
bool changed;
nsresult result = cssParser.ParseDeclarations(aCssText, env.mSheetURI,
env.mBaseURI, env.mPrincipal,
decl, &changed);
if (NS_FAILED(result) || !changed) {
return result;
}
newdecl = decl.forget();
RefPtr<css::Declaration> decl(new css::Declaration());
decl->InitializeEmpty();
nsCSSParser cssParser(env.mCSSLoader);
bool changed;
nsresult result = cssParser.ParseDeclarations(aCssText, env.mSheetURI,
env.mBaseURI, env.mPrincipal,
decl, &changed);
if (NS_FAILED(result) || !changed) {
return result;
}
newdecl = decl.forget();
return SetCSSDeclaration(newdecl);
}
@@ -300,17 +296,10 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSPropertyID aPropID,
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
bool changed;
if (decl->IsGecko()) {
nsCSSParser cssParser(env.mCSSLoader);
cssParser.ParseProperty(aPropID, aPropValue,
env.mSheetURI, env.mBaseURI, env.mPrincipal,
decl->AsGecko(), &changed, aIsImportant);
} else {
nsIAtom* atom = nsCSSProps::AtomForProperty(aPropID);
NS_ConvertUTF16toUTF8 value(aPropValue);
changed = Servo_DeclarationBlock_SetProperty(
decl->AsServo()->Raw(), atom, false, &value, aIsImportant);
}
nsCSSParser cssParser(env.mCSSLoader);
cssParser.ParseProperty(aPropID, aPropValue,
env.mSheetURI, env.mBaseURI, env.mPrincipal,
decl->AsGecko(), &changed, aIsImportant);
if (!changed) {
// Parsing failed -- but we don't throw an exception for that.
return NS_OK;
@@ -347,17 +336,10 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
bool changed;
auto propName = Substring(aPropertyName, CSS_CUSTOM_NAME_PREFIX_LENGTH);
if (decl->IsGecko()) {
nsCSSParser cssParser(env.mCSSLoader);
cssParser.ParseVariable(propName, aPropValue, env.mSheetURI,
env.mBaseURI, env.mPrincipal, decl->AsGecko(),
&changed, aIsImportant);
} else {
RefPtr<nsIAtom> atom = NS_Atomize(propName);
NS_ConvertUTF16toUTF8 value(aPropValue);
changed = Servo_DeclarationBlock_SetProperty(
decl->AsServo()->Raw(), atom, true, &value, aIsImportant);
}
nsCSSParser cssParser(env.mCSSLoader);
cssParser.ParseVariable(propName, aPropValue, env.mSheetURI,
env.mBaseURI, env.mPrincipal, decl->AsGecko(),
&changed, aIsImportant);
if (!changed) {
// Parsing failed -- but we don't throw an exception for that.
return NS_OK;
-3
View File
@@ -73,9 +73,6 @@ nsHTMLCSSStyleSheet::ElementRulesMatching(nsPresContext* aPresContext,
declaration = aElement->GetSMILOverrideStyleDeclaration();
if (declaration) {
MOZ_ASSERT(aPresContext->RestyleManager()->IsGecko(),
"stylo: ElementRulesMatching must not be called when we have "
"a Servo-backed style system");
RestyleManager* restyleManager = aPresContext->RestyleManager()->AsGecko();
if (!restyleManager->SkipAnimationRules()) {
// Animation restyle (or non-restyle traversal of rules)
+3 -18
View File
@@ -505,9 +505,6 @@ nsLayoutStylesheetCache::InvalidateSheet(RefPtr<StyleSheet>* aGeckoSheet,
const bool gotGeckoSheet = aGeckoSheet && *aGeckoSheet;
const bool gotServoSheet = aServoSheet && *aServoSheet;
// Make sure sheets have the expected types
MOZ_ASSERT(!gotGeckoSheet || (*aGeckoSheet)->IsGecko());
MOZ_ASSERT(!gotServoSheet || (*aServoSheet)->IsServo());
// Make sure the URIs match
MOZ_ASSERT(!gotServoSheet || !gotGeckoSheet ||
(*aGeckoSheet)->GetSheetURI() == (*aServoSheet)->GetSheetURI(),
@@ -574,13 +571,8 @@ void
nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<StyleSheet>* aSheet,
nsPresContext* aPresContext)
{
if (mBackendType == StyleBackendType::Gecko) {
*aSheet = new CSSStyleSheet(eAgentSheetFeatures, CORS_NONE,
mozilla::net::RP_Default);
} else {
*aSheet = new ServoStyleSheet(eAgentSheetFeatures, CORS_NONE,
mozilla::net::RP_Default, dom::SRIMetadata());
}
*aSheet = new CSSStyleSheet(eAgentSheetFeatures, CORS_NONE,
mozilla::net::RP_Default);
StyleSheet* sheet = *aSheet;
@@ -675,14 +667,7 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<StyleSheet>* aSheet,
"kPreallocSize should be big enough to build preference style "
"sheet without reallocation");
if (sheet->IsGecko()) {
sheet->AsGecko()->ReparseSheet(sheetText);
} else {
nsresult rv = sheet->AsServo()->ParseSheet(sheetText, uri, uri, nullptr, 0);
// Parsing the about:PreferenceStyleSheet URI can only fail on OOM. If we
// are OOM before we parsed any documents we might as well abort.
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
}
sheet->AsGecko()->ReparseSheet(sheetText);
#undef NS_GET_R_G_B
}
-4
View File
@@ -1659,8 +1659,6 @@ nsRuleNode::nsRuleNode(nsPresContext* aContext, nsRuleNode* aParent,
NS_ASSERTION(IsRoot() || GetLevel() == aLevel, "not enough bits");
NS_ASSERTION(IsRoot() || IsImportantRule() == aIsImportant, "yikes");
MOZ_ASSERT(aContext->StyleSet()->IsGecko(),
"ServoStyleSets should not have rule nodes");
aContext->StyleSet()->AsGecko()->RuleNodeUnused(this, /* aMayGC = */ false);
// nsStyleSet::GetContext depends on there being only one animation
@@ -3904,8 +3902,6 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
if (variantAlternates & NS_FONT_VARIANT_ALTERNATES_FUNCTIONAL_MASK) {
// fetch the feature lookup object from the styleset
MOZ_ASSERT(aPresContext->StyleSet()->IsGecko(),
"ServoStyleSets should not have rule nodes");
aFont->mFont.featureValueLookup =
aPresContext->StyleSet()->AsGecko()->GetFontFeatureValuesLookup();
+7 -49
View File
@@ -160,9 +160,7 @@ nsStyleContext::FinishConstruction(bool aSkipParentDisplayBasedStyleFixup)
}
SetStyleBits();
if (!mSource.IsServoComputedValues()) {
ApplyStyleFixups(aSkipParentDisplayBasedStyleFixup);
}
ApplyStyleFixups(aSkipParentDisplayBasedStyleFixup);
#define eStyleStruct_LastItem (nsStyleStructID_Length - 1)
NS_ASSERTION(NS_STYLE_INHERIT_MASK & NS_STYLE_INHERIT_BIT(LastItem),
@@ -450,43 +448,11 @@ const void* nsStyleContext::StyleData(nsStyleStructID aSID)
return cachedData; // We have computed data stored on this node in the context tree.
// Our style source will take care of it for us.
const void* newData;
if (mSource.IsGeckoRuleNode()) {
newData = mSource.AsGeckoRuleNode()->GetStyleData(aSID, this, true);
if (!nsCachedStyleData::IsReset(aSID)) {
// always cache inherited data on the style context; the rule
// node set the bit in mBits for us if needed.
mCachedInheritedData.mStyleStructs[aSID] = const_cast<void*>(newData);
}
} else {
newData = StyleStructFromServoComputedValues(aSID);
// perform any remaining main thread work on the struct
switch (aSID) {
#define STYLE_STRUCT(name_, checkdata_cb_) \
case eStyleStruct_##name_: { \
auto data = static_cast<const nsStyle##name_*>(newData); \
const_cast<nsStyle##name_*>(data)->FinishStyle(PresContext()); \
break; \
}
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
default:
MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value");
break;
}
// The Servo-backed StyleContextSource owns the struct.
AddStyleBit(nsCachedStyleData::GetBitForSID(aSID));
// XXXbholley: Unconditionally caching reset structs here defeats the memory
// optimization where we lazily allocate mCachedResetData, so that we can avoid
// performing an FFI call each time we want to get the style structs. We should
// measure the tradeoffs at some point. If the FFI overhead is low and the memory
// win significant, we should consider _always_ grabbing the struct over FFI, and
// potentially giving mCachedInheritedData the same treatment.
//
// Note that there is a similar comment in the struct getters in nsStyleContext.h.
SetStyle(aSID, const_cast<void*>(newData));
newData = mSource.AsGeckoRuleNode()->GetStyleData(aSID, this, true);
if (!nsCachedStyleData::IsReset(aSID)) {
// always cache inherited data on the style context; the rule
// node set the bit in mBits for us if needed.
mCachedInheritedData.mStyleStructs[aSID] = const_cast<void*>(newData);
}
return newData;
}
@@ -497,9 +463,6 @@ const void* nsStyleContext::StyleData(nsStyleStructID aSID)
void*
nsStyleContext::GetUniqueStyleData(const nsStyleStructID& aSID)
{
MOZ_ASSERT(!mSource.IsServoComputedValues(),
"Can't COW-mutate servo values from Gecko!");
// If we already own the struct and no kids could depend on it, then
// just return it. (We leak in this case if there are kids -- and this
// function really shouldn't be called for style contexts that could
@@ -715,9 +678,6 @@ nsStyleContext::SetStyleBits()
void
nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
{
MOZ_ASSERT(!mSource.IsServoComputedValues(),
"Can't do Gecko style fixups on Servo values");
#define GET_UNIQUE_STYLE_DATA(name_) \
static_cast<nsStyle##name_*>(GetUniqueStyleData(eStyleStruct_##name_))
@@ -1351,9 +1311,7 @@ void nsStyleContext::List(FILE* out, int32_t aIndent, bool aListDescendants)
str.Append(' ');
}
if (mSource.IsServoComputedValues()) {
fprintf_stderr(out, "%s{ServoComputedValues}\n", str.get());
} else if (mSource.IsGeckoRuleNode()) {
if (mSource.AsGeckoRuleNode()) {
fprintf_stderr(out, "%s{\n", str.get());
str.Truncate();
nsRuleNode* ruleNode = mSource.AsGeckoRuleNode();
+4 -94
View File
@@ -308,7 +308,6 @@ public:
}
nsRuleNode* RuleNode() {
MOZ_RELEASE_ASSERT(mSource.IsGeckoRuleNode());
return mSource.AsGeckoRuleNode();
}
@@ -530,19 +529,6 @@ private:
void SetStyleBits();
void ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup);
const void* StyleStructFromServoComputedValues(nsStyleStructID aSID) {
switch (aSID) {
#define STYLE_STRUCT(name_, checkdata_cb_) \
case eStyleStruct_##name_: \
return Servo_GetStyle##name_(mSource.AsServoComputedValues());
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
default:
MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value");
return nullptr;
}
}
#ifdef DEBUG
struct AutoCheckDependency {
@@ -589,61 +575,8 @@ private:
/* Have the rulenode deal */ \
AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_); \
const nsStyle##name_ * newData; \
if (mSource.IsGeckoRuleNode()) { \
newData = mSource.AsGeckoRuleNode()-> \
GetStyle##name_<aComputeData>(this, mBits); \
} else { \
/** \
* Reach the parent to grab the inherited style struct if \
* we're a text node. \
* \
* This causes the parent element's style context to cache any \
* inherited structs we request for a text node, which means we \
* don't have to compute change hints for the text node, as \
* handling the change on the parent element is sufficient. \
* \
* Note that adding the inherit bit is ok, because the struct \
* pointer returned by the parent and the child is owned by \
* Servo. This is fine if the pointers are the same (as it \
* should, read below), because both style context sources will \
* hold it. \
* \
* In the case of a mishandled frame, we could end up with the \
* pointer to and old parent style, but that's fine too, since \
* the parent style context will remain alive until we reframe, \
* in which case we'll discard both style contexts. Also, we \
* hold a strong reference to the parent style context, which \
* makes it a non-issue. \
* \
* Also, note that the assertion below should be true, except \
* for those frames we still don't handle correctly, like \
* anonymous table wrappers, in which case the pointers will \
* differ. \
* \
* That means we're not going to restyle correctly text frames \
* of anonymous table wrappers, for example. It's kind of \
* embarrassing, but I think it's not worth it to add more \
* logic here unconditionally, given that's going to be fixed. \
* \
* TODO(emilio): Convert to a strong assertion once we support \
* all kinds of random frames. In fact, this can be a great \
* assertion to debug them. \
*/ \
if (mPseudoTag == nsCSSAnonBoxes::mozText) { \
MOZ_ASSERT(mParent); \
newData = mParent->DoGetStyle##name_<true>(); \
NS_WARNING_ASSERTION( \
newData == Servo_GetStyle##name_(mSource.AsServoComputedValues()), \
"bad newData"); \
} else { \
newData = \
Servo_GetStyle##name_(mSource.AsServoComputedValues()); \
} \
/* perform any remaining main thread work on the struct */ \
const_cast<nsStyle##name_*>(newData)->FinishStyle(PresContext());\
/* the Servo-backed StyleContextSource owns the struct */ \
AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \
} \
newData = mSource.AsGeckoRuleNode()-> \
GetStyle##name_<aComputeData>(this, mBits); \
/* always cache inherited data on the style context; the rule */ \
/* node set the bit in mBits for us if needed. */ \
mCachedInheritedData.mStyleStructs[eStyleStruct_##name_] = \
@@ -663,31 +596,8 @@ private:
/* Have the rulenode deal */ \
AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_); \
const nsStyle##name_ * newData; \
if (mSource.IsGeckoRuleNode()) { \
newData = mSource.AsGeckoRuleNode()-> \
GetStyle##name_<aComputeData>(this); \
} else { \
newData = \
Servo_GetStyle##name_(mSource.AsServoComputedValues()); \
/* perform any remaining main thread work on the struct */ \
const_cast<nsStyle##name_*>(newData)->FinishStyle(PresContext());\
/* The Servo-backed StyleContextSource owns the struct. \
* \
* XXXbholley: Unconditionally caching reset structs here \
* defeats the memory optimization where we lazily allocate \
* mCachedResetData, so that we can avoid performing an FFI \
* call each time we want to get the style structs. We should \
* measure the tradeoffs at some point. If the FFI overhead is \
* low and the memory win significant, we should consider \
* _always_ grabbing the struct over FFI, and potentially \
* giving mCachedInheritedData the same treatment. \
* \
* Note that there is a similar comment in StyleData(). \
*/ \
AddStyleBit(NS_STYLE_INHERIT_BIT(name_)); \
SetStyle(eStyleStruct_##name_, \
const_cast<nsStyle##name_*>(newData)); \
} \
newData = mSource.AsGeckoRuleNode()-> \
GetStyle##name_<aComputeData>(this); \
return newData; \
}
#include "nsStyleStructList.h"
-13
View File
@@ -754,8 +754,6 @@ nsStyleSet::AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) c
AutoTArray<StyleSheet*, 32> sheets;
mBindingManager->AppendAllSheets(sheets);
for (StyleSheet* handle : sheets) {
MOZ_ASSERT(handle->IsGecko(), "stylo: AppendAllSheets shouldn't give us "
"ServoStyleSheets yet");
aArray.AppendElement(handle->AsGecko());
}
}
@@ -1760,9 +1758,6 @@ nsStyleSet::ResolveStyleWithoutAnimation(dom::Element* aTarget,
pseudoType == CSSPseudoElementType::before ||
pseudoType == CSSPseudoElementType::after,
"unexpected type for animations");
MOZ_ASSERT(PresContext()->RestyleManager()->IsGecko(),
"stylo: the style set and restyle manager must have the same "
"StyleBackendType");
RestyleManager* restyleManager = PresContext()->RestyleManager()->AsGecko();
bool oldSkipAnimationRules = restyleManager->SkipAnimationRules();
@@ -2243,9 +2238,6 @@ nsStyleSet::ReparentStyleContext(nsStyleContext* aStyleContext,
CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
nsRuleNode* ruleNode = aStyleContext->RuleNode();
MOZ_ASSERT(PresContext()->RestyleManager()->IsGecko(),
"stylo: the style set and restyle manager must have the same "
"StyleBackendType");
NS_ASSERTION(!PresContext()->RestyleManager()->AsGecko()->SkipAnimationRules(),
"we no longer handle SkipAnimationRules()");
@@ -2481,8 +2473,6 @@ nsStyleSet::EnsureUniqueInnerOnCSSSheets()
// CSSStyleSheets).
mBindingManager->AppendAllSheets(sheets);
for (StyleSheet* sheet : sheets) {
MOZ_ASSERT(sheet->IsGecko(), "stylo: AppendAllSheets shouldn't give us "
"ServoStyleSheets yet");
queue.AppendElement(sheet->AsGecko());
}
}
@@ -2531,8 +2521,5 @@ nsStyleSet::ClearSelectors()
if (!mRuleTree) {
return;
}
MOZ_ASSERT(PresContext()->RestyleManager()->IsGecko(),
"stylo: the style set and restyle manager must have the same "
"StyleBackendType");
PresContext()->RestyleManager()->AsGecko()->ClearSelectors();
}
-4
View File
@@ -580,8 +580,6 @@ inline
void nsRuleNode::AddRef()
{
if (mRefCnt++ == 0) {
MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
"ServoStyleSets should not have rule nodes");
mPresContext->StyleSet()->AsGecko()->RuleNodeInUse(this);
}
}
@@ -590,8 +588,6 @@ inline
void nsRuleNode::Release()
{
if (--mRefCnt == 0) {
MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
"ServoStyleSets should not have rule nodes");
mPresContext->StyleSet()->AsGecko()->RuleNodeUnused(this, /* aMayGC = */ true);
}
}
-4
View File
@@ -453,7 +453,6 @@ void
nsStyleBorder::FinishStyle(nsPresContext* aPresContext)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
mBorderImageSource.ResolveImage(aPresContext);
}
@@ -676,7 +675,6 @@ void
nsStyleList::FinishStyle(nsPresContext* aPresContext)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
if (mListStyleImage && !mListStyleImage->IsResolved()) {
mListStyleImage->Resolve(aPresContext);
@@ -1208,7 +1206,6 @@ void
nsStyleSVGReset::FinishStyle(nsPresContext* aPresContext)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
mMask.ResolveImages(aPresContext);
}
@@ -2945,7 +2942,6 @@ void
nsStyleBackground::FinishStyle(nsPresContext* aPresContext)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
mImage.ResolveImages(aPresContext);
}
-10
View File
@@ -501,9 +501,6 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
return;
}
MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
"ServoRestyleManager should not use nsTransitionManager "
"for transitions");
if (collection &&
collection->mCheckGeneration ==
mPresContext->RestyleManager()->AsGecko()->GetAnimationGeneration()) {
@@ -533,9 +530,6 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
// not stopping or starting right now.
RefPtr<nsStyleContext> afterChangeStyle;
if (collection) {
MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
"ServoStyleSets should not use nsTransitionManager "
"for transitions");
nsStyleSet* styleSet = mPresContext->StyleSet()->AsGecko();
afterChangeStyle =
styleSet->ResolveStyleWithoutAnimation(aElement, newStyleContext,
@@ -914,10 +908,6 @@ nsTransitionManager::ConsiderInitiatingTransition(
Move(startValue), Move(endValue), tf),
aNewStyleContext);
MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
"ServoRestyleManager should not use nsTransitionManager "
"for transitions");
RefPtr<CSSTransition> animation =
new CSSTransition(mPresContext->Document()->GetScopeObject());
animation->SetOwningElement(
-4
View File
@@ -78,10 +78,6 @@ nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator,
}
if (!result) {
// We missed the cache. Resolve this pseudo-style.
// XXXheycam ServoStyleSets do not support XUL tree styles.
if (aPresContext->StyleSet()->IsServo()) {
MOZ_CRASH("stylo: ServoStyleSets should not support XUL tree styles yet");
}
RefPtr<nsStyleContext> newResult = aPresContext->StyleSet()->AsGecko()->
ResolveXULTreePseudoStyle(aContent->AsElement(), aPseudoElement,
aContext, aComparator);