Title: [96660] trunk/Source
Revision
96660
Author
[email protected]
Date
2011-10-04 16:01:00 -0700 (Tue, 04 Oct 2011)

Log Message

[Chromium] Moved files towards GTK removal
https://bugs.webkit.org/show_bug.cgi?id=69229

Patch by Fady Samuel <[email protected]> on 2011-10-04
Reviewed by Tony Chang.

Source/WebCore:

* WebCore.gypi:
* platform/chromium/PlatformThemeChromiumLinux.cpp: Renamed from Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp.
(WebCore::PlatformThemeChromiumLinux::setScrollbarColors):
(WebCore::clamp):
(WebCore::PlatformThemeChromiumLinux::saturateAndBrighten):
(WebCore::PlatformThemeChromiumLinux::outlineColor):
(WebCore::PlatformThemeChromiumLinux::paintArrowButton):
* platform/chromium/PlatformThemeChromiumLinux.h: Renamed from Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.h.
(WebCore::PlatformThemeChromiumLinux::thumbInactiveColor):
(WebCore::PlatformThemeChromiumLinux::thumbActiveColor):
(WebCore::PlatformThemeChromiumLinux::trackColor):
(WebCore::PlatformThemeChromiumLinux::PlatformThemeChromiumLinux):

Source/WebKit/chromium:

* WebKit.gyp:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setScrollbarColors):
* src/linux/WebFontInfo.cpp: Renamed from Source/WebKit/chromium/src/gtk/WebFontInfo.cpp.
(WebKit::WebFontInfo::familyForChars):
(WebKit::WebFontInfo::renderStyleForStrike):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (96659 => 96660)


--- trunk/Source/WebCore/ChangeLog	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebCore/ChangeLog	2011-10-04 23:01:00 UTC (rev 96660)
@@ -1,3 +1,23 @@
+2011-10-04  Fady Samuel  <[email protected]>
+
+        [Chromium] Moved files towards GTK removal
+        https://bugs.webkit.org/show_bug.cgi?id=69229
+
+        Reviewed by Tony Chang.
+
+        * WebCore.gypi:
+        * platform/chromium/PlatformThemeChromiumLinux.cpp: Renamed from Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp.
+        (WebCore::PlatformThemeChromiumLinux::setScrollbarColors):
+        (WebCore::clamp):
+        (WebCore::PlatformThemeChromiumLinux::saturateAndBrighten):
+        (WebCore::PlatformThemeChromiumLinux::outlineColor):
+        (WebCore::PlatformThemeChromiumLinux::paintArrowButton):
+        * platform/chromium/PlatformThemeChromiumLinux.h: Renamed from Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.h.
+        (WebCore::PlatformThemeChromiumLinux::thumbInactiveColor):
+        (WebCore::PlatformThemeChromiumLinux::thumbActiveColor):
+        (WebCore::PlatformThemeChromiumLinux::trackColor):
+        (WebCore::PlatformThemeChromiumLinux::PlatformThemeChromiumLinux):
+
 2011-10-04  James Robinson  <[email protected]>
 
         [chromium] Extract scheduling logic from CCThreadProxy to its own class

Modified: trunk/Source/WebCore/WebCore.gypi (96659 => 96660)


--- trunk/Source/WebCore/WebCore.gypi	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebCore/WebCore.gypi	2011-10-04 23:01:00 UTC (rev 96660)
@@ -3189,8 +3189,8 @@
             'platform/chromium/PlatformKeyboardEventChromium.cpp',
             'platform/chromium/PlatformScreenChromium.cpp',
             'platform/chromium/PlatformSupport.h',
-            'platform/chromium/PlatformThemeChromiumGtk.cpp',
-            'platform/chromium/PlatformThemeChromiumGtk.h',
+            'platform/chromium/PlatformThemeChromiumLinux.cpp',
+            'platform/chromium/PlatformThemeChromiumLinux.h',
             'platform/chromium/PlatformWidget.h',
             'platform/chromium/PopupContainer.cpp',
             'platform/chromium/PopupContainer.h',

Deleted: trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp (96659 => 96660)


--- trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp	2011-10-04 23:01:00 UTC (rev 96660)
@@ -1,221 +0,0 @@
-/*
- * 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 or read-only, the arrow is drawn with the outline color.
-    if (states & EnabledState && !(states & ReadOnlyState))
-        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
-

Deleted: trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.h (96659 => 96660)


--- trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.h	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.h	2011-10-04 23:01:00 UTC (rev 96660)
@@ -1,71 +0,0 @@
-/*
- * 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

Copied: trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.cpp (from rev 96657, trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.cpp) (0 => 96660)


--- trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.cpp	2011-10-04 23:01:00 UTC (rev 96660)
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2011 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 "PlatformThemeChromiumLinux.h"
+
+namespace WebCore {
+
+unsigned PlatformThemeChromiumLinux::s_thumbInactiveColor = 0xeaeaea;
+unsigned PlatformThemeChromiumLinux::s_thumbActiveColor = 0xf4f4f4;
+unsigned PlatformThemeChromiumLinux::s_trackColor = 0xd3d3d3;
+
+void PlatformThemeChromiumLinux::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 PlatformThemeChromiumLinux::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 PlatformThemeChromiumLinux::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 PlatformThemeChromiumLinux::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 or read-only, the arrow is drawn with the outline color.
+    if (states & EnabledState && !(states & ReadOnlyState))
+        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
+

Property changes: trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.cpp


Added: svn:eol-style

Copied: trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.h (from rev 96657, trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumGtk.h) (0 => 96660)


--- trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.h	2011-10-04 23:01:00 UTC (rev 96660)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2011 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 PlatformThemeChromiumLinux_h
+#define PlatformThemeChromiumLinux_h
+
+#include "PlatformContextSkia.h"
+#include "SkColor.h"
+#include "SkScalar.h"
+#include "ThemeTypes.h"
+
+namespace WebCore {
+
+class PlatformThemeChromiumLinux {
+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:
+    PlatformThemeChromiumLinux() { }
+
+    static unsigned s_thumbInactiveColor;
+    static unsigned s_thumbActiveColor;
+    static unsigned s_trackColor;
+};
+
+} // namespace WebCore
+
+#endif // PlatformThemeChromiumLinux_h

Property changes: trunk/Source/WebCore/platform/chromium/PlatformThemeChromiumLinux.h


Added: svn:eol-style

Modified: trunk/Source/WebKit/chromium/ChangeLog (96659 => 96660)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-10-04 23:01:00 UTC (rev 96660)
@@ -1,3 +1,17 @@
+2011-10-04  Fady Samuel  <[email protected]>
+
+        [Chromium] Moved files towards GTK removal
+        https://bugs.webkit.org/show_bug.cgi?id=69229
+
+        Reviewed by Tony Chang.
+
+        * WebKit.gyp:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::setScrollbarColors):
+        * src/linux/WebFontInfo.cpp: Renamed from Source/WebKit/chromium/src/gtk/WebFontInfo.cpp.
+        (WebKit::WebFontInfo::familyForChars):
+        (WebKit::WebFontInfo::renderStyleForStrike):
+
 2011-10-04  James Robinson  <[email protected]>
 
         [chromium] Extract scheduling logic from CCThreadProxy to its own class

Modified: trunk/Source/WebKit/chromium/WebKit.gyp (96659 => 96660)


--- trunk/Source/WebKit/chromium/WebKit.gyp	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebKit/chromium/WebKit.gyp	2011-10-04 23:01:00 UTC (rev 96660)
@@ -371,7 +371,6 @@
                 'src/GeolocationClientProxy.h',
                 'src/GraphicsContext3DChromium.cpp',
                 'src/GraphicsContext3DPrivate.h',
-                'src/gtk/WebFontInfo.cpp',
                 'src/gtk/WebInputEventFactory.cpp',
                 'src/IDBCallbacksProxy.cpp',
                 'src/IDBCallbacksProxy.h',
@@ -395,6 +394,7 @@
                 'src/InspectorClientImpl.h',
                 'src/InspectorFrontendClientImpl.cpp',
                 'src/InspectorFrontendClientImpl.h',
+                'src/linux/WebFontInfo.cpp',
                 'src/linux/WebFontRendering.cpp',
                 'src/linux/WebFontRenderStyle.cpp',
                 'src/linux/WebRenderTheme.cpp',

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (96659 => 96660)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-10-04 23:01:00 UTC (rev 96660)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 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
@@ -85,7 +85,7 @@
 #include "PlatformContextSkia.h"
 #include "PlatformKeyboardEvent.h"
 #include "PlatformMouseEvent.h"
-#include "PlatformThemeChromiumGtk.h"
+#include "PlatformThemeChromiumLinux.h"
 #include "PlatformWheelEvent.h"
 #include "PopupContainer.h"
 #include "PopupMenuClient.h"
@@ -2308,9 +2308,7 @@
                                      unsigned activeColor,
                                      unsigned trackColor) {
 #if OS(UNIX) && !OS(DARWIN)
-    PlatformThemeChromiumGtk::setScrollbarColors(inactiveColor,
-                                                 activeColor,
-                                                 trackColor);
+    PlatformThemeChromiumLinux::setScrollbarColors(inactiveColor, activeColor, trackColor);
 #endif
 }
 

Deleted: trunk/Source/WebKit/chromium/src/gtk/WebFontInfo.cpp (96659 => 96660)


--- trunk/Source/WebKit/chromium/src/gtk/WebFontInfo.cpp	2011-10-04 22:57:08 UTC (rev 96659)
+++ trunk/Source/WebKit/chromium/src/gtk/WebFontInfo.cpp	2011-10-04 23:01:00 UTC (rev 96660)
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2009 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 "WebFontInfo.h"
-#include "WebFontRenderStyle.h"
-
-#include <fontconfig/fontconfig.h>
-#include <string.h>
-#include <unicode/utf16.h>
-
-namespace WebKit {
-
-WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale)
-{
-    FcCharSet* cset = FcCharSetCreate();
-    for (size_t i = 0; i < numCharacters; ++i) {
-        if (U16_IS_SURROGATE(characters[i])
-         && U16_IS_SURROGATE_LEAD(characters[i])
-         && i != numCharacters - 1
-         && U16_IS_TRAIL(characters[i + 1])) {
-              FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
-          i++;
-        } else
-              FcCharSetAddChar(cset, characters[i]);
-    }
-    FcPattern* pattern = FcPatternCreate();
-
-    FcValue fcvalue;
-    fcvalue.type = FcTypeCharSet;
-    fcvalue.u.c = cset;
-    FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeBool;
-    fcvalue.u.b = FcTrue;
-    FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
-
-    if (preferredLocale) {
-        FcLangSet* langset = FcLangSetCreate();
-        FcLangSetAdd(langset, reinterpret_cast<const FcChar8 *>(preferredLocale));
-        FcPatternAddLangSet(pattern, FC_LANG, langset);
-        FcLangSetDestroy(langset);
-    }
-
-    FcConfigSubstitute(0, pattern, FcMatchPattern);
-    FcDefaultSubstitute(pattern);
-
-    FcResult result;
-    FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
-    FcPatternDestroy(pattern);
-    FcCharSetDestroy(cset);
-
-    if (!fontSet)
-        return WebCString();
-
-    // Older versions of fontconfig have a bug where they cannot select
-    // only scalable fonts so we have to manually filter the results.
-    for (int i = 0; i < fontSet->nfont; ++i) {
-        FcPattern* current = fontSet->fonts[i];
-        FcBool isScalable;
-
-        if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
-            || !isScalable)
-            continue;
-
-        // fontconfig can also return fonts which are unreadable
-        FcChar8* cFilename;
-        if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch)
-            continue;
-
-        if (access(reinterpret_cast<char*>(cFilename), R_OK))
-            continue;
-
-        FcChar8* family;
-        WebCString result;
-        if (FcPatternGetString(current, FC_FAMILY, 0, &family) == FcResultMatch) {
-            const char* charFamily = reinterpret_cast<char*>(family);
-            result = WebCString(charFamily, strlen(charFamily));
-        }
-        FcFontSetDestroy(fontSet);
-        return result;
-    }
-
-    FcFontSetDestroy(fontSet);
-    return WebCString();
-}
-
-void WebFontInfo::renderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* out)
-{
-    bool isBold = sizeAndStyle & 1;
-    bool isItalic = sizeAndStyle & 2;
-    int pixelSize = sizeAndStyle >> 2;
-
-    FcPattern* pattern = FcPatternCreate();
-    FcValue fcvalue;
-
-    fcvalue.type = FcTypeString;
-    fcvalue.u.s = reinterpret_cast<const FcChar8 *>(family);
-    FcPatternAdd(pattern, FC_FAMILY, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeInteger;
-    fcvalue.u.i = isBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
-    FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeInteger;
-    fcvalue.u.i = isItalic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
-    FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeBool;
-    fcvalue.u.b = FcTrue;
-    FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeDouble;
-    fcvalue.u.d = pixelSize;
-    FcPatternAdd(pattern, FC_SIZE, fcvalue, FcFalse);
-
-    FcConfigSubstitute(0, pattern, FcMatchPattern);
-    FcDefaultSubstitute(pattern);
-
-    FcResult result;
-    // Some versions of fontconfig don't actually write a value into result.
-    // However, it's not clear from the documentation if result should be a
-    // non-0 pointer: future versions might expect to be able to write to
-    // it. So we pass in a valid pointer and ignore it.
-    FcPattern* match = FcFontMatch(0, pattern, &result);
-    FcPatternDestroy(pattern);
-
-    out->setDefaults();
-
-    if (!match)
-        return;
-
-    FcBool b;
-    int i;
-
-    if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &b) == FcResultMatch)
-        out->useAntiAlias = b;
-    if (FcPatternGetBool(match, FC_EMBEDDED_BITMAP, 0, &b) == FcResultMatch)
-        out->useBitmaps = b;
-    if (FcPatternGetBool(match, FC_AUTOHINT, 0, &b) == FcResultMatch)
-        out->useAutoHint = b;
-    if (FcPatternGetBool(match, FC_HINTING, 0, &b) == FcResultMatch)
-        out->useHinting = b;
-    if (FcPatternGetInteger(match, FC_HINT_STYLE, 0, &i) == FcResultMatch)
-        out->hintStyle = i;
-    if (FcPatternGetInteger(match, FC_RGBA, 0, &i) == FcResultMatch) {
-        switch (i) {
-        case FC_RGBA_NONE:
-            out->useSubpixel = 0;
-            break;
-        case FC_RGBA_RGB:
-        case FC_RGBA_BGR:
-        case FC_RGBA_VRGB:
-        case FC_RGBA_VBGR:
-            out->useSubpixel = 1;
-            break;
-        default:
-            // This includes FC_RGBA_UNKNOWN.
-            out->useSubpixel = 2;
-            break;
-        }
-    }
-
-    FcPatternDestroy(match);
-}
-
-} // namespace WebKit

Copied: trunk/Source/WebKit/chromium/src/linux/WebFontInfo.cpp (from rev 96657, trunk/Source/WebKit/chromium/src/gtk/WebFontInfo.cpp) (0 => 96660)


--- trunk/Source/WebKit/chromium/src/linux/WebFontInfo.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/src/linux/WebFontInfo.cpp	2011-10-04 23:01:00 UTC (rev 96660)
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2009 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 "WebFontInfo.h"
+
+#include "WebFontRenderStyle.h"
+
+#include <fontconfig/fontconfig.h>
+#include <string.h>
+#include <unicode/utf16.h>
+
+namespace WebKit {
+
+WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale)
+{
+    FcCharSet* cset = FcCharSetCreate();
+    for (size_t i = 0; i < numCharacters; ++i) {
+        if (U16_IS_SURROGATE(characters[i])
+         && U16_IS_SURROGATE_LEAD(characters[i])
+         && i != numCharacters - 1
+         && U16_IS_TRAIL(characters[i + 1])) {
+              FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
+          i++;
+        } else
+              FcCharSetAddChar(cset, characters[i]);
+    }
+    FcPattern* pattern = FcPatternCreate();
+
+    FcValue fcvalue;
+    fcvalue.type = FcTypeCharSet;
+    fcvalue.u.c = cset;
+    FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeBool;
+    fcvalue.u.b = FcTrue;
+    FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
+
+    if (preferredLocale) {
+        FcLangSet* langset = FcLangSetCreate();
+        FcLangSetAdd(langset, reinterpret_cast<const FcChar8 *>(preferredLocale));
+        FcPatternAddLangSet(pattern, FC_LANG, langset);
+        FcLangSetDestroy(langset);
+    }
+
+    FcConfigSubstitute(0, pattern, FcMatchPattern);
+    FcDefaultSubstitute(pattern);
+
+    FcResult result;
+    FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
+    FcPatternDestroy(pattern);
+    FcCharSetDestroy(cset);
+
+    if (!fontSet)
+        return WebCString();
+
+    // Older versions of fontconfig have a bug where they cannot select
+    // only scalable fonts so we have to manually filter the results.
+    for (int i = 0; i < fontSet->nfont; ++i) {
+        FcPattern* current = fontSet->fonts[i];
+        FcBool isScalable;
+
+        if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
+            || !isScalable)
+            continue;
+
+        // fontconfig can also return fonts which are unreadable
+        FcChar8* cFilename;
+        if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch)
+            continue;
+
+        if (access(reinterpret_cast<char*>(cFilename), R_OK))
+            continue;
+
+        FcChar8* family;
+        WebCString result;
+        if (FcPatternGetString(current, FC_FAMILY, 0, &family) == FcResultMatch) {
+            const char* charFamily = reinterpret_cast<char*>(family);
+            result = WebCString(charFamily, strlen(charFamily));
+        }
+        FcFontSetDestroy(fontSet);
+        return result;
+    }
+
+    FcFontSetDestroy(fontSet);
+    return WebCString();
+}
+
+void WebFontInfo::renderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* out)
+{
+    bool isBold = sizeAndStyle & 1;
+    bool isItalic = sizeAndStyle & 2;
+    int pixelSize = sizeAndStyle >> 2;
+
+    FcPattern* pattern = FcPatternCreate();
+    FcValue fcvalue;
+
+    fcvalue.type = FcTypeString;
+    fcvalue.u.s = reinterpret_cast<const FcChar8 *>(family);
+    FcPatternAdd(pattern, FC_FAMILY, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeInteger;
+    fcvalue.u.i = isBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
+    FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeInteger;
+    fcvalue.u.i = isItalic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
+    FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeBool;
+    fcvalue.u.b = FcTrue;
+    FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeDouble;
+    fcvalue.u.d = pixelSize;
+    FcPatternAdd(pattern, FC_SIZE, fcvalue, FcFalse);
+
+    FcConfigSubstitute(0, pattern, FcMatchPattern);
+    FcDefaultSubstitute(pattern);
+
+    FcResult result;
+    // Some versions of fontconfig don't actually write a value into result.
+    // However, it's not clear from the documentation if result should be a
+    // non-0 pointer: future versions might expect to be able to write to
+    // it. So we pass in a valid pointer and ignore it.
+    FcPattern* match = FcFontMatch(0, pattern, &result);
+    FcPatternDestroy(pattern);
+
+    out->setDefaults();
+
+    if (!match)
+        return;
+
+    FcBool b;
+    int i;
+
+    if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &b) == FcResultMatch)
+        out->useAntiAlias = b;
+    if (FcPatternGetBool(match, FC_EMBEDDED_BITMAP, 0, &b) == FcResultMatch)
+        out->useBitmaps = b;
+    if (FcPatternGetBool(match, FC_AUTOHINT, 0, &b) == FcResultMatch)
+        out->useAutoHint = b;
+    if (FcPatternGetBool(match, FC_HINTING, 0, &b) == FcResultMatch)
+        out->useHinting = b;
+    if (FcPatternGetInteger(match, FC_HINT_STYLE, 0, &i) == FcResultMatch)
+        out->hintStyle = i;
+    if (FcPatternGetInteger(match, FC_RGBA, 0, &i) == FcResultMatch) {
+        switch (i) {
+        case FC_RGBA_NONE:
+            out->useSubpixel = 0;
+            break;
+        case FC_RGBA_RGB:
+        case FC_RGBA_BGR:
+        case FC_RGBA_VRGB:
+        case FC_RGBA_VBGR:
+            out->useSubpixel = 1;
+            break;
+        default:
+            // This includes FC_RGBA_UNKNOWN.
+            out->useSubpixel = 2;
+            break;
+        }
+    }
+
+    FcPatternDestroy(match);
+}
+
+} // namespace WebKit

Property changes: trunk/Source/WebKit/chromium/src/linux/WebFontInfo.cpp


Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to