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

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

Issue 270613004: Implement "Copy image" for canvas (blink side). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nits Created 6 years, 5 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // We can always select all... 218 // We can always select all...
219 data.editFlags |= WebContextMenuData::CanSelectAll; 219 data.editFlags |= WebContextMenuData::CanSelectAll;
220 data.editFlags |= WebContextMenuData::CanTranslate; 220 data.editFlags |= WebContextMenuData::CanTranslate;
221 221
222 // Links, Images, Media tags, and Image/Media-Links take preference over 222 // Links, Images, Media tags, and Image/Media-Links take preference over
223 // all else. 223 // all else.
224 data.linkURL = r.absoluteLinkURL(); 224 data.linkURL = r.absoluteLinkURL();
225 225
226 if (isHTMLCanvasElement(r.innerNonSharedNode())) { 226 if (isHTMLCanvasElement(r.innerNonSharedNode())) {
227 data.mediaType = WebContextMenuData::MediaTypeCanvas; 227 data.mediaType = WebContextMenuData::MediaTypeCanvas;
228 data.hasImageContents = true;
228 } else if (!r.absoluteImageURL().isEmpty()) { 229 } else if (!r.absoluteImageURL().isEmpty()) {
229 data.srcURL = r.absoluteImageURL(); 230 data.srcURL = r.absoluteImageURL();
230 data.mediaType = WebContextMenuData::MediaTypeImage; 231 data.mediaType = WebContextMenuData::MediaTypeImage;
231 data.mediaFlags |= WebContextMenuData::MediaCanPrint; 232 data.mediaFlags |= WebContextMenuData::MediaCanPrint;
233
234 // An image can to be null for many reasons, like being blocked, no imag e
tkent 2014/06/30 22:59:46 can to be -> can be?
zino 2014/07/01 10:12:11 Done.
235 // data received from server yet.
236 data.hasImageContents = r.image() && !r.image()->isNull();
232 } else if (!r.absoluteMediaURL().isEmpty()) { 237 } else if (!r.absoluteMediaURL().isEmpty()) {
233 data.srcURL = r.absoluteMediaURL(); 238 data.srcURL = r.absoluteMediaURL();
234 239
235 // We know that if absoluteMediaURL() is not empty, then this 240 // We know that if absoluteMediaURL() is not empty, then this
236 // is a media element. 241 // is a media element.
237 HTMLMediaElement* mediaElement = toHTMLMediaElement(r.innerNonSharedNode ()); 242 HTMLMediaElement* mediaElement = toHTMLMediaElement(r.innerNonSharedNode ());
238 if (isHTMLVideoElement(*mediaElement)) 243 if (isHTMLVideoElement(*mediaElement))
239 data.mediaType = WebContextMenuData::MediaTypeVideo; 244 data.mediaType = WebContextMenuData::MediaTypeVideo;
240 else if (isHTMLAudioElement(*mediaElement)) 245 else if (isHTMLAudioElement(*mediaElement))
241 data.mediaType = WebContextMenuData::MediaTypeAudio; 246 data.mediaType = WebContextMenuData::MediaTypeAudio;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 data.srcURL = pluginElement->document().completeURL(pluginElemen t->url()); 286 data.srcURL = pluginElement->document().completeURL(pluginElemen t->url());
282 data.mediaFlags |= WebContextMenuData::MediaCanSave; 287 data.mediaFlags |= WebContextMenuData::MediaCanSave;
283 288
284 // Add context menu commands that are supported by the plugin. 289 // Add context menu commands that are supported by the plugin.
285 if (plugin->plugin()->canRotateView()) 290 if (plugin->plugin()->canRotateView())
286 data.mediaFlags |= WebContextMenuData::MediaCanRotate; 291 data.mediaFlags |= WebContextMenuData::MediaCanRotate;
287 } 292 }
288 } 293 }
289 } 294 }
290 295
291 // An image can to be null for many reasons, like being blocked, no image
292 // data received from server yet.
293 data.hasImageContents =
294 (data.mediaType == WebContextMenuData::MediaTypeImage)
295 && r.image() && !(r.image()->isNull());
296
297 // If it's not a link, an image, a media element, or an image/media link, 296 // If it's not a link, an image, a media element, or an image/media link,
298 // show a selection menu or a more generic page menu. 297 // show a selection menu or a more generic page menu.
299 if (selectedFrame->document()->loader()) 298 if (selectedFrame->document()->loader())
300 data.frameEncoding = selectedFrame->document()->encodingName(); 299 data.frameEncoding = selectedFrame->document()->encodingName();
301 300
302 // Send the frame and page URLs in any case. 301 // Send the frame and page URLs in any case.
303 data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame()); 302 data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame());
304 if (selectedFrame != m_webView->mainFrameImpl()->frame()) { 303 if (selectedFrame != m_webView->mainFrameImpl()->frame()) {
305 data.frameURL = urlFromFrame(selectedFrame); 304 data.frameURL = urlFromFrame(selectedFrame);
306 RefPtr<HistoryItem> historyItem = selectedFrame->loader().currentItem(); 305 RefPtr<HistoryItem> historyItem = selectedFrame->loader().currentItem();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 outputItems[i] = subItems[i]; 432 outputItems[i] = subItems[i];
434 subMenuItems.swap(outputItems); 433 subMenuItems.swap(outputItems);
435 } 434 }
436 435
437 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) 436 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
438 { 437 {
439 populateSubMenuItems(defaultMenu->items(), data->customItems); 438 populateSubMenuItems(defaultMenu->items(), data->customItems);
440 } 439 }
441 440
442 } // namespace blink 441 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698