| OLD | NEW |
| 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 // date viewport. | 927 // date viewport. |
| 928 if (host->settings().viewportEnabled() && frame->isMainFrame()) | 928 if (host->settings().viewportEnabled() && frame->isMainFrame()) |
| 929 frame->document()->updateLayoutIgnorePendingStylesheets(); | 929 frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 930 | 930 |
| 931 // FIXME: This is potentially too much work. We really only need to know the
dimensions of the parent frame's layoutObject. | 931 // FIXME: This is potentially too much work. We really only need to know the
dimensions of the parent frame's layoutObject. |
| 932 if (Frame* parent = frame->tree().parent()) { | 932 if (Frame* parent = frame->tree().parent()) { |
| 933 if (parent && parent->isLocalFrame()) | 933 if (parent && parent->isLocalFrame()) |
| 934 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee
ts(); | 934 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee
ts(); |
| 935 } | 935 } |
| 936 | 936 |
| 937 return frame->isMainFrame() && !host->settings().inertVisualViewport() | 937 return view->visibleContentRect(IncludeScrollbars).size(); |
| 938 ? host->visualViewport().visibleRect().size() | |
| 939 : view->visibleContentRect(IncludeScrollbars).size(); | |
| 940 } | 938 } |
| 941 | 939 |
| 942 int LocalDOMWindow::innerHeight() const | 940 int LocalDOMWindow::innerHeight() const |
| 943 { | 941 { |
| 944 if (!frame()) | 942 if (!frame()) |
| 945 return 0; | 943 return 0; |
| 946 | 944 |
| 947 FloatSize viewportSize = getViewportSize(frame()); | 945 FloatSize viewportSize = getViewportSize(frame()); |
| 948 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame()
->pageZoomFactor()); | 946 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame()
->pageZoomFactor()); |
| 949 } | 947 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 FrameView* view = frame()->view(); | 991 FrameView* view = frame()->view(); |
| 994 if (!view) | 992 if (!view) |
| 995 return 0; | 993 return 0; |
| 996 | 994 |
| 997 FrameHost* host = frame()->host(); | 995 FrameHost* host = frame()->host(); |
| 998 if (!host) | 996 if (!host) |
| 999 return 0; | 997 return 0; |
| 1000 | 998 |
| 1001 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 999 frame()->document()->updateLayoutIgnorePendingStylesheets(); |
| 1002 | 1000 |
| 1003 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1001 double viewportX = view->layoutViewportScrollableArea()->scrollPositionDoubl
e().x(); |
| 1004 double viewportX = viewport->scrollPositionDouble().x(); | |
| 1005 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); | 1002 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); |
| 1006 } | 1003 } |
| 1007 | 1004 |
| 1008 double LocalDOMWindow::scrollY() const | 1005 double LocalDOMWindow::scrollY() const |
| 1009 { | 1006 { |
| 1010 if (!frame()) | 1007 if (!frame()) |
| 1011 return 0; | 1008 return 0; |
| 1012 | 1009 |
| 1013 FrameView* view = frame()->view(); | 1010 FrameView* view = frame()->view(); |
| 1014 if (!view) | 1011 if (!view) |
| 1015 return 0; | 1012 return 0; |
| 1016 | 1013 |
| 1017 FrameHost* host = frame()->host(); | 1014 FrameHost* host = frame()->host(); |
| 1018 if (!host) | 1015 if (!host) |
| 1019 return 0; | 1016 return 0; |
| 1020 | 1017 |
| 1021 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 1018 frame()->document()->updateLayoutIgnorePendingStylesheets(); |
| 1022 | 1019 |
| 1023 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1020 double viewportY = view->layoutViewportScrollableArea()->scrollPositionDoubl
e().y(); |
| 1024 double viewportY = viewport->scrollPositionDouble().y(); | |
| 1025 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); | 1021 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); |
| 1026 } | 1022 } |
| 1027 | 1023 |
| 1028 const AtomicString& LocalDOMWindow::name() const | 1024 const AtomicString& LocalDOMWindow::name() const |
| 1029 { | 1025 { |
| 1030 if (!isCurrentlyDisplayedInFrame()) | 1026 if (!isCurrentlyDisplayedInFrame()) |
| 1031 return nullAtom; | 1027 return nullAtom; |
| 1032 | 1028 |
| 1033 return frame()->tree().name(); | 1029 return frame()->tree().name(); |
| 1034 } | 1030 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 { | 1118 { |
| 1123 if (!isCurrentlyDisplayedInFrame()) | 1119 if (!isCurrentlyDisplayedInFrame()) |
| 1124 return; | 1120 return; |
| 1125 | 1121 |
| 1126 document()->updateLayoutIgnorePendingStylesheets(); | 1122 document()->updateLayoutIgnorePendingStylesheets(); |
| 1127 | 1123 |
| 1128 FrameView* view = frame()->view(); | 1124 FrameView* view = frame()->view(); |
| 1129 if (!view) | 1125 if (!view) |
| 1130 return; | 1126 return; |
| 1131 | 1127 |
| 1132 FrameHost* host = frame()->host(); | |
| 1133 if (!host) | |
| 1134 return; | |
| 1135 | |
| 1136 x = ScrollableArea::normalizeNonFiniteScroll(x); | 1128 x = ScrollableArea::normalizeNonFiniteScroll(x); |
| 1137 y = ScrollableArea::normalizeNonFiniteScroll(y); | 1129 y = ScrollableArea::normalizeNonFiniteScroll(y); |
| 1138 | 1130 |
| 1139 DoublePoint currentOffset = view->scrollableArea()->scrollPositionDouble(); | 1131 DoublePoint currentOffset = view->layoutViewportScrollableArea()->scrollPosi
tionDouble(); |
| 1140 DoubleSize scaledDelta(x * frame()->pageZoomFactor(), y * frame()->pageZoomF
actor()); | 1132 DoubleSize scaledDelta(x * frame()->pageZoomFactor(), y * frame()->pageZoomF
actor()); |
| 1141 | 1133 |
| 1142 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1134 view->layoutViewportScrollableArea()->setScrollPosition( |
| 1143 viewport->setScrollPosition(currentOffset + scaledDelta, ProgrammaticScroll,
scrollBehavior); | 1135 currentOffset + scaledDelta, ProgrammaticScroll, scrollBehavior); |
| 1144 } | 1136 } |
| 1145 | 1137 |
| 1146 void LocalDOMWindow::scrollBy(const ScrollToOptions& scrollToOptions) const | 1138 void LocalDOMWindow::scrollBy(const ScrollToOptions& scrollToOptions) const |
| 1147 { | 1139 { |
| 1148 double x = 0.0; | 1140 double x = 0.0; |
| 1149 double y = 0.0; | 1141 double y = 0.0; |
| 1150 if (scrollToOptions.hasLeft()) | 1142 if (scrollToOptions.hasLeft()) |
| 1151 x = scrollToOptions.left(); | 1143 x = scrollToOptions.left(); |
| 1152 if (scrollToOptions.hasTop()) | 1144 if (scrollToOptions.hasTop()) |
| 1153 y = scrollToOptions.top(); | 1145 y = scrollToOptions.top(); |
| 1154 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; | 1146 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
| 1155 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB
ehavior); | 1147 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB
ehavior); |
| 1156 scrollBy(x, y, scrollBehavior); | 1148 scrollBy(x, y, scrollBehavior); |
| 1157 } | 1149 } |
| 1158 | 1150 |
| 1159 void LocalDOMWindow::scrollTo(double x, double y) const | 1151 void LocalDOMWindow::scrollTo(double x, double y) const |
| 1160 { | 1152 { |
| 1161 if (!isCurrentlyDisplayedInFrame()) | 1153 if (!isCurrentlyDisplayedInFrame()) |
| 1162 return; | 1154 return; |
| 1163 | 1155 |
| 1164 FrameView* view = frame()->view(); | 1156 FrameView* view = frame()->view(); |
| 1165 if (!view) | 1157 if (!view) |
| 1166 return; | 1158 return; |
| 1167 | 1159 |
| 1168 FrameHost* host = frame()->host(); | |
| 1169 if (!host) | |
| 1170 return; | |
| 1171 | |
| 1172 x = ScrollableArea::normalizeNonFiniteScroll(x); | 1160 x = ScrollableArea::normalizeNonFiniteScroll(x); |
| 1173 y = ScrollableArea::normalizeNonFiniteScroll(y); | 1161 y = ScrollableArea::normalizeNonFiniteScroll(y); |
| 1174 | 1162 |
| 1175 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1163 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
| 1176 // which is never the case for (0, 0). | 1164 // which is never the case for (0, 0). |
| 1177 if (x || y) | 1165 if (x || y) |
| 1178 document()->updateLayoutIgnorePendingStylesheets(); | 1166 document()->updateLayoutIgnorePendingStylesheets(); |
| 1179 | 1167 |
| 1180 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); | 1168 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); |
| 1181 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1169 view->layoutViewportScrollableArea()->setScrollPosition( |
| 1182 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAut
o); | 1170 layoutPos, ProgrammaticScroll, ScrollBehaviorAuto); |
| 1183 } | 1171 } |
| 1184 | 1172 |
| 1185 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const | 1173 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const |
| 1186 { | 1174 { |
| 1187 if (!isCurrentlyDisplayedInFrame()) | 1175 if (!isCurrentlyDisplayedInFrame()) |
| 1188 return; | 1176 return; |
| 1189 | 1177 |
| 1190 FrameView* view = frame()->view(); | 1178 FrameView* view = frame()->view(); |
| 1191 if (!view) | 1179 if (!view) |
| 1192 return; | 1180 return; |
| 1193 | 1181 |
| 1194 FrameHost* host = frame()->host(); | |
| 1195 if (!host) | |
| 1196 return; | |
| 1197 | |
| 1198 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1182 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
| 1199 // which is never the case for (0, 0). | 1183 // which is never the case for (0, 0). |
| 1200 if (!scrollToOptions.hasLeft() | 1184 if (!scrollToOptions.hasLeft() |
| 1201 || !scrollToOptions.hasTop() | 1185 || !scrollToOptions.hasTop() |
| 1202 || scrollToOptions.left() | 1186 || scrollToOptions.left() |
| 1203 || scrollToOptions.top()) { | 1187 || scrollToOptions.top()) { |
| 1204 document()->updateLayoutIgnorePendingStylesheets(); | 1188 document()->updateLayoutIgnorePendingStylesheets(); |
| 1205 } | 1189 } |
| 1206 | 1190 |
| 1207 double scaledX = 0.0; | 1191 double scaledX = 0.0; |
| 1208 double scaledY = 0.0; | 1192 double scaledY = 0.0; |
| 1209 | 1193 |
| 1210 DoublePoint currentOffset = view->scrollableArea()->scrollPositionDouble(); | 1194 DoublePoint currentOffset = view->layoutViewportScrollableArea()->scrollPosi
tionDouble(); |
| 1211 scaledX = currentOffset.x(); | 1195 scaledX = currentOffset.x(); |
| 1212 scaledY = currentOffset.y(); | 1196 scaledY = currentOffset.y(); |
| 1213 | 1197 |
| 1214 if (scrollToOptions.hasLeft()) | 1198 if (scrollToOptions.hasLeft()) |
| 1215 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left(
)) * frame()->pageZoomFactor(); | 1199 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left(
)) * frame()->pageZoomFactor(); |
| 1216 | 1200 |
| 1217 if (scrollToOptions.hasTop()) | 1201 if (scrollToOptions.hasTop()) |
| 1218 scaledY = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.top()
) * frame()->pageZoomFactor(); | 1202 scaledY = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.top()
) * frame()->pageZoomFactor(); |
| 1219 | 1203 |
| 1220 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; | 1204 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; |
| 1221 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB
ehavior); | 1205 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB
ehavior); |
| 1222 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1206 |
| 1223 viewport->setScrollPosition(DoublePoint(scaledX, scaledY), ProgrammaticScrol
l, scrollBehavior); | 1207 view->layoutViewportScrollableArea()->setScrollPosition( |
| 1208 DoublePoint(scaledX, scaledY), ProgrammaticScroll, scrollBehavior); |
| 1224 } | 1209 } |
| 1225 | 1210 |
| 1226 void LocalDOMWindow::moveBy(int x, int y) const | 1211 void LocalDOMWindow::moveBy(int x, int y) const |
| 1227 { | 1212 { |
| 1228 if (!frame() || !frame()->isMainFrame()) | 1213 if (!frame() || !frame()->isMainFrame()) |
| 1229 return; | 1214 return; |
| 1230 | 1215 |
| 1231 FrameHost* host = frame()->host(); | 1216 FrameHost* host = frame()->host(); |
| 1232 if (!host) | 1217 if (!host) |
| 1233 return; | 1218 return; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 { | 1513 { |
| 1529 // If the LocalDOMWindow still has a frame reference, that frame must point | 1514 // If the LocalDOMWindow still has a frame reference, that frame must point |
| 1530 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1515 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
| 1531 // where script execution leaks between different LocalDOMWindows. | 1516 // where script execution leaks between different LocalDOMWindows. |
| 1532 if (m_frameObserver->frame()) | 1517 if (m_frameObserver->frame()) |
| 1533 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWi
ndow() == this); | 1518 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWi
ndow() == this); |
| 1534 return m_frameObserver->frame(); | 1519 return m_frameObserver->frame(); |
| 1535 } | 1520 } |
| 1536 | 1521 |
| 1537 } // namespace blink | 1522 } // namespace blink |
| OLD | NEW |