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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return GetKeyModifiers(modifier_names); | 118 return GetKeyModifiers(modifier_names); |
119 } | 119 } |
120 | 120 |
121 // 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 |
122 // double or triple click. | 122 // double or triple click. |
123 const double kMultipleClickTimeSec = 1; | 123 const double kMultipleClickTimeSec = 1; |
124 const int kMultipleClickRadiusPixels = 5; | 124 const int kMultipleClickRadiusPixels = 5; |
125 const char kSubMenuDepthIdentifier[] = "_"; | 125 const char kSubMenuDepthIdentifier[] = "_"; |
126 const char kSubMenuIdentifier[] = " >"; | 126 const char kSubMenuIdentifier[] = " >"; |
127 const char kSeparatorIdentifier[] = "---------"; | 127 const char kSeparatorIdentifier[] = "---------"; |
| 128 const char kDisabledIdentifier[] = "#"; |
| 129 const char kCheckedIdentifier[] = "*"; |
128 | 130 |
129 bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { | 131 bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { |
130 return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) > | 132 return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) > |
131 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; | 133 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; |
132 } | 134 } |
133 | 135 |
134 void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems, | 136 void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems, |
135 const std::string& prefix, std::vector<std::string>* strings) { | 137 const std::string& prefix, std::vector<std::string>* strings) { |
136 for (size_t i = 0; i < customItems.size(); ++i) { | 138 for (size_t i = 0; i < customItems.size(); ++i) { |
| 139 std::string prefixCopy = prefix; |
| 140 if (!customItems[i].enabled) |
| 141 prefixCopy = kDisabledIdentifier + prefix; |
| 142 if (customItems[i].checked) |
| 143 prefixCopy = kCheckedIdentifier + prefix; |
137 if (customItems[i].type == blink::WebMenuItemInfo::Separator) { | 144 if (customItems[i].type == blink::WebMenuItemInfo::Separator) { |
138 strings->push_back(prefix + kSeparatorIdentifier); | 145 strings->push_back(prefixCopy + kSeparatorIdentifier); |
139 } else if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) { | 146 } else if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) { |
140 strings->push_back(prefix + customItems[i].label.utf8() + | 147 strings->push_back(prefixCopy + customItems[i].label.utf8() + |
141 kSubMenuIdentifier); | 148 kSubMenuIdentifier); |
142 PopulateCustomItems(customItems[i].subMenuItems, prefix + | 149 PopulateCustomItems(customItems[i].subMenuItems, prefixCopy + |
143 kSubMenuDepthIdentifier, strings); | 150 kSubMenuDepthIdentifier, strings); |
144 } else { | 151 } else { |
145 strings->push_back(prefix + customItems[i].label.utf8()); | 152 strings->push_back(prefixCopy + customItems[i].label.utf8()); |
146 } | 153 } |
147 } | 154 } |
148 } | 155 } |
149 | 156 |
150 // Because actual context menu is implemented by the browser side, | 157 // Because actual context menu is implemented by the browser side, |
151 // this function does only what LayoutTests are expecting: | 158 // this function does only what LayoutTests are expecting: |
152 // - Many test checks the count of items. So returning non-zero value makes | 159 // - Many test checks the count of items. So returning non-zero value makes |
153 // sense. | 160 // sense. |
154 // - Some test compares the count before and after some action. So changing the | 161 // - Some test compares the count before and after some action. So changing the |
155 // count based on flags also makes sense. This function is doing such for some | 162 // count based on flags also makes sense. This function is doing such for some |
(...skipping 2140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 } | 2303 } |
2297 default: | 2304 default: |
2298 NOTREACHED(); | 2305 NOTREACHED(); |
2299 } | 2306 } |
2300 } | 2307 } |
2301 | 2308 |
2302 replaying_saved_events_ = false; | 2309 replaying_saved_events_ = false; |
2303 } | 2310 } |
2304 | 2311 |
2305 } // namespace content | 2312 } // namespace content |
OLD | NEW |