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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 518043003: Add saveImageFromDataURL() and use it in saveImageAt(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | public/web/WebViewClient.h » ('j') | public/web/WebViewClient.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 3278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving 3289 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving
3290 // to do two hit tests. 3290 // to do two hit tests.
3291 return; 3291 return;
3292 } 3292 }
3293 3293
3294 m_page->deprecatedLocalMainFrame()->editor().copyImage(result); 3294 m_page->deprecatedLocalMainFrame()->editor().copyImage(result);
3295 } 3295 }
3296 3296
3297 void WebViewImpl::saveImageAt(const WebPoint& point) 3297 void WebViewImpl::saveImageAt(const WebPoint& point)
3298 { 3298 {
3299 if (!m_page) 3299 if (!m_client)
3300 return; 3300 return;
3301 3301
3302 KURL url = hitTestResultForWindowPos(point).absoluteImageURLIncludingCanvasD ataURL(); 3302 Node* node = hitTestResultForWindowPos(point).innerNonSharedNode();
3303 3303 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node)))
3304 if (url.isEmpty())
3305 return; 3304 return;
3306 3305
3307 ResourceRequest request(url); 3306 m_client->saveImageFromDataURL(toElement(*node).imageSourceURL());
Justin Novosad 2014/09/03 16:55:29 The name "saveImageFromDataURL" is misleading. The
Ken Russell (switch to Gerrit) 2014/09/04 00:23:10 After considering the various alternatives I think
3308 request.setRequestContext(WebURLRequest::RequestContextDownload);
3309 m_page->deprecatedLocalMainFrame()->loader().client()->loadURLExternally(
3310 request, NavigationPolicyDownloadTo, WebString());
3311 } 3307 }
3312 3308
3313 void WebViewImpl::dragSourceEndedAt( 3309 void WebViewImpl::dragSourceEndedAt(
3314 const WebPoint& clientPoint, 3310 const WebPoint& clientPoint,
3315 const WebPoint& screenPoint, 3311 const WebPoint& screenPoint,
3316 WebDragOperation operation) 3312 WebDragOperation operation)
3317 { 3313 {
3318 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent:: MouseMoved, 3314 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent:: MouseMoved,
3319 0, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishab le, 0); 3315 0, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishab le, 0);
3320 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme, 3316 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme,
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
4274 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4270 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4275 4271
4276 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4272 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4277 return false; 4273 return false;
4278 4274
4279 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4275 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4280 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4276 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4281 } 4277 }
4282 4278
4283 } // namespace blink 4279 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/web/WebViewClient.h » ('j') | public/web/WebViewClient.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698