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

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

Issue 1165233002: Apply :target styling even if fragment scrolling was skipped. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 client()->dispatchDidFinishDocumentLoad(); 417 client()->dispatchDidFinishDocumentLoad();
418 418
419 checkCompleted(); 419 checkCompleted();
420 420
421 if (!m_frame->view()) 421 if (!m_frame->view())
422 return; // We are being destroyed by something checkCompleted called. 422 return; // We are being destroyed by something checkCompleted called.
423 423
424 // Check if the scrollbars are really needed for the content. 424 // Check if the scrollbars are really needed for the content.
425 // If not, remove them, relayout, and repaint. 425 // If not, remove them, relayout, and repaint.
426 m_frame->view()->restoreScrollbar(); 426 m_frame->view()->restoreScrollbar();
427 if (!documentLoader()->initialScrollState().didRestoreFromHistory) 427 processFragment(m_frame->document()->url(), false);
428 scrollToFragmentWithParentBoundary(m_frame->document()->url());
429 } 428 }
430 429
431 static bool allDescendantsAreComplete(Frame* frame) 430 static bool allDescendantsAreComplete(Frame* frame)
432 { 431 {
433 for (Frame* child = frame->tree().firstChild(); child; child = child->tree() .traverseNext(frame)) { 432 for (Frame* child = frame->tree().firstChild(); child; child = child->tree() .traverseNext(frame)) {
434 if (child->isLoading()) 433 if (child->isLoading())
435 return false; 434 return false;
436 } 435 }
437 return true; 436 return true;
438 } 437 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 m_frame->eventHandler().stopAutoscroll(); 617 m_frame->eventHandler().stopAutoscroll();
619 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); 618 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url);
620 } 619 }
621 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); 620 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect);
622 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, ScrollRestorationAuto, type); 621 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, ScrollRestorationAuto, type);
623 622
624 m_frame->view()->setWasScrolledByUser(false); 623 m_frame->view()->setWasScrolledByUser(false);
625 624
626 // We need to scroll to the fragment whether or not a hash change occurred, since 625 // We need to scroll to the fragment whether or not a hash change occurred, since
627 // the user might have scrolled since the previous navigation. 626 // the user might have scrolled since the previous navigation.
628 scrollToFragmentWithParentBoundary(url); 627 processFragment(url, true);
629 checkCompleted(); 628 checkCompleted();
630 629
631 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize dScriptValue::nullValue()); 630 m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : Serialize dScriptValue::nullValue());
632 } 631 }
633 632
634 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen dReferrer shouldSendReferrer, Document* originDocument) 633 void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSen dReferrer shouldSendReferrer, Document* originDocument)
635 { 634 {
636 if (!originDocument) 635 if (!originDocument)
637 return; 636 return;
638 // FIXME: This should be an assertion, but there's some plugin code in the c hromium repo 637 // FIXME: This should be an assertion, but there's some plugin code in the c hromium repo
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 && loadType != FrameLoadTypeReload 1138 && loadType != FrameLoadTypeReload
1140 && loadType != FrameLoadTypeSame 1139 && loadType != FrameLoadTypeSame
1141 && loadType != FrameLoadTypeBackForward 1140 && loadType != FrameLoadTypeBackForward
1142 && url.hasFragmentIdentifier() 1141 && url.hasFragmentIdentifier()
1143 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url) 1142 && equalIgnoringFragmentIdentifier(m_frame->document()->url(), url)
1144 // We don't want to just scroll if a link from within a 1143 // We don't want to just scroll if a link from within a
1145 // frameset is trying to reload the frameset into _top. 1144 // frameset is trying to reload the frameset into _top.
1146 && !m_frame->document()->isFrameSet(); 1145 && !m_frame->document()->isFrameSet();
1147 } 1146 }
1148 1147
1149 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) 1148 void FrameLoader::processFragment(const KURL& url, bool isSameDocument)
1150 { 1149 {
1151 FrameView* view = m_frame->view(); 1150 FrameView* view = m_frame->view();
1152 if (!view) 1151 if (!view)
1153 return; 1152 return;
1154 1153
1155 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack. 1154 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack.
1156 RefPtrWillBeRawPtr<Frame> boundaryFrame = url.hasFragmentIdentifier() ? m_fr ame->findUnsafeParentScrollPropagationBoundary() : 0; 1155 RefPtrWillBeRawPtr<Frame> boundaryFrame = url.hasFragmentIdentifier() ? m_fr ame->findUnsafeParentScrollPropagationBoundary() : 0;
1157 1156
1158 // FIXME: Handle RemoteFrames 1157 // FIXME: Handle RemoteFrames
1159 if (boundaryFrame && boundaryFrame->isLocalFrame()) 1158 if (boundaryFrame && boundaryFrame->isLocalFrame())
1160 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar ent(false); 1159 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar ent(false);
1161 1160
1162 view->scrollToFragment(url); 1161 view->processUrlFragment(url,
1162 !isSameDocument && documentLoader()->initialScrollState().didRestoreFrom History ?
1163 FrameView::UrlFragmentDontScroll : FrameView::UrlFragmentScroll);
1163 1164
1164 if (boundaryFrame && boundaryFrame->isLocalFrame()) 1165 if (boundaryFrame && boundaryFrame->isLocalFrame())
1165 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar ent(true); 1166 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar ent(true);
1166 } 1167 }
1167 1168
1168 bool FrameLoader::shouldClose() 1169 bool FrameLoader::shouldClose()
1169 { 1170 {
1170 Page* page = m_frame->page(); 1171 Page* page = m_frame->page();
1171 if (!page || !page->chromeClient().canOpenBeforeUnloadConfirmPanel()) 1172 if (!page || !page->chromeClient().canOpenBeforeUnloadConfirmPanel())
1172 return true; 1173 return true;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 // FIXME: We need a way to propagate insecure requests policy flags to 1445 // FIXME: We need a way to propagate insecure requests policy flags to
1445 // out-of-process frames. For now, we'll always use default behavior. 1446 // out-of-process frames. For now, we'll always use default behavior.
1446 if (!parentFrame->isLocalFrame()) 1447 if (!parentFrame->isLocalFrame())
1447 return nullptr; 1448 return nullptr;
1448 1449
1449 ASSERT(toLocalFrame(parentFrame)->document()); 1450 ASSERT(toLocalFrame(parentFrame)->document());
1450 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1451 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1451 } 1452 }
1452 1453
1453 } // namespace blink 1454 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698