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

Unified Diff: third_party/WebKit/Source/core/css/MediaValuesCached.cpp

Issue 1679703002: Revert of Create MediaValuesCached and TokenPreloadScanner on the parser thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_MediaValuesCached
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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 75c3a53d281d2517bad8d42ef3c8006086aa9c88..3fd8c563bfb65ecd2bb7281530b721d48d7d0e59 100644
--- a/third_party/WebKit/Source/core/css/MediaValuesCached.cpp
+++ b/third_party/WebKit/Source/core/css/MediaValuesCached.cpp
@@ -11,49 +11,59 @@
namespace blink {
-MediaValuesCached::MediaValuesCachedData::MediaValuesCachedData(Document& document)
- : MediaValuesCached::MediaValuesCachedData()
-{
- ASSERT(isMainThread());
- LocalFrame* frame = MediaValues::frameFrom(document);
- // TODO(hiroshige): Clean up |frame->view()| conditions.
- 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()
{
return adoptRefWillBeNoop(new MediaValuesCached());
}
-PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(const MediaValuesCachedData& data)
+PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(MediaValuesCachedData& data)
{
return adoptRefWillBeNoop(new MediaValuesCached(data));
}
+PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(Document& document)
+{
+ return MediaValuesCached::create(frameFrom(document));
+}
+
+PassRefPtrWillBeRawPtr<MediaValuesCached> MediaValuesCached::create(LocalFrame* frame)
+{
+ // 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));
+}
+
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)
@@ -74,6 +84,19 @@
bool MediaValuesCached::computeLength(double value, CSSPrimitiveValue::UnitType type, double& result) const
{
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

Powered by Google App Engine
This is Rietveld 408576698