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

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

Issue 2589143003: Add 'get' prefix for Settings.in generated code. (Closed)
Patch Set: Capitalize the prefix. Created 4 years 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 unsigned LocalDOMWindow::pendingUnloadEventListeners() const { 256 unsigned LocalDOMWindow::pendingUnloadEventListeners() const {
257 return windowsWithUnloadEventListeners().count( 257 return windowsWithUnloadEventListeners().count(
258 const_cast<LocalDOMWindow*>(this)); 258 const_cast<LocalDOMWindow*>(this));
259 } 259 }
260 260
261 bool LocalDOMWindow::allowPopUp(LocalFrame& firstFrame) { 261 bool LocalDOMWindow::allowPopUp(LocalFrame& firstFrame) {
262 if (UserGestureIndicator::utilizeUserGesture()) 262 if (UserGestureIndicator::utilizeUserGesture())
263 return true; 263 return true;
264 264
265 Settings* settings = firstFrame.settings(); 265 Settings* settings = firstFrame.settings();
266 return settings && settings->javaScriptCanOpenWindowsAutomatically(); 266 return settings && settings->GetJavaScriptCanOpenWindowsAutomatically();
267 } 267 }
268 268
269 bool LocalDOMWindow::allowPopUp() { 269 bool LocalDOMWindow::allowPopUp() {
270 return frame() && allowPopUp(*frame()); 270 return frame() && allowPopUp(*frame());
271 } 271 }
272 272
273 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) 273 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame)
274 : m_frame(&frame), 274 : m_frame(&frame),
275 m_visualViewport(DOMVisualViewport::create(this)), 275 m_visualViewport(DOMVisualViewport::create(this)),
276 m_unusedPreloadsTimer(this, &LocalDOMWindow::warnUnusedPreloads), 276 m_unusedPreloadsTimer(this, &LocalDOMWindow::warnUnusedPreloads),
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 855
856 int LocalDOMWindow::outerHeight() const { 856 int LocalDOMWindow::outerHeight() const {
857 if (!frame()) 857 if (!frame())
858 return 0; 858 return 0;
859 859
860 FrameHost* host = frame()->host(); 860 FrameHost* host = frame()->host();
861 if (!host) 861 if (!host)
862 return 0; 862 return 0;
863 863
864 ChromeClient& chromeClient = host->chromeClient(); 864 ChromeClient& chromeClient = host->chromeClient();
865 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) 865 if (host->settings().GetReportScreenSizeInPhysicalPixelsQuirk())
866 return lroundf(chromeClient.rootWindowRect().height() * 866 return lroundf(chromeClient.rootWindowRect().height() *
867 chromeClient.screenInfo().deviceScaleFactor); 867 chromeClient.screenInfo().deviceScaleFactor);
868 return chromeClient.rootWindowRect().height(); 868 return chromeClient.rootWindowRect().height();
869 } 869 }
870 870
871 int LocalDOMWindow::outerWidth() const { 871 int LocalDOMWindow::outerWidth() const {
872 if (!frame()) 872 if (!frame())
873 return 0; 873 return 0;
874 874
875 FrameHost* host = frame()->host(); 875 FrameHost* host = frame()->host();
876 if (!host) 876 if (!host)
877 return 0; 877 return 0;
878 878
879 ChromeClient& chromeClient = host->chromeClient(); 879 ChromeClient& chromeClient = host->chromeClient();
880 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) 880 if (host->settings().GetReportScreenSizeInPhysicalPixelsQuirk())
881 return lroundf(chromeClient.rootWindowRect().width() * 881 return lroundf(chromeClient.rootWindowRect().width() *
882 chromeClient.screenInfo().deviceScaleFactor); 882 chromeClient.screenInfo().deviceScaleFactor);
883 883
884 return chromeClient.rootWindowRect().width(); 884 return chromeClient.rootWindowRect().width();
885 } 885 }
886 886
887 FloatSize LocalDOMWindow::getViewportSize( 887 FloatSize LocalDOMWindow::getViewportSize(
888 IncludeScrollbarsInRect scrollbarInclusion) const { 888 IncludeScrollbarsInRect scrollbarInclusion) const {
889 if (!frame()) 889 if (!frame())
890 return FloatSize(); 890 return FloatSize();
891 891
892 FrameView* view = frame()->view(); 892 FrameView* view = frame()->view();
893 if (!view) 893 if (!view)
894 return FloatSize(); 894 return FloatSize();
895 895
896 FrameHost* host = frame()->host(); 896 FrameHost* host = frame()->host();
897 if (!host) 897 if (!host)
898 return FloatSize(); 898 return FloatSize();
899 899
900 // The main frame's viewport size depends on the page scale. Since the 900 // The main frame's viewport size depends on the page scale. Since the
901 // initial page scale depends on the content width and is set after a 901 // initial page scale depends on the content width and is set after a
902 // layout, perform one now so queries during page load will use the up to 902 // layout, perform one now so queries during page load will use the up to
903 // date viewport. 903 // date viewport.
904 if (host->settings().viewportEnabled() && frame()->isMainFrame()) 904 if (host->settings().GetViewportEnabled() && frame()->isMainFrame())
905 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 905 document()->updateStyleAndLayoutIgnorePendingStylesheets();
906 906
907 // FIXME: This is potentially too much work. We really only need to know the 907 // FIXME: This is potentially too much work. We really only need to know the
908 // dimensions of the parent frame's layoutObject. 908 // dimensions of the parent frame's layoutObject.
909 if (Frame* parent = frame()->tree().parent()) { 909 if (Frame* parent = frame()->tree().parent()) {
910 if (parent && parent->isLocalFrame()) 910 if (parent && parent->isLocalFrame())
911 toLocalFrame(parent) 911 toLocalFrame(parent)
912 ->document() 912 ->document()
913 ->updateStyleAndLayoutIgnorePendingStylesheets(); 913 ->updateStyleAndLayoutIgnorePendingStylesheets();
914 } 914 }
915 915
916 return frame()->isMainFrame() && !host->settings().inertVisualViewport() 916 return frame()->isMainFrame() && !host->settings().GetInertVisualViewport()
917 ? FloatSize(host->visualViewport().visibleRect().size()) 917 ? FloatSize(host->visualViewport().visibleRect().size())
918 : FloatSize(view->visibleContentRect(scrollbarInclusion).size()); 918 : FloatSize(view->visibleContentRect(scrollbarInclusion).size());
919 } 919 }
920 920
921 int LocalDOMWindow::innerHeight() const { 921 int LocalDOMWindow::innerHeight() const {
922 if (!frame()) 922 if (!frame())
923 return 0; 923 return 0;
924 924
925 FloatSize viewportSize = getViewportSize(IncludeScrollbars); 925 FloatSize viewportSize = getViewportSize(IncludeScrollbars);
926 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), 926 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(),
(...skipping 11 matching lines...) Expand all
938 938
939 int LocalDOMWindow::screenX() const { 939 int LocalDOMWindow::screenX() const {
940 if (!frame()) 940 if (!frame())
941 return 0; 941 return 0;
942 942
943 FrameHost* host = frame()->host(); 943 FrameHost* host = frame()->host();
944 if (!host) 944 if (!host)
945 return 0; 945 return 0;
946 946
947 ChromeClient& chromeClient = host->chromeClient(); 947 ChromeClient& chromeClient = host->chromeClient();
948 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) 948 if (host->settings().GetReportScreenSizeInPhysicalPixelsQuirk())
949 return lroundf(chromeClient.rootWindowRect().x() * 949 return lroundf(chromeClient.rootWindowRect().x() *
950 chromeClient.screenInfo().deviceScaleFactor); 950 chromeClient.screenInfo().deviceScaleFactor);
951 return chromeClient.rootWindowRect().x(); 951 return chromeClient.rootWindowRect().x();
952 } 952 }
953 953
954 int LocalDOMWindow::screenY() const { 954 int LocalDOMWindow::screenY() const {
955 if (!frame()) 955 if (!frame())
956 return 0; 956 return 0;
957 957
958 FrameHost* host = frame()->host(); 958 FrameHost* host = frame()->host();
959 if (!host) 959 if (!host)
960 return 0; 960 return 0;
961 961
962 ChromeClient& chromeClient = host->chromeClient(); 962 ChromeClient& chromeClient = host->chromeClient();
963 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) 963 if (host->settings().GetReportScreenSizeInPhysicalPixelsQuirk())
964 return lroundf(chromeClient.rootWindowRect().y() * 964 return lroundf(chromeClient.rootWindowRect().y() *
965 chromeClient.screenInfo().deviceScaleFactor); 965 chromeClient.screenInfo().deviceScaleFactor);
966 return chromeClient.rootWindowRect().y(); 966 return chromeClient.rootWindowRect().y();
967 } 967 }
968 968
969 double LocalDOMWindow::scrollX() const { 969 double LocalDOMWindow::scrollX() const {
970 if (!frame() || !frame()->host()) 970 if (!frame() || !frame()->host())
971 return 0; 971 return 0;
972 972
973 if (!frame()->host()->settings().inertVisualViewport()) 973 if (!frame()->host()->settings().GetInertVisualViewport())
974 return m_visualViewport->pageX(); 974 return m_visualViewport->pageX();
975 975
976 FrameView* view = frame()->view(); 976 FrameView* view = frame()->view();
977 if (!view) 977 if (!view)
978 return 0; 978 return 0;
979 979
980 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 980 document()->updateStyleAndLayoutIgnorePendingStylesheets();
981 981
982 double viewportX = 982 double viewportX =
983 view->layoutViewportScrollableArea()->getScrollOffset().width(); 983 view->layoutViewportScrollableArea()->getScrollOffset().width();
984 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); 984 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor());
985 } 985 }
986 986
987 double LocalDOMWindow::scrollY() const { 987 double LocalDOMWindow::scrollY() const {
988 if (!frame() || !frame()->host()) 988 if (!frame() || !frame()->host())
989 return 0; 989 return 0;
990 990
991 if (!frame()->host()->settings().inertVisualViewport()) 991 if (!frame()->host()->settings().GetInertVisualViewport())
992 return m_visualViewport->pageY(); 992 return m_visualViewport->pageY();
993 993
994 FrameView* view = frame()->view(); 994 FrameView* view = frame()->view();
995 if (!view) 995 if (!view)
996 return 0; 996 return 0;
997 997
998 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 998 document()->updateStyleAndLayoutIgnorePendingStylesheets();
999 999
1000 double viewportY = 1000 double viewportY =
1001 view->layoutViewportScrollableArea()->getScrollOffset().height(); 1001 view->layoutViewportScrollableArea()->getScrollOffset().height();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 if (!view) 1113 if (!view)
1114 return; 1114 return;
1115 1115
1116 FrameHost* host = frame()->host(); 1116 FrameHost* host = frame()->host();
1117 if (!host) 1117 if (!host)
1118 return; 1118 return;
1119 1119
1120 x = ScrollableArea::normalizeNonFiniteScroll(x); 1120 x = ScrollableArea::normalizeNonFiniteScroll(x);
1121 y = ScrollableArea::normalizeNonFiniteScroll(y); 1121 y = ScrollableArea::normalizeNonFiniteScroll(y);
1122 1122
1123 ScrollableArea* viewport = host->settings().inertVisualViewport() 1123 ScrollableArea* viewport = host->settings().GetInertVisualViewport()
1124 ? view->layoutViewportScrollableArea() 1124 ? view->layoutViewportScrollableArea()
1125 : view->getScrollableArea(); 1125 : view->getScrollableArea();
1126 1126
1127 ScrollOffset currentOffset = viewport->getScrollOffset(); 1127 ScrollOffset currentOffset = viewport->getScrollOffset();
1128 ScrollOffset scaledDelta(x * frame()->pageZoomFactor(), 1128 ScrollOffset scaledDelta(x * frame()->pageZoomFactor(),
1129 y * frame()->pageZoomFactor()); 1129 y * frame()->pageZoomFactor());
1130 1130
1131 viewport->setScrollOffset(currentOffset + scaledDelta, ProgrammaticScroll, 1131 viewport->setScrollOffset(currentOffset + scaledDelta, ProgrammaticScroll,
1132 scrollBehavior); 1132 scrollBehavior);
1133 } 1133 }
(...skipping 26 matching lines...) Expand all
1160 x = ScrollableArea::normalizeNonFiniteScroll(x); 1160 x = ScrollableArea::normalizeNonFiniteScroll(x);
1161 y = ScrollableArea::normalizeNonFiniteScroll(y); 1161 y = ScrollableArea::normalizeNonFiniteScroll(y);
1162 1162
1163 // It is only necessary to have an up-to-date layout if the position may be 1163 // It is only necessary to have an up-to-date layout if the position may be
1164 // clamped, which is never the case for (0, 0). 1164 // clamped, which is never the case for (0, 0).
1165 if (x || y) 1165 if (x || y)
1166 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1166 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1167 1167
1168 ScrollOffset layoutOffset(x * frame()->pageZoomFactor(), 1168 ScrollOffset layoutOffset(x * frame()->pageZoomFactor(),
1169 y * frame()->pageZoomFactor()); 1169 y * frame()->pageZoomFactor());
1170 ScrollableArea* viewport = host->settings().inertVisualViewport() 1170 ScrollableArea* viewport = host->settings().GetInertVisualViewport()
1171 ? view->layoutViewportScrollableArea() 1171 ? view->layoutViewportScrollableArea()
1172 : view->getScrollableArea(); 1172 : view->getScrollableArea();
1173 viewport->setScrollOffset(layoutOffset, ProgrammaticScroll, 1173 viewport->setScrollOffset(layoutOffset, ProgrammaticScroll,
1174 ScrollBehaviorAuto); 1174 ScrollBehaviorAuto);
1175 } 1175 }
1176 1176
1177 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const { 1177 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const {
1178 if (!isCurrentlyDisplayedInFrame()) 1178 if (!isCurrentlyDisplayedInFrame())
1179 return; 1179 return;
1180 1180
1181 FrameView* view = frame()->view(); 1181 FrameView* view = frame()->view();
1182 if (!view) 1182 if (!view)
1183 return; 1183 return;
1184 1184
1185 FrameHost* host = frame()->host(); 1185 FrameHost* host = frame()->host();
1186 if (!host) 1186 if (!host)
1187 return; 1187 return;
1188 1188
1189 // It is only necessary to have an up-to-date layout if the position may be 1189 // It is only necessary to have an up-to-date layout if the position may be
1190 // clamped, which is never the case for (0, 0). 1190 // clamped, which is never the case for (0, 0).
1191 if (!scrollToOptions.hasLeft() || !scrollToOptions.hasTop() || 1191 if (!scrollToOptions.hasLeft() || !scrollToOptions.hasTop() ||
1192 scrollToOptions.left() || scrollToOptions.top()) { 1192 scrollToOptions.left() || scrollToOptions.top()) {
1193 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1193 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1194 } 1194 }
1195 1195
1196 double scaledX = 0.0; 1196 double scaledX = 0.0;
1197 double scaledY = 0.0; 1197 double scaledY = 0.0;
1198 1198
1199 ScrollableArea* viewport = host->settings().inertVisualViewport() 1199 ScrollableArea* viewport = host->settings().GetInertVisualViewport()
1200 ? view->layoutViewportScrollableArea() 1200 ? view->layoutViewportScrollableArea()
1201 : view->getScrollableArea(); 1201 : view->getScrollableArea();
1202 1202
1203 ScrollOffset currentOffset = viewport->getScrollOffset(); 1203 ScrollOffset currentOffset = viewport->getScrollOffset();
1204 scaledX = currentOffset.width(); 1204 scaledX = currentOffset.width();
1205 scaledY = currentOffset.height(); 1205 scaledY = currentOffset.height();
1206 1206
1207 if (scrollToOptions.hasLeft()) 1207 if (scrollToOptions.hasLeft())
1208 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left()) * 1208 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left()) *
1209 frame()->pageZoomFactor(); 1209 frame()->pageZoomFactor();
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 1567
1568 LocalFrame* LocalDOMWindow::frame() const { 1568 LocalFrame* LocalDOMWindow::frame() const {
1569 // If the LocalDOMWindow still has a frame reference, that frame must point 1569 // If the LocalDOMWindow still has a frame reference, that frame must point
1570 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1570 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1571 // where script execution leaks between different LocalDOMWindows. 1571 // where script execution leaks between different LocalDOMWindows.
1572 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this); 1572 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this);
1573 return m_frame; 1573 return m_frame;
1574 } 1574 }
1575 1575
1576 } // namespace blink 1576 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698