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

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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 925
926 FrameHost* host = frame()->host(); 926 FrameHost* host = frame()->host();
927 if (!host) 927 if (!host)
928 return 0; 928 return 0;
929 929
930 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) 930 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk())
931 return lroundf(host->chrome().windowRect().width() * host->deviceScaleFa ctor()); 931 return lroundf(host->chrome().windowRect().width() * host->deviceScaleFa ctor());
932 return host->chrome().windowRect().width(); 932 return host->chrome().windowRect().width();
933 } 933 }
934 934
935 static FloatSize getViewportSize(LocalFrame* frame)
936 {
937 FrameView* view = frame->view();
938 if (!view)
939 return FloatSize();
940
941 FrameHost* host = frame->host();
942 if (!host)
943 return FloatSize();
944
945 // The main frame's viewport size depends on the page scale. Since the
946 // initial page scale depends on the content width and is set after a
947 // layout, perform one now so queries during page load will use the up to
948 // date viewport.
949 if (host->settings().viewportEnabled() && frame->isMainFrame())
950 frame->document()->updateLayoutIgnorePendingStylesheets();
951
952 // FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer.
953 if (Frame* parent = frame->tree().parent()) {
954 if (parent && parent->isLocalFrame())
955 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts();
956 }
957
958 return frame->isMainFrame()
959 ? host->pinchViewport().visibleRect().size()
960 : view->visibleContentRect(IncludeScrollbars).size();
961 }
962
935 int LocalDOMWindow::innerHeight() const 963 int LocalDOMWindow::innerHeight() const
936 { 964 {
937 if (!frame()) 965 if (!frame())
938 return 0; 966 return 0;
939 967
940 FrameView* view = frame()->view(); 968 FloatSize viewportSize = getViewportSize(frame());
941 if (!view)
942 return 0;
943
944 FrameHost* host = frame()->host();
945 if (!host)
946 return 0;
947
948 // 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()) {
950 if (parent && parent->isLocalFrame())
951 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts();
952 }
953
954 FloatSize viewportSize = frame()->isMainFrame()
955 ? host->pinchViewport().visibleRect().size()
956 : view->visibleContentRect(IncludeScrollbars).size();
957
958 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame() ->pageZoomFactor()); 969 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame() ->pageZoomFactor());
959 } 970 }
960 971
961 int LocalDOMWindow::innerWidth() const 972 int LocalDOMWindow::innerWidth() const
962 { 973 {
963 if (!frame()) 974 if (!frame())
964 return 0; 975 return 0;
965 976
966 FrameView* view = frame()->view(); 977 FloatSize viewportSize = getViewportSize(frame());
967 if (!view)
968 return 0;
969
970 FrameHost* host = frame()->host();
971 if (!host)
972 return 0;
973
974 // 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()) {
976 if (parent && parent->isLocalFrame())
977 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee ts();
978 }
979
980 FloatSize viewportSize = frame()->isMainFrame()
981 ? host->pinchViewport().visibleRect().size()
982 : view->visibleContentRect(IncludeScrollbars).size();
983
984 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), frame()- >pageZoomFactor()); 978 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), frame()- >pageZoomFactor());
985 } 979 }
986 980
987 int LocalDOMWindow::screenX() const 981 int LocalDOMWindow::screenX() const
988 { 982 {
989 if (!frame()) 983 if (!frame())
990 return 0; 984 return 0;
991 985
992 FrameHost* host = frame()->host(); 986 FrameHost* host = frame()->host();
993 if (!host) 987 if (!host)
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 return m_frameObserver->frame(); 1660 return m_frameObserver->frame();
1667 } 1661 }
1668 1662
1669 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 1663 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
1670 { 1664 {
1671 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 1665 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
1672 return v8::Handle<v8::Object>(); 1666 return v8::Handle<v8::Object>();
1673 } 1667 }
1674 1668
1675 } // namespace blink 1669 } // namespace blink
OLDNEW
« 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