Changeset 139750 in webkit


Ignore:
Timestamp:
Jan 15, 2013, 10:10:28 AM (12 years ago)
Author:
Simon Fraser
Message:

Allow tiled WKViews to have transparent backgrounds
https://bugs.webkit.org/show_bug.cgi?id=106400

Source/WebCore:

Reviewed by Anders Carlsson.

When WKViews were set to have transparent backgrounds, they still
obscured content behind the view, for several reasons.

First, when in tiled scrolling mode, WKView set the background
of its layer to opaque white. Fix by using the clearColor (effectively
removing the background color) if the view has a non-opaque background.

Second, RenderLayerBacking just looked at FrameViews's isTransparent()
when deciding to make TileCache tiles non-opaque, but it also needs to
consider FrameViews with a non-opaque base background color. The
same logic was necessary to avoid setting an opaque white background
color on the TileCache layer.

Finally, for views with non-opaque backgrounds, we don't want to display
linen, so RenderLayerCompositor::requiresOverhangAreasLayer() was changed
to return false in that case.

View transparency is not testable in layout tests.

  • page/FrameView.cpp:

(WebCore::FrameView::hasOpaqueBackground):

  • page/FrameView.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
(WebCore::RenderLayerBacking::updateBackgroundColor):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::requiresOverhangAreasLayer):

Source/WebKit2:

Reviewed by Anders Carlsson.

When WKViews were set to have transparent backgrounds, they still
obscured content behind the view, for several reasons.

First, when in tiled scrolling mode, WKView set the background
of its layer to opaque white. Fix by using the clearColor (effectively
removing the background color) if the view has a non-opaque background.

Second, RenderLayerBacking just looked at FrameViews's isTransparent()
when deciding to make TileCache tiles non-opaque, but it also needs to
consider FrameViews with a non-opaque base background color. The
same logic was necessary to avoid setting an opaque white background
color on the TileCache layer.

Finally, for views with non-opaque backgrounds, we don't want to display
linen, so RenderLayerCompositor::requiresOverhangAreasLayer() was changed
to return false in that case.

  • UIProcess/API/mac/WKView.mm:

(-[WKView updateLayer]):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139749 r139750  
     12013-01-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow tiled WKViews to have transparent backgrounds
     4        https://bugs.webkit.org/show_bug.cgi?id=106400
     5
     6        Reviewed by Anders Carlsson.
     7       
     8        When WKViews were set to have transparent backgrounds, they still
     9        obscured content behind the view, for several reasons.
     10       
     11        First, when in tiled scrolling mode, WKView set the background
     12        of its layer to opaque white. Fix by using the clearColor (effectively
     13        removing the background color) if the view has a non-opaque background.
     14       
     15        Second, RenderLayerBacking just looked at FrameViews's isTransparent()
     16        when deciding to make TileCache tiles non-opaque, but it also needs to
     17        consider FrameViews with a non-opaque base background color. The
     18        same logic was necessary to avoid setting an opaque white background
     19        color on the TileCache layer.
     20       
     21        Finally, for views with non-opaque backgrounds, we don't want to display
     22        linen, so RenderLayerCompositor::requiresOverhangAreasLayer() was changed
     23        to return false in that case.
     24       
     25        View transparency is not testable in layout tests.
     26
     27        * page/FrameView.cpp:
     28        (WebCore::FrameView::hasOpaqueBackground):
     29        * page/FrameView.h:
     30        * rendering/RenderLayerBacking.cpp:
     31        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
     32        (WebCore::RenderLayerBacking::updateBackgroundColor):
     33        * rendering/RenderLayerCompositor.cpp:
     34        (WebCore::RenderLayerCompositor::requiresOverhangAreasLayer):
     35
    1362013-01-15  Ojan Vafai  <ojan@chromium.org>
    237
  • trunk/Source/WebCore/page/FrameView.cpp

    r139691 r139750  
    23262326}
    23272327
     2328bool FrameView::hasOpaqueBackground() const
     2329{
     2330    return !m_isTransparent && !m_baseBackgroundColor.hasAlpha();
     2331}
     2332
    23282333Color FrameView::baseBackgroundColor() const
    23292334{
  • trunk/Source/WebCore/page/FrameView.h

    r139691 r139750  
    165165    bool isTransparent() const;
    166166    void setTransparent(bool isTransparent);
     167   
     168    // True if the FrameView is not transparent, and the base background color is opaque.
     169    bool hasOpaqueBackground() const;
    167170
    168171    Color baseBackgroundColor() const;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r139258 r139750  
    268268
    269269    if (m_isMainFrameRenderViewLayer) {
    270         bool isTransparent = false;
     270        bool hasOpaqueBackground = false;
    271271        if (FrameView* frameView = toRenderView(renderer())->frameView())
    272             isTransparent = frameView->isTransparent();
    273 
    274         m_graphicsLayer->setContentsOpaque(!isTransparent);
     272            hasOpaqueBackground = !frameView->hasOpaqueBackground();
     273
     274        m_graphicsLayer->setContentsOpaque(!hasOpaqueBackground);
    275275        m_graphicsLayer->setAppliesPageScale();
    276276    }
     
    11811181        if (!frameView->isTransparent()) {
    11821182            backgroundColor = frameView->documentBackgroundColor();
    1183             if (!backgroundColor.isValid() || backgroundColor.hasAlpha())
     1183            if (frameView->hasOpaqueBackground() && (!backgroundColor.isValid() || backgroundColor.hasAlpha()))
    11841184                backgroundColor = Color::white;
    11851185        }
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r139493 r139750  
    22242224
    22252225    // We do want a layer if we have a scrolling coordinator.
    2226     if (scrollingCoordinator())
     2226    if (scrollingCoordinator() && m_renderView->frameView()->hasOpaqueBackground())
    22272227        return true;
    22282228
  • trunk/Source/WebKit2/ChangeLog

    r139702 r139750  
     12013-01-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow tiled WKViews to have transparent backgrounds
     4        https://bugs.webkit.org/show_bug.cgi?id=106400
     5
     6        Reviewed by Anders Carlsson.
     7
     8        When WKViews were set to have transparent backgrounds, they still
     9        obscured content behind the view, for several reasons.
     10       
     11        First, when in tiled scrolling mode, WKView set the background
     12        of its layer to opaque white. Fix by using the clearColor (effectively
     13        removing the background color) if the view has a non-opaque background.
     14       
     15        Second, RenderLayerBacking just looked at FrameViews's isTransparent()
     16        when deciding to make TileCache tiles non-opaque, but it also needs to
     17        consider FrameViews with a non-opaque base background color. The
     18        same logic was necessary to avoid setting an opaque white background
     19        color on the TileCache layer.
     20       
     21        Finally, for views with non-opaque backgrounds, we don't want to display
     22        linen, so RenderLayerCompositor::requiresOverhangAreasLayer() was changed
     23        to return false in that case.
     24
     25        * UIProcess/API/mac/WKView.mm:
     26        (-[WKView updateLayer]):
     27
    1282013-01-14  Dean Jackson  <dino@apple.com>
    229
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r136620 r139750  
    29702970- (void)updateLayer
    29712971{
    2972     self.layer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
     2972    if ([self drawsBackground] && ![self drawsTransparentBackground])
     2973        self.layer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
     2974    else
     2975        self.layer.backgroundColor = CGColorGetConstantColor(kCGColorClear);
    29732976
    29742977    if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea())
Note: See TracChangeset for help on using the changeset viewer.