зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1415940 Part 1: Expand StyleSheet dirty flag into a bitfield, to allow more types of dirtiness. r=bz
MozReview-Commit-ID: 7IasNqj85il --HG-- extra : rebase_source : 414548a7a0d413917bd72ee3fc384cf2280c334b
This commit is contained in:
Родитель
d673bbdc88
Коммит
7e7864add9
|
@ -1112,8 +1112,8 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal,
|
|||
}
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
// Mark the sheet as complete.
|
||||
MOZ_ASSERT(!sheet->IsModified(),
|
||||
"should not get marked modified during parsing");
|
||||
MOZ_ASSERT(!sheet->HasForcedUniqueInner(),
|
||||
"should not get a forced unique inner during parsing");
|
||||
sheet->SetComplete();
|
||||
// Loop through all the rules found in the CSS text
|
||||
ErrorResult err;
|
||||
|
|
|
@ -353,7 +353,7 @@ CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy,
|
|||
, mScopeElement(nullptr)
|
||||
, mRuleProcessors(nullptr)
|
||||
{
|
||||
if (mDirty) { // CSSOM's been there, force full copy now
|
||||
if (HasForcedUniqueInner()) { // CSSOM's been there, force full copy now
|
||||
NS_ASSERTION(mInner->mComplete,
|
||||
"Why have rules been accessed on an incomplete sheet?");
|
||||
// FIXME: handle failure?
|
||||
|
@ -610,7 +610,7 @@ CSSStyleSheet::ClearRuleCascades()
|
|||
void
|
||||
CSSStyleSheet::DidDirty()
|
||||
{
|
||||
MOZ_ASSERT(!mInner->mComplete || mDirty,
|
||||
MOZ_ASSERT(!mInner->mComplete || HasForcedUniqueInner(),
|
||||
"caller must have called WillDirty()");
|
||||
ClearRuleCascades();
|
||||
}
|
||||
|
|
|
@ -1003,9 +1003,12 @@ Loader::CreateSheet(nsIURI* aURI,
|
|||
NS_ASSERTION(sheet->IsComplete(),
|
||||
"Sheet thinks it's not complete while we think it is");
|
||||
|
||||
// Make sure it hasn't been modified; if it has, we can't use it
|
||||
if (sheet->IsModified()) {
|
||||
LOG((" Not cloning completed sheet %p because it's been modified",
|
||||
// Make sure it hasn't been forced to have a unique inner;
|
||||
// that is an indication that its rules have been exposed to
|
||||
// CSSOM and so we can't use it.
|
||||
if (sheet->HasForcedUniqueInner()) {
|
||||
LOG((" Not cloning completed sheet %p because it has a "
|
||||
"forced unique inner",
|
||||
sheet.get()));
|
||||
sheet = nullptr;
|
||||
fromCompleteSheets = false;
|
||||
|
@ -1056,10 +1059,11 @@ Loader::CreateSheet(nsIURI* aURI,
|
|||
}
|
||||
|
||||
if (sheet) {
|
||||
// The sheet we have now should be either incomplete or unmodified
|
||||
NS_ASSERTION(!sheet->IsModified() ||
|
||||
// The sheet we have now should be either incomplete or without
|
||||
// a forced unique inner.
|
||||
NS_ASSERTION(!sheet->HasForcedUniqueInner() ||
|
||||
!sheet->IsComplete(),
|
||||
"Unexpected modified complete sheet");
|
||||
"Unexpected complete sheet with forced unique inner");
|
||||
NS_ASSERTION(sheet->IsComplete() ||
|
||||
aSheetState != eSheetComplete,
|
||||
"Sheet thinks it's not complete while we think it is");
|
||||
|
@ -1812,8 +1816,8 @@ 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->IsModified(),
|
||||
"should not get marked modified during parsing");
|
||||
MOZ_ASSERT(!data->mSheet->HasForcedUniqueInner(),
|
||||
"should not get a forced unique inner during parsing");
|
||||
data->mSheet->SetComplete();
|
||||
data->ScheduleLoadEventIfNeeded(aStatus);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ ServoStyleSheet::ServoStyleSheet(const ServoStyleSheet& aCopy,
|
|||
aDocumentToUse,
|
||||
aOwningNodeToUse)
|
||||
{
|
||||
if (mDirty) { // CSSOM's been there, force full copy now
|
||||
if (HasForcedUniqueInner()) { // CSSOM's been there, force full copy now
|
||||
NS_ASSERTION(mInner->mComplete,
|
||||
"Why have rules been accessed on an incomplete sheet?");
|
||||
// FIXME: handle failure?
|
||||
|
|
|
@ -28,7 +28,7 @@ StyleSheet::StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMod
|
|||
, mParsingMode(aParsingMode)
|
||||
, mType(aType)
|
||||
, mDisabled(false)
|
||||
, mDirty(false)
|
||||
, mDirtyFlags(0)
|
||||
, mDocumentAssociationMode(NotOwnedByDocument)
|
||||
, mInner(nullptr)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ StyleSheet::StyleSheet(const StyleSheet& aCopy,
|
|||
, mParsingMode(aCopy.mParsingMode)
|
||||
, mType(aCopy.mType)
|
||||
, mDisabled(aCopy.mDisabled)
|
||||
, mDirty(aCopy.mDirty)
|
||||
, mDirtyFlags(aCopy.mDirtyFlags)
|
||||
// We only use this constructor during cloning. It's the cloner's
|
||||
// responsibility to notify us if we end up being owned by a document.
|
||||
, mDocumentAssociationMode(NotOwnedByDocument)
|
||||
|
@ -196,7 +196,9 @@ StyleSheet::IsComplete() const
|
|||
void
|
||||
StyleSheet::SetComplete()
|
||||
{
|
||||
NS_ASSERTION(!mDirty, "Can't set a dirty sheet complete!");
|
||||
NS_ASSERTION(!HasForcedUniqueInner(),
|
||||
"Can't complete a sheet that's already been forced "
|
||||
"unique.");
|
||||
SheetInfo().mComplete = true;
|
||||
if (mDocument && !mDisabled) {
|
||||
// Let the document know
|
||||
|
@ -377,7 +379,7 @@ StyleSheet::EnsureUniqueInner()
|
|||
{
|
||||
MOZ_ASSERT(mInner->mSheets.Length() != 0,
|
||||
"unexpected number of outers");
|
||||
mDirty = true;
|
||||
mDirtyFlags |= FORCED_UNIQUE_INNER;
|
||||
|
||||
if (HasUniqueInner()) {
|
||||
// already unique
|
||||
|
|
|
@ -132,7 +132,8 @@ public:
|
|||
nsIDocument* aCloneDocument,
|
||||
nsINode* aCloneOwningNode) const = 0;
|
||||
|
||||
bool IsModified() const { return mDirty; }
|
||||
bool HasForcedUniqueInner() const { return mDirtyFlags &
|
||||
FORCED_UNIQUE_INNER; }
|
||||
|
||||
inline bool HasUniqueInner() const;
|
||||
void EnsureUniqueInner();
|
||||
|
@ -338,7 +339,10 @@ protected:
|
|||
const StyleBackendType mType;
|
||||
bool mDisabled;
|
||||
|
||||
bool mDirty; // has been modified
|
||||
enum dirtyFlagAttributes {
|
||||
FORCED_UNIQUE_INNER = 0x1,
|
||||
};
|
||||
uint8_t mDirtyFlags; // has been modified
|
||||
|
||||
// mDocumentAssociationMode determines whether mDocument directly owns us (in
|
||||
// the sense that if it's known-live then we're known-live). Always
|
||||
|
|
Загрузка…
Ссылка в новой задаче