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 RenderView* view = (frame->document()->renderView()); | |
eseidel
2014/04/26 05:04:05
The parens aren't needed.
| |
37 if (!view) | |
38 return 1.0; | |
39 RenderStyle* style = view->style(); | |
40 if (!style) | |
41 return 1.0; | |
42 return style->effectiveZoom(); | |
43 } | |
44 | |
33 int MediaValues::calculateViewportWidth(LocalFrame* frame) const | 45 int MediaValues::calculateViewportWidth(LocalFrame* frame) const |
34 { | 46 { |
35 ASSERT(frame && frame->view() && frame->document()); | 47 ASSERT(frame && frame->view()); |
36 int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width(); | 48 int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width(); |
37 return adjustForAbsoluteZoom(viewportWidth, frame->document()->renderView()) ; | 49 return adjustForAbsoluteZoom(viewportWidth, getEffectiveZoom(frame)); |
38 } | 50 } |
39 | 51 |
40 int MediaValues::calculateViewportHeight(LocalFrame* frame) const | 52 int MediaValues::calculateViewportHeight(LocalFrame* frame) const |
41 { | 53 { |
42 ASSERT(frame && frame->view() && frame->document()); | 54 ASSERT(frame && frame->view()); |
43 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); | 55 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); |
44 return adjustForAbsoluteZoom(viewportHeight, frame->document()->renderView() ); | 56 return adjustForAbsoluteZoom(viewportHeight, getEffectiveZoom(frame)); |
45 } | 57 } |
46 | 58 |
47 int MediaValues::calculateDeviceWidth(LocalFrame* frame) const | 59 int MediaValues::calculateDeviceWidth(LocalFrame* frame) const |
48 { | 60 { |
49 ASSERT(frame && frame->view() && frame->settings() && frame->host()); | 61 ASSERT(frame && frame->view() && frame->settings() && frame->host()); |
50 int deviceWidth = static_cast<int>(screenRect(frame->view()).width()); | 62 int deviceWidth = static_cast<int>(screenRect(frame->view()).width()); |
51 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) | 63 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) |
52 deviceWidth = lroundf(deviceWidth * frame->host()->deviceScaleFactor()); | 64 deviceWidth = lroundf(deviceWidth * frame->host()->deviceScaleFactor()); |
53 return deviceWidth; | 65 return deviceWidth; |
54 } | 66 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 default: | 207 default: |
196 return false; | 208 return false; |
197 } | 209 } |
198 | 210 |
199 ASSERT(factor > 0); | 211 ASSERT(factor > 0); |
200 result = roundForImpreciseConversion<int>(value*factor); | 212 result = roundForImpreciseConversion<int>(value*factor); |
201 return true; | 213 return true; |
202 } | 214 } |
203 | 215 |
204 } // namespace | 216 } // namespace |
OLD | NEW |