diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-21 22:04:41 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-21 22:04:41 +0000 |
commit | ca340e836e37e450e86a2a180e02c77af319e4d7 (patch) | |
tree | 47998c9106f3c428dfbeb10b9ac262282270974f /chrome/browser/gtk | |
parent | d6b671d0968013c3205c50ebaf45f356e34a58c5 (diff) | |
download | chromium_src-ca340e836e37e450e86a2a180e02c77af319e4d7.zip chromium_src-ca340e836e37e450e86a2a180e02c77af319e4d7.tar.gz chromium_src-ca340e836e37e450e86a2a180e02c77af319e4d7.tar.bz2 |
Remove src/app's dependency on the WebKit api.
src/app shouldn't depend on webkit in anyway. DEPS allows this
because it allows paths pulled in by deps = {} (stuff pulled in
by gclient). Add a new rule to explicitly disallow this.
Review URL: http://codereview.chromium.org/3998004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/gtk_util.cc | 29 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_util.h | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/tab_contents_drag_source.cc | 4 |
3 files changed, 37 insertions, 2 deletions
diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc index 57d4f4d..babed07 100644 --- a/chrome/browser/gtk/gtk_util.cc +++ b/chrome/browser/gtk/gtk_util.cc @@ -37,6 +37,13 @@ #include "views/window/window.h" #endif // defined(OS_CHROMEOS) +using WebKit::WebDragOperationsMask; +using WebKit::WebDragOperation; +using WebKit::WebDragOperationNone; +using WebKit::WebDragOperationCopy; +using WebKit::WebDragOperationLink; +using WebKit::WebDragOperationMove; + namespace { const char kBoldLabelMarkup[] = "<span weight='bold'>%s</span>"; @@ -1107,6 +1114,28 @@ void InitLabelSizeRequestAndEllipsizeMode(GtkWidget* label) { gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END); } +GdkDragAction WebDragOpToGdkDragAction(WebDragOperationsMask op) { + GdkDragAction action = static_cast<GdkDragAction>(0); + if (op & WebDragOperationCopy) + action = static_cast<GdkDragAction>(action | GDK_ACTION_COPY); + if (op & WebDragOperationLink) + action = static_cast<GdkDragAction>(action | GDK_ACTION_LINK); + if (op & WebDragOperationMove) + action = static_cast<GdkDragAction>(action | GDK_ACTION_MOVE); + return action; +} + +WebDragOperationsMask GdkDragActionToWebDragOp(GdkDragAction action) { + WebDragOperationsMask op = WebDragOperationNone; + if (action & GDK_ACTION_COPY) + op = static_cast<WebDragOperationsMask>(op | WebDragOperationCopy); + if (action & GDK_ACTION_LINK) + op = static_cast<WebDragOperationsMask>(op | WebDragOperationLink); + if (action & GDK_ACTION_MOVE) + op = static_cast<WebDragOperationsMask>(op | WebDragOperationMove); + return op; +} + void DrawTopDropShadowForRenderView(cairo_t* cr, const gfx::Point& origin, const gfx::Rect& paint_rect) { gfx::Rect shadow_rect(paint_rect.x(), origin.y(), diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h index 9c6e158..466ba7e 100644 --- a/chrome/browser/gtk/gtk_util.h +++ b/chrome/browser/gtk/gtk_util.h @@ -14,6 +14,7 @@ #include "base/string16.h" #include "gfx/point.h" #include "gfx/rect.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" #include "webkit/glue/window_open_disposition.h" typedef struct _cairo cairo_t; @@ -338,6 +339,11 @@ void SetLabelWidth(GtkWidget* label, int pixel_width); // to make sure the pango can get correct font information for the calculation. void InitLabelSizeRequestAndEllipsizeMode(GtkWidget* label); +// Convenience methods for converting between web drag operations and the GDK +// equivalent. +GdkDragAction WebDragOpToGdkDragAction(WebKit::WebDragOperationsMask op); +WebKit::WebDragOperationsMask GdkDragActionToWebDragOp(GdkDragAction action); + // Code to draw the drop shadow below an infobar (at the top of the render // view). void DrawTopDropShadowForRenderView(cairo_t* cr, const gfx::Point& origin, diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc index e6da6ad..393fc99 100644 --- a/chrome/browser/gtk/tab_contents_drag_source.cc +++ b/chrome/browser/gtk/tab_contents_drag_source.cc @@ -126,7 +126,7 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data, // initiating event from webkit. GdkDragContext* context = gtk_drag_begin( drag_widget_, list, - gtk_dnd_util::WebDragOpToGdkDragAction(allowed_ops), + gtk_util::WebDragOpToGdkDragAction(allowed_ops), 1, // Drags are always initiated by the left button. reinterpret_cast<GdkEvent*>(last_mouse_down)); // The drag adds a ref; let it own the list. @@ -356,7 +356,7 @@ void TabContentsDragSource::OnDragEnd(GtkWidget* sender, if (tab_contents()->render_view_host()) { tab_contents()->render_view_host()->DragSourceEndedAt( client.x(), client.y(), root.x(), root.y(), - gtk_dnd_util::GdkDragActionToWebDragOp(drag_context->action)); + gtk_util::GdkDragActionToWebDragOp(drag_context->action)); } } |