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

Unified Diff: third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp

Issue 2754653002: Cleanup anonymous text objects that pass the document as a node. (Closed)
Patch Set: Cleanup anonymous text objects that pass the document as a node. Created 3 years, 9 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 | « no previous file | third_party/WebKit/Source/core/dom/PseudoElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b08b73bcd942a3cfec37278981cf3dc2714df543 100644
--- a/third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp
+++ b/third_party/WebKit/Source/core/dom/FirstLetterPseudoElement.cpp
@@ -290,13 +290,20 @@ 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 {
+ remainingText = LayoutTextFragment::createAnonymous(
+ *this, oldText.impl(), length, remainingLength);
+ }
+
remainingText->setFirstLetterPseudoElement(this);
remainingText->setIsRemainingTextLayoutObject(true);
remainingText->setStyle(nextLayoutObject->mutableStyle());
@@ -310,8 +317,8 @@ 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);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/PseudoElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698