| OLD | NEW |
| 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 3608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3619 } | 3619 } |
| 3620 | 3620 |
| 3621 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport) | 3621 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport) |
| 3622 { | 3622 { |
| 3623 DocumentLifecycle::AllowThrottlingScope throttlingScope(mainFrameImpl()->fra
me()->document()->lifecycle()); | 3623 DocumentLifecycle::AllowThrottlingScope throttlingScope(mainFrameImpl()->fra
me()->document()->lifecycle()); |
| 3624 FrameView* view = mainFrameImpl()->frameView(); | 3624 FrameView* view = mainFrameImpl()->frameView(); |
| 3625 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p
ointInViewport)); | 3625 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p
ointInViewport)); |
| 3626 return hitTestResultForRootFramePos(pointInRootFrame); | 3626 return hitTestResultForRootFramePos(pointInRootFrame); |
| 3627 } | 3627 } |
| 3628 | 3628 |
| 3629 void WebViewImpl::copyImageAt(const WebPoint& point) | |
| 3630 { | |
| 3631 if (!m_page) | |
| 3632 return; | |
| 3633 | |
| 3634 HitTestResult result = hitTestResultForViewportPos(point); | |
| 3635 if (!isHTMLCanvasElement(result.innerNodeOrImageMapImage()) && result.absolu
teImageURL().isEmpty()) { | |
| 3636 // There isn't actually an image at these coordinates. Might be because | |
| 3637 // the window scrolled while the context menu was open or because the pa
ge | |
| 3638 // changed itself between when we thought there was an image here and wh
en | |
| 3639 // we actually tried to retreive the image. | |
| 3640 // | |
| 3641 // FIXME: implement a cache of the most recent HitTestResult to avoid ha
ving | |
| 3642 // to do two hit tests. | |
| 3643 return; | |
| 3644 } | |
| 3645 | |
| 3646 m_page->deprecatedLocalMainFrame()->editor().copyImage(result); | |
| 3647 } | |
| 3648 | |
| 3649 void WebViewImpl::saveImageAt(const WebPoint& point) | |
| 3650 { | |
| 3651 if (!m_client) | |
| 3652 return; | |
| 3653 | |
| 3654 Node* node = hitTestResultForViewportPos(point).innerNodeOrImageMapImage(); | |
| 3655 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node))) | |
| 3656 return; | |
| 3657 | |
| 3658 String url = toElement(*node).imageSourceURL(); | |
| 3659 if (!KURL(KURL(), url).protocolIsData()) | |
| 3660 return; | |
| 3661 | |
| 3662 m_client->saveImageFromDataURL(url); | |
| 3663 } | |
| 3664 | |
| 3665 void WebViewImpl::dragSourceEndedAt( | 3629 void WebViewImpl::dragSourceEndedAt( |
| 3666 const WebPoint& clientPoint, | 3630 const WebPoint& clientPoint, |
| 3667 const WebPoint& screenPoint, | 3631 const WebPoint& screenPoint, |
| 3668 WebDragOperation operation) | 3632 WebDragOperation operation) |
| 3669 { | 3633 { |
| 3670 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent::
MouseMoved, | 3634 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent::
MouseMoved, |
| 3671 0, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishab
le, WTF::monotonicallyIncreasingTime()); | 3635 0, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishab
le, WTF::monotonicallyIncreasingTime()); |
| 3672 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme, | 3636 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme, |
| 3673 static_cast<DragOperation>(operation)); | 3637 static_cast<DragOperation>(operation)); |
| 3674 } | 3638 } |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4567 { | 4531 { |
| 4568 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4532 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
| 4569 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4533 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
| 4570 if (!page()) | 4534 if (!page()) |
| 4571 return 1; | 4535 return 1; |
| 4572 | 4536 |
| 4573 return page()->deviceScaleFactor(); | 4537 return page()->deviceScaleFactor(); |
| 4574 } | 4538 } |
| 4575 | 4539 |
| 4576 } // namespace blink | 4540 } // namespace blink |
| OLD | NEW |