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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1424313003: element.scrollIntoView only scrolls the layout viewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback Created 5 years, 1 month 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 return isHTMLElement() && document().isHTMLDocument(); 468 return isHTMLElement() && document().isHTMLDocument();
469 } 469 }
470 470
471 void Element::scrollIntoView(bool alignToTop) 471 void Element::scrollIntoView(bool alignToTop)
472 { 472 {
473 document().updateLayoutIgnorePendingStylesheets(); 473 document().updateLayoutIgnorePendingStylesheets();
474 474
475 if (!layoutObject()) 475 if (!layoutObject())
476 return; 476 return;
477 477
478 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua lViewport();
479
478 LayoutRect bounds = boundingBox(); 480 LayoutRect bounds = boundingBox();
479 // Align to the top / bottom and to the closest edge. 481 // Align to the top / bottom and to the closest edge.
480 if (alignToTop) 482 if (alignToTop)
481 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignTopAlways); 483 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignTopAlways, ProgrammaticScroll, makeVisibleInVisu alViewport);
482 else 484 else
483 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignBottomAlways); 485 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignBottomAlways, ProgrammaticScroll, makeVisibleInV isualViewport);
484 } 486 }
485 487
486 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) 488 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
487 { 489 {
488 document().updateLayoutIgnorePendingStylesheets(); 490 document().updateLayoutIgnorePendingStylesheets();
489 491
490 if (!layoutObject()) 492 if (!layoutObject())
491 return; 493 return;
492 494
495 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua lViewport();
496
493 LayoutRect bounds = boundingBox(); 497 LayoutRect bounds = boundingBox();
494 if (centerIfNeeded) 498 if (centerIfNeeded)
495 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter IfNeeded, ScrollAlignment::alignCenterIfNeeded); 499 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter IfNeeded, ScrollAlignment::alignCenterIfNeeded, ProgrammaticScroll, makeVisibleI nVisualViewport);
496 else 500 else
497 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignToEdgeIfNeeded); 501 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ProgrammaticScroll, makeVisibleI nVisualViewport);
498 } 502 }
499 503
500 void Element::setDistributeScroll(ScrollStateCallback* scrollStateCallback, Stri ng nativeScrollBehavior) 504 void Element::setDistributeScroll(ScrollStateCallback* scrollStateCallback, Stri ng nativeScrollBehavior)
501 { 505 {
502 scrollStateCallback->setNativeScrollBehavior(ScrollStateCallback::toNativeSc rollBehavior(nativeScrollBehavior)); 506 scrollStateCallback->setNativeScrollBehavior(ScrollStateCallback::toNativeSc rollBehavior(nativeScrollBehavior));
503 scrollCustomizationCallbacks().setDistributeScroll(this, scrollStateCallback ); 507 scrollCustomizationCallbacks().setDistributeScroll(this, scrollStateCallback );
504 } 508 }
505 509
506 void Element::setApplyScroll(ScrollStateCallback* scrollStateCallback, String na tiveScrollBehavior) 510 void Element::setApplyScroll(ScrollStateCallback* scrollStateCallback, String na tiveScrollBehavior)
507 { 511 {
(...skipping 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after
3569 { 3573 {
3570 #if ENABLE(OILPAN) 3574 #if ENABLE(OILPAN)
3571 if (hasRareData()) 3575 if (hasRareData())
3572 visitor->trace(elementRareData()); 3576 visitor->trace(elementRareData());
3573 visitor->trace(m_elementData); 3577 visitor->trace(m_elementData);
3574 #endif 3578 #endif
3575 ContainerNode::trace(visitor); 3579 ContainerNode::trace(visitor);
3576 } 3580 }
3577 3581
3578 } // namespace blink 3582 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698