Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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: Canonical link: https://commits.webkit.org/161618@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182620 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
952 additions
and 568 deletions.
- +50 −0 LayoutTests/ChangeLog
- +40 −0 LayoutTests/fast/text/simple-line-with-br-expected.html
- +38 −0 LayoutTests/fast/text/simple-line-with-br.html
- +1 −4 LayoutTests/platform/mac-mavericks/fast/parser/open-comment-in-textarea-expected.txt
- +0 −1 LayoutTests/platform/mac-mavericks/http/tests/navigation/javascriptlink-frames-expected.txt
- +3 −0 LayoutTests/platform/mac/editing/pasteboard/5761530-1-expected.txt
- +1 −1 LayoutTests/platform/mac/fast/css/text-overflow-ellipsis-bidi-expected.txt
- +1 −1 LayoutTests/platform/mac/fast/dom/focus-contenteditable-expected.txt
- +16 −0 LayoutTests/platform/mac/fast/forms/range/slider-padding-expected.txt
- +0 −16 LayoutTests/platform/mac/fast/forms/textarea-scroll-height-expected.txt
- +1 −4 LayoutTests/platform/mac/fast/parser/open-comment-in-textarea-expected.txt
- +1 −1 LayoutTests/platform/mac/fast/text/international/bidi-layout-across-linebreak-expected.txt
- +14 −0 LayoutTests/platform/mac/fast/text/svg-font-face-with-kerning-expected.txt
- +0 −1 LayoutTests/platform/mac/http/tests/navigation/javascriptlink-frames-expected.txt
- +5 −5 LayoutTests/platform/mac/http/tests/navigation/postredirect-basic-expected.txt
- +5 −5 LayoutTests/platform/mac/http/tests/navigation/postredirect-goback1-expected.txt
- +400 −400 LayoutTests/platform/mac/printing/single-line-must-not-be-split-into-two-pages-expected.txt
- +1 −1 LayoutTests/platform/mac/svg/wicd/test-rightsizing-b-expected.txt
- +2 −2 LayoutTests/platform/mac/tables/mozilla/bugs/bug106795-expected.txt
- +2 −2 LayoutTests/platform/mac/tables/mozilla/bugs/bug1224-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug131020-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug131020_iframe-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug1430-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug16252-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug19599-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug20579-expected.txt
- +3 −3 LayoutTests/platform/mac/tables/mozilla/bugs/bug32205-3-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug82946-2-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/bugs/bug92143-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/marvin/tables_cellpadding-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla/marvin/tables_cellspacing-expected.txt
- +11 −11 LayoutTests/platform/mac/tables/mozilla/other/wa_table_thtd_rowspan-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/bug1262-expected.txt
- +1 −1 LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/bug56024-expected.txt
- +2 −2 LayoutTests/platform/mac/tables/mozilla_expected_failures/other/test4-expected.txt
- +87 −0 Source/WebCore/ChangeLog
- +5 −1 Source/WebCore/editing/TextIterator.cpp
- +3 −4 Source/WebCore/rendering/RenderBlock.h
- +16 −3 Source/WebCore/rendering/RenderBlockFlow.cpp
- +1 −0 Source/WebCore/rendering/RenderBlockFlow.h
- +37 −0 Source/WebCore/rendering/RenderLineBreak.cpp
- +1 −0 Source/WebCore/rendering/RenderLineBreak.h
- +8 −8 Source/WebCore/rendering/RenderText.cpp
- +80 −37 Source/WebCore/rendering/SimpleLineLayout.cpp
- +9 −12 Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp
- +0 −1 Source/WebCore/rendering/SimpleLineLayoutFlowContents.h
- +12 −7 Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
- +37 −8 Source/WebCore/rendering/SimpleLineLayoutResolver.cpp
- +11 −0 Source/WebCore/rendering/SimpleLineLayoutResolver.h
- +20 −10 Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp
- +16 −5 Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test that text content with <br> works fine with simple line layout.</title> | ||
</head> | ||
<body> | ||
<script> | ||
function injectTextNodes(container, style) | ||
{ | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode(" ")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode("This tests")); | ||
container.appendChild(document.createTextNode(" ")); | ||
container.appendChild(document.createTextNode("line breaking")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode(" with ")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode("multiple ")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode("renderers.")); | ||
container.style.cssText = style; | ||
document.body.appendChild(container); | ||
} | ||
|
||
if (window.internals) | ||
internals.settings.setSimpleLineLayoutEnabled(false) | ||
injectTextNodes(document.createElement("div")); | ||
injectTextNodes(document.createElement("div"), "width: 0px"); | ||
injectTextNodes(document.createElement("div"), "width: 10px"); | ||
injectTextNodes(document.createElement("div"), "width: 100px"); | ||
injectTextNodes(document.createElement("pre")); | ||
injectTextNodes(document.createElement("pre"), "white-space: pre-wrap"); | ||
injectTextNodes(document.createElement("pre"), "white-space: pre-wrap; width: 100px"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test that text content with <br> works fine with simple line layout.</title> | ||
</head> | ||
<body> | ||
<script> | ||
function injectTextNodes(container, style) | ||
{ | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode(" ")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode("This tests")); | ||
container.appendChild(document.createTextNode(" ")); | ||
container.appendChild(document.createTextNode("line breaking")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode(" with ")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode("multiple ")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createElement("br")); | ||
container.appendChild(document.createTextNode("renderers.")); | ||
container.style.cssText = style; | ||
document.body.appendChild(container); | ||
} | ||
|
||
injectTextNodes(document.createElement("div")); | ||
injectTextNodes(document.createElement("div"), "width: 0px"); | ||
injectTextNodes(document.createElement("div"), "width: 10px"); | ||
injectTextNodes(document.createElement("div"), "width: 100px"); | ||
injectTextNodes(document.createElement("pre")); | ||
injectTextNodes(document.createElement("pre"), "white-space: pre-wrap"); | ||
injectTextNodes(document.createElement("pre"), "white-space: pre-wrap; width: 100px"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,3 @@ | ||
This tests to see that tabs are put into tab spans when they are copied individually. The pasted tab should be inside of a tab span, not a style span. To run the test manually, paste and then inspect the editable region, and ensure that there is a tab span at the beginning of the editable div. | ||
|
||
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space:pre;"> </span>xxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,16 @@ | ||
layer at (0,0) size 800x600 | ||
RenderView at (0,0) size 800x600 | ||
layer at (0,0) size 800x600 | ||
RenderBlock {HTML} at (0,0) size 800x600 | ||
RenderBody {BODY} at (8,8) size 784x579 | ||
RenderBlock (anonymous) at (0,0) size 784x18 | ||
RenderText {#text} at (0,0) size 330x18 | ||
text run at (0,0) width 330: "This tests that the slider control considers padding. " | ||
RenderBR {BR} at (329,14) size 1x0 | ||
RenderBlock {DIV} at (0,18) size 784x39 [bgcolor=#ADD8E6] | ||
RenderSlider {INPUT} at (2,2) size 100x35 [color=#909090] [bgcolor=#FFFFFF] | ||
RenderFlexibleBox {DIV} at (10,10) size 80x15 | ||
RenderBlock {DIV} at (0,0) size 80x15 | ||
RenderBlock {DIV} at (0,0) size 15x15 | ||
RenderText {#text} at (0,0) size 0x0 | ||
RenderBlock {PRE} at (0,70) size 784x0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,14 @@ | ||
layer at (0,0) size 800x600 | ||
RenderView at (0,0) size 800x600 | ||
layer at (0,0) size 800x600 | ||
RenderBlock {HTML} at (0,0) size 800x600 | ||
RenderBody {BODY} at (8,8) size 784x584 | ||
RenderBlock {DIV} at (0,0) size 230x90 | ||
RenderText {#text} at (0,1) size 207x34 | ||
text run at (0,1) width 207: "This is a test of kerning when" | ||
text run at (0,19) width 157: "using SVG web fonts. " | ||
RenderBR {BR} at (156,32) size 1x0 | ||
RenderBR {BR} at (0,37) size 0x16 | ||
RenderText {#text} at (0,55) size 230x34 | ||
text run at (0,55) width 230: "Wow, The V/A Team's Task Was" | ||
text run at (0,73) width 85: "on Youtube." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.