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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2727853002: [css-display] Support display: contents pseudo-elements.
Patch Set: Add missing nullcheck (whoops). 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
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
172 setIsText(); 166 setIsText();
173 167
174 view()->frameView()->incrementVisuallyNonEmptyCharacterCount(m_text.length()); 168 DCHECK(!node || !node->isDocumentNode());
169 if (node)
170 frameView()->incrementVisuallyNonEmptyCharacterCount(m_text.length());
175 } 171 }
176 172
177 #if DCHECK_IS_ON() 173 #if DCHECK_IS_ON()
178 174
179 LayoutText::~LayoutText() { 175 LayoutText::~LayoutText() {
180 ASSERT(!m_firstTextBox); 176 ASSERT(!m_firstTextBox);
181 ASSERT(!m_lastTextBox); 177 ASSERT(!m_lastTextBox);
182 } 178 }
183 179
184 #endif 180 #endif
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 gSecureTextTimers->insert(this, secureTextTimer); 2020 gSecureTextTimers->insert(this, secureTextTimer);
2025 } 2021 }
2026 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 2022 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
2027 } 2023 }
2028 2024
2029 PassRefPtr<AbstractInlineTextBox> LayoutText::firstAbstractInlineTextBox() { 2025 PassRefPtr<AbstractInlineTextBox> LayoutText::firstAbstractInlineTextBox() {
2030 return AbstractInlineTextBox::getOrCreate(LineLayoutText(this), 2026 return AbstractInlineTextBox::getOrCreate(LineLayoutText(this),
2031 m_firstTextBox); 2027 m_firstTextBox);
2032 } 2028 }
2033 2029
2030 LayoutText* LayoutText::createEmptyAnonymous(Document& doc) {
2031 LayoutText* text = new LayoutText(nullptr, StringImpl::empty);
2032 text->setDocumentForAnonymous(&doc);
2033 return text;
2034 }
2035
2034 void LayoutText::invalidateDisplayItemClients( 2036 void LayoutText::invalidateDisplayItemClients(
2035 PaintInvalidationReason invalidationReason) const { 2037 PaintInvalidationReason invalidationReason) const {
2036 ObjectPaintInvalidator paintInvalidator(*this); 2038 ObjectPaintInvalidator paintInvalidator(*this);
2037 paintInvalidator.invalidateDisplayItemClient(*this, invalidationReason); 2039 paintInvalidator.invalidateDisplayItemClient(*this, invalidationReason);
2038 2040
2039 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 2041 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
2040 paintInvalidator.invalidateDisplayItemClient(*box, invalidationReason); 2042 paintInvalidator.invalidateDisplayItemClient(*box, invalidationReason);
2041 if (box->truncation() != cNoTruncation) { 2043 if (box->truncation() != cNoTruncation) {
2042 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) 2044 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox())
2043 paintInvalidator.invalidateDisplayItemClient(*ellipsisBox, 2045 paintInvalidator.invalidateDisplayItemClient(*ellipsisBox,
2044 invalidationReason); 2046 invalidationReason);
2045 } 2047 }
2046 } 2048 }
2047 } 2049 }
2048 2050
2049 // TODO(lunalu): Would be better to dump the bounding box x and y rather than 2051 // TODO(lunalu): Would be better to dump the bounding box x and y rather than
2050 // the first run's x and y, but that would involve updating many test results. 2052 // the first run's x and y, but that would involve updating many test results.
2051 LayoutRect LayoutText::debugRect() const { 2053 LayoutRect LayoutText::debugRect() const {
2052 IntRect linesBox = enclosingIntRect(linesBoundingBox()); 2054 IntRect linesBox = enclosingIntRect(linesBoundingBox());
2053 LayoutRect rect = LayoutRect( 2055 LayoutRect rect = LayoutRect(
2054 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 2056 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
2055 LayoutBlock* block = containingBlock(); 2057 LayoutBlock* block = containingBlock();
2056 if (block && hasTextBoxes()) 2058 if (block && hasTextBoxes())
2057 block->adjustChildDebugRect(rect); 2059 block->adjustChildDebugRect(rect);
2058 2060
2059 return rect; 2061 return rect;
2060 } 2062 }
2061 2063
2062 } // namespace blink 2064 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698