Bug 1339629 Part 9: Uplift EnsureUniqueInnerOnCSSSheets and SetNeedsRestyleAfterEnsureUniqueInner into StyleSetHandle, and eliminate CSSStyleSheet::EnsureUniqueInner. r=heycam

MozReview-Commit-ID: LH7vTKUmuv8

--HG--
extra : rebase_source : 35d2e23978150001c2a6293a8749065dd49eed4a
This commit is contained in:
Brad Werth 2017-05-15 16:30:10 -07:00
Родитель 1af9f090ed
Коммит 450a0513e2
10 изменённых файлов: 49 добавлений и 25 удалений

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

@ -2381,14 +2381,7 @@ nsPresContext::NotifyMissingFonts()
void
nsPresContext::EnsureSafeToHandOutCSSRules()
{
nsStyleSet* styleSet = mShell->StyleSet()->GetAsGecko();
if (!styleSet) {
// ServoStyleSets do not need to handle copy-on-write style sheet
// innards like with CSSStyleSheets.
return;
}
if (!styleSet->EnsureUniqueInnerOnCSSSheets()) {
if (!mShell->StyleSet()->EnsureUniqueInnerOnCSSSheets()) {
// Nothing to do.
return;
}

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

@ -568,19 +568,6 @@ CSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const
return Inner()->mOrderedRules.SafeObjectAt(aIndex);
}
void
CSSStyleSheet::EnsureUniqueInner()
{
StyleSheet::EnsureUniqueInner();
// let our containing style sets know that if we call
// nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the
// document
for (StyleSetHandle setHandle : mStyleSets) {
setHandle->AsGecko()->SetNeedsRestyleAfterEnsureUniqueInner();
}
}
void
CSSStyleSheet::AppendAllChildSheets(nsTArray<CSSStyleSheet*>& aArray)
{

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

@ -140,8 +140,6 @@ public:
NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate,
nsresult aStatus) override;
void EnsureUniqueInner() override;
// Append all of this sheet's child sheets to aArray.
void AppendAllChildSheets(nsTArray<CSSStyleSheet*>& aArray);

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

@ -43,6 +43,7 @@ ServoStyleSet::ServoStyleSet()
, mAllowResolveStaleStyles(false)
, mAuthorStyleDisabled(false)
, mStylistState(StylistState::NotDirty)
, mNeedsRestyleAfterEnsureUniqueInner(false)
{
}
@ -983,6 +984,17 @@ ServoStyleSet::ComputeAnimationValue(
mRawSet.get()).Consume();
}
bool
ServoStyleSet::EnsureUniqueInnerOnCSSSheets()
{
// This is a stub until more of the functionality of nsStyleSet is
// replicated for Servo here.
bool res = mNeedsRestyleAfterEnsureUniqueInner;
mNeedsRestyleAfterEnsureUniqueInner = false;
return res;
}
void
ServoStyleSet::RebuildData()
{

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

@ -355,6 +355,16 @@ public:
mPostTraversalTasks.AppendElement(aTask);
}
// Returns true if a restyle of the document is needed due to cloning
// sheet inners.
bool EnsureUniqueInnerOnCSSSheets();
// Called by StyleSheet::EnsureUniqueInner to let us know it cloned
// its inner.
void SetNeedsRestyleAfterEnsureUniqueInner() {
mNeedsRestyleAfterEnsureUniqueInner = true;
}
private:
// On construction, sets sInServoTraversal to the given ServoStyleSet.
// On destruction, clears sInServoTraversal and calls RunPostTraversalTasks.
@ -506,6 +516,8 @@ private:
bool mAuthorStyleDisabled;
StylistState mStylistState;
bool mNeedsRestyleAfterEnsureUniqueInner;
// Stores pointers to our cached style contexts for non-inheriting anonymous
// boxes.
EnumeratedArray<nsCSSAnonBoxes::NonInheriting,

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

@ -177,6 +177,9 @@ public:
inline bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
inline nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
inline bool EnsureUniqueInnerOnCSSSheets();
inline void SetNeedsRestyleAfterEnsureUniqueInner();
private:
// Stores a pointer to an nsStyleSet or a ServoStyleSet. The least
// significant bit is 0 for the former, 1 for the latter. This is

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

@ -296,6 +296,18 @@ StyleSetHandle::Ptr::CounterStyleRuleForName(nsIAtom* aName)
FORWARD(CounterStyleRuleForName, (aName));
}
bool
StyleSetHandle::Ptr::EnsureUniqueInnerOnCSSSheets()
{
FORWARD(EnsureUniqueInnerOnCSSSheets, ());
}
void
StyleSetHandle::Ptr::SetNeedsRestyleAfterEnsureUniqueInner()
{
FORWARD(SetNeedsRestyleAfterEnsureUniqueInner, ());
}
} // namespace mozilla
#undef FORWARD

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

@ -449,6 +449,13 @@ StyleSheet::EnsureUniqueInner()
// Ensure we're using the new rules.
ClearRuleCascades();
// let our containing style sets know that if we call
// nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the
// document
for (StyleSetHandle& setHandle : mStyleSets) {
setHandle->SetNeedsRestyleAfterEnsureUniqueInner();
}
}
// WebIDL CSSStyleSheet API

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

@ -122,7 +122,7 @@ public:
bool IsModified() const { return mDirty; }
virtual void EnsureUniqueInner();
void EnsureUniqueInner();
// style sheet owner info
enum DocumentAssociationMode {

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

@ -463,7 +463,7 @@ class nsStyleSet final
// sheet inners.
bool EnsureUniqueInnerOnCSSSheets();
// Called by CSSStyleSheet::EnsureUniqueInner to let us know it cloned
// Called by StyleSheet::EnsureUniqueInner to let us know it cloned
// its inner.
void SetNeedsRestyleAfterEnsureUniqueInner() {
mNeedsRestyleAfterEnsureUniqueInner = true;