void ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, int32_t aModType, const nsAttrValue* aOldValue) { MOZ_ASSERT(!mInStyleRefresh); MOZ_ASSERT_IF(mSnapshots.Get(aElement), mSnapshots.Get(aElement)->HasAttrs()); nsIFrame* primaryFrame = aElement->GetPrimaryFrame(); if (primaryFrame) { primaryFrame->AttributeChanged(aNameSpaceID, aAttribute, aModType); } nsChangeHint hint = aElement->GetAttributeChangeHint(aAttribute, aModType); if (hint) { PostRestyleEvent(aElement, nsRestyleHint(0), hint); } if (aAttribute == nsGkAtoms::style) { PostRestyleEvent(aElement, eRestyle_StyleAttribute, nsChangeHint(0)); } // <td> is affected by the cellpadding on its ancestor table, // so we should restyle the whole subtree if (aAttribute == nsGkAtoms::cellpadding && aElement->IsHTMLElement(nsGkAtoms::table)) { PostRestyleEvent(aElement, eRestyle_Subtree, nsChangeHint(0)); } if (aElement->IsAttributeMapped(aAttribute)) { Servo_NoteExplicitHints(aElement, eRestyle_Self, nsChangeHint(0)); } }
void ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, int32_t aModType, const nsAttrValue* aOldValue) { MOZ_ASSERT(SnapshotForElement(aElement)->HasAttrs()); if (aAttribute == nsGkAtoms::style) { PostRestyleEvent(aElement, eRestyle_StyleAttribute, nsChangeHint(0)); } }
void ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, int32_t aModType, const nsAttrValue* aOldValue) { #ifdef DEBUG ServoElementSnapshot* snapshot = Servo_Element_GetSnapshot(aElement); MOZ_ASSERT_IF(snapshot, snapshot->HasAttrs()); #endif if (aAttribute == nsGkAtoms::style) { PostRestyleEvent(aElement, eRestyle_StyleAttribute, nsChangeHint(0)); } }
void ServoRestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint, nsRestyleHint aRestyleHint) { StyleSet()->ClearDataAndMarkDeviceDirty(); if (Element* root = mPresContext->Document()->GetRootElement()) { PostRestyleEvent(root, aRestyleHint, aExtraHint); } // TODO(emilio, bz): Extensions can add/remove stylesheets that can affect // non-inheriting anon boxes. It's not clear if we want to support that, but // if we do, we need to re-selector-match them here. }
void ServoRestyleManager::ContentStateChanged(nsIContent* aContent, EventStates aChangedBits) { MOZ_ASSERT(!mInStyleRefresh); if (!aContent->IsElement()) { return; } Element* aElement = aContent->AsElement(); nsChangeHint changeHint; nsRestyleHint restyleHint; if (!aElement->HasServoData()) { return; } // NOTE: restyleHint here is effectively always 0, since that's what // ServoStyleSet::HasStateDependentStyle returns. Servo computes on // ProcessPendingRestyles using the ElementSnapshot, but in theory could // compute it sequentially easily. // // Determine what's the best way to do it, and how much work do we save // processing the restyle hint early (i.e., computing the style hint here // sequentially, potentially saving the snapshot), vs lazily (snapshot // approach). // // If we take the sequential approach we need to specialize Servo's restyle // hints system a bit more, and mesure whether we save something storing the // restyle hint in the table and deferring the dirtiness setting until // ProcessPendingRestyles (that's a requirement if we store snapshots though), // vs processing the restyle hint in-place, dirtying the nodes on // PostRestyleEvent. // // If we definitely take the snapshot approach, we should take rid of // HasStateDependentStyle, etc (though right now they're no-ops). ContentStateChangedInternal(aElement, aChangedBits, &changeHint, &restyleHint); ServoElementSnapshot& snapshot = SnapshotFor(aElement); EventStates previousState = aElement->StyleState() ^ aChangedBits; snapshot.AddState(previousState); if (Element* parent = aElement->GetFlattenedTreeParentElementForStyle()) { parent->NoteDirtyDescendantsForServo(); } PostRestyleEvent(aElement, restyleHint, changeHint); }