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

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

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 #ifndef MediaValues_h 5 #ifndef MediaValues_h
6 #define MediaValues_h 6 #define MediaValues_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "public/platform/PointerProperties.h" 10 #include "public/platform/PointerProperties.h"
(...skipping 10 matching lines...) Expand all
21 class CORE_EXPORT MediaValues : public RefCountedWillBeGarbageCollectedFinalized <MediaValues> { 21 class CORE_EXPORT MediaValues : public RefCountedWillBeGarbageCollectedFinalized <MediaValues> {
22 public: 22 public:
23 23
24 virtual ~MediaValues() { } 24 virtual ~MediaValues() { }
25 DEFINE_INLINE_VIRTUAL_TRACE() { } 25 DEFINE_INLINE_VIRTUAL_TRACE() { }
26 26
27 static PassRefPtrWillBeRawPtr<MediaValues> createDynamicIfFrameExists(LocalF rame*); 27 static PassRefPtrWillBeRawPtr<MediaValues> createDynamicIfFrameExists(LocalF rame*);
28 virtual PassRefPtrWillBeRawPtr<MediaValues> copy() const = 0; 28 virtual PassRefPtrWillBeRawPtr<MediaValues> copy() const = 0;
29 virtual bool isSafeToSendToAnotherThread() const = 0; 29 virtual bool isSafeToSendToAnotherThread() const = 0;
30 30
31 static bool computeLengthImpl(double value, CSSPrimitiveValue::UnitType, uns igned defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, double& result); 31 static bool computeLengthImpl(double value, CSSPrimitiveValue::UnitType, uns igned defaultFontSize, double viewportWidth, double viewportHeight, double& resu lt);
32 template<typename T> 32 template<typename T>
33 static bool computeLength(double value, CSSPrimitiveValue::UnitType type, un signed defaultFontSize, unsigned viewportWidth, unsigned viewportHeight, T& resu lt) 33 static bool computeLength(double value, CSSPrimitiveValue::UnitType type, un signed defaultFontSize, double viewportWidth, double viewportHeight, T& result)
34 { 34 {
35 double tempResult; 35 double tempResult;
36 if (!computeLengthImpl(value, type, defaultFontSize, viewportWidth, view portHeight, tempResult)) 36 if (!computeLengthImpl(value, type, defaultFontSize, viewportWidth, view portHeight, tempResult))
37 return false; 37 return false;
38 result = clampTo<T>(tempResult); 38 result = clampTo<T>(tempResult);
39 return true; 39 return true;
40 } 40 }
41 virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, int& r esult) const = 0; 41 virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, int& r esult) const = 0;
42 virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, double & result) const = 0; 42 virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, double & result) const = 0;
43 43
44 virtual int viewportWidth() const = 0; 44 virtual double viewportWidth() const = 0;
45 virtual int viewportHeight() const = 0; 45 virtual double viewportHeight() const = 0;
46 virtual int deviceWidth() const = 0; 46 virtual int deviceWidth() const = 0;
47 virtual int deviceHeight() const = 0; 47 virtual int deviceHeight() const = 0;
48 virtual float devicePixelRatio() const = 0; 48 virtual float devicePixelRatio() const = 0;
49 virtual int colorBitsPerComponent() const = 0; 49 virtual int colorBitsPerComponent() const = 0;
50 virtual int monochromeBitsPerComponent() const = 0; 50 virtual int monochromeBitsPerComponent() const = 0;
51 virtual PointerType primaryPointerType() const = 0; 51 virtual PointerType primaryPointerType() const = 0;
52 virtual int availablePointerTypes() const = 0; 52 virtual int availablePointerTypes() const = 0;
53 virtual HoverType primaryHoverType() const = 0; 53 virtual HoverType primaryHoverType() const = 0;
54 virtual int availableHoverTypes() const = 0; 54 virtual int availableHoverTypes() const = 0;
55 virtual bool threeDEnabled() const = 0; 55 virtual bool threeDEnabled() const = 0;
56 virtual const String mediaType() const = 0; 56 virtual const String mediaType() const = 0;
57 virtual WebDisplayMode displayMode() const = 0; 57 virtual WebDisplayMode displayMode() const = 0;
58 virtual bool strictMode() const = 0; 58 virtual bool strictMode() const = 0;
59 virtual Document* document() const = 0; 59 virtual Document* document() const = 0;
60 virtual bool hasValues() const = 0; 60 virtual bool hasValues() const = 0;
61 61
62 virtual bool isCached() const { return false; } 62 virtual bool isCached() const { return false; }
63 63
64 protected: 64 protected:
65 int calculateViewportWidth(LocalFrame*) const; 65 double calculateViewportWidth(LocalFrame*) const;
66 int calculateViewportHeight(LocalFrame*) const; 66 double calculateViewportHeight(LocalFrame*) const;
67 int calculateDeviceWidth(LocalFrame*) const; 67 int calculateDeviceWidth(LocalFrame*) const;
68 int calculateDeviceHeight(LocalFrame*) const; 68 int calculateDeviceHeight(LocalFrame*) const;
69 bool calculateStrictMode(LocalFrame*) const; 69 bool calculateStrictMode(LocalFrame*) const;
70 float calculateDevicePixelRatio(LocalFrame*) const; 70 float calculateDevicePixelRatio(LocalFrame*) const;
71 int calculateColorBitsPerComponent(LocalFrame*) const; 71 int calculateColorBitsPerComponent(LocalFrame*) const;
72 int calculateMonochromeBitsPerComponent(LocalFrame*) const; 72 int calculateMonochromeBitsPerComponent(LocalFrame*) const;
73 int calculateDefaultFontSize(LocalFrame*) const; 73 int calculateDefaultFontSize(LocalFrame*) const;
74 const String calculateMediaType(LocalFrame*) const; 74 const String calculateMediaType(LocalFrame*) const;
75 WebDisplayMode calculateDisplayMode(LocalFrame*) const; 75 WebDisplayMode calculateDisplayMode(LocalFrame*) const;
76 bool calculateThreeDEnabled(LocalFrame*) const; 76 bool calculateThreeDEnabled(LocalFrame*) const;
77 PointerType calculatePrimaryPointerType(LocalFrame*) const; 77 PointerType calculatePrimaryPointerType(LocalFrame*) const;
78 int calculateAvailablePointerTypes(LocalFrame*) const; 78 int calculateAvailablePointerTypes(LocalFrame*) const;
79 HoverType calculatePrimaryHoverType(LocalFrame*) const; 79 HoverType calculatePrimaryHoverType(LocalFrame*) const;
80 int calculateAvailableHoverTypes(LocalFrame*) const; 80 int calculateAvailableHoverTypes(LocalFrame*) const;
81 static LocalFrame* frameFrom(Document&); 81 static LocalFrame* frameFrom(Document&);
82 82
83 }; 83 };
84 84
85 } // namespace 85 } // namespace
86 86
87 #endif // MediaValues_h 87 #endif // MediaValues_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp ('k') | third_party/WebKit/Source/core/css/MediaValues.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698