Updating MakeMenuItemStringsFor() to include custom items if provided by blink.

BUG=87553

Review URL: https://codereview.chromium.org/438193003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287527 0039d316-1c4b-4281-b951-d872f2087c98
parent 3415cf74
......@@ -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,28 @@ int GetKeyModifiersFromV8(v8::Handle<v8::Value> value) {
// double or triple click.
const double kMultipleClickTimeSec = 1;
const int kMultipleClickRadiusPixels = 5;
const char kSubMenuDepthIdentifier[] = "_";
const char kSubMenuIdentifier[] = " >";
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;
}
void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems,
const std::string& prefix, std::vector<std::string>* strings) {
for (size_t i = 0; i < customItems.size(); ++i) {
if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) {
strings->push_back(prefix + customItems[i].label.utf8() +
kSubMenuIdentifier);
PopulateCustomItems(customItems[i].subMenuItems, prefix +
kSubMenuDepthIdentifier, strings);
} else {
strings->push_back(prefix + customItems[i].label.utf8());
}
}
}
// 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 +189,9 @@ std::vector<std::string> MakeMenuItemStringsFor(
std::vector<std::string> strings;
// Populate custom menu items if provided by blink.
PopulateCustomItems(context_menu->customItems, "", &strings);
if (context_menu->isEditable) {
for (const char** item = kEditableMenuStrings; *item; ++item) {
strings.push_back(*item);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment