2011-04-19 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Apr 2011 05:13:32 +0000 (05:13 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Apr 2011 05:13:32 +0000 (05:13 +0000)
commite5821d4f573e53ddf549c3744ccab170bb8ab3cb
tree424660fbb1dc28b3ace01206271efe1ad4df7b74
parent943906050e52f5ec065f2310117feaa67d5131c7
2011-04-19  Simon Fraser  <simon.fraser@apple.com>

        Reviewed by Dan Bernstein.

        background color of elements with border-radius shows around outer edge of border at corners
        https://bugs.webkit.org/show_bug.cgi?id=21819

        When drawing a background followed by a border with the same rounded
        clip, some border color leaks out because of antialiasing.

        Fix this by using two different strategies depending on the colors.
        If the border is opaque on all sides, we can inset the background by
        a device pixel. If not, then we have to draw the unclipped background
        and border into a transparency layer, and then clip that.

        A futher possible solution is mentioned in a comment in
        determineBackgroundBleedAvoidance() but not yet implemented.

        Also don't try to paint shadows with zero offset, spread and blur.

        Test: fast/backgrounds/background-leakage.html,
              fast/backgrounds/background-leakage-transforms.html

        * rendering/RenderBoxModelObject.h:
        Add a BackgroundBleedAvoidance enum with a value for each
        strategy.
        * rendering/RenderBoxModelObject.cpp:
        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
        Pass BackgroundBleedAvoidance, bail early if the border rect is empty.
        If using the transparency layer solution, don't bother to clip
        to the rounded rect for the background. If the strategy is to
        shrink the background, do that.
        (WebCore::BorderEdge::BorderEdge):
        (WebCore::BorderEdge::obscuresBackgroundEdge):
        Helper method to determine if this border side will totally
        obscured by the border edge, allowing us to inset it.
        (WebCore::RenderBoxModelObject::paintOneBorderSide):
        Pass BackgroundBleedAvoidance through.
        (WebCore::RenderBoxModelObject::paintBorderSides):
        Ditto.
        (WebCore::RenderBoxModelObject::paintTranslucentBorderSides):
        Ditto.
        (WebCore::RenderBoxModelObject::paintBorder):
        Fill BorderEdges using getBorderEdgeInfo now.
        Don't clip to the rounded border if we are using the
        transparency layer solution.
        (WebCore::RenderBoxModelObject::drawBoxSideFromPath):
        Pass bleedAvoidance through, and use it for double borders.
        (WebCore::RenderBoxModelObject::getBorderEdgeInfo):
        Helper to fill in the BorderEdge array.
        (WebCore::RenderBoxModelObject::borderObscuresBackgroundEdge):
        Used to determine if we can use the background shrinkage solution.
        (WebCore::RenderBoxModelObject::paintBoxShadow):
        Don't paint shadows that should not be visible.

        * rendering/RenderBox.h:
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::paintRootBoxFillLayers):
        Pass BackgroundBleedNone for the root box.

        (WebCore::RenderBox::determineBackgroundBleedAvoidance):
        Determine which bleed strategy we can use.

        (WebCore::RenderBox::paintBoxDecorationsWithSize):
        Based on the bleedAvoidance, make a transparency layer
        which will be clipped to the rounded border outside edge,
        and pass bleedAvoidance to the background and border-painting
        methods.
        (WebCore::RenderBox::paintMaskImages):
        Use BackgroundBleedNone.
        (WebCore::RenderBox::paintFillLayers):
        (WebCore::RenderBox::paintFillLayer):
        Pass bleedAvoidance through.

        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::paintFillLayer):
        (WebCore::InlineFlowBox::paintBoxDecorations):
        Pass BackgroundBleedNone. At some point we may want to do the right
        thing for split inlines.

        * rendering/RenderFieldset.cpp:
        (WebCore::RenderFieldset::paintBoxDecorations):
        * rendering/RenderTableCell.cpp:
        (WebCore::RenderTableCell::paintBackgroundsBehindCell):
        Pass BackgroundBleedNone.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@84341 268f45cc-cd09-0410-ab3c-d52691b4dbfc
