[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
tkent at chromium.org
tkent at chromium.org
Wed Dec 22 11:09:41 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit b7ad638e79ad9d27323e54d014c32afbfc6b7d0d
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jul 14 04:48:05 2010 +0000
[Chromium] Linux implementation of <input type=number> UI
https://bugs.webkit.org/show_bug.cgi?id=41925
Reviewed by Darin Fisher.
WebCore:
- Move the code for scrollbar steppers from ScrollbarThemeChromiumLinux
to PlatformThemeChromiumGtk.
- Move the code for scrollbar colors from RenderThemeChromiumLinux
to PlatformThemeChromiumGtk.
* WebCore.gypi:
* platform/chromium/PlatformThemeChromiumGtk.cpp: Added.
(WebCore::PlatformThemeChromiumGtk::setScrollbarColors): Moved from RenderThemeChromiumLinux.
(WebCore::clamp): Moved from ScrollbarThemeChromiumLinux.
(WebCore::PlatformThemeChromiumGtk::saturateAndBrighten): ditto.
(WebCore::PlatformThemeChromiumGtk::outlineColor): ditto.
(WebCore::PlatformThemeChromiumGtk::paintArrowButton): ditto.
* platform/chromium/PlatformThemeChromiumGtk.h: Added.
* platform/chromium/ScrollbarThemeChromiumLinux.cpp:
(WebCore::ScrollbarThemeChromiumLinux::paintTrackPiece):
(WebCore::ScrollbarThemeChromiumLinux::paintButton):
Move the main part of the code to PlatformThemeChromiumGtk.
(WebCore::ScrollbarThemeChromiumLinux::paintThumb):
* rendering/RenderThemeChromiumLinux.cpp:
(WebCore::RenderThemeChromiumLinux::adjustInnerSpinButtonStyle): Added.
(WebCore::RenderThemeChromiumLinux::paintInnerSpinButton): Added.
* rendering/RenderThemeChromiumLinux.h:
WebKit/chromium:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setScrollbarColors):
Call PlatformThemeChromiumGtk::setScrollbarColors() instead of
RenderThemeChromiumLinux::setScrollbarColors().
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63280 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 54111c8..f452226 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-07-13 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ [Chromium] Linux implementation of <input type=number> UI
+ https://bugs.webkit.org/show_bug.cgi?id=41925
+
+ - Move the code for scrollbar steppers from ScrollbarThemeChromiumLinux
+ to PlatformThemeChromiumGtk.
+ - Move the code for scrollbar colors from RenderThemeChromiumLinux
+ to PlatformThemeChromiumGtk.
+
+ * WebCore.gypi:
+ * platform/chromium/PlatformThemeChromiumGtk.cpp: Added.
+ (WebCore::PlatformThemeChromiumGtk::setScrollbarColors): Moved from RenderThemeChromiumLinux.
+ (WebCore::clamp): Moved from ScrollbarThemeChromiumLinux.
+ (WebCore::PlatformThemeChromiumGtk::saturateAndBrighten): ditto.
+ (WebCore::PlatformThemeChromiumGtk::outlineColor): ditto.
+ (WebCore::PlatformThemeChromiumGtk::paintArrowButton): ditto.
+ * platform/chromium/PlatformThemeChromiumGtk.h: Added.
+ * platform/chromium/ScrollbarThemeChromiumLinux.cpp:
+ (WebCore::ScrollbarThemeChromiumLinux::paintTrackPiece):
+ (WebCore::ScrollbarThemeChromiumLinux::paintButton):
+ Move the main part of the code to PlatformThemeChromiumGtk.
+ (WebCore::ScrollbarThemeChromiumLinux::paintThumb):
+ * rendering/RenderThemeChromiumLinux.cpp:
+ (WebCore::RenderThemeChromiumLinux::adjustInnerSpinButtonStyle): Added.
+ (WebCore::RenderThemeChromiumLinux::paintInnerSpinButton): Added.
+ * rendering/RenderThemeChromiumLinux.h:
+
2010-07-13 Dumitru Daniliuc <dumi at chromium.org>
Reviewed by Darin Fisher
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 9dbc80a..00a04f1 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2110,6 +2110,8 @@
'platform/chromium/PlatformCursor.h',
'platform/chromium/PlatformKeyboardEventChromium.cpp',
'platform/chromium/PlatformScreenChromium.cpp',
+ 'platform/chromium/PlatformThemeChromiumGtk.cpp',
+ 'platform/chromium/PlatformThemeChromiumGtk.h',
'platform/chromium/PlatformWidget.h',
'platform/chromium/PopupMenuChromium.cpp',
'platform/chromium/PopupMenuChromium.h',
diff --git a/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp b/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp
new file mode 100644
index 0000000..1f74840
--- /dev/null
+++ b/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformThemeChromiumGtk.h"
+
+namespace WebCore {
+
+unsigned PlatformThemeChromiumGtk::s_thumbInactiveColor = 0xeaeaea;
+unsigned PlatformThemeChromiumGtk::s_thumbActiveColor = 0xf4f4f4;
+unsigned PlatformThemeChromiumGtk::s_trackColor = 0xd3d3d3;
+
+void PlatformThemeChromiumGtk::setScrollbarColors(
+ SkColor inactiveColor, SkColor activeColor, SkColor trackColor)
+{
+ s_thumbInactiveColor = inactiveColor;
+ s_thumbActiveColor = activeColor;
+ s_trackColor = trackColor;
+}
+
+static SkScalar clamp(SkScalar value, SkScalar min, SkScalar max)
+{
+ return std::min(std::max(value, min), max);
+}
+
+SkColor PlatformThemeChromiumGtk::saturateAndBrighten(const SkScalar hsv[3], SkScalar saturateAmount, SkScalar brightenAmount)
+{
+ SkScalar color[3];
+ color[0] = hsv[0];
+ color[1] = clamp(hsv[1] + saturateAmount, 0.0, 1.0);
+ color[2] = clamp(hsv[2] + brightenAmount, 0.0, 1.0);
+ return SkHSVToColor(color);
+}
+
+SkColor PlatformThemeChromiumGtk::outlineColor(const SkScalar hsv1[3], const SkScalar hsv2[3])
+{
+ // GTK Theme engines have way too much control over the layout of
+ // the scrollbar. We might be able to more closely approximate its
+ // look-and-feel, if we sent whole images instead of just colors
+ // from the browser to the renderer. But even then, some themes
+ // would just break.
+ //
+ // So, instead, we don't even try to 100% replicate the look of
+ // the native scrollbar. We render our own version, but we make
+ // sure to pick colors that blend in nicely with the system GTK
+ // theme. In most cases, we can just sample a couple of pixels
+ // from the system scrollbar and use those colors to draw our
+ // scrollbar.
+ //
+ // This works fine for the track color and the overall thumb
+ // color. But it fails spectacularly for the outline color used
+ // around the thumb piece. Not all themes have a clearly defined
+ // outline. For some of them it is partially transparent, and for
+ // others the thickness is very unpredictable.
+ //
+ // So, instead of trying to approximate the system theme, we
+ // instead try to compute a reasonable looking choice based on the
+ // known color of the track and the thumb piece. This is difficult
+ // when trying to deal both with high- and low-contrast themes,
+ // and both with positive and inverted themes.
+ //
+ // The following code has been tested to look OK with all of the
+ // default GTK themes.
+ SkScalar minDiff = clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5);
+ SkScalar diff = clamp(fabs(hsv1[2] - hsv2[2]) / 2, minDiff, 0.5);
+
+ if (hsv1[2] + hsv2[2] > 1.0)
+ diff = -diff;
+
+ return saturateAndBrighten(hsv2, -0.2, diff);
+}
+
+void PlatformThemeChromiumGtk::paintArrowButton(GraphicsContext* gc, const IntRect& rect, ArrowDirection direction, ControlStates states)
+{
+ SkCanvas* const canvas = gc->platformContext()->canvas();
+ int widthMiddle, lengthMiddle;
+ SkPaint paint;
+ if (direction == North || direction == South) {
+ widthMiddle = rect.width() / 2 + 1;
+ lengthMiddle = rect.height() / 2 + 1;
+ } else {
+ lengthMiddle = rect.width() / 2 + 1;
+ widthMiddle = rect.height() / 2 + 1;
+ }
+
+ // Calculate button color.
+ SkScalar trackHSV[3];
+ SkColorToHSV(trackColor(), trackHSV);
+ SkColor buttonColor = saturateAndBrighten(trackHSV, 0, 0.2);
+ SkColor backgroundColor = buttonColor;
+ if (states & PressedState) {
+ SkScalar buttonHSV[3];
+ SkColorToHSV(buttonColor, buttonHSV);
+ buttonColor = saturateAndBrighten(buttonHSV, 0, -0.1);
+ } else if (states & HoverState) {
+ SkScalar buttonHSV[3];
+ SkColorToHSV(buttonColor, buttonHSV);
+ buttonColor = saturateAndBrighten(buttonHSV, 0, 0.05);
+ }
+
+ SkIRect skrect;
+ skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
+ // Paint the background (the area visible behind the rounded corners).
+ paint.setColor(backgroundColor);
+ canvas->drawIRect(skrect, paint);
+
+ // Paint the button's outline and fill the middle
+ SkPath outline;
+ switch (direction) {
+ case North:
+ outline.moveTo(rect.x() + 0.5, rect.y() + rect.height() + 0.5);
+ outline.rLineTo(0, -(rect.height() - 2));
+ outline.rLineTo(2, -2);
+ outline.rLineTo(rect.width() - 5, 0);
+ outline.rLineTo(2, 2);
+ outline.rLineTo(0, rect.height() - 2);
+ break;
+ case South:
+ outline.moveTo(rect.x() + 0.5, rect.y() - 0.5);
+ outline.rLineTo(0, rect.height() - 2);
+ outline.rLineTo(2, 2);
+ outline.rLineTo(rect.width() - 5, 0);
+ outline.rLineTo(2, -2);
+ outline.rLineTo(0, -(rect.height() - 2));
+ break;
+ case East:
+ outline.moveTo(rect.x() - 0.5, rect.y() + 0.5);
+ outline.rLineTo(rect.width() - 2, 0);
+ outline.rLineTo(2, 2);
+ outline.rLineTo(0, rect.height() - 5);
+ outline.rLineTo(-2, 2);
+ outline.rLineTo(-(rect.width() - 2), 0);
+ break;
+ case West:
+ outline.moveTo(rect.x() + rect.width() + 0.5, rect.y() + 0.5);
+ outline.rLineTo(-(rect.width() - 2), 0);
+ outline.rLineTo(-2, 2);
+ outline.rLineTo(0, rect.height() - 5);
+ outline.rLineTo(2, 2);
+ outline.rLineTo(rect.width() - 2, 0);
+ break;
+ }
+ outline.close();
+
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(buttonColor);
+ canvas->drawPath(outline, paint);
+
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ SkScalar thumbHSV[3];
+ SkColorToHSV(thumbInactiveColor(), thumbHSV);
+ paint.setColor(outlineColor(trackHSV, thumbHSV));
+ canvas->drawPath(outline, paint);
+
+ // If the button is disabled, the arrow is drawn with the outline color.
+ if (states & EnabledState)
+ paint.setColor(SK_ColorBLACK);
+
+ paint.setAntiAlias(false);
+ paint.setStyle(SkPaint::kFill_Style);
+
+ SkPath path;
+ // The constants in this block of code are hand-tailored to produce good
+ // looking arrows without anti-aliasing.
+ switch (direction) {
+ case North:
+ path.moveTo(rect.x() + widthMiddle - 4, rect.y() + lengthMiddle + 2);
+ path.rLineTo(7, 0);
+ path.rLineTo(-4, -4);
+ break;
+ case South:
+ path.moveTo(rect.x() + widthMiddle - 4, rect.y() + lengthMiddle - 3);
+ path.rLineTo(7, 0);
+ path.rLineTo(-4, 4);
+ break;
+ case East:
+ path.moveTo(rect.x() + lengthMiddle - 3, rect.y() + widthMiddle - 4);
+ path.rLineTo(0, 7);
+ path.rLineTo(4, -4);
+ break;
+ case West:
+ path.moveTo(rect.x() + lengthMiddle + 1, rect.y() + widthMiddle - 5);
+ path.rLineTo(0, 9);
+ path.rLineTo(-4, -4);
+ break;
+ }
+ path.close();
+
+ canvas->drawPath(path, paint);
+}
+
+} // namespace WebCore
+
diff --git a/WebCore/platform/chromium/PlatformThemeChromiumGtk.h b/WebCore/platform/chromium/PlatformThemeChromiumGtk.h
new file mode 100644
index 0000000..bdc2683
--- /dev/null
+++ b/WebCore/platform/chromium/PlatformThemeChromiumGtk.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformThemeChromiumGtk_h
+#define PlatformThemeChromiumGtk_h
+
+#include "PlatformContextSkia.h"
+#include "SkColor.h"
+#include "SkScalar.h"
+#include "ThemeTypes.h"
+
+namespace WebCore {
+
+class PlatformThemeChromiumGtk {
+public:
+ enum ArrowDirection {
+ North,
+ East,
+ South,
+ West,
+ };
+
+ static void setScrollbarColors(unsigned inactiveColor,
+ unsigned activeColor,
+ unsigned trackColor);
+ static unsigned thumbInactiveColor() { return s_thumbInactiveColor; }
+ static unsigned thumbActiveColor() { return s_thumbActiveColor; }
+ static unsigned trackColor() { return s_trackColor; }
+
+ static SkColor saturateAndBrighten(const SkScalar hsv[3], SkScalar saturateAmount, SkScalar brightenAmount);
+ static SkColor outlineColor(const SkScalar hsv1[3], const SkScalar hsv2[3]);
+ static void paintArrowButton(GraphicsContext*, const IntRect&, ArrowDirection, ControlStates);
+
+private:
+ PlatformThemeChromiumGtk() {}
+
+ static unsigned s_thumbInactiveColor;
+ static unsigned s_thumbActiveColor;
+ static unsigned s_trackColor;
+};
+
+} // namespace WebCore
+
+#endif // PlatformThemeChromiumGtk_h
diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
index a9cff9f..289c264 100644
--- a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
+++ b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
@@ -33,8 +33,7 @@
#include "PlatformContextSkia.h"
#include "PlatformMouseEvent.h"
-#include "RenderTheme.h"
-#include "RenderThemeChromiumLinux.h"
+#include "PlatformThemeChromiumGtk.h"
#include "Scrollbar.h"
#include "TransformationMatrix.h"
@@ -78,60 +77,6 @@ static void drawBox(SkCanvas* canvas, const IntRect& rect, const SkPaint& paint)
drawVertLine(canvas, rect.x(), rect.y(), bottom, paint);
}
-static SkScalar clamp(SkScalar value, SkScalar min, SkScalar max)
-{
- return std::min(std::max(value, min), max);
-}
-
-static SkColor saturateAndBrighten(SkScalar* hsv,
- SkScalar saturateAmount,
- SkScalar brightenAmount)
-{
- SkScalar color[3];
- color[0] = hsv[0];
- color[1] = clamp(hsv[1] + saturateAmount, 0.0, 1.0);
- color[2] = clamp(hsv[2] + brightenAmount, 0.0, 1.0);
- return SkHSVToColor(color);
-}
-
-static SkColor outlineColor(SkScalar* hsv1, SkScalar* hsv2)
-{
- // GTK Theme engines have way too much control over the layout of
- // the scrollbar. We might be able to more closely approximate its
- // look-and-feel, if we sent whole images instead of just colors
- // from the browser to the renderer. But even then, some themes
- // would just break.
- //
- // So, instead, we don't even try to 100% replicate the look of
- // the native scrollbar. We render our own version, but we make
- // sure to pick colors that blend in nicely with the system GTK
- // theme. In most cases, we can just sample a couple of pixels
- // from the system scrollbar and use those colors to draw our
- // scrollbar.
- //
- // This works fine for the track color and the overall thumb
- // color. But it fails spectacularly for the outline color used
- // around the thumb piece. Not all themes have a clearly defined
- // outline. For some of them it is partially transparent, and for
- // others the thickness is very unpredictable.
- //
- // So, instead of trying to approximate the system theme, we
- // instead try to compute a reasonable looking choice based on the
- // known color of the track and the thumb piece. This is difficult
- // when trying to deal both with high- and low-contrast themes,
- // and both with positive and inverted themes.
- //
- // The following code has been tested to look OK with all of the
- // default GTK themes.
- SkScalar minDiff = clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5);
- SkScalar diff = clamp(fabs(hsv1[2] - hsv2[2]) / 2, minDiff, 0.5);
-
- if (hsv1[2] + hsv2[2] > 1.0)
- diff = -diff;
-
- return saturateAndBrighten(hsv2, -0.2, diff);
-}
-
void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType)
{
SkCanvas* const canvas = gc->platformContext()->canvas();
@@ -140,154 +85,45 @@ void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar
skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
SkScalar trackHSV[3];
- SkColorToHSV(RenderThemeChromiumLinux::trackColor(), trackHSV);
- paint.setColor(saturateAndBrighten(trackHSV, 0, 0));
+ SkColorToHSV(PlatformThemeChromiumGtk::trackColor(), trackHSV);
+ paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(trackHSV, 0, 0));
canvas->drawIRect(skrect, paint);
SkScalar thumbHSV[3];
- SkColorToHSV(RenderThemeChromiumLinux::thumbInactiveColor(),
+ SkColorToHSV(PlatformThemeChromiumGtk::thumbInactiveColor(),
thumbHSV);
- paint.setColor(outlineColor(trackHSV, thumbHSV));
+ paint.setColor(PlatformThemeChromiumGtk::outlineColor(trackHSV, thumbHSV));
drawBox(canvas, rect, paint);
}
void ScrollbarThemeChromiumLinux::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
{
- SkCanvas* const canvas = gc->platformContext()->canvas();
- static const int widthMiddle = scrollbarThicknessValue / 2 + 1;
- static const int lengthMiddle = buttonLength / 2 + 1;
- SkPaint paint;
- enum {
- North,
- East,
- South,
- West,
- } direction;
-
+ PlatformThemeChromiumGtk::ArrowDirection direction;
if (scrollbar->orientation() == HorizontalScrollbar) {
if (part == BackButtonStartPart)
- direction = West;
+ direction = PlatformThemeChromiumGtk::West;
else
- direction = East;
+ direction = PlatformThemeChromiumGtk::East;
} else {
if (part == BackButtonStartPart)
- direction = North;
+ direction = PlatformThemeChromiumGtk::North;
else
- direction = South;
+ direction = PlatformThemeChromiumGtk::South;
}
+ ControlStates states = 0;
// Determine if the button can be pressed.
- bool enabled = false;
- if (((direction == West || direction == North) && scrollbar->currentPos())
- || (direction == East || direction == South) && scrollbar->currentPos() != scrollbar->maximum())
- enabled = true;
+ if (((direction == PlatformThemeChromiumGtk::West || direction == PlatformThemeChromiumGtk::North) && scrollbar->currentPos())
+ || (direction == PlatformThemeChromiumGtk::East || direction == PlatformThemeChromiumGtk::South) && scrollbar->currentPos() != scrollbar->maximum())
+ states |= EnabledState;
- // Calculate button color.
- SkScalar trackHSV[3];
- SkColorToHSV(RenderThemeChromiumLinux::trackColor(), trackHSV);
- SkColor buttonColor = saturateAndBrighten(trackHSV, 0, 0.2);
- SkColor backgroundColor = buttonColor;
- if (part == scrollbar->pressedPart()) {
- SkScalar buttonHSV[3];
- SkColorToHSV(buttonColor, buttonHSV);
- buttonColor = saturateAndBrighten(buttonHSV, 0, -0.1);
- } else if (part == scrollbar->hoveredPart() && enabled) {
- SkScalar buttonHSV[3];
- SkColorToHSV(buttonColor, buttonHSV);
- buttonColor = saturateAndBrighten(buttonHSV, 0, 0.05);
- }
-
- SkIRect skrect;
- skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
- // Paint the background (the area visible behind the rounded corners).
- paint.setColor(backgroundColor);
- canvas->drawIRect(skrect, paint);
-
- // Paint the button's outline and fill the middle
- SkPath outline;
- switch (direction) {
- case North:
- outline.moveTo(rect.x() + 0.5, rect.y() + rect.height() + 0.5);
- outline.rLineTo(0, -(rect.height() - 2));
- outline.rLineTo(2, -2);
- outline.rLineTo(rect.width() - 5, 0);
- outline.rLineTo(2, 2);
- outline.rLineTo(0, rect.height() - 2);
- break;
- case South:
- outline.moveTo(rect.x() + 0.5, rect.y() - 0.5);
- outline.rLineTo(0, rect.height() - 2);
- outline.rLineTo(2, 2);
- outline.rLineTo(rect.width() - 5, 0);
- outline.rLineTo(2, -2);
- outline.rLineTo(0, -(rect.height() - 2));
- break;
- case East:
- outline.moveTo(rect.x() - 0.5, rect.y() + 0.5);
- outline.rLineTo(rect.width() - 2, 0);
- outline.rLineTo(2, 2);
- outline.rLineTo(0, rect.height() - 5);
- outline.rLineTo(-2, 2);
- outline.rLineTo(-(rect.width() - 2), 0);
- break;
- case West:
- outline.moveTo(rect.x() + rect.width() + 0.5, rect.y() + 0.5);
- outline.rLineTo(-(rect.width() - 2), 0);
- outline.rLineTo(-2, 2);
- outline.rLineTo(0, rect.height() - 5);
- outline.rLineTo(2, 2);
- outline.rLineTo(rect.width() - 2, 0);
- break;
- }
- outline.close();
-
- paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(buttonColor);
- canvas->drawPath(outline, paint);
-
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- SkScalar thumbHSV[3];
- SkColorToHSV(RenderThemeChromiumLinux::thumbInactiveColor(), thumbHSV);
- paint.setColor(outlineColor(trackHSV, thumbHSV));
- canvas->drawPath(outline, paint);
-
- // If the button is disabled, the arrow is drawn with the outline color.
- if (enabled)
- paint.setColor(SK_ColorBLACK);
-
- paint.setAntiAlias(false);
- paint.setStyle(SkPaint::kFill_Style);
-
- SkPath path;
- // The constants in this block of code are hand-tailored to produce good
- // looking arrows without anti-aliasing.
- switch (direction) {
- case North:
- path.moveTo(rect.x() + widthMiddle - 4, rect.y() + lengthMiddle + 2);
- path.rLineTo(7, 0);
- path.rLineTo(-4, -4);
- break;
- case South:
- path.moveTo(rect.x() + widthMiddle - 4, rect.y() + lengthMiddle - 3);
- path.rLineTo(7, 0);
- path.rLineTo(-4, 4);
- break;
- case East:
- path.moveTo(rect.x() + lengthMiddle - 3, rect.y() + widthMiddle - 4);
- path.rLineTo(0, 7);
- path.rLineTo(4, -4);
- break;
- case West:
- path.moveTo(rect.x() + lengthMiddle + 1, rect.y() + widthMiddle - 5);
- path.rLineTo(0, 9);
- path.rLineTo(-4, -4);
- break;
- }
- path.close();
+ if (part == scrollbar->pressedPart())
+ states |= PressedState;
+ else if (part == scrollbar->hoveredPart() && states & EnabledState)
+ states |= HoverState;
- canvas->drawPath(path, paint);
+ PlatformThemeChromiumGtk::paintArrowButton(gc, rect, direction, states);
}
void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect)
@@ -300,12 +136,12 @@ void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scr
SkScalar thumb[3];
SkColorToHSV(hovered
- ? RenderThemeChromiumLinux::thumbActiveColor()
- : RenderThemeChromiumLinux::thumbInactiveColor(),
+ ? PlatformThemeChromiumGtk::thumbActiveColor()
+ : PlatformThemeChromiumGtk::thumbInactiveColor(),
thumb);
SkPaint paint;
- paint.setColor(saturateAndBrighten(thumb, 0, 0.02));
+ paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, 0.02));
SkIRect skrect;
if (vertical)
@@ -315,7 +151,7 @@ void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scr
canvas->drawIRect(skrect, paint);
- paint.setColor(saturateAndBrighten(thumb, 0, -0.02));
+ paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, -0.02));
if (vertical)
skrect.set(midx + 1, rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
@@ -325,8 +161,8 @@ void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scr
canvas->drawIRect(skrect, paint);
SkScalar track[3];
- SkColorToHSV(RenderThemeChromiumLinux::trackColor(), track);
- paint.setColor(outlineColor(track, thumb));
+ SkColorToHSV(PlatformThemeChromiumGtk::trackColor(), track);
+ paint.setColor(PlatformThemeChromiumGtk::outlineColor(track, thumb));
drawBox(canvas, rect, paint);
if (rect.height() > 10 && rect.width() > 10) {
diff --git a/WebCore/rendering/RenderThemeChromiumLinux.cpp b/WebCore/rendering/RenderThemeChromiumLinux.cpp
index c29353d..de83ae9 100644
--- a/WebCore/rendering/RenderThemeChromiumLinux.cpp
+++ b/WebCore/rendering/RenderThemeChromiumLinux.cpp
@@ -27,14 +27,13 @@
#include "CSSValueKeywords.h"
#include "Color.h"
+#include "PlatformThemeChromiumGtk.h"
#include "RenderObject.h"
+#include "ScrollbarTheme.h"
#include "UserAgentStyleSheets.h"
namespace WebCore {
-unsigned RenderThemeChromiumLinux::m_thumbInactiveColor = 0xeaeaea;
-unsigned RenderThemeChromiumLinux::m_thumbActiveColor = 0xf4f4f4;
-unsigned RenderThemeChromiumLinux::m_trackColor = 0xd3d3d3;
unsigned RenderThemeChromiumLinux::m_activeSelectionBackgroundColor =
0xff1e90ff;
unsigned RenderThemeChromiumLinux::m_activeSelectionForegroundColor =
@@ -168,12 +167,29 @@ void RenderThemeChromiumLinux::setSelectionColors(
m_inactiveSelectionForegroundColor = inactiveForegroundColor;
}
-void RenderThemeChromiumLinux::setScrollbarColors(
- SkColor inactiveColor, SkColor activeColor, SkColor trackColor)
+void RenderThemeChromiumLinux::adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
{
- m_thumbInactiveColor = inactiveColor;
- m_thumbActiveColor = activeColor;
- m_trackColor = trackColor;
+ int width = ScrollbarTheme::nativeTheme()->scrollbarThickness();
+ style->setWidth(Length(width, Fixed));
+ style->setMinWidth(Length(width, Fixed));
+}
+
+bool RenderThemeChromiumLinux::paintInnerSpinButton(RenderObject* object, const PaintInfo& info, const IntRect& rect)
+{
+ ControlStates northStates = controlStatesForRenderer(object);
+ ControlStates southStates = northStates;
+ if (northStates & SpinUpState)
+ southStates &= ~(HoverState | PressedState);
+ else
+ northStates &= ~(HoverState | PressedState);
+
+ IntRect half = rect;
+ half.setHeight(rect.height() / 2);
+ PlatformThemeChromiumGtk::paintArrowButton(info.context, half, PlatformThemeChromiumGtk::North, northStates);
+
+ half.setY(rect.y() + rect.height() / 2);
+ PlatformThemeChromiumGtk::paintArrowButton(info.context, half, PlatformThemeChromiumGtk::South, southStates);
+ return false;
}
} // namespace WebCore
diff --git a/WebCore/rendering/RenderThemeChromiumLinux.h b/WebCore/rendering/RenderThemeChromiumLinux.h
index c60dec3..9eeca97 100644
--- a/WebCore/rendering/RenderThemeChromiumLinux.h
+++ b/WebCore/rendering/RenderThemeChromiumLinux.h
@@ -59,18 +59,14 @@ namespace WebCore {
static void setCaretBlinkInterval(double interval);
virtual double caretBlinkIntervalInternal() const;
+ virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
+
static void setSelectionColors(unsigned activeBackgroundColor,
unsigned activeForegroundColor,
unsigned inactiveBackgroundColor,
unsigned inactiveForegroundColor);
- static void setScrollbarColors(unsigned inactive_color,
- unsigned active_color,
- unsigned track_color);
- static unsigned thumbInactiveColor() { return m_thumbInactiveColor; }
- static unsigned thumbActiveColor() { return m_thumbActiveColor; }
- static unsigned trackColor() { return m_trackColor; }
-
private:
RenderThemeChromiumLinux();
virtual ~RenderThemeChromiumLinux();
@@ -84,10 +80,6 @@ namespace WebCore {
static unsigned m_activeSelectionForegroundColor;
static unsigned m_inactiveSelectionBackgroundColor;
static unsigned m_inactiveSelectionForegroundColor;
-
- static unsigned m_thumbInactiveColor;
- static unsigned m_thumbActiveColor;
- static unsigned m_trackColor;
};
} // namespace WebCore
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index b16aeeb..7e14d0b 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,15 @@
+2010-07-13 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ [Chromium] Linux implementation of <input type=number> UI
+ https://bugs.webkit.org/show_bug.cgi?id=41925
+
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::setScrollbarColors):
+ Call PlatformThemeChromiumGtk::setScrollbarColors() instead of
+ RenderThemeChromiumLinux::setScrollbarColors().
+
2010-07-13 Chris Guillory <chris.guillory at google.com>
Reviewed by David Levin.
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index d1ca71e..f3fec75 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -73,6 +73,7 @@
#include "PlatformContextSkia.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformMouseEvent.h"
+#include "PlatformThemeChromiumGtk.h"
#include "PlatformWheelEvent.h"
#include "PopupMenuChromium.h"
#include "PopupMenuClient.h"
@@ -1852,7 +1853,7 @@ void WebViewImpl::setScrollbarColors(unsigned inactiveColor,
unsigned activeColor,
unsigned trackColor) {
#if OS(LINUX)
- RenderThemeChromiumLinux::setScrollbarColors(inactiveColor,
+ PlatformThemeChromiumGtk::setScrollbarColors(inactiveColor,
activeColor,
trackColor);
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list