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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 FrameView* view = frame()->view(); | 977 FrameView* view = frame()->view(); |
978 if (!view) | 978 if (!view) |
979 return 0; | 979 return 0; |
980 | 980 |
981 FrameHost* host = frame()->host(); | 981 FrameHost* host = frame()->host(); |
982 if (!host) | 982 if (!host) |
983 return 0; | 983 return 0; |
984 | 984 |
985 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 985 frame()->document()->updateLayoutIgnorePendingStylesheets(); |
986 | 986 |
987 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 987 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
988 double viewportX = viewport->scrollPositionDouble().x(); | 988 double viewportX = viewport->scrollPositionDouble().x(); |
989 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); | 989 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); |
990 } | 990 } |
991 | 991 |
992 double LocalDOMWindow::scrollY() const | 992 double LocalDOMWindow::scrollY() const |
993 { | 993 { |
994 if (!frame()) | 994 if (!frame()) |
995 return 0; | 995 return 0; |
996 | 996 |
997 FrameView* view = frame()->view(); | 997 FrameView* view = frame()->view(); |
998 if (!view) | 998 if (!view) |
999 return 0; | 999 return 0; |
1000 | 1000 |
1001 FrameHost* host = frame()->host(); | 1001 FrameHost* host = frame()->host(); |
1002 if (!host) | 1002 if (!host) |
1003 return 0; | 1003 return 0; |
1004 | 1004 |
1005 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 1005 frame()->document()->updateLayoutIgnorePendingStylesheets(); |
1006 | 1006 |
1007 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1007 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1008 double viewportY = viewport->scrollPositionDouble().y(); | 1008 double viewportY = viewport->scrollPositionDouble().y(); |
1009 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); | 1009 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); |
1010 } | 1010 } |
1011 | 1011 |
1012 const AtomicString& LocalDOMWindow::name() const | 1012 const AtomicString& LocalDOMWindow::name() const |
1013 { | 1013 { |
1014 if (!isCurrentlyDisplayedInFrame()) | 1014 if (!isCurrentlyDisplayedInFrame()) |
1015 return nullAtom; | 1015 return nullAtom; |
1016 | 1016 |
1017 return frame()->tree().name(); | 1017 return frame()->tree().name(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1123 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1124 | 1124 |
1125 DoublePoint currentOffset = viewport->scrollPositionDouble(); | 1125 DoublePoint currentOffset = viewport->scrollPositionDouble(); |
1126 DoubleSize scaledDelta(x * frame()->pageZoomFactor(), y * frame()->pageZoomF
actor()); | 1126 DoubleSize scaledDelta(x * frame()->pageZoomFactor(), y * frame()->pageZoomF
actor()); |
1127 | 1127 |
1128 viewport->setScrollPosition(currentOffset + scaledDelta, ProgrammaticScroll,
scrollBehavior); | 1128 viewport->setScrollPosition(currentOffset + scaledDelta, ProgrammaticScroll,
scrollBehavior); |
1129 } | 1129 } |
1130 | 1130 |
1131 void LocalDOMWindow::scrollBy(const ScrollToOptions& scrollToOptions) const | 1131 void LocalDOMWindow::scrollBy(const ScrollToOptions& scrollToOptions) const |
1132 { | 1132 { |
1133 double x = 0.0; | 1133 double x = 0.0; |
(...skipping 22 matching lines...) Expand all Loading... |
1156 | 1156 |
1157 x = ScrollableArea::normalizeNonFiniteScroll(x); | 1157 x = ScrollableArea::normalizeNonFiniteScroll(x); |
1158 y = ScrollableArea::normalizeNonFiniteScroll(y); | 1158 y = ScrollableArea::normalizeNonFiniteScroll(y); |
1159 | 1159 |
1160 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1160 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
1161 // which is never the case for (0, 0). | 1161 // which is never the case for (0, 0). |
1162 if (x || y) | 1162 if (x || y) |
1163 document()->updateLayoutIgnorePendingStylesheets(); | 1163 document()->updateLayoutIgnorePendingStylesheets(); |
1164 | 1164 |
1165 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); | 1165 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); |
1166 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1166 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1167 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAut
o); | 1167 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAut
o); |
1168 } | 1168 } |
1169 | 1169 |
1170 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const | 1170 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const |
1171 { | 1171 { |
1172 if (!isCurrentlyDisplayedInFrame()) | 1172 if (!isCurrentlyDisplayedInFrame()) |
1173 return; | 1173 return; |
1174 | 1174 |
1175 FrameView* view = frame()->view(); | 1175 FrameView* view = frame()->view(); |
1176 if (!view) | 1176 if (!view) |
1177 return; | 1177 return; |
1178 | 1178 |
1179 FrameHost* host = frame()->host(); | 1179 FrameHost* host = frame()->host(); |
1180 if (!host) | 1180 if (!host) |
1181 return; | 1181 return; |
1182 | 1182 |
1183 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1183 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
1184 // which is never the case for (0, 0). | 1184 // which is never the case for (0, 0). |
1185 if (!scrollToOptions.hasLeft() | 1185 if (!scrollToOptions.hasLeft() |
1186 || !scrollToOptions.hasTop() | 1186 || !scrollToOptions.hasTop() |
1187 || scrollToOptions.left() | 1187 || scrollToOptions.left() |
1188 || scrollToOptions.top()) { | 1188 || scrollToOptions.top()) { |
1189 document()->updateLayoutIgnorePendingStylesheets(); | 1189 document()->updateLayoutIgnorePendingStylesheets(); |
1190 } | 1190 } |
1191 | 1191 |
1192 double scaledX = 0.0; | 1192 double scaledX = 0.0; |
1193 double scaledY = 0.0; | 1193 double scaledY = 0.0; |
1194 | 1194 |
1195 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->scrollableArea(); | 1195 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1196 | 1196 |
1197 DoublePoint currentOffset = viewport->scrollPositionDouble(); | 1197 DoublePoint currentOffset = viewport->scrollPositionDouble(); |
1198 scaledX = currentOffset.x(); | 1198 scaledX = currentOffset.x(); |
1199 scaledY = currentOffset.y(); | 1199 scaledY = currentOffset.y(); |
1200 | 1200 |
1201 if (scrollToOptions.hasLeft()) | 1201 if (scrollToOptions.hasLeft()) |
1202 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left(
)) * frame()->pageZoomFactor(); | 1202 scaledX = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left(
)) * frame()->pageZoomFactor(); |
1203 | 1203 |
1204 if (scrollToOptions.hasTop()) | 1204 if (scrollToOptions.hasTop()) |
1205 scaledY = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.top()
) * frame()->pageZoomFactor(); | 1205 scaledY = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.top()
) * frame()->pageZoomFactor(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 { | 1519 { |
1520 // If the LocalDOMWindow still has a frame reference, that frame must point | 1520 // If the LocalDOMWindow still has a frame reference, that frame must point |
1521 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1521 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
1522 // where script execution leaks between different LocalDOMWindows. | 1522 // where script execution leaks between different LocalDOMWindows. |
1523 if (m_frameObserver->frame()) | 1523 if (m_frameObserver->frame()) |
1524 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1524 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
1525 return m_frameObserver->frame(); | 1525 return m_frameObserver->frame(); |
1526 } | 1526 } |
1527 | 1527 |
1528 } // namespace blink | 1528 } // namespace blink |
OLD | NEW |