91 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/backgrounds/background-leakage-transforms.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/background-leakage-expected.checksum
LayoutTests/platform/mac/fast/backgrounds/background-leakage-expected.png
LayoutTests/platform/mac/fast/backgrounds/background-leakage-transforms-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/background-leakage-transforms-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/background-leakage-transforms-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/borders/border-radius-circle-expected.checksum
LayoutTests/platform/mac/fast/borders/border-radius-circle-expected.png
LayoutTests/platform/mac/fast/borders/border-radius-huge-assert-expected.checksum
LayoutTests/platform/mac/fast/borders/border-radius-huge-assert-expected.png
LayoutTests/platform/mac/fast/borders/border-radius-wide-border-01-expected.checksum
LayoutTests/platform/mac/fast/borders/border-radius-wide-border-01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusAllStylesAllCorners-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusAllStylesAllCorners-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusArcs01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusArcs01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDashed01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDashed01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDashed02-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDashed02-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDashed03-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDashed03-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDotted01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDotted01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDotted02-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDotted02-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDotted03-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDotted03-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDouble01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDouble01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDouble02-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDouble02-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusDouble03-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusDouble03-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusGroove01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusGroove01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusGroove02-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusGroove02-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusInset01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusInset01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusInvalidColor-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusInvalidColor-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusOutset01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusOutset01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusRidge01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusRidge01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusSolid01-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusSolid01-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusSolid02-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusSolid02-expected.png
LayoutTests/platform/mac/fast/borders/borderRadiusSolid03-expected.checksum
LayoutTests/platform/mac/fast/borders/borderRadiusSolid03-expected.png
LayoutTests/platform/mac/fast/box-shadow/inset-expected.checksum
LayoutTests/platform/mac/fast/box-shadow/inset-expected.png
LayoutTests/platform/mac/fast/box-shadow/inset-with-extraordinary-radii-and-border-expected.checksum
LayoutTests/platform/mac/fast/box-shadow/inset-with-extraordinary-radii-and-border-expected.png
LayoutTests/platform/mac/fast/forms/basic-selects-expected.checksum
LayoutTests/platform/mac/fast/forms/basic-selects-expected.png
LayoutTests/platform/mac/fast/forms/menulist-clip-expected.checksum
LayoutTests/platform/mac/fast/forms/menulist-clip-expected.png
LayoutTests/platform/mac/fast/forms/menulist-narrow-width-expected.checksum
LayoutTests/platform/mac/fast/forms/menulist-narrow-width-expected.png
LayoutTests/platform/mac/fast/forms/menulist-option-wrap-expected.checksum
LayoutTests/platform/mac/fast/forms/menulist-option-wrap-expected.png
LayoutTests/platform/mac/fast/forms/menulist-restrict-line-height-expected.checksum
LayoutTests/platform/mac/fast/forms/menulist-restrict-line-height-expected.png
LayoutTests/platform/mac/fast/forms/menulist-separator-painting-expected.checksum
LayoutTests/platform/mac/fast/forms/menulist-separator-painting-expected.png
LayoutTests/platform/mac/fast/forms/menulist-style-color-expected.checksum
LayoutTests/platform/mac/fast/forms/menulist-style-color-expected.png
LayoutTests/platform/mac/fast/forms/select-baseline-expected.checksum
LayoutTests/platform/mac/fast/forms/select-baseline-expected.png
LayoutTests/platform/mac/fast/forms/select-empty-option-height-expected.checksum
LayoutTests/platform/mac/fast/forms/select-empty-option-height-expected.png
LayoutTests/platform/mac/fast/forms/select-style-expected.checksum
LayoutTests/platform/mac/fast/forms/select-style-expected.png
LayoutTests/platform/mac/fast/overflow/border-radius-clipping-expected.checksum
LayoutTests/platform/mac/fast/overflow/border-radius-clipping-expected.png
LayoutTests/platform/mac/fast/repaint/border-radius-repaint-expected.checksum
LayoutTests/platform/mac/fast/repaint/border-radius-repaint-expected.png
LayoutTests/platform/mac/fast/repaint/control-clip-expected.checksum
LayoutTests/platform/mac/fast/repaint/control-clip-expected.png
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderFieldset.cpp
Source/WebCore/rendering/RenderTableCell.cpp