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 "config.h" | 5 #include "config.h" |
6 #include "core/css/MediaValues.h" | 6 #include "core/css/MediaValues.h" |
7 | 7 |
8 #include "core/css/CSSHelper.h" | 8 #include "core/css/CSSHelper.h" |
9 #include "core/css/MediaValuesCached.h" | 9 #include "core/css/MediaValuesCached.h" |
10 #include "core/css/MediaValuesDynamic.h" | 10 #include "core/css/MediaValuesDynamic.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 | 23 |
24 namespace WebCore { | 24 namespace WebCore { |
25 | 25 |
26 PassRefPtr<MediaValues> MediaValues::createDynamicIfFrameExists(LocalFrame* fram e) | 26 PassRefPtr<MediaValues> MediaValues::createDynamicIfFrameExists(LocalFrame* fram e) |
27 { | 27 { |
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 static float getEffectiveZoom(LocalFrame* frame) | |
34 { | |
35 ASSERT(frame->document()); | |
36 RenderStyle* style = (RenderStyle*)(frame->document()->renderView()); | |
eseidel
2014/04/25 23:53:24
Huh!? That's not a style.
| |
37 if (!style) | |
38 return 1.0; | |
39 return style->effectiveZoom(); | |
40 } | |
41 | |
33 int MediaValues::calculateViewportWidth(LocalFrame* frame) const | 42 int MediaValues::calculateViewportWidth(LocalFrame* frame) const |
34 { | 43 { |
35 ASSERT(frame && frame->view() && frame->document()); | 44 ASSERT(frame && frame->view()); |
36 int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width(); | 45 int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width(); |
37 return adjustForAbsoluteZoom(viewportWidth, frame->document()->renderView()) ; | 46 return adjustForAbsoluteZoom(viewportWidth, getEffectiveZoom(frame)); |
38 } | 47 } |
39 | 48 |
40 int MediaValues::calculateViewportHeight(LocalFrame* frame) const | 49 int MediaValues::calculateViewportHeight(LocalFrame* frame) const |
41 { | 50 { |
42 ASSERT(frame && frame->view() && frame->document()); | 51 ASSERT(frame && frame->view()); |
43 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); | 52 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); |
44 return adjustForAbsoluteZoom(viewportHeight, frame->document()->renderView() ); | 53 return adjustForAbsoluteZoom(viewportHeight, getEffectiveZoom(frame)); |
45 } | 54 } |
46 | 55 |
47 int MediaValues::calculateDeviceWidth(LocalFrame* frame) const | 56 int MediaValues::calculateDeviceWidth(LocalFrame* frame) const |
48 { | 57 { |
49 ASSERT(frame && frame->view() && frame->settings() && frame->host()); | 58 ASSERT(frame && frame->view() && frame->settings() && frame->host()); |
50 int deviceWidth = static_cast<int>(screenRect(frame->view()).width()); | 59 int deviceWidth = static_cast<int>(screenRect(frame->view()).width()); |
51 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) | 60 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) |
52 deviceWidth = lroundf(deviceWidth * frame->host()->deviceScaleFactor()); | 61 deviceWidth = lroundf(deviceWidth * frame->host()->deviceScaleFactor()); |
53 return deviceWidth; | 62 return deviceWidth; |
54 } | 63 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 default: | 204 default: |
196 return false; | 205 return false; |
197 } | 206 } |
198 | 207 |
199 ASSERT(factor > 0); | 208 ASSERT(factor > 0); |
200 result = roundForImpreciseConversion<int>(value*factor); | 209 result = roundForImpreciseConversion<int>(value*factor); |
201 return true; | 210 return true; |
202 } | 211 } |
203 | 212 |
204 } // namespace | 213 } // namespace |
OLD | NEW |