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