Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Unified Diff: Source/core/dom/Element.cpp

Issue 778003003: List marker pseudo elements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 73c0dd8b4d1f2937092fec0007f838441ba746bc..6a0f7bd484706020d7d182ce7f8058d9a39227b5 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1344,12 +1344,33 @@ void Element::attach(const AttachContext& context)
// from any of them.
createPseudoElementIfNeeded(FIRST_LETTER);
+ // The marker has to come after the other content, including the BEFORE pseudo
+ // element so make sure we create it last.
+ if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled())
+ createPseudoElementIfNeeded(MARKER);
+
if (hasRareData() && !renderer()) {
if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimations()) {
activeAnimations->cssAnimations().cancel();
activeAnimations->setAnimationStyleChange(false);
}
}
+
+ // If our parent has a marker pseudo element we need to inform them that we
+ // were attached as they may need to move the list marker.
Julien - ping for review 2014/12/05 19:44:03 Move the list maker? Usually moving renderers is a
dsinclair 2015/01/23 20:46:36 Yea, it sucks but we still have to do it. It's pos
+ if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled() && parentNode() && parentNode()->isElementNode()) {
+ if (PseudoElement* pseudoElement = toElement(parentNode())->pseudoElement(MARKER)) {
+ bool neededRecalc = pseudoElement->needsStyleRecalc();
+ pseudoElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::PseudoClass));
+
+ // If style recalc is currently executing, and we have already been recalc'd
+ // we need to tell our parent to do the recalc again because we need to
+ // re-initialize the first letter state. This can happen for things like
+ // RenderQuote where quotes processed later can effect things already styled.
+ if (document().inStyleRecalc() && !neededRecalc)
+ pseudoElement->recalcStyle(UpdatePseudoElements);
+ }
+ }
}
void Element::detach(const AttachContext& context)
@@ -1506,6 +1527,8 @@ void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling)
updatePseudoElement(AFTER, change);
updatePseudoElement(BACKDROP, change);
+ if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled())
+ updatePseudoElement(MARKER, change);
// If our children have changed then we need to force the first-letter
// checks as we don't know if they effected the first letter or not.
@@ -2513,7 +2536,8 @@ void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
// is false, otherwise we could continuously create and destroy PseudoElements
// when RenderObject::isChildAllowed on our parent returns false for the
// PseudoElement's renderer for each style recalc.
- if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedPseudoStyle(pseudoId)))
+ if (!renderer() ||
+ (!pseudoElementRendererIsNeeded(renderer()->getCachedPseudoStyle(pseudoId)) && (pseudoId == MARKER && renderer()->style()->display() != LIST_ITEM)))
elementRareData()->setPseudoElement(pseudoId, nullptr);
} else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElements && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) {
// This can happen if we change to a float, for example. We need to cleanup the
@@ -2549,7 +2573,7 @@ bool Element::updateFirstLetter(Element* element)
void Element::createPseudoElementIfNeeded(PseudoId pseudoId)
{
- if (isPseudoElement())
+ if (isPseudoElement() && (pseudoId != MARKER || isMarkerPseudoElement()))
return;
// Document::ensureStyleResolver is not inlined and shows up on profiles, avoid it here.
@@ -2557,9 +2581,9 @@ void Element::createPseudoElementIfNeeded(PseudoId pseudoId)
RefPtrWillBeRawPtr<PseudoElement> element = engine->ensureResolver().createPseudoElementIfNeeded(*this, pseudoId);
if (!element)
return;
-
if (pseudoId == BACKDROP)
document().addToTopLayer(element.get(), this);
+
element->insertedInto(this);
element->attach();

Powered by Google App Engine
This is Rietveld 408576698