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

Side by Side Diff: third_party/WebKit/Source/web/ContextMenuClientImpl.cpp

Issue 2712603007: Select All present even all selectable text has been selected (Closed)
Patch Set: yosin's nits Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 r.setToShadowHostIfInUserAgentShadowRoot(); 159 r.setToShadowHostIfInUserAgentShadowRoot();
160 160
161 LocalFrame* selectedFrame = r.innerNodeFrame(); 161 LocalFrame* selectedFrame = r.innerNodeFrame();
162 162
163 WebContextMenuData data; 163 WebContextMenuData data;
164 data.mousePosition = selectedFrame->view()->contentsToViewport( 164 data.mousePosition = selectedFrame->view()->contentsToViewport(
165 r.roundedPointInInnerNodeFrame()); 165 r.roundedPointInInnerNodeFrame());
166 166
167 // Compute edit flags. 167 // Compute edit flags.
168 data.editFlags = WebContextMenuData::CanDoNone; 168 data.editFlags = WebContextMenuData::CanDoNone;
169 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo()) 169 if (selectedFrame->document()->isHTMLDocument() ||
170 data.editFlags |= WebContextMenuData::CanUndo; 170 selectedFrame->document()->isXHTMLDocument()) {
171 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo()) 171 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo())
172 data.editFlags |= WebContextMenuData::CanRedo; 172 data.editFlags |= WebContextMenuData::CanUndo;
173 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut()) 173 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo())
174 data.editFlags |= WebContextMenuData::CanCut; 174 data.editFlags |= WebContextMenuData::CanRedo;
175 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy()) 175 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut())
176 data.editFlags |= WebContextMenuData::CanCopy; 176 data.editFlags |= WebContextMenuData::CanCut;
177 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste()) 177 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy())
178 data.editFlags |= WebContextMenuData::CanPaste; 178 data.editFlags |= WebContextMenuData::CanCopy;
179 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete()) 179 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste())
180 data.editFlags |= WebContextMenuData::CanDelete; 180 data.editFlags |= WebContextMenuData::CanPaste;
181 // We can always select all... 181 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete())
182 data.editFlags |= WebContextMenuData::CanSelectAll; 182 data.editFlags |= WebContextMenuData::CanDelete;
183 data.editFlags |= WebContextMenuData::CanTranslate; 183 if (selectedFrame->document()->queryCommandEnabled("selectAll",
184 ASSERT_NO_EXCEPTION))
185 data.editFlags |= WebContextMenuData::CanSelectAll;
186 data.editFlags |= WebContextMenuData::CanTranslate;
187 }
184 188
185 // Links, Images, Media tags, and Image/Media-Links take preference over 189 // Links, Images, Media tags, and Image/Media-Links take preference over
186 // all else. 190 // all else.
187 data.linkURL = r.absoluteLinkURL(); 191 data.linkURL = r.absoluteLinkURL();
188 192
189 if (r.innerNode()->isHTMLElement()) { 193 if (r.innerNode()->isHTMLElement()) {
190 HTMLElement* htmlElement = toHTMLElement(r.innerNode()); 194 HTMLElement* htmlElement = toHTMLElement(r.innerNode());
191 if (!htmlElement->title().isEmpty()) { 195 if (!htmlElement->title().isEmpty()) {
192 data.titleText = htmlElement->title(); 196 data.titleText = htmlElement->title();
193 } else { 197 } else {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 subMenuItems.swap(outputItems); 452 subMenuItems.swap(outputItems);
449 } 453 }
450 454
451 void ContextMenuClientImpl::populateCustomMenuItems( 455 void ContextMenuClientImpl::populateCustomMenuItems(
452 const ContextMenu* defaultMenu, 456 const ContextMenu* defaultMenu,
453 WebContextMenuData* data) { 457 WebContextMenuData* data) {
454 populateSubMenuItems(defaultMenu->items(), data->customItems); 458 populateSubMenuItems(defaultMenu->items(), data->customItems);
455 } 459 }
456 460
457 } // namespace blink 461 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698