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/MediaValues.h" | 5 #include "core/css/MediaValues.h" |
6 | 6 |
7 #include "core/css/CSSHelper.h" | 7 #include "core/css/CSSHelper.h" |
8 #include "core/css/MediaValuesCached.h" | 8 #include "core/css/MediaValuesCached.h" |
9 #include "core/css/MediaValuesDynamic.h" | 9 #include "core/css/MediaValuesDynamic.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 namespace blink { | 25 namespace blink { |
26 | 26 |
27 MediaValues* MediaValues::createDynamicIfFrameExists(LocalFrame* frame) { | 27 MediaValues* MediaValues::createDynamicIfFrameExists(LocalFrame* frame) { |
28 if (frame) | 28 if (frame) |
29 return MediaValuesDynamic::create(frame); | 29 return MediaValuesDynamic::create(frame); |
30 return MediaValuesCached::create(); | 30 return MediaValuesCached::create(); |
31 } | 31 } |
32 | 32 |
33 double MediaValues::calculateViewportWidth(LocalFrame* frame) { | 33 double MediaValues::calculateViewportWidth(LocalFrame* frame) { |
34 ASSERT(frame && frame->view() && frame->document()); | 34 ASSERT(frame && frame->view() && frame->document()); |
35 int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width(); | 35 return frame->view()->viewportSizeForViewportUnits().width(); |
36 return adjustDoubleForAbsoluteZoom( | |
37 viewportWidth, frame->document()->layoutViewItem().styleRef()); | |
38 } | 36 } |
39 | 37 |
40 double MediaValues::calculateViewportHeight(LocalFrame* frame) { | 38 double MediaValues::calculateViewportHeight(LocalFrame* frame) { |
41 ASSERT(frame && frame->view() && frame->document()); | 39 ASSERT(frame && frame->view() && frame->document()); |
42 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); | 40 return frame->view()->viewportSizeForViewportUnits().height(); |
bokan
2017/03/09 16:29:56
I think this is slightly wrong. The reason we have
rune
2017/03/09 17:47:36
Why is there a difference between ICB and viewport
rune
2017/03/09 22:04:55
I added a new viewportSizeForMediaQueries() instea
| |
43 return adjustDoubleForAbsoluteZoom( | |
44 viewportHeight, frame->document()->layoutViewItem().styleRef()); | |
45 } | 41 } |
46 | 42 |
47 int MediaValues::calculateDeviceWidth(LocalFrame* frame) { | 43 int MediaValues::calculateDeviceWidth(LocalFrame* frame) { |
48 DCHECK(frame && frame->view() && frame->settings() && frame->page()); | 44 DCHECK(frame && frame->view() && frame->settings() && frame->page()); |
49 blink::WebScreenInfo screenInfo = frame->page()->chromeClient().screenInfo(); | 45 blink::WebScreenInfo screenInfo = frame->page()->chromeClient().screenInfo(); |
50 int deviceWidth = screenInfo.rect.width; | 46 int deviceWidth = screenInfo.rect.width; |
51 if (frame->settings()->getReportScreenSizeInPhysicalPixelsQuirk()) | 47 if (frame->settings()->getReportScreenSizeInPhysicalPixelsQuirk()) |
52 deviceWidth = lroundf(deviceWidth * screenInfo.deviceScaleFactor); | 48 deviceWidth = lroundf(deviceWidth * screenInfo.deviceScaleFactor); |
53 return deviceWidth; | 49 return deviceWidth; |
54 } | 50 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 | 212 |
217 LocalFrame* MediaValues::frameFrom(Document& document) { | 213 LocalFrame* MediaValues::frameFrom(Document& document) { |
218 Document* executingDocument = document.importsController() | 214 Document* executingDocument = document.importsController() |
219 ? document.importsController()->master() | 215 ? document.importsController()->master() |
220 : &document; | 216 : &document; |
221 ASSERT(executingDocument); | 217 ASSERT(executingDocument); |
222 return executingDocument->frame(); | 218 return executingDocument->frame(); |
223 } | 219 } |
224 | 220 |
225 } // namespace blink | 221 } // namespace blink |
OLD | NEW |