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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 return 0; 938 return 0;
939 939
940 FrameView* view = frame()->view(); 940 FrameView* view = frame()->view();
941 if (!view) 941 if (!view)
942 return 0; 942 return 0;
943 943
944 FrameHost* host = frame()->host(); 944 FrameHost* host = frame()->host();
945 if (!host) 945 if (!host)
946 return 0; 946 return 0;
947 947
948 // The main frame's innerHeight depends on the page scale. Since the initial
949 // page scale depends on the content width and is set after a layout,
950 // perform one now so queries before the first layout reflect the true size
951 // of the window.
rune 2015/04/16 22:02:12 The initial scale can be adjusted multiple times a
bokan 2015/04/20 17:47:24 Done.
952 if (host->settings().viewportEnabled() && frame()->isMainFrame())
953 frame()->document()->updateLayoutIgnorePendingStylesheets();
954
948 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. 955 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer.
949 if (Frame* parent = frame()->tree().parent()) { 956 if (Frame* parent = frame()->tree().parent()) {
950 if (parent && parent->isLocalFrame()) 957 if (parent && parent->isLocalFrame())
951 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts(); 958 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts();
952 } 959 }
953 960
954 FloatSize viewportSize = frame()->isMainFrame() 961 FloatSize viewportSize = frame()->isMainFrame()
955 ? host->pinchViewport().visibleRect().size() 962 ? host->pinchViewport().visibleRect().size()
956 : view->visibleContentRect(IncludeScrollbars).size(); 963 : view->visibleContentRect(IncludeScrollbars).size();
957 964
958 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame() ->pageZoomFactor()); 965 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame() ->pageZoomFactor());
959 } 966 }
960 967
961 int LocalDOMWindow::innerWidth() const 968 int LocalDOMWindow::innerWidth() const
962 { 969 {
963 if (!frame()) 970 if (!frame())
964 return 0; 971 return 0;
965 972
966 FrameView* view = frame()->view(); 973 FrameView* view = frame()->view();
967 if (!view) 974 if (!view)
968 return 0; 975 return 0;
969 976
970 FrameHost* host = frame()->host(); 977 FrameHost* host = frame()->host();
971 if (!host) 978 if (!host)
972 return 0; 979 return 0;
973 980
981 // The main frame's innerHeight depends on the page scale. Since the initial
982 // page scale depends on the content width and is set after a layout,
983 // perform one now so queries before the first layout reflect the true size
984 // of the window.
985 if (host->settings().viewportEnabled() && frame()->isMainFrame())
986 frame()->document()->updateLayoutIgnorePendingStylesheets();
987
rune 2015/04/16 22:02:12 Most code and comments in innerWidth and innerHeig
bokan 2015/04/20 17:47:24 Done.
974 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. 988 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer.
975 if (Frame* parent = frame()->tree().parent()) { 989 if (Frame* parent = frame()->tree().parent()) {
976 if (parent && parent->isLocalFrame()) 990 if (parent && parent->isLocalFrame())
977 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts(); 991 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts();
978 } 992 }
979 993
980 FloatSize viewportSize = frame()->isMainFrame() 994 FloatSize viewportSize = frame()->isMainFrame()
981 ? host->pinchViewport().visibleRect().size() 995 ? host->pinchViewport().visibleRect().size()
982 : view->visibleContentRect(IncludeScrollbars).size(); 996 : view->visibleContentRect(IncludeScrollbars).size();
983 997
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 return m_frameObserver->frame(); 1680 return m_frameObserver->frame();
1667 } 1681 }
1668 1682
1669 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 1683 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
1670 { 1684 {
1671 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 1685 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
1672 return v8::Handle<v8::Object>(); 1686 return v8::Handle<v8::Object>();
1673 } 1687 }
1674 1688
1675 } // namespace blink 1689 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/PinchViewportTest.cpp » ('j') | Source/web/tests/PinchViewportTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698