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

Side by Side Diff: Source/core/loader/FrameLoader.cpp

Issue 263853008: Added pinch viewport offset to history item. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/core/frame/PinchViewport.cpp ('k') | Source/core/loader/HistoryItem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/dom/Element.h" 43 #include "core/dom/Element.h"
44 #include "core/dom/ViewportDescription.h" 44 #include "core/dom/ViewportDescription.h"
45 #include "core/editing/Editor.h" 45 #include "core/editing/Editor.h"
46 #include "core/editing/UndoStack.h" 46 #include "core/editing/UndoStack.h"
47 #include "core/events/Event.h" 47 #include "core/events/Event.h"
48 #include "core/events/PageTransitionEvent.h" 48 #include "core/events/PageTransitionEvent.h"
49 #include "core/fetch/FetchContext.h" 49 #include "core/fetch/FetchContext.h"
50 #include "core/fetch/ResourceFetcher.h" 50 #include "core/fetch/ResourceFetcher.h"
51 #include "core/fetch/ResourceLoader.h" 51 #include "core/fetch/ResourceLoader.h"
52 #include "core/frame/DOMWindow.h" 52 #include "core/frame/DOMWindow.h"
53 #include "core/frame/FrameHost.h"
53 #include "core/frame/FrameView.h" 54 #include "core/frame/FrameView.h"
54 #include "core/frame/LocalFrame.h" 55 #include "core/frame/LocalFrame.h"
56 #include "core/frame/PinchViewport.h"
55 #include "core/frame/csp/ContentSecurityPolicy.h" 57 #include "core/frame/csp/ContentSecurityPolicy.h"
56 #include "core/html/HTMLFormElement.h" 58 #include "core/html/HTMLFormElement.h"
57 #include "core/html/HTMLFrameOwnerElement.h" 59 #include "core/html/HTMLFrameOwnerElement.h"
58 #include "core/html/parser/HTMLParserIdioms.h" 60 #include "core/html/parser/HTMLParserIdioms.h"
59 #include "core/inspector/InspectorController.h" 61 #include "core/inspector/InspectorController.h"
60 #include "core/inspector/InspectorInstrumentation.h" 62 #include "core/inspector/InspectorInstrumentation.h"
61 #include "core/loader/DocumentLoadTiming.h" 63 #include "core/loader/DocumentLoadTiming.h"
62 #include "core/loader/DocumentLoader.h" 64 #include "core/loader/DocumentLoader.h"
63 #include "core/loader/FormState.h" 65 #include "core/loader/FormState.h"
64 #include "core/loader/FormSubmission.h" 66 #include "core/loader/FormSubmission.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void FrameLoader::saveScrollState() 179 void FrameLoader::saveScrollState()
178 { 180 {
179 if (!m_currentItem || !m_frame->view()) 181 if (!m_currentItem || !m_frame->view())
180 return; 182 return;
181 183
182 // Shouldn't clobber anything if we might still restore later. 184 // Shouldn't clobber anything if we might still restore later.
183 if (needsHistoryItemRestore(m_loadType) && !m_frame->view()->wasScrolledByUs er()) 185 if (needsHistoryItemRestore(m_loadType) && !m_frame->view()->wasScrolledByUs er())
184 return; 186 return;
185 187
186 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition()); 188 m_currentItem->setScrollPoint(m_frame->view()->scrollPosition());
189
190 if (m_frame->settings()->pinchVirtualViewportEnabled())
191 m_currentItem->setPinchViewportScrollPoint(m_frame->host()->pinchViewpor t().visibleRect().location());
192 else
193 m_currentItem->setPinchViewportScrollPoint(FloatPoint(-1, -1));
194
187 if (m_frame->isMainFrame() && !m_frame->page()->inspectorController().device EmulationEnabled()) 195 if (m_frame->isMainFrame() && !m_frame->page()->inspectorController().device EmulationEnabled())
188 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); 196 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor());
189 197
190 m_client->didUpdateCurrentHistoryItem(); 198 m_client->didUpdateCurrentHistoryItem();
191 } 199 }
192 200
193 void FrameLoader::clearScrollPositionAndViewState() 201 void FrameLoader::clearScrollPositionAndViewState()
194 { 202 {
195 ASSERT(m_frame->isMainFrame()); 203 ASSERT(m_frame->isMainFrame());
196 if (!m_currentItem) 204 if (!m_currentItem)
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 return; 993 return;
986 994
987 if (!needsHistoryItemRestore(m_loadType)) 995 if (!needsHistoryItemRestore(m_loadType))
988 return; 996 return;
989 997
990 // This tries to balance 1. restoring as soon as possible, 2. detecting 998 // This tries to balance 1. restoring as soon as possible, 2. detecting
991 // clamping to avoid repeatedly popping the scroll position down as the 999 // clamping to avoid repeatedly popping the scroll position down as the
992 // page height increases, 3. ignore clamp detection after load completes 1000 // page height increases, 3. ignore clamp detection after load completes
993 // because that may be because the page will never reach its previous 1001 // because that may be because the page will never reach its previous
994 // height. 1002 // height.
995 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr ollPoint(), m_currentItem->pageScaleFactor()) == m_currentItem->scrollPoint(); 1003 float mainFrameScale = m_frame->settings()->pinchVirtualViewportEnabled() ? 1 : m_currentItem->pageScaleFactor();
1004 bool canRestoreWithoutClamping = view->clampOffsetAtScale(m_currentItem->scr ollPoint(), mainFrameScale) == m_currentItem->scrollPoint();
996 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto reWithoutClamping || m_state == FrameStateComplete); 1005 bool canRestoreWithoutAnnoyingUser = !view->wasScrolledByUser() && (canResto reWithoutClamping || m_state == FrameStateComplete);
997 if (!canRestoreWithoutAnnoyingUser) 1006 if (!canRestoreWithoutAnnoyingUser)
998 return; 1007 return;
999 1008
1000 if (m_frame->isMainFrame() && m_currentItem->pageScaleFactor()) 1009 if (m_frame->isMainFrame() && m_currentItem->pageScaleFactor()) {
1001 m_frame->page()->setPageScaleFactor(m_currentItem->pageScaleFactor(), m_ currentItem->scrollPoint()); 1010 FloatPoint pinchViewportOffset(m_currentItem->pinchViewportScrollPoint() );
1002 else 1011 IntPoint frameScrollOffset(m_currentItem->scrollPoint());
1012
1013 m_frame->page()->setPageScaleFactor(m_currentItem->pageScaleFactor(), fr ameScrollOffset);
1014
1015 if (m_frame->document()->settings()->pinchVirtualViewportEnabled()) {
1016 // If the pinch viewport's offset is (-1, -1) it means the history i tem
1017 // is an old version of HistoryItem so distribute the scroll between
1018 // the main frame and the pinch viewport as best as we can.
1019 // FIXME(bokan): This legacy distribution can be removed once the vi rtual viewport
1020 // pinch path is enabled on all platforms for at least one release.
1021 if (pinchViewportOffset.x() == -1 && pinchViewportOffset.y() == -1)
1022 pinchViewportOffset = FloatPoint(frameScrollOffset - view->scrol lPosition());
1023
1024 m_frame->host()->pinchViewport().setLocation(pinchViewportOffset);
1025 }
1026 } else {
1003 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ; 1027 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ;
1028 }
1004 1029
1005 if (m_frame->isMainFrame()) { 1030 if (m_frame->isMainFrame()) {
1006 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) 1031 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator())
1007 scrollingCoordinator->frameViewRootLayerDidChange(view); 1032 scrollingCoordinator->frameViewRootLayerDidChange(view);
1008 } 1033 }
1009 } 1034 }
1010 1035
1011 void FrameLoader::detachChildren() 1036 void FrameLoader::detachChildren()
1012 { 1037 {
1013 typedef Vector<RefPtr<LocalFrame> > FrameVector; 1038 typedef Vector<RefPtr<LocalFrame> > FrameVector;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 { 1430 {
1406 SandboxFlags flags = m_forcedSandboxFlags; 1431 SandboxFlags flags = m_forcedSandboxFlags;
1407 if (LocalFrame* parentFrame = m_frame->tree().parent()) 1432 if (LocalFrame* parentFrame = m_frame->tree().parent())
1408 flags |= parentFrame->document()->sandboxFlags(); 1433 flags |= parentFrame->document()->sandboxFlags();
1409 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) 1434 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
1410 flags |= ownerElement->sandboxFlags(); 1435 flags |= ownerElement->sandboxFlags();
1411 return flags; 1436 return flags;
1412 } 1437 }
1413 1438
1414 } // namespace WebCore 1439 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/PinchViewport.cpp ('k') | Source/core/loader/HistoryItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698