OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/MediaValuesCached.h" | 5 #include "core/css/MediaValuesCached.h" |
6 | 6 |
7 #include "core/css/CSSPrimitiveValue.h" | 7 #include "core/css/CSSPrimitiveValue.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
11 #include "core/layout/api/LayoutViewItem.h" | 11 #include "core/layout/api/LayoutViewItem.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 MediaValuesCached::MediaValuesCachedData::MediaValuesCachedData( | 15 MediaValuesCached::MediaValuesCachedData::MediaValuesCachedData( |
16 Document& document) | 16 Document& document) |
17 : MediaValuesCached::MediaValuesCachedData() { | 17 : MediaValuesCached::MediaValuesCachedData() { |
18 ASSERT(isMainThread()); | 18 ASSERT(isMainThread()); |
19 LocalFrame* frame = MediaValues::frameFrom(document); | 19 LocalFrame* frame = MediaValues::frameFrom(document); |
20 // TODO(hiroshige): Clean up |frame->view()| conditions. | 20 // TODO(hiroshige): Clean up |frame->view()| conditions. |
21 ASSERT(!frame || frame->view()); | 21 ASSERT(!frame || frame->view()); |
22 if (frame && frame->view()) { | 22 if (frame && frame->view()) { |
23 ASSERT(frame->document() && !frame->document()->layoutViewItem().isNull()); | 23 ASSERT(frame->document() && !frame->document()->layoutViewItem().isNull()); |
24 | 24 |
25 // In case that frame is missing (e.g. for images that their document does n
ot have a frame) | 25 // In case that frame is missing (e.g. for images that their document does |
26 // We simply leave the MediaValues object with the default MediaValuesCached
Data values. | 26 // not have a frame) |
| 27 // We simply leave the MediaValues object with the default |
| 28 // MediaValuesCachedData values. |
27 viewportWidth = MediaValues::calculateViewportWidth(frame); | 29 viewportWidth = MediaValues::calculateViewportWidth(frame); |
28 viewportHeight = MediaValues::calculateViewportHeight(frame); | 30 viewportHeight = MediaValues::calculateViewportHeight(frame); |
29 deviceWidth = MediaValues::calculateDeviceWidth(frame); | 31 deviceWidth = MediaValues::calculateDeviceWidth(frame); |
30 deviceHeight = MediaValues::calculateDeviceHeight(frame); | 32 deviceHeight = MediaValues::calculateDeviceHeight(frame); |
31 devicePixelRatio = MediaValues::calculateDevicePixelRatio(frame); | 33 devicePixelRatio = MediaValues::calculateDevicePixelRatio(frame); |
32 colorBitsPerComponent = MediaValues::calculateColorBitsPerComponent(frame); | 34 colorBitsPerComponent = MediaValues::calculateColorBitsPerComponent(frame); |
33 monochromeBitsPerComponent = | 35 monochromeBitsPerComponent = |
34 MediaValues::calculateMonochromeBitsPerComponent(frame); | 36 MediaValues::calculateMonochromeBitsPerComponent(frame); |
35 primaryPointerType = MediaValues::calculatePrimaryPointerType(frame); | 37 primaryPointerType = MediaValues::calculatePrimaryPointerType(frame); |
36 availablePointerTypes = MediaValues::calculateAvailablePointerTypes(frame); | 38 availablePointerTypes = MediaValues::calculateAvailablePointerTypes(frame); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return true; | 148 return true; |
147 } | 149 } |
148 | 150 |
149 void MediaValuesCached::overrideViewportDimensions(double width, | 151 void MediaValuesCached::overrideViewportDimensions(double width, |
150 double height) { | 152 double height) { |
151 m_data.viewportWidth = width; | 153 m_data.viewportWidth = width; |
152 m_data.viewportHeight = height; | 154 m_data.viewportHeight = height; |
153 } | 155 } |
154 | 156 |
155 } // namespace blink | 157 } // namespace blink |
OLD | NEW |