| 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" |
| 11 #include "core/dom/Element.h" | 11 #include "core/dom/Element.h" |
| 12 #include "core/frame/FrameHost.h" | |
| 13 #include "core/frame/FrameView.h" | 12 #include "core/frame/FrameView.h" |
| 14 #include "core/frame/LocalFrame.h" | 13 #include "core/frame/LocalFrame.h" |
| 15 #include "core/frame/Settings.h" | 14 #include "core/frame/Settings.h" |
| 16 #include "core/html/imports/HTMLImportsController.h" | 15 #include "core/html/imports/HTMLImportsController.h" |
| 17 #include "core/layout/LayoutObject.h" | 16 #include "core/layout/LayoutObject.h" |
| 18 #include "core/layout/api/LayoutViewItem.h" | 17 #include "core/layout/api/LayoutViewItem.h" |
| 19 #include "core/layout/compositing/PaintLayerCompositor.h" | 18 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 20 #include "core/page/ChromeClient.h" | 19 #include "core/page/ChromeClient.h" |
| 21 #include "core/page/Page.h" | 20 #include "core/page/Page.h" |
| 22 #include "core/style/ComputedStyle.h" | 21 #include "core/style/ComputedStyle.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 } | 38 } |
| 40 | 39 |
| 41 double MediaValues::calculateViewportHeight(LocalFrame* frame) { | 40 double MediaValues::calculateViewportHeight(LocalFrame* frame) { |
| 42 ASSERT(frame && frame->view() && frame->document()); | 41 ASSERT(frame && frame->view() && frame->document()); |
| 43 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); | 42 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); |
| 44 return adjustDoubleForAbsoluteZoom( | 43 return adjustDoubleForAbsoluteZoom( |
| 45 viewportHeight, frame->document()->layoutViewItem().styleRef()); | 44 viewportHeight, frame->document()->layoutViewItem().styleRef()); |
| 46 } | 45 } |
| 47 | 46 |
| 48 int MediaValues::calculateDeviceWidth(LocalFrame* frame) { | 47 int MediaValues::calculateDeviceWidth(LocalFrame* frame) { |
| 49 ASSERT(frame && frame->view() && frame->settings() && frame->host()); | 48 DCHECK(frame && frame->view() && frame->settings() && frame->page()); |
| 50 blink::WebScreenInfo screenInfo = frame->host()->chromeClient().screenInfo(); | 49 blink::WebScreenInfo screenInfo = frame->page()->chromeClient().screenInfo(); |
| 51 int deviceWidth = screenInfo.rect.width; | 50 int deviceWidth = screenInfo.rect.width; |
| 52 if (frame->settings()->getReportScreenSizeInPhysicalPixelsQuirk()) | 51 if (frame->settings()->getReportScreenSizeInPhysicalPixelsQuirk()) |
| 53 deviceWidth = lroundf(deviceWidth * screenInfo.deviceScaleFactor); | 52 deviceWidth = lroundf(deviceWidth * screenInfo.deviceScaleFactor); |
| 54 return deviceWidth; | 53 return deviceWidth; |
| 55 } | 54 } |
| 56 | 55 |
| 57 int MediaValues::calculateDeviceHeight(LocalFrame* frame) { | 56 int MediaValues::calculateDeviceHeight(LocalFrame* frame) { |
| 58 ASSERT(frame && frame->view() && frame->settings() && frame->host()); | 57 DCHECK(frame && frame->view() && frame->settings() && frame->page()); |
| 59 blink::WebScreenInfo screenInfo = frame->host()->chromeClient().screenInfo(); | 58 blink::WebScreenInfo screenInfo = frame->page()->chromeClient().screenInfo(); |
| 60 int deviceHeight = screenInfo.rect.height; | 59 int deviceHeight = screenInfo.rect.height; |
| 61 if (frame->settings()->getReportScreenSizeInPhysicalPixelsQuirk()) | 60 if (frame->settings()->getReportScreenSizeInPhysicalPixelsQuirk()) |
| 62 deviceHeight = lroundf(deviceHeight * screenInfo.deviceScaleFactor); | 61 deviceHeight = lroundf(deviceHeight * screenInfo.deviceScaleFactor); |
| 63 return deviceHeight; | 62 return deviceHeight; |
| 64 } | 63 } |
| 65 | 64 |
| 66 bool MediaValues::calculateStrictMode(LocalFrame* frame) { | 65 bool MediaValues::calculateStrictMode(LocalFrame* frame) { |
| 67 ASSERT(frame && frame->document()); | 66 ASSERT(frame && frame->document()); |
| 68 return !frame->document()->inQuirksMode(); | 67 return !frame->document()->inQuirksMode(); |
| 69 } | 68 } |
| 70 | 69 |
| 71 float MediaValues::calculateDevicePixelRatio(LocalFrame* frame) { | 70 float MediaValues::calculateDevicePixelRatio(LocalFrame* frame) { |
| 72 return frame->devicePixelRatio(); | 71 return frame->devicePixelRatio(); |
| 73 } | 72 } |
| 74 | 73 |
| 75 int MediaValues::calculateColorBitsPerComponent(LocalFrame* frame) { | 74 int MediaValues::calculateColorBitsPerComponent(LocalFrame* frame) { |
| 76 ASSERT(frame && frame->page() && frame->page()->mainFrame()); | 75 ASSERT(frame && frame->page() && frame->page()->mainFrame()); |
| 77 if (!frame->page()->mainFrame()->isLocalFrame() || | 76 if (!frame->page()->mainFrame()->isLocalFrame() || |
| 78 frame->host()->chromeClient().screenInfo().isMonochrome) | 77 frame->page()->chromeClient().screenInfo().isMonochrome) |
| 79 return 0; | 78 return 0; |
| 80 return frame->host()->chromeClient().screenInfo().depthPerComponent; | 79 return frame->page()->chromeClient().screenInfo().depthPerComponent; |
| 81 } | 80 } |
| 82 | 81 |
| 83 int MediaValues::calculateMonochromeBitsPerComponent(LocalFrame* frame) { | 82 int MediaValues::calculateMonochromeBitsPerComponent(LocalFrame* frame) { |
| 84 ASSERT(frame && frame->page() && frame->page()->mainFrame()); | 83 ASSERT(frame && frame->page() && frame->page()->mainFrame()); |
| 85 if (!frame->page()->mainFrame()->isLocalFrame() || | 84 if (!frame->page()->mainFrame()->isLocalFrame() || |
| 86 !frame->host()->chromeClient().screenInfo().isMonochrome) | 85 !frame->page()->chromeClient().screenInfo().isMonochrome) |
| 87 return 0; | 86 return 0; |
| 88 return frame->host()->chromeClient().screenInfo().depthPerComponent; | 87 return frame->page()->chromeClient().screenInfo().depthPerComponent; |
| 89 } | 88 } |
| 90 | 89 |
| 91 int MediaValues::calculateDefaultFontSize(LocalFrame* frame) { | 90 int MediaValues::calculateDefaultFontSize(LocalFrame* frame) { |
| 92 return frame->page()->settings().getDefaultFontSize(); | 91 return frame->page()->settings().getDefaultFontSize(); |
| 93 } | 92 } |
| 94 | 93 |
| 95 const String MediaValues::calculateMediaType(LocalFrame* frame) { | 94 const String MediaValues::calculateMediaType(LocalFrame* frame) { |
| 96 ASSERT(frame); | 95 ASSERT(frame); |
| 97 if (!frame->view()) | 96 if (!frame->view()) |
| 98 return emptyAtom; | 97 return emptyAtom; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 ASSERT(frame && frame->settings()); | 134 ASSERT(frame && frame->settings()); |
| 136 return frame->settings()->getPrimaryHoverType(); | 135 return frame->settings()->getPrimaryHoverType(); |
| 137 } | 136 } |
| 138 | 137 |
| 139 int MediaValues::calculateAvailableHoverTypes(LocalFrame* frame) { | 138 int MediaValues::calculateAvailableHoverTypes(LocalFrame* frame) { |
| 140 ASSERT(frame && frame->settings()); | 139 ASSERT(frame && frame->settings()); |
| 141 return frame->settings()->getAvailableHoverTypes(); | 140 return frame->settings()->getAvailableHoverTypes(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 DisplayShape MediaValues::calculateDisplayShape(LocalFrame* frame) { | 143 DisplayShape MediaValues::calculateDisplayShape(LocalFrame* frame) { |
| 145 DCHECK(frame && frame->host()); | 144 DCHECK(frame && frame->page()); |
| 146 return frame->host()->chromeClient().screenInfo().displayShape; | 145 return frame->page()->chromeClient().screenInfo().displayShape; |
| 147 } | 146 } |
| 148 | 147 |
| 149 ColorSpaceGamut MediaValues::calculateColorGamut(LocalFrame* frame) { | 148 ColorSpaceGamut MediaValues::calculateColorGamut(LocalFrame* frame) { |
| 150 DCHECK(frame && frame->host()); | 149 DCHECK(frame && frame->page()); |
| 151 return ColorSpaceUtilities::getColorSpaceGamut( | 150 return ColorSpaceUtilities::getColorSpaceGamut( |
| 152 frame->host()->chromeClient().screenInfo()); | 151 frame->page()->chromeClient().screenInfo()); |
| 153 } | 152 } |
| 154 | 153 |
| 155 bool MediaValues::computeLengthImpl(double value, | 154 bool MediaValues::computeLengthImpl(double value, |
| 156 CSSPrimitiveValue::UnitType type, | 155 CSSPrimitiveValue::UnitType type, |
| 157 unsigned defaultFontSize, | 156 unsigned defaultFontSize, |
| 158 double viewportWidth, | 157 double viewportWidth, |
| 159 double viewportHeight, | 158 double viewportHeight, |
| 160 double& result) { | 159 double& result) { |
| 161 // The logic in this function is duplicated from | 160 // The logic in this function is duplicated from |
| 162 // CSSToLengthConversionData::zoomedComputedPixels() because | 161 // CSSToLengthConversionData::zoomedComputedPixels() because |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 216 |
| 218 LocalFrame* MediaValues::frameFrom(Document& document) { | 217 LocalFrame* MediaValues::frameFrom(Document& document) { |
| 219 Document* executingDocument = document.importsController() | 218 Document* executingDocument = document.importsController() |
| 220 ? document.importsController()->master() | 219 ? document.importsController()->master() |
| 221 : &document; | 220 : &document; |
| 222 ASSERT(executingDocument); | 221 ASSERT(executingDocument); |
| 223 return executingDocument->frame(); | 222 return executingDocument->frame(); |
| 224 } | 223 } |
| 225 | 224 |
| 226 } // namespace blink | 225 } // namespace blink |
| OLD | NEW |