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

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: Use MediaValuesCached in HTMLImageElement 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));
eseidel 2014/04/18 16:50:13 Why do we ever create a MediaValuesDynamic when th
21 } 18 }
22 19
23 PassRefPtr<MediaValues> MediaValuesDynamic::create(Document& document) 20 PassRefPtr<MediaValues> MediaValuesDynamic::create(Document& document)
24 { 21 {
25 Document* executingDocument = getExecutingDocument(document); 22 Document* executingDocument = getExecutingDocument(document);
26 return MediaValuesDynamic::create(executingDocument->frame(), executingDocum ent->renderer()->style()); 23 ASSERT(executingDocument->frame());
24 return MediaValuesDynamic::create(executingDocument->frame());
27 } 25 }
28 26
29 MediaValuesDynamic::MediaValuesDynamic(PassRefPtr<LocalFrame> frame, PassRefPtr< RenderStyle> style) 27 MediaValuesDynamic::MediaValuesDynamic(PassRefPtr<LocalFrame> frame)
30 : m_style(style) 28 : m_frame(frame)
31 , m_frame(frame)
32 { 29 {
33 } 30 }
34 31
35 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const 32 PassRefPtr<MediaValues> MediaValuesDynamic::copy() const
36 { 33 {
37 return adoptRef(new MediaValuesDynamic(m_frame, m_style)); 34 return adoptRef(new MediaValuesDynamic(m_frame));
38 } 35 }
39 36
40 bool MediaValuesDynamic::computeLength(double value, unsigned short type, int& r esult) const 37 bool MediaValuesDynamic::computeLength(double value, unsigned short type, int& r esult) const
41 { 38 {
42 ASSERT(m_style.get()); 39 LocalFrame* frame = m_frame.get();
43 RefPtr<CSSPrimitiveValue> primitiveValue = CSSPrimitiveValue::create(value, (CSSPrimitiveValue::UnitTypes)type); 40 return MediaValues::computeLength(value,
44 result = primitiveValue->computeLength<int>(CSSToLengthConversionData(m_styl e.get(), m_style.get(), 0, 1.0 /* zoom */, true /* computingFontSize */)); 41 type,
45 return true; 42 calculateDefaultFontSize(frame),
43 calculateViewportWidth(frame),
44 calculateViewportHeight(frame),
45 result);
46 } 46 }
47 47
48 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const 48 bool MediaValuesDynamic::isSafeToSendToAnotherThread() const
49 { 49 {
50 return false; 50 return false;
51 } 51 }
52 52
53 int MediaValuesDynamic::viewportWidth() const 53 int MediaValuesDynamic::viewportWidth() const
54 { 54 {
55 ASSERT(m_style.get());
56 ASSERT(m_frame.get()); 55 ASSERT(m_frame.get());
57 return calculateViewportWidth(m_frame.get()); 56 return calculateViewportWidth(m_frame.get());
58 } 57 }
59 58
60 int MediaValuesDynamic::viewportHeight() const 59 int MediaValuesDynamic::viewportHeight() const
61 { 60 {
62 ASSERT(m_style.get());
63 ASSERT(m_frame.get()); 61 ASSERT(m_frame.get());
64 return calculateViewportHeight(m_frame.get()); 62 return calculateViewportHeight(m_frame.get());
65 } 63 }
66 64
67 int MediaValuesDynamic::deviceWidth() const 65 int MediaValuesDynamic::deviceWidth() const
68 { 66 {
69 ASSERT(m_frame.get()); 67 ASSERT(m_frame.get());
70 return calculateDeviceWidth(m_frame.get()); 68 return calculateDeviceWidth(m_frame.get());
71 } 69 }
72 70
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 129 }
132 130
133 Document* MediaValuesDynamic::document() const 131 Document* MediaValuesDynamic::document() const
134 { 132 {
135 ASSERT(m_frame.get()); 133 ASSERT(m_frame.get());
136 return m_frame->document(); 134 return m_frame->document();
137 } 135 }
138 136
139 bool MediaValuesDynamic::hasValues() const 137 bool MediaValuesDynamic::hasValues() const
140 { 138 {
141 return(m_style.get() && m_frame.get()); 139 return(m_frame.get());
142 } 140 }
143 141
144 } // namespace 142 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698