Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/MediaValuesCached.cpp |
| diff --git a/third_party/WebKit/Source/core/css/MediaValuesCached.cpp b/third_party/WebKit/Source/core/css/MediaValuesCached.cpp |
| index 3fd8c563bfb65ecd2bb7281530b721d48d7d0e59..15e83aa597e6cd3c39b0b66dd54ab4422ea00b43 100644 |
| --- a/third_party/WebKit/Source/core/css/MediaValuesCached.cpp |
| +++ b/third_party/WebKit/Source/core/css/MediaValuesCached.cpp |
| @@ -11,61 +11,51 @@ |
| namespace blink { |
| -PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create() |
| -{ |
| - return adoptRefWillBeNoop(new MediaValuesCached()); |
| -} |
| - |
| -PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(MediaValuesCachedData& data) |
| +MediaValuesCached::MediaValuesCachedData::MediaValuesCachedData(Document& document) |
| + : MediaValuesCached::MediaValuesCachedData() |
| { |
| - return adoptRefWillBeNoop(new MediaValuesCached(data)); |
| + ASSERT(isMainThread()); |
| + LocalFrame* frame = MediaValues::frameFrom(document); |
| + // FIXME - Added an assert here so we can better understand when a frame is present without its view(). |
|
Yoav Weiss
2016/02/01 09:29:30
I think we can now safely conclude that this doesn
haraken
2016/02/01 11:09:16
FIXME => TODO(hiroshige)
hiroshige
2016/02/06 10:08:44
Done. I'll create another CL.
Is this because Iss
|
| + ASSERT(!frame || frame->view()); |
| + if (frame && frame->view()) { |
| + ASSERT(frame->document() && frame->document()->layoutView()); |
| + |
| + // In case that frame is missing (e.g. for images that their document does not have a frame) |
| + // We simply leave the MediaValues object with the default MediaValuesCachedData values. |
| + viewportWidth = MediaValues::calculateViewportWidth(frame); |
| + viewportHeight = MediaValues::calculateViewportHeight(frame); |
| + deviceWidth = MediaValues::calculateDeviceWidth(frame); |
| + deviceHeight = MediaValues::calculateDeviceHeight(frame); |
| + devicePixelRatio = MediaValues::calculateDevicePixelRatio(frame); |
| + colorBitsPerComponent = MediaValues::calculateColorBitsPerComponent(frame); |
| + monochromeBitsPerComponent = MediaValues::calculateMonochromeBitsPerComponent(frame); |
| + primaryPointerType = MediaValues::calculatePrimaryPointerType(frame); |
| + availablePointerTypes = MediaValues::calculateAvailablePointerTypes(frame); |
| + primaryHoverType = MediaValues::calculatePrimaryHoverType(frame); |
| + availableHoverTypes = MediaValues::calculateAvailableHoverTypes(frame); |
| + defaultFontSize = MediaValues::calculateDefaultFontSize(frame); |
| + threeDEnabled = MediaValues::calculateThreeDEnabled(frame); |
| + strictMode = MediaValues::calculateStrictMode(frame); |
| + displayMode = MediaValues::calculateDisplayMode(frame); |
| + mediaType = MediaValues::calculateMediaType(frame); |
| + } |
| } |
| -PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(Document& document) |
| +PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create() |
| { |
| - return MediaValuesCached::create(frameFrom(document)); |
| + return adoptRefWillBeNoop(new MediaValuesCached()); |
| } |
| -PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(LocalFrame* frame) |
| +PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(const MediaValuesCachedData& data) |
| { |
| - // FIXME - Added an assert here so we can better understand when a frame is present without its view(). |
| - ASSERT(!frame || frame->view()); |
| - if (!frame || !frame->view()) |
| - return adoptRefWillBeNoop(new MediaValuesCached()); |
| - ASSERT(frame->document() && frame->document()->layoutView()); |
| - return adoptRefWillBeNoop(new MediaValuesCached(frame)); |
| + return adoptRefWillBeNoop(new MediaValuesCached(data)); |
| } |
| MediaValuesCached::MediaValuesCached() |
| { |
| } |
| -MediaValuesCached::MediaValuesCached(LocalFrame* frame) |
| -{ |
| - ASSERT(isMainThread()); |
| - ASSERT(frame); |
| - // In case that frame is missing (e.g. for images that their document does not have a frame) |
| - // We simply leave the MediaValues object with the default MediaValuesCachedData values. |
| - m_data.viewportWidth = calculateViewportWidth(frame); |
| - m_data.viewportHeight = calculateViewportHeight(frame); |
| - m_data.deviceWidth = calculateDeviceWidth(frame); |
| - m_data.deviceHeight = calculateDeviceHeight(frame); |
| - m_data.devicePixelRatio = calculateDevicePixelRatio(frame); |
| - m_data.colorBitsPerComponent = calculateColorBitsPerComponent(frame); |
| - m_data.monochromeBitsPerComponent = calculateMonochromeBitsPerComponent(frame); |
| - m_data.primaryPointerType = calculatePrimaryPointerType(frame); |
| - m_data.availablePointerTypes = calculateAvailablePointerTypes(frame); |
| - m_data.primaryHoverType = calculatePrimaryHoverType(frame); |
| - m_data.availableHoverTypes = calculateAvailableHoverTypes(frame); |
| - m_data.defaultFontSize = calculateDefaultFontSize(frame); |
| - m_data.threeDEnabled = calculateThreeDEnabled(frame); |
| - m_data.strictMode = calculateStrictMode(frame); |
| - m_data.displayMode = calculateDisplayMode(frame); |
| - const String mediaType = calculateMediaType(frame); |
| - if (!mediaType.isEmpty()) |
| - m_data.mediaType = mediaType.isolatedCopy(); |
| -} |
| - |
| MediaValuesCached::MediaValuesCached(const MediaValuesCachedData& data) |
| : m_data(data) |
| { |
| @@ -86,19 +76,6 @@ bool MediaValuesCached::computeLength(double value, CSSPrimitiveValue::UnitType |
| return MediaValues::computeLength(value, type, m_data.defaultFontSize, m_data.viewportWidth, m_data.viewportHeight, result); |
| } |
| -bool MediaValuesCached::isSafeToSendToAnotherThread() const |
| -{ |
| -#if ENABLE(OILPAN) |
| - // Oilpan objects are safe to send to another thread as long as the thread |
| - // does not outlive the thread used for creation. MediaValues are |
| - // allocated on the main thread and may be passed to the parser thread, |
| - // so this should be safe. |
| - return true; |
| -#else |
| - return hasOneRef(); |
| -#endif |
| -} |
| - |
| double MediaValuesCached::viewportWidth() const |
| { |
| return m_data.viewportWidth; |