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

Unified Diff: Source/core/css/MediaValues.cpp

Issue 252683007: Protect MediaValuesCached creation when RenderView is missing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/MediaValues.cpp
diff --git a/Source/core/css/MediaValues.cpp b/Source/core/css/MediaValues.cpp
index 57b7d9997a55edf6fe6e28573e867e3eafbcbfc6..4e6d1d8810cfd5f63d32fdb55bbef9d2ff4e8ae3 100644
--- a/Source/core/css/MediaValues.cpp
+++ b/Source/core/css/MediaValues.cpp
@@ -30,18 +30,30 @@ PassRefPtr<MediaValues> MediaValues::createDynamicIfFrameExists(LocalFrame* fram
return MediaValuesCached::create();
}
+static float getEffectiveZoom(LocalFrame* frame)
+{
+ ASSERT(frame->document());
+ RenderView* view = (frame->document()->renderView());
eseidel 2014/04/26 05:04:05 The parens aren't needed.
+ if (!view)
+ return 1.0;
+ RenderStyle* style = view->style();
+ if (!style)
+ return 1.0;
+ return style->effectiveZoom();
+}
+
int MediaValues::calculateViewportWidth(LocalFrame* frame) const
{
- ASSERT(frame && frame->view() && frame->document());
+ ASSERT(frame && frame->view());
int viewportWidth = frame->view()->layoutSize(IncludeScrollbars).width();
- return adjustForAbsoluteZoom(viewportWidth, frame->document()->renderView());
+ return adjustForAbsoluteZoom(viewportWidth, getEffectiveZoom(frame));
}
int MediaValues::calculateViewportHeight(LocalFrame* frame) const
{
- ASSERT(frame && frame->view() && frame->document());
+ ASSERT(frame && frame->view());
int viewportHeight = frame->view()->layoutSize(IncludeScrollbars).height();
- return adjustForAbsoluteZoom(viewportHeight, frame->document()->renderView());
+ return adjustForAbsoluteZoom(viewportHeight, getEffectiveZoom(frame));
}
int MediaValues::calculateDeviceWidth(LocalFrame* frame) const
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698