- Revision
- 106588
- Author
- [email protected]
- Date
- 2012-02-02 13:18:37 -0800 (Thu, 02 Feb 2012)
Log Message
The overhang area layer should have a linen background
https://bugs.webkit.org/show_bug.cgi?id=77670
<rdar://problem/10797727>
Reviewed by Andreas Kling.
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinator::scrollByOnScrollingThread):
Add an #ifdef so that scroll position clamping can be disabled. This will be
removed once rubber-banding works properly.
* platform/ScrollbarTheme.h:
(WebCore::ScrollbarTheme::setUpOverhangAreasLayerContents):
Add new empty function.
* platform/mac/ScrollbarThemeMac.h:
(ScrollbarThemeMac):
* platform/mac/ScrollbarThemeMac.mm:
(WebCore::linenBackgroundColor):
Helper function for getting the CGColorRef that represents the linen background color.
(WebCore::ScrollbarThemeMac::setUpOverhangAreasLayerContents):
Set the linen background color as the overhang areas layer background color.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
Call ScrollbarTheme::setUpOverhangAreasLayerContents.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (106587 => 106588)
--- trunk/Source/WebCore/ChangeLog 2012-02-02 21:15:51 UTC (rev 106587)
+++ trunk/Source/WebCore/ChangeLog 2012-02-02 21:18:37 UTC (rev 106588)
@@ -1,3 +1,33 @@
+2012-02-02 Anders Carlsson <[email protected]>
+
+ The overhang area layer should have a linen background
+ https://bugs.webkit.org/show_bug.cgi?id=77670
+ <rdar://problem/10797727>
+
+ Reviewed by Andreas Kling.
+
+ * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+ (WebCore::ScrollingCoordinator::scrollByOnScrollingThread):
+ Add an #ifdef so that scroll position clamping can be disabled. This will be
+ removed once rubber-banding works properly.
+
+ * platform/ScrollbarTheme.h:
+ (WebCore::ScrollbarTheme::setUpOverhangAreasLayerContents):
+ Add new empty function.
+
+ * platform/mac/ScrollbarThemeMac.h:
+ (ScrollbarThemeMac):
+ * platform/mac/ScrollbarThemeMac.mm:
+ (WebCore::linenBackgroundColor):
+ Helper function for getting the CGColorRef that represents the linen background color.
+
+ (WebCore::ScrollbarThemeMac::setUpOverhangAreasLayerContents):
+ Set the linen background color as the overhang areas layer background color.
+
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+ Call ScrollbarTheme::setUpOverhangAreasLayerContents.
+
2012-02-02 Sheriff Bot <[email protected]>
Unreviewed, rolling out r106566.
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (106587 => 106588)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2012-02-02 21:15:51 UTC (rev 106587)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2012-02-02 21:18:37 UTC (rev 106588)
@@ -77,6 +77,8 @@
// FIXME: Inform the scrolling thread?
}
+#define ENABLE_FREE_SCROLLING 0
+
void ScrollingCoordinator::scrollByOnScrollingThread(const IntSize& offset)
{
ASSERT(ScrollingThread::isCurrentThread());
@@ -88,10 +90,13 @@
scrollPosition = -scrollPosition;
scrollPosition += offset;
+
+#if !ENABLE_FREE_SCROLLING
scrollPosition.clampNegativeToZero();
IntPoint maximumScrollPosition = IntPoint(m_mainFrameContentsSize.width() - m_mainFrameVisibleContentRect.width(), m_mainFrameContentsSize.height() - m_mainFrameVisibleContentRect.height());
scrollPosition = scrollPosition.shrunkTo(maximumScrollPosition);
+#endif
updateMainFrameScrollLayerPositionOnScrollingThread(-scrollPosition);
Modified: trunk/Source/WebCore/platform/ScrollbarTheme.h (106587 => 106588)
--- trunk/Source/WebCore/platform/ScrollbarTheme.h 2012-02-02 21:15:51 UTC (rev 106587)
+++ trunk/Source/WebCore/platform/ScrollbarTheme.h 2012-02-02 21:18:37 UTC (rev 106588)
@@ -36,6 +36,10 @@
class Scrollbar;
class ScrollView;
+#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
+class GraphicsLayer;
+#endif
+
class ScrollbarTheme {
WTF_MAKE_NONCOPYABLE(ScrollbarTheme); WTF_MAKE_FAST_ALLOCATED;
public:
@@ -84,6 +88,10 @@
virtual void paintOverhangAreas(ScrollView*, GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) { }
+#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
+ virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) { }
+#endif
+
virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&) { return false; }
virtual bool shouldSnapBackToDragOrigin(Scrollbar*, const PlatformMouseEvent&) { return false; }
virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&) { return false; }
Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h (106587 => 106588)
--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h 2012-02-02 21:15:51 UTC (rev 106587)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h 2012-02-02 21:18:37 UTC (rev 106588)
@@ -80,6 +80,10 @@
virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&);
int scrollbarPartToHIPressedState(ScrollbarPart);
+
+#if !PLATFORM(CHROMIUM) && USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
+ virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) OVERRIDE;
+#endif
};
}
Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm (106587 => 106588)
--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm 2012-02-02 21:15:51 UTC (rev 106587)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm 2012-02-02 21:18:37 UTC (rev 106588)
@@ -44,6 +44,10 @@
using namespace std;
using namespace WebCore;
+@interface NSColor (WebNSColorDetails)
++ (NSImage *)_linenPatternImage;
+@end
+
namespace WebCore {
typedef HashMap<Scrollbar*, RetainPtr<ScrollbarPainter> > ScrollbarPainterMap;
@@ -598,5 +602,28 @@
}
#endif
+#if !PLATFORM(CHROMIUM) && USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
+static RetainPtr<CGColorRef> linenBackgroundColor()
+{
+ NSImage *image = [NSColor _linenPatternImage];
+ CGImageRef cgImage = [image CGImageForProposedRect:NULL context:NULL hints:nil];
+
+ RetainPtr<CGPatternRef> pattern = adoptCF(wkCGPatternCreateWithImageAndTransform(cgImage, CGAffineTransformIdentity, wkPatternTilingNoDistortion));
+ RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreatePattern(0));
+
+ const CGFloat alpha = 1.0;
+ return adoptCF(CGColorCreateWithPattern(colorSpace.get(), pattern.get(), &alpha));
}
+void ScrollbarThemeMac::setUpOverhangAreasLayerContents(GraphicsLayer* graphicsLayer)
+{
+ static CGColorRef cachedLinenBackgroundColor = linenBackgroundColor().leakRef();
+
+ // We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
+ // of pattern images, and we know that WebCore won't touch this layer.
+ graphicsLayer->platformLayer().backgroundColor = cachedLinenBackgroundColor;
+}
+
+#endif
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (106587 => 106588)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2012-02-02 21:15:51 UTC (rev 106587)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2012-02-02 21:18:37 UTC (rev 106588)
@@ -50,6 +50,7 @@
#include "RenderReplica.h"
#include "RenderVideo.h"
#include "RenderView.h"
+#include "ScrollbarTheme.h"
#include "Settings.h"
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
@@ -1753,6 +1754,8 @@
m_layerForOverhangAreas->setDrawsContent(false);
m_layerForOverhangAreas->setSize(m_renderView->frameView()->frameRect().size());
+ ScrollbarTheme::theme()->setUpOverhangAreasLayerContents(m_layerForOverhangAreas.get());
+
// We want the overhang areas layer to be positioned below the frame contents,
// so insert it below the clip layer.
m_overflowControlsHostLayer->addChildBelow(m_layerForOverhangAreas.get(), m_clipLayer.get());