Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: third_party/WebKit/Source/core/css/MediaValues.cpp

Issue 1496683002: Avoid rounding down viewport dimensions in Media Queries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to double Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 25
26 namespace blink { 26 namespace blink {
27 27
28 PassRefPtrWillBeRawPtr<MediaValues> MediaValues::createDynamicIfFrameExists(Loca lFrame* frame) 28 PassRefPtrWillBeRawPtr<MediaValues> MediaValues::createDynamicIfFrameExists(Loca lFrame* frame)
29 { 29 {
30 if (frame) 30 if (frame)
31 return MediaValuesDynamic::create(frame); 31 return MediaValuesDynamic::create(frame);
32 return MediaValuesCached::create(); 32 return MediaValuesCached::create();
33 } 33 }
34 34
35 int MediaValues::calculateViewportWidth(LocalFrame* frame) const 35 double MediaValues::calculateViewportWidth(LocalFrame* frame) const
36 { 36 {
37 ASSERT(frame && frame->view() && frame->document()); 37 ASSERT(frame && frame->view() && frame->document());
38 int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width(); 38 int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width();
39 return adjustForAbsoluteZoom(viewportWidth, frame->document()->layoutView()) ; 39 return adjustDoubleForAbsoluteZoom(viewportWidth, *frame->document()->layout View());
40 } 40 }
41 41
42 int MediaValues::calculateViewportHeight(LocalFrame* frame) const 42 double MediaValues::calculateViewportHeight(LocalFrame* frame) const
43 { 43 {
44 ASSERT(frame && frame->view() && frame->document()); 44 ASSERT(frame && frame->view() && frame->document());
45 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height(); 45 int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height();
46 return adjustForAbsoluteZoom(viewportHeight, frame->document()->layoutView() ); 46 return adjustDoubleForAbsoluteZoom(viewportHeight, *frame->document()->layou tView());
47 } 47 }
48 48
49 int MediaValues::calculateDeviceWidth(LocalFrame* frame) const 49 int MediaValues::calculateDeviceWidth(LocalFrame* frame) const
50 { 50 {
51 ASSERT(frame && frame->view() && frame->settings() && frame->host()); 51 ASSERT(frame && frame->view() && frame->settings() && frame->host());
52 int deviceWidth = frame->host()->chromeClient().screenInfo().rect.width; 52 int deviceWidth = frame->host()->chromeClient().screenInfo().rect.width;
53 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk()) 53 if (frame->settings()->reportScreenSizeInPhysicalPixelsQuirk())
54 deviceWidth = lroundf(deviceWidth * frame->host()->deviceScaleFactor()); 54 deviceWidth = lroundf(deviceWidth * frame->host()->deviceScaleFactor());
55 return deviceWidth; 55 return deviceWidth;
56 } 56 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ASSERT(frame && frame->settings()); 146 ASSERT(frame && frame->settings());
147 return frame->settings()->primaryHoverType(); 147 return frame->settings()->primaryHoverType();
148 } 148 }
149 149
150 int MediaValues::calculateAvailableHoverTypes(LocalFrame* frame) const 150 int MediaValues::calculateAvailableHoverTypes(LocalFrame* frame) const
151 { 151 {
152 ASSERT(frame && frame->settings()); 152 ASSERT(frame && frame->settings());
153 return frame->settings()->availableHoverTypes(); 153 return frame->settings()->availableHoverTypes();
154 } 154 }
155 155
156 bool MediaValues::computeLengthImpl(double value, CSSPrimitiveValue::UnitType ty pe, unsigned defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, d ouble& result) 156 bool MediaValues::computeLengthImpl(double value, CSSPrimitiveValue::UnitType ty pe, unsigned defaultFontSize, double viewportWidth, double viewportHeight, doubl e& result)
157 { 157 {
158 // The logic in this function is duplicated from CSSToLengthConversionData:: zoomedComputedPixels() 158 // The logic in this function is duplicated from CSSToLengthConversionData:: zoomedComputedPixels()
159 // because MediaValues::computeLength() needs nearly identical logic, but we haven't found a way to make 159 // because MediaValues::computeLength() needs nearly identical logic, but we haven't found a way to make
160 // CSSToLengthConversionData::zoomedComputedPixels() more generic (to solve both cases) without hurting performance. 160 // CSSToLengthConversionData::zoomedComputedPixels() more generic (to solve both cases) without hurting performance.
161 161
162 // FIXME - Unite the logic here with CSSToLengthConversionData in a performa nt way. 162 // FIXME - Unite the logic here with CSSToLengthConversionData in a performa nt way.
163 double factor = 0; 163 double factor = 0;
164 switch (type) { 164 switch (type) {
165 case CSSPrimitiveValue::UnitType::Ems: 165 case CSSPrimitiveValue::UnitType::Ems:
166 case CSSPrimitiveValue::UnitType::Rems: 166 case CSSPrimitiveValue::UnitType::Rems:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 219
220 LocalFrame* MediaValues::frameFrom(Document& document) 220 LocalFrame* MediaValues::frameFrom(Document& document)
221 { 221 {
222 Document* executingDocument = document.importsController() ? document.import sController()->master() : &document; 222 Document* executingDocument = document.importsController() ? document.import sController()->master() : &document;
223 ASSERT(executingDocument); 223 ASSERT(executingDocument);
224 return executingDocument->frame(); 224 return executingDocument->frame();
225 } 225 }
226 226
227 } // namespace 227 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaValues.h ('k') | third_party/WebKit/Source/core/css/MediaValuesCached.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698