| 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 26 matching lines...) Expand all Loading... |
| 37 #include "core/css/CSSStyleDeclaration.h" | 37 #include "core/css/CSSStyleDeclaration.h" |
| 38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
| 39 #include "core/editing/Editor.h" | 39 #include "core/editing/Editor.h" |
| 40 #include "core/editing/markers/DocumentMarkerController.h" | 40 #include "core/editing/markers/DocumentMarkerController.h" |
| 41 #include "core/editing/spellcheck/SpellChecker.h" | 41 #include "core/editing/spellcheck/SpellChecker.h" |
| 42 #include "core/exported/WebDataSourceImpl.h" | 42 #include "core/exported/WebDataSourceImpl.h" |
| 43 #include "core/exported/WebViewBase.h" | 43 #include "core/exported/WebViewBase.h" |
| 44 #include "core/frame/FrameView.h" | 44 #include "core/frame/FrameView.h" |
| 45 #include "core/frame/Settings.h" | 45 #include "core/frame/Settings.h" |
| 46 #include "core/frame/VisualViewport.h" | 46 #include "core/frame/VisualViewport.h" |
| 47 #include "core/frame/WebLocalFrameBase.h" |
| 47 #include "core/html/HTMLAnchorElement.h" | 48 #include "core/html/HTMLAnchorElement.h" |
| 48 #include "core/html/HTMLFormElement.h" | 49 #include "core/html/HTMLFormElement.h" |
| 49 #include "core/html/HTMLImageElement.h" | 50 #include "core/html/HTMLImageElement.h" |
| 50 #include "core/html/HTMLInputElement.h" | 51 #include "core/html/HTMLInputElement.h" |
| 51 #include "core/html/HTMLMediaElement.h" | 52 #include "core/html/HTMLMediaElement.h" |
| 52 #include "core/html/HTMLPlugInElement.h" | 53 #include "core/html/HTMLPlugInElement.h" |
| 53 #include "core/input/EventHandler.h" | 54 #include "core/input/EventHandler.h" |
| 54 #include "core/layout/HitTestResult.h" | 55 #include "core/layout/HitTestResult.h" |
| 55 #include "core/layout/LayoutPart.h" | 56 #include "core/layout/LayoutPart.h" |
| 56 #include "core/loader/DocumentLoader.h" | 57 #include "core/loader/DocumentLoader.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 71 #include "public/platform/WebVector.h" | 72 #include "public/platform/WebVector.h" |
| 72 #include "public/web/WebContextMenuData.h" | 73 #include "public/web/WebContextMenuData.h" |
| 73 #include "public/web/WebFormElement.h" | 74 #include "public/web/WebFormElement.h" |
| 74 #include "public/web/WebFrameClient.h" | 75 #include "public/web/WebFrameClient.h" |
| 75 #include "public/web/WebMenuItemInfo.h" | 76 #include "public/web/WebMenuItemInfo.h" |
| 76 #include "public/web/WebPlugin.h" | 77 #include "public/web/WebPlugin.h" |
| 77 #include "public/web/WebSearchableFormData.h" | 78 #include "public/web/WebSearchableFormData.h" |
| 78 #include "public/web/WebTextCheckClient.h" | 79 #include "public/web/WebTextCheckClient.h" |
| 79 #include "public/web/WebViewClient.h" | 80 #include "public/web/WebViewClient.h" |
| 80 #include "web/ContextMenuAllowedScope.h" | 81 #include "web/ContextMenuAllowedScope.h" |
| 81 #include "web/WebLocalFrameImpl.h" | |
| 82 #include "web/WebPluginContainerImpl.h" | 82 #include "web/WebPluginContainerImpl.h" |
| 83 | 83 |
| 84 namespace blink { | 84 namespace blink { |
| 85 | 85 |
| 86 // Figure out the URL of a page or subframe. Returns |page_type| as the type, | 86 // Figure out the URL of a page or subframe. Returns |page_type| as the type, |
| 87 // which indicates page or subframe, or ContextNodeType::kNone if the URL could | 87 // which indicates page or subframe, or ContextNodeType::kNone if the URL could |
| 88 // not be determined for some reason. | 88 // not be determined for some reason. |
| 89 static WebURL UrlFromFrame(LocalFrame* frame) { | 89 static WebURL UrlFromFrame(LocalFrame* frame) { |
| 90 if (frame) { | 90 if (frame) { |
| 91 DocumentLoader* dl = frame->Loader().GetDocumentLoader(); | 91 DocumentLoader* dl = frame->Loader().GetDocumentLoader(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // in response to the above input events before popping up the context menu. | 182 // in response to the above input events before popping up the context menu. |
| 183 if (!ContextMenuAllowedScope::IsContextMenuAllowed()) | 183 if (!ContextMenuAllowedScope::IsContextMenuAllowed()) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 HitTestResult r = | 186 HitTestResult r = |
| 187 web_view_->GetPage()->GetContextMenuController().GetHitTestResult(); | 187 web_view_->GetPage()->GetContextMenuController().GetHitTestResult(); |
| 188 | 188 |
| 189 r.SetToShadowHostIfInRestrictedShadowRoot(); | 189 r.SetToShadowHostIfInRestrictedShadowRoot(); |
| 190 | 190 |
| 191 LocalFrame* selected_frame = r.InnerNodeFrame(); | 191 LocalFrame* selected_frame = r.InnerNodeFrame(); |
| 192 WebLocalFrameImpl* selected_web_frame = | 192 WebLocalFrameBase* selected_web_frame = |
| 193 WebLocalFrameImpl::FromFrame(selected_frame); | 193 WebLocalFrameBase::FromFrame(selected_frame); |
| 194 | 194 |
| 195 WebContextMenuData data; | 195 WebContextMenuData data; |
| 196 data.mouse_position = selected_frame->View()->ContentsToViewport( | 196 data.mouse_position = selected_frame->View()->ContentsToViewport( |
| 197 r.RoundedPointInInnerNodeFrame()); | 197 r.RoundedPointInInnerNodeFrame()); |
| 198 | 198 |
| 199 data.edit_flags = ComputeEditFlags( | 199 data.edit_flags = ComputeEditFlags( |
| 200 *selected_frame->GetDocument(), | 200 *selected_frame->GetDocument(), |
| 201 ToLocalFrame(web_view_->FocusedCoreFrame())->GetEditor()); | 201 ToLocalFrame(web_view_->FocusedCoreFrame())->GetEditor()); |
| 202 | 202 |
| 203 // Links, Images, Media tags, and Image/Media-Links take preference over | 203 // Links, Images, Media tags, and Image/Media-Links take preference over |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return true; | 413 return true; |
| 414 } | 414 } |
| 415 | 415 |
| 416 void ContextMenuClientImpl::ClearContextMenu() { | 416 void ContextMenuClientImpl::ClearContextMenu() { |
| 417 HitTestResult r = | 417 HitTestResult r = |
| 418 web_view_->GetPage()->GetContextMenuController().GetHitTestResult(); | 418 web_view_->GetPage()->GetContextMenuController().GetHitTestResult(); |
| 419 LocalFrame* selected_frame = r.InnerNodeFrame(); | 419 LocalFrame* selected_frame = r.InnerNodeFrame(); |
| 420 if (!selected_frame) | 420 if (!selected_frame) |
| 421 return; | 421 return; |
| 422 | 422 |
| 423 WebLocalFrameImpl* selected_web_frame = | 423 WebLocalFrameBase* selected_web_frame = |
| 424 WebLocalFrameImpl::FromFrame(selected_frame); | 424 WebLocalFrameBase::FromFrame(selected_frame); |
| 425 selected_web_frame->ClearContextMenuNode(); | 425 selected_web_frame->ClearContextMenuNode(); |
| 426 } | 426 } |
| 427 | 427 |
| 428 static void PopulateSubMenuItems(const Vector<ContextMenuItem>& input_menu, | 428 static void PopulateSubMenuItems(const Vector<ContextMenuItem>& input_menu, |
| 429 WebVector<WebMenuItemInfo>& sub_menu_items) { | 429 WebVector<WebMenuItemInfo>& sub_menu_items) { |
| 430 Vector<WebMenuItemInfo> sub_items; | 430 Vector<WebMenuItemInfo> sub_items; |
| 431 for (size_t i = 0; i < input_menu.size(); ++i) { | 431 for (size_t i = 0; i < input_menu.size(); ++i) { |
| 432 const ContextMenuItem* input_item = &input_menu.at(i); | 432 const ContextMenuItem* input_item = &input_menu.at(i); |
| 433 if (input_item->Action() < kContextMenuItemBaseCustomTag || | 433 if (input_item->Action() < kContextMenuItemBaseCustomTag || |
| 434 input_item->Action() > kContextMenuItemLastCustomTag) | 434 input_item->Action() > kContextMenuItemLastCustomTag) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 sub_menu_items.Swap(output_items); | 466 sub_menu_items.Swap(output_items); |
| 467 } | 467 } |
| 468 | 468 |
| 469 void ContextMenuClientImpl::PopulateCustomMenuItems( | 469 void ContextMenuClientImpl::PopulateCustomMenuItems( |
| 470 const ContextMenu* default_menu, | 470 const ContextMenu* default_menu, |
| 471 WebContextMenuData* data) { | 471 WebContextMenuData* data) { |
| 472 PopulateSubMenuItems(default_menu->Items(), data->custom_items); | 472 PopulateSubMenuItems(default_menu->Items(), data->custom_items); |
| 473 } | 473 } |
| 474 | 474 |
| 475 } // namespace blink | 475 } // namespace blink |
| OLD | NEW |