| 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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 double durationInSeconds) { | 1013 double durationInSeconds) { |
| 1014 VisualViewport& visualViewport = page()->frameHost().visualViewport(); | 1014 VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
| 1015 WebPoint clampedPoint = targetPosition; | 1015 WebPoint clampedPoint = targetPosition; |
| 1016 if (!useAnchor) { | 1016 if (!useAnchor) { |
| 1017 clampedPoint = | 1017 clampedPoint = |
| 1018 visualViewport.clampDocumentOffsetAtScale(targetPosition, newScale); | 1018 visualViewport.clampDocumentOffsetAtScale(targetPosition, newScale); |
| 1019 if (!durationInSeconds) { | 1019 if (!durationInSeconds) { |
| 1020 setPageScaleFactor(newScale); | 1020 setPageScaleFactor(newScale); |
| 1021 | 1021 |
| 1022 FrameView* view = mainFrameImpl()->frameView(); | 1022 FrameView* view = mainFrameImpl()->frameView(); |
| 1023 if (view && view->getScrollableArea()) | 1023 if (view && view->getScrollableArea()) { |
| 1024 view->getScrollableArea()->setScrollPosition( | 1024 view->getScrollableArea()->setScrollOffset( |
| 1025 DoublePoint(clampedPoint.x, clampedPoint.y), ProgrammaticScroll); | 1025 ScrollOffset(clampedPoint.x, clampedPoint.y), ProgrammaticScroll); |
| 1026 } |
| 1026 | 1027 |
| 1027 return false; | 1028 return false; |
| 1028 } | 1029 } |
| 1029 } | 1030 } |
| 1030 if (useAnchor && newScale == pageScaleFactor()) | 1031 if (useAnchor && newScale == pageScaleFactor()) |
| 1031 return false; | 1032 return false; |
| 1032 | 1033 |
| 1033 if (m_enableFakePageScaleAnimationForTesting) { | 1034 if (m_enableFakePageScaleAnimationForTesting) { |
| 1034 m_fakePageScaleAnimationTargetPosition = targetPosition; | 1035 m_fakePageScaleAnimationTargetPosition = targetPosition; |
| 1035 m_fakePageScaleAnimationUseAnchor = useAnchor; | 1036 m_fakePageScaleAnimationUseAnchor = useAnchor; |
| (...skipping 2325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3361 if (!mainFrameImpl()) | 3362 if (!mainFrameImpl()) |
| 3362 return; | 3363 return; |
| 3363 | 3364 |
| 3364 FrameView* view = mainFrameImpl()->frameView(); | 3365 FrameView* view = mainFrameImpl()->frameView(); |
| 3365 if (!view) | 3366 if (!view) |
| 3366 return; | 3367 return; |
| 3367 | 3368 |
| 3368 // Order is important: visual viewport location is clamped based on | 3369 // Order is important: visual viewport location is clamped based on |
| 3369 // main frame scroll position and visual viewport scale. | 3370 // main frame scroll position and visual viewport scale. |
| 3370 | 3371 |
| 3371 view->setScrollPosition(mainFrameOrigin, ProgrammaticScroll); | 3372 view->setScrollOffset(toScrollOffset(mainFrameOrigin), ProgrammaticScroll); |
| 3372 | 3373 |
| 3373 setPageScaleFactor(scaleFactor); | 3374 setPageScaleFactor(scaleFactor); |
| 3374 | 3375 |
| 3375 page()->frameHost().visualViewport().setLocation(visualViewportOrigin); | 3376 page()->frameHost().visualViewport().setLocation(visualViewportOrigin); |
| 3376 } | 3377 } |
| 3377 | 3378 |
| 3378 void WebViewImpl::setPageScaleFactorAndLocation(float scaleFactor, | 3379 void WebViewImpl::setPageScaleFactorAndLocation(float scaleFactor, |
| 3379 const FloatPoint& location) { | 3380 const FloatPoint& location) { |
| 3380 DCHECK(page()); | 3381 DCHECK(page()); |
| 3381 | 3382 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3672 | 3673 |
| 3673 void WebViewImpl::resetScrollAndScaleState() { | 3674 void WebViewImpl::resetScrollAndScaleState() { |
| 3674 page()->frameHost().visualViewport().reset(); | 3675 page()->frameHost().visualViewport().reset(); |
| 3675 | 3676 |
| 3676 if (!page()->mainFrame()->isLocalFrame()) | 3677 if (!page()->mainFrame()->isLocalFrame()) |
| 3677 return; | 3678 return; |
| 3678 | 3679 |
| 3679 if (FrameView* frameView = toLocalFrame(page()->mainFrame())->view()) { | 3680 if (FrameView* frameView = toLocalFrame(page()->mainFrame())->view()) { |
| 3680 ScrollableArea* scrollableArea = frameView->layoutViewportScrollableArea(); | 3681 ScrollableArea* scrollableArea = frameView->layoutViewportScrollableArea(); |
| 3681 | 3682 |
| 3682 if (scrollableArea->scrollPositionDouble() != DoublePoint::zero()) | 3683 if (!scrollableArea->scrollOffset().isZero()) |
| 3683 scrollableArea->setScrollPosition(DoublePoint::zero(), | 3684 scrollableArea->setScrollOffset(ScrollOffset(), ProgrammaticScroll); |
| 3684 ProgrammaticScroll); | |
| 3685 } | 3685 } |
| 3686 | 3686 |
| 3687 pageScaleConstraintsSet().setNeedsReset(true); | 3687 pageScaleConstraintsSet().setNeedsReset(true); |
| 3688 } | 3688 } |
| 3689 | 3689 |
| 3690 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, | 3690 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, |
| 3691 const WebPoint& location) { | 3691 const WebPoint& location) { |
| 3692 HitTestResult result = hitTestResultForViewportPos(location); | 3692 HitTestResult result = hitTestResultForViewportPos(location); |
| 3693 Node* node = result.innerNode(); | 3693 Node* node = result.innerNode(); |
| 3694 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) | 3694 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4696 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) | 4696 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) |
| 4697 return nullptr; | 4697 return nullptr; |
| 4698 return focusedFrame; | 4698 return focusedFrame; |
| 4699 } | 4699 } |
| 4700 | 4700 |
| 4701 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { | 4701 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { |
| 4702 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4702 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
| 4703 } | 4703 } |
| 4704 | 4704 |
| 4705 } // namespace blink | 4705 } // namespace blink |
| OLD | NEW |