OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/renderer/test_runner/event_sender.h" | 5 #include "content/shell/renderer/test_runner/event_sender.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "content/public/common/page_zoom.h" | 10 #include "content/public/common/page_zoom.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "v8/include/v8.h" | 25 #include "v8/include/v8.h" |
26 | 26 |
27 using blink::WebContextMenuData; | 27 using blink::WebContextMenuData; |
28 using blink::WebDragData; | 28 using blink::WebDragData; |
29 using blink::WebDragOperationsMask; | 29 using blink::WebDragOperationsMask; |
30 using blink::WebFloatPoint; | 30 using blink::WebFloatPoint; |
31 using blink::WebFrame; | 31 using blink::WebFrame; |
32 using blink::WebGestureEvent; | 32 using blink::WebGestureEvent; |
33 using blink::WebInputEvent; | 33 using blink::WebInputEvent; |
34 using blink::WebKeyboardEvent; | 34 using blink::WebKeyboardEvent; |
35 using blink::WebMenuItemInfo; | |
35 using blink::WebMouseEvent; | 36 using blink::WebMouseEvent; |
36 using blink::WebMouseWheelEvent; | 37 using blink::WebMouseWheelEvent; |
37 using blink::WebPoint; | 38 using blink::WebPoint; |
38 using blink::WebString; | 39 using blink::WebString; |
39 using blink::WebTouchEvent; | 40 using blink::WebTouchEvent; |
40 using blink::WebTouchPoint; | 41 using blink::WebTouchPoint; |
41 using blink::WebVector; | 42 using blink::WebVector; |
42 using blink::WebView; | 43 using blink::WebView; |
43 | 44 |
44 namespace content { | 45 namespace content { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 gin::Converter<std::vector<std::string> >::FromV8( | 115 gin::Converter<std::vector<std::string> >::FromV8( |
115 NULL, value, &modifier_names); | 116 NULL, value, &modifier_names); |
116 } | 117 } |
117 return GetKeyModifiers(modifier_names); | 118 return GetKeyModifiers(modifier_names); |
118 } | 119 } |
119 | 120 |
120 // Maximum distance (in space and time) for a mouse click to register as a | 121 // Maximum distance (in space and time) for a mouse click to register as a |
121 // double or triple click. | 122 // double or triple click. |
122 const double kMultipleClickTimeSec = 1; | 123 const double kMultipleClickTimeSec = 1; |
123 const int kMultipleClickRadiusPixels = 5; | 124 const int kMultipleClickRadiusPixels = 5; |
125 const char kSubMenuDepthIdentifier[] = "_"; | |
126 const char kSubMenuIdentifier[] = " >"; | |
124 | 127 |
125 bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { | 128 bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { |
126 return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) > | 129 return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) > |
127 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; | 130 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; |
128 } | 131 } |
129 | 132 |
133 void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems, | |
tkent
2014/08/05 09:08:45
This doesn't follow Chromium coding style.
- 'out
pals
2014/08/05 09:17:29
Done.
| |
134 std::vector<std::string>& strings, const std::string& prefix) { | |
135 for (size_t i = 0; i < customItems.size(); ++i) { | |
136 if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) { | |
137 strings.push_back(prefix + customItems[i].label.utf8() + kSubMenuIdentifie r); | |
tkent
2014/08/05 09:08:45
wrap in 80 columns
pals
2014/08/05 09:17:29
Done.
| |
138 PopulateCustomItems(customItems[i].subMenuItems, strings, prefix + kSubMen uDepthIdentifier); | |
tkent
2014/08/05 09:08:45
Ditto.
pals
2014/08/05 09:17:29
Done.
| |
139 } else { | |
140 strings.push_back(prefix + customItems[i].label.utf8()); | |
141 } | |
142 } | |
143 } | |
144 | |
130 // Because actual context menu is implemented by the browser side, | 145 // Because actual context menu is implemented by the browser side, |
131 // this function does only what LayoutTests are expecting: | 146 // this function does only what LayoutTests are expecting: |
132 // - Many test checks the count of items. So returning non-zero value makes | 147 // - Many test checks the count of items. So returning non-zero value makes |
133 // sense. | 148 // sense. |
134 // - Some test compares the count before and after some action. So changing the | 149 // - Some test compares the count before and after some action. So changing the |
135 // count based on flags also makes sense. This function is doing such for some | 150 // count based on flags also makes sense. This function is doing such for some |
136 // flags. | 151 // flags. |
137 // - Some test even checks actual string content. So providing it would be also | 152 // - Some test even checks actual string content. So providing it would be also |
138 // helpful. | 153 // helpful. |
139 std::vector<std::string> MakeMenuItemStringsFor( | 154 std::vector<std::string> MakeMenuItemStringsFor( |
(...skipping 25 matching lines...) Expand all Loading... | |
165 "<separator>", | 180 "<separator>", |
166 0 | 181 0 |
167 }; | 182 }; |
168 | 183 |
169 // This is possible because mouse events are cancelleable. | 184 // This is possible because mouse events are cancelleable. |
170 if (!context_menu) | 185 if (!context_menu) |
171 return std::vector<std::string>(); | 186 return std::vector<std::string>(); |
172 | 187 |
173 std::vector<std::string> strings; | 188 std::vector<std::string> strings; |
174 | 189 |
190 // Populate custom menu items if provided by the blink internals. | |
tkent
2014/08/05 09:08:45
nit: |by the blink internals.| -> |by Blink.|
pals
2014/08/05 09:17:29
Done.
| |
191 PopulateCustomItems(context_menu->customItems, strings, ""); | |
192 | |
175 if (context_menu->isEditable) { | 193 if (context_menu->isEditable) { |
176 for (const char** item = kEditableMenuStrings; *item; ++item) { | 194 for (const char** item = kEditableMenuStrings; *item; ++item) { |
177 strings.push_back(*item); | 195 strings.push_back(*item); |
178 } | 196 } |
179 WebVector<WebString> suggestions; | 197 WebVector<WebString> suggestions; |
180 MockSpellCheck::FillSuggestionList(context_menu->misspelledWord, | 198 MockSpellCheck::FillSuggestionList(context_menu->misspelledWord, |
181 &suggestions); | 199 &suggestions); |
182 for (size_t i = 0; i < suggestions.size(); ++i) { | 200 for (size_t i = 0; i < suggestions.size(); ++i) { |
183 strings.push_back(suggestions[i].utf8()); | 201 strings.push_back(suggestions[i].utf8()); |
184 } | 202 } |
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2258 } | 2276 } |
2259 default: | 2277 default: |
2260 NOTREACHED(); | 2278 NOTREACHED(); |
2261 } | 2279 } |
2262 } | 2280 } |
2263 | 2281 |
2264 replaying_saved_events_ = false; | 2282 replaying_saved_events_ = false; |
2265 } | 2283 } |
2266 | 2284 |
2267 } // namespace content | 2285 } // namespace content |
OLD | NEW |