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

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: Feedback addressed + small fix for broken unit test 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
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->document()->settings()->pinchVirtualViewportEnabled())
abarth-chromium 2014/05/09 14:11:23 m_frame->settings()
bokan 2014/05/09 14:32:57 Done.
191 m_currentItem->setPinchViewportScrollPoint(m_frame->host()->pinchViewpor t().visibleRect().location());
192 else
193 m_currentItem->setPinchViewportScrollPoint(FloatPoint(-1, -1));
abarth-chromium 2014/05/09 14:11:23 Can we use something other than (-1, -1) here? Th
bokan 2014/05/09 14:32:57 It's not a valid value for the pinch viewport's sc
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->document()->settings()->pinchVirtualViewport Enabled() ? 1 : m_currentItem->pageScaleFactor();
abarth-chromium 2014/05/09 14:11:23 m_frame->settings()
bokan 2014/05/09 14:32:57 Done.
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 if (pinchViewportOffset.x() == -1 && pinchViewportOffset.y() == -1)
abarth-chromium 2014/05/09 14:11:23 Again, please don't use in-band signaling.
1020 pinchViewportOffset = IntPoint(frameScrollOffset - view->scrollP osition());
abarth-chromium 2014/05/09 14:11:23 Why an IntPoint?
bokan 2014/05/09 14:32:57 Done. Changed to FloatPoint.
1021
1022 m_frame->host()->pinchViewport().setLocation(pinchViewportOffset);
1023 }
1024 } else {
1003 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ; 1025 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ;
1026 }
1004 1027
1005 if (m_frame->isMainFrame()) { 1028 if (m_frame->isMainFrame()) {
1006 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) 1029 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator())
1007 scrollingCoordinator->frameViewRootLayerDidChange(view); 1030 scrollingCoordinator->frameViewRootLayerDidChange(view);
1008 } 1031 }
1009 } 1032 }
1010 1033
1011 void FrameLoader::detachChildren() 1034 void FrameLoader::detachChildren()
1012 { 1035 {
1013 typedef Vector<RefPtr<LocalFrame> > FrameVector; 1036 typedef Vector<RefPtr<LocalFrame> > FrameVector;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 { 1427 {
1405 SandboxFlags flags = m_forcedSandboxFlags; 1428 SandboxFlags flags = m_forcedSandboxFlags;
1406 if (LocalFrame* parentFrame = m_frame->tree().parent()) 1429 if (LocalFrame* parentFrame = m_frame->tree().parent())
1407 flags |= parentFrame->document()->sandboxFlags(); 1430 flags |= parentFrame->document()->sandboxFlags();
1408 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) 1431 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
1409 flags |= ownerElement->sandboxFlags(); 1432 flags |= ownerElement->sandboxFlags();
1410 return flags; 1433 return flags;
1411 } 1434 }
1412 1435
1413 } // namespace WebCore 1436 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698