Bug 1292930: stylo: Store the change hint generated by non-elements in their parent element. r=heycam

Otherwise, the parent style context doesn't have some inherited structs in the
cache, so it avoids comparing them entirely.

For example, the following example:

<p>Hey</p>

p { color: blue }
p:hover { color: red }

Wouldn't work as intended, because when calculating the change hint the
nsStyleColor struct in the element hasn't been accessed by layout (only the
child text frame's has), so it will report a change hint of 0 when hovering over
the paragraph, and we would ignore the nsChangeHint_ReconstructFrame generated
by the text node.

MozReview-Commit-ID: FW7Thhuh7LG
This commit is contained in:
Emilio Cobos Álvarez 2016-08-06 13:34:53 -07:00
Родитель ace33150af
Коммит 9faca13ea4
2 изменённых файлов: 16 добавлений и 5 удалений

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

@ -224,12 +224,23 @@ void
Gecko_StoreStyleDifference(RawGeckoNode* aNode, nsChangeHint aChangeHintToStore)
{
#ifdef MOZ_STYLO
// XXXEmilio probably storing it in the nearest content parent is a sane thing
// to do if this case can ever happen?
MOZ_ASSERT(aNode->IsContent());
MOZ_ASSERT(aNode->IsDirtyForServo(),
"Change hint stored in a not-dirty node");
nsIContent* aContent = aNode->AsContent();
nsIFrame* primaryFrame = aContent->GetPrimaryFrame();
// For elements, we need to store the change hint in the proper style context.
// For text nodes, we want to store the change hint in the parent element,
// since Gecko's change list only operates on Elements, and we'll fail to
// compute the change hint for the element properly because the property won't
// always be in the cache of the parent's nsStyleContext.
//
// For Gecko this is not a problem, because they access the inherited structs
// from the parent style context in order to inherit them, so they're found in
// the cache and get compared.
Element* aElement =
aNode->IsElement() ? aNode->AsElement() : aNode->GetParentElement();
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
if (!primaryFrame) {
// TODO: Pick the undisplayed content map from the frame-constructor, and
// stick it there. For now we're generating ReconstructFrame

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

@ -534,7 +534,7 @@ public:
void StoreChangeHint(nsChangeHint aHint)
{
MOZ_ASSERT(!IsShared());
mStoredChangeHint = aHint;
mStoredChangeHint |= aHint;
#ifdef DEBUG
mConsumedChangeHint = false;
#endif