Modified: trunk/Source/WebCore/ChangeLog (123401 => 123402)
--- trunk/Source/WebCore/ChangeLog 2012-07-23 23:37:10 UTC (rev 123401)
+++ trunk/Source/WebCore/ChangeLog 2012-07-23 23:38:54 UTC (rev 123402)
@@ -1,3 +1,33 @@
+2012-07-23 Tien-Ren Chen <[email protected]>
+
+ [chromium] Implement scrollbar theme for Android
+ https://bugs.webkit.org/show_bug.cgi?id=91674
+
+ Reviewed by Adam Barth.
+
+ Previously the scrollbar for Android was implemented as an extra
+ drawing pass in the compositor. Now we switch to use the standard
+ ScrollbarTheme mechanism.
+
+ No new tests. We use mock scrollbars during layout test to share
+ pixel results with Linux.
+
+ * platform/chromium/ScrollbarThemeChromiumAndroid.cpp:
+ (WebCore::ScrollbarThemeChromiumAndroid::scrollbarThickness):
+ (WebCore::ScrollbarThemeChromiumAndroid::thumbPosition):
+ (WebCore::ScrollbarThemeChromiumAndroid::thumbLength):
+ (WebCore::ScrollbarThemeChromiumAndroid::backButtonRect):
+ (WebCore::ScrollbarThemeChromiumAndroid::forwardButtonRect):
+ (WebCore::ScrollbarThemeChromiumAndroid::trackRect):
+ (WebCore):
+ (WebCore::ScrollbarThemeChromiumAndroid::paintThumb):
+ (WebCore::ScrollbarThemeChromiumAndroid::paintScrollbarBackground):
+ * platform/chromium/ScrollbarThemeChromiumAndroid.h:
+ (WebCore::ScrollbarThemeChromiumAndroid::usesOverlayScrollbars):
+ (ScrollbarThemeChromiumAndroid):
+ (WebCore::ScrollbarThemeChromiumAndroid::hasButtons):
+ (WebCore::ScrollbarThemeChromiumAndroid::hasThumb):
+
2012-07-23 Kwang Yul Seo <[email protected]>
Use the original token to create an element in "reconstruct the active formatting elements" and "call the adoption agency"
Modified: trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumAndroid.cpp (123401 => 123402)
--- trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumAndroid.cpp 2012-07-23 23:37:10 UTC (rev 123401)
+++ trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumAndroid.cpp 2012-07-23 23:38:54 UTC (rev 123402)
@@ -32,12 +32,14 @@
#include "Scrollbar.h"
#include "TransformationMatrix.h"
+#include <algorithm>
+
+using namespace std;
+
namespace WebCore {
-// On Android, the threaded compositor is in charge of drawing the scrollbar,
-// so set the internal scrollbar thickness and button length to be zero.
-static const int scrollbarThicknessValue = 0;
-static const int buttonLength = 0;
+static const int scrollbarWidth = 8;
+static const int scrollbarMargin = 5;
ScrollbarTheme* ScrollbarTheme::nativeTheme()
{
@@ -54,33 +56,100 @@
IntSize scrollbarSize = PlatformSupport::getThemePartSize(PlatformSupport::PartScrollbarDownArrow);
return scrollbarSize.width();
}
- return scrollbarThicknessValue;
+
+ return scrollbarWidth + scrollbarMargin;
}
-void ScrollbarThemeChromiumAndroid::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
+int ScrollbarThemeChromiumAndroid::thumbPosition(ScrollbarThemeClient* scrollbar)
{
- // Paint black background in DumpRenderTree, otherwise the pixels in the scrollbar area depend
- // on their previous state, which makes the dumped result undetermined.
- if (PlatformSupport::layoutTestMode())
- context->fillRect(scrollbar->frameRect(), Color::black, ColorSpaceDeviceRGB);
+ if (!scrollbar->totalSize())
+ return 0;
+
+ int trackLen = trackLength(scrollbar);
+ float proportion = static_cast<float>(scrollbar->currentPos()) / scrollbar->totalSize();
+ return round(proportion * trackLen);
}
-bool ScrollbarThemeChromiumAndroid::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt)
+int ScrollbarThemeChromiumAndroid::thumbLength(ScrollbarThemeClient* scrollbar)
{
- return true;
+ int trackLen = trackLength(scrollbar);
+
+ if (!scrollbar->totalSize())
+ return trackLen;
+
+ float proportion = (float)scrollbar->visibleSize() / scrollbar->totalSize();
+ int length = round(proportion * trackLen);
+ length = min(max(length, minimumThumbLength(scrollbar)), trackLen);
+ return length;
}
-IntSize ScrollbarThemeChromiumAndroid::buttonSize(ScrollbarThemeClient* scrollbar)
+IntRect ScrollbarThemeChromiumAndroid::backButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool)
{
- if (scrollbar->orientation() == VerticalScrollbar)
- return IntSize(scrollbarThicknessValue, buttonLength);
+ return IntRect();
+}
- return IntSize(buttonLength, scrollbarThicknessValue);
+IntRect ScrollbarThemeChromiumAndroid::forwardButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool)
+{
+ return IntRect();
}
-int ScrollbarThemeChromiumAndroid::minimumThumbLength(ScrollbarThemeClient* scrollbar)
+IntRect ScrollbarThemeChromiumAndroid::trackRect(ScrollbarThemeClient* scrollbar, bool)
{
- return 2 * scrollbarThickness(scrollbar->controlSize());
+ IntRect rect = scrollbar->frameRect();
+ if (scrollbar->orientation() == HorizontalScrollbar)
+ rect.inflateX(-scrollbarMargin);
+ else
+ rect.inflateY(-scrollbarMargin);
+ return rect;
}
+static void fillSmoothEdgedRect(GraphicsContext* context, const IntRect& rect, const Color& color)
+{
+ Color halfColor(color.red(), color.green(), color.blue(), color.alpha() / 2);
+
+ IntRect topRect = rect;
+ topRect.inflateX(-1);
+ topRect.setHeight(1);
+ context->fillRect(topRect, halfColor, ColorSpaceDeviceRGB);
+
+ IntRect leftRect = rect;
+ leftRect.inflateY(-1);
+ leftRect.setWidth(1);
+ context->fillRect(leftRect, halfColor, ColorSpaceDeviceRGB);
+
+ IntRect centerRect = rect;
+ centerRect.inflate(-1);
+ context->fillRect(centerRect, color, ColorSpaceDeviceRGB);
+
+ IntRect rightRect = rect;
+ rightRect.inflateY(-1);
+ rightRect.setX(centerRect.maxX());
+ rightRect.setWidth(1);
+ context->fillRect(rightRect, halfColor, ColorSpaceDeviceRGB);
+
+ IntRect bottomRect = rect;
+ bottomRect.inflateX(-1);
+ bottomRect.setY(centerRect.maxY());
+ bottomRect.setHeight(1);
+ context->fillRect(bottomRect, halfColor, ColorSpaceDeviceRGB);
+}
+
+void ScrollbarThemeChromiumAndroid::paintThumb(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
+{
+ IntRect thumbRect = rect;
+ if (scrollbar->orientation() == HorizontalScrollbar)
+ thumbRect.setHeight(thumbRect.height() - scrollbarMargin);
+ else
+ thumbRect.setWidth(thumbRect.width() - scrollbarMargin);
+ fillSmoothEdgedRect(context, thumbRect, Color(128, 128, 128, 128));
+}
+
+void ScrollbarThemeChromiumAndroid::paintScrollbarBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar)
+{
+ // Paint black background in DumpRenderTree, otherwise the pixels in the scrollbar area depend
+ // on their previous state, which makes the dumped result undetermined.
+ if (PlatformSupport::layoutTestMode())
+ context->fillRect(scrollbar->frameRect(), Color::black, ColorSpaceDeviceRGB);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumAndroid.h (123401 => 123402)
--- trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumAndroid.h 2012-07-23 23:37:10 UTC (rev 123401)
+++ trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumAndroid.h 2012-07-23 23:38:54 UTC (rev 123402)
@@ -30,15 +30,23 @@
namespace WebCore {
-class ScrollbarThemeChromiumAndroid : public ScrollbarThemeChromium {
+class ScrollbarThemeChromiumAndroid : public ScrollbarThemeComposite {
public:
virtual int scrollbarThickness(ScrollbarControlSize);
+ virtual bool usesOverlayScrollbars() const { return true; }
-protected:
+ virtual int thumbPosition(ScrollbarThemeClient*);
+ virtual int thumbLength(ScrollbarThemeClient*);
+
+ virtual bool hasButtons(ScrollbarThemeClient*) { return false; };
+ virtual bool hasThumb(ScrollbarThemeClient*) { return true; };
+
+ virtual IntRect backButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false);
+ virtual IntRect forwardButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false);
+ virtual IntRect trackRect(ScrollbarThemeClient*, bool painting = false);
+
+ virtual void paintThumb(GraphicsContext*, ScrollbarThemeClient*, const IntRect&);
virtual void paintScrollbarBackground(GraphicsContext*, ScrollbarThemeClient*);
- virtual bool shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent&);
- virtual IntSize buttonSize(ScrollbarThemeClient*);
- virtual int minimumThumbLength(ScrollbarThemeClient*);
};
} // namespace WebCore