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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp

Issue 2709263003: Removed FrameHost::settings() (Closed)
Patch Set: Created 3 years, 9 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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 909
910 int LocalDOMWindow::outerHeight() const { 910 int LocalDOMWindow::outerHeight() const {
911 if (!frame()) 911 if (!frame())
912 return 0; 912 return 0;
913 913
914 FrameHost* host = frame()->host(); 914 FrameHost* host = frame()->host();
915 if (!host) 915 if (!host)
916 return 0; 916 return 0;
917 917
918 ChromeClient& chromeClient = host->chromeClient(); 918 ChromeClient& chromeClient = host->chromeClient();
919 if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) 919 if (host->page().settings().getReportScreenSizeInPhysicalPixelsQuirk())
920 return lroundf(chromeClient.rootWindowRect().height() * 920 return lroundf(chromeClient.rootWindowRect().height() *
921 chromeClient.screenInfo().deviceScaleFactor); 921 chromeClient.screenInfo().deviceScaleFactor);
922 return chromeClient.rootWindowRect().height(); 922 return chromeClient.rootWindowRect().height();
923 } 923 }
924 924
925 int LocalDOMWindow::outerWidth() const { 925 int LocalDOMWindow::outerWidth() const {
926 if (!frame()) 926 if (!frame())
927 return 0; 927 return 0;
928 928
929 FrameHost* host = frame()->host(); 929 FrameHost* host = frame()->host();
930 if (!host) 930 if (!host)
931 return 0; 931 return 0;
932 932
933 ChromeClient& chromeClient = host->chromeClient(); 933 ChromeClient& chromeClient = host->chromeClient();
934 if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) 934 if (host->page().settings().getReportScreenSizeInPhysicalPixelsQuirk())
935 return lroundf(chromeClient.rootWindowRect().width() * 935 return lroundf(chromeClient.rootWindowRect().width() *
936 chromeClient.screenInfo().deviceScaleFactor); 936 chromeClient.screenInfo().deviceScaleFactor);
937 937
938 return chromeClient.rootWindowRect().width(); 938 return chromeClient.rootWindowRect().width();
939 } 939 }
940 940
941 FloatSize LocalDOMWindow::getViewportSize( 941 FloatSize LocalDOMWindow::getViewportSize(
942 IncludeScrollbarsInRect scrollbarInclusion) const { 942 IncludeScrollbarsInRect scrollbarInclusion) const {
943 if (!frame()) 943 if (!frame())
944 return FloatSize(); 944 return FloatSize();
945 945
946 FrameView* view = frame()->view(); 946 FrameView* view = frame()->view();
947 if (!view) 947 if (!view)
948 return FloatSize(); 948 return FloatSize();
949 949
950 FrameHost* host = frame()->host(); 950 FrameHost* host = frame()->host();
951 if (!host) 951 if (!host)
952 return FloatSize(); 952 return FloatSize();
953 953
954 // The main frame's viewport size depends on the page scale. Since the 954 // The main frame's viewport size depends on the page scale. Since the
955 // initial page scale depends on the content width and is set after a 955 // initial page scale depends on the content width and is set after a
956 // layout, perform one now so queries during page load will use the up to 956 // layout, perform one now so queries during page load will use the up to
957 // date viewport. 957 // date viewport.
958 if (host->settings().getViewportEnabled() && frame()->isMainFrame()) 958 if (host->page().settings().getViewportEnabled() && frame()->isMainFrame())
959 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 959 document()->updateStyleAndLayoutIgnorePendingStylesheets();
960 960
961 // FIXME: This is potentially too much work. We really only need to know the 961 // FIXME: This is potentially too much work. We really only need to know the
962 // dimensions of the parent frame's layoutObject. 962 // dimensions of the parent frame's layoutObject.
963 if (Frame* parent = frame()->tree().parent()) { 963 if (Frame* parent = frame()->tree().parent()) {
964 if (parent && parent->isLocalFrame()) 964 if (parent && parent->isLocalFrame())
965 toLocalFrame(parent) 965 toLocalFrame(parent)
966 ->document() 966 ->document()
967 ->updateStyleAndLayoutIgnorePendingStylesheets(); 967 ->updateStyleAndLayoutIgnorePendingStylesheets();
968 } 968 }
969 969
970 return frame()->isMainFrame() && !host->settings().getInertVisualViewport() 970 return frame()->isMainFrame() &&
971 !host->page().settings().getInertVisualViewport()
971 ? FloatSize(host->visualViewport().visibleRect().size()) 972 ? FloatSize(host->visualViewport().visibleRect().size())
972 : FloatSize(view->visibleContentRect(scrollbarInclusion).size()); 973 : FloatSize(view->visibleContentRect(scrollbarInclusion).size());
973 } 974 }
974 975
975 int LocalDOMWindow::innerHeight() const { 976 int LocalDOMWindow::innerHeight() const {
976 if (!frame()) 977 if (!frame())
977 return 0; 978 return 0;
978 979
979 FloatSize viewportSize = getViewportSize(IncludeScrollbars); 980 FloatSize viewportSize = getViewportSize(IncludeScrollbars);
980 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), 981 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(),
(...skipping 11 matching lines...) Expand all
992 993
993 int LocalDOMWindow::screenX() const { 994 int LocalDOMWindow::screenX() const {
994 if (!frame()) 995 if (!frame())
995 return 0; 996 return 0;
996 997
997 FrameHost* host = frame()->host(); 998 FrameHost* host = frame()->host();
998 if (!host) 999 if (!host)
999 return 0; 1000 return 0;
1000 1001
1001 ChromeClient& chromeClient = host->chromeClient(); 1002 ChromeClient& chromeClient = host->chromeClient();
1002 if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) 1003 if (host->page().settings().getReportScreenSizeInPhysicalPixelsQuirk())
1003 return lroundf(chromeClient.rootWindowRect().x() * 1004 return lroundf(chromeClient.rootWindowRect().x() *
1004 chromeClient.screenInfo().deviceScaleFactor); 1005 chromeClient.screenInfo().deviceScaleFactor);
1005 return chromeClient.rootWindowRect().x(); 1006 return chromeClient.rootWindowRect().x();
1006 } 1007 }
1007 1008
1008 int LocalDOMWindow::screenY() const { 1009 int LocalDOMWindow::screenY() const {
1009 if (!frame()) 1010 if (!frame())
1010 return 0; 1011 return 0;
1011 1012
1012 FrameHost* host = frame()->host(); 1013 FrameHost* host = frame()->host();
1013 if (!host) 1014 if (!host)
1014 return 0; 1015 return 0;
1015 1016
1016 ChromeClient& chromeClient = host->chromeClient(); 1017 ChromeClient& chromeClient = host->chromeClient();
1017 if (host->settings().getReportScreenSizeInPhysicalPixelsQuirk()) 1018 if (host->page().settings().getReportScreenSizeInPhysicalPixelsQuirk())
1018 return lroundf(chromeClient.rootWindowRect().y() * 1019 return lroundf(chromeClient.rootWindowRect().y() *
1019 chromeClient.screenInfo().deviceScaleFactor); 1020 chromeClient.screenInfo().deviceScaleFactor);
1020 return chromeClient.rootWindowRect().y(); 1021 return chromeClient.rootWindowRect().y();
1021 } 1022 }
1022 1023
1023 double LocalDOMWindow::scrollX() const { 1024 double LocalDOMWindow::scrollX() const {
1024 if (!frame() || !frame()->host()) 1025 if (!frame() || !frame()->host())
1025 return 0; 1026 return 0;
1026 1027
1027 if (!frame()->host()->settings().getInertVisualViewport()) 1028 if (!frame()->host()->page().settings().getInertVisualViewport())
1028 return m_visualViewport->pageX(); 1029 return m_visualViewport->pageX();
1029 1030
1030 FrameView* view = frame()->view(); 1031 FrameView* view = frame()->view();
1031 if (!view) 1032 if (!view)
1032 return 0; 1033 return 0;
1033 1034
1034 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1035 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1035 1036
1036 double viewportX = 1037 double viewportX =
1037 view->layoutViewportScrollableArea()->getScrollOffset().width(); 1038 view->layoutViewportScrollableArea()->getScrollOffset().width();
1038 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); 1039 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor());
1039 } 1040 }
1040 1041
1041 double LocalDOMWindow::scrollY() const { 1042 double LocalDOMWindow::scrollY() const {
1042 if (!frame() || !frame()->host()) 1043 if (!frame() || !frame()->host())
1043 return 0; 1044 return 0;
1044 1045
1045 if (!frame()->host()->settings().getInertVisualViewport()) 1046 if (!frame()->host()->page().settings().getInertVisualViewport())
1046 return m_visualViewport->pageY(); 1047 return m_visualViewport->pageY();
1047 1048
1048 FrameView* view = frame()->view(); 1049 FrameView* view = frame()->view();
1049 if (!view) 1050 if (!view)
1050 return 0; 1051 return 0;
1051 1052
1052 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1053 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1053 1054
1054 double viewportY = 1055 double viewportY =
1055 view->layoutViewportScrollableArea()->getScrollOffset().height(); 1056 view->layoutViewportScrollableArea()->getScrollOffset().height();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 if (!view) 1168 if (!view)
1168 return; 1169 return;
1169 1170
1170 FrameHost* host = frame()->host(); 1171 FrameHost* host = frame()->host();
1171 if (!host) 1172 if (!host)
1172 return; 1173 return;
1173 1174
1174 x = ScrollableArea::normalizeNonFiniteScroll(x); 1175 x = ScrollableArea::normalizeNonFiniteScroll(x);
1175 y = ScrollableArea::normalizeNonFiniteScroll(y); 1176 y = ScrollableArea::normalizeNonFiniteScroll(y);
1176 1177
1177 ScrollableArea* viewport = host->settings().getInertVisualViewport() 1178 ScrollableArea* viewport = host->page().settings().getInertVisualViewport()
1178 ? view->layoutViewportScrollableArea() 1179 ? view->layoutViewportScrollableArea()
1179 : view->getScrollableArea(); 1180 : view->getScrollableArea();
1180 1181
1181 ScrollOffset currentOffset = viewport->getScrollOffset(); 1182 ScrollOffset currentOffset = viewport->getScrollOffset();
1182 ScrollOffset scaledDelta(x * frame()->pageZoomFactor(), 1183 ScrollOffset scaledDelta(x * frame()->pageZoomFactor(),
1183 y * frame()->pageZoomFactor()); 1184 y * frame()->pageZoomFactor());
1184 1185
1185 viewport->setScrollOffset(currentOffset + scaledDelta, ProgrammaticScroll, 1186 viewport->setScrollOffset(currentOffset + scaledDelta, ProgrammaticScroll,
1186 scrollBehavior); 1187 scrollBehavior);
1187 } 1188 }
(...skipping 26 matching lines...) Expand all
1214 x = ScrollableArea::normalizeNonFiniteScroll(x); 1215 x = ScrollableArea::normalizeNonFiniteScroll(x);
1215 y = ScrollableArea::normalizeNonFiniteScroll(y); 1216 y = ScrollableArea::normalizeNonFiniteScroll(y);
1216 1217
1217 // It is only necessary to have an up-to-date layout if the position may be 1218 // It is only necessary to have an up-to-date layout if the position may be
1218 // clamped, which is never the case for (0, 0). 1219 // clamped, which is never the case for (0, 0).
1219 if (x || y) 1220 if (x || y)
1220 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1221 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1221 1222
1222 ScrollOffset layoutOffset(x * frame()->pageZoomFactor(), 1223 ScrollOffset layoutOffset(x * frame()->pageZoomFactor(),
1223 y * frame()->pageZoomFactor()); 1224 y * frame()->pageZoomFactor());
1224 ScrollableArea* viewport = host->settings().getInertVisualViewport() 1225 ScrollableArea* viewport = host->page().settings().getInertVisualViewport()
1225 ? view->layoutViewportScrollableArea() 1226 ? view->layoutViewportScrollableArea()
1226 : view->getScrollableArea(); 1227 : view->getScrollableArea();
1227 viewport->setScrollOffset(layoutOffset, ProgrammaticScroll, 1228 viewport->setScrollOffset(layoutOffset, ProgrammaticScroll,
1228 ScrollBehaviorAuto); 1229 ScrollBehaviorAuto);
1229 } 1230 }
1230 1231
1231 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const { 1232 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const {
1232 if (!isCurrentlyDisplayedInFrame()) 1233 if (!isCurrentlyDisplayedInFrame())
1233 return; 1234 return;
1234 1235
1235 FrameView* view = frame()->view(); 1236 FrameView* view = frame()->view();
1236 if (!view) 1237 if (!view)
1237 return; 1238 return;
1238 1239
1239 FrameHost* host = frame()->host(); 1240 FrameHost* host = frame()->host();
1240 if (!host) 1241 if (!host)
1241 return; 1242 return;
1242 1243
1243 // It is only necessary to have an up-to-date layout if the position may be 1244 // It is only necessary to have an up-to-date layout if the position may be
1244 // clamped, which is never the case for (0, 0). 1245 // clamped, which is never the case for (0, 0).
1245 if (!scrollToOptions.hasLeft() || !scrollToOptions.hasTop() || 1246 if (!scrollToOptions.hasLeft() || !scrollToOptions.hasTop() ||
1246 scrollToOptions.left() || scrollToOptions.top()) { 1247 scrollToOptions.left() || scrollToOptions.top()) {
1247 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1248 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1248 } 1249 }
1249 1250
1250 double scaledX = 0.0; 1251 double scaledX = 0.0;
1251 double scaledY = 0.0; 1252 double scaledY = 0.0;
1252 1253
1253 ScrollableArea* viewport = host->settings().getInertVisualViewport() 1254 ScrollableArea* viewport = host->page().settings().getInertVisualViewport()
1254 ? view->layoutViewportScrollableArea() 1255 ? view->layoutViewportScrollableArea()
1255 : view->getScrollableArea(); 1256 : view->getScrollableArea();
1256 1257
1257 ScrollOffset currentOffset = viewport->getScrollOffset(); 1258 ScrollOffset currentOffset = viewport->getScrollOffset();
1258 scaledX = currentOffset.width(); 1259 scaledX = currentOffset.width();
1259 scaledY = currentOffset.height(); 1260 scaledY = currentOffset.height();
1260 1261
1261 if (scrollToOptions.hasLeft()) 1262 if (scrollToOptions.hasLeft())
1262 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left()) * 1263 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left()) *
1263 frame()->pageZoomFactor(); 1264 frame()->pageZoomFactor();
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 DOMWindow::trace(visitor); 1632 DOMWindow::trace(visitor);
1632 Supplementable<LocalDOMWindow>::trace(visitor); 1633 Supplementable<LocalDOMWindow>::trace(visitor);
1633 } 1634 }
1634 1635
1635 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) { 1636 DEFINE_TRACE_WRAPPERS(LocalDOMWindow) {
1636 visitor->traceWrappers(m_customElements); 1637 visitor->traceWrappers(m_customElements);
1637 DOMWindow::traceWrappers(visitor); 1638 DOMWindow::traceWrappers(visitor);
1638 } 1639 }
1639 1640
1640 } // namespace blink 1641 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698