Bug 1407888 part 2 - Make ServoStyleRuleMap::FillTableFromStyleSheet not make unique inner. r=heycam

MozReview-Commit-ID: 1I7sawfjcnl

--HG--
extra : rebase_source : 620cc19b3826d557e5a255b1bee2417b073da799
This commit is contained in:
Xidorn Quan 2017-10-12 18:56:02 +11:00
Родитель bbaaba8ede
Коммит 75fcad8ea7
7 изменённых файлов: 33 добавлений и 8 удалений

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

@ -11,6 +11,7 @@
#include "mozilla/ServoStyleRule.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/ServoImportRule.h"
#include "mozilla/StyleSheetInlines.h"
#include "nsDocument.h"
#include "nsStyleSheetService.h"
@ -175,7 +176,19 @@ void
ServoStyleRuleMap::FillTableFromStyleSheet(ServoStyleSheet* aSheet)
{
if (aSheet->IsComplete()) {
FillTableFromRuleList(aSheet->GetCssRulesInternal());
// Users of ServoStyleRuleMap should ensure any non-XBL complete
// stylesheet has already had a unique inner, and XBL stylesheets
// are not expected to ever change, so it's fine to construct the
// rule list without a unique inner.
// This is important because inner of XBL stylesheets is not made
// unique by EnsureSafeToHandOutCSSRules, and even if it is, the new
// unique inner may not be taken to restyle properly, so we may end
// up not being able to match rules there anyway.
MOZ_ASSERT(aSheet->HasUniqueInner() || mStyleSet->IsForXBL(),
"Non-XBL stylesheets should be made unique before "
"initializing ServoStyleRuleMap");
FillTableFromRuleList(
aSheet->GetCssRulesInternal(/* aRequireUniqueInner = */ false));
}
}

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

@ -478,6 +478,9 @@ public:
ServoStyleContext* aNewLayoutParent,
Element* aElement);
bool IsMaster() const { return mKind == Kind::Master; }
bool IsForXBL() const { return mKind == Kind::ForXBL; }
private:
friend class AutoSetInServoTraversal;
friend class AutoPrepareTraversal;
@ -489,9 +492,6 @@ private:
*/
const SnapshotTable& Snapshots();
bool IsMaster() const { return mKind == Kind::Master; }
bool IsForXBL() const { return mKind == Kind::ForXBL; }
/**
* Resolve all ServoDeclarationBlocks attached to mapped
* presentation attributes cached on the document.

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

@ -393,10 +393,15 @@ ServoStyleSheet::Clone(StyleSheet* aCloneParent,
}
ServoCSSRuleList*
ServoStyleSheet::GetCssRulesInternal()
ServoStyleSheet::GetCssRulesInternal(bool aRequireUniqueInner)
{
if (!mRuleList) {
EnsureUniqueInner();
MOZ_ASSERT(HasUniqueInner() || aRequireUniqueInner || !mDocument,
"Not requiring unique inner for stylesheet associated "
"with document may have undesired behavior");
if (aRequireUniqueInner) {
EnsureUniqueInner();
}
RefPtr<ServoCssRules> rawRules =
Servo_StyleSheet_GetRules(Inner()->mContents).Consume();

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

@ -120,7 +120,7 @@ public:
// Internal GetCssRules method which do not have security check and
// completelness check.
ServoCSSRuleList* GetCssRulesInternal();
ServoCSSRuleList* GetCssRulesInternal(bool aRequireUniqueInner = true);
// Returns the stylesheet's Servo origin as an OriginFlags value.
OriginFlags GetOrigin();

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

@ -450,7 +450,7 @@ StyleSheet::EnsureUniqueInner()
"unexpected number of outers");
mDirty = true;
if (mInner->mSheets.Length() == 1) {
if (HasUniqueInner()) {
// already unique
return;
}

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

@ -138,6 +138,7 @@ public:
bool IsModified() const { return mDirty; }
inline bool HasUniqueInner() const;
void EnsureUniqueInner();
// Append all of this sheet's child sheets to aArray.

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

@ -129,6 +129,12 @@ StyleSheet::GetIntegrity(dom::SRIMetadata& aResult) const
aResult = SheetInfo().mIntegrity;
}
bool
StyleSheet::HasUniqueInner() const
{
return mInner->mSheets.Length() == 1;
}
}
#endif // mozilla_StyleSheetInlines_h