| 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 30 matching lines...) Expand all Loading... |
| 41 double MediaValues::calculateViewportHeight(LocalFrame* frame) | 41 double MediaValues::calculateViewportHeight(LocalFrame* frame) |
| 42 { | 42 { |
| 43 ASSERT(frame && frame->view() && frame->document()); | 43 ASSERT(frame && frame->view() && frame->document()); |
| 44 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); | 44 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); |
| 45 return adjustDoubleForAbsoluteZoom(viewportHeight, frame->document()->layout
ViewItem().styleRef()); | 45 return adjustDoubleForAbsoluteZoom(viewportHeight, frame->document()->layout
ViewItem().styleRef()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 int MediaValues::calculateDeviceWidth(LocalFrame* frame) | 48 int MediaValues::calculateDeviceWidth(LocalFrame* frame) |
| 49 { | 49 { |
| 50 ASSERT(frame && frame->view() && frame->settings() && frame->host()); | 50 ASSERT(frame && frame->view() && frame->settings() && frame->host()); |
| 51 int deviceWidth = frame->host()->chromeClient().screenInfo().rect.width; | 51 blink::WebScreenInfo screenInfo = frame->host()->chromeClient().screenInfo()
; |
| 52 int deviceWidth = screenInfo.rect.width; |
| 52 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) | 53 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) |
| 53 deviceWidth = lroundf(deviceWidth * frame->host()->deviceScaleFactor()); | 54 deviceWidth = lroundf(deviceWidth * screenInfo.deviceScaleFactor); |
| 54 return deviceWidth; | 55 return deviceWidth; |
| 55 } | 56 } |
| 56 | 57 |
| 57 int MediaValues::calculateDeviceHeight(LocalFrame* frame) | 58 int MediaValues::calculateDeviceHeight(LocalFrame* frame) |
| 58 { | 59 { |
| 59 ASSERT(frame && frame->view() && frame->settings() && frame->host()); | 60 ASSERT(frame && frame->view() && frame->settings() && frame->host()); |
| 60 int deviceHeight = frame->host()->chromeClient().screenInfo().rect.height; | 61 blink::WebScreenInfo screenInfo = frame->host()->chromeClient().screenInfo()
; |
| 62 int deviceHeight = screenInfo.rect.height; |
| 61 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) | 63 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) |
| 62 deviceHeight = lroundf(deviceHeight * frame->host()->deviceScaleFactor()
); | 64 deviceHeight = lroundf(deviceHeight * screenInfo.deviceScaleFactor); |
| 63 return deviceHeight; | 65 return deviceHeight; |
| 64 } | 66 } |
| 65 | 67 |
| 66 bool MediaValues::calculateStrictMode(LocalFrame* frame) | 68 bool MediaValues::calculateStrictMode(LocalFrame* frame) |
| 67 { | 69 { |
| 68 ASSERT(frame && frame->document()); | 70 ASSERT(frame && frame->document()); |
| 69 return !frame->document()->inQuirksMode(); | 71 return !frame->document()->inQuirksMode(); |
| 70 } | 72 } |
| 71 | 73 |
| 72 float MediaValues::calculateDevicePixelRatio(LocalFrame* frame) | 74 float MediaValues::calculateDevicePixelRatio(LocalFrame* frame) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 210 } |
| 209 | 211 |
| 210 LocalFrame* MediaValues::frameFrom(Document& document) | 212 LocalFrame* MediaValues::frameFrom(Document& document) |
| 211 { | 213 { |
| 212 Document* executingDocument = document.importsController() ? document.import
sController()->master() : &document; | 214 Document* executingDocument = document.importsController() ? document.import
sController()->master() : &document; |
| 213 ASSERT(executingDocument); | 215 ASSERT(executingDocument); |
| 214 return executingDocument->frame(); | 216 return executingDocument->frame(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 } // namespace blink | 219 } // namespace blink |
| OLD | NEW |