Use background color for GraphicsLayers when applicable
https://bugs.webkit.org/show_bug.cgi?id=103786

Source/WebCore:

Updated RenderLayerBacking to call GraphicsLayer::setContentsToBackgroundColor when the following conditions take place:
1. The layer doesn't paint its own content, other than background/decoration.
2. There are no borders or other box decorations (border radius, borders, outline, shadow etc.)
3. The image has only a background color, and no background image.
4. background-composite is set to source-over, and background-clip is anything apart from text.
5. The port supports setContentsToBackgroundColor.

This allows any implementation of GraphicsLayer that supports setContentsToBackgroundColor to avoid allocating a backing store
for that layer, but instead draw that solid color directly.
In addition to setting the background color, the layer's contentsRect needs to be adjusted, since the default contents rect of
a layer is not always equivalent to the rect where the background is supposed to be painted, which is derived from the box's
background-clip property.

Patch by No'am Rosenthal <noam@webkit.org> on 2012-12-08
Reviewed by Simon Fraser.

Tests: compositing/background-color/background-color-alpha.html
       compositing/background-color/background-color-change-to-text.html
       compositing/background-color/background-color-composite.html
       compositing/background-color/background-color-container.html
       compositing/background-color/background-color-content-clip.html
       compositing/background-color/background-color-padding-change.html
       compositing/background-color/background-color-padding-clip.html
       compositing/background-color/background-color-simple.html
       compositing/background-color/background-color-text-change.html
       compositing/background-color/background-color-text-clip.html

* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::supportsBackgroundColorContent):
    Allows different implementation of GraphicsLayer to identify whether they implement setContentsToBackgroundColor.
    Currently only the MAC implementation and TextureMapper falls under that category.

* rendering/RenderBox.h:
(WebCore::RenderBox::paddingBoxRect):
    Added paddingBoxRect to compliment borderBoxRect and contentsBoxRect. paddingBoxRect corresponds to
    background-clip: padding.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
    Update the background color if needed, for every configuration change.
    This should accomodate the old behavior for full-screen, while enabling background color changes for other layers.

(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
    Move the contentsRect logic to updateContentsRect.

(WebCore::RenderLayerBacking::updateContentsRect):
    Use the background box when directly compositing backgrounds.

(WebCore::RenderLayerBacking::updateBackgroundColor):
    Set the background color if applicable, otherwise set to trasnparent and clear.
    This was not needed in the past because background colors were only used for the special case of full-screen.

(WebCore::supportsDirectBoxDecorationsComposition):
    Helper function to determine whether a particular background can be directly composited. Right now only
    background color can be composited, and only if the GraphicsLayer implementation supports background colors.
    Also we don't yet support background-clip: text and any background-composite other than source-over.

(WebCore::RenderLayerBacking::paintsBoxDecorations):
    Apply the new supportsDirectBoxDecorationsComposition logic.

(WebCore::RenderLayerBacking::contentsBox):
    Remove unnecessary local variable.

(WebCore::backgroundRectForBox):
(WebCore::RenderLayerBacking::backgroundBox):
    Figure out the correct rect for the GraphicsLayer's contentsRect, based on the renderer's backgroundClip.
    The rectangle has to be adjusted based on the composited layer offset, and snapped to an IntRect as
    GraphicsLayer::contentsRect expects snapped pixels.

LayoutTests:

Created new tests for composited background colors, update existing tests that are affected by the change,
and created platform-specific overrides for Chromium, since it does not yet support composited background
colors.

Patch by No'am Rosenthal <noam@webkit.org> on 2012-12-08
Reviewed by Simon Fraser.

* compositing/background-color/background-color-alpha-expected.html: Added.
* compositing/background-color/background-color-alpha.html: Added.
* compositing/background-color/background-color-change-to-text-expected.html: Added.
* compositing/background-color/background-color-change-to-text.html: Added.
* compositing/background-color/background-color-composite-expected.html: Added.
* compositing/background-color/background-color-composite.html: Added.
* compositing/background-color/background-color-container-expected.html: Added.
* compositing/background-color/background-color-container.html: Added.
* compositing/background-color/background-color-content-clip-expected.html: Added.
* compositing/background-color/background-color-content-clip.html: Added.
* compositing/background-color/background-color-padding-change-expected.html: Added.
* compositing/background-color/background-color-padding-change.html: Added.
* compositing/background-color/background-color-padding-clip-expected.html: Added.
* compositing/background-color/background-color-padding-clip.html: Added.
* compositing/background-color/background-color-simple-expected.html: Added.
* compositing/background-color/background-color-simple.html: Added.
* compositing/background-color/background-color-text-change-expected.html: Added.
* compositing/background-color/background-color-text-change.html: Added.
* compositing/background-color/background-color-text-clip-expected.html: Added.
* compositing/background-color/background-color-text-clip.html: Added.
        Added new tests for the specific functionality added, with the edge cases regarding composited
        backgrounds.

* compositing/backing/no-backing-for-clip-expected.txt:
* compositing/backing/no-backing-for-clip-overlap-expected.txt:
* compositing/backing/no-backing-for-perspective-expected.txt:
* compositing/columns/composited-in-paginated-expected.txt:
* compositing/geometry/ancestor-overflow-change-expected.txt:
* compositing/geometry/bounds-ignores-hidden-composited-descendant-expected.txt:
* compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt:
* compositing/geometry/clip-expected.txt:
* compositing/geometry/composited-in-columns-expected.txt:
* compositing/geometry/flipped-writing-mode-expected.txt:
* compositing/geometry/layer-due-to-layer-children-deep-switch-expected.txt:
* compositing/geometry/limit-layer-bounds-fixed-positioned-expected.txt:
* compositing/geometry/limit-layer-bounds-overflow-root-expected.txt:
* compositing/geometry/limit-layer-bounds-positioned-expected.txt:
* compositing/geometry/limit-layer-bounds-positioned-transition-expected.txt:
* compositing/geometry/limit-layer-bounds-transformed-expected.txt:
* compositing/geometry/limit-layer-bounds-transformed-overflow-expected.txt:
* compositing/geometry/preserve-3d-switching-expected.txt:
* compositing/iframes/become-composited-nested-iframes-expected.txt:
* compositing/iframes/become-overlapped-iframe-expected.txt:
* compositing/iframes/composited-parent-iframe-expected.txt:
* compositing/iframes/connect-compositing-iframe-delayed-expected.txt:
* compositing/iframes/connect-compositing-iframe-expected.txt:
* compositing/iframes/connect-compositing-iframe2-expected.txt:
* compositing/iframes/connect-compositing-iframe3-expected.txt:
* compositing/iframes/enter-compositing-iframe-expected.txt:
* compositing/iframes/iframe-resize-expected.txt:
* compositing/iframes/invisible-nested-iframe-hide-expected.txt:
* compositing/iframes/invisible-nested-iframe-show-expected.txt:
* compositing/iframes/overlapped-iframe-expected.txt:
* compositing/iframes/overlapped-iframe-iframe-expected.txt:
* compositing/iframes/page-cache-layer-tree-expected.txt:
* compositing/iframes/scrolling-iframe-expected.txt:
* compositing/layer-creation/animation-overlap-with-children-expected.txt:
* compositing/layer-creation/fixed-position-and-transform-expected.txt:
* compositing/layer-creation/fixed-position-under-transform-expected.txt:
* compositing/layer-creation/no-compositing-for-preserve-3d-expected.txt:
* compositing/layer-creation/overflow-scroll-overlap-expected.txt:
* compositing/layer-creation/overlap-animation-expected.txt:
* compositing/layer-creation/overlap-child-layer-expected.txt:
* compositing/layer-creation/overlap-clipping-expected.txt:
* compositing/layer-creation/overlap-transformed-and-clipped-expected.txt:
* compositing/layer-creation/overlap-transformed-layer-expected.txt:
* compositing/layer-creation/overlap-transforms-expected.txt:
* compositing/layer-creation/scroll-partial-update-expected.txt:
* compositing/layer-creation/spanOverlapsCanvas-expected.txt:
* compositing/layer-creation/stacking-context-overlap-expected.txt:
* compositing/layer-creation/stacking-context-overlap-nested-expected.txt:
* compositing/layer-creation/translatez-overlap-expected.txt:
* compositing/overflow-trumps-transform-style-expected.txt:
* compositing/overflow/clip-descendents-expected.txt:
* compositing/plugins/no-backing-store-expected.txt:
* compositing/rtl/rtl-absolute-expected.txt:
* compositing/rtl/rtl-absolute-overflow-expected.txt:
* compositing/rtl/rtl-absolute-overflow-scrolled-expected.txt:
* compositing/rtl/rtl-fixed-expected.txt:
* compositing/rtl/rtl-fixed-overflow-expected.txt:
* compositing/rtl/rtl-relative-expected.txt:
* compositing/tiled-layers-hidpi-expected.txt:
* compositing/visible-rect/2d-transformed-expected.txt:
* compositing/visible-rect/3d-transform-style-expected.txt:
* compositing/visible-rect/3d-transformed-expected.txt:
* compositing/visible-rect/animated-expected.txt:
* compositing/visible-rect/animated-from-none-expected.txt:
* compositing/visible-rect/clipped-by-viewport-expected.txt:
* compositing/visible-rect/clipped-visible-rect-expected.txt:
* compositing/visible-rect/iframe-and-layers-expected.txt:
* compositing/visible-rect/nested-transform-expected.txt:
* compositing/visible-rect/scrolled-expected.txt:
* css3/filters/filtered-compositing-descendant-expected.txt:
        Updated existing tests that now print different layer-tree results.

* platform/chromium/compositing/backing/no-backing-for-clip-expected.txt: Copied from LayoutTests/compositing/backing/no-backing-for-clip-expected.txt.
* platform/chromium/compositing/backing/no-backing-for-clip-overlap-expected.txt: Copied from LayoutTests/compositing/backing/no-backing-for-clip-overlap-expected.txt.
* platform/chromium/compositing/backing/no-backing-for-perspective-expected.txt: Copied from LayoutTests/compositing/backing/no-backing-for-perspective-expected.txt.
* platform/chromium/compositing/columns/composited-in-paginated-expected.txt: Copied from LayoutTests/compositing/columns/composited-in-paginated-expected.txt.
* platform/chromium/compositing/geometry/ancestor-overflow-change-expected.txt: Copied from LayoutTests/compositing/geometry/ancestor-overflow-change-expected.txt.
* platform/chromium/compositing/geometry/bounds-ignores-hidden-composited-descendant-expected.txt: Copied from LayoutTests/compositing/geometry/bounds-ignores-hidden-composited-descendant-expected.txt.
* platform/chromium/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt: Copied from LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt.
* platform/chromium/compositing/geometry/clip-expected.txt: Copied from LayoutTests/compositing/geometry/clip-expected.txt.
* platform/chromium/compositing/geometry/composited-in-columns-expected.txt: Copied from LayoutTests/compositing/geometry/composited-in-columns-expected.txt.
* platform/chromium/compositing/geometry/flipped-writing-mode-expected.txt: Copied from LayoutTests/compositing/geometry/flipped-writing-mode-expected.txt.
* platform/chromium/compositing/geometry/layer-due-to-layer-children-deep-switch-expected.txt: Copied from LayoutTests/compositing/geometry/layer-due-to-layer-children-deep-switch-expected.txt.
* platform/chromium/compositing/geometry/limit-layer-bounds-overflow-root-expected.txt: Copied from LayoutTests/compositing/geometry/limit-layer-bounds-overflow-root-expected.txt.
* platform/chromium/compositing/geometry/limit-layer-bounds-positioned-expected.txt: Copied from LayoutTests/compositing/geometry/limit-layer-bounds-positioned-expected.txt.
* platform/chromium/compositing/geometry/limit-layer-bounds-positioned-transition-expected.txt: Copied from LayoutTests/compositing/geometry/limit-layer-bounds-positioned-transition-expected.txt.
* platform/chromium/compositing/geometry/limit-layer-bounds-transformed-expected.txt: Copied from LayoutTests/compositing/geometry/limit-layer-bounds-transformed-expected.txt.
* platform/chromium/compositing/geometry/preserve-3d-switching-expected.txt: Copied from LayoutTests/compositing/geometry/preserve-3d-switching-expected.txt.
* platform/chromium/compositing/iframes/invisible-nested-iframe-hide-expected.txt: Copied from LayoutTests/compositing/iframes/invisible-nested-iframe-hide-expected.txt.
* platform/chromium/compositing/layer-creation/fixed-position-and-transform-expected.txt: Copied from LayoutTests/compositing/layer-creation/fixed-position-and-transform-expected.txt.
* platform/chromium/compositing/layer-creation/fixed-position-under-transform-expected.txt: Copied from LayoutTests/compositing/layer-creation/fixed-position-under-transform-expected.txt.
* platform/chromium/compositing/layer-creation/no-compositing-for-preserve-3d-expected.txt: Copied from LayoutTests/compositing/layer-creation/no-compositing-for-preserve-3d-expected.txt.
* platform/chromium/compositing/layer-creation/overlap-animation-expected.txt: Copied from LayoutTests/compositing/layer-creation/overlap-animation-expected.txt.
* platform/chromium/compositing/layer-creation/overlap-child-layer-expected.txt: Copied from LayoutTests/compositing/layer-creation/overlap-child-layer-expected.txt.
* platform/chromium/compositing/layer-creation/overlap-clipping-expected.txt: Copied from LayoutTests/compositing/layer-creation/overlap-clipping-expected.txt.
* platform/chromium/compositing/layer-creation/overlap-transformed-and-clipped-expected.txt: Copied from LayoutTests/compositing/layer-creation/overlap-transformed-and-clipped-expected.txt.
* platform/chromium/compositing/layer-creation/overlap-transformed-layer-expected.txt: Copied from LayoutTests/compositing/layer-creation/overlap-transformed-layer-expected.txt.
* platform/chromium/compositing/layer-creation/overlap-transforms-expected.txt: Copied from LayoutTests/compositing/layer-creation/overlap-transforms-expected.txt.
* platform/chromium/compositing/layer-creation/scroll-partial-update-expected.txt: Copied from LayoutTests/compositing/layer-creation/scroll-partial-update-expected.txt.
* platform/chromium/compositing/layer-creation/stacking-context-overlap-expected.txt: Copied from LayoutTests/compositing/layer-creation/stacking-context-overlap-expected.txt.
* platform/chromium/compositing/layer-creation/stacking-context-overlap-nested-expected.txt: Copied from LayoutTests/compositing/layer-creation/stacking-context-overlap-nested-expected.txt.
* platform/chromium/compositing/layer-creation/translatez-overlap-expected.txt: Copied from LayoutTests/compositing/layer-creation/translatez-overlap-expected.txt.
* platform/chromium/compositing/overflow-trumps-transform-style-expected.txt: Copied from LayoutTests/compositing/overflow-trumps-transform-style-expected.txt.
* platform/chromium/compositing/rtl/rtl-absolute-expected.txt: Copied from LayoutTests/compositing/rtl/rtl-absolute-expected.txt.
* platform/chromium/compositing/rtl/rtl-absolute-overflow-expected.txt: Copied from LayoutTests/compositing/rtl/rtl-absolute-overflow-expected.txt.
* platform/chromium/compositing/rtl/rtl-absolute-overflow-scrolled-expected.txt: Copied from LayoutTests/compositing/rtl/rtl-absolute-overflow-scrolled-expected.txt.
* platform/chromium/compositing/rtl/rtl-fixed-expected.txt: Copied from LayoutTests/compositing/rtl/rtl-fixed-expected.txt.
* platform/chromium/compositing/rtl/rtl-fixed-overflow-expected.txt: Copied from LayoutTests/compositing/rtl/rtl-fixed-overflow-expected.txt.
* platform/chromium/compositing/rtl/rtl-relative-expected.txt: Copied from LayoutTests/compositing/rtl/rtl-relative-expected.txt.
* platform/chromium/css3/filters/filtered-compositing-descendant-expected.txt: Copied from LayoutTests/css3/filters/filtered-compositing-descendant-expected.txt.
        Create chromium-specific results since chromium does not yet support setContentsToBackgroundColor.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137051 268f45cc-cd09-0410-ab3c-d52691b4dbfc