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

Unified Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 1836973003: Move download messages from Renderer to Frame filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RenderViewHostTest Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
index 0893b67b0d59e7013896a1dce6d7647599e72786..8782e4be1a1dc8f0dd50232f2857590db45fc7b3 100644
--- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
+++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
@@ -120,6 +120,7 @@
#include "core/frame/RemoteFrame.h"
#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
+#include "core/frame/VisualViewport.h"
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLFormElement.h"
@@ -1355,6 +1356,36 @@ bool WebLocalFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length)
return frame()->spellChecker().selectionStartHasSpellingMarkerFor(from, length);
}
+void WebLocalFrameImpl::copyImageAt(const WebPoint& posInViewport)
+{
+ HitTestResult result = hitTestResultForVisualViewportPos(posInViewport);
+ if (!isHTMLCanvasElement(result.innerNodeOrImageMapImage()) && result.absoluteImageURL().isEmpty()) {
+ // There isn't actually an image at these coordinates. Might be because
+ // the window scrolled while the context menu was open or because the page
+ // changed itself between when we thought there was an image here and when
+ // we actually tried to retreive the image.
+ //
+ // FIXME: implement a cache of the most recent HitTestResult to avoid having
+ // to do two hit tests.
+ return;
+ }
+
+ frame()->editor().copyImage(result);
+}
+
+void WebLocalFrameImpl::saveImageAt(const WebPoint& posInViewport)
+{
+ Node* node = hitTestResultForVisualViewportPos(posInViewport).innerNodeOrImageMapImage();
+ if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node)))
+ return;
+
+ String url = toElement(*node).imageSourceURL();
+ if (!KURL(KURL(), url).protocolIsData())
+ return;
+
+ m_client->saveImageFromDataURL(url);
+}
+
WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const
{
if (!frame())
@@ -1758,6 +1789,15 @@ void WebLocalFrameImpl::loadJavaScriptURL(const KURL& url)
frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResult, ownerDocument);
}
+HitTestResult WebLocalFrameImpl::hitTestResultForVisualViewportPos(const IntPoint& posInViewport)
+{
+ IntPoint rootFramePoint(frame()->host()->visualViewport().viewportToRootFrame(posInViewport));
dcheng 2016/06/08 16:00:35 +bokan, is this the right thing to do for a local
bokan 2016/06/08 16:13:27 Hmm...I'm not sure how VisualViewport behaves in O
alexmos 2016/06/08 16:40:33 Note that I recently did some work to sync the Vis
brettw 2016/06/09 23:41:01 I didn't make any changes here. If I should change
+ IntPoint docPoint(frame()->view()->rootFrameToContents(rootFramePoint));
+ HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active);
+ result.setToShadowHostIfInUserAgentShadowRoot();
+ return result;
+}
+
static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader)
{
// Internally, Blink uses CommittedMultipleRealLoads to track whether the

Powered by Google App Engine
This is Rietveld 408576698