Bug 1449321 - Remove the IsServo and IsGecko methods from the style system code. r=emilio

--HG--
extra : source : 763277b299e42d8ee7eafede027ee690b66a7a2a
This commit is contained in:
Jonathan Watt 2018-03-23 16:01:34 +00:00
Родитель 986651e3c5
Коммит 68e78b291f
40 изменённых файлов: 133 добавлений и 514 удалений

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

@ -311,7 +311,6 @@ EffectCompositor::PostRestyleForAnimation(dom::Element* aElement,
eRestyle_CSSTransitions :
eRestyle_CSSAnimations;
if (mPresContext->StyleSet()->IsServo()) {
MOZ_ASSERT(NS_IsMainThread(),
"Restyle request during restyling should be requested only on "
"the main-thread. e.g. after the parallel traversal");
@ -328,10 +327,10 @@ EffectCompositor::PostRestyleForAnimation(dom::Element* aElement,
// second traversal so we don't need to post any restyle requests to the
// PresShell.
return;
} else {
}
MOZ_ASSERT(!mPresContext->RestyleManager()->IsInStyleRefresh());
}
}
mPresContext->PresShell()->RestyleForAnimation(element, hint);
}
@ -812,7 +811,6 @@ EffectCompositor::PreTraverseInSubtree(ServoTraversalFlags aFlags,
Element* aRoot)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mPresContext->RestyleManager()->IsServo());
MOZ_ASSERT(!aRoot || nsContentUtils::GetPresShellForContent(aRoot),
"Traversal root, if provided, should be bound to a display "
"document");
@ -961,7 +959,6 @@ EffectCompositor::PreTraverse(dom::Element* aElement,
CSSPseudoElementType aPseudoType)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mPresContext->RestyleManager()->IsServo());
// If |aElement|'s document does not have a pres shell, e.g. it is document
// without a browsing context such as we might get from an XMLHttpRequest, we

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

@ -1314,16 +1314,10 @@ nsIDocument::SelectorCache::~SelectorCache()
void
nsIDocument::SelectorCache::SelectorList::Reset()
{
if (mIsServo) {
if (mServo) {
Servo_SelectorList_Drop(mServo);
mServo = nullptr;
}
} else {
if (mGecko) {
MOZ_CRASH("old style system disabled");
}
}
}

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

@ -1505,8 +1505,7 @@ public:
{
public:
SelectorList()
: mIsServo(false)
, mGecko(nullptr)
: mGecko(nullptr)
{}
SelectorList(SelectorList&& aOther)
@ -1517,21 +1516,15 @@ public:
SelectorList& operator=(SelectorList&& aOther)
{
Reset();
mIsServo = aOther.mIsServo;
if (mIsServo) {
mServo = aOther.mServo;
aOther.mServo = nullptr;
} else {
MOZ_CRASH("old style system disabled");
}
return *this;
}
SelectorList(const SelectorList& aOther) = delete;
explicit SelectorList(mozilla::UniquePtr<RawServoSelectorList>&& aList)
: mIsServo(true)
, mServo(aList.release())
: mServo(aList.release())
{}
@ -1539,31 +1532,24 @@ public:
Reset();
}
bool IsServo() const { return mIsServo; }
bool IsGecko() const { return !IsServo(); }
explicit operator bool() const
{
return IsServo() ? !!AsServo() : !!AsGecko();
return !!AsServo();
}
nsCSSSelectorList* AsGecko() const
{
MOZ_ASSERT(IsGecko());
return mGecko;
}
RawServoSelectorList* AsServo() const
{
MOZ_ASSERT(IsServo());
return mServo;
}
private:
void Reset();
bool mIsServo;
union {
nsCSSSelectorList* mGecko;
RawServoSelectorList* mServo;

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

@ -2689,8 +2689,6 @@ GetFontStyleForServo(Element* aElement, const nsAString& aFont,
nsAString& aOutUsedFont,
ErrorResult& aError)
{
MOZ_ASSERT(aPresShell->StyleSet()->IsServo());
RefPtr<RawServoDeclarationBlock> declarations =
CreateFontDeclarationForServo(aFont, aPresShell->GetDocument());
if (!declarations) {
@ -2760,8 +2758,6 @@ ResolveFilterStyleForServo(const nsAString& aFilterString,
nsIPresShell* aPresShell,
ErrorResult& aError)
{
MOZ_ASSERT(aPresShell->StyleSet()->IsServo());
RefPtr<RawServoDeclarationBlock> declarations =
CreateFilterDeclarationForServo(aFilterString, aPresShell->GetDocument());
if (!declarations) {
@ -2800,14 +2796,7 @@ CanvasRenderingContext2D::ParseFilter(const nsAString& aString,
return false;
}
nsString usedFont;
if (presShell->StyleSet()->IsGecko()) {
MOZ_CRASH("old style system disabled");
return false;
}
// For stylo
MOZ_ASSERT(presShell->StyleSet()->IsServo());
nsString usedFont; // unused
RefPtr<ComputedStyle> parentStyle =
GetFontStyleForServo(mCanvasElement,
@ -3735,14 +3724,9 @@ CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont,
return false;
}
RefPtr<ComputedStyle> sc;
nsString usedFont;
if (presShell->StyleSet()->IsServo()) {
sc =
RefPtr<ComputedStyle> sc =
GetFontStyleForServo(mCanvasElement, aFont, presShell, usedFont, aError);
} else {
MOZ_CRASH("old style system disabled");
}
if (!sc) {
return false;
}
@ -3755,8 +3739,8 @@ CanvasRenderingContext2D::SetFontInternal(const nsAString& aFont,
// size (fontStyle->mSize). See
// https://bugzilla.mozilla.org/show_bug.cgi?id=698652.
// FIXME: Nobody initializes mAllowZoom for servo?
MOZ_ASSERT(presShell->StyleSet()->IsServo() || !fontStyle->mAllowZoom,
"expected text zoom to be disabled on this nsStyleFont");
//MOZ_ASSERT(!fontStyle->mAllowZoom,
// "expected text zoom to be disabled on this nsStyleFont");
nsFont resizedFont(fontStyle->mFont);
// Create a font group working in units of CSS pixels instead of the usual
// device pixels, to avoid being affected by page zoom. nsFontMetrics will

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

@ -2959,13 +2959,7 @@ nsGenericHTMLElement::NewURIFromString(const nsAString& aURISpec,
static bool
IsOrHasAncestorWithDisplayNone(Element* aElement, nsIPresShell* aPresShell)
{
if (aPresShell->StyleSet()->IsServo()) {
return !aElement->HasServoData() || Servo_Element_IsDisplayNone(aElement);
}
MOZ_CRASH("Old style system disabled");
return false;
}
void

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

@ -715,8 +715,6 @@ nsSMILAnimationController::PreTraverseInSubtree(Element* aRoot)
if (!context) {
return false;
}
MOZ_ASSERT(context->RestyleManager()->IsServo(),
"PreTraverse should only be called for the servo style system");
bool foundElementsNeedingRestyle = false;
for (auto iter = mAnimationElementTable.Iter(); !iter.Done(); iter.Next()) {

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

@ -118,7 +118,7 @@ nsSVGElement::DidAnimateClass()
nsIPresShell* shell = OwnerDoc()->GetShell();
if (shell) {
nsPresContext* presContext = shell->GetPresContext();
if (presContext && presContext->RestyleManager()->IsServo()) {
if (presContext) {
presContext->RestyleManager()
->AsServo()
->ClassAttributeWillBeChangedBySMIL(this);

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

@ -182,12 +182,8 @@ nsXBLResourceLoader::StyleSheetLoaded(StyleSheet* aSheet,
if (mPendingSheets == 0) {
// All stylesheets are loaded.
if (aSheet->IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
mResources->ComputeServoStyles(
*mBoundDocument->GetShell()->StyleSet()->AsServo());
}
// XXX Check for mPendingScripts when scripts also come online.
if (!mInLoadResourcesFunc)

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

@ -3013,12 +3013,8 @@ 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;
}
MOZ_CRASH("old style system disabled");
// FIXME: This used to do sheet->SetDisabled(false), figure out if we can
// just remove all this code in bug 1449522, since it seems unused.
return true;
}

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

@ -604,11 +604,7 @@ 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;
}
MOZ_CRASH("old style system disabled");
}
}
#define VERIFY_STYLE_TREE ::VerifyStyleTree(mPresContext, mFrameConstructor)
@ -4372,11 +4368,7 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument, EventStates aStateMask)
MOZ_ASSERT(!aStateMask.IsEmpty());
if (mDidInitialize) {
if (mStyleSet->IsServo()) {
mStyleSet->AsServo()->InvalidateStyleForDocumentStateChanges(aStateMask);
} else {
MOZ_CRASH("old style system disabled");
}
}
if (aStateMask.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
@ -4596,7 +4588,6 @@ PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet,
{
// too bad we can't check that the update is UPDATE_STYLE
NS_ASSERTION(mUpdateCount != 0, "must be in an update");
MOZ_ASSERT(aStyleSheet->IsServo() == mStyleSet->IsServo());
mStyleSet->RecordStyleSheetChange(aStyleSheet, aChangeType);
}
@ -9642,14 +9633,9 @@ PresShell::VerifyIncrementalReflow()
// Create a new presentation shell to view the document. Use the
// exact same style information that this document has.
nsAutoPtr<ServoStyleSet> newServoSet;
StyleSetHandle newSet;
if (mStyleSet->IsServo()) {
newServoSet = CloneStyleSet(mStyleSet->AsServo());
newSet = newServoSet;
} else {
MOZ_CRASH("old style system disabled");
}
nsAutoPtr<ServoStyleSet> newServoSet(CloneStyleSet(mStyleSet->AsServo()));
StyleSetHandle newSet(newServoSet);
nsCOMPtr<nsIPresShell> sh = mDocument->CreateShell(cx, vm, newSet);
NS_ENSURE_TRUE(sh, false);
newServoSet.forget();
@ -10380,11 +10366,7 @@ PresShell::AddSizeOfIncludingThis(nsWindowSizes& aSizes) const
mApproximatelyVisibleFrames.ShallowSizeOfExcludingThis(mallocSizeOf) +
mFramesToDirty.ShallowSizeOfExcludingThis(mallocSizeOf);
if (StyleSet()->IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
StyleSet()->AsServo()->AddSizeOfIncludingThis(aSizes);
}
aSizes.mLayoutTextRunsSize += SizeOfTextRuns(mallocSizeOf);
@ -10581,9 +10563,6 @@ nsIPresShell::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
bool* aRetVal)
{
*aRetVal = false;
if (mStyleSet->IsGecko()) {
MOZ_CRASH("old style system disabled");
}
return NS_OK;
}

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

@ -374,7 +374,7 @@ RestyleManager::ContentRemoved(nsINode* aContainer,
{
// Computed style data isn't useful for detached nodes, and we'll need to
// recompute it anyway if we ever insert the nodes back into a document.
if (IsServo() && aOldChild->IsElement()) {
if (aOldChild->IsElement()) {
ServoRestyleManager::ClearServoDataFromSubtree(aOldChild->AsElement());
}
@ -629,13 +629,9 @@ static bool gInApplyRenderingChangeToTree = false;
void
RestyleManager::DebugVerifyStyleTree(nsIFrame* aFrame)
{
if (IsServo()) {
// XXXheycam For now, we know that we don't use the same inheritance
// hierarchy for certain cases, so just skip these assertions until
// we work out what we want to assert (bug 1322570).
return;
}
MOZ_CRASH("old style system disabled");
}
#endif // DEBUG
@ -1750,14 +1746,9 @@ RestyleManager::IncrementAnimationGeneration()
// We update the animation generation at start of each call to
// ProcessPendingRestyles so we should ignore any subsequent (redundant)
// calls that occur while we are still processing restyles.
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
if (mInStyleRefresh) {
return;
}
}
if (!mInStyleRefresh) {
++mAnimationGeneration;
}
}
/* static */ void

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

@ -1151,7 +1151,7 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
while (styleSet->StyleDocument(aFlags)) {
ClearSnapshots();
nsStyleChangeList currentChanges(StyleBackendType::Servo);
nsStyleChangeList currentChanges;
bool anyStyleChanged = false;
// Recreate styles , and queue up change hints (which also handle lazy frame

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

@ -305,9 +305,6 @@ private:
inline ServoStyleSet* StyleSet() const
{
MOZ_ASSERT(PresContext()->StyleSet()->IsServo(),
"ServoRestyleManager should only be used with a Servo-flavored "
"style backend");
return PresContext()->StyleSet()->AsServo();
}

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

@ -471,12 +471,7 @@ ReparentFrame(RestyleManager* aRestyleManager,
aFrame->SetParent(aNewParentFrame);
// We reparent frames for two reasons: to put them inside ::first-line, and to
// put them inside some wrapper anonymous boxes.
//
// The latter shouldn't affect any styles in practice, so only needs style
// context reparenting in the Gecko backend.
//
// FIXME(emilio): Remove old Gecko stuff.
if (aForceStyleReparent || aRestyleManager->IsGecko()) {
if (aForceStyleReparent) {
aRestyleManager->ReparentComputedStyle(aFrame);
}
}
@ -10632,11 +10627,6 @@ nsCSSFrameConstructor::CheckForFirstLineInsertion(nsIFrame* aParentFrame,
}
class RestyleManager* restyleManager = RestyleManager();
if (!restyleManager->IsServo()) {
// Gecko's style resolution is frame-based, so already has the right styles
// even in the ::first-line case.
return;
}
// Check whether there's a ::first-line on the path up from aParentFrame.
// Note that we can't stop until we've run out of ancestors with

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

@ -85,7 +85,7 @@ public:
*/
static nsIContent* GetApplicableParent(nsIContent* aParent);
void AddSizeOfIncludingThis(nsWindowSizes& aSizes, bool aIsServo) const;
void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const;
protected:
LinkedList<UndisplayedNode>* GetListFor(nsIContent* aParentContent);
@ -693,13 +693,12 @@ nsFrameManager::DestroyAnonymousContent(already_AddRefed<nsIContent> aContent)
void
nsFrameManager::AddSizeOfIncludingThis(nsWindowSizes& aSizes) const
{
bool isServo = mPresShell->StyleSet()->IsServo();
aSizes.mLayoutPresShellSize += aSizes.mState.mMallocSizeOf(this);
if (mDisplayNoneMap) {
mDisplayNoneMap->AddSizeOfIncludingThis(aSizes, isServo);
mDisplayNoneMap->AddSizeOfIncludingThis(aSizes);
}
if (mDisplayContentsMap) {
mDisplayContentsMap->AddSizeOfIncludingThis(aSizes, isServo);
mDisplayContentsMap->AddSizeOfIncludingThis(aSizes);
}
}
@ -840,7 +839,7 @@ nsFrameManager::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
void
nsFrameManager::UndisplayedMap::
AddSizeOfIncludingThis(nsWindowSizes& aSizes, bool aIsServo) const
AddSizeOfIncludingThis(nsWindowSizes& aSizes) const
{
MallocSizeOf mallocSizeOf = aSizes.mState.mMallocSizeOf;
aSizes.mLayoutPresShellSize += ShallowSizeOfIncludingThis(mallocSizeOf);
@ -849,11 +848,6 @@ AddSizeOfIncludingThis(nsWindowSizes& aSizes, bool aIsServo) const
for (auto iter = ConstIter(); !iter.Done(); iter.Next()) {
const LinkedList<UndisplayedNode>* list = iter.UserData();
aSizes.mLayoutPresShellSize += list->sizeOfExcludingThis(mallocSizeOf);
if (!aIsServo) {
// Computed values and style structs can only be stale when using
// Servo style system.
continue;
}
for (const UndisplayedNode* node = list->getFirst();
node; node = node->getNext()) {
ComputedStyle* computedStyle = node->mStyle;

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

@ -1207,9 +1207,7 @@ nsPresContext::CompatibilityModeChanged()
}
StyleSetHandle styleSet = mShell->StyleSet();
if (styleSet->IsServo()) {
styleSet->AsServo()->CompatibilityModeChanged();
}
if (doc->IsSVGDocument()) {
// SVG documents never load quirk.css.

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

@ -45,7 +45,7 @@ nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChange
if (aHint & nsChangeHint_ReconstructFrame) {
// If Servo fires reconstruct at a node, it is the only change hint fired at
// that node.
if (IsServo()) {
// Note: Because we check whether |aHint| is a reconstruct above (which is
// necessary to avoid debug test timeouts on certain crashtests), this check
// will not find bugs where we add a non-reconstruct hint for an element after
@ -60,15 +60,6 @@ nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChange
content.");
}
#endif
} else {
// Filter out all other changes for same content for Gecko (Servo asserts against this
// case above).
// NOTE: This is captured by reference to please static analysis.
// Capturing it by value as a pointer should be fine in this case.
RemoveElementsBy([&](const nsStyleChangeData& aData) {
return aData.mContent == aContent;
});
}
}
if (!IsEmpty() && aFrame && aFrame == LastElement().mFrame) {

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

@ -41,8 +41,9 @@ public:
using base_type::Length;
using base_type::operator[];
explicit nsStyleChangeList(mozilla::StyleBackendType aType) :
mType(aType) { MOZ_COUNT_CTOR(nsStyleChangeList); }
nsStyleChangeList() {
MOZ_COUNT_CTOR(nsStyleChangeList);
}
~nsStyleChangeList() { MOZ_COUNT_DTOR(nsStyleChangeList); }
void AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint);
@ -54,12 +55,6 @@ public:
RemoveLastElement();
}
}
bool IsGecko() const { return mType == mozilla::StyleBackendType::Gecko; }
bool IsServo() const { return mType == mozilla::StyleBackendType::Servo; }
private:
mozilla::StyleBackendType mType;
};
#endif /* nsStyleChangeList_h___ */

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

@ -768,14 +768,6 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData)
if (IsPrimaryFrame()) {
// This needs to happen before we clear our Properties() table.
ActiveLayerTracker::TransferActivityToContent(this, mContent);
// Unfortunately, we need to do this for all frames being reframed
// 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()) {
MOZ_CRASH("old style system disabled");
}
}
if (HasCSSAnimations() || HasCSSTransitions() ||

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

@ -28,21 +28,13 @@ DeclarationBlock::Release()
already_AddRefed<DeclarationBlock>
DeclarationBlock::Clone() const
{
RefPtr<DeclarationBlock> result;
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
result = new ServoDeclarationBlock(*AsServo());
}
return result.forget();
return do_AddRef(new ServoDeclarationBlock(*AsServo()));
}
already_AddRefed<DeclarationBlock>
DeclarationBlock::EnsureMutable()
{
#ifdef DEBUG
#endif
if (IsServo() && !IsDirty()) {
if (!IsDirty()) {
// In stylo, the old DeclarationBlock is stored in element's rule node tree
// directly, to avoid new values replacing the DeclarationBlock in the tree
// directly, we need to copy the old one here if we haven't yet copied.

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

@ -138,20 +138,12 @@ ErrorReporter::ReleaseGlobals()
NS_IF_RELEASE(sSpecCache);
}
ErrorReporter::ErrorReporter(const nsCSSScanner& aScanner,
const StyleSheet* aSheet,
ErrorReporter::ErrorReporter(const StyleSheet* aSheet,
const Loader* aLoader,
nsIURI* aURI)
: mScanner(&aScanner), mSheet(aSheet), mLoader(aLoader), mURI(aURI),
mInnerWindowID(0), mErrorLineNumber(0), mPrevErrorLineNumber(0),
mErrorColNumber(0)
{
}
ErrorReporter::ErrorReporter(const ServoStyleSheet* aSheet,
const Loader* aLoader,
nsIURI* aURI)
: mScanner(nullptr), mSheet(aSheet), mLoader(aLoader), mURI(aURI),
: mSheet(aSheet)
, mLoader(aLoader)
, mURI(aURI),
mInnerWindowID(0), mErrorLineNumber(0), mPrevErrorLineNumber(0),
mErrorColNumber(0)
{
@ -288,23 +280,6 @@ ErrorReporter::AddToError(const nsString &aErrorText)
if (mError.IsEmpty()) {
mError = aErrorText;
// If this error reporter is being used from Stylo, the equivalent operation occurs
// in the OutputError variant that provides source information.
if (!IsServo()) {
mErrorLineNumber = mScanner->GetLineNumber();
mErrorColNumber = mScanner->GetColumnNumber();
// Retrieve the error line once per line, and reuse the same nsString
// for all errors on that line. That causes the text of the line to
// be shared among all the nsIScriptError objects.
if (mErrorLine.IsEmpty() || mErrorLineNumber != mPrevErrorLineNumber) {
// Be careful here: the error line might be really long and OOM
// when we try to make a copy here. If so, just leave it empty.
if (!mErrorLine.Assign(mScanner->GetCurrentLine(), fallible)) {
mErrorLine.Truncate();
}
mPrevErrorLineNumber = mErrorLineNumber;
}
}
} else {
mError.AppendLiteral(" ");
mError.Append(aErrorText);
@ -428,12 +403,6 @@ ErrorReporter::ReportUnexpectedEOF(char16_t aExpected)
AddToError(str);
}
bool
ErrorReporter::IsServo() const
{
return !mScanner;
}
} // namespace css
} // namespace mozilla

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

@ -15,7 +15,6 @@
#include "nsString.h"
struct nsCSSToken;
class nsCSSScanner;
class nsIURI;
namespace mozilla {
@ -30,13 +29,9 @@ class Loader;
// methods become inline stubs.
class ErrorReporter {
public:
ErrorReporter(const nsCSSScanner &aScanner,
const StyleSheet *aSheet,
const Loader *aLoader,
nsIURI *aURI);
ErrorReporter(const ServoStyleSheet *aSheet,
const Loader *aLoader,
nsIURI *aURI);
ErrorReporter(const StyleSheet* aSheet,
const Loader* aLoader,
nsIURI* aURI);
~ErrorReporter();
static void ReleaseGlobals();
@ -75,13 +70,10 @@ public:
private:
void AddToError(const nsString &aErrorText);
bool IsServo() const;
#ifdef CSS_REPORT_PARSE_ERRORS
nsAutoString mError;
nsString mErrorLine;
nsString mFileName;
const nsCSSScanner *mScanner;
const StyleSheet *mSheet;
const Loader *mLoader;
nsIURI *mURI;
@ -93,8 +85,7 @@ private:
};
#ifndef CSS_REPORT_PARSE_ERRORS
inline ErrorReporter::ErrorReporter(const nsCSSScanner&,
const StyleSheet*,
inline ErrorReporter::ErrorReporter(const StyleSheet*,
const Loader*,
nsIURI*) {}
inline ErrorReporter::~ErrorReporter() {}

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

@ -26,14 +26,10 @@ MOZ_DEFINE_STYLO_METHODS(GenericSpecifiedValues,
bool
GenericSpecifiedValues::ShouldIgnoreColors() const
{
if (IsServo()) {
// Servo handles this during cascading.
//
// FIXME(emilio): We should eventually move it to the document though.
return false;
}
MOZ_CRASH("old style system disabled");
}
bool
@ -77,10 +73,7 @@ void
GenericSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
{
if (IsServo()) {
return AsServo()->SetKeywordValue(aId, aValue);
}
MOZ_CRASH("old style system disabled");
}
void

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

@ -1204,7 +1204,7 @@ Loader::InsertChildSheet(StyleSheet* aSheet,
LOG(("css::Loader::InsertChildSheet"));
MOZ_ASSERT(aSheet, "Nothing to insert");
MOZ_ASSERT(aParentSheet, "Need a parent to insert into");
MOZ_ASSERT(aSheet->IsGecko() == !!aGeckoParentRule);
MOZ_ASSERT(!aGeckoParentRule, "TODO remove this param");
// child sheets should always start out enabled, even if they got
// cloned off of top-level sheets which were disabled
@ -2092,7 +2092,7 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet,
LOG(("css::Loader::LoadChildSheet"));
NS_PRECONDITION(aURL, "Must have a URI to load");
NS_PRECONDITION(aParentSheet, "Must have a parent sheet");
MOZ_ASSERT(aParentSheet->IsGecko() == !!aGeckoParentRule);
MOZ_ASSERT(!aGeckoParentRule, "TODO remove this param");
if (!mEnabled) {
LOG_WARN((" Not enabled"));
@ -2158,9 +2158,6 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet,
RefPtr<StyleSheet> sheet;
StyleSheetState state;
if (aReusableSheets && aReusableSheets->FindReusableStyleSheet(aURL, sheet)) {
if (aParentSheet->IsGecko()) {
MOZ_CRASH("old style system disabled");
}
state = eSheetComplete;
} else {
bool isAlternate;

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

@ -57,10 +57,6 @@ public:
virtual void SetText(const nsAString& aMediaText) = 0;
virtual bool Matches(nsPresContext* aPresContext) const = 0;
#ifdef DEBUG
virtual bool IsServo() const = 0;
#endif
void SetStyleSheet(StyleSheet* aSheet);
// WebIDL

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

@ -405,12 +405,6 @@ Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
if (!decl) {
return nullptr;
}
if (decl->IsGecko()) {
// XXX This can happen when nodes are adopted from a Gecko-style-backend
// document into a Servo-style-backend document. See bug 1330051.
NS_WARNING("stylo: requesting a Gecko declaration block?");
return nullptr;
}
return decl->AsServo()->RefRawStrong();
}
@ -421,12 +415,6 @@ Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed aElement)
if (!decl) {
return;
}
if (decl->IsGecko()) {
// XXX This can happen when nodes are adopted from a Gecko-style-backend
// document into a Servo-style-backend document. See bug 1330051.
NS_WARNING("stylo: requesting a Gecko declaration block?");
return;
}
decl->UnsetDirty();
}

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

@ -33,10 +33,6 @@ public:
bool Matches(nsPresContext*) const final;
#ifdef DEBUG
bool IsServo() const final { return true; }
#endif
RawServoMediaList& RawList() { return *mRawList; }
protected:

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

@ -72,8 +72,6 @@ ServoStyleRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
{
ServoStyleRule* rule = Rule();
if (RefPtr<StyleSheet> sheet = rule->GetStyleSheet()) {
MOZ_ASSERT(sheet->IsServo(), "Servo style rules should have "
"servo stylesheets.");
nsCOMPtr<nsIDocument> doc = sheet->GetAssociatedDocument();
mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true);
if (aDecl != mDecls) {

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

@ -208,7 +208,6 @@ ServoStyleSheet::ParseSheet(css::Loader* aLoader,
{
MOZ_ASSERT(mParsePromise.IsEmpty());
RefPtr<StyleSheetParsePromise> p = mParsePromise.Ensure(__func__);
MOZ_ASSERT(!mMedia || mMedia->IsServo());
Inner()->mURLData = new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal); // RefPtr
Inner()->mContents = Servo_StyleSheet_FromUTF8Bytes(aLoader,
this,
@ -237,7 +236,6 @@ ServoStyleSheet::ParseSheetSync(css::Loader* aLoader,
nsCompatibility aCompatMode,
css::LoaderReusableStyleSheets* aReusableSheets)
{
MOZ_ASSERT(!mMedia || mMedia->IsServo());
Inner()->mURLData = new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal); // RefPtr
Inner()->mContents = Servo_StyleSheet_FromUTF8Bytes(aLoader,
@ -375,9 +373,6 @@ ServoStyleSheet::StyleSheetLoaded(StyleSheet* aSheet,
bool aWasAlternate,
nsresult aStatus)
{
MOZ_ASSERT(aSheet->IsServo(),
"why we were called back with a CSSStyleSheet?");
ServoStyleSheet* sheet = aSheet->AsServo();
if (!sheet->GetParentSheet()) {
return NS_OK; // ignore if sheet has been detached already

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

@ -35,10 +35,6 @@ inline bool IsInServoTraversal()
}
} // namespace mozilla
# define MOZ_DECL_STYLO_CHECK_METHODS \
bool IsGecko() const { return false; } \
bool IsServo() const { return true; }
#define MOZ_DECL_STYLO_CONVERT_METHODS_SERVO(servotype_) \
inline servotype_* AsServo(); \
inline const servotype_* AsServo() const; \
@ -59,39 +55,34 @@ inline bool IsInServoTraversal()
* The class should define |StyleBackendType mType;| itself.
*/
#define MOZ_DECL_STYLO_METHODS(geckotype_, servotype_) \
MOZ_DECL_STYLO_CHECK_METHODS \
MOZ_DECL_STYLO_CONVERT_METHODS(geckotype_, servotype_)
#define MOZ_DEFINE_STYLO_METHODS_GECKO(type_, geckotype_) \
geckotype_* type_::AsGecko() { \
MOZ_ASSERT(IsGecko()); \
return static_cast<geckotype_*>(this); \
} \
const geckotype_* type_::AsGecko() const { \
MOZ_ASSERT(IsGecko()); \
return static_cast<const geckotype_*>(this); \
} \
geckotype_* type_::GetAsGecko() { \
return IsGecko() ? AsGecko() : nullptr; \
return nullptr; \
} \
const geckotype_* type_::GetAsGecko() const { \
return IsGecko() ? AsGecko() : nullptr; \
return nullptr; \
}
#define MOZ_DEFINE_STYLO_METHODS_SERVO(type_, servotype_) \
servotype_* type_::AsServo() { \
MOZ_ASSERT(IsServo()); \
return static_cast<servotype_*>(this); \
} \
const servotype_* type_::AsServo() const { \
MOZ_ASSERT(IsServo()); \
return static_cast<const servotype_*>(this); \
} \
servotype_* type_::GetAsServo() { \
return IsServo() ? AsServo() : nullptr; \
return AsServo(); \
} \
const servotype_* type_::GetAsServo() const { \
return IsServo() ? AsServo() : nullptr; \
return AsServo(); \
}

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

@ -20,7 +20,6 @@ StreamLoader::StreamLoader(mozilla::css::SheetLoadData* aSheetLoadData)
: mSheetLoadData(aSheetLoadData)
, mStatus(NS_OK)
{
MOZ_ASSERT(!aSheetLoadData->mSheet->IsGecko());
}
StreamLoader::~StreamLoader()

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

@ -43,8 +43,6 @@ namespace css {
class Rule;
} // namespace css
#define SERVO_BIT 0x1
/**
* Smart pointer class that can hold a pointer to either an nsStyleSet
* or a ServoStyleSet.
@ -61,40 +59,26 @@ public:
public:
friend class ::mozilla::StyleSetHandle;
bool IsGecko() const
{
return false;
}
bool IsServo() const
{
MOZ_ASSERT(mValue, "StyleSetHandle null pointer dereference");
return mValue & SERVO_BIT;
}
StyleBackendType BackendType() const
{
return IsGecko() ? StyleBackendType::Gecko :
StyleBackendType::Servo;
return StyleBackendType::Servo;
}
ServoStyleSet* AsServo()
{
MOZ_ASSERT(IsServo());
return reinterpret_cast<ServoStyleSet*>(mValue & ~SERVO_BIT);
return reinterpret_cast<ServoStyleSet*>(mValue);
}
ServoStyleSet* GetAsServo() { return IsServo() ? AsServo() : nullptr; }
ServoStyleSet* GetAsServo() { return AsServo(); }
const ServoStyleSet* AsServo() const
{
MOZ_ASSERT(IsServo());
return const_cast<Ptr*>(this)->AsServo();
}
const ServoStyleSet* GetAsServo() const { return IsServo() ? AsServo() : nullptr; }
const ServoStyleSet* GetAsServo() const { return AsServo(); }
// These inline methods are defined in StyleSetHandleInlines.h.
inline void Delete();
@ -178,8 +162,6 @@ public:
inline already_AddRefed<ComputedStyle>
ProbePseudoElementStyle(dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType);
inline void RootComputedStyleAdded();
inline void RootComputedStyleRemoved();
inline bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
inline nsCSSCounterStyleRule* CounterStyleRuleForName(nsAtom* aName);
@ -203,18 +185,14 @@ public:
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_ASSERT(!(reinterpret_cast<uintptr_t>(aStyleSet) & SERVO_BIT),
"least significant bit shouldn't be set; we use it for state");
mPtr.mValue =
aStyleSet ? (reinterpret_cast<uintptr_t>(aStyleSet) | SERVO_BIT) : 0;
aStyleSet ? reinterpret_cast<uintptr_t>(aStyleSet) : 0;
return *this;
}
@ -235,8 +213,6 @@ private:
Ptr mPtr;
};
#undef SERVO_BIT
} // namespace mozilla
#endif // mozilla_StyleSetHandle_h

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

@ -25,9 +25,6 @@ void
StyleSetHandle::Ptr::Delete()
{
if (mValue) {
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
}
delete AsServo();
}
}
@ -161,10 +158,6 @@ nsresult
StyleSetHandle::Ptr::ReplaceSheets(SheetType aType,
const nsTArray<RefPtr<StyleSheet>>& aNewSheets)
{
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
}
nsTArray<RefPtr<ServoStyleSheet>> newSheets(aNewSheets.Length());
for (auto& sheet : aNewSheets) {
newSheets.AppendElement(sheet->AsServo());
@ -276,26 +269,6 @@ StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement,
FORWARD(ProbePseudoElementStyle, (aParentElement, aType, aParentStyle));
}
void
StyleSetHandle::Ptr::RootComputedStyleAdded()
{
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
}
// Not needed.
}
void
StyleSetHandle::Ptr::RootComputedStyleRemoved()
{
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
}
// Not needed.
}
bool
StyleSetHandle::Ptr::
AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)

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

@ -80,11 +80,7 @@ StyleSheet::LastRelease()
MOZ_ASSERT(mInner->mSheets.Contains(this), "Our mInner should include us.");
UnparentChildren();
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
AsServo()->LastRelease();
}
mInner->RemoveSheet(this);
mInner = nullptr;
@ -397,14 +393,10 @@ StyleSheet::EnsureUniqueInner()
mInner->RemoveSheet(this);
mInner = clone;
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
// Fixup the child lists and parent links in the Servo sheet. This is done
// here instead of in StyleSheetInner::CloneFor, because it's just more
// convenient to do so instead.
AsServo()->BuildChildListAfterInnerClone();
}
// let our containing style sets know that if we call
// nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the
@ -425,10 +417,7 @@ StyleSheet::AppendAllChildSheets(nsTArray<StyleSheet*>& aArray)
// WebIDL CSSStyleSheet API
#define FORWARD_INTERNAL(method_, args_) \
if (IsServo()) { \
return AsServo()->method_ args_; \
} \
MOZ_CRASH("old style system disabled");
return AsServo()->method_ args_;
dom::CSSRuleList*
StyleSheet::GetCssRules(nsIPrincipal& aSubjectPrincipal,
@ -604,12 +593,8 @@ StyleSheet::InsertRuleIntoGroup(const nsAString& aRule,
WillDirty();
nsresult result;
if (IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
result = AsServo()->InsertRuleIntoGroupInternal(aRule, aGroup, aIndex);
}
nsresult result =
AsServo()->InsertRuleIntoGroupInternal(aRule, aGroup, aIndex);
NS_ENSURE_SUCCESS(result, result);
RuleAdded(*aGroup->GetStyleRuleAt(aIndex));

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

@ -383,19 +383,12 @@ nsCSSCounterStyleRule::SetDescriptor(nsCSSCounterDesc aDescID,
const nsAString& aValue)
{
nsCSSValue value;
bool ok;
StyleSheet* sheet = GetStyleSheet();
bool useServo = !sheet || sheet->IsServo();
if (useServo) {
URLExtraData* data = sheet ? sheet->AsServo()->URLData() : nullptr;
ok = ServoCSSParser::ParseCounterStyleDescriptor(aDescID, aValue, data,
bool ok = ServoCSSParser::ParseCounterStyleDescriptor(aDescID, aValue, data,
value);
} else {
MOZ_CRASH("old style system disabled");
}
if (ok && CheckDescValue(GetSystem(), aDescID, value)) {
SetDesc(aDescID, value);

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

@ -121,20 +121,16 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText,
// rule (see stack in bug 209575).
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
RefPtr<DeclarationBlock> newdecl;
if (olddecl->IsServo()) {
ServoCSSParsingEnvironment servoEnv = GetServoCSSParsingEnvironment(
aSubjectPrincipal);
ServoCSSParsingEnvironment servoEnv =
GetServoCSSParsingEnvironment(aSubjectPrincipal);
if (!servoEnv.mUrlExtraData) {
aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return;
}
newdecl = ServoDeclarationBlock::FromCssText(aCssText, servoEnv.mUrlExtraData,
RefPtr<DeclarationBlock> newdecl =
ServoDeclarationBlock::FromCssText(aCssText, servoEnv.mUrlExtraData,
servoEnv.mCompatMode, servoEnv.mLoader);
} else {
MOZ_CRASH("old style system disabled");
}
aRv = SetCSSDeclaration(newdecl);
}
@ -295,9 +291,6 @@ nsDOMCSSDeclaration::ModifyDeclaration(nsIPrincipal* aSubjectPrincipal,
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
bool changed;
if (decl->IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
ServoCSSParsingEnvironment servoEnv = GetServoCSSParsingEnvironment(
aSubjectPrincipal);
if (!servoEnv.mUrlExtraData) {
@ -305,7 +298,7 @@ nsDOMCSSDeclaration::ModifyDeclaration(nsIPrincipal* aSubjectPrincipal,
}
changed = aServoFunc(decl->AsServo(), servoEnv);
}
if (!changed) {
// Parsing failed -- but we don't throw an exception for that.
return NS_OK;

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

@ -116,14 +116,10 @@ nsHTMLStyleSheet::ImplLinkColorSetter(
RestyleManager* restyle = mDocument->GetPresContext()->RestyleManager();
if (restyle->IsServo()) {
MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal());
aDecl = Servo_DeclarationBlock_CreateEmpty().Consume();
Servo_DeclarationBlock_SetColorValue(aDecl.get(), eCSSProperty_color,
aColor);
} else {
MOZ_CRASH("old style system disabled");
}
// Now make sure we restyle any links that might need it. This
// shouldn't happen often, so just rebuilding everything is ok.

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

@ -820,67 +820,6 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
}
}
/* static */ void
nsLayoutStylesheetCache::InvalidateSheet(RefPtr<StyleSheet>* aGeckoSheet,
RefPtr<StyleSheet>* aServoSheet)
{
MOZ_ASSERT(gCSSLoader_Gecko || gCSSLoader_Servo,
"pref changed before we loaded a sheet?");
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(),
"Sheets passed should have the same URI");
nsIURI* uri;
if (gotGeckoSheet) {
uri = (*aGeckoSheet)->GetSheetURI();
} else if (gotServoSheet) {
uri = (*aServoSheet)->GetSheetURI();
} else {
return;
}
if (gCSSLoader_Gecko) {
gCSSLoader_Gecko->ObsoleteSheet(uri);
}
if (gCSSLoader_Servo) {
gCSSLoader_Servo->ObsoleteSheet(uri);
}
if (gotGeckoSheet) {
*aGeckoSheet = nullptr;
}
if (gotServoSheet) {
*aServoSheet = nullptr;
}
}
/* static */ void
nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData)
{
MOZ_ASSERT(gStyleCache_Gecko || gStyleCache_Servo,
"pref changed after shutdown?");
// Cause any UA style sheets whose parsing depends on the value of prefs
// to be re-parsed by dropping the sheet from gCSSLoader_{Gecko,Servo}'s cache
// then setting our cached sheet pointer to null. This will only work for
// sheets that are loaded lazily.
#define INVALIDATE(sheet_) \
InvalidateSheet(gStyleCache_Gecko ? &gStyleCache_Gecko->sheet_ : nullptr, \
gStyleCache_Servo ? &gStyleCache_Servo->sheet_ : nullptr);
// INVALIDATE(mUASheet); // for layout.css.example-pref.enabled
#undef INVALIDATE
}
/* static */ void
nsLayoutStylesheetCache::InvalidatePreferenceSheets()
{
@ -998,14 +937,10 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<StyleSheet>* aSheet,
"kPreallocSize should be big enough to build preference style "
"sheet without reallocation");
if (sheet->IsGecko()) {
MOZ_CRASH("old style system disabled");
} else {
ServoStyleSheet* servoSheet = sheet->AsServo();
// NB: The pref sheet never has @import rules.
servoSheet->ParseSheetSync(
nullptr, sheetText, uri, uri, nullptr, /* aLoadData = */ nullptr, 0, eCompatibility_FullStandards);
}
#undef NS_GET_R_G_B
}

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

@ -100,9 +100,6 @@ private:
void LoadSheet(nsIURI* aURI, RefPtr<mozilla::StyleSheet>* aSheet,
mozilla::css::SheetParsingMode aParsingMode,
mozilla::css::FailureAction aFailureAction);
static void InvalidateSheet(RefPtr<mozilla::StyleSheet>* aGeckoSheet,
RefPtr<mozilla::StyleSheet>* aServoSheet);
static void DependentPrefChanged(const char* aPref, void* aData);
void BuildPreferenceSheet(RefPtr<mozilla::StyleSheet>* aSheet,
nsPresContext* aPresContext);

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

@ -396,7 +396,6 @@ void
nsStyleBorder::FinishStyle(nsPresContext* aPresContext, const nsStyleBorder* aOldStyle)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
mBorderImageSource.ResolveImage(
aPresContext, aOldStyle ? &aOldStyle->mBorderImageSource : nullptr);
@ -617,7 +616,6 @@ void
nsStyleList::FinishStyle(nsPresContext* aPresContext, const nsStyleList* aOldStyle)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
if (mListStyleImage && !mListStyleImage->IsResolved()) {
mListStyleImage->Resolve(
@ -1305,7 +1303,6 @@ void
nsStyleSVGReset::FinishStyle(nsPresContext* aPresContext, const nsStyleSVGReset* aOldStyle)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, mMask) {
nsStyleImage& image = mMask.mLayers[i].mImage;
@ -3373,7 +3370,6 @@ nsStyleBackground::FinishStyle(
nsPresContext* aPresContext, const nsStyleBackground* aOldStyle)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
mImage.ResolveImages(aPresContext, aOldStyle ? &aOldStyle->mImage : nullptr);
}
@ -3753,7 +3749,6 @@ nsStyleDisplay::FinishStyle(
nsPresContext* aPresContext, const nsStyleDisplay* aOldStyle)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
if (mShapeOutside.GetType() == StyleShapeSourceType::Image) {
const UniquePtr<nsStyleImage>& shapeImage = mShapeOutside.GetShapeImage();
@ -4677,7 +4672,6 @@ nsStyleUserInterface::FinishStyle(
nsPresContext* aPresContext, const nsStyleUserInterface* aOldStyle)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPresContext->StyleSet()->IsServo());
for (size_t i = 0; i < mCursorImages.Length(); ++i) {
nsCursorImage& cursor = mCursorImages[i];