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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 : WTF::Unicode::toTitleCase(stringWithPrevious[startOfWord])); 143 : WTF::Unicode::toTitleCase(stringWithPrevious[startOfWord]));
144 } 144 }
145 for (int i = startOfWord + 1; i < endOfWord; i++) 145 for (int i = startOfWord + 1; i < endOfWord; i++)
146 result.append(input[i - 1]); 146 result.append(input[i - 1]);
147 } 147 }
148 148
149 *string = result.toString(); 149 *string = result.toString();
150 } 150 }
151 151
152 LayoutText::LayoutText(Node* node, PassRefPtr<StringImpl> str) 152 LayoutText::LayoutText(Node* node, PassRefPtr<StringImpl> str)
153 : LayoutObject(!node || node->isDocumentNode() ? 0 : node), 153 : LayoutObject(node),
154 m_hasTab(false), 154 m_hasTab(false),
155 m_linesDirty(false), 155 m_linesDirty(false),
156 m_containsReversedText(false), 156 m_containsReversedText(false),
157 m_knownToHaveNoOverflowAndNoFallbackFonts(false), 157 m_knownToHaveNoOverflowAndNoFallbackFonts(false),
158 m_minWidth(-1), 158 m_minWidth(-1),
159 m_maxWidth(-1), 159 m_maxWidth(-1),
160 m_firstLineMinWidth(0), 160 m_firstLineMinWidth(0),
161 m_lastLineLineMinWidth(0), 161 m_lastLineLineMinWidth(0),
162 m_text(std::move(str)), 162 m_text(std::move(str)),
163 m_firstTextBox(nullptr), 163 m_firstTextBox(nullptr),
164 m_lastTextBox(nullptr) { 164 m_lastTextBox(nullptr) {
165 ASSERT(m_text); 165 ASSERT(m_text);
166 // FIXME: Some clients of LayoutText (and subclasses) pass Document as node to 166 DCHECK(!node || !node->isDocumentNode());
167 // create anonymous layoutObject.
168 // They should be switched to passing null and using setDocumentForAnonymous.
169 if (node && node->isDocumentNode())
170 setDocumentForAnonymous(toDocument(node));
171 167
172 setIsText(); 168 setIsText();
173 169
174 view()->frameView()->incrementVisuallyNonEmptyCharacterCount(m_text.length()); 170 if (node)
171 frameView()->incrementVisuallyNonEmptyCharacterCount(m_text.length());
175 } 172 }
176 173
177 #if DCHECK_IS_ON() 174 #if DCHECK_IS_ON()
178 175
179 LayoutText::~LayoutText() { 176 LayoutText::~LayoutText() {
180 ASSERT(!m_firstTextBox); 177 ASSERT(!m_firstTextBox);
181 ASSERT(!m_lastTextBox); 178 ASSERT(!m_lastTextBox);
182 } 179 }
183 180
184 #endif 181 #endif
185 182
183 LayoutText* LayoutText::createEmptyAnonymous(Document& doc) {
184 LayoutText* text = new LayoutText(nullptr, StringImpl::empty);
185 text->setDocumentForAnonymous(&doc);
186 return text;
187 }
188
186 bool LayoutText::isTextFragment() const { 189 bool LayoutText::isTextFragment() const {
187 return false; 190 return false;
188 } 191 }
189 192
190 bool LayoutText::isWordBreak() const { 193 bool LayoutText::isWordBreak() const {
191 return false; 194 return false;
192 } 195 }
193 196
194 void LayoutText::styleDidChange(StyleDifference diff, 197 void LayoutText::styleDidChange(StyleDifference diff,
195 const ComputedStyle* oldStyle) { 198 const ComputedStyle* oldStyle) {
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 LayoutRect rect = LayoutRect( 2056 LayoutRect rect = LayoutRect(
2054 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 2057 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
2055 LayoutBlock* block = containingBlock(); 2058 LayoutBlock* block = containingBlock();
2056 if (block && hasTextBoxes()) 2059 if (block && hasTextBoxes())
2057 block->adjustChildDebugRect(rect); 2060 block->adjustChildDebugRect(rect);
2058 2061
2059 return rect; 2062 return rect;
2060 } 2063 }
2061 2064
2062 } // namespace blink 2065 } // namespace blink
OLDNEW
« 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