Unreviewed, rolling out r95860.
authormihaip@chromium.org <mihaip@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Sep 2011 00:07:11 +0000 (00:07 +0000)
committermihaip@chromium.org <mihaip@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Sep 2011 00:07:11 +0000 (00:07 +0000)
http://trac.webkit.org/changeset/95860
https://bugs.webkit.org/show_bug.cgi?id=68648

Breaks overhang rendering on Chromium Mac

Source/WebCore:

* platform/chromium/ScrollbarThemeChromium.cpp:
* platform/chromium/ScrollbarThemeChromium.h:
* platform/chromium/ScrollbarThemeChromiumMac.h:
* platform/chromium/ScrollbarThemeChromiumMac.mm:
(WebCore::ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac):
(WebCore::ScrollbarThemeChromiumMac::paintOverhangAreas):

Source/WebKit/chromium:

* features.gypi:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/chromium/ScrollbarThemeChromium.cpp
Source/WebCore/platform/chromium/ScrollbarThemeChromium.h
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h
Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/features.gypi

index 7fb0ef4..56810cc 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-23  Mihai Parparita  <mihaip@chromium.org>
+
+        Unreviewed, rolling out r95860.
+        http://trac.webkit.org/changeset/95860
+        https://bugs.webkit.org/show_bug.cgi?id=68648
+
+        Breaks overhang rendering on Chromium Mac
+
+        * platform/chromium/ScrollbarThemeChromium.cpp:
+        * platform/chromium/ScrollbarThemeChromium.h:
+        * platform/chromium/ScrollbarThemeChromiumMac.h:
+        * platform/chromium/ScrollbarThemeChromiumMac.mm:
+        (WebCore::ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac):
+        (WebCore::ScrollbarThemeChromiumMac::paintOverhangAreas):
+
 2011-09-23  Dean Jackson  <dino@apple.com>
 
         Add -webkit-filter to CSSPropertyNames
index 6cc4d3d..24b3e18 100644 (file)
 #include "ScrollbarThemeChromium.h"
 
 #include "PlatformMouseEvent.h"
-
-#if ENABLE(RUBBER_BANDING)
-#include "ScrollView.h"
-#endif
-
 #include "ScrollableArea.h"
 #include "Scrollbar.h"
 #include "ScrollbarThemeComposite.h"
 
 namespace WebCore {
 
-#if ENABLE(RUBBER_BANDING)
-ScrollbarThemeChromium::ScrollbarThemeChromium()
-{
-    static bool initialized = false;
-    if (!initialized) {
-        initialized = true;
-        // Load the linen pattern image used for overhang drawing.
-        RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern");
-        m_overhangPattern = Pattern::create(patternImage, true, true);
-    }
-}
-
-ScrollbarThemeChromium::~ScrollbarThemeChromium()
-{
-}
-
-void ScrollbarThemeChromium::paintOverhangAreas(ScrollView* view, GraphicsContext* context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect)
-{
-    // The extent of each shadow in pixels.
-    const int kShadowSize = 4;
-    // Offset of negative one pixel to make the gradient blend with the toolbar's bottom border.
-    const int kToolbarShadowOffset = -1;
-    const struct {
-        float stop;
-        Color color;
-    } kShadowColors[] = {
-        { 0.000, Color(0, 0, 0, 255) },
-        { 0.125, Color(0, 0, 0, 57) },
-        { 0.375, Color(0, 0, 0, 41) },
-        { 0.625, Color(0, 0, 0, 18) },
-        { 0.875, Color(0, 0, 0, 6) },
-        { 1.000, Color(0, 0, 0, 0) }
-    };
-    const unsigned kNumShadowColors = sizeof(kShadowColors) / sizeof(kShadowColors[0]);
-
-    const bool hasHorizontalOverhang = !horizontalOverhangRect.isEmpty();
-    const bool hasVerticalOverhang = !verticalOverhangRect.isEmpty();
-    // Prefer non-additive shadows, but degrade to additive shadows if there is vertical overhang.
-    const bool useAdditiveShadows = hasVerticalOverhang;
-
-    GraphicsContextStateSaver stateSaver(*context);
-
-    context->setFillPattern(m_overhangPattern);
-    if (hasHorizontalOverhang)
-        context->fillRect(intersection(horizontalOverhangRect, dirtyRect));
-    if (hasVerticalOverhang)
-        context->fillRect(intersection(verticalOverhangRect, dirtyRect));
-
-    IntSize scrollOffset = view->scrollOffset();
-    FloatPoint shadowCornerOrigin;
-    FloatPoint shadowCornerOffset;
-
-    // Draw the shadow for the horizontal overhang.
-    if (hasHorizontalOverhang) {
-        int toolbarShadowHeight = kShadowSize;
-        RefPtr<Gradient> gradient;
-        IntRect shadowRect = horizontalOverhangRect;
-        shadowRect.setHeight(kShadowSize);
-        if (scrollOffset.height() < 0) {
-            if (useAdditiveShadows) {
-                toolbarShadowHeight = std::min(horizontalOverhangRect.height(), kShadowSize);
-            } else if (horizontalOverhangRect.height() < 2 * kShadowSize + kToolbarShadowOffset) {
-                // Split the overhang area between the web content shadow and toolbar shadow if it's too small.
-                shadowRect.setHeight((horizontalOverhangRect.height() + 1) / 2);
-                toolbarShadowHeight = horizontalOverhangRect.height() - shadowRect.height() - kToolbarShadowOffset;
-            }
-            shadowRect.setY(horizontalOverhangRect.maxY() - shadowRect.height());
-            gradient = Gradient::create(FloatPoint(0, shadowRect.maxY()), FloatPoint(0, shadowRect.maxY() - kShadowSize));
-            shadowCornerOrigin.setY(shadowRect.maxY());
-            shadowCornerOffset.setY(-kShadowSize);
-        } else {
-            gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.maxY()));
-            shadowCornerOrigin.setY(shadowRect.y());
-        }
-        if (hasVerticalOverhang) {
-            shadowRect.setWidth(shadowRect.width() - verticalOverhangRect.width());
-            if (scrollOffset.width() < 0) {
-                shadowRect.setX(shadowRect.x() + verticalOverhangRect.width());
-                shadowCornerOrigin.setX(shadowRect.x());
-                shadowCornerOffset.setX(-kShadowSize);
-            } else
-                shadowCornerOrigin.setX(shadowRect.maxX());
-        }
-        for (unsigned i = 0; i < kNumShadowColors; i++)
-            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
-        context->setFillGradient(gradient);
-        context->fillRect(intersection(shadowRect, dirtyRect));
-
-        // Draw a drop-shadow from the toolbar.
-        if (scrollOffset.height() < 0) {
-            shadowRect.setY(kToolbarShadowOffset);
-            shadowRect.setHeight(toolbarShadowHeight);
-            gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.y() + kShadowSize));
-            for (unsigned i = 0; i < kNumShadowColors; i++)
-                gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
-            context->setFillGradient(gradient);
-            context->fillRect(intersection(shadowRect, dirtyRect));
-        }
-    }
-
-    // Draw the shadow for the vertical overhang.
-    if (hasVerticalOverhang) {
-        RefPtr<Gradient> gradient;
-        IntRect shadowRect = verticalOverhangRect;
-        shadowRect.setWidth(kShadowSize);
-        if (scrollOffset.width() < 0) {
-            shadowRect.setX(verticalOverhangRect.maxX() - shadowRect.width());
-            gradient = Gradient::create(FloatPoint(shadowRect.maxX(), 0), FloatPoint(shadowRect.x(), 0));
-        } else
-            gradient = Gradient::create(FloatPoint(shadowRect.x(), 0), FloatPoint(shadowRect.maxX(), 0));
-
-        for (unsigned i = 0; i < kNumShadowColors; i++)
-            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
-        context->setFillGradient(gradient);
-        context->fillRect(intersection(shadowRect, dirtyRect));
-
-        // Draw a drop-shadow from the toolbar.
-        shadowRect = verticalOverhangRect;
-        shadowRect.setY(kToolbarShadowOffset);
-        shadowRect.setHeight(kShadowSize);
-        gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.maxY()));
-        for (unsigned i = 0; i < kNumShadowColors; i++)
-            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
-        context->setFillGradient(gradient);
-        context->fillRect(intersection(shadowRect, dirtyRect));
-    }
-
-    // If both rectangles present, draw a radial gradient for the corner.
-    if (hasHorizontalOverhang && hasVerticalOverhang) {
-        RefPtr<Gradient> gradient = Gradient::create(shadowCornerOrigin, 0, shadowCornerOrigin, kShadowSize);
-        for (unsigned i = 0; i < kNumShadowColors; i++)
-            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
-        context->setFillGradient(gradient);
-        context->fillRect(FloatRect(shadowCornerOrigin.x() + shadowCornerOffset.x(), shadowCornerOrigin.y() + shadowCornerOffset.y(), kShadowSize, kShadowSize));
-    }
-}
-#endif
-
 bool ScrollbarThemeChromium::hasThumb(Scrollbar* scrollbar)
 {
     // This method is just called as a paint-time optimization to see if
index 179c34e..1178125 100644 (file)
@@ -40,13 +40,6 @@ namespace WebCore {
     // This class contains the scrollbar code which is shared between Chromium
     // Windows and Linux.
     class ScrollbarThemeChromium : public ScrollbarThemeComposite {
-#if ENABLE(RUBBER_BANDING)
-    public:
-        ScrollbarThemeChromium();
-        virtual ~ScrollbarThemeChromium();
-        virtual void paintOverhangAreas(ScrollView*, GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
-#endif
-
     protected:
         virtual bool hasButtons(Scrollbar*) { return true; }
         virtual bool hasThumb(Scrollbar*);
@@ -59,11 +52,6 @@ namespace WebCore {
         virtual void paintTickmarks(GraphicsContext*, Scrollbar*, const IntRect&);
 
         virtual IntSize buttonSize(Scrollbar*) = 0;
-
-#if ENABLE(RUBBER_BANDING)
-    private:
-        RefPtr<Pattern> m_overhangPattern;
-#endif
     };
 } // namespace WebCore
 
index ed84f32..cc9a308 100644 (file)
@@ -62,6 +62,8 @@ public:
 
     void setNewPainterForScrollbar(Scrollbar*, WKScrollbarPainterRef);
     WKScrollbarPainterRef painterForScrollbar(Scrollbar*);
+
+    virtual void paintOverhangAreas(ScrollView*, GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
     
 protected:
     virtual bool hasButtons(Scrollbar*);
@@ -80,6 +82,9 @@ protected:
 
 private:
     void paintGivenTickmarks(GraphicsContext*, Scrollbar*, const IntRect&, const Vector<IntRect>&);
+
+private:
+    RefPtr<Pattern> m_overhangPattern;
 };
 
 }
index c2dd0d3..472343d 100644 (file)
@@ -194,6 +194,10 @@ ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac()
     if (!initialized) {
         initialized = true;
 
+        // Load the linen pattern image used for overhang drawing.
+        RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern");
+        m_overhangPattern = Pattern::create(patternImage, true, true);
+
         [ScrollbarPrefsObserver registerAsObserver];
         preferencesChanged();
     }
@@ -672,4 +676,127 @@ void ScrollbarThemeChromiumMac::paintGivenTickmarks(GraphicsContext* context, Sc
     }
 }
 
+void ScrollbarThemeChromiumMac::paintOverhangAreas(ScrollView* view, GraphicsContext* context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect)
+{
+    // The extent of each shadow in pixels.
+    const int kShadowSize = 4;
+    // Offset of negative one pixel to make the gradient blend with the toolbar's bottom border.
+    const int kToolbarShadowOffset = -1;
+    const struct {
+        float stop;
+        Color color;
+    } kShadowColors[] = {
+        { 0.000, Color(0, 0, 0, 255) },
+        { 0.125, Color(0, 0, 0, 57) },
+        { 0.375, Color(0, 0, 0, 41) },
+        { 0.625, Color(0, 0, 0, 18) },
+        { 0.875, Color(0, 0, 0, 6) },
+        { 1.000, Color(0, 0, 0, 0) }
+    };
+    const unsigned kNumShadowColors = sizeof(kShadowColors)/sizeof(kShadowColors[0]);
+
+    const bool hasHorizontalOverhang = !horizontalOverhangRect.isEmpty();
+    const bool hasVerticalOverhang = !verticalOverhangRect.isEmpty();
+    // Prefer non-additive shadows, but degrade to additive shadows if there is vertical overhang.
+    const bool useAdditiveShadows = hasVerticalOverhang;
+
+    GraphicsContextStateSaver stateSaver(*context);
+
+    context->setFillPattern(m_overhangPattern);
+    if (hasHorizontalOverhang)
+        context->fillRect(intersection(horizontalOverhangRect, dirtyRect));
+    if (hasVerticalOverhang)
+        context->fillRect(intersection(verticalOverhangRect, dirtyRect));
+
+    IntSize scrollOffset = view->scrollOffset();
+    FloatPoint shadowCornerOrigin;
+    FloatPoint shadowCornerOffset;
+
+    // Draw the shadow for the horizontal overhang.
+    if (hasHorizontalOverhang) {
+        int toolbarShadowHeight = kShadowSize;
+        RefPtr<Gradient> gradient;
+        IntRect shadowRect = horizontalOverhangRect;
+        shadowRect.setHeight(kShadowSize);
+        if (scrollOffset.height() < 0) {
+            if (useAdditiveShadows) {
+                toolbarShadowHeight = std::min(horizontalOverhangRect.height(), kShadowSize);
+            } else if (horizontalOverhangRect.height() < 2 * kShadowSize + kToolbarShadowOffset) {
+                // Split the overhang area between the web content shadow and toolbar shadow if it's too small.
+                shadowRect.setHeight((horizontalOverhangRect.height() + 1) / 2);
+                toolbarShadowHeight = horizontalOverhangRect.height() - shadowRect.height() - kToolbarShadowOffset;
+            }
+            shadowRect.setY(horizontalOverhangRect.maxY() - shadowRect.height());
+            gradient = Gradient::create(FloatPoint(0, shadowRect.maxY()), FloatPoint(0, shadowRect.maxY() - kShadowSize));
+            shadowCornerOrigin.setY(shadowRect.maxY());
+            shadowCornerOffset.setY(-kShadowSize);
+        } else {
+            gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.maxY()));
+            shadowCornerOrigin.setY(shadowRect.y());
+        }
+        if (hasVerticalOverhang) {
+            shadowRect.setWidth(shadowRect.width() - verticalOverhangRect.width());
+            if (scrollOffset.width() < 0) {
+                shadowRect.setX(shadowRect.x() + verticalOverhangRect.width());
+                shadowCornerOrigin.setX(shadowRect.x());
+                shadowCornerOffset.setX(-kShadowSize);
+            } else {
+                shadowCornerOrigin.setX(shadowRect.maxX());
+            }
+        }
+        for (unsigned i = 0; i < kNumShadowColors; i++)
+            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
+        context->setFillGradient(gradient);
+        context->fillRect(intersection(shadowRect, dirtyRect));
+
+        // Draw a drop-shadow from the toolbar.
+        if (scrollOffset.height() < 0) {
+            shadowRect.setY(kToolbarShadowOffset);
+            shadowRect.setHeight(toolbarShadowHeight);
+            gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.y() + kShadowSize));
+            for (unsigned i = 0; i < kNumShadowColors; i++)
+                gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
+            context->setFillGradient(gradient);
+            context->fillRect(intersection(shadowRect, dirtyRect));
+        }
+    }
+
+    // Draw the shadow for the vertical overhang.
+    if (hasVerticalOverhang) {
+        RefPtr<Gradient> gradient;
+        IntRect shadowRect = verticalOverhangRect;
+        shadowRect.setWidth(kShadowSize);
+        if (scrollOffset.width() < 0) {
+            shadowRect.setX(verticalOverhangRect.maxX() - shadowRect.width());
+            gradient = Gradient::create(FloatPoint(shadowRect.maxX(), 0), FloatPoint(shadowRect.x(), 0));
+        } else {
+            gradient = Gradient::create(FloatPoint(shadowRect.x(), 0), FloatPoint(shadowRect.maxX(), 0));
+        }
+        for (unsigned i = 0; i < kNumShadowColors; i++)
+            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
+        context->setFillGradient(gradient);
+        context->fillRect(intersection(shadowRect, dirtyRect));
+
+        // Draw a drop-shadow from the toolbar.
+        shadowRect = verticalOverhangRect;
+        shadowRect.setY(kToolbarShadowOffset);
+        shadowRect.setHeight(kShadowSize);
+        gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.maxY()));
+        for (unsigned i = 0; i < kNumShadowColors; i++)
+            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
+        context->setFillGradient(gradient);
+        context->fillRect(intersection(shadowRect, dirtyRect));
+    }
+
+    // If both rectangles present, draw a radial gradient for the corner.
+    if (hasHorizontalOverhang && hasVerticalOverhang) {
+        RefPtr<Gradient> gradient = Gradient::create(shadowCornerOrigin, 0, shadowCornerOrigin, kShadowSize);
+        for (unsigned i = 0; i < kNumShadowColors; i++)
+            gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
+        context->setFillGradient(gradient);
+        context->fillRect(FloatRect(shadowCornerOrigin.x() + shadowCornerOffset.x(), shadowCornerOrigin.y() + shadowCornerOffset.y(), kShadowSize, kShadowSize));
+    }
+}
+
+
 }
index 2c9180e..cabb328 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-23  Mihai Parparita  <mihaip@chromium.org>
+
+        Unreviewed, rolling out r95860.
+        http://trac.webkit.org/changeset/95860
+        https://bugs.webkit.org/show_bug.cgi?id=68648
+
+        Breaks overhang rendering on Chromium Mac
+
+        * features.gypi:
+
 2011-09-23  Adam Klein  <adamk@chromium.org>
 
         [chromium] Remove WEBWIDGET_HAS_ANIMATE_CHANGES #define
index fbb2e5a..c7c078c 100644 (file)
       }],
       ['touchui==1', {
         'enable_touch_icon_loading': 1,
-        'feature_defines': [
-          'ENABLE_RUBBER_BANDING=1',
-        ],
       }],
       # Mac OS X uses Accelerate.framework FFT by default instead of FFmpeg.
       ['OS!="mac"', {