Changeset 212693 in webkit
- Timestamp:
- Feb 20, 2017 6:12:04 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r212691 r212693 1 2017-02-20 Zalan Bujtas <zalan@apple.com> 2 3 Simple line layout: Implement absoluteQuadsForRange. 4 https://bugs.webkit.org/show_bug.cgi?id=168613 5 <rdar://problem/30614618> 6 7 Reviewed by Simon Fraser. 8 9 * fast/dom/Range/simple-line-layout-getclientrects-expected.html: Added. 10 * fast/dom/Range/simple-line-layout-getclientrects.html: Added. 11 1 12 2017-02-20 Ryan Haddad <ryanhaddad@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r212691 r212693 1 2017-02-20 Zalan Bujtas <zalan@apple.com> 2 3 Simple line layout: Implement absoluteQuadsForRange. 4 https://bugs.webkit.org/show_bug.cgi?id=168613 5 <rdar://problem/30614618> 6 7 Reviewed by Simon Fraser. 8 9 This patch ensures that the commonly used Range::getClientRects calls do not 10 throw us off of the simple line layout path. 11 12 Test: fast/dom/Range/simple-line-layout-getclientrects.html 13 14 * rendering/RenderText.cpp: 15 (WebCore::RenderText::absoluteQuadsForRange): 16 * rendering/SimpleLineLayoutFunctions.cpp: 17 (WebCore::SimpleLineLayout::collectAbsoluteQuadsForRange): Special case empty ranges with multiple empty runs. 18 * rendering/SimpleLineLayoutFunctions.h: 19 * rendering/SimpleLineLayoutResolver.cpp: 20 (WebCore::SimpleLineLayout::RunResolver::rangeForRendererWithOffsets): 21 * rendering/SimpleLineLayoutResolver.h: 22 1 23 2017-02-20 Ryan Haddad <ryanhaddad@apple.com> 2 24 -
trunk/Source/WebCore/rendering/RenderText.cpp
r212615 r212693 423 423 Vector<FloatQuad> RenderText::absoluteQuadsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const 424 424 { 425 const_cast<RenderText&>(*this).ensureLineBoxes();426 427 425 // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX 428 // to mean "all the way to the end". InlineTextBox coordinates are unsigneds, so changing this 429 // function to take ints causes various internal mismatches. But selectionRect takes ints, and 430 // passing UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take unsigneds, but 426 // to mean "all the way to the end". InlineTextBox coordinates are unsigneds, so changing this 427 // function to take ints causes various internal mismatches. But selectionRect takes ints, and 428 // passing UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take unsigneds, but 431 429 // that would cause many ripple effects, so for now we'll just clamp our unsigned parameters to INT_MAX. 432 430 ASSERT(end == UINT_MAX || end <= INT_MAX); … … 434 432 start = std::min(start, static_cast<unsigned>(INT_MAX)); 435 433 end = std::min(end, static_cast<unsigned>(INT_MAX)); 436 434 if (simpleLineLayout() && !useSelectionHeight) 435 return collectAbsoluteQuadsForRange(*this, start, end, *simpleLineLayout(), wasFixed); 436 const_cast<RenderText&>(*this).ensureLineBoxes(); 437 437 return m_lineBoxes.absoluteQuadsForRange(*this, start, end, useSelectionHeight, wasFixed); 438 438 } -
trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
r212615 r212693 233 233 } 234 234 235 Vector<FloatQuad> collectAbsoluteQuadsForRange(const RenderObject& renderer, unsigned start, unsigned end, const Layout& layout, bool* wasFixed) 236 { 237 auto& style = downcast<RenderBlockFlow>(*renderer.parent()).style(); 238 Vector<FloatQuad> quads; 239 auto resolver = runResolver(downcast<RenderBlockFlow>(*renderer.parent()), layout); 240 for (auto run : resolver.rangeForRendererWithOffsets(renderer, start, end)) { 241 // This run is fully contained. 242 if (start <= run.start() && end >= run.end()) { 243 quads.append(renderer.localToAbsoluteQuad(FloatQuad(run.rect()), UseTransforms, wasFixed)); 244 continue; 245 } 246 // Partially contained run. 247 TextRun textRun(run.text(), run.logicalLeft(), run.expansion(), run.expansionBehavior()); 248 textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize()); 249 LayoutRect runRect(run.rect()); 250 // Special case empty ranges. 251 if (start == end) { 252 runRect.setWidth(0); 253 quads.append(renderer.localToAbsoluteQuad(FloatQuad(runRect), UseTransforms, wasFixed)); 254 continue; 255 } 256 ASSERT(start < run.end()); 257 ASSERT(end > run.start()); 258 auto localStart = std::max(run.start(), start) - run.start(); 259 auto localEnd = std::min(run.end(), end) - run.start(); 260 style.fontCascade().adjustSelectionRectForText(textRun, runRect, localStart, localEnd); 261 quads.append(renderer.localToAbsoluteQuad(FloatQuad(runRect), UseTransforms, wasFixed)); 262 } 263 return quads; 264 } 265 235 266 #if ENABLE(TREE_DEBUGGING) 236 267 static void printPrefix(int& printedCharacters, int depth) -
trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h
r212615 r212693 59 59 Vector<FloatQuad> collectAbsoluteQuads(const RenderObject&, const Layout&, bool* wasFixed); 60 60 unsigned textOffsetForPoint(const LayoutPoint&, const RenderText&, const Layout&); 61 Vector<FloatQuad> collectAbsoluteQuadsForRange(const RenderObject&, unsigned start, unsigned end, const Layout&, bool* wasFixed); 61 62 62 63 LayoutUnit lineHeightFromFlow(const RenderBlockFlow&); -
trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp
r212615 r212693 220 220 } 221 221 222 Range<RunResolver::Iterator> RunResolver::rangeForRendererWithOffsets(const RenderObject& renderer, unsigned startOffset, unsigned endOffset) const 223 { 224 ASSERT(startOffset <= endOffset); 225 auto range = rangeForRenderer(renderer); 226 auto it = range.begin(); 227 // Advance to the firt run with the start offset inside. 228 while (it != range.end() && (*it).end() <= startOffset) 229 ++it; 230 if (it == range.end()) 231 return { end(), end() }; 232 auto rangeBegin = it; 233 // Special case empty ranges that start at the edge of the run. Apparently normal line layout include those. 234 if (endOffset == startOffset && (*it).start() == endOffset) 235 return { rangeBegin, ++it }; 236 // Advance beyond the last run with the end offset. 237 while (it != range.end() && (*it).start() < endOffset) 238 ++it; 239 return { rangeBegin, it }; 240 } 241 222 242 LineResolver::Iterator::Iterator(RunResolver::Iterator runIterator) 223 243 : m_runIterator(runIterator) -
trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h
r212615 r212693 117 117 Range<Iterator> rangeForRenderer(const RenderObject&) const; 118 118 Iterator runForPoint(const LayoutPoint&) const; 119 Range<Iterator> rangeForRendererWithOffsets(const RenderObject&, unsigned start, unsigned end) const; 119 120 120 121 private:
Note: See TracChangeset
for help on using the changeset viewer.