summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp')
-rw-r--r--Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp76
1 files changed, 46 insertions, 30 deletions
diff --git a/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp b/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp
index 99726087c..1db759404 100644
--- a/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp
+++ b/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp
@@ -29,17 +29,22 @@
#include "Frame.h"
#include "FrameView.h"
-#include "LayerChromium.h"
#include "Region.h"
#include "RenderLayerCompositor.h"
#include "RenderView.h"
-#include "ScrollbarLayerChromium.h"
-#include "ScrollbarTheme.h"
-#include "cc/CCProxy.h"
+#include "ScrollbarThemeComposite.h"
+#include "WebScrollbarThemeGeometryNative.h"
#include <public/WebScrollableLayer.h>
+#include <public/WebScrollbar.h>
+#include <public/WebScrollbarLayer.h>
+#include <public/WebScrollbarThemeGeometry.h>
+#include <public/WebScrollbarThemePainter.h>
using WebKit::WebLayer;
+using WebKit::WebRect;
using WebKit::WebScrollableLayer;
+using WebKit::WebScrollbarLayer;
+using WebKit::WebVector;
namespace WebCore {
@@ -53,19 +58,18 @@ public:
{
m_scrollLayer = layer;
- int id = layer.isNull() ? 0 : layer.unwrap<LayerChromium>()->id();
if (!m_horizontalScrollbarLayer.isNull())
- m_horizontalScrollbarLayer.unwrap<ScrollbarLayerChromium>()->setScrollLayerId(id);
+ m_horizontalScrollbarLayer.setScrollLayer(layer);
if (!m_verticalScrollbarLayer.isNull())
- m_verticalScrollbarLayer.unwrap<ScrollbarLayerChromium>()->setScrollLayerId(id);
+ m_verticalScrollbarLayer.setScrollLayer(layer);
}
- void setHorizontalScrollbarLayer(WebLayer layer)
+ void setHorizontalScrollbarLayer(WebScrollbarLayer layer)
{
m_horizontalScrollbarLayer = layer;
}
- void setVerticalScrollbarLayer(WebLayer layer)
+ void setVerticalScrollbarLayer(WebScrollbarLayer layer)
{
m_verticalScrollbarLayer = layer;
}
@@ -75,8 +79,8 @@ public:
private:
WebScrollableLayer m_scrollLayer;
- WebLayer m_horizontalScrollbarLayer;
- WebLayer m_verticalScrollbarLayer;
+ WebScrollbarLayer m_horizontalScrollbarLayer;
+ WebScrollbarLayer m_verticalScrollbarLayer;
};
PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
@@ -108,14 +112,14 @@ static GraphicsLayer* scrollLayerForFrameView(FrameView* frameView)
#endif
}
-static WebLayer createScrollbarLayer(Scrollbar* scrollbar, WebScrollableLayer scrollLayer, GraphicsLayer* scrollbarGraphicsLayer, FrameView* frameView)
+static WebScrollbarLayer createScrollbarLayer(Scrollbar* scrollbar, WebScrollableLayer scrollLayer, GraphicsLayer* scrollbarGraphicsLayer, FrameView* frameView)
{
ASSERT(scrollbar);
ASSERT(scrollbarGraphicsLayer);
if (scrollLayer.isNull()) {
// FIXME: sometimes we get called before setScrollLayer, workaround by finding the scroll layout ourselves.
- scrollLayer = WebScrollableLayer(scrollLayerForFrameView(frameView)->platformLayer());
+ scrollLayer = scrollLayerForFrameView(frameView)->platformLayer()->to<WebScrollableLayer>();
ASSERT(!scrollLayer.isNull());
}
@@ -126,26 +130,30 @@ static WebLayer createScrollbarLayer(Scrollbar* scrollbar, WebScrollableLayer sc
scrollbarGraphicsLayer->setContentsOpaque(isOpaqueRootScrollbar);
// FIXME: Mac scrollbar themes are not thread-safe to paint.
- // FIXME: Win scrollbars on XP Classic themes do not paint valid alpha
- // values due to GDI. This needs to be fixed in theme code before it
- // can be turned on here.
bool platformSupported = true;
-#if OS(DARWIN) || OS(WINDOWS)
+#if OS(DARWIN)
platformSupported = false;
#endif
- if (!platformSupported || scrollbar->isOverlayScrollbar()) {
+ if (!platformSupported || scrollbar->isCustomScrollbar()) {
scrollbarGraphicsLayer->setContentsToMedia(0);
scrollbarGraphicsLayer->setDrawsContent(true);
- return WebLayer();
+ return WebScrollbarLayer();
}
- RefPtr<ScrollbarLayerChromium> scrollbarLayer = ScrollbarLayerChromium::create(scrollbar, scrollLayer.unwrap<LayerChromium>()->id());
- scrollbarGraphicsLayer->setContentsToMedia(scrollbarLayer.get());
+ // All Chromium scrollbar themes derive from ScrollbarThemeComposite.
+ ScrollbarThemeComposite* themeComposite = static_cast<ScrollbarThemeComposite*>(scrollbar->theme());
+ WebKit::WebScrollbarThemePainter painter(themeComposite, scrollbar);
+ OwnPtr<WebKit::WebScrollbarThemeGeometry> geometry(WebKit::WebScrollbarThemeGeometryNative::create(themeComposite));
+
+ WebScrollbarLayer scrollbarLayer = WebScrollbarLayer::create(scrollbar, painter, geometry.release());
+ scrollbarLayer.setScrollLayer(scrollLayer);
+
+ scrollbarGraphicsLayer->setContentsToMedia(&scrollbarLayer);
scrollbarGraphicsLayer->setDrawsContent(false);
- scrollbarLayer->setOpaque(scrollbarGraphicsLayer->contentsOpaque());
+ scrollbarLayer.setOpaque(scrollbarGraphicsLayer->contentsOpaque());
- return WebLayer(scrollbarLayer.release());
+ return scrollbarLayer;
}
void ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange(FrameView* frameView, GraphicsLayer* horizontalScrollbarLayer)
@@ -166,13 +174,21 @@ void ScrollingCoordinator::frameViewVerticalScrollbarLayerDidChange(FrameView* f
void ScrollingCoordinator::setScrollLayer(GraphicsLayer* scrollLayer)
{
- m_private->setScrollLayer(WebScrollableLayer(scrollLayer ? scrollLayer->platformLayer() : 0));
+ WebScrollableLayer layer;
+ if (scrollLayer)
+ layer = scrollLayer->platformLayer()->to<WebScrollableLayer>();
+ m_private->setScrollLayer(layer);
}
void ScrollingCoordinator::setNonFastScrollableRegion(const Region& region)
{
- if (m_private->hasScrollLayer())
- m_private->scrollLayer().unwrap<LayerChromium>()->setNonFastScrollableRegion(region);
+ if (m_private->hasScrollLayer()) {
+ Vector<IntRect> rects = region.rects();
+ WebVector<WebRect> webRects(rects.size());
+ for (size_t i = 0; i < rects.size(); ++i)
+ webRects[i] = rects[i];
+ m_private->scrollLayer().setNonFastScrollableRegion(webRects);
+ }
}
void ScrollingCoordinator::setScrollParameters(const ScrollParameters&)
@@ -199,14 +215,14 @@ bool ScrollingCoordinator::supportsFixedPositionLayers() const
void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLayer* layer, bool enable)
{
- if (LayerChromium* platformLayer = layer->platformLayer())
- platformLayer->setIsContainerForFixedPositionLayers(enable);
+ if (WebLayer* platformLayer = layer->platformLayer())
+ platformLayer->to<WebScrollableLayer>().setIsContainerForFixedPositionLayers(enable);
}
void ScrollingCoordinator::setLayerIsFixedToContainerLayer(GraphicsLayer* layer, bool enable)
{
- if (LayerChromium* platformLayer = layer->platformLayer())
- platformLayer->setFixedToContainerLayer(enable);
+ if (WebLayer* platformLayer = layer->platformLayer())
+ platformLayer->to<WebScrollableLayer>().setFixedToContainerLayer(enable);
}
}