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: third_party/WebKit/Source/core/layout/LayoutBox.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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { 496 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) {
497 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); 497 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment);
498 if (Page* page = frameView->frame().page()) { 498 if (Page* page = frameView->frame().page()) {
499 return page->autoscrollController().autoscrollInProgress() 499 return page->autoscrollController().autoscrollInProgress()
500 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; 500 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff;
501 } 501 }
502 } 502 }
503 return false; 503 return false;
504 } 504 }
505 505
506 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY, ScrollType scrollType) 506 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY, ScrollType scrollType, bool makeVisibl eInVisualViewport)
507 { 507 {
508 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll); 508 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll);
509 // Presumably the same issue as in setScrollTop. See crbug.com/343132. 509 // Presumably the same issue as in setScrollTop. See crbug.com/343132.
510 DisableCompositingQueryAsserts disabler; 510 DisableCompositingQueryAsserts disabler;
511 511
512 LayoutBox* parentBox = nullptr; 512 LayoutBox* parentBox = nullptr;
513 LayoutRect newRect = rect; 513 LayoutRect newRect = rect;
514 514
515 bool restrictedByLineClamp = false; 515 bool restrictedByLineClamp = false;
516 if (parent()) { 516 if (parent()) {
517 parentBox = parent()->enclosingBox(); 517 parentBox = parent()->enclosingBox();
518 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); 518 restrictedByLineClamp = !parent()->style()->lineClamp().isNone();
519 } 519 }
520 520
521 if (hasOverflowClip() && !restrictedByLineClamp) { 521 if (hasOverflowClip() && !restrictedByLineClamp) {
522 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. 522 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
523 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. 523 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
524 newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY , scrollType); 524 newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY , scrollType);
525 } else if (!parentBox && canBeProgramaticallyScrolled()) { 525 } else if (!parentBox && canBeProgramaticallyScrolled()) {
526 if (FrameView* frameView = this->frameView()) { 526 if (FrameView* frameView = this->frameView()) {
527 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); 527 HTMLFrameOwnerElement* ownerElement = document().ownerElement();
528 if (!isDisallowedAutoscroll(ownerElement, frameView)) { 528 if (!isDisallowedAutoscroll(ownerElement, frameView)) {
529 frameView->scrollableArea()->scrollIntoView(rect, alignX, alignY , scrollType); 529 if (makeVisibleInVisualViewport) {
530 530 frameView->scrollableArea()->scrollIntoView(rect, alignX, al ignY, scrollType);
531 } else {
532 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType);
533 }
531 if (ownerElement && ownerElement->layoutObject()) { 534 if (ownerElement && ownerElement->layoutObject()) {
532 if (frameView->safeToPropagateScrollToParent()) { 535 if (frameView->safeToPropagateScrollToParent()) {
533 parentBox = ownerElement->layoutObject()->enclosingBox() ; 536 parentBox = ownerElement->layoutObject()->enclosingBox() ;
534 // FIXME: This doesn't correctly convert the rect to 537 // FIXME: This doesn't correctly convert the rect to
535 // absolute coordinates in the parent. 538 // absolute coordinates in the parent.
536 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x()); 539 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x());
537 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y()); 540 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y());
538 } else { 541 } else {
539 parentBox = nullptr; 542 parentBox = nullptr;
540 } 543 }
541 } 544 }
542 } 545 }
543 } 546 }
544 } 547 }
545 548
546 // If we are fixed-position, it is useless to scroll the parent. 549 // If we are fixed-position, it is useless to scroll the parent.
547 if (hasLayer() && layer()->scrollsWithViewport()) 550 if (hasLayer() && layer()->scrollsWithViewport())
548 return; 551 return;
549 552
550 if (frame()->page()->autoscrollController().autoscrollInProgress()) 553 if (frame()->page()->autoscrollController().autoscrollInProgress())
551 parentBox = enclosingScrollableBox(); 554 parentBox = enclosingScrollableBox();
552 555
553 if (parentBox) 556 if (parentBox)
554 parentBox->scrollRectToVisible(newRect, alignX, alignY, scrollType); 557 parentBox->scrollRectToVisible(newRect, alignX, alignY, scrollType, make VisibleInVisualViewport);
555 } 558 }
556 559
557 void LayoutBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumul atedOffset) const 560 void LayoutBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumul atedOffset) const
558 { 561 {
559 rects.append(pixelSnappedIntRect(accumulatedOffset, size())); 562 rects.append(pixelSnappedIntRect(accumulatedOffset, size()));
560 } 563 }
561 564
562 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const 565 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
563 { 566 {
564 quads.append(localToAbsoluteQuad(FloatRect(0, 0, m_frameRect.width().toFloat (), m_frameRect.height().toFloat()), 0 /* mode */, wasFixed)); 567 quads.append(localToAbsoluteQuad(FloatRect(0, 0, m_frameRect.width().toFloat (), m_frameRect.height().toFloat()), 0 /* mode */, wasFixed));
(...skipping 4273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4838 StyleImage* borderImage = style()->borderImage().image(); 4841 StyleImage* borderImage = style()->borderImage().image();
4839 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); 4842 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded();
4840 } 4843 }
4841 4844
4842 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const 4845 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const
4843 { 4846 {
4844 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; 4847 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr;
4845 } 4848 }
4846 4849
4847 } // namespace blink 4850 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698