OLD | NEW |
---|---|
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 // We can always select all... | 217 // We can always select all... |
218 data.editFlags |= WebContextMenuData::CanSelectAll; | 218 data.editFlags |= WebContextMenuData::CanSelectAll; |
219 data.editFlags |= WebContextMenuData::CanTranslate; | 219 data.editFlags |= WebContextMenuData::CanTranslate; |
220 | 220 |
221 // Links, Images, Media tags, and Image/Media-Links take preference over | 221 // Links, Images, Media tags, and Image/Media-Links take preference over |
222 // all else. | 222 // all else. |
223 data.linkURL = r.absoluteLinkURL(); | 223 data.linkURL = r.absoluteLinkURL(); |
224 | 224 |
225 if (isHTMLCanvasElement(r.innerNonSharedNode())) { | 225 if (isHTMLCanvasElement(r.innerNonSharedNode())) { |
226 data.mediaType = WebContextMenuData::MediaTypeCanvas; | 226 data.mediaType = WebContextMenuData::MediaTypeCanvas; |
227 data.hasImageContents = true; | |
227 } else if (!r.absoluteImageURL().isEmpty()) { | 228 } else if (!r.absoluteImageURL().isEmpty()) { |
228 data.srcURL = r.absoluteImageURL(); | 229 data.srcURL = r.absoluteImageURL(); |
229 data.mediaType = WebContextMenuData::MediaTypeImage; | 230 data.mediaType = WebContextMenuData::MediaTypeImage; |
230 data.mediaFlags |= WebContextMenuData::MediaCanPrint; | 231 data.mediaFlags |= WebContextMenuData::MediaCanPrint; |
232 | |
233 // An image can to be null for many reasons, like being blocked, no imag e | |
234 // data received from server yet. | |
235 data.hasImageContents = r.image() && !(r.image()->isNull()); | |
yosin_UTC9
2014/06/20 04:24:10
nit: We don't need to have parenthesis, |!r.image
| |
231 } else if (!r.absoluteMediaURL().isEmpty()) { | 236 } else if (!r.absoluteMediaURL().isEmpty()) { |
232 data.srcURL = r.absoluteMediaURL(); | 237 data.srcURL = r.absoluteMediaURL(); |
233 | 238 |
234 // We know that if absoluteMediaURL() is not empty, then this | 239 // We know that if absoluteMediaURL() is not empty, then this |
235 // is a media element. | 240 // is a media element. |
236 HTMLMediaElement* mediaElement = toHTMLMediaElement(r.innerNonSharedNode ()); | 241 HTMLMediaElement* mediaElement = toHTMLMediaElement(r.innerNonSharedNode ()); |
237 if (isHTMLVideoElement(*mediaElement)) | 242 if (isHTMLVideoElement(*mediaElement)) |
238 data.mediaType = WebContextMenuData::MediaTypeVideo; | 243 data.mediaType = WebContextMenuData::MediaTypeVideo; |
239 else if (isHTMLAudioElement(*mediaElement)) | 244 else if (isHTMLAudioElement(*mediaElement)) |
240 data.mediaType = WebContextMenuData::MediaTypeAudio; | 245 data.mediaType = WebContextMenuData::MediaTypeAudio; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 data.srcURL = pluginElement->document().completeURL(pluginElemen t->url()); | 285 data.srcURL = pluginElement->document().completeURL(pluginElemen t->url()); |
281 data.mediaFlags |= WebContextMenuData::MediaCanSave; | 286 data.mediaFlags |= WebContextMenuData::MediaCanSave; |
282 | 287 |
283 // Add context menu commands that are supported by the plugin. | 288 // Add context menu commands that are supported by the plugin. |
284 if (plugin->plugin()->canRotateView()) | 289 if (plugin->plugin()->canRotateView()) |
285 data.mediaFlags |= WebContextMenuData::MediaCanRotate; | 290 data.mediaFlags |= WebContextMenuData::MediaCanRotate; |
286 } | 291 } |
287 } | 292 } |
288 } | 293 } |
289 | 294 |
290 // An image can to be null for many reasons, like being blocked, no image | |
291 // data received from server yet. | |
292 data.hasImageContents = | |
293 (data.mediaType == WebContextMenuData::MediaTypeImage) | |
294 && r.image() && !(r.image()->isNull()); | |
295 | |
296 // If it's not a link, an image, a media element, or an image/media link, | 295 // If it's not a link, an image, a media element, or an image/media link, |
297 // show a selection menu or a more generic page menu. | 296 // show a selection menu or a more generic page menu. |
298 if (selectedFrame->document()->loader()) | 297 if (selectedFrame->document()->loader()) |
299 data.frameEncoding = selectedFrame->document()->encodingName(); | 298 data.frameEncoding = selectedFrame->document()->encodingName(); |
300 | 299 |
301 // Send the frame and page URLs in any case. | 300 // Send the frame and page URLs in any case. |
302 data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame()); | 301 data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame()); |
303 if (selectedFrame != m_webView->mainFrameImpl()->frame()) { | 302 if (selectedFrame != m_webView->mainFrameImpl()->frame()) { |
304 data.frameURL = urlFromFrame(selectedFrame); | 303 data.frameURL = urlFromFrame(selectedFrame); |
305 RefPtr<HistoryItem> historyItem = selectedFrame->loader().currentItem(); | 304 RefPtr<HistoryItem> historyItem = selectedFrame->loader().currentItem(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 outputItems[i] = subItems[i]; | 425 outputItems[i] = subItems[i]; |
427 subMenuItems.swap(outputItems); | 426 subMenuItems.swap(outputItems); |
428 } | 427 } |
429 | 428 |
430 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) | 429 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) |
431 { | 430 { |
432 populateSubMenuItems(defaultMenu->items(), data->customItems); | 431 populateSubMenuItems(defaultMenu->items(), data->customItems); |
433 } | 432 } |
434 | 433 |
435 } // namespace blink | 434 } // namespace blink |
OLD | NEW |