Index: content/shell/renderer/test_runner/event_sender.cc |
diff --git a/content/shell/renderer/test_runner/event_sender.cc b/content/shell/renderer/test_runner/event_sender.cc |
index 8791a2f8c1dfb26b4a89dd7a1d54577c6a2faf3d..090d4b9454af961e7fc40a43a67b6187942094c9 100644 |
--- a/content/shell/renderer/test_runner/event_sender.cc |
+++ b/content/shell/renderer/test_runner/event_sender.cc |
@@ -32,6 +32,7 @@ using blink::WebFrame; |
using blink::WebGestureEvent; |
using blink::WebInputEvent; |
using blink::WebKeyboardEvent; |
+using blink::WebMenuItemInfo; |
using blink::WebMouseEvent; |
using blink::WebMouseWheelEvent; |
using blink::WebPoint; |
@@ -121,12 +122,39 @@ int GetKeyModifiersFromV8(v8::Handle<v8::Value> value) { |
// double or triple click. |
const double kMultipleClickTimeSec = 1; |
const int kMultipleClickRadiusPixels = 5; |
+const std::string kSubMenuIdentifier = " >"; |
tkent
2014/08/05 08:50:10
We don't allow static initialization of classes.
k
pals
2014/08/05 09:02:24
Done.
|
+const std::string kSubMenuDepthIdentifier = "_"; |
bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { |
return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) > |
kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; |
} |
+std::string depthPrefix(unsigned depth) |
+{ |
+ if (depth < 1) |
+ return std::string(); |
+ |
+ std::string prefix; |
+ for (size_t i = 0; i < depth; ++i) { |
+ prefix += kSubMenuDepthIdentifier; |
+ } |
+ return std::string(prefix); |
+} |
+ |
+void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems, |
+ std::vector<std::string>& strings, unsigned depth) { |
tkent
2014/08/05 08:50:10
Please make the third argument |const std::string&
pals
2014/08/05 09:02:24
Done. Thanks
|
+ for (size_t i = 0; i < customItems.size(); ++i) { |
+ if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) { |
+ unsigned newDepth = depth + 1; |
+ strings.push_back(depthPrefix(newDepth) + customItems[i].label.utf8() + kSubMenuIdentifier); |
tkent
2014/08/05 08:50:10
|depthPrefix(newDepth) +| -> |prefix +|
pals
2014/08/05 09:02:24
Done.
|
+ PopulateCustomItems(customItems[i].subMenuItems, strings, newDepth); |
tkent
2014/08/05 08:50:10
|newDepth| -> |prefix + kSubMenuDepthIdentifier|
pals
2014/08/05 09:02:24
Done.
|
+ } else { |
+ strings.push_back(depthPrefix(depth) + customItems[i].label.utf8()); |
tkent
2014/08/05 08:50:11
|depthPrefix(newDepth) +| -> |prefix +|
pals
2014/08/05 09:02:24
Done.
|
+ } |
+ } |
+} |
+ |
// Because actual context menu is implemented by the browser side, |
// this function does only what LayoutTests are expecting: |
// - Many test checks the count of items. So returning non-zero value makes |
@@ -172,6 +200,9 @@ std::vector<std::string> MakeMenuItemStringsFor( |
std::vector<std::string> strings; |
+ // Populate custom menu items if provided by the WebCore internals. |
tkent
2014/08/05 08:50:11
|WebCore| is an obsolete name.
"provided by Blink
pals
2014/08/05 09:02:24
Done.
|
+ PopulateCustomItems(context_menu->customItems, strings, 0); |
tkent
2014/08/05 08:50:10
|0| -> |""|
pals
2014/08/05 09:02:24
Done.
|
+ |
if (context_menu->isEditable) { |
for (const char** item = kEditableMenuStrings; *item; ++item) { |
strings.push_back(*item); |