Title: [145156] trunk/Source
Revision
145156
Author
bda...@apple.com
Date
2013-03-07 16:57:00 -0800 (Thu, 07 Mar 2013)

Log Message

Need API to draw custom overhang area
https://bugs.webkit.org/show_bug.cgi?id=111679
-and corresponding-
<rdar://problem/13291415>

Reviewed by Simon Fraser.

Source/WebCore: 

This will allow clients to put custom images into the top or bottom overhang area.

New FrameView API takes a bool indicating whether the client wants a top/bottom 
overhang layer. If the bool is true, the overhang layer will be returned. 
* WebCore.exp.in:
* page/FrameView.cpp:
(WebCore::FrameView::setWantsLayerForTopOverHangArea):
(WebCore::FrameView::setWantsLayerForBottomOverHangArea):
* page/FrameView.h:
(FrameView):

Keep member variables for the top and bottom overhang layers. Create them if 
necessary, and update them if the root layer changes.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateRootLayerPosition):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
(WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
(WebCore::RenderLayerCompositor::reportMemoryUsage):
* rendering/RenderLayerCompositor.h:
(RenderLayerCompositor):

Source/WebKit2: 

The new API is WKBundlePageSetTopOverhangImage() and 
WKBundlePageSetBottomOverhangImage(). When the API is called, WebPage will get 
GraphicsLayers for the appropriate area from FrameView, and then set the image as 
the contents of the layer.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageSetTopOverhangImage):
(WKBundlePageSetBottomOverhangImage):
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/WebPage/WebPage.h:
(WebPage):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::setTopOverhangImage):
(WebKit):
(WebKit::WebPage::setBottomOverhangImage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145155 => 145156)


--- trunk/Source/WebCore/ChangeLog	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebCore/ChangeLog	2013-03-08 00:57:00 UTC (rev 145156)
@@ -1,3 +1,33 @@
+2013-03-07  Beth Dakin  <bda...@apple.com>
+
+        Need API to draw custom overhang area
+        https://bugs.webkit.org/show_bug.cgi?id=111679
+        -and corresponding-
+        <rdar://problem/13291415>
+
+        Reviewed by Simon Fraser.
+
+        This will allow clients to put custom images into the top or bottom overhang area.
+
+        New FrameView API takes a bool indicating whether the client wants a top/bottom 
+        overhang layer. If the bool is true, the overhang layer will be returned. 
+        * WebCore.exp.in:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setWantsLayerForTopOverHangArea):
+        (WebCore::FrameView::setWantsLayerForBottomOverHangArea):
+        * page/FrameView.h:
+        (FrameView):
+
+        Keep member variables for the top and bottom overhang layers. Create them if 
+        necessary, and update them if the root layer changes.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+        (WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
+        (WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
+        (WebCore::RenderLayerCompositor::reportMemoryUsage):
+        * rendering/RenderLayerCompositor.h:
+        (RenderLayerCompositor):
+
 2013-03-07  Gavin Barraclough  <barraclo...@apple.com>
 
         Reduce page cache size on Mac

Modified: trunk/Source/WebCore/WebCore.exp.in (145155 => 145156)


--- trunk/Source/WebCore/WebCore.exp.in	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-03-08 00:57:00 UTC (rev 145156)
@@ -1542,6 +1542,8 @@
 __ZNK7WebCore9FrameView23documentBackgroundColorEv
 __ZNK7WebCore9FrameView27windowClipRectForFrameOwnerEPKNS_21HTMLFrameOwnerElementEb
 __ZNK7WebCore9FrameView28isEnclosedInCompositingLayerEv
+__ZNK7WebCore9FrameView31setWantsLayerForTopOverHangAreaEb
+__ZNK7WebCore9FrameView34setWantsLayerForBottomOverHangAreaEb
 __ZNK7WebCore9PageCache10frameCountEv
 __ZTVN7WebCore12ChromeClientE
 __ZTVN7WebCore14LoaderStrategyE

Modified: trunk/Source/WebCore/page/FrameView.cpp (145155 => 145156)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-03-08 00:57:00 UTC (rev 145156)
@@ -862,8 +862,34 @@
         return 0;
     return renderView->compositor()->layerForOverhangAreas();
 }
+
+GraphicsLayer* FrameView::setWantsLayerForTopOverHangArea(bool wantsLayer) const
+{
+    RenderView* renderView = this->renderView();
+    if (!renderView)
+        return 0;
+
+#if USE(ACCELERATED_COMPOSITING)
+    return renderView->compositor()->updateLayerForTopOverhangArea(wantsLayer);
+#else
+    return 0;
 #endif
+}
 
+GraphicsLayer* FrameView::setWantsLayerForBottomOverHangArea(bool wantsLayer) const
+{
+    RenderView* renderView = this->renderView();
+    if (!renderView)
+        return 0;
+
+#if USE(ACCELERATED_COMPOSITING)
+    return renderView->compositor()->updateLayerForBottomOverhangArea(wantsLayer);
+#else
+    return 0;
+#endif
+}
+#endif
+
 bool FrameView::flushCompositingStateForThisFrame(Frame* rootFrameForFlush)
 {
     RenderView* renderView = this->renderView();

Modified: trunk/Source/WebCore/page/FrameView.h (145155 => 145156)


--- trunk/Source/WebCore/page/FrameView.h	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebCore/page/FrameView.h	2013-03-08 00:57:00 UTC (rev 145156)
@@ -399,6 +399,11 @@
 
     virtual bool isActive() const OVERRIDE;
 
+#if ENABLE(RUBBER_BANDING)
+    GraphicsLayer* setWantsLayerForTopOverHangArea(bool) const;
+    GraphicsLayer* setWantsLayerForBottomOverHangArea(bool) const;
+#endif
+
 protected:
     virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
     virtual void scrollContentsSlowPath(const IntRect& updateRect);

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (145155 => 145156)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2013-03-08 00:57:00 UTC (rev 145156)
@@ -1583,6 +1583,9 @@
             ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get());
         }
     }
+
+    updateLayerForTopOverhangArea(m_layerForTopOverhangArea);
+    updateLayerForBottomOverhangArea(m_layerForBottomOverhangArea);
 #endif
 }
 
@@ -2425,8 +2428,58 @@
 
     return false;
 }
+
+GraphicsLayer* RenderLayerCompositor::updateLayerForTopOverhangArea(bool wantsLayer)
+{
+    if (m_renderView->document()->ownerElement())
+        return 0;
+
+    if (!wantsLayer) {
+        if (m_layerForTopOverhangArea) {
+            m_layerForTopOverhangArea->removeFromParent();
+            m_layerForTopOverhangArea = nullptr;
+        }
+        return 0;
+    }
+
+    if (!m_layerForTopOverhangArea) {
+        m_layerForTopOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), this);
+#ifndef NDEBUG
+        m_layerForTopOverhangArea->setName("top overhang area");
 #endif
+        m_scrollLayer->addChildBelow(m_layerForTopOverhangArea.get(), m_rootContentLayer.get());
+    }
 
+    return m_layerForTopOverhangArea.get();
+}
+
+GraphicsLayer* RenderLayerCompositor::updateLayerForBottomOverhangArea(bool wantsLayer)
+{
+    if (m_renderView->document()->ownerElement())
+        return 0;
+
+    if (!wantsLayer) {
+        if (m_layerForBottomOverhangArea) {
+            m_layerForBottomOverhangArea->removeFromParent();
+            m_layerForBottomOverhangArea = nullptr;
+        }
+        return 0;
+    }
+
+    if (!m_layerForBottomOverhangArea) {
+        m_layerForBottomOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), this);
+#ifndef NDEBUG
+        m_layerForBottomOverhangArea->setName("bottom overhang area");
+#endif
+        m_scrollLayer->addChildBelow(m_layerForBottomOverhangArea.get(), m_rootContentLayer.get());
+    }
+
+    m_layerForBottomOverhangArea->setPosition(FloatPoint(0, m_rootContentLayer->size().height()));
+    return m_layerForBottomOverhangArea.get();
+}
+
+#endif
+
 bool RenderLayerCompositor::viewHasTransparentBackground(Color* backgroundColor) const
 {
     FrameView* frameView = m_renderView->frameView();
@@ -3030,6 +3083,8 @@
 #if ENABLE(RUBBER_BANDING)
     info.addMember(m_layerForOverhangAreas, "layerForOverhangAreas");
     info.addMember(m_contentShadowLayer, "contentShadowLayer");
+    info.addMember(m_layerForTopOverhangArea, "layerForTopOverhangArea");
+    info.addMember(m_layerForBottomOverhangArea, "layerForBottomOverhangArea");
 #endif
     info.addMember(m_layerUpdater, "layerUpdater");
 }

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (145155 => 145156)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2013-03-08 00:57:00 UTC (rev 145156)
@@ -254,6 +254,9 @@
     GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
 #if ENABLE(RUBBER_BANDING)
     GraphicsLayer* layerForOverhangAreas() const { return m_layerForOverhangAreas.get(); }
+
+    GraphicsLayer* updateLayerForTopOverhangArea(bool wantsLayer);
+    GraphicsLayer* updateLayerForBottomOverhangArea(bool wantsLayer);
 #endif
 
     void updateViewportConstraintStatus(RenderLayer*);
@@ -422,6 +425,8 @@
 #if ENABLE(RUBBER_BANDING)
     OwnPtr<GraphicsLayer> m_layerForOverhangAreas;
     OwnPtr<GraphicsLayer> m_contentShadowLayer;
+    OwnPtr<GraphicsLayer> m_layerForTopOverhangArea;
+    OwnPtr<GraphicsLayer> m_layerForBottomOverhangArea;
 #endif
 
     OwnPtr<GraphicsLayerUpdater> m_layerUpdater; // Updates tiled layer visible area periodically while animations are running.

Modified: trunk/Source/WebKit2/ChangeLog (145155 => 145156)


--- trunk/Source/WebKit2/ChangeLog	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebKit2/ChangeLog	2013-03-08 00:57:00 UTC (rev 145156)
@@ -1,3 +1,28 @@
+2013-03-07  Beth Dakin  <bda...@apple.com>
+
+        Need API to draw custom overhang area
+        https://bugs.webkit.org/show_bug.cgi?id=111679
+        -and corresponding-
+        <rdar://problem/13291415>
+
+        Reviewed by Simon Fraser.
+
+        The new API is WKBundlePageSetTopOverhangImage() and 
+        WKBundlePageSetBottomOverhangImage(). When the API is called, WebPage will get 
+        GraphicsLayers for the appropriate area from FrameView, and then set the image as 
+        the contents of the layer.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageSetTopOverhangImage):
+        (WKBundlePageSetBottomOverhangImage):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+        * WebProcess/WebPage/WebPage.h:
+        (WebPage):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::setTopOverhangImage):
+        (WebKit):
+        (WebKit::WebPage::setBottomOverhangImage):
+
 2013-03-07  Gavin Barraclough  <barraclo...@apple.com>
 
         Reduce page cache size on Mac

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (145155 => 145156)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2013-03-08 00:57:00 UTC (rev 145156)
@@ -303,6 +303,26 @@
     toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), true);
 }
 
+void WKBundlePageSetTopOverhangImage(WKBundlePageRef page, WKImageRef image)
+{
+#if PLATFORM(MAC)
+    toImpl(page)->setTopOverhangImage(toImpl(image));
+#else
+    UNUSED_PARAM(page);
+    UNUSED_PARAM(image);
+#endif
+}
+
+void WKBundlePageSetBottomOverhangImage(WKBundlePageRef page, WKImageRef image)
+{
+#if PLATFORM(MAC)
+    toImpl(page)->setBottomOverhangImage(toImpl(image));
+#else
+    UNUSED_PARAM(page);
+    UNUSED_PARAM(image);
+#endif
+}
+
 bool WKBundlePageHasLocalDataForURL(WKBundlePageRef pageRef, WKURLRef urlRef)
 {
     return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)));

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (145155 => 145156)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2013-03-08 00:57:00 UTC (rev 145156)
@@ -429,6 +429,9 @@
 WK_EXPORT void WKBundlePageInstallPageOverlayWithAnimation(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
 WK_EXPORT void WKBundlePageUninstallPageOverlayWithAnimation(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
 
+WK_EXPORT void WKBundlePageSetTopOverhangImage(WKBundlePageRef page, WKImageRef image);
+WK_EXPORT void WKBundlePageSetBottomOverhangImage(WKBundlePageRef page, WKImageRef image);
+
 WK_EXPORT bool WKBundlePageHasLocalDataForURL(WKBundlePageRef page, WKURLRef url);
 WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (145155 => 145156)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-03-08 00:57:00 UTC (rev 145156)
@@ -354,6 +354,9 @@
     void updatePluginsActiveAndFocusedState();
     const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
     const WebCore::IntRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
+
+    void setTopOverhangImage(PassRefPtr<WebImage>);
+    void setBottomOverhangImage(PassRefPtr<WebImage>);
 #endif
 
     bool windowIsFocused() const;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (145155 => 145156)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2013-03-08 00:54:35 UTC (rev 145155)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2013-03-08 00:57:00 UTC (rev 145156)
@@ -37,6 +37,7 @@
 #import "WebEvent.h"
 #import "WebEventConversion.h"
 #import "WebFrame.h"
+#import "WebImage.h"
 #import "WebInspector.h"
 #import "WebPageProxyMessages.h"
 #import "WebPreferencesStore.h"
@@ -781,6 +782,39 @@
         (*it)->setLayerHostingMode(layerHostingMode);
 }
 
+void WebPage::setTopOverhangImage(PassRefPtr<WebImage> image)
+{
+    FrameView* frameView = m_mainFrame->coreFrame()->view();
+    if (!frameView)
+        return;
+
+    GraphicsLayer* layer = frameView->setWantsLayerForTopOverHangArea(image.get());
+    if (!layer)
+        return;
+
+    layer->setSize(image->size());
+    layer->setPosition(FloatPoint(0, -image->size().height()));
+
+    RetainPtr<CGImageRef> cgImage = image->bitmap()->makeCGImageCopy();
+    layer->platformLayer().contents =(id)cgImage.get();
+}
+
+void WebPage::setBottomOverhangImage(PassRefPtr<WebImage> image)
+{
+    FrameView* frameView = m_mainFrame->coreFrame()->view();
+    if (!frameView)
+        return;
+
+    GraphicsLayer* layer = frameView->setWantsLayerForBottomOverHangArea(image.get());
+    if (!layer)
+        return;
+
+    layer->setSize(image->size());
+    
+    RetainPtr<CGImageRef> cgImage = image->bitmap()->makeCGImageCopy();
+    layer->platformLayer().contents =(id)cgImage.get();
+}
+
 void WebPage::computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo& printInfo, Vector<IntRect>& resultPageRects)
 {
     ASSERT(resultPageRects.isEmpty());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to