source: webkit/trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp

Last change on this file was 282223, checked in by Antti Koivisto, 4 years ago

Cull inline culling
https://bugs.webkit.org/show_bug.cgi?id=202920

Reviewed by Alan Bujtas.

The optimization was already disabled in r282129.
This patch removes all the associated code.

  • editing/SimplifyMarkupCommand.cpp:

(WebCore::SimplifyMarkupCommand::doApply):

  • page/FrameView.cpp:

(WebCore::FrameView::paintContents):

  • rendering/LegacyInlineFlowBox.cpp:

(WebCore::LegacyInlineFlowBox::nodeAtPoint):

  • rendering/LegacyLineLayout.cpp:

(WebCore::LegacyLineLayout::createLineBoxes):
(WebCore::LegacyLineLayout::layoutLineBoxes):

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::RenderElement):

  • rendering/RenderElement.h:

(WebCore::RenderElement::setRenderInlineAlwaysCreatesLineBoxes): Deleted.
(WebCore::RenderElement::renderInlineAlwaysCreatesLineBoxes const): Deleted.

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::styleDidChange):
(WebCore::RenderInline::mayAffectLayout const):

Rename mayAffectRendering -> mayAffectLayout for specificity.

(WebCore::RenderInline::generateLineBoxRects const):
(WebCore::RenderInline::firstInlineBoxTopLeft const):
(WebCore::RenderInline::linesBoundingBox const):
(WebCore::RenderInline::linesVisualOverflowBoundingBox const):
(WebCore::RenderInline::linesVisualOverflowBoundingBoxInFragment const):
(WebCore::RenderInline::clippedOverflowRect const):
(WebCore::RenderInline::dirtyLineBoxes):
(WebCore::RenderInline::createAndAppendInlineFlowBox):
(WebCore::RenderInline::mayAffectRendering const): Deleted.
(WebCore::RenderInline::updateAlwaysCreateLineBoxes): Deleted.
(WebCore::RenderInline::generateCulledLineBoxRects const): Deleted.
(WebCore::RenderInline::hitTestCulledInline): Deleted.
(WebCore::RenderInline::culledInlineFirstLineBox const): Deleted.
(WebCore::RenderInline::culledInlineLastLineBox const): Deleted.
(WebCore::RenderInline::culledInlineVisualOverflowBoundingBox const): Deleted.

  • rendering/RenderInline.h:

(WebCore::RenderInline::lastLineBox const):
(WebCore::RenderInline::firstLineBoxIncludingCulling const): Deleted.
(WebCore::RenderInline::lastLineBoxIncludingCulling const): Deleted.
(WebCore::RenderInline::alwaysCreateLineBoxes const): Deleted.
(WebCore::RenderInline::setAlwaysCreateLineBoxes): Deleted.

  • rendering/RenderLineBoxList.cpp:

(WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):

  • rendering/RenderText.cpp:

(WebCore::RenderText::linesVisualOverflowBoundingBox const): Deleted.

  • rendering/RenderText.h:
  • rendering/RenderTextLineBoxes.cpp:

(WebCore::RenderTextLineBoxes::visualOverflowBoundingBox const): Deleted.

  • rendering/RenderTextLineBoxes.h:
  • rendering/RenderTreeAsText.cpp:

(WebCore::hasNonEmptySibling):

  • rendering/svg/RenderSVGInline.cpp:

(WebCore::RenderSVGInline::RenderSVGInline):

File size: 8.4 KB
Line 
1/*
2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "RenderTextLineBoxes.h"
28
29#include "LegacyEllipsisBox.h"
30#include "LegacyInlineTextBox.h"
31#include "LegacyRootInlineBox.h"
32#include "RenderBlock.h"
33#include "RenderStyle.h"
34#include "RenderView.h"
35#include "VisiblePosition.h"
36
37namespace WebCore {
38
39RenderTextLineBoxes::RenderTextLineBoxes()
40 : m_first(nullptr)
41 , m_last(nullptr)
42{
43}
44
45LegacyInlineTextBox* RenderTextLineBoxes::createAndAppendLineBox(RenderText& renderText)
46{
47 auto textBox = renderText.createTextBox();
48 if (!m_first) {
49 m_first = textBox.get();
50 m_last = textBox.get();
51 } else {
52 m_last->setNextTextBox(textBox.get());
53 textBox->setPreviousTextBox(m_last);
54 m_last = textBox.get();
55 }
56 return textBox.release();
57}
58
59void RenderTextLineBoxes::extract(LegacyInlineTextBox& box)
60{
61 checkConsistency();
62
63 m_last = box.prevTextBox();
64 if (&box == m_first)
65 m_first = nullptr;
66 if (box.prevTextBox())
67 box.prevTextBox()->setNextTextBox(nullptr);
68 box.setPreviousTextBox(nullptr);
69 for (auto* current = &box; current; current = current->nextTextBox())
70 current->setExtracted();
71
72 checkConsistency();
73}
74
75void RenderTextLineBoxes::attach(LegacyInlineTextBox& box)
76{
77 checkConsistency();
78
79 if (m_last) {
80 m_last->setNextTextBox(&box);
81 box.setPreviousTextBox(m_last);
82 } else
83 m_first = &box;
84 LegacyInlineTextBox* last = nullptr;
85 for (auto* current = &box; current; current = current->nextTextBox()) {
86 current->setExtracted(false);
87 last = current;
88 }
89 m_last = last;
90
91 checkConsistency();
92}
93
94void RenderTextLineBoxes::remove(LegacyInlineTextBox& box)
95{
96 checkConsistency();
97
98 if (&box == m_first)
99 m_first = box.nextTextBox();
100 if (&box == m_last)
101 m_last = box.prevTextBox();
102 if (box.nextTextBox())
103 box.nextTextBox()->setPreviousTextBox(box.prevTextBox());
104 if (box.prevTextBox())
105 box.prevTextBox()->setNextTextBox(box.nextTextBox());
106
107 checkConsistency();
108}
109
110void RenderTextLineBoxes::removeAllFromParent(RenderText& renderer)
111{
112 if (!m_first) {
113 if (renderer.parent())
114 renderer.parent()->dirtyLinesFromChangedChild(renderer);
115 return;
116 }
117 for (auto* box = m_first; box; box = box->nextTextBox())
118 box->removeFromParent();
119}
120
121void RenderTextLineBoxes::deleteAll()
122{
123 if (!m_first)
124 return;
125 LegacyInlineTextBox* next;
126 for (auto* current = m_first; current; current = next) {
127 next = current->nextTextBox();
128 delete current;
129 }
130 m_first = nullptr;
131 m_last = nullptr;
132}
133
134LegacyInlineTextBox* RenderTextLineBoxes::findNext(int offset, int& position) const
135{
136 if (!m_first)
137 return nullptr;
138 // FIXME: This looks buggy. The function is only used for debugging purposes.
139 auto current = m_first;
140 int currentOffset = current->len();
141 while (offset > currentOffset && current->nextTextBox()) {
142 current = current->nextTextBox();
143 currentOffset = current->start() + current->len();
144 }
145 // we are now in the correct text run
146 position = (offset > currentOffset ? current->len() : current->len() - (currentOffset - offset));
147 return current;
148}
149
150void RenderTextLineBoxes::dirtyAll()
151{
152 for (auto* box = m_first; box; box = box->nextTextBox())
153 box->dirtyLineBoxes();
154}
155
156bool RenderTextLineBoxes::dirtyRange(RenderText& renderer, unsigned start, unsigned end, int lengthDelta)
157{
158 LegacyRootInlineBox* firstRootBox = nullptr;
159 LegacyRootInlineBox* lastRootBox = nullptr;
160
161 // Dirty all text boxes that include characters in between offset and offset+len.
162 bool dirtiedLines = false;
163 for (auto* current = m_first; current; current = current->nextTextBox()) {
164 // FIXME: This shouldn't rely on the end of a dirty line box. See https://bugs.webkit.org/show_bug.cgi?id=97264
165 // Text run is entirely before the affected range.
166 if (current->end() <= start)
167 continue;
168 // Text run is entirely after the affected range.
169 if (current->start() >= end) {
170 current->offsetRun(lengthDelta);
171 auto& rootBox = current->root();
172 if (!firstRootBox) {
173 firstRootBox = &rootBox;
174 if (!dirtiedLines) {
175 // The affected area was in between two runs. Mark the root box of the run after the affected area as dirty.
176 firstRootBox->markDirty();
177 dirtiedLines = true;
178 }
179 }
180 lastRootBox = &rootBox;
181 continue;
182 }
183 if (current->end() > start && current->end() <= end) {
184 // Text run overlaps with the left end of the affected range.
185 current->dirtyLineBoxes();
186 dirtiedLines = true;
187 continue;
188 }
189 if (current->start() <= start && current->end() >= end) {
190 // Text run subsumes the affected range.
191 current->dirtyLineBoxes();
192 dirtiedLines = true;
193 continue;
194 }
195 if (current->start() < end && current->end() >= end) {
196 // Text run overlaps with right end of the affected range.
197 current->dirtyLineBoxes();
198 dirtiedLines = true;
199 continue;
200 }
201 }
202
203 // Now we have to walk all of the clean lines and adjust their cached line break information
204 // to reflect our updated offsets.
205 if (lastRootBox)
206 lastRootBox = lastRootBox->nextRootBox();
207 if (firstRootBox) {
208 auto previousRootBox = firstRootBox->prevRootBox();
209 if (previousRootBox)
210 firstRootBox = previousRootBox;
211 } else if (m_last) {
212 ASSERT(!lastRootBox);
213 firstRootBox = &m_last->root();
214 firstRootBox->markDirty();
215 dirtiedLines = true;
216 }
217
218 for (auto* current = firstRootBox; current && current != lastRootBox; current = current->nextRootBox()) {
219 auto lineBreakPos = current->lineBreakPos();
220 if (current->lineBreakObj() == &renderer && (lineBreakPos > end || (start != end && lineBreakPos == end)))
221 current->setLineBreakPos(current->lineBreakPos() + lengthDelta);
222 }
223
224 // If the text node is empty, dirty the line where new text will be inserted.
225 if (!m_first && renderer.parent()) {
226 renderer.parent()->dirtyLinesFromChangedChild(renderer);
227 dirtiedLines = true;
228 }
229 return dirtiedLines;
230}
231
232inline void RenderTextLineBoxes::checkConsistency() const
233{
234#if ASSERT_ENABLED
235#ifdef CHECK_CONSISTENCY
236 const LegacyInlineTextBox* prev = nullptr;
237 for (auto* child = m_first; child; child = child->nextTextBox()) {
238 ASSERT(child->renderer() == this);
239 ASSERT(child->prevTextBox() == prev);
240 prev = child;
241 }
242 ASSERT(prev == m_last);
243#endif
244#endif // ASSERT_ENABLED
245}
246
247#if ASSERT_ENABLED
248RenderTextLineBoxes::~RenderTextLineBoxes()
249{
250 ASSERT(!m_first);
251 ASSERT(!m_last);
252}
253#endif
254
255#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED
256void RenderTextLineBoxes::invalidateParentChildLists()
257{
258 for (auto* box = m_first; box; box = box->nextTextBox())
259 box->invalidateParentChildList();
260}
261#endif
262
263}
Note: See TracBrowser for help on using the repository browser.