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

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 5 years, 8 months 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
« no previous file with comments | « Source/core/css/resolver/StyleResolver.cpp ('k') | Source/core/dom/ElementRareData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 38eed3a7dbb0036e1d860ef39ddd1994994fa108..46b41b871024cf5d5215f1dcc482cf1114dffc9b 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1525,6 +1525,11 @@ 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() && !layoutObject()) {
if (ElementAnimations* elementAnimations = elementRareData()->elementAnimations()) {
elementAnimations->cssAnimations().cancel();
@@ -1691,6 +1696,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.
@@ -2757,9 +2764,12 @@ void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
// Wait until our parent is not displayed or pseudoElementRendererIsNeeded
// is false, otherwise we could continuously create and destroy PseudoElements
// when LayoutObject::isChildAllowed on our parent returns false for the
- // PseudoElement's renderer for each style recalc.
- if (!layoutObject() || !pseudoElementRendererIsNeeded(layoutObject()->getCachedPseudoStyle(pseudoId)))
+ // PseudoElement's layoutObject for each style recalc.
+ if (!layoutObject()
+ || (!pseudoElementRendererIsNeeded(layoutObject()->getCachedPseudoStyle(pseudoId))
+ && (pseudoId == MARKER && layoutObject()->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
// first-letter pseudoElement and then fix the text of the original remaining
@@ -2793,16 +2803,19 @@ bool Element::updateFirstLetter(Element* element)
void Element::createPseudoElementIfNeeded(PseudoId pseudoId)
{
- if (isPseudoElement())
+ // Marker pseudo elements can be nested inside other pseudo elements. This
+ // happens when display: list-item is set on something like an :after element.
+ // See fast/lists/anonymous-items.html for an example.
+ if (isPseudoElement() && (pseudoId != MARKER || isMarkerPseudoElement()))
return;
// Document::ensureStyleResolver is not inlined and shows up on profiles, avoid it here.
- RefPtrWillBeRawPtr<PseudoElement> element = document().styleEngine().ensureResolver().createPseudoElementIfNeeded(*this, pseudoId);
+ RefPtrWillBeRawPtr<PseudoElement> element = document().styleEngine().ensureResolver().createPseudoElementIfNeeded(*this, pseudoId);
if (!element)
return;
-
if (pseudoId == BACKDROP)
document().addToTopLayer(element.get(), this);
+
element->insertedInto(this);
element->attach();
« no previous file with comments | « Source/core/css/resolver/StyleResolver.cpp ('k') | Source/core/dom/ElementRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698