summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/chromium
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/chromium')
-rw-r--r--WebCore/platform/chromium/ChromiumBridge.h16
-rw-r--r--WebCore/platform/chromium/ClipboardChromium.cpp3
-rw-r--r--WebCore/platform/chromium/PasteboardPrivate.h4
-rw-r--r--WebCore/platform/chromium/PopupMenuChromium.cpp6
-rw-r--r--WebCore/platform/chromium/ScrollbarThemeChromium.cpp18
-rw-r--r--WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp170
-rw-r--r--WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp18
7 files changed, 191 insertions, 44 deletions
diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h
index 3e9406d..3284aae 100644
--- a/WebCore/platform/chromium/ChromiumBridge.h
+++ b/WebCore/platform/chromium/ChromiumBridge.h
@@ -1,10 +1,10 @@
/*
* 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
@@ -14,7 +14,7 @@
* * 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
@@ -38,6 +38,7 @@
#include "PasteboardPrivate.h"
#include "PluginData.h"
+#include <wtf/HashSet.h>
#include <wtf/Vector.h>
typedef struct NPObject NPObject;
@@ -60,6 +61,7 @@ typedef struct HFONT__* HFONT;
namespace WebCore {
+ class ClipboardData;
class Color;
class Cursor;
class Document;
@@ -91,13 +93,19 @@ namespace WebCore {
static String clipboardReadPlainText(PasteboardPrivate::ClipboardBuffer);
static void clipboardReadHTML(PasteboardPrivate::ClipboardBuffer, String*, KURL*);
- // Only the clipboardRead functions take a buffer argument because
+ // Only the clipboardRead functions take a buffer argument because
// Chromium currently uses a different technique to write to alternate
// clipboard buffers.
static void clipboardWriteSelection(const String&, const KURL&, const String&, bool);
static void clipboardWritePlainText(const String&);
static void clipboardWriteURL(const KURL&, const String&);
static void clipboardWriteImage(NativeImagePtr, const KURL&, const String&);
+ static void clipboardWriteData(ClipboardData*);
+
+ // Interface for handling copy and paste, drag and drop, and selection copy.
+ static HashSet<String> clipboardReadAvailableTypes(PasteboardPrivate::ClipboardBuffer, bool* containsFilenames);
+ static bool clipboardReadData(PasteboardPrivate::ClipboardBuffer, const String& type, String& data, String& metadata);
+ static Vector<String> clipboardReadFilenames(PasteboardPrivate::ClipboardBuffer);
// Cookies ------------------------------------------------------------
static void setCookies(const Document*, const KURL&, const String& value);
diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp
index 29f9620..8aad8aa 100644
--- a/WebCore/platform/chromium/ClipboardChromium.cpp
+++ b/WebCore/platform/chromium/ClipboardChromium.cpp
@@ -495,8 +495,11 @@ void ClipboardChromium::writeURL(const KURL& url, const String& title, Frame*)
{
if (!m_dataObject)
return;
+ ASSERT(!url.isEmpty());
m_dataObject->url = url;
m_dataObject->urlTitle = title;
+ m_dataObject->uriList.clear();
+ m_dataObject->uriList.append(url);
// The URL can also be used as plain text.
m_dataObject->plainText = url.string();
diff --git a/WebCore/platform/chromium/PasteboardPrivate.h b/WebCore/platform/chromium/PasteboardPrivate.h
index 95cc697..1de7fe3 100644
--- a/WebCore/platform/chromium/PasteboardPrivate.h
+++ b/WebCore/platform/chromium/PasteboardPrivate.h
@@ -33,8 +33,7 @@
namespace WebCore {
- class PasteboardPrivate
- {
+ class PasteboardPrivate {
public:
enum ClipboardFormat {
HTMLFormat,
@@ -44,6 +43,7 @@ namespace WebCore {
enum ClipboardBuffer {
StandardBuffer,
SelectionBuffer,
+ DragBuffer,
};
};
diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp
index e8ab333..7e3a2a0 100644
--- a/WebCore/platform/chromium/PopupMenuChromium.cpp
+++ b/WebCore/platform/chromium/PopupMenuChromium.cpp
@@ -53,6 +53,7 @@
#include "ScrollbarTheme.h"
#include "StringTruncator.h"
#include "SystemTime.h"
+#include "UserGestureIndicator.h"
#include <wtf/CurrentTime.h>
@@ -451,30 +452,35 @@ void PopupContainer::layout()
bool PopupContainer::handleMouseDownEvent(const PlatformMouseEvent& event)
{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
return m_listBox->handleMouseDownEvent(
constructRelativeMouseEvent(event, this, m_listBox.get()));
}
bool PopupContainer::handleMouseMoveEvent(const PlatformMouseEvent& event)
{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
return m_listBox->handleMouseMoveEvent(
constructRelativeMouseEvent(event, this, m_listBox.get()));
}
bool PopupContainer::handleMouseReleaseEvent(const PlatformMouseEvent& event)
{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
return m_listBox->handleMouseReleaseEvent(
constructRelativeMouseEvent(event, this, m_listBox.get()));
}
bool PopupContainer::handleWheelEvent(const PlatformWheelEvent& event)
{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
return m_listBox->handleWheelEvent(
constructRelativeWheelEvent(event, this, m_listBox.get()));
}
bool PopupContainer::handleKeyEvent(const PlatformKeyboardEvent& event)
{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
return m_listBox->handleKeyEvent(event);
}
diff --git a/WebCore/platform/chromium/ScrollbarThemeChromium.cpp b/WebCore/platform/chromium/ScrollbarThemeChromium.cpp
index a6720a1..cf3ca6f 100644
--- a/WebCore/platform/chromium/ScrollbarThemeChromium.cpp
+++ b/WebCore/platform/chromium/ScrollbarThemeChromium.cpp
@@ -75,6 +75,24 @@ IntRect ScrollbarThemeChromium::forwardButtonRect(Scrollbar* scrollbar, Scrollba
return IntRect(x, y, size.width(), size.height());
}
+IntRect ScrollbarThemeChromium::trackRect(Scrollbar* scrollbar, bool)
+{
+ IntSize bs = buttonSize(scrollbar);
+ // The buttons at the top and bottom of the scrollbar are square, so the
+ // thickness of the scrollbar is also their height.
+ int thickness = scrollbarThickness(scrollbar->controlSize());
+ if (scrollbar->orientation() == HorizontalScrollbar) {
+ // Once the scrollbar becomes smaller than the natural size of the
+ // two buttons, the track disappears.
+ if (scrollbar->width() < 2 * thickness)
+ return IntRect();
+ return IntRect(scrollbar->x() + bs.width(), scrollbar->y(), scrollbar->width() - 2 * bs.width(), thickness);
+ }
+ if (scrollbar->height() < 2 * thickness)
+ return IntRect();
+ return IntRect(scrollbar->x(), scrollbar->y() + bs.height(), thickness, scrollbar->height() - 2 * bs.height());
+}
+
void ScrollbarThemeChromium::paintTrackBackground(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
{
// Just assume a forward track part. We only paint the track as a single piece when there is no thumb.
diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
index 3a1a652..a9cff9f 100644
--- a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
+++ b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp
@@ -40,6 +40,9 @@
namespace WebCore {
+static const int scrollbarThicknessValue = 15;
+static const int buttonLength = 14;
+
ScrollbarTheme* ScrollbarTheme::nativeTheme()
{
static ScrollbarThemeChromiumLinux theme;
@@ -48,7 +51,7 @@ ScrollbarTheme* ScrollbarTheme::nativeTheme()
int ScrollbarThemeChromiumLinux::scrollbarThickness(ScrollbarControlSize controlSize)
{
- return 15;
+ return scrollbarThicknessValue;
}
static void drawVertLine(SkCanvas* canvas, int x, int y1, int y2, const SkPaint& paint)
@@ -120,7 +123,7 @@ static SkColor outlineColor(SkScalar* hsv1, SkScalar* hsv2)
//
// 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.2, 0.5);
+ 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)
@@ -129,15 +132,6 @@ static SkColor outlineColor(SkScalar* hsv1, SkScalar* hsv2)
return saturateAndBrighten(hsv2, -0.2, diff);
}
-IntRect ScrollbarThemeChromium::trackRect(Scrollbar* scrollbar, bool)
-{
- IntSize bs = buttonSize(scrollbar);
- int thickness = scrollbarThickness(scrollbar->controlSize());
- if (scrollbar->orientation() == HorizontalScrollbar)
- return IntRect(scrollbar->x() + bs.width(), scrollbar->y(), scrollbar->width(), thickness);
- return IntRect(scrollbar->x(), scrollbar->y() + bs.height(), thickness, scrollbar->height());
-}
-
void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType)
{
SkCanvas* const canvas = gc->platformContext()->canvas();
@@ -145,22 +139,155 @@ void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar
SkIRect skrect;
skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
- SkScalar track_hsv[3];
- SkColorToHSV(RenderThemeChromiumLinux::trackColor(), track_hsv);
- paint.setColor(saturateAndBrighten(track_hsv, 0, 0));
+ SkScalar trackHSV[3];
+ SkColorToHSV(RenderThemeChromiumLinux::trackColor(), trackHSV);
+ paint.setColor(saturateAndBrighten(trackHSV, 0, 0));
canvas->drawIRect(skrect, paint);
- SkScalar thumb_hsv[3];
+ SkScalar thumbHSV[3];
SkColorToHSV(RenderThemeChromiumLinux::thumbInactiveColor(),
- thumb_hsv);
+ thumbHSV);
- paint.setColor(outlineColor(track_hsv, thumb_hsv));
+ paint.setColor(outlineColor(trackHSV, thumbHSV));
drawBox(canvas, rect, paint);
}
void ScrollbarThemeChromiumLinux::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
{
- // We don't use buttons
+ 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;
+
+ if (scrollbar->orientation() == HorizontalScrollbar) {
+ if (part == BackButtonStartPart)
+ direction = West;
+ else
+ direction = East;
+ } else {
+ if (part == BackButtonStartPart)
+ direction = North;
+ else
+ direction = South;
+ }
+
+ // 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;
+
+ // 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();
+
+ canvas->drawPath(path, paint);
}
void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect)
@@ -224,8 +351,11 @@ bool ScrollbarThemeChromiumLinux::shouldCenterOnThumb(Scrollbar*, const Platform
IntSize ScrollbarThemeChromiumLinux::buttonSize(Scrollbar* scrollbar)
{
- // On Linux, we don't use buttons
- return IntSize(0, 0);
+ if (scrollbar->orientation() == VerticalScrollbar)
+ return IntSize(scrollbarThicknessValue, buttonLength);
+
+ // HorizontalScrollbar
+ return IntSize(buttonLength, scrollbarThicknessValue);
}
int ScrollbarThemeChromiumLinux::minimumThumbLength(Scrollbar* scrollbar)
diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp b/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp
index d84ad5e..ba7e97b 100644
--- a/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp
+++ b/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp
@@ -57,24 +57,6 @@ static const int kMacScrollbarSize[3] = { 15, 11, 15 };
static const int kOffEndMultiplier = 3;
static const int kOffSideMultiplier = 8;
-IntRect ScrollbarThemeChromium::trackRect(Scrollbar* scrollbar, bool)
-{
- IntSize bs = buttonSize(scrollbar);
- // The buttons at the top and bottom of the scrollbar are square, so the
- // thickness of the scrollbar is also their height.
- int thickness = scrollbarThickness(scrollbar->controlSize());
- if (scrollbar->orientation() == HorizontalScrollbar) {
- // Once the scrollbar becomes smaller than the natural size of the
- // two buttons, the track disappears.
- if (scrollbar->width() < 2 * thickness)
- return IntRect();
- return IntRect(scrollbar->x() + bs.width(), scrollbar->y(), scrollbar->width() - 2 * bs.width(), thickness);
- }
- if (scrollbar->height() < 2 * thickness)
- return IntRect();
- return IntRect(scrollbar->x(), scrollbar->y() + bs.height(), thickness, scrollbar->height() - 2 * bs.height());
-}
-
int ScrollbarThemeChromiumWin::scrollbarThickness(ScrollbarControlSize controlSize)
{
static int thickness;