Chromium Code Reviews| 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/MediaValuesCached.h" | 6 #include "core/css/MediaValuesCached.h" |
| 7 | 7 |
| 8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 11 #include "core/layout/LayoutObject.h" | 11 #include "core/layout/LayoutObject.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 PassRefPtr<MediaValues> MediaValuesCached::create() | 15 PassRefPtrWillBeRawPtr<MediaValues> MediaValuesCached::create() |
| 16 { | 16 { |
| 17 return adoptRef(new MediaValuesCached()); | 17 return adoptRefWillBeNoop(new MediaValuesCached()); |
| 18 } | 18 } |
| 19 | 19 |
| 20 PassRefPtr<MediaValues> MediaValuesCached::create(MediaValuesCachedData& data) | 20 PassRefPtrWillBeRawPtr<MediaValues> MediaValuesCached::create(MediaValuesCachedD ata& data) |
| 21 { | 21 { |
| 22 return adoptRef(new MediaValuesCached(data)); | 22 return adoptRefWillBeNoop(new MediaValuesCached(data)); |
| 23 } | 23 } |
| 24 | 24 |
| 25 PassRefPtr<MediaValues> MediaValuesCached::create(Document& document) | 25 PassRefPtrWillBeRawPtr<MediaValues> MediaValuesCached::create(Document& document ) |
| 26 { | 26 { |
| 27 return MediaValuesCached::create(frameFrom(document)); | 27 return MediaValuesCached::create(frameFrom(document)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 PassRefPtr<MediaValues> MediaValuesCached::create(LocalFrame* frame) | 30 PassRefPtrWillBeRawPtr<MediaValues> MediaValuesCached::create(LocalFrame* frame) |
| 31 { | 31 { |
| 32 // FIXME - Added an assert here so we can better understand when a frame is present without its view(). | 32 // FIXME - Added an assert here so we can better understand when a frame is present without its view(). |
| 33 ASSERT(!frame || frame->view()); | 33 ASSERT(!frame || frame->view()); |
| 34 if (!frame || !frame->view()) | 34 if (!frame || !frame->view()) |
| 35 return adoptRef(new MediaValuesCached()); | 35 return adoptRefWillBeNoop(new MediaValuesCached()); |
| 36 ASSERT(frame->document() && frame->document()->layoutView()); | 36 ASSERT(frame->document() && frame->document()->layoutView()); |
| 37 return adoptRef(new MediaValuesCached(frame)); | 37 return adoptRefWillBeNoop(new MediaValuesCached(frame)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 MediaValuesCached::MediaValuesCached() | 40 MediaValuesCached::MediaValuesCached() |
| 41 { | 41 { |
| 42 } | 42 } |
| 43 | 43 |
| 44 MediaValuesCached::MediaValuesCached(LocalFrame* frame) | 44 MediaValuesCached::MediaValuesCached(LocalFrame* frame) |
| 45 { | 45 { |
| 46 ASSERT(isMainThread()); | 46 ASSERT(isMainThread()); |
| 47 ASSERT(frame); | 47 ASSERT(frame); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 65 const String mediaType = calculateMediaType(frame); | 65 const String mediaType = calculateMediaType(frame); |
| 66 if (!mediaType.isEmpty()) | 66 if (!mediaType.isEmpty()) |
| 67 m_data.mediaType = mediaType.isolatedCopy(); | 67 m_data.mediaType = mediaType.isolatedCopy(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 MediaValuesCached::MediaValuesCached(const MediaValuesCachedData& data) | 70 MediaValuesCached::MediaValuesCached(const MediaValuesCachedData& data) |
| 71 : m_data(data) | 71 : m_data(data) |
| 72 { | 72 { |
| 73 } | 73 } |
| 74 | 74 |
| 75 PassRefPtr<MediaValues> MediaValuesCached::copy() const | 75 PassRefPtrWillBeRawPtr<MediaValues> MediaValuesCached::copy() const |
| 76 { | 76 { |
| 77 return adoptRef(new MediaValuesCached(m_data)); | 77 return adoptRefWillBeNoop(new MediaValuesCached(m_data)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool MediaValuesCached::computeLength(double value, CSSPrimitiveValue::UnitType type, int& result) const | 80 bool MediaValuesCached::computeLength(double value, CSSPrimitiveValue::UnitType type, int& result) const |
| 81 { | 81 { |
| 82 return MediaValues::computeLength(value, type, m_data.defaultFontSize, m_dat a.viewportWidth, m_data.viewportHeight, result); | 82 return MediaValues::computeLength(value, type, m_data.defaultFontSize, m_dat a.viewportWidth, m_data.viewportHeight, result); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool MediaValuesCached::computeLength(double value, CSSPrimitiveValue::UnitType type, double& result) const | 85 bool MediaValuesCached::computeLength(double value, CSSPrimitiveValue::UnitType type, double& result) const |
| 86 { | 86 { |
| 87 return MediaValues::computeLength(value, type, m_data.defaultFontSize, m_dat a.viewportWidth, m_data.viewportHeight, result); | 87 return MediaValues::computeLength(value, type, m_data.defaultFontSize, m_dat a.viewportWidth, m_data.viewportHeight, result); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool MediaValuesCached::isSafeToSendToAnotherThread() const | 90 bool MediaValuesCached::isSafeToSendToAnotherThread() const |
| 91 { | 91 { |
| 92 #if ENABLE(OILPAN) | |
| 93 return true; | |
|
haraken
2015/08/06 08:54:34
Worth having a comment on why it is always safe to
keishi
2015/08/10 06:50:46
Done. Could you take a look and see if this is cor
| |
| 94 #else | |
| 92 return hasOneRef(); | 95 return hasOneRef(); |
| 96 #endif | |
| 93 } | 97 } |
| 94 | 98 |
| 95 int MediaValuesCached::viewportWidth() const | 99 int MediaValuesCached::viewportWidth() const |
| 96 { | 100 { |
| 97 return m_data.viewportWidth; | 101 return m_data.viewportWidth; |
| 98 } | 102 } |
| 99 | 103 |
| 100 int MediaValuesCached::viewportHeight() const | 104 int MediaValuesCached::viewportHeight() const |
| 101 { | 105 { |
| 102 return m_data.viewportHeight; | 106 return m_data.viewportHeight; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 { | 185 { |
| 182 m_data.viewportWidth = width; | 186 m_data.viewportWidth = width; |
| 183 } | 187 } |
| 184 | 188 |
| 185 void MediaValuesCached::setViewportHeight(int height) | 189 void MediaValuesCached::setViewportHeight(int height) |
| 186 { | 190 { |
| 187 m_data.viewportHeight = height; | 191 m_data.viewportHeight = height; |
| 188 } | 192 } |
| 189 | 193 |
| 190 } // namespace | 194 } // namespace |
| OLD | NEW |