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

Side by Side Diff: Source/core/layout/LayoutTextFragment.cpp

Issue 940373003: Rename RenderText to LayoutText (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/core/layout/LayoutTextFragment.h ('k') | Source/core/layout/LayoutTreeAsText.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/rendering/RenderTextFragment.h" 24 #include "core/layout/LayoutTextFragment.h"
25 25
26 #include "core/dom/FirstLetterPseudoElement.h" 26 #include "core/dom/FirstLetterPseudoElement.h"
27 #include "core/dom/PseudoElement.h" 27 #include "core/dom/PseudoElement.h"
28 #include "core/dom/StyleChangeReason.h" 28 #include "core/dom/StyleChangeReason.h"
29 #include "core/dom/Text.h" 29 #include "core/dom/Text.h"
30 #include "core/layout/HitTestResult.h" 30 #include "core/layout/HitTestResult.h"
31 #include "core/layout/LayoutBlock.h" 31 #include "core/layout/LayoutBlock.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str, int startOff set, int length) 35 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str, int startOff set, int length)
36 : RenderText(node, str ? str->substring(startOffset, length) : PassRefPtr<St ringImpl>(nullptr)) 36 : LayoutText(node, str ? str->substring(startOffset, length) : PassRefPtr<St ringImpl>(nullptr))
37 , m_start(startOffset) 37 , m_start(startOffset)
38 , m_end(length) 38 , m_end(length)
39 , m_isRemainingTextRenderer(false) 39 , m_isRemainingTextRenderer(false)
40 , m_contentString(str) 40 , m_contentString(str)
41 , m_firstLetterPseudoElement(nullptr) 41 , m_firstLetterPseudoElement(nullptr)
42 { 42 {
43 } 43 }
44 44
45 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str) 45 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str)
46 : RenderText(node, str) 46 : LayoutText(node, str)
47 , m_start(0) 47 , m_start(0)
48 , m_end(str ? str->length() : 0) 48 , m_end(str ? str->length() : 0)
49 , m_isRemainingTextRenderer(false) 49 , m_isRemainingTextRenderer(false)
50 , m_contentString(str) 50 , m_contentString(str)
51 , m_firstLetterPseudoElement(nullptr) 51 , m_firstLetterPseudoElement(nullptr)
52 { 52 {
53 } 53 }
54 54
55 RenderTextFragment::~RenderTextFragment() 55 LayoutTextFragment::~LayoutTextFragment()
56 { 56 {
57 ASSERT(!m_firstLetterPseudoElement); 57 ASSERT(!m_firstLetterPseudoElement);
58 } 58 }
59 59
60 void RenderTextFragment::destroy() 60 void LayoutTextFragment::destroy()
61 { 61 {
62 if (m_isRemainingTextRenderer && m_firstLetterPseudoElement) 62 if (m_isRemainingTextRenderer && m_firstLetterPseudoElement)
63 m_firstLetterPseudoElement->setRemainingTextRenderer(nullptr); 63 m_firstLetterPseudoElement->setRemainingTextRenderer(nullptr);
64 m_firstLetterPseudoElement = nullptr; 64 m_firstLetterPseudoElement = nullptr;
65 RenderText::destroy(); 65 LayoutText::destroy();
66 } 66 }
67 67
68 PassRefPtr<StringImpl> RenderTextFragment::completeText() const 68 PassRefPtr<StringImpl> LayoutTextFragment::completeText() const
69 { 69 {
70 Text* text = associatedTextNode(); 70 Text* text = associatedTextNode();
71 return text ? text->dataImpl() : contentString(); 71 return text ? text->dataImpl() : contentString();
72 } 72 }
73 73
74 void RenderTextFragment::setContentString(StringImpl* str) 74 void LayoutTextFragment::setContentString(StringImpl* str)
75 { 75 {
76 m_contentString = str; 76 m_contentString = str;
77 setText(str); 77 setText(str);
78 } 78 }
79 79
80 PassRefPtr<StringImpl> RenderTextFragment::originalText() const 80 PassRefPtr<StringImpl> LayoutTextFragment::originalText() const
81 { 81 {
82 RefPtr<StringImpl> result = completeText(); 82 RefPtr<StringImpl> result = completeText();
83 if (!result) 83 if (!result)
84 return nullptr; 84 return nullptr;
85 return result->substring(start(), end()); 85 return result->substring(start(), end());
86 } 86 }
87 87
88 void RenderTextFragment::setText(PassRefPtr<StringImpl> text, bool force) 88 void LayoutTextFragment::setText(PassRefPtr<StringImpl> text, bool force)
89 { 89 {
90 RenderText::setText(text, force); 90 LayoutText::setText(text, force);
91 91
92 m_start = 0; 92 m_start = 0;
93 m_end = textLength(); 93 m_end = textLength();
94 94
95 // If we're the remaining text from a first letter then we have to tell the 95 // If we're the remaining text from a first letter then we have to tell the
96 // first letter pseudo element to reattach itself so it can re-calculate the 96 // first letter pseudo element to reattach itself so it can re-calculate the
97 // correct first-letter settings. 97 // correct first-letter settings.
98 if (LayoutObject* previous = previousSibling()) { 98 if (LayoutObject* previous = previousSibling()) {
99 if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseu doElement()) 99 if (!previous->isPseudoElement() || !previous->node()->isFirstLetterPseu doElement())
100 return; 100 return;
101 101
102 // Tell the first letter container node, and the first-letter node 102 // Tell the first letter container node, and the first-letter node
103 // that their text content changed. 103 // that their text content changed.
104 toFirstLetterPseudoElement(previous->node())->updateTextFragments(); 104 toFirstLetterPseudoElement(previous->node())->updateTextFragments();
105 } 105 }
106 } 106 }
107 107
108 void RenderTextFragment::setTextFragment(PassRefPtr<StringImpl> text, unsigned s tart, unsigned length) 108 void LayoutTextFragment::setTextFragment(PassRefPtr<StringImpl> text, unsigned s tart, unsigned length)
109 { 109 {
110 RenderText::setText(text, false); 110 LayoutText::setText(text, false);
111 111
112 m_start = start; 112 m_start = start;
113 m_end = length; 113 m_end = length;
114 } 114 }
115 115
116 void RenderTextFragment::transformText() 116 void LayoutTextFragment::transformText()
117 { 117 {
118 // Note, we have to call RenderText::setText here because, if we use our 118 // Note, we have to call LayoutText::setText here because, if we use our
119 // version we will, potentially, screw up the first-letter settings where 119 // version we will, potentially, screw up the first-letter settings where
120 // we only use portions of the string. 120 // we only use portions of the string.
121 if (RefPtr<StringImpl> textToTransform = originalText()) 121 if (RefPtr<StringImpl> textToTransform = originalText())
122 RenderText::setText(textToTransform.release(), true); 122 LayoutText::setText(textToTransform.release(), true);
123 } 123 }
124 124
125 UChar RenderTextFragment::previousCharacter() const 125 UChar LayoutTextFragment::previousCharacter() const
126 { 126 {
127 if (start()) { 127 if (start()) {
128 StringImpl* original = completeText().get(); 128 StringImpl* original = completeText().get();
129 if (original && start() <= original->length()) 129 if (original && start() <= original->length())
130 return (*original)[start() - 1]; 130 return (*original)[start() - 1];
131 } 131 }
132 132
133 return RenderText::previousCharacter(); 133 return LayoutText::previousCharacter();
134 } 134 }
135 135
136 // If this is the renderer for a first-letter pseudoNode then we have to look 136 // If this is the renderer for a first-letter pseudoNode then we have to look
137 // at the node for the remaining text to find our content. 137 // at the node for the remaining text to find our content.
138 Text* RenderTextFragment::associatedTextNode() const 138 Text* LayoutTextFragment::associatedTextNode() const
139 { 139 {
140 Node* node = this->firstLetterPseudoElement(); 140 Node* node = this->firstLetterPseudoElement();
141 if (m_isRemainingTextRenderer || !node) { 141 if (m_isRemainingTextRenderer || !node) {
142 // If we don't have a node, then we aren't part of a first-letter pseudo 142 // If we don't have a node, then we aren't part of a first-letter pseudo
143 // element, so use the actual node. Likewise, if we have a node, but 143 // element, so use the actual node. Likewise, if we have a node, but
144 // we're the remainingTextRenderer for a pseudo element use the real 144 // we're the remainingTextRenderer for a pseudo element use the real
145 // text node. 145 // text node.
146 node = this->node(); 146 node = this->node();
147 } 147 }
148 148
149 if (!node) 149 if (!node)
150 return nullptr; 150 return nullptr;
151 151
152 if (node->isFirstLetterPseudoElement()) { 152 if (node->isFirstLetterPseudoElement()) {
153 FirstLetterPseudoElement* pseudo = toFirstLetterPseudoElement(node); 153 FirstLetterPseudoElement* pseudo = toFirstLetterPseudoElement(node);
154 LayoutObject* nextRenderer = FirstLetterPseudoElement::firstLetterTextRe nderer(*pseudo); 154 LayoutObject* nextRenderer = FirstLetterPseudoElement::firstLetterTextRe nderer(*pseudo);
155 if (!nextRenderer) 155 if (!nextRenderer)
156 return nullptr; 156 return nullptr;
157 node = nextRenderer->node(); 157 node = nextRenderer->node();
158 } 158 }
159 return (node && node->isTextNode()) ? toText(node) : nullptr; 159 return (node && node->isTextNode()) ? toText(node) : nullptr;
160 } 160 }
161 161
162 } // namespace blink 162 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutTextFragment.h ('k') | Source/core/layout/LayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698