Text decorations do not contribute to visual overflow
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2014 00:45:52 +0000 (00:45 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2014 00:45:52 +0000 (00:45 +0000)
commit4c7820f41bfd93f6da37b20031c071dc837ffec9
tree5aa95bd2648294987882791bb8160b120b09fd93
parente01a3e4216f68614b48133aa6097e04723da06a8
Text decorations do not contribute to visual overflow
https://bugs.webkit.org/show_bug.cgi?id=132773

Patch by Myles C. Maxfield <litherum@gmail.com> on 2014-05-19
Reviewed by Antti Koivisto.

Source/WebCore:
This patch creates a function, visualOverflowForDecorations, which computes
how much visual overflow to add around a text box due to text decorations. Most of the time,
text decorations are fully contained within the text box, so the result is usually 0.

This function exists within style/InlineTextBoxStyle.cpp, which is an added file. This is
so that it can be called from setLogicalWidthForTextRun() inside RenderBlockLineLayout.cpp
and from RenderStyle::changeAffectsVisualOverflow(). The former case passes in the full
InlineTextBox and the latter case just passes in a RenderStyle (because the InlineTextBox
is unavailable.)

This patch also modifies RenderTableSection::spannedColumns() to fix an off-by-one error
that was causing table borders to not be drawn when they existed right on the edge of
a repaint rect.

Tests: fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html
Tests: fast/repaint/border-collapse-table-off-by-one-expected.html

* WebCore.vcxproj/WebCore.vcxproj: Adding reference to new InlineTextBoxStyle.cpp file
* WebCore.vcxproj/WebCore.vcxproj.filters: Adding reference to new InlineTextBoxStyle files
* WebCore.xcodeproj/project.pbxproj: Adding reference to new InlineTextBoxStyle files
* rendering/InlineTextBox.cpp:
(WebCore::computeUnderlineOffset): Moved to InlineTextBox.cpp
(WebCore::getWavyStrokeParameters): Moved to InlineTextBox.cpp
(WebCore::InlineTextBox::paintDecoration): Update to use newly refactored functions
* rendering/RenderBlockLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun): Call visualOverflowForDecorations()
* rendering/RenderTableSection.cpp:
* rendering/RenderTableSelection.cpp: Fix off-by-one error when the boundary of a repaint
rect lies exactly on top of a table column position
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeAffectsVisualOverflow): Inspects shadows and text decorations
(WebCore::RenderStyle::changeRequiresLayout): Calls changeAffectsVisualOverflow()
(WebCore::RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline): Moved code from here
to changeAffectsVisualOverflow().
* rendering/style/RenderStyle.h: Function signature
* style/InlineTextBoxStyle.cpp: Added.
(WebCore::computeUnderlineOffset): Moved from InlineTextBox.cpp
(WebCore::getWavyStrokeParameters): Moved from InlineTextBox.cpp
(WebCore::extendIntToFloat): Convenience function for dealing with the fact that
underline bounding boxes use floats and GlyphOverflow uses ints
(WebCore::visualOverflowForDecorations): Given
vertical overflow bounds, possibly extend those to include location of
decorations.
* style/InlineTextBoxStyle.h: Added. Function signatures.
(WebCore::textDecorationStrokeThickness): Refactored from InlineTextBox.cpp
(WebCore::wavyOffsetFromDecoration): Refactored from InlineTextBox.cpp
* platform/graphics/Font.h:
(WebCore::GlyphOverflow::isEmpty): Convenience function
(WebCore::GlyphOverflow::extendTo): Convenience function

LayoutTests:
This first test makes sure that repaint rects are extended to include text decorations that may
lie outside of the text layout rects. It compares text with an underline to text that has
had underline applied to it in a timer.

The second test triggers an off-by-one error in collapsed table borders where a border was not
being drawn if it lay right on top of a repaint rect.

* fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg: Added. This font has a
descent of 0 (so it will not intersect underlines).
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html: Added.
Apply the underline without any timeout.
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html: Added.
Apply the underline with a timeout.
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-removed-expected.html: Added.
Draw text without decorations.
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-removed.html: Added.
Draw text with decorations which contribute to overflow, then remove those decorations on a timer.
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-altered-expected.html: Added.
Draw text as if the final state of the decorations had always existed.
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-altered.html: Added.
Make sure that modifying decorations that contribute to overflow redraw properly.
* fast/repaint/border-collapse-table-off-by-one-expected.html: Added.
* fast/repaint/border-collapse-table-off-by-one.html: Added. Trigger the off-by-one error in
RenderTableSection.cpp

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-altered-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-altered.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-removed-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-removed.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html [new file with mode: 0644]
LayoutTests/fast/repaint/border-collapse-table-off-by-one-expected.html [new file with mode: 0644]
LayoutTests/fast/repaint/border-collapse-table-off-by-one.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/Font.h
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/RenderTableSection.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/style/InlineTextBoxStyle.cpp [new file with mode: 0644]
Source/WebCore/style/InlineTextBoxStyle.h [new file with mode: 0644]