| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/frame/VisualViewport.h" | 31 #include "core/frame/VisualViewport.h" |
| 32 | 32 |
| 33 #include "core/dom/DOMNodeIds.h" | 33 #include "core/dom/DOMNodeIds.h" |
| 34 #include "core/dom/ViewportDescription.h" |
| 34 #include "core/frame/FrameHost.h" | 35 #include "core/frame/FrameHost.h" |
| 35 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
| 36 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
| 37 #include "core/frame/PageScaleConstraints.h" | 38 #include "core/frame/PageScaleConstraints.h" |
| 38 #include "core/frame/PageScaleConstraintsSet.h" | 39 #include "core/frame/PageScaleConstraintsSet.h" |
| 39 #include "core/frame/RootFrameViewport.h" | 40 #include "core/frame/RootFrameViewport.h" |
| 40 #include "core/frame/Settings.h" | 41 #include "core/frame/Settings.h" |
| 41 #include "core/inspector/InspectorInstrumentation.h" | 42 #include "core/inspector/InspectorInstrumentation.h" |
| 42 #include "core/layout/TextAutosizer.h" | 43 #include "core/layout/TextAutosizer.h" |
| 43 #include "core/layout/compositing/PaintLayerCompositor.h" | 44 #include "core/layout/compositing/PaintLayerCompositor.h" |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 if (!mainFrame()) | 728 if (!mainFrame()) |
| 728 return; | 729 return; |
| 729 | 730 |
| 730 Document* document = mainFrame()->document(); | 731 Document* document = mainFrame()->document(); |
| 731 if (!document) | 732 if (!document) |
| 732 return; | 733 return; |
| 733 | 734 |
| 734 if (!document->url().protocolIsInHTTPFamily()) | 735 if (!document->url().protocolIsInHTTPFamily()) |
| 735 return; | 736 return; |
| 736 | 737 |
| 737 m_trackPinchZoomStatsForPage = !shouldDisableDesktopWorkarounds(); | 738 m_trackPinchZoomStatsForPage = |
| 739 !document->viewportDescription().isSpecifiedByAuthor(); |
| 738 } | 740 } |
| 739 | 741 |
| 740 void VisualViewport::userDidChangeScale() { | 742 void VisualViewport::userDidChangeScale() { |
| 741 if (!m_trackPinchZoomStatsForPage) | 743 if (!m_trackPinchZoomStatsForPage) |
| 742 return; | 744 return; |
| 743 | 745 |
| 744 m_maxPageScale = std::max(m_maxPageScale, m_scale); | 746 m_maxPageScale = std::max(m_maxPageScale, m_scale); |
| 745 } | 747 } |
| 746 | 748 |
| 747 void VisualViewport::sendUMAMetrics() { | 749 void VisualViewport::sendUMAMetrics() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 762 DEFINE_STATIC_LOCAL(EnumerationHistogram, maxScaleHistogram, | 764 DEFINE_STATIC_LOCAL(EnumerationHistogram, maxScaleHistogram, |
| 763 ("Viewport.MaxPageScale", 21)); | 765 ("Viewport.MaxPageScale", 21)); |
| 764 maxScaleHistogram.count(bucket); | 766 maxScaleHistogram.count(bucket); |
| 765 } | 767 } |
| 766 } | 768 } |
| 767 | 769 |
| 768 m_maxPageScale = -1; | 770 m_maxPageScale = -1; |
| 769 m_trackPinchZoomStatsForPage = false; | 771 m_trackPinchZoomStatsForPage = false; |
| 770 } | 772 } |
| 771 | 773 |
| 772 bool VisualViewport::shouldDisableDesktopWorkarounds() const { | |
| 773 if (!mainFrame() || !mainFrame()->view()) | |
| 774 return false; | |
| 775 | |
| 776 if (!mainFrame()->settings()->viewportEnabled()) | |
| 777 return false; | |
| 778 | |
| 779 // A document is considered adapted to small screen UAs if one of these holds: | |
| 780 // 1. The author specified viewport has a constrained width that is equal to | |
| 781 // the initial viewport width. | |
| 782 // 2. The author has disabled viewport zoom. | |
| 783 const PageScaleConstraints& constraints = | |
| 784 frameHost().pageScaleConstraintsSet().pageDefinedConstraints(); | |
| 785 | |
| 786 return mainFrame()->view()->layoutSize().width() == m_size.width() || | |
| 787 (constraints.minimumScale == constraints.maximumScale && | |
| 788 constraints.minimumScale != -1); | |
| 789 } | |
| 790 | |
| 791 CompositorAnimationTimeline* VisualViewport::compositorAnimationTimeline() | 774 CompositorAnimationTimeline* VisualViewport::compositorAnimationTimeline() |
| 792 const { | 775 const { |
| 793 ScrollingCoordinator* c = frameHost().page().scrollingCoordinator(); | 776 ScrollingCoordinator* c = frameHost().page().scrollingCoordinator(); |
| 794 return c ? c->compositorAnimationTimeline() : nullptr; | 777 return c ? c->compositorAnimationTimeline() : nullptr; |
| 795 } | 778 } |
| 796 | 779 |
| 797 void VisualViewport::notifyRootFrameViewport() const { | 780 void VisualViewport::notifyRootFrameViewport() const { |
| 798 if (!mainFrame() || !mainFrame()->view()) | 781 if (!mainFrame() || !mainFrame()->view()) |
| 799 return; | 782 return; |
| 800 | 783 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 824 } else if (graphicsLayer == m_rootTransformLayer.get()) { | 807 } else if (graphicsLayer == m_rootTransformLayer.get()) { |
| 825 name = "Root Transform Layer"; | 808 name = "Root Transform Layer"; |
| 826 } else { | 809 } else { |
| 827 ASSERT_NOT_REACHED(); | 810 ASSERT_NOT_REACHED(); |
| 828 } | 811 } |
| 829 | 812 |
| 830 return name; | 813 return name; |
| 831 } | 814 } |
| 832 | 815 |
| 833 } // namespace blink | 816 } // namespace blink |
| OLD | NEW |