OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
9 * | 9 * |
10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 #include "core/dom/Document.h" | 42 #include "core/dom/Document.h" |
43 #include "core/dom/Element.h" | 43 #include "core/dom/Element.h" |
44 #include "core/editing/Editor.h" | 44 #include "core/editing/Editor.h" |
45 #include "core/editing/UndoStack.h" | 45 #include "core/editing/UndoStack.h" |
46 #include "core/events/Event.h" | 46 #include "core/events/Event.h" |
47 #include "core/events/PageTransitionEvent.h" | 47 #include "core/events/PageTransitionEvent.h" |
48 #include "core/fetch/FetchContext.h" | 48 #include "core/fetch/FetchContext.h" |
49 #include "core/fetch/ResourceFetcher.h" | 49 #include "core/fetch/ResourceFetcher.h" |
50 #include "core/fetch/ResourceLoader.h" | 50 #include "core/fetch/ResourceLoader.h" |
51 #include "core/frame/DOMWindow.h" | 51 #include "core/frame/DOMWindow.h" |
52 #include "core/frame/FrameHost.h" | |
52 #include "core/frame/FrameView.h" | 53 #include "core/frame/FrameView.h" |
53 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
55 #include "core/frame/PinchViewport.h" | |
54 #include "core/frame/csp/ContentSecurityPolicy.h" | 56 #include "core/frame/csp/ContentSecurityPolicy.h" |
55 #include "core/html/HTMLFormElement.h" | 57 #include "core/html/HTMLFormElement.h" |
56 #include "core/html/HTMLFrameOwnerElement.h" | 58 #include "core/html/HTMLFrameOwnerElement.h" |
57 #include "core/html/parser/HTMLParserIdioms.h" | 59 #include "core/html/parser/HTMLParserIdioms.h" |
58 #include "core/inspector/InspectorController.h" | 60 #include "core/inspector/InspectorController.h" |
59 #include "core/inspector/InspectorInstrumentation.h" | 61 #include "core/inspector/InspectorInstrumentation.h" |
60 #include "core/loader/DocumentLoadTiming.h" | 62 #include "core/loader/DocumentLoadTiming.h" |
61 #include "core/loader/DocumentLoader.h" | 63 #include "core/loader/DocumentLoader.h" |
62 #include "core/loader/FormState.h" | 64 #include "core/loader/FormState.h" |
63 #include "core/loader/FormSubmission.h" | 65 #include "core/loader/FormSubmission.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 void FrameLoader::saveScrollState() | 178 void FrameLoader::saveScrollState() |
177 { | 179 { |
178 if (!m_currentItem || !m_frame->view()) | 180 if (!m_currentItem || !m_frame->view()) |
179 return; | 181 return; |
180 | 182 |
181 // Shouldn't clobber anything if we might still restore later. | 183 // Shouldn't clobber anything if we might still restore later. |
182 if (needsHistoryItemRestore(m_loadType) && !m_frame->view()->wasScrolledByUs er()) | 184 if (needsHistoryItemRestore(m_loadType) && !m_frame->view()->wasScrolledByUs er()) |
183 return; | 185 return; |
184 | 186 |
185 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition()); | 187 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition()); |
188 | |
189 if (m_frame->document()->settings()->pinchVirtualViewportEnabled()) | |
190 m_currentItem->setPinchViewportScrollPoint(m_frame->host()->pinchViewpor t().visibleRect().location()); | |
191 else | |
192 m_currentItem->setPinchViewportScrollPoint(FloatPoint(-1, -1)); | |
193 | |
186 if (m_frame->isMainFrame() && !m_frame->page()->inspectorController().device EmulationEnabled()) | 194 if (m_frame->isMainFrame() && !m_frame->page()->inspectorController().device EmulationEnabled()) |
187 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); | 195 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); |
188 | 196 |
189 m_client->didUpdateCurrentHistoryItem(); | 197 m_client->didUpdateCurrentHistoryItem(); |
190 } | 198 } |
191 | 199 |
192 void FrameLoader::clearScrollPositionAndViewState() | 200 void FrameLoader::clearScrollPositionAndViewState() |
193 { | 201 { |
194 ASSERT(m_frame->isMainFrame()); | 202 ASSERT(m_frame->isMainFrame()); |
195 if (!m_currentItem) | 203 if (!m_currentItem) |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
979 return; | 987 return; |
980 | 988 |
981 if (!needsHistoryItemRestore(m_loadType)) | 989 if (!needsHistoryItemRestore(m_loadType)) |
982 return; | 990 return; |
983 | 991 |
984 // This tries to balance 1. restoring as soon as possible, 2. detecting | 992 // This tries to balance 1. restoring as soon as possible, 2. detecting |
985 // clamping to avoid repeatedly popping the scroll position down as the | 993 // clamping to avoid repeatedly popping the scroll position down as the |
986 // page height increases, 3. ignore clamp detection after load completes | 994 // page height increases, 3. ignore clamp detection after load completes |
987 // because that may be because the page will never reach its previous | 995 // because that may be because the page will never reach its previous |
988 // height. | 996 // height. |
989 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr ollPoint(), m_currentItem->pageScaleFactor()) == m_currentItem->scrollPoint(); | 997 float mainFrameScale = m_frame->document()->settings()->pinchVirtualViewport Enabled() ? 1 : m_currentItem->pageScaleFactor(); |
998 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr ollPoint(), mainFrameScale) == m_currentItem->scrollPoint(); | |
990 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto reWithoutClamping || m_state == FrameStateComplete); | 999 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto reWithoutClamping || m_state == FrameStateComplete); |
991 if (!canRestoreWithoutAnnoyingUser) | 1000 if (!canRestoreWithoutAnnoyingUser) |
992 return; | 1001 return; |
993 | 1002 |
994 if (m_frame->isMainFrame() && m_currentItem->pageScaleFactor()) | 1003 if (m_frame->isMainFrame() && m_currentItem->pageScaleFactor()) { |
995 m_frame->page()->setPageScaleFactor(m_currentItem->pageScaleFactor(), m_ currentItem->scrollPoint()); | 1004 FloatPoint pinchViewportOffset(m_currentItem->pinchViewportScrollPoint() ); |
996 else | 1005 IntPoint frameScrollOffset(m_currentItem->scrollPoint()); |
1006 | |
1007 m_frame->page()->setPageScaleFactor(m_currentItem->pageScaleFactor(), fr ameScrollOffset); | |
aelias_OOO_until_Jul13
2014/05/07 08:06:03
In the legacy historyitem case, I think you also n
aelias_OOO_until_Jul13
2014/05/07 08:41:35
Ignore that comment, since I realized it has to al
| |
1008 | |
1009 if (m_frame->document()->settings()->pinchVirtualViewportEnabled()) { | |
1010 // If the pinch viewport's offset is (-1, -1) it means the history i tem | |
1011 // is an old version of HistoryItem so distribute the scroll between | |
1012 // the main frame and the pinch viewport as best as we can. | |
1013 if (pinchViewportOffset.x() == -1 && pinchViewportOffset.y() == -1) | |
1014 pinchViewportOffset = IntPoint(frameScrollOffset - view->scrollP osition()); | |
1015 | |
1016 m_frame->host()->pinchViewport().setLocation(pinchViewportOffset); | |
1017 } | |
1018 } else { | |
997 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ; | 1019 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ; |
1020 } | |
998 | 1021 |
999 if (m_frame->isMainFrame()) { | 1022 if (m_frame->isMainFrame()) { |
1000 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) | 1023 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) |
1001 scrollingCoordinator->frameViewRootLayerDidChange(view); | 1024 scrollingCoordinator->frameViewRootLayerDidChange(view); |
1002 } | 1025 } |
1003 } | 1026 } |
1004 | 1027 |
1005 void FrameLoader::detachChildren() | 1028 void FrameLoader::detachChildren() |
1006 { | 1029 { |
1007 typedef Vector<RefPtr<LocalFrame> > FrameVector; | 1030 typedef Vector<RefPtr<LocalFrame> > FrameVector; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1398 { | 1421 { |
1399 SandboxFlags flags = m_forcedSandboxFlags; | 1422 SandboxFlags flags = m_forcedSandboxFlags; |
1400 if (LocalFrame* parentFrame = m_frame->tree().parent()) | 1423 if (LocalFrame* parentFrame = m_frame->tree().parent()) |
1401 flags |= parentFrame->document()->sandboxFlags(); | 1424 flags |= parentFrame->document()->sandboxFlags(); |
1402 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1425 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
1403 flags |= ownerElement->sandboxFlags(); | 1426 flags |= ownerElement->sandboxFlags(); |
1404 return flags; | 1427 return flags; |
1405 } | 1428 } |
1406 | 1429 |
1407 } // namespace WebCore | 1430 } // namespace WebCore |
OLD | NEW |