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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutText.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
Index: third_party/WebKit/Source/core/layout/LayoutText.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutText.cpp b/third_party/WebKit/Source/core/layout/LayoutText.cpp
index 14174575961fc7206f750c4432cc5ba811aef590..be826bc1c531ee9425e981ac64bb80dc8341aae7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp
@@ -150,7 +150,7 @@ static void makeCapitalized(String* string, UChar previous) {
}
LayoutText::LayoutText(Node* node, PassRefPtr<StringImpl> str)
- : LayoutObject(!node || node->isDocumentNode() ? 0 : node),
+ : LayoutObject(node),
m_hasTab(false),
m_linesDirty(false),
m_containsReversedText(false),
@@ -163,15 +163,12 @@ LayoutText::LayoutText(Node* node, PassRefPtr<StringImpl> str)
m_firstTextBox(nullptr),
m_lastTextBox(nullptr) {
ASSERT(m_text);
- // FIXME: Some clients of LayoutText (and subclasses) pass Document as node to
- // create anonymous layoutObject.
- // They should be switched to passing null and using setDocumentForAnonymous.
- if (node && node->isDocumentNode())
- setDocumentForAnonymous(toDocument(node));
+ DCHECK(!node || !node->isDocumentNode());
setIsText();
- view()->frameView()->incrementVisuallyNonEmptyCharacterCount(m_text.length());
+ if (node)
+ frameView()->incrementVisuallyNonEmptyCharacterCount(m_text.length());
}
#if DCHECK_IS_ON()
@@ -183,6 +180,12 @@ LayoutText::~LayoutText() {
#endif
+LayoutText* LayoutText::createEmptyAnonymous(Document& doc) {
+ LayoutText* text = new LayoutText(nullptr, StringImpl::empty);
+ text->setDocumentForAnonymous(&doc);
+ return text;
+}
+
bool LayoutText::isTextFragment() const {
return false;
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutText.h ('k') | third_party/WebKit/Source/core/layout/LayoutTextFragment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698