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

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: review comments, merge 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
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b446f19ebe8fd28f213b00644dbb2f93ee0a93d5 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"
@@ -1758,6 +1759,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));
+ 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
@@ -2103,6 +2113,36 @@ WebFrameWidget* WebLocalFrameImpl::frameWidget() const
return m_frameWidget;
}
+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);
+}
+
WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const
{
if (!frame())
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698