Simple line layout: Add <br> support.
https://bugs.webkit.org/show_bug.cgi?id=139012
This patch enables RenderBlockFlows to use simple line layout on text content when <br> is present.
Simple text with <br> is a fairly common pattern on discussion(forum)-like web pages. This patch reduces memory usage
and speeds up layout for such content.
Source/WebCore:
PerformanceTest/layout/line-layout-simple.html shows more than 2x speedup, when each paragraph is modified by appending <br> to the end.
With <br> support enabled:
mean: 70.02391461289068 runs/s
median: 70.47986488932318 runs/s
While with <br> support disabled:
mean: 30.417295049468184 runs/s
median: 30.36517778760357 runs/s
Reviewed by Antti Koivisto.
Test: fast/text/simple-line-with-br.html
* editing/TextIterator.cpp:
(WebCore::TextIterator::handleTextNode):
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::setSelectionState):
(WebCore::RenderBlockFlow::deleteLineBoxesBeforeSimpleLineLayout):
* rendering/RenderBlockFlow.h:
* rendering/RenderLineBreak.cpp:
(WebCore::simpleLineLayout):
(WebCore::ensureLineBoxes):
(WebCore::RenderLineBreak::deleteLineBoxesBeforeSimpleLineLayout):
(WebCore::RenderLineBreak::positionForPoint):
(WebCore::RenderLineBreak::setSelectionState):
(WebCore::RenderLineBreak::linesBoundingBox):
(WebCore::RenderLineBreak::absoluteRects):
(WebCore::RenderLineBreak::absoluteQuads):
(WebCore::RenderLineBreak::collectSelectionRects):
* rendering/RenderLineBreak.h:
* rendering/RenderText.cpp:
(WebCore::RenderText::absoluteRects):
(WebCore::RenderText::absoluteQuadsClippedToEllipsis):
(WebCore::RenderText::absoluteQuads):
(WebCore::RenderText::linesBoundingBox):
(WebCore::RenderText::caretMinOffset):
(WebCore::RenderText::caretMaxOffset):
(WebCore::RenderText::containsCaretOffset):
(WebCore::RenderText::hasRenderedText):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseFor):
(WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace):
(WebCore::SimpleLineLayout::removeTrailingWhitespace):
(WebCore::SimpleLineLayout::consumeLineBreakIfNeeded):
(WebCore::SimpleLineLayout::skipWhitespaceIfNeeded):
(WebCore::SimpleLineLayout::firstFragment):
(WebCore::SimpleLineLayout::forceFragmentToLine):
(WebCore::SimpleLineLayout::createLineRuns):
(WebCore::SimpleLineLayout::create):
* rendering/SimpleLineLayoutFlowContents.cpp:
(WebCore::SimpleLineLayout::initializeSegments):
(WebCore::SimpleLineLayout::FlowContents::segmentForRenderer): Deleted.
* rendering/SimpleLineLayoutFlowContents.h:
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):
(WebCore::SimpleLineLayout::hitTestFlow):
(WebCore::SimpleLineLayout::showLineLayoutForFlow):
* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::RunResolver::Run::rect):
(WebCore::SimpleLineLayout::RunResolver::RunResolver):
(WebCore::SimpleLineLayout::RunResolver::rangeForRenderer):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Iterator::inQuirksMode):
(WebCore::SimpleLineLayout::RunResolver::Iterator::operator--):
* rendering/SimpleLineLayoutTextFragmentIterator.cpp:
(WebCore::SimpleLineLayout::TextFragmentIterator::nextTextFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::findNextTextFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::revertToFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):
* rendering/SimpleLineLayoutTextFragmentIterator.h:
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isLastInRenderer):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isLineBreak):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isEmpty):
(WebCore::SimpleLineLayout::TextFragmentIterator::isSoftLineBreak):
(WebCore::SimpleLineLayout::TextFragmentIterator::isHardLineBreak):
(WebCore::SimpleLineLayout::TextFragmentIterator::isLineBreak): Deleted.
LayoutTests:
Test output changes in 2 different ways:
1. Repositioned RenderLineBreak elements. (1px wide <br> is the result of integral pixel snapping)
2. Removed empty content (<br>).
Reviewed by Antti Koivisto.
* fast/text/simple-line-with-br-expected.html: Added.
* fast/text/simple-line-with-br.html: Added.
* platform/mac-mavericks/fast/parser/open-comment-in-textarea-expected.txt:
* platform/mac-mavericks/http/tests/navigation/javascriptlink-frames-expected.txt:
* platform/mac/editing/pasteboard/5761530-1-expected.txt: Added.
* platform/mac/fast/css/text-overflow-ellipsis-bidi-expected.txt:
* platform/mac/fast/dom/focus-contenteditable-expected.txt:
* platform/mac/fast/forms/range/slider-padding-expected.txt: Added.
* platform/mac/fast/forms/textarea-scroll-height-expected.txt:
* platform/mac/fast/parser/open-comment-in-textarea-expected.txt:
* platform/mac/fast/text/international/bidi-layout-across-linebreak-expected.txt:
* platform/mac/fast/text/svg-font-face-with-kerning-expected.txt: Added.
* platform/mac/http/tests/navigation/javascriptlink-frames-expected.txt:
* platform/mac/http/tests/navigation/postredirect-basic-expected.txt:
* platform/mac/http/tests/navigation/postredirect-goback1-expected.txt:
* platform/mac/printing/single-line-must-not-be-split-into-two-pages-expected.txt:
* platform/mac/svg/wicd/test-rightsizing-b-expected.txt:
* platform/mac/tables/mozilla/bugs/bug106795-expected.txt:
* platform/mac/tables/mozilla/bugs/bug1224-expected.txt:
* platform/mac/tables/mozilla/bugs/bug131020-expected.txt:
* platform/mac/tables/mozilla/bugs/bug131020_iframe-expected.txt:
* platform/mac/tables/mozilla/bugs/bug1430-expected.txt:
* platform/mac/tables/mozilla/bugs/bug16252-expected.txt:
* platform/mac/tables/mozilla/bugs/bug19599-expected.txt:
* platform/mac/tables/mozilla/bugs/bug20579-expected.txt:
* platform/mac/tables/mozilla/bugs/bug32205-3-expected.txt:
* platform/mac/tables/mozilla/bugs/bug82946-2-expected.txt:
* platform/mac/tables/mozilla/bugs/bug92143-expected.txt:
* platform/mac/tables/mozilla/marvin/tables_cellpadding-expected.txt:
* platform/mac/tables/mozilla/marvin/tables_cellspacing-expected.txt:
* platform/mac/tables/mozilla/other/wa_table_thtd_rowspan-expected.txt:
* platform/mac/tables/mozilla_expected_failures/bugs/bug1262-expected.txt:
* platform/mac/tables/mozilla_expected_failures/bugs/bug56024-expected.txt:
* platform/mac/tables/mozilla_expected_failures/other/test4-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@182620 268f45cc-cd09-0410-ab3c-d52691b4dbfc
51 files changed