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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 using blink::FrameHost; | 64 using blink::FrameHost; |
65 using blink::GraphicsLayer; | 65 using blink::GraphicsLayer; |
66 using blink::GraphicsLayerFactory; | 66 using blink::GraphicsLayerFactory; |
67 | 67 |
68 namespace blink { | 68 namespace blink { |
69 | 69 |
70 VisualViewport::VisualViewport(FrameHost& owner) | 70 VisualViewport::VisualViewport(FrameHost& owner) |
71 : m_frameHost(&owner) | 71 : m_frameHost(&owner) |
72 , m_scale(1) | 72 , m_scale(1) |
73 , m_topControlsAdjustment(0) | 73 , m_topControlsAdjustment(0) |
74 , m_maxPageScale(-1) | |
75 , m_trackPinchZoomStatsForPage(false) | |
74 { | 76 { |
75 reset(); | 77 reset(); |
76 } | 78 } |
77 | 79 |
78 VisualViewport::~VisualViewport() | 80 VisualViewport::~VisualViewport() |
79 { | 81 { |
82 sendUMAMetrics(); | |
Rick Byers
2015/09/28 18:43:58
Is there already an established pattern for render
bokan
2015/09/29 20:33:20
I copied this pattern from the Blink useCounter wh
bokan
2015/10/01 20:58:15
Right, so this wont report stats for a page if the
Rick Byers
2015/10/02 00:53:22
Ugh, that's a pain. I didn't realize UseCounter d
| |
80 } | 83 } |
81 | 84 |
82 DEFINE_TRACE(VisualViewport) | 85 DEFINE_TRACE(VisualViewport) |
83 { | 86 { |
84 visitor->trace(m_frameHost); | 87 visitor->trace(m_frameHost); |
85 ScrollableArea::trace(visitor); | 88 ScrollableArea::trace(visitor); |
86 } | 89 } |
87 | 90 |
88 void VisualViewport::setSize(const IntSize& size) | 91 void VisualViewport::setSize(const IntSize& size) |
89 { | 92 { |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 // FIXME: How to snap to pixels? | 650 // FIXME: How to snap to pixels? |
648 return flooredIntPoint(FloatPoint(viewportToRootFrame(FloatPoint(pointInView port)))); | 651 return flooredIntPoint(FloatPoint(viewportToRootFrame(FloatPoint(pointInView port)))); |
649 } | 652 } |
650 | 653 |
651 IntPoint VisualViewport::rootFrameToViewport(const IntPoint& pointInRootFrame) c onst | 654 IntPoint VisualViewport::rootFrameToViewport(const IntPoint& pointInRootFrame) c onst |
652 { | 655 { |
653 // FIXME: How to snap to pixels? | 656 // FIXME: How to snap to pixels? |
654 return flooredIntPoint(FloatPoint(rootFrameToViewport(FloatPoint(pointInRoot Frame)))); | 657 return flooredIntPoint(FloatPoint(rootFrameToViewport(FloatPoint(pointInRoot Frame)))); |
655 } | 658 } |
656 | 659 |
660 void VisualViewport::startTrackingPinchStats() | |
661 { | |
662 #if !OS(ANDROID) | |
663 return; | |
Rick Byers
2015/09/28 18:43:58
Always sucks to add more #if OS(ANDROID (eg. makes
bokan
2015/10/01 20:18:31
Gone in latest patch.
| |
664 #endif | |
665 | |
666 if (!mainFrame()) | |
667 return; | |
668 | |
669 Document* document = mainFrame()->document(); | |
670 if (!document) | |
671 return; | |
672 | |
673 if (!document->url().protocolIsInHTTPFamily()) | |
674 return; | |
675 | |
676 const ViewportDescription& desc = mainFrame()->document()->viewportDescripti on(); | |
677 bool isNonMobile = | |
Rick Byers
2015/09/28 18:43:58
I thought this logic (along with "am I on Android"
bokan
2015/09/29 20:33:20
WebViewImpl::shouldDisableDesktopWorkarounds. It's
bokan
2015/10/01 20:18:31
Latest patch replaces this with the shouldDisableD
| |
678 !desc.isSpecifiedByAuthor() | |
679 || (desc.isMetaViewportType() && desc.maxWidth.type() == blink::Fixed); | |
680 | |
681 m_trackPinchZoomStatsForPage = isNonMobile; | |
682 } | |
683 | |
684 void VisualViewport::userDidChangeScale() | |
685 { | |
686 if (!m_trackPinchZoomStatsForPage) | |
687 return; | |
688 | |
689 m_maxPageScale = std::max(m_maxPageScale, m_scale); | |
Rick Byers
2015/09/28 18:43:58
I assume this gets called only at GesturePinchEnd
bokan
2015/09/29 20:33:20
Good point. I do think capturing the scale only at
| |
690 } | |
691 | |
692 void VisualViewport::sendUMAMetrics() | |
693 { | |
694 if (m_trackPinchZoomStatsForPage) { | |
695 bool didScale = m_maxPageScale > 0; | |
696 | |
697 Platform::current()->histogramEnumeration("Viewport.DidScalePage", didSc ale ? 1 : 0, 2); | |
698 | |
699 if (didScale) { | |
700 int zoomPercentage = floor(m_maxPageScale * 100); | |
701 Platform::current()->histogramEnumeration("Viewport.MaxPageScale", z oomPercentage, 501); | |
Ilya Sherman
2015/09/30 04:30:28
This allocates a histogram with 500 buckets, which
bokan
2015/10/01 20:18:31
Ok, I mapped the percentages into ~20 buckets comp
| |
702 } | |
703 } | |
704 | |
705 m_maxPageScale = -1; | |
706 m_trackPinchZoomStatsForPage = false; | |
707 } | |
708 | |
657 String VisualViewport::debugName(const GraphicsLayer* graphicsLayer) | 709 String VisualViewport::debugName(const GraphicsLayer* graphicsLayer) |
658 { | 710 { |
659 String name; | 711 String name; |
660 if (graphicsLayer == m_innerViewportContainerLayer.get()) { | 712 if (graphicsLayer == m_innerViewportContainerLayer.get()) { |
661 name = "Inner Viewport Container Layer"; | 713 name = "Inner Viewport Container Layer"; |
662 } else if (graphicsLayer == m_overscrollElasticityLayer.get()) { | 714 } else if (graphicsLayer == m_overscrollElasticityLayer.get()) { |
663 name = "Overscroll Elasticity Layer"; | 715 name = "Overscroll Elasticity Layer"; |
664 } else if (graphicsLayer == m_pageScaleLayer.get()) { | 716 } else if (graphicsLayer == m_pageScaleLayer.get()) { |
665 name = "Page Scale Layer"; | 717 name = "Page Scale Layer"; |
666 } else if (graphicsLayer == m_innerViewportScrollLayer.get()) { | 718 } else if (graphicsLayer == m_innerViewportScrollLayer.get()) { |
667 name = "Inner Viewport Scroll Layer"; | 719 name = "Inner Viewport Scroll Layer"; |
668 } else if (graphicsLayer == m_overlayScrollbarHorizontal.get()) { | 720 } else if (graphicsLayer == m_overlayScrollbarHorizontal.get()) { |
669 name = "Overlay Scrollbar Horizontal Layer"; | 721 name = "Overlay Scrollbar Horizontal Layer"; |
670 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { | 722 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { |
671 name = "Overlay Scrollbar Vertical Layer"; | 723 name = "Overlay Scrollbar Vertical Layer"; |
672 } else if (graphicsLayer == m_rootTransformLayer) { | 724 } else if (graphicsLayer == m_rootTransformLayer) { |
673 name = "Root Transform Layer"; | 725 name = "Root Transform Layer"; |
674 } else { | 726 } else { |
675 ASSERT_NOT_REACHED(); | 727 ASSERT_NOT_REACHED(); |
676 } | 728 } |
677 | 729 |
678 return name; | 730 return name; |
679 } | 731 } |
680 | 732 |
681 } // namespace blink | 733 } // namespace blink |
OLD | NEW |