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

Unified Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 1094673002: Make window.innerWidth and innerHeight cause layout if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed null check Created 5 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 | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/LocalDOMWindow.cpp
diff --git a/Source/core/frame/LocalDOMWindow.cpp b/Source/core/frame/LocalDOMWindow.cpp
index 6f4e6ec346538fefab490d39a3bed0beb2a49eda..7163f829c96cf22af7286b0b320ebe477c621b02 100644
--- a/Source/core/frame/LocalDOMWindow.cpp
+++ b/Source/core/frame/LocalDOMWindow.cpp
@@ -932,55 +932,49 @@ int LocalDOMWindow::outerWidth() const
return host->chrome().windowRect().width();
}
-int LocalDOMWindow::innerHeight() const
+static FloatSize getViewportSize(LocalFrame* frame)
{
- if (!frame())
- return 0;
-
- FrameView* view = frame()->view();
+ FrameView* view = frame->view();
if (!view)
- return 0;
+ return FloatSize();
- FrameHost* host = frame()->host();
+ FrameHost* host = frame->host();
if (!host)
- return 0;
+ return FloatSize();
+
+ // The main frame's viewport size depends on the page scale. Since the
+ // initial page scale depends on the content width and is set after a
+ // layout, perform one now so queries during page load will use the up to
+ // date viewport.
+ if (host->settings().viewportEnabled() && frame->isMainFrame())
+ frame->document()->updateLayoutIgnorePendingStylesheets();
// FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer.
- if (Frame* parent = frame()->tree().parent()) {
+ if (Frame* parent = frame->tree().parent()) {
if (parent && parent->isLocalFrame())
toLocalFrame(parent)->document()->updateLayoutIgnorePendingStylesheets();
}
- FloatSize viewportSize = frame()->isMainFrame()
+ return frame->isMainFrame()
? host->pinchViewport().visibleRect().size()
: view->visibleContentRect(IncludeScrollbars).size();
-
- return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame()->pageZoomFactor());
}
-int LocalDOMWindow::innerWidth() const
+int LocalDOMWindow::innerHeight() const
{
if (!frame())
return 0;
- FrameView* view = frame()->view();
- if (!view)
- return 0;
+ FloatSize viewportSize = getViewportSize(frame());
+ return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame()->pageZoomFactor());
+}
- FrameHost* host = frame()->host();
- if (!host)
+int LocalDOMWindow::innerWidth() const
+{
+ if (!frame())
return 0;
- // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer.
- if (Frame* parent = frame()->tree().parent()) {
- if (parent && parent->isLocalFrame())
- toLocalFrame(parent)->document()->updateLayoutIgnorePendingStylesheets();
- }
-
- FloatSize viewportSize = frame()->isMainFrame()
- ? host->pinchViewport().visibleRect().size()
- : view->visibleContentRect(IncludeScrollbars).size();
-
+ FloatSize viewportSize = getViewportSize(frame());
return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), frame()->pageZoomFactor());
}
« no previous file with comments | « no previous file | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698