| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #include "public/web/WebPlugin.h" | 73 #include "public/web/WebPlugin.h" |
| 74 #include "public/web/WebSearchableFormData.h" | 74 #include "public/web/WebSearchableFormData.h" |
| 75 #include "public/web/WebSpellCheckClient.h" | 75 #include "public/web/WebSpellCheckClient.h" |
| 76 #include "public/web/WebViewClient.h" | 76 #include "public/web/WebViewClient.h" |
| 77 #include "web/WebDataSourceImpl.h" | 77 #include "web/WebDataSourceImpl.h" |
| 78 #include "web/WebLocalFrameImpl.h" | 78 #include "web/WebLocalFrameImpl.h" |
| 79 #include "web/WebPluginContainerImpl.h" | 79 #include "web/WebPluginContainerImpl.h" |
| 80 #include "web/WebViewImpl.h" | 80 #include "web/WebViewImpl.h" |
| 81 #include "wtf/text/WTFString.h" | 81 #include "wtf/text/WTFString.h" |
| 82 | 82 |
| 83 using namespace blink; | |
| 84 | |
| 85 namespace blink { | 83 namespace blink { |
| 86 | 84 |
| 87 // Figure out the URL of a page or subframe. Returns |page_type| as the type, | 85 // Figure out the URL of a page or subframe. Returns |page_type| as the type, |
| 88 // which indicates page or subframe, or ContextNodeType::NONE if the URL could n
ot | 86 // which indicates page or subframe, or ContextNodeType::NONE if the URL could n
ot |
| 89 // be determined for some reason. | 87 // be determined for some reason. |
| 90 static WebURL urlFromFrame(LocalFrame* frame) | 88 static WebURL urlFromFrame(LocalFrame* frame) |
| 91 { | 89 { |
| 92 if (frame) { | 90 if (frame) { |
| 93 DocumentLoader* dl = frame->loader().documentLoader(); | 91 DocumentLoader* dl = frame->loader().documentLoader(); |
| 94 if (dl) { | 92 if (dl) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 RefPtrWillBeRawPtr<Range> markerRange = selectionRange->cloneRange(); | 170 RefPtrWillBeRawPtr<Range> markerRange = selectionRange->cloneRange(); |
| 173 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset
()); | 171 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset
()); |
| 174 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); | 172 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); |
| 175 | 173 |
| 176 if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selec
tionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation)) | 174 if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selec
tionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation)) |
| 177 return String(); | 175 return String(); |
| 178 | 176 |
| 179 return markerRange->text(); | 177 return markerRange->text(); |
| 180 } | 178 } |
| 181 | 179 |
| 182 void ContextMenuClientImpl::showContextMenu(const blink::ContextMenu* defaultMen
u) | 180 void ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu) |
| 183 { | 181 { |
| 184 // Displaying the context menu in this function is a big hack as we don't | 182 // Displaying the context menu in this function is a big hack as we don't |
| 185 // have context, i.e. whether this is being invoked via a script or in | 183 // have context, i.e. whether this is being invoked via a script or in |
| 186 // response to user input (Mouse event WM_RBUTTONDOWN, | 184 // response to user input (Mouse event WM_RBUTTONDOWN, |
| 187 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked | 185 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked |
| 188 // in response to the above input events before popping up the context menu. | 186 // in response to the above input events before popping up the context menu. |
| 189 if (!m_webView->contextMenuAllowed()) | 187 if (!m_webView->contextMenuAllowed()) |
| 190 return; | 188 return; |
| 191 | 189 |
| 192 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult()
; | 190 HitTestResult r = m_webView->page()->contextMenuController().hitTestResult()
; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 431 } |
| 434 subItems.append(outputItem); | 432 subItems.append(outputItem); |
| 435 } | 433 } |
| 436 | 434 |
| 437 WebVector<WebMenuItemInfo> outputItems(subItems.size()); | 435 WebVector<WebMenuItemInfo> outputItems(subItems.size()); |
| 438 for (size_t i = 0; i < subItems.size(); ++i) | 436 for (size_t i = 0; i < subItems.size(); ++i) |
| 439 outputItems[i] = subItems[i]; | 437 outputItems[i] = subItems[i]; |
| 440 subMenuItems.swap(outputItems); | 438 subMenuItems.swap(outputItems); |
| 441 } | 439 } |
| 442 | 440 |
| 443 void ContextMenuClientImpl::populateCustomMenuItems(const blink::ContextMenu* de
faultMenu, WebContextMenuData* data) | 441 void ContextMenuClientImpl::populateCustomMenuItems(const ContextMenu* defaultMe
nu, WebContextMenuData* data) |
| 444 { | 442 { |
| 445 populateSubMenuItems(defaultMenu->items(), data->customItems); | 443 populateSubMenuItems(defaultMenu->items(), data->customItems); |
| 446 } | 444 } |
| 447 | 445 |
| 448 } // namespace blink | 446 } // namespace blink |
| OLD | NEW |