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

Side by Side Diff: Source/core/frame/FrameView.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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1401 }
1402 1402
1403 hostWindow()->invalidateRect(updateRect); 1403 hostWindow()->invalidateRect(updateRect);
1404 } 1404 }
1405 1405
1406 void FrameView::restoreScrollbar() 1406 void FrameView::restoreScrollbar()
1407 { 1407 {
1408 setScrollbarsSuppressed(false); 1408 setScrollbarsSuppressed(false);
1409 } 1409 }
1410 1410
1411 bool FrameView::scrollToFragment(const KURL& url) 1411 bool FrameView::processUrlFragment(const KURL& url, UrlFragmentBehavior behavior )
1412 { 1412 {
1413 // If our URL has no ref, then we have no place we need to jump to. 1413 // If our URL has no ref, then we have no place we need to jump to.
1414 // OTOH If CSS target was set previously, we want to set it to 0, recalc 1414 // OTOH If CSS target was set previously, we want to set it to 0, recalc
1415 // and possibly paint invalidation because :target pseudo class may have bee n 1415 // and possibly paint invalidation because :target pseudo class may have bee n
1416 // set (see bug 11321). 1416 // set (see bug 11321).
1417 // Similarly for svg, if we had a previous svgView() then we need to reset 1417 // Similarly for svg, if we had a previous svgView() then we need to reset
1418 // the initial view if we don't have a fragment. 1418 // the initial view if we don't have a fragment.
1419 if (!url.hasFragmentIdentifier() && !m_frame->document()->cssTarget() && !m_ frame->document()->isSVGDocument()) 1419 if (!url.hasFragmentIdentifier() && !m_frame->document()->cssTarget() && !m_ frame->document()->isSVGDocument())
1420 return false; 1420 return false;
1421 1421
1422 String fragmentIdentifier = url.fragmentIdentifier(); 1422 String fragmentIdentifier = url.fragmentIdentifier();
1423 if (scrollToAnchor(fragmentIdentifier)) 1423 if (processUrlFragmentHelper(fragmentIdentifier, behavior))
1424 return true; 1424 return true;
1425 1425
1426 // Try again after decoding the ref, based on the document's encoding. 1426 // Try again after decoding the ref, based on the document's encoding.
1427 if (m_frame->document()->encoding().isValid()) 1427 if (m_frame->document()->encoding().isValid())
1428 return scrollToAnchor(decodeURLEscapeSequences(fragmentIdentifier, m_fra me->document()->encoding())); 1428 return processUrlFragmentHelper(decodeURLEscapeSequences(fragmentIdentif ier, m_frame->document()->encoding()), behavior);
1429 1429
1430 return false; 1430 return false;
1431 } 1431 }
1432 1432
1433 bool FrameView::scrollToAnchor(const String& name) 1433 bool FrameView::processUrlFragmentHelper(const String& name, UrlFragmentBehavior behavior)
1434 { 1434 {
1435 ASSERT(m_frame->document()); 1435 ASSERT(m_frame->document());
1436 1436
1437 if (!m_frame->document()->isRenderingReady()) { 1437 if (behavior == UrlFragmentScroll && !m_frame->document()->isRenderingReady( )) {
1438 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true); 1438 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true);
1439 return false; 1439 return false;
1440 } 1440 }
1441 1441
1442 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false); 1442 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false);
1443 1443
1444 Element* anchorNode = m_frame->document()->findAnchor(name); 1444 Element* anchorNode = m_frame->document()->findAnchor(name);
1445 1445
1446 // Setting to null will clear the current target. 1446 // Setting to null will clear the current target.
1447 m_frame->document()->setCSSTarget(anchorNode); 1447 m_frame->document()->setCSSTarget(anchorNode);
1448 1448
1449 if (m_frame->document()->isSVGDocument()) { 1449 if (m_frame->document()->isSVGDocument()) {
1450 if (SVGSVGElement* svg = SVGDocumentExtensions::rootElement(*m_frame->do cument())) { 1450 if (SVGSVGElement* svg = SVGDocumentExtensions::rootElement(*m_frame->do cument())) {
1451 svg->setupInitialView(name, anchorNode); 1451 svg->setupInitialView(name, anchorNode);
1452 if (!anchorNode) 1452 if (!anchorNode)
1453 return true; 1453 return true;
1454 } 1454 }
1455 } 1455 }
1456 1456
1457 // Implement the rule that "" and "top" both mean top of page as in other br owsers. 1457 // Implement the rule that "" and "top" both mean top of page as in other br owsers.
1458 if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top"))) 1458 if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top")))
1459 return false; 1459 return false;
1460 1460
1461 maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document()); 1461 if (behavior == UrlFragmentScroll)
1462 maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNod e) : m_frame->document());
1462 1463
1463 // If the anchor accepts keyboard focus, move focus there to aid users relyi ng on keyboard navigation. 1464 // If the anchor accepts keyboard focus, move focus there to aid users relyi ng on keyboard navigation.
1464 // If anchorNode is not focusable, setFocusedElement() will still clear focu s, which matches the behavior of other browsers. 1465 // If anchorNode is not focusable, setFocusedElement() will still clear focu s, which matches the behavior of other browsers.
1465 if (anchorNode) 1466 if (anchorNode)
1466 m_frame->document()->setFocusedElement(anchorNode); 1467 m_frame->document()->setFocusedElement(anchorNode);
1467 1468
1468 return true; 1469 return true;
1469 } 1470 }
1470 1471
1471 void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode) 1472 void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode)
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4006 4007
4007 if (!graphicsLayer) 4008 if (!graphicsLayer)
4008 return; 4009 return;
4009 4010
4010 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect); 4011 DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(localFrame->contentL ayoutObject(), paintInvalidationContainer, viewRect);
4011 4012
4012 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect))); 4013 graphicsLayerTimingRequests.add(graphicsLayer, Vector<std::pair<int64_t, Web Rect>>()).storedValue->value.append(std::make_pair(m_frame->frameID(), enclosing IntRect(viewRect)));
4013 } 4014 }
4014 4015
4015 } // namespace blink 4016 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698