| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights |
| 7 * reserved. | 7 * reserved. |
| 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * You should have received a copy of the GNU Library General Public License | 23 * You should have received a copy of the GNU Library General Public License |
| 24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
| 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
| 27 * | 27 * |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "core/dom/ViewportDescription.h" | 30 #include "core/dom/ViewportDescription.h" |
| 31 | 31 |
| 32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
| 33 #include "core/frame/FrameHost.h" | |
| 34 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
| 35 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 36 #include "core/frame/Settings.h" | 35 #include "core/frame/Settings.h" |
| 37 #include "core/frame/VisualViewport.h" | 36 #include "core/frame/VisualViewport.h" |
| 37 #include "core/page/Page.h" |
| 38 #include "platform/Histogram.h" | 38 #include "platform/Histogram.h" |
| 39 #include "platform/weborigin/KURL.h" | 39 #include "platform/weborigin/KURL.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 static const float& compareIgnoringAuto(const float& value1, | 43 static const float& compareIgnoringAuto(const float& value1, |
| 44 const float& value2, | 44 const float& value2, |
| 45 const float& (*compare)(const float&, | 45 const float& (*compare)(const float&, |
| 46 const float&)) { | 46 const float&)) { |
| 47 if (value1 == ViewportDescription::ValueAuto) | 47 if (value1 == ViewportDescription::ValueAuto) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 NoViewportTag, | 242 NoViewportTag, |
| 243 DeviceWidth, | 243 DeviceWidth, |
| 244 ConstantWidth, | 244 ConstantWidth, |
| 245 MetaWidthOther, | 245 MetaWidthOther, |
| 246 MetaHandheldFriendly, | 246 MetaHandheldFriendly, |
| 247 MetaMobileOptimized, | 247 MetaMobileOptimized, |
| 248 XhtmlMobileProfile, | 248 XhtmlMobileProfile, |
| 249 TypeCount | 249 TypeCount |
| 250 }; | 250 }; |
| 251 | 251 |
| 252 if (!mainFrame || !mainFrame->host() || !mainFrame->view() || | 252 if (!mainFrame || !mainFrame->page() || !mainFrame->view() || |
| 253 !mainFrame->document()) | 253 !mainFrame->document()) |
| 254 return; | 254 return; |
| 255 | 255 |
| 256 // Avoid chrome:// pages like the new-tab page (on Android new tab is | 256 // Avoid chrome:// pages like the new-tab page (on Android new tab is |
| 257 // non-http). | 257 // non-http). |
| 258 if (!mainFrame->document()->url().protocolIsInHTTPFamily()) | 258 if (!mainFrame->document()->url().protocolIsInHTTPFamily()) |
| 259 return; | 259 return; |
| 260 | 260 |
| 261 DEFINE_STATIC_LOCAL(EnumerationHistogram, metaTagTypeHistogram, | 261 DEFINE_STATIC_LOCAL(EnumerationHistogram, metaTagTypeHistogram, |
| 262 ("Viewport.MetaTagType", TypeCount)); | 262 ("Viewport.MetaTagType", TypeCount)); |
| 263 if (!isSpecifiedByAuthor()) { | 263 if (!isSpecifiedByAuthor()) { |
| 264 metaTagTypeHistogram.count(mainFrame->document()->isMobileDocument() | 264 metaTagTypeHistogram.count(mainFrame->document()->isMobileDocument() |
| 265 ? XhtmlMobileProfile | 265 ? XhtmlMobileProfile |
| 266 : NoViewportTag); | 266 : NoViewportTag); |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 | 269 |
| 270 if (isMetaViewportType()) { | 270 if (isMetaViewportType()) { |
| 271 if (maxWidth.type() == blink::Fixed) { | 271 if (maxWidth.type() == blink::Fixed) { |
| 272 metaTagTypeHistogram.count(ConstantWidth); | 272 metaTagTypeHistogram.count(ConstantWidth); |
| 273 | 273 |
| 274 if (mainFrame->view()) { | 274 if (mainFrame->view()) { |
| 275 // To get an idea of how "far" the viewport is from the device's ideal | 275 // To get an idea of how "far" the viewport is from the device's ideal |
| 276 // width, we report the zoom level that we'd need to be at for the | 276 // width, we report the zoom level that we'd need to be at for the |
| 277 // entire page to be visible. | 277 // entire page to be visible. |
| 278 int viewportWidth = maxWidth.intValue(); | 278 int viewportWidth = maxWidth.intValue(); |
| 279 int windowWidth = mainFrame->host()->visualViewport().size().width(); | 279 int windowWidth = mainFrame->page()->visualViewport().size().width(); |
| 280 int overviewZoomPercent = | 280 int overviewZoomPercent = |
| 281 100 * windowWidth / static_cast<float>(viewportWidth); | 281 100 * windowWidth / static_cast<float>(viewportWidth); |
| 282 DEFINE_STATIC_LOCAL(SparseHistogram, overviewZoomHistogram, | 282 DEFINE_STATIC_LOCAL(SparseHistogram, overviewZoomHistogram, |
| 283 ("Viewport.OverviewZoom")); | 283 ("Viewport.OverviewZoom")); |
| 284 overviewZoomHistogram.sample(overviewZoomPercent); | 284 overviewZoomHistogram.sample(overviewZoomPercent); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } else if (maxWidth.type() == blink::DeviceWidth || | 287 } else if (maxWidth.type() == blink::DeviceWidth || |
| 288 maxWidth.type() == blink::ExtendToZoom) { | 288 maxWidth.type() == blink::ExtendToZoom) { |
| 289 metaTagTypeHistogram.count(DeviceWidth); | 289 metaTagTypeHistogram.count(DeviceWidth); |
| 290 } else { | 290 } else { |
| 291 // Overflow bucket for cases we may be unaware of. | 291 // Overflow bucket for cases we may be unaware of. |
| 292 metaTagTypeHistogram.count(MetaWidthOther); | 292 metaTagTypeHistogram.count(MetaWidthOther); |
| 293 } | 293 } |
| 294 } else if (type == ViewportDescription::HandheldFriendlyMeta) { | 294 } else if (type == ViewportDescription::HandheldFriendlyMeta) { |
| 295 metaTagTypeHistogram.count(MetaHandheldFriendly); | 295 metaTagTypeHistogram.count(MetaHandheldFriendly); |
| 296 } else if (type == ViewportDescription::MobileOptimizedMeta) { | 296 } else if (type == ViewportDescription::MobileOptimizedMeta) { |
| 297 metaTagTypeHistogram.count(MetaMobileOptimized); | 297 metaTagTypeHistogram.count(MetaMobileOptimized); |
| 298 } | 298 } |
| 299 #endif | 299 #endif |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool ViewportDescription::matchesHeuristicsForGpuRasterization() const { | 302 bool ViewportDescription::matchesHeuristicsForGpuRasterization() const { |
| 303 return isSpecifiedByAuthor(); | 303 return isSpecifiedByAuthor(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace blink | 306 } // namespace blink |
| OLD | NEW |