| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/glue/webcursor.h" | 5 #include "webkit/glue/webcursor.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 | 8 |
| 9 #include "config.h" | 9 #include "base/logging.h" |
| 10 #include "PlatformCursor.h" | 10 #include "webkit/api/public/WebCursorInfo.h" |
| 11 | 11 |
| 12 #undef LOG | 12 using WebKit::WebCursorInfo; |
| 13 #include "base/logging.h" | |
| 14 | |
| 15 using WebCore::PlatformCursor; | |
| 16 | 13 |
| 17 namespace { | 14 namespace { |
| 18 | 15 |
| 19 // webcursor_gtk_data.h is taken directly from WebKit's CursorGtk.h. | 16 // webcursor_gtk_data.h is taken directly from WebKit's CursorGtk.h. |
| 20 #include "webkit/glue/webcursor_gtk_data.h" | 17 #include "webkit/glue/webcursor_gtk_data.h" |
| 21 | 18 |
| 22 // This helper function is taken directly from WebKit's CursorGtk.cpp. | 19 // This helper function is taken directly from WebKit's CursorGtk.cpp. |
| 23 // It attempts to create a custom cursor from the data inlined in | 20 // It attempts to create a custom cursor from the data inlined in |
| 24 // webcursor_gtk_data.h. | 21 // webcursor_gtk_data.h. |
| 25 GdkCursor* GetInlineCustomCursor(CustomCursorType type) { | 22 GdkCursor* GetInlineCustomCursor(CustomCursorType type) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 41 return cursor; | 38 return cursor; |
| 42 } | 39 } |
| 43 | 40 |
| 44 } // end anonymous namespace | 41 } // end anonymous namespace |
| 45 | 42 |
| 46 GdkCursorType WebCursor::GetCursorType() const { | 43 GdkCursorType WebCursor::GetCursorType() const { |
| 47 // http://library.gnome.org/devel/gdk/2.12/gdk-Cursors.html has images | 44 // http://library.gnome.org/devel/gdk/2.12/gdk-Cursors.html has images |
| 48 // of the default X theme, but beware that the user's cursor theme can | 45 // of the default X theme, but beware that the user's cursor theme can |
| 49 // change everything. | 46 // change everything. |
| 50 switch (type_) { | 47 switch (type_) { |
| 51 case PlatformCursor::TypePointer: | 48 case WebCursorInfo::TypePointer: |
| 52 return GDK_LAST_CURSOR; | 49 return GDK_LAST_CURSOR; |
| 53 case PlatformCursor::TypeCross: | 50 case WebCursorInfo::TypeCross: |
| 54 return GDK_CROSS; | 51 return GDK_CROSS; |
| 55 case PlatformCursor::TypeHand: | 52 case WebCursorInfo::TypeHand: |
| 56 return GDK_HAND2; | 53 return GDK_HAND2; |
| 57 case PlatformCursor::TypeIBeam: | 54 case WebCursorInfo::TypeIBeam: |
| 58 return GDK_XTERM; | 55 return GDK_XTERM; |
| 59 case PlatformCursor::TypeWait: | 56 case WebCursorInfo::TypeWait: |
| 60 return GDK_WATCH; | 57 return GDK_WATCH; |
| 61 case PlatformCursor::TypeHelp: | 58 case WebCursorInfo::TypeHelp: |
| 62 return GDK_QUESTION_ARROW; | 59 return GDK_QUESTION_ARROW; |
| 63 case PlatformCursor::TypeEastResize: | 60 case WebCursorInfo::TypeEastResize: |
| 64 return GDK_RIGHT_SIDE; | 61 return GDK_RIGHT_SIDE; |
| 65 case PlatformCursor::TypeNorthResize: | 62 case WebCursorInfo::TypeNorthResize: |
| 66 return GDK_TOP_SIDE; | 63 return GDK_TOP_SIDE; |
| 67 case PlatformCursor::TypeNorthEastResize: | 64 case WebCursorInfo::TypeNorthEastResize: |
| 68 return GDK_TOP_RIGHT_CORNER; | 65 return GDK_TOP_RIGHT_CORNER; |
| 69 case PlatformCursor::TypeNorthWestResize: | 66 case WebCursorInfo::TypeNorthWestResize: |
| 70 return GDK_TOP_LEFT_CORNER; | 67 return GDK_TOP_LEFT_CORNER; |
| 71 case PlatformCursor::TypeSouthResize: | 68 case WebCursorInfo::TypeSouthResize: |
| 72 return GDK_BOTTOM_SIDE; | 69 return GDK_BOTTOM_SIDE; |
| 73 case PlatformCursor::TypeSouthEastResize: | 70 case WebCursorInfo::TypeSouthEastResize: |
| 74 return GDK_BOTTOM_RIGHT_CORNER; | 71 return GDK_BOTTOM_RIGHT_CORNER; |
| 75 case PlatformCursor::TypeSouthWestResize: | 72 case WebCursorInfo::TypeSouthWestResize: |
| 76 return GDK_BOTTOM_LEFT_CORNER; | 73 return GDK_BOTTOM_LEFT_CORNER; |
| 77 case PlatformCursor::TypeWestResize: | 74 case WebCursorInfo::TypeWestResize: |
| 78 return GDK_LEFT_SIDE; | 75 return GDK_LEFT_SIDE; |
| 79 case PlatformCursor::TypeNorthSouthResize: | 76 case WebCursorInfo::TypeNorthSouthResize: |
| 80 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 77 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 81 case PlatformCursor::TypeEastWestResize: | 78 case WebCursorInfo::TypeEastWestResize: |
| 82 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 79 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 83 case PlatformCursor::TypeNorthEastSouthWestResize: | 80 case WebCursorInfo::TypeNorthEastSouthWestResize: |
| 84 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 81 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 85 case PlatformCursor::TypeNorthWestSouthEastResize: | 82 case WebCursorInfo::TypeNorthWestSouthEastResize: |
| 86 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 83 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 87 case PlatformCursor::TypeColumnResize: | 84 case WebCursorInfo::TypeColumnResize: |
| 88 return GDK_SB_H_DOUBLE_ARROW; // TODO(evanm): is this correct? | 85 return GDK_SB_H_DOUBLE_ARROW; // TODO(evanm): is this correct? |
| 89 case PlatformCursor::TypeRowResize: | 86 case WebCursorInfo::TypeRowResize: |
| 90 return GDK_SB_V_DOUBLE_ARROW; // TODO(evanm): is this correct? | 87 return GDK_SB_V_DOUBLE_ARROW; // TODO(evanm): is this correct? |
| 91 case PlatformCursor::TypeMiddlePanning: | 88 case WebCursorInfo::TypeMiddlePanning: |
| 92 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 89 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 93 case PlatformCursor::TypeEastPanning: | 90 case WebCursorInfo::TypeEastPanning: |
| 94 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 91 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 95 case PlatformCursor::TypeNorthPanning: | 92 case WebCursorInfo::TypeNorthPanning: |
| 96 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 93 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 97 case PlatformCursor::TypeNorthEastPanning: | 94 case WebCursorInfo::TypeNorthEastPanning: |
| 98 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 95 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 99 case PlatformCursor::TypeNorthWestPanning: | 96 case WebCursorInfo::TypeNorthWestPanning: |
| 100 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 97 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 101 case PlatformCursor::TypeSouthPanning: | 98 case WebCursorInfo::TypeSouthPanning: |
| 102 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 99 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 103 case PlatformCursor::TypeSouthEastPanning: | 100 case WebCursorInfo::TypeSouthEastPanning: |
| 104 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 101 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 105 case PlatformCursor::TypeSouthWestPanning: | 102 case WebCursorInfo::TypeSouthWestPanning: |
| 106 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 103 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 107 case PlatformCursor::TypeWestPanning: | 104 case WebCursorInfo::TypeWestPanning: |
| 108 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 105 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 109 case PlatformCursor::TypeMove: | 106 case WebCursorInfo::TypeMove: |
| 110 return GDK_FLEUR; | 107 return GDK_FLEUR; |
| 111 case PlatformCursor::TypeVerticalText: | 108 case WebCursorInfo::TypeVerticalText: |
| 112 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 109 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 113 case PlatformCursor::TypeCell: | 110 case WebCursorInfo::TypeCell: |
| 114 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 111 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 115 case PlatformCursor::TypeContextMenu: | 112 case WebCursorInfo::TypeContextMenu: |
| 116 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 113 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 117 case PlatformCursor::TypeAlias: | 114 case WebCursorInfo::TypeAlias: |
| 118 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 115 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 119 case PlatformCursor::TypeProgress: | 116 case WebCursorInfo::TypeProgress: |
| 120 return GDK_WATCH; | 117 return GDK_WATCH; |
| 121 case PlatformCursor::TypeNoDrop: | 118 case WebCursorInfo::TypeNoDrop: |
| 122 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 119 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 123 case PlatformCursor::TypeCopy: | 120 case WebCursorInfo::TypeCopy: |
| 124 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 121 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 125 case PlatformCursor::TypeNone: | 122 case WebCursorInfo::TypeNone: |
| 126 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 123 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 127 case PlatformCursor::TypeNotAllowed: | 124 case WebCursorInfo::TypeNotAllowed: |
| 128 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; | 125 NOTIMPLEMENTED(); return GDK_LAST_CURSOR; |
| 129 case PlatformCursor::TypeZoomIn: | 126 case WebCursorInfo::TypeZoomIn: |
| 130 case PlatformCursor::TypeZoomOut: | 127 case WebCursorInfo::TypeZoomOut: |
| 131 case PlatformCursor::TypeCustom: | 128 case WebCursorInfo::TypeCustom: |
| 132 return GDK_CURSOR_IS_PIXMAP; | 129 return GDK_CURSOR_IS_PIXMAP; |
| 133 } | 130 } |
| 134 NOTREACHED(); | 131 NOTREACHED(); |
| 135 return GDK_LAST_CURSOR; | 132 return GDK_LAST_CURSOR; |
| 136 } | 133 } |
| 137 | 134 |
| 138 GdkCursor* WebCursor::GetCustomCursor() const { | 135 GdkCursor* WebCursor::GetCustomCursor() const { |
| 139 switch (type_) { | 136 switch (type_) { |
| 140 case PlatformCursor::TypeZoomIn: | 137 case WebCursorInfo::TypeZoomIn: |
| 141 return GetInlineCustomCursor(CustomCursorZoomIn); | 138 return GetInlineCustomCursor(CustomCursorZoomIn); |
| 142 case PlatformCursor::TypeZoomOut: | 139 case WebCursorInfo::TypeZoomOut: |
| 143 return GetInlineCustomCursor(CustomCursorZoomOut); | 140 return GetInlineCustomCursor(CustomCursorZoomOut); |
| 144 } | 141 } |
| 145 | 142 |
| 146 if (type_ != PlatformCursor::TypeCustom) { | 143 if (type_ != WebCursorInfo::TypeCustom) { |
| 147 NOTREACHED(); | 144 NOTREACHED(); |
| 148 return NULL; | 145 return NULL; |
| 149 } | 146 } |
| 150 | 147 |
| 151 const guchar* data = reinterpret_cast<const guchar*>(&custom_data_[0]); | 148 const guchar* data = reinterpret_cast<const guchar*>(&custom_data_[0]); |
| 152 GdkPixbuf* pixbuf = | 149 GdkPixbuf* pixbuf = |
| 153 gdk_pixbuf_new_from_data(data, | 150 gdk_pixbuf_new_from_data(data, |
| 154 GDK_COLORSPACE_RGB, | 151 GDK_COLORSPACE_RGB, |
| 155 TRUE, // has_alpha | 152 TRUE, // has_alpha |
| 156 8, // bits_per_sample | 153 8, // bits_per_sample |
| (...skipping 29 matching lines...) Expand all Loading... |
| 186 return true; | 183 return true; |
| 187 } | 184 } |
| 188 | 185 |
| 189 void WebCursor::CleanupPlatformData() { | 186 void WebCursor::CleanupPlatformData() { |
| 190 return; | 187 return; |
| 191 } | 188 } |
| 192 | 189 |
| 193 void WebCursor::CopyPlatformData(const WebCursor& other) { | 190 void WebCursor::CopyPlatformData(const WebCursor& other) { |
| 194 return; | 191 return; |
| 195 } | 192 } |
| OLD | NEW |