Index: third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp |
diff --git a/third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp b/third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp |
index e6be90885fcb8693e464e75c1ecf96cf0b1fdb8c..a92a3a22aee115a899ca584e2db0dac02a2094db 100644 |
--- a/third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp |
+++ b/third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp |
@@ -290,13 +290,23 @@ void FirstLetterPseudoElement::attachFirstLetterTextLayoutObjects() { |
// FIXME: This would already have been calculated in firstLetterLayoutObject. |
// Can we pass the length through? |
unsigned length = FirstLetterPseudoElement::firstLetterLength(oldText); |
+ unsigned remainingLength = oldText.length() - length; |
// Construct a text fragment for the text after the first letter. |
// This text fragment might be empty. |
- LayoutTextFragment* remainingText = new LayoutTextFragment( |
- nextLayoutObject->node() ? nextLayoutObject->node() |
- : &nextLayoutObject->document(), |
- oldText.impl(), length, oldText.length() - length); |
+ LayoutTextFragment* remainingText; |
+ |
+ if (nextLayoutObject->node()) { |
+ remainingText = new LayoutTextFragment( |
+ nextLayoutObject->node(), oldText.impl(), length, remainingLength); |
+ } else { |
+ // TODO(ecobos@igalia.com): This is wrong, should keep the old m_node |
+ // unconditionally, not replacing it with the ::first-letter pseudo here, |
+ // for ::first-letter in ::before/::after with display: contents. |
+ remainingText = LayoutTextFragment::createAnonymous( |
+ *this, oldText.impl(), length, remainingLength); |
+ } |
+ |
remainingText->setFirstLetterPseudoElement(this); |
remainingText->setIsRemainingTextLayoutObject(true); |
remainingText->setStyle(nextLayoutObject->mutableStyle()); |
@@ -310,8 +320,9 @@ void FirstLetterPseudoElement::attachFirstLetterTextLayoutObjects() { |
layoutObject()->parent()->addChild(remainingText, nextSibling); |
// Construct text fragment for the first letter. |
- LayoutTextFragment* letter = new LayoutTextFragment( |
- &nextLayoutObject->document(), oldText.impl(), 0, length); |
+ LayoutTextFragment* letter = |
+ LayoutTextFragment::createAnonymous(*this, oldText.impl(), 0, length); |
+ |
letter->setFirstLetterPseudoElement(this); |
letter->setStyle(pseudoStyle); |
layoutObject()->addChild(letter); |