summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/gtk')
-rw-r--r--WebCore/platform/gtk/ClipboardGtk.cpp60
-rw-r--r--WebCore/platform/gtk/ClipboardGtk.h9
-rw-r--r--WebCore/platform/gtk/CursorGtk.cpp431
-rw-r--r--WebCore/platform/gtk/KeyEventGtk.cpp1
-rw-r--r--WebCore/platform/gtk/WidgetGtk.cpp2
5 files changed, 179 insertions, 324 deletions
diff --git a/WebCore/platform/gtk/ClipboardGtk.cpp b/WebCore/platform/gtk/ClipboardGtk.cpp
index c08b03f..7003cf0 100644
--- a/WebCore/platform/gtk/ClipboardGtk.cpp
+++ b/WebCore/platform/gtk/ClipboardGtk.cpp
@@ -23,6 +23,7 @@
#include "Element.h"
#include "FileList.h"
#include "Frame.h"
+#include "HTMLNames.h"
#include "Image.h"
#include "NotImplemented.h"
#include "Pasteboard.h"
@@ -271,38 +272,38 @@ PassRefPtr<FileList> ClipboardGtk::files() const
return fileList.release();
}
-IntPoint ClipboardGtk::dragLocation() const
+void ClipboardGtk::setDragImage(CachedImage* image, const IntPoint& location)
{
- notImplemented();
- return IntPoint(0, 0);
+ setDragImage(image, 0, location);
}
-CachedImage* ClipboardGtk::dragImage() const
+void ClipboardGtk::setDragImageElement(Node* element, const IntPoint& location)
{
- notImplemented();
- return 0;
+ setDragImage(0, element, location);
}
-void ClipboardGtk::setDragImage(CachedImage*, const IntPoint&)
+void ClipboardGtk::setDragImage(CachedImage* image, Node* element, const IntPoint& location)
{
- notImplemented();
-}
+ if (policy() != ClipboardImageWritable && policy() != ClipboardWritable)
+ return;
-Node* ClipboardGtk::dragImageElement()
-{
- notImplemented();
- return 0;
-}
+ if (m_dragImage)
+ m_dragImage->removeClient(this);
+ m_dragImage = image;
+ if (m_dragImage)
+ m_dragImage->addClient(this);
-void ClipboardGtk::setDragImageElement(Node*, const IntPoint&)
-{
- notImplemented();
+ m_dragLoc = location;
+ m_dragImageElement = element;
}
-DragImageRef ClipboardGtk::createDragImage(IntPoint&) const
+DragImageRef ClipboardGtk::createDragImage(IntPoint& location) const
{
- notImplemented();
- return 0;
+ location = m_dragLoc;
+ if (!m_dragImage)
+ return 0;
+
+ return createDragImageFromImage(m_dragImage->image());
}
static CachedImage* getCachedImage(Element* element)
@@ -320,23 +321,20 @@ static CachedImage* getCachedImage(Element* element)
return 0;
}
-void ClipboardGtk::declareAndWriteDragImage(Element* element, const KURL& url, const String& label, Frame*)
+void ClipboardGtk::declareAndWriteDragImage(Element* element, const KURL& url, const String& label, Frame* frame)
{
- CachedImage* cachedImage = getCachedImage(element);
- if (!cachedImage || !cachedImage->isLoaded())
+ m_dataObject->setURL(url, label);
+ m_dataObject->setMarkup(createMarkup(element, IncludeNode, 0, AbsoluteURLs));
+
+ CachedImage* image = getCachedImage(element);
+ if (!image || !image->isLoaded())
return;
- GdkPixbuf* pixbuf = cachedImage->image()->getGdkPixbuf();
+ GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->image()->getGdkPixbuf());
if (!pixbuf)
return;
- GtkClipboard* imageClipboard = gtk_clipboard_get(gdk_atom_intern_static_string("WebKitClipboardImage"));
- gtk_clipboard_clear(imageClipboard);
-
- gtk_clipboard_set_image(imageClipboard, pixbuf);
- g_object_unref(pixbuf);
-
- writeURL(url, label, 0);
+ m_dataObject->setImage(pixbuf.get());
}
void ClipboardGtk::writeURL(const KURL& url, const String& label, Frame*)
diff --git a/WebCore/platform/gtk/ClipboardGtk.h b/WebCore/platform/gtk/ClipboardGtk.h
index 5b42ac6..8b8ee38 100644
--- a/WebCore/platform/gtk/ClipboardGtk.h
+++ b/WebCore/platform/gtk/ClipboardGtk.h
@@ -27,6 +27,7 @@
#ifndef ClipboardGtk_h
#define ClipboardGtk_h
+#include "CachedResourceClient.h"
#include "Clipboard.h"
#include "DataObjectGtk.h"
@@ -39,7 +40,7 @@ namespace WebCore {
// State available during IE's events for drag and drop and copy/paste
// Created from the EventHandlerGtk to be used by the dom
- class ClipboardGtk : public Clipboard {
+ class ClipboardGtk : public Clipboard, public CachedResourceClient {
public:
static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, GtkClipboard* clipboard, bool isForDragging, Frame* frame)
{
@@ -60,14 +61,14 @@ namespace WebCore {
virtual HashSet<String> types() const;
virtual PassRefPtr<FileList> files() const;
- IntPoint dragLocation() const;
- CachedImage* dragImage() const;
void setDragImage(CachedImage*, const IntPoint&);
- Node* dragImageElement();
void setDragImageElement(Node*, const IntPoint&);
+ void setDragImage(CachedImage*, Node*, const IntPoint&);
virtual DragImageRef createDragImage(IntPoint&) const;
+#if ENABLE(DRAG_SUPPORT)
virtual void declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*);
+#endif
virtual void writeURL(const KURL&, const String&, Frame*);
virtual void writeRange(Range*, Frame*);
virtual void writePlainText(const String&);
diff --git a/WebCore/platform/gtk/CursorGtk.cpp b/WebCore/platform/gtk/CursorGtk.cpp
index a535f0c..41b0800 100644
--- a/WebCore/platform/gtk/CursorGtk.cpp
+++ b/WebCore/platform/gtk/CursorGtk.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
* Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
+ * Copyright (C) 2010 Igalia S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,318 +31,172 @@
#include "Image.h"
#include "IntPoint.h"
-
-#include <wtf/Assertions.h>
-
#include <gdk/gdk.h>
#include <gtk/gtk.h>
+#include <wtf/Assertions.h>
namespace WebCore {
-static GdkCursor* customCursorNew(CustomCursorType cursorType)
+static GRefPtr<GdkCursor> createNamedCursor(CustomCursorType cursorType)
{
CustomCursor cursor = CustomCursors[cursorType];
- GdkCursor* c = gdk_cursor_new_from_name(gdk_display_get_default(), cursor.name);
- if (!c) {
- const GdkColor fg = { 0, 0, 0, 0 };
- const GdkColor bg = { 65535, 65535, 65535, 65535 };
+ GRefPtr<GdkCursor> c = adoptGRef(gdk_cursor_new_from_name(gdk_display_get_default(), cursor.name));
+ if (c)
+ return c;
- GdkPixmap* source = gdk_bitmap_create_from_data(NULL, cursor.bits, 32, 32);
- GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, cursor.mask_bits, 32, 32);
- c = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, cursor.hot_x, cursor.hot_y);
- g_object_unref(source);
- g_object_unref(mask);
- }
- return c;
+ const GdkColor fg = { 0, 0, 0, 0 };
+ const GdkColor bg = { 65535, 65535, 65535, 65535 };
+ GRefPtr<GdkPixmap> source = adoptGRef(gdk_bitmap_create_from_data(0, cursor.bits, 32, 32));
+ GRefPtr<GdkPixmap> mask = adoptGRef(gdk_bitmap_create_from_data(0, cursor.mask_bits, 32, 32));
+ return adoptGRef(gdk_cursor_new_from_pixmap(source.get(), mask.get(), &fg, &bg, cursor.hot_x, cursor.hot_y));
}
-
-Cursor::Cursor(const Cursor& other)
- : m_platformCursor(other.m_platformCursor)
-{
- if (m_platformCursor)
- gdk_cursor_ref(m_platformCursor);
-}
-
-Cursor::Cursor(Image* image, const IntPoint& hotSpot)
+static GRefPtr<GdkCursor> createCustomCursor(Image* image, const IntPoint& hotSpot)
{
IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
- GdkPixbuf* pixbuf = image->getGdkPixbuf();
- m_platformCursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, effectiveHotSpot.x(), effectiveHotSpot.y());
- g_object_unref(pixbuf);
+ GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->getGdkPixbuf());
+ return adoptGRef(gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf.get(), effectiveHotSpot.x(), effectiveHotSpot.y()));
+}
+
+void Cursor::ensurePlatformCursor() const
+{
+ if (m_platformCursor || m_type == Cursor::Pointer)
+ return;
+
+ switch (m_type) {
+ case Cursor::Pointer:
+ // A null GdkCursor is the default cursor for the window.
+ m_platformCursor = 0;
+ break;
+ case Cursor::Cross:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_CROSS));
+ break;
+ case Cursor::Hand:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_HAND2));
+ break;
+ case Cursor::IBeam:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_XTERM));
+ break;
+ case Cursor::Wait:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_WATCH));
+ break;
+ case Cursor::Help:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_QUESTION_ARROW));
+ break;
+ case Cursor::Move:
+ case Cursor::MiddlePanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_FLEUR));
+ break;
+ case Cursor::EastResize:
+ case Cursor::EastPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_RIGHT_SIDE));
+ break;
+ case Cursor::NorthResize:
+ case Cursor::NorthPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_TOP_SIDE));
+ break;
+ case Cursor::NorthEastResize:
+ case Cursor::NorthEastPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_LEFT_SIDE));
+ break;
+ case Cursor::NorthWestResize:
+ case Cursor::NorthWestPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_TOP_LEFT_CORNER));
+ break;
+ case Cursor::SouthResize:
+ case Cursor::SouthPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_BOTTOM_SIDE));
+ break;
+ case Cursor::SouthEastResize:
+ case Cursor::SouthEastPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER));
+ break;
+ case Cursor::SouthWestResize:
+ case Cursor::SouthWestPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_BOTTOM_LEFT_CORNER));
+ break;
+ case Cursor::WestResize:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_LEFT_SIDE));
+ break;
+ case Cursor::NorthSouthResize:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_TOP_TEE));
+ break;
+ case Cursor::EastWestResize:
+ case Cursor::WestPanning:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_LEFT_SIDE));
+ break;
+ case Cursor::NorthEastSouthWestResize:
+ case Cursor::NorthWestSouthEastResize:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_SIZING));
+ break;
+ case Cursor::ColumnResize:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW));
+ break;
+ case Cursor::RowResize:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW));
+ break;
+ case Cursor::VerticalText:
+ m_platformCursor = createNamedCursor(CustomCursorVerticalText);
+ break;
+ case Cursor::Cell:
+ m_platformCursor = adoptGRef(gdk_cursor_new(GDK_PLUS));
+ break;
+ case Cursor::ContextMenu:
+ m_platformCursor = createNamedCursor(CustomCursorContextMenu);
+ break;
+ case Cursor::Alias:
+ m_platformCursor = createNamedCursor(CustomCursorAlias);
+ break;
+ case Cursor::Progress:
+ m_platformCursor = createNamedCursor(CustomCursorProgress);
+ break;
+ case Cursor::NoDrop:
+ case Cursor::NotAllowed:
+ m_platformCursor = createNamedCursor(CustomCursorNoDrop);
+ break;
+ case Cursor::Copy:
+ m_platformCursor = createNamedCursor(CustomCursorCopy);
+ break;
+ case Cursor::None:
+ m_platformCursor = createNamedCursor(CustomCursorNone);
+ break;
+ case Cursor::ZoomIn:
+ m_platformCursor = createNamedCursor(CustomCursorZoomIn);
+ break;
+ case Cursor::ZoomOut:
+ m_platformCursor = createNamedCursor(CustomCursorZoomOut);
+ break;
+ case Cursor::Grab:
+ m_platformCursor = createNamedCursor(CustomCursorGrab);
+ break;
+ case Cursor::Grabbing:
+ m_platformCursor = createNamedCursor(CustomCursorGrabbing);
+ break;
+ case Cursor::Custom:
+ m_platformCursor = createCustomCursor(m_image.get(), m_hotSpot);
+ break;
+ }
}
-Cursor::~Cursor()
+Cursor::Cursor(const Cursor& other)
+ : m_type(other.m_type)
+ , m_image(other.m_image)
+ , m_hotSpot(other.m_hotSpot)
+ , m_platformCursor(other.m_platformCursor)
{
- if (m_platformCursor)
- gdk_cursor_unref(m_platformCursor);
}
Cursor& Cursor::operator=(const Cursor& other)
{
- gdk_cursor_ref(other.m_platformCursor);
- gdk_cursor_unref(m_platformCursor);
+ m_type = other.m_type;
+ m_image = other.m_image;
+ m_hotSpot = other.m_hotSpot;
m_platformCursor = other.m_platformCursor;
return *this;
}
-Cursor::Cursor(GdkCursor* c)
- : m_platformCursor(c)
-{
- m_platformCursor = c;
-
- // The GdkCursor may be NULL - the default cursor for the window.
- if (c)
- gdk_cursor_ref(c);
-}
-
-const Cursor& pointerCursor()
-{
- static Cursor c = 0;
- return c;
-}
-
-const Cursor& crossCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_CROSS);
- return c;
-}
-
-const Cursor& handCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_HAND2);
- return c;
-}
-
-const Cursor& moveCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_FLEUR);
- return c;
-}
-
-const Cursor& iBeamCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_XTERM);
- return c;
-}
-
-const Cursor& waitCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_WATCH);
- return c;
-}
-
-const Cursor& helpCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_QUESTION_ARROW);
- return c;
-}
-
-const Cursor& eastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_RIGHT_SIDE);
- return c;
-}
-
-const Cursor& northResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_SIDE);
- return c;
-}
-
-const Cursor& northEastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_RIGHT_CORNER);
- return c;
-}
-
-const Cursor& northWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_LEFT_CORNER);
- return c;
-}
-
-const Cursor& southResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_BOTTOM_SIDE);
- return c;
-}
-
-const Cursor& southEastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER);
- return c;
-}
-
-const Cursor& southWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_BOTTOM_LEFT_CORNER);
- return c;
-}
-
-const Cursor& westResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_LEFT_SIDE);
- return c;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_TEE);
- return c;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_LEFT_SIDE);
- return c;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_SIZING);
- return c;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_SIZING);
- return c;
-}
-
-const Cursor& columnResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW);
- return c;
-}
-
-const Cursor& rowResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW);
- return c;
-}
-
-const Cursor& middlePanningCursor()
-{
- return moveCursor();
-}
-
-const Cursor& eastPanningCursor()
-{
- return eastResizeCursor();
-}
-
-const Cursor& northPanningCursor()
-{
- return northResizeCursor();
-}
-
-const Cursor& northEastPanningCursor()
-{
- return northEastResizeCursor();
-}
-
-const Cursor& northWestPanningCursor()
-{
- return northWestResizeCursor();
-}
-
-const Cursor& southPanningCursor()
-{
- return southResizeCursor();
-}
-
-const Cursor& southEastPanningCursor()
-{
- return southEastResizeCursor();
-}
-
-const Cursor& southWestPanningCursor()
-{
- return southWestResizeCursor();
-}
-
-const Cursor& westPanningCursor()
-{
- return westResizeCursor();
-}
-
-
-const Cursor& verticalTextCursor()
-{
- static Cursor c = customCursorNew(CustomCursorVerticalText);
- return c;
-}
-
-const Cursor& cellCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_PLUS);
- return c;
-}
-
-const Cursor& contextMenuCursor()
-{
- static Cursor c = customCursorNew(CustomCursorContextMenu);
- return c;
-}
-
-const Cursor& noDropCursor()
-{
- static Cursor c = customCursorNew(CustomCursorNoDrop);
- return c;
-}
-
-const Cursor& copyCursor()
-{
- static Cursor c = customCursorNew(CustomCursorCopy);
- return c;
-}
-
-const Cursor& progressCursor()
-{
- static Cursor c = customCursorNew(CustomCursorProgress);
- return c;
-}
-
-const Cursor& aliasCursor()
-{
- static Cursor c = customCursorNew(CustomCursorAlias);
- return c;
-}
-
-const Cursor& noneCursor()
-{
- static Cursor c = customCursorNew(CustomCursorNone);
- return c;
-}
-
-const Cursor& notAllowedCursor()
-{
- return noDropCursor();
-}
-
-const Cursor& zoomInCursor()
-{
- static Cursor c = customCursorNew(CustomCursorZoomIn);
- return c;
-}
-
-const Cursor& zoomOutCursor()
-{
- static Cursor c = customCursorNew(CustomCursorZoomOut);
- return c;
-}
-
-const Cursor& grabCursor()
-{
- static Cursor c = customCursorNew(CustomCursorGrab);
- return c;
-}
-
-const Cursor& grabbingCursor()
+Cursor::~Cursor()
{
- static Cursor c = customCursorNew(CustomCursorGrabbing);
- return c;
}
}
diff --git a/WebCore/platform/gtk/KeyEventGtk.cpp b/WebCore/platform/gtk/KeyEventGtk.cpp
index e9756d8..f90647d 100644
--- a/WebCore/platform/gtk/KeyEventGtk.cpp
+++ b/WebCore/platform/gtk/KeyEventGtk.cpp
@@ -126,6 +126,7 @@ static String keyIdentifierForGdkKeyCode(guint keyCode)
case GDK_Pause:
return "Pause";
case GDK_3270_PrintScreen:
+ case GDK_Print:
return "PrintScreen";
case GDK_Right:
return "Right";
diff --git a/WebCore/platform/gtk/WidgetGtk.cpp b/WebCore/platform/gtk/WidgetGtk.cpp
index c2c11bd..db316d5 100644
--- a/WebCore/platform/gtk/WidgetGtk.cpp
+++ b/WebCore/platform/gtk/WidgetGtk.cpp
@@ -67,7 +67,7 @@ static GdkDrawable* gdkDrawable(PlatformWidget widget)
void Widget::setCursor(const Cursor& cursor)
{
- GdkCursor* platformCursor = cursor.impl();
+ GdkCursor* platformCursor = cursor.platformCursor().get();
// http://bugs.webkit.org/show_bug.cgi?id=16388
// [GTK] Widget::setCursor() gets called frequently