| 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 3559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3570 } | 3570 } |
| 3571 | 3571 |
| 3572 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport) | 3572 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport) |
| 3573 { | 3573 { |
| 3574 DocumentLifecycle::AllowThrottlingScope throttlingScope(mainFrameImpl()->fra
me()->document()->lifecycle()); | 3574 DocumentLifecycle::AllowThrottlingScope throttlingScope(mainFrameImpl()->fra
me()->document()->lifecycle()); |
| 3575 FrameView* view = mainFrameImpl()->frameView(); | 3575 FrameView* view = mainFrameImpl()->frameView(); |
| 3576 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p
ointInViewport)); | 3576 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p
ointInViewport)); |
| 3577 return hitTestResultForRootFramePos(pointInRootFrame); | 3577 return hitTestResultForRootFramePos(pointInRootFrame); |
| 3578 } | 3578 } |
| 3579 | 3579 |
| 3580 void WebViewImpl::copyImageAt(const WebPoint& point) | |
| 3581 { | |
| 3582 if (!m_page) | |
| 3583 return; | |
| 3584 | |
| 3585 HitTestResult result = hitTestResultForViewportPos(point); | |
| 3586 if (!isHTMLCanvasElement(result.innerNodeOrImageMapImage()) && result.absolu
teImageURL().isEmpty()) { | |
| 3587 // There isn't actually an image at these coordinates. Might be because | |
| 3588 // the window scrolled while the context menu was open or because the pa
ge | |
| 3589 // changed itself between when we thought there was an image here and wh
en | |
| 3590 // we actually tried to retreive the image. | |
| 3591 // | |
| 3592 // FIXME: implement a cache of the most recent HitTestResult to avoid ha
ving | |
| 3593 // to do two hit tests. | |
| 3594 return; | |
| 3595 } | |
| 3596 | |
| 3597 m_page->deprecatedLocalMainFrame()->editor().copyImage(result); | |
| 3598 } | |
| 3599 | |
| 3600 void WebViewImpl::saveImageAt(const WebPoint& point) | |
| 3601 { | |
| 3602 if (!m_client) | |
| 3603 return; | |
| 3604 | |
| 3605 Node* node = hitTestResultForViewportPos(point).innerNodeOrImageMapImage(); | |
| 3606 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node))) | |
| 3607 return; | |
| 3608 | |
| 3609 String url = toElement(*node).imageSourceURL(); | |
| 3610 if (!KURL(KURL(), url).protocolIsData()) | |
| 3611 return; | |
| 3612 | |
| 3613 m_client->saveImageFromDataURL(url); | |
| 3614 } | |
| 3615 | |
| 3616 void WebViewImpl::dragSourceEndedAt( | 3580 void WebViewImpl::dragSourceEndedAt( |
| 3617 const WebPoint& clientPoint, | 3581 const WebPoint& clientPoint, |
| 3618 const WebPoint& screenPoint, | 3582 const WebPoint& screenPoint, |
| 3619 WebDragOperation operation) | 3583 WebDragOperation operation) |
| 3620 { | 3584 { |
| 3621 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent::
MouseMoved, | 3585 PlatformMouseEvent pme(clientPoint, screenPoint, LeftButton, PlatformEvent::
MouseMoved, |
| 3622 0, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishab
le, WTF::monotonicallyIncreasingTime()); | 3586 0, PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishab
le, WTF::monotonicallyIncreasingTime()); |
| 3623 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme, | 3587 m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme, |
| 3624 static_cast<DragOperation>(operation)); | 3588 static_cast<DragOperation>(operation)); |
| 3625 } | 3589 } |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4524 { | 4488 { |
| 4525 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4489 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
| 4526 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4490 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
| 4527 if (!page()) | 4491 if (!page()) |
| 4528 return 1; | 4492 return 1; |
| 4529 | 4493 |
| 4530 return page()->deviceScaleFactor(); | 4494 return page()->deviceScaleFactor(); |
| 4531 } | 4495 } |
| 4532 | 4496 |
| 4533 } // namespace blink | 4497 } // namespace blink |
| OLD | NEW |