Index: Source/core/css/resolver/StyleResolver.cpp |
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp |
index 5658520f8fb0fdbcab0a7b8638e1ab77f5c054b5..2f8b4cc2f2200c867d8c6473e12db2828bfc342f 100644 |
--- a/Source/core/css/resolver/StyleResolver.cpp |
+++ b/Source/core/css/resolver/StyleResolver.cpp |
@@ -68,6 +68,7 @@ |
#include "core/css/resolver/StyleResolverStats.h" |
#include "core/css/resolver/ViewportStyleResolver.h" |
#include "core/dom/CSSSelectorWatch.h" |
+#include "core/dom/FirstLetterPseudoElement.h" |
#include "core/dom/NodeRenderStyle.h" |
#include "core/dom/StyleEngine.h" |
#include "core/dom/Text.h" |
@@ -718,18 +719,30 @@ PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap |
return CSSAnimatableValueFactory::create(property, *state.style()); |
} |
+PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element* parent, PseudoId pseudoId) |
+{ |
+ if (pseudoId == FIRST_LETTER) |
+ return FirstLetterPseudoElement::create(parent); |
+ return PseudoElement::create(parent, pseudoId); |
+} |
+ |
PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded(Element& parent, PseudoId pseudoId) |
{ |
RenderObject* parentRenderer = parent.renderer(); |
if (!parentRenderer) |
return nullptr; |
- if (pseudoId < FIRST_INTERNAL_PSEUDOID && !parentRenderer->style()->hasPseudoStyle(pseudoId)) |
+ // The first letter pseudo element has to look up the tree and see if any |
+ // of the ancestors are first letter. |
+ if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !parentRenderer->style()->hasPseudoStyle(pseudoId)) |
return nullptr; |
if (pseudoId == BACKDROP && !parent.isInTopLayer()) |
return nullptr; |
+ if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudoElement::firstLetterTextRenderer(parent))) |
+ return nullptr; |
+ |
if (!parentRenderer->canHaveGeneratedChildren()) |
return nullptr; |
@@ -737,7 +750,7 @@ PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded |
if (RenderStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) { |
if (!pseudoElementRendererIsNeeded(cachedStyle)) |
return nullptr; |
- return PseudoElement::create(&parent, pseudoId); |
+ return createPseudoElement(&parent, pseudoId); |
} |
StyleResolverState state(document(), &parent, parentStyle); |
@@ -750,7 +763,7 @@ PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded |
if (!pseudoElementRendererIsNeeded(style.get())) |
return nullptr; |
- RefPtrWillBeRawPtr<PseudoElement> pseudo = PseudoElement::create(&parent, pseudoId); |
+ RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseudoId); |
setAnimationUpdateIfNeeded(state, *pseudo); |
if (ActiveAnimations* activeAnimations = pseudo->activeAnimations()) |