Bug 1371976 - Resolve counter style during parallel traversal when possible. r=heycam
MozReview-Commit-ID: 4StYe5Fb3Uw
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -2019,17 +2019,17 @@ CounterStyleManager::Disconnect()
mStyles.Clear();
mPresContext = nullptr;
}
CounterStyle*
CounterStyleManager::BuildCounterStyle(nsIAtom* aName)
{
MOZ_ASSERT(NS_IsMainThread());
- CounterStyle* data = mStyles.Get(aName);
+ CounterStyle* data = GetCounterStyle(aName);
if (data) {
return data;
}
// It is intentional that the predefined names are case-insensitive
// but the user-defined names case-sensitive.
StyleSetHandle styleSet = mPresContext->StyleSet();
nsCSSCounterStyleRule* rule = styleSet->CounterStyleRuleForName(aName);
--- a/layout/style/CounterStyleManager.h
+++ b/layout/style/CounterStyleManager.h
@@ -319,16 +319,23 @@ public:
void Disconnect();
bool IsInitial() const
{
// only 'none' and 'decimal'
return mStyles.Count() == 2;
}
+ // Returns the counter style object for the given name from the style
+ // table if it is already built, and nullptr otherwise.
+ CounterStyle* GetCounterStyle(nsIAtom* aName) const {
+ return mStyles.Get(aName);
+ }
+ // Same as GetCounterStyle but try to build the counter style object
+ // rather than returning nullptr if that hasn't been built.
CounterStyle* BuildCounterStyle(nsIAtom* aName);
static CounterStyle* GetBuiltinStyle(int32_t aStyle);
static CounterStyle* GetNoneStyle()
{
return GetBuiltinStyle(NS_STYLE_LIST_STYLE_NONE);
}
static CounterStyle* GetDecimalStyle()
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1268,19 +1268,28 @@ Gecko_SetImageOrientationAsFromImage(nsS
void
Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
const nsStyleVisibility* aSrc)
{
aDst->mImageOrientation = aSrc->mImageOrientation;
}
void
-Gecko_SetCounterStyleToName(CounterStylePtr* aPtr, nsIAtom* aName)
+Gecko_SetCounterStyleToName(CounterStylePtr* aPtr, nsIAtom* aName,
+ RawGeckoPresContextBorrowed aPresContext)
{
- *aPtr = already_AddRefed<nsIAtom>(aName);
+ // Try resolving the counter style if possible, and keep it unresolved
+ // otherwise.
+ CounterStyleManager* manager = aPresContext->CounterStyleManager();
+ nsCOMPtr<nsIAtom> name = already_AddRefed<nsIAtom>(aName);
+ if (CounterStyle* style = manager->GetCounterStyle(name)) {
+ *aPtr = style;
+ } else {
+ *aPtr = name.forget();
+ }
}
void
Gecko_SetCounterStyleToSymbols(CounterStylePtr* aPtr, uint8_t aSymbolsType,
nsACString const* const* aSymbols,
uint32_t aSymbolsCount)
{
nsTArray<nsString> symbols(aSymbolsCount);
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -284,17 +284,18 @@ void Gecko_SetImageOrientation(nsStyleVi
double aRadians,
bool aFlip);
void Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility);
void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
const nsStyleVisibility* aSrc);
// Counter style.
// This function takes an already addrefed nsIAtom
-void Gecko_SetCounterStyleToName(mozilla::CounterStylePtr* ptr, nsIAtom* name);
+void Gecko_SetCounterStyleToName(mozilla::CounterStylePtr* ptr, nsIAtom* name,
+ RawGeckoPresContextBorrowed pres_context);
void Gecko_SetCounterStyleToSymbols(mozilla::CounterStylePtr* ptr,
uint8_t symbols_type,
nsACString const* const* symbols,
uint32_t symbols_count);
void Gecko_SetCounterStyleToString(mozilla::CounterStylePtr* ptr,
const nsACString* symbol);
void Gecko_CopyCounterStyle(mozilla::CounterStylePtr* dst,
const mozilla::CounterStylePtr* src);