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

Side by Side Diff: Source/core/css/MediaValuesDynamic.cpp

Issue 242883002: Remove MediaValues' dependency on RenderStyle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Modified minimal recalc tests to represent reduced recalc. Created 6 years, 8 months 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/MediaValuesDynamic.h" 6 #include "core/css/MediaValuesDynamic.h"
7 7
8 #include "core/css/CSSHelper.h" 8 #include "core/css/CSSHelper.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/CSSToLengthConversionData.h" 10 #include "core/css/CSSToLengthConversionData.h"
11 #include "core/dom/Document.h" 11 #include "core/dom/Document.h"
12 #include "core/rendering/RenderObject.h"
13 #include "core/rendering/style/RenderStyle.h"
14 #include "core/rendering/style/StyleInheritedData.h"
15 12
16 namespace WebCore { 13 namespace WebCore {
17 14
18 PassRefPtr<MediaValues> MediaValuesDynamic::create(PassRefPtr<LocalFrame> frame, PassRefPtr<RenderStyle> style) 15 PassRefPtr<MediaValues> MediaValuesDynamic::create(PassRefPtr<LocalFrame> frame)
19 { 16 {
20 return adoptRef(new MediaValuesDynamic(frame, style)); 17 return adoptRef(new MediaValuesDynamic(frame));
21 } 18 }
22 19
23 PassRefPtr<MediaValues> MediaValuesDynamic::create(Document& document) 20 MediaValuesDynamic::MediaValuesDynamic(PassRefPtr<LocalFrame> frame)
21 : m_frame(frame)
24 { 22 {
25 Document* executingDocument = getExecutingDocument(document); 23 ASSERT(m_frame.get());
26 return MediaValuesDynamic::create(executingDocument->frame(), executingDocum ent->renderer()->style());
27 }
28
29 MediaValuesDynamic::MediaValuesDynamic(PassRefPtr<LocalFrame> frame, PassRefPtr< RenderStyle> style)
30 : m_style(style)
31 , m_frame(frame)
32 {
33 } 24 }
34 25
35 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const 26 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const
36 { 27 {
37 return adoptRef(new MediaValuesDynamic(m_frame, m_style)); 28 return adoptRef(new MediaValuesDynamic(m_frame));
38 } 29 }
39 30
40 bool MediaValuesDynamic::computeLength(double value, unsigned short type, int& r esult) const 31 bool MediaValuesDynamic::computeLength(double value, unsigned short type, int& r esult) const
41 { 32 {
42 ASSERT(m_style.get()); 33 LocalFrame* frame = m_frame.get();
43 RefPtr<CSSPrimitiveValue> primitiveValue = CSSPrimitiveValue::create(value, (CSSPrimitiveValue::UnitTypes)type); 34 return MediaValues::computeLength(value,
44 result = primitiveValue->computeLength<int>(CSSToLengthConversionData(m_styl e.get(), m_style.get(), 0, 1.0 /* zoom */, true /* computingFontSize */)); 35 type,
45 return true; 36 calculateDefaultFontSize(frame),
37 calculateViewportWidth(frame),
38 calculateViewportHeight(frame),
39 result);
46 } 40 }
47 41
48 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const 42 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const
49 { 43 {
50 return false; 44 return false;
51 } 45 }
52 46
53 int MediaValuesDynamic::viewportWidth() const 47 int MediaValuesDynamic::viewportWidth() const
54 { 48 {
55 ASSERT(m_style.get());
56 ASSERT(m_frame.get());
57 return calculateViewportWidth(m_frame.get()); 49 return calculateViewportWidth(m_frame.get());
58 } 50 }
59 51
60 int MediaValuesDynamic::viewportHeight() const 52 int MediaValuesDynamic::viewportHeight() const
61 { 53 {
62 ASSERT(m_style.get());
63 ASSERT(m_frame.get());
64 return calculateViewportHeight(m_frame.get()); 54 return calculateViewportHeight(m_frame.get());
65 } 55 }
66 56
67 int MediaValuesDynamic::deviceWidth() const 57 int MediaValuesDynamic::deviceWidth() const
68 { 58 {
69 ASSERT(m_frame.get());
70 return calculateDeviceWidth(m_frame.get()); 59 return calculateDeviceWidth(m_frame.get());
71 } 60 }
72 61
73 int MediaValuesDynamic::deviceHeight() const 62 int MediaValuesDynamic::deviceHeight() const
74 { 63 {
75 ASSERT(m_frame.get());
76 return calculateDeviceHeight(m_frame.get()); 64 return calculateDeviceHeight(m_frame.get());
77 } 65 }
78 66
79 float MediaValuesDynamic::devicePixelRatio() const 67 float MediaValuesDynamic::devicePixelRatio() const
80 { 68 {
81 ASSERT(m_frame.get());
82 return calculateDevicePixelRatio(m_frame.get()); 69 return calculateDevicePixelRatio(m_frame.get());
83 } 70 }
84 71
85 int MediaValuesDynamic::colorBitsPerComponent() const 72 int MediaValuesDynamic::colorBitsPerComponent() const
86 { 73 {
87 ASSERT(m_frame.get());
88 return calculateColorBitsPerComponent(m_frame.get()); 74 return calculateColorBitsPerComponent(m_frame.get());
89 } 75 }
90 76
91 int MediaValuesDynamic::monochromeBitsPerComponent() const 77 int MediaValuesDynamic::monochromeBitsPerComponent() const
92 { 78 {
93 ASSERT(m_frame.get());
94 return calculateMonochromeBitsPerComponent(m_frame.get()); 79 return calculateMonochromeBitsPerComponent(m_frame.get());
95 } 80 }
96 81
97 MediaValues::PointerDeviceType MediaValuesDynamic::pointer() const 82 MediaValues::PointerDeviceType MediaValuesDynamic::pointer() const
98 { 83 {
99 ASSERT(m_frame.get());
100 return calculateLeastCapablePrimaryPointerDeviceType(m_frame.get()); 84 return calculateLeastCapablePrimaryPointerDeviceType(m_frame.get());
101 } 85 }
102 86
103 bool MediaValuesDynamic::threeDEnabled() const 87 bool MediaValuesDynamic::threeDEnabled() const
104 { 88 {
105 ASSERT(m_frame.get());
106 return calculateThreeDEnabled(m_frame.get()); 89 return calculateThreeDEnabled(m_frame.get());
107 } 90 }
108 91
109 bool MediaValuesDynamic::scanMediaType() const 92 bool MediaValuesDynamic::scanMediaType() const
110 { 93 {
111 ASSERT(m_frame.get());
112 return calculateScanMediaType(m_frame.get()); 94 return calculateScanMediaType(m_frame.get());
113 } 95 }
114 96
115 bool MediaValuesDynamic::screenMediaType() const 97 bool MediaValuesDynamic::screenMediaType() const
116 { 98 {
117 ASSERT(m_frame.get());
118 return calculateScreenMediaType(m_frame.get()); 99 return calculateScreenMediaType(m_frame.get());
119 } 100 }
120 101
121 bool MediaValuesDynamic::printMediaType() const 102 bool MediaValuesDynamic::printMediaType() const
122 { 103 {
123 ASSERT(m_frame.get());
124 return calculatePrintMediaType(m_frame.get()); 104 return calculatePrintMediaType(m_frame.get());
125 } 105 }
126 106
127 bool MediaValuesDynamic::strictMode() const 107 bool MediaValuesDynamic::strictMode() const
128 { 108 {
129 ASSERT(m_frame.get());
130 return calculateStrictMode(m_frame.get()); 109 return calculateStrictMode(m_frame.get());
131 } 110 }
132 111
133 Document* MediaValuesDynamic::document() const 112 Document* MediaValuesDynamic::document() const
134 { 113 {
135 ASSERT(m_frame.get());
136 return m_frame->document(); 114 return m_frame->document();
137 } 115 }
138 116
139 bool MediaValuesDynamic::hasValues() const 117 bool MediaValuesDynamic::hasValues() const
140 { 118 {
141 return(m_style.get() && m_frame.get()); 119 return(m_frame.get());
142 } 120 }
143 121
144 } // namespace 122 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698