Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 438193003: Updating MakeMenuItemStringsFor() to include custom items if provided by blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
124 125
125 bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { 126 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)) > 127 return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) >
127 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; 128 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels;
128 } 129 }
129 130
131 void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems,
132 std::vector<std::string>& strings) {
133 for (size_t i = 0; i < customItems.size(); ++i) {
134 if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) {
135 strings.push_back(customItems[i].label.utf8());
136 PopulateCustomItems(customItems[i].subMenuItems, strings);
tkent 2014/08/05 06:36:57 Let's prepend/append something to items for submen
pals 2014/08/05 08:38:08 Done.
137 } else {
138 strings.push_back(customItems[i].label.utf8());
139 }
140 }
141 }
142
130 // Because actual context menu is implemented by the browser side, 143 // Because actual context menu is implemented by the browser side,
131 // this function does only what LayoutTests are expecting: 144 // this function does only what LayoutTests are expecting:
132 // - Many test checks the count of items. So returning non-zero value makes 145 // - Many test checks the count of items. So returning non-zero value makes
133 // sense. 146 // sense.
134 // - Some test compares the count before and after some action. So changing the 147 // - 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 148 // count based on flags also makes sense. This function is doing such for some
136 // flags. 149 // flags.
137 // - Some test even checks actual string content. So providing it would be also 150 // - Some test even checks actual string content. So providing it would be also
138 // helpful. 151 // helpful.
139 std::vector<std::string> MakeMenuItemStringsFor( 152 std::vector<std::string> MakeMenuItemStringsFor(
(...skipping 25 matching lines...) Expand all
165 "<separator>", 178 "<separator>",
166 0 179 0
167 }; 180 };
168 181
169 // This is possible because mouse events are cancelleable. 182 // This is possible because mouse events are cancelleable.
170 if (!context_menu) 183 if (!context_menu)
171 return std::vector<std::string>(); 184 return std::vector<std::string>();
172 185
173 std::vector<std::string> strings; 186 std::vector<std::string> strings;
174 187
188 // Populate custom menu items if provided by the WebCore internals.
189 PopulateCustomItems(context_menu->customItems, strings);
190
175 if (context_menu->isEditable) { 191 if (context_menu->isEditable) {
176 for (const char** item = kEditableMenuStrings; *item; ++item) { 192 for (const char** item = kEditableMenuStrings; *item; ++item) {
177 strings.push_back(*item); 193 strings.push_back(*item);
178 } 194 }
179 WebVector<WebString> suggestions; 195 WebVector<WebString> suggestions;
180 MockSpellCheck::FillSuggestionList(context_menu->misspelledWord, 196 MockSpellCheck::FillSuggestionList(context_menu->misspelledWord,
181 &suggestions); 197 &suggestions);
182 for (size_t i = 0; i < suggestions.size(); ++i) { 198 for (size_t i = 0; i < suggestions.size(); ++i) {
183 strings.push_back(suggestions[i].utf8()); 199 strings.push_back(suggestions[i].utf8());
184 } 200 }
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 } 2274 }
2259 default: 2275 default:
2260 NOTREACHED(); 2276 NOTREACHED();
2261 } 2277 }
2262 } 2278 }
2263 2279
2264 replaying_saved_events_ = false; 2280 replaying_saved_events_ = false;
2265 } 2281 }
2266 2282
2267 } // namespace content 2283 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698