| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | |
| 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | |
| 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | |
| 9 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. | |
| 10 * | |
| 11 * This library is free software; you can redistribute it and/or | |
| 12 * modify it under the terms of the GNU Library General Public | |
| 13 * License as published by the Free Software Foundation; either | |
| 14 * version 2 of the License, or (at your option) any later version. | |
| 15 * | |
| 16 * This library is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 19 * Library General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Library General Public License | |
| 22 * along with this library; see the file COPYING.LIB. If not, write to | |
| 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 24 * Boston, MA 02110-1301, USA. | |
| 25 * | |
| 26 */ | |
| 27 | |
| 28 #include "config.h" | |
| 29 #include "core/dom/ViewportDescription.h" | |
| 30 | |
| 31 #include "core/dom/Document.h" | |
| 32 #include "core/frame/FrameHost.h" | |
| 33 #include "core/frame/FrameView.h" | |
| 34 #include "core/frame/LocalFrame.h" | |
| 35 #include "core/frame/Settings.h" | |
| 36 #include "platform/weborigin/KURL.h" | |
| 37 #include "public/platform/Platform.h" | |
| 38 | |
| 39 namespace blink { | |
| 40 | |
| 41 float ViewportDescription::resolveViewportLength(const Length& length, const Flo
atSize& initialViewportSize, Direction direction) | |
| 42 { | |
| 43 if (length.isAuto()) | |
| 44 return ViewportDescription::ValueAuto; | |
| 45 | |
| 46 if (length.isFixed()) | |
| 47 return length.getFloatValue(); | |
| 48 | |
| 49 if (length.type() == ExtendToZoom) | |
| 50 return ViewportDescription::ValueExtendToZoom; | |
| 51 | |
| 52 if (length.type() == Percent && direction == Horizontal) | |
| 53 return initialViewportSize.width() * length.getFloatValue() / 100.0f; | |
| 54 | |
| 55 if (length.type() == Percent && direction == Vertical) | |
| 56 return initialViewportSize.height() * length.getFloatValue() / 100.0f; | |
| 57 | |
| 58 if (length.type() == DeviceWidth) | |
| 59 return initialViewportSize.width(); | |
| 60 | |
| 61 if (length.type() == DeviceHeight) | |
| 62 return initialViewportSize.height(); | |
| 63 | |
| 64 ASSERT_NOT_REACHED(); | |
| 65 return ViewportDescription::ValueAuto; | |
| 66 } | |
| 67 | |
| 68 void ViewportDescription::reportMobilePageStats(const LocalFrame* mainFrame) con
st | |
| 69 { | |
| 70 #if OS(ANDROID) | |
| 71 enum ViewportUMAType { | |
| 72 NoViewportTag, | |
| 73 DeviceWidth, | |
| 74 ConstantWidth, | |
| 75 MetaWidthOther, | |
| 76 MetaHandheldFriendly, | |
| 77 MetaMobileOptimized, | |
| 78 XhtmlMobileProfile, | |
| 79 TypeCount | |
| 80 }; | |
| 81 | |
| 82 if (!mainFrame || !mainFrame->host() || !mainFrame->view() || !mainFrame->do
cument()) | |
| 83 return; | |
| 84 | |
| 85 // Avoid chrome:// pages like the new-tab page (on Android new tab is non-ht
tp). | |
| 86 if (!mainFrame->document()->url().protocolIsInHTTPFamily()) | |
| 87 return; | |
| 88 | |
| 89 if (!isSpecifiedByAuthor()) { | |
| 90 Platform::current()->histogramEnumeration("Viewport.MetaTagType", NoView
portTag, TypeCount); | |
| 91 return; | |
| 92 } | |
| 93 | |
| 94 if (isMetaViewportType()) { | |
| 95 if (maxWidth.type() == blink::Fixed) { | |
| 96 Platform::current()->histogramEnumeration("Viewport.MetaTagType", Co
nstantWidth, TypeCount); | |
| 97 | |
| 98 if (mainFrame->view()) { | |
| 99 // To get an idea of how "far" the viewport is from the device's
ideal width, we | |
| 100 // report the zoom level that we'd need to be at for the entire
page to be visible. | |
| 101 int viewportWidth = maxWidth.intValue(); | |
| 102 int windowWidth = mainFrame->view()->frameRect().width(); | |
| 103 int overviewZoomPercent = 100 * windowWidth / static_cast<float>
(viewportWidth); | |
| 104 Platform::current()->histogramSparse("Viewport.OverviewZoom", ov
erviewZoomPercent); | |
| 105 } | |
| 106 | |
| 107 } else if (maxWidth.type() == blink::DeviceWidth || maxWidth.type() == b
link::ExtendToZoom) { | |
| 108 Platform::current()->histogramEnumeration("Viewport.MetaTagType", De
viceWidth, TypeCount); | |
| 109 } else { | |
| 110 // Overflow bucket for cases we may be unaware of. | |
| 111 Platform::current()->histogramEnumeration("Viewport.MetaTagType", Me
taWidthOther, TypeCount); | |
| 112 } | |
| 113 } else if (type == ViewportDescription::HandheldFriendlyMeta) { | |
| 114 Platform::current()->histogramEnumeration("Viewport.MetaTagType", MetaHa
ndheldFriendly, TypeCount); | |
| 115 } else if (type == ViewportDescription::MobileOptimizedMeta) { | |
| 116 Platform::current()->histogramEnumeration("Viewport.MetaTagType", Mobile
OptimizedMeta, TypeCount); | |
| 117 } | |
| 118 #endif | |
| 119 } | |
| 120 | |
| 121 } // namespace blink | |
| OLD | NEW |