summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/chromium/src/gtk')
-rw-r--r--WebKit/chromium/src/gtk/WebFontInfo.cpp86
-rw-r--r--WebKit/chromium/src/gtk/WebInputEventFactory.cpp77
-rw-r--r--WebKit/chromium/src/gtk/WebScreenInfoFactory.cpp62
3 files changed, 156 insertions, 69 deletions
diff --git a/WebKit/chromium/src/gtk/WebFontInfo.cpp b/WebKit/chromium/src/gtk/WebFontInfo.cpp
index 76ed618..dd25eb1 100644
--- a/WebKit/chromium/src/gtk/WebFontInfo.cpp
+++ b/WebKit/chromium/src/gtk/WebFontInfo.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "WebFontInfo.h"
+#include "WebFontRenderStyle.h"
#include <fontconfig/fontconfig.h>
#include <string.h>
@@ -55,11 +56,11 @@ WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCha
FcValue fcvalue;
fcvalue.type = FcTypeCharSet;
fcvalue.u.c = cset;
- FcPatternAdd(pattern, FC_CHARSET, fcvalue, 0);
+ FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
fcvalue.type = FcTypeBool;
fcvalue.u.b = FcTrue;
- FcPatternAdd(pattern, FC_SCALABLE, fcvalue, 0);
+ FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
@@ -104,4 +105,85 @@ WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCha
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) {
+ FcPatternDestroy(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
diff --git a/WebKit/chromium/src/gtk/WebInputEventFactory.cpp b/WebKit/chromium/src/gtk/WebInputEventFactory.cpp
index 7125a16..71d1b39 100644
--- a/WebKit/chromium/src/gtk/WebInputEventFactory.cpp
+++ b/WebKit/chromium/src/gtk/WebInputEventFactory.cpp
@@ -45,12 +45,15 @@
namespace {
-gint getDoubleClickTime()
+bool countsAsDoubleClick(gint timeDiff, gint xDiff, gint yDiff)
{
static GtkSettings* settings = gtk_settings_get_default();
gint doubleClickTime = 250;
- g_object_get(G_OBJECT(settings), "gtk-double-click-time", &doubleClickTime, 0);
- return doubleClickTime;
+ gint doubleClickDistance = 5;
+ g_object_get(G_OBJECT(settings),
+ "gtk-double-click-time", &doubleClickTime,
+ "gtk-double-click-distance", &doubleClickDistance, NULL);
+ return timeDiff <= doubleClickTime && abs(xDiff) <= doubleClickDistance && abs(yDiff) <= doubleClickDistance;
}
} // namespace
@@ -82,6 +85,10 @@ static int gdkStateToWebEventModifiers(guint state)
modifiers |= WebInputEvent::MiddleButtonDown;
if (state & GDK_BUTTON3_MASK)
modifiers |= WebInputEvent::RightButtonDown;
+ if (state & GDK_LOCK_MASK)
+ modifiers |= WebInputEvent::CapsLockOn;
+ if (state & GDK_MOD2_MASK)
+ modifiers |= WebInputEvent::NumLockOn;
return modifiers;
}
@@ -151,6 +158,60 @@ static int gdkEventToWindowsKeyCode(const GdkEventKey* event)
GDK_period, // 0x3C: GDK_period
GDK_slash, // 0x3D: GDK_slash
0, // 0x3E: GDK_Shift_R
+ 0, // 0x3F:
+ 0, // 0x40:
+ 0, // 0x41:
+ 0, // 0x42:
+ 0, // 0x43:
+ 0, // 0x44:
+ 0, // 0x45:
+ 0, // 0x46:
+ 0, // 0x47:
+ 0, // 0x48:
+ 0, // 0x49:
+ 0, // 0x4A:
+ 0, // 0x4B:
+ 0, // 0x4C:
+ 0, // 0x4D:
+ 0, // 0x4E:
+ 0, // 0x4F:
+ 0, // 0x50:
+ 0, // 0x51:
+ 0, // 0x52:
+ 0, // 0x53:
+ 0, // 0x54:
+ 0, // 0x55:
+ 0, // 0x56:
+ 0, // 0x57:
+ 0, // 0x58:
+ 0, // 0x59:
+ 0, // 0x5A:
+ 0, // 0x5B:
+ 0, // 0x5C:
+ 0, // 0x5D:
+ 0, // 0x5E:
+ 0, // 0x5F:
+ 0, // 0x60:
+ 0, // 0x61:
+ 0, // 0x62:
+ 0, // 0x63:
+ 0, // 0x64:
+ 0, // 0x65:
+ 0, // 0x66:
+ 0, // 0x67:
+ 0, // 0x68:
+ 0, // 0x69:
+ 0, // 0x6A:
+ 0, // 0x6B:
+ 0, // 0x6C:
+ 0, // 0x6D:
+ 0, // 0x6E:
+ 0, // 0x6F:
+ 0, // 0x70:
+ 0, // 0x71:
+ 0, // 0x72:
+ GDK_Super_L, // 0x73: GDK_Super_L
+ GDK_Super_R, // 0x74: GDK_Super_R
};
// |windowsKeyCode| has to include a valid virtual-key code even when we
@@ -350,9 +411,13 @@ WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event)
static int numClicks = 0;
static GdkWindow* eventWindow = 0;
static gint lastLeftClickTime = 0;
+ static gint lastLeftClickX = 0;
+ static gint lastLeftClickY = 0;
- gint time_diff = event->time - lastLeftClickTime;
- if (eventWindow == event->window && time_diff < getDoubleClickTime())
+ gint timeDiff = event->time - lastLeftClickTime;
+ gint xDiff = event->x - lastLeftClickX;
+ gint yDiff = event->y - lastLeftClickY;
+ if (eventWindow == event->window && countsAsDoubleClick(timeDiff, xDiff, yDiff))
numClicks++;
else
numClicks = 1;
@@ -360,6 +425,8 @@ WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event)
result.clickCount = numClicks;
eventWindow = event->window;
lastLeftClickTime = event->time;
+ lastLeftClickX = event->x;
+ lastLeftClickY = event->y;
}
result.button = WebMouseEvent::ButtonNone;
diff --git a/WebKit/chromium/src/gtk/WebScreenInfoFactory.cpp b/WebKit/chromium/src/gtk/WebScreenInfoFactory.cpp
deleted file mode 100644
index 081daa2..0000000
--- a/WebKit/chromium/src/gtk/WebScreenInfoFactory.cpp
+++ /dev/null
@@ -1,62 +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 "WebScreenInfoFactory.h"
-
-#include "WebScreenInfo.h"
-#include <gtk/gtk.h>
-
-namespace WebKit {
-
-WebScreenInfo WebScreenInfoFactory::screenInfo(GtkWidget* widget)
-{
- WebScreenInfo results;
- results.depth = 32;
- results.depthPerComponent = 8;
- results.isMonochrome = false;
-
- if (!widget)
- return results;
-
- GdkScreen* screen = gtk_widget_get_screen(widget);
-
- results.rect = WebRect(
- 0, 0, gdk_screen_get_width(screen), gdk_screen_get_height(screen));
-
- // I don't know of a way to query the "maximize" size of the window (e.g.
- // screen size less sidebars etc) since this is something which only the
- // window manager knows.
- results.availableRect = results.rect;
-
- return results;
-}
-
-} // namespace WebKit