Bug 1368922 - Set mIsDirty atomically. r=hiro

MozReview-Commit-ID: Ei3zCECVRFf

--HG--
extra : rebase_source : 0429db876e33329a250dced6e8bfcd965a5dfbc8
This commit is contained in:
Cameron McCormack 2017-09-20 11:30:08 +08:00
Родитель 4440d60ddb
Коммит 402b6433ed
2 изменённых файлов: 16 добавлений и 6 удалений

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

@ -35,6 +35,7 @@ function checkExternalFunction(entry)
// Assume that atomic accesses are threadsafe.
/^__atomic_fetch_/,
/^__atomic_load_/,
/^__atomic_store_/,
/^__atomic_thread_fence/,
];
if (entry.matches(whitelist))
@ -475,9 +476,6 @@ function ignoreContents(entry)
// Unable to trace through dataflow, but straightforward if inspected.
"Gecko_NewNoneTransform",
// Bug 1368922
"Gecko_UnsetDirtyStyleAttr",
// Bug 1400438
"Gecko_AppendMozBorderColors",

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

@ -12,6 +12,7 @@
#ifndef mozilla_DeclarationBlock_h
#define mozilla_DeclarationBlock_h
#include "mozilla/Atomics.h"
#include "mozilla/ServoUtils.h"
#include "mozilla/StyleBackendType.h"
@ -33,8 +34,8 @@ class DeclarationBlock
protected:
explicit DeclarationBlock(StyleBackendType aType)
: mImmutable(false)
, mIsDirty(false)
, mType(aType)
, mIsDirty(false)
{
mContainer.mRaw = 0;
}
@ -154,10 +155,21 @@ private:
// set when declaration put in the rule tree;
bool mImmutable;
// True if this declaration has not been restyled after modified.
bool mIsDirty;
const StyleBackendType mType;
// True if this declaration has not been restyled after modified.
//
// Since we can clear this flag from style worker threads, we use an Atomic.
//
// Note that although a single DeclarationBlock can be shared between
// different rule nodes (due to the style="" attribute cache), whenever a
// DeclarationBlock has its mIsDirty flag set to true, we always clone it to
// a unique object first. So when we clear this flag during Servo traversal,
// we know that we are clearing it on a DeclarationBlock that has a single
// reference, and there is no problem with another user of the same
// DeclarationBlock thinking that it is not dirty.
Atomic<bool, MemoryOrdering::Relaxed> mIsDirty;
};
} // namespace mozilla