Bug 1345804 part 3 - Change will-change to store nsIAtom rather than nsString. r?heycam
MozReview-Commit-ID: 5ISVZwKw6LI
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -1324,16 +1324,17 @@ GK_ATOM(visuallyselected, "visuallyselec
GK_ATOM(vlink, "vlink")
GK_ATOM(vspace, "vspace")
GK_ATOM(wbr, "wbr")
GK_ATOM(webkitdirectory, "webkitdirectory")
GK_ATOM(when, "when")
GK_ATOM(where, "where")
GK_ATOM(widget, "widget")
GK_ATOM(width, "width")
+GK_ATOM(willChange, "will-change")
GK_ATOM(window, "window")
GK_ATOM(headerWindowTarget, "window-target")
GK_ATOM(windowtype, "windowtype")
GK_ATOM(withParam, "with-param")
GK_ATOM(wizard, "wizard")
GK_ATOM(wrap, "wrap")
GK_ATOM(headerDNSPrefetchControl,"x-dns-prefetch-control")
GK_ATOM(headerCSP, "content-security-policy")
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -164,23 +164,25 @@ PrintDisplayItemTo(nsDisplayListBuilder*
aItem->IsUniform(aBuilder) ? " uniform" : "",
aItem->ReferenceFrame(), aItem->GetAnimatedGeometryRoot()->mFrame);
for (auto iter = opaque.RectIter(); !iter.Done(); iter.Next()) {
const nsRect& r = iter.Get();
aStream << nsPrintfCString(" (opaque %d,%d,%d,%d)", r.x, r.y, r.width, r.height);
}
- if (aItem->Frame()->StyleDisplay()->mWillChange.Length() > 0) {
+ const auto& willChange = aItem->Frame()->StyleDisplay()->mWillChange;
+ if (!willChange.IsEmpty()) {
aStream << " (will-change=";
- for (size_t i = 0; i < aItem->Frame()->StyleDisplay()->mWillChange.Length(); i++) {
+ for (size_t i = 0; i < willChange.Length(); i++) {
if (i > 0) {
aStream << ",";
}
- aStream << NS_LossyConvertUTF16toASCII(aItem->Frame()->StyleDisplay()->mWillChange[i]).get();
+ nsDependentAtomString buffer(willChange[i]);
+ aStream << NS_LossyConvertUTF16toASCII(buffer).get();
}
aStream << ")";
}
// Display item specific debug info
aItem->WriteDebugInfo(aStream);
#ifdef MOZ_DUMP_PAINTING
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -16093,24 +16093,23 @@ bool CSSParserImpl::ParseWillChange()
if (first) {
AppendValue(eCSSProperty_will_change, value);
return true;
} else {
return false;
}
}
- nsString str;
- value.GetStringValue(str);
- if (str.LowerCaseEqualsLiteral("default") ||
- str.LowerCaseEqualsLiteral("will-change")) {
- return false;
- }
-
- currentListValue->mValue = value;
+ value.AtomizeIdentValue();
+ nsIAtom* atom = value.GetAtomValue();
+ if (atom == nsGkAtoms::_default || atom == nsGkAtoms::willChange) {
+ return false;
+ }
+
+ currentListValue->mValue = Move(value);
if (!ExpectSymbol(',', true)) {
break;
}
currentListValue->mNext = new nsCSSValueList;
currentListValue = currentListValue->mNext;
first = false;
}
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -4830,29 +4830,28 @@ nsComputedDOMStyle::DoGetClip()
}
return val.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetWillChange()
{
- const nsTArray<nsString>& willChange = StyleDisplay()->mWillChange;
+ const nsCOMArray<nsIAtom>& willChange = StyleDisplay()->mWillChange;
if (willChange.IsEmpty()) {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(eCSSKeyword_auto);
return val.forget();
}
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(true);
- for (size_t i = 0; i < willChange.Length(); i++) {
- const nsString& willChangeIdentifier = willChange[i];
+ for (const nsIAtom* ident : willChange) {
RefPtr<nsROCSSPrimitiveValue> property = new nsROCSSPrimitiveValue;
- property->SetString(willChangeIdentifier);
+ property->SetString(nsDependentAtomString(ident));
valueList->AppendCSSValue(property.forget());
}
return valueList.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetOverflow()
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -6459,54 +6459,50 @@ nsRuleNode::ComputeDisplayData(void* aSt
case eCSSUnit_List:
case eCSSUnit_ListDep: {
display->mWillChange.Clear();
display->mWillChangeBitField = 0;
for (const nsCSSValueList* item = willChangeValue->GetListValue();
item; item = item->mNext)
{
- if (item->mValue.UnitHasStringValue()) {
- nsAutoString buffer;
- item->mValue.GetStringValue(buffer);
- display->mWillChange.AppendElement(buffer);
-
- if (buffer.EqualsLiteral("transform")) {
- display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_TRANSFORM;
- }
- if (buffer.EqualsLiteral("opacity")) {
- display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_OPACITY;
- }
- if (buffer.EqualsLiteral("scroll-position")) {
- display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_SCROLL;
- }
-
- nsCSSPropertyID prop =
- nsCSSProps::LookupProperty(buffer, CSSEnabledState::eForAllContent);
- if (prop != eCSSProperty_UNKNOWN &&
- prop != eCSSPropertyExtra_variable) {
- // If the property given is a shorthand, it indicates the expectation
- // for all the longhands the shorthand expands to.
- if (nsCSSProps::IsShorthand(prop)) {
- for (const nsCSSPropertyID* shorthands =
- nsCSSProps::SubpropertyEntryFor(prop);
- *shorthands != eCSSProperty_UNKNOWN; ++shorthands) {
- display->mWillChangeBitField |= GetWillChangeBitFieldFromPropFlags(*shorthands);
- }
- } else {
- display->mWillChangeBitField |= GetWillChangeBitFieldFromPropFlags(prop);
+ nsIAtom* atom = item->mValue.GetAtomValue();
+ display->mWillChange.AppendElement(atom);
+ if (atom == nsGkAtoms::transform) {
+ display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_TRANSFORM;
+ } else if (atom == nsGkAtoms::opacity) {
+ display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_OPACITY;
+ } else if (atom == nsGkAtoms::scrollPosition) {
+ display->mWillChangeBitField |= NS_STYLE_WILL_CHANGE_SCROLL;
+ }
+
+ nsDependentAtomString buffer(atom);
+ nsCSSPropertyID prop =
+ nsCSSProps::LookupProperty(buffer, CSSEnabledState::eForAllContent);
+ if (prop != eCSSProperty_UNKNOWN &&
+ prop != eCSSPropertyExtra_variable) {
+ // If the property given is a shorthand, it indicates the expectation
+ // for all the longhands the shorthand expands to.
+ if (nsCSSProps::IsShorthand(prop)) {
+ for (const nsCSSPropertyID* shorthands =
+ nsCSSProps::SubpropertyEntryFor(prop);
+ *shorthands != eCSSProperty_UNKNOWN; ++shorthands) {
+ display->mWillChangeBitField |= GetWillChangeBitFieldFromPropFlags(*shorthands);
}
+ } else {
+ display->mWillChangeBitField |= GetWillChangeBitFieldFromPropFlags(prop);
}
}
}
break;
}
case eCSSUnit_Inherit:
- display->mWillChange = parentDisplay->mWillChange;
+ display->mWillChange.Clear();
+ display->mWillChange.AppendElements(parentDisplay->mWillChange);
display->mWillChangeBitField = parentDisplay->mWillChangeBitField;
conditions.SetUncacheable();
break;
case eCSSUnit_Initial:
case eCSSUnit_Unset:
case eCSSUnit_Auto:
display->mWillChange.Clear();
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2860,17 +2860,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
uint8_t mIsolation; // [reset] see nsStyleConsts.h
uint8_t mTopLayer; // [reset] see nsStyleConsts.h
uint8_t mWillChangeBitField; // [reset] see nsStyleConsts.h. Stores a
// bitfield representation of the properties
// that are frequently queried. This should
// match mWillChange. Also tracks if any of the
// properties in the will-change list require
// a stacking context.
- nsTArray<nsString> mWillChange;
+ nsCOMArray<nsIAtom> mWillChange;
uint8_t mTouchAction; // [reset] see nsStyleConsts.h
uint8_t mScrollBehavior; // [reset] see nsStyleConsts.h NS_STYLE_SCROLL_BEHAVIOR_*
uint8_t mScrollSnapTypeX; // [reset] see nsStyleConsts.h NS_STYLE_SCROLL_SNAP_TYPE_*
uint8_t mScrollSnapTypeY; // [reset] see nsStyleConsts.h NS_STYLE_SCROLL_SNAP_TYPE_*
nsStyleCoord mScrollSnapPointsX; // [reset]
nsStyleCoord mScrollSnapPointsY; // [reset]
mozilla::Position mScrollSnapDestination; // [reset]