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: http://svn.webkit.org/repository/webkit/trunk@169089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed