• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "content/common/cursors/webcursor.h"
6 
7 #include "base/logging.h"
8 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
9 #include "ui/base/cursor/cursor.h"
10 
11 using blink::WebCursorInfo;
12 
13 namespace content {
14 
GetNativeCursor()15 gfx::NativeCursor WebCursor::GetNativeCursor() {
16   switch (type_) {
17     case WebCursorInfo::TypePointer:
18       return ui::kCursorPointer;
19     case WebCursorInfo::TypeCross:
20       return ui::kCursorCross;
21     case WebCursorInfo::TypeHand:
22       return ui::kCursorHand;
23     case WebCursorInfo::TypeIBeam:
24       return ui::kCursorIBeam;
25     case WebCursorInfo::TypeWait:
26       return ui::kCursorWait;
27     case WebCursorInfo::TypeHelp:
28       return ui::kCursorHelp;
29     case WebCursorInfo::TypeEastResize:
30       return ui::kCursorEastResize;
31     case WebCursorInfo::TypeNorthResize:
32       return ui::kCursorNorthResize;
33     case WebCursorInfo::TypeNorthEastResize:
34       return ui::kCursorNorthEastResize;
35     case WebCursorInfo::TypeNorthWestResize:
36       return ui::kCursorNorthWestResize;
37     case WebCursorInfo::TypeSouthResize:
38       return ui::kCursorSouthResize;
39     case WebCursorInfo::TypeSouthEastResize:
40       return ui::kCursorSouthEastResize;
41     case WebCursorInfo::TypeSouthWestResize:
42       return ui::kCursorSouthWestResize;
43     case WebCursorInfo::TypeWestResize:
44       return ui::kCursorWestResize;
45     case WebCursorInfo::TypeNorthSouthResize:
46       return ui::kCursorNorthSouthResize;
47     case WebCursorInfo::TypeEastWestResize:
48       return ui::kCursorEastWestResize;
49     case WebCursorInfo::TypeNorthEastSouthWestResize:
50       return ui::kCursorNorthEastSouthWestResize;
51     case WebCursorInfo::TypeNorthWestSouthEastResize:
52       return ui::kCursorNorthWestSouthEastResize;
53     case WebCursorInfo::TypeColumnResize:
54       return ui::kCursorColumnResize;
55     case WebCursorInfo::TypeRowResize:
56       return ui::kCursorRowResize;
57     case WebCursorInfo::TypeMiddlePanning:
58       return ui::kCursorMiddlePanning;
59     case WebCursorInfo::TypeEastPanning:
60       return ui::kCursorEastPanning;
61     case WebCursorInfo::TypeNorthPanning:
62       return ui::kCursorNorthPanning;
63     case WebCursorInfo::TypeNorthEastPanning:
64       return ui::kCursorNorthEastPanning;
65     case WebCursorInfo::TypeNorthWestPanning:
66       return ui::kCursorNorthWestPanning;
67     case WebCursorInfo::TypeSouthPanning:
68       return ui::kCursorSouthPanning;
69     case WebCursorInfo::TypeSouthEastPanning:
70       return ui::kCursorSouthEastPanning;
71     case WebCursorInfo::TypeSouthWestPanning:
72       return ui::kCursorSouthWestPanning;
73     case WebCursorInfo::TypeWestPanning:
74       return ui::kCursorWestPanning;
75     case WebCursorInfo::TypeMove:
76       return ui::kCursorMove;
77     case WebCursorInfo::TypeVerticalText:
78       return ui::kCursorVerticalText;
79     case WebCursorInfo::TypeCell:
80       return ui::kCursorCell;
81     case WebCursorInfo::TypeContextMenu:
82       return ui::kCursorContextMenu;
83     case WebCursorInfo::TypeAlias:
84       return ui::kCursorAlias;
85     case WebCursorInfo::TypeProgress:
86       return ui::kCursorProgress;
87     case WebCursorInfo::TypeNoDrop:
88       return ui::kCursorNoDrop;
89     case WebCursorInfo::TypeCopy:
90       return ui::kCursorCopy;
91     case WebCursorInfo::TypeNone:
92       return ui::kCursorNone;
93     case WebCursorInfo::TypeNotAllowed:
94       return ui::kCursorNotAllowed;
95     case WebCursorInfo::TypeZoomIn:
96       return ui::kCursorZoomIn;
97     case WebCursorInfo::TypeZoomOut:
98       return ui::kCursorZoomOut;
99     case WebCursorInfo::TypeGrab:
100       return ui::kCursorGrab;
101     case WebCursorInfo::TypeGrabbing:
102       return ui::kCursorGrabbing;
103     case WebCursorInfo::TypeCustom: {
104       ui::Cursor cursor(ui::kCursorCustom);
105       cursor.SetPlatformCursor(GetPlatformCursor());
106       return cursor;
107     }
108     default:
109       NOTREACHED();
110       return gfx::kNullCursor;
111   }
112 }
113 
114 }  // namespace content
115