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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2339653003: Enable the scroll of empty elements by setting the rect's size to 1. (Closed)
Patch Set: Rebase and format Created 4 years, 3 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) 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 558 }
559 return false; 559 return false;
560 } 560 }
561 561
562 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY, ScrollType scrollType, bool makeVisibl eInVisualViewport) 562 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY, ScrollType scrollType, bool makeVisibl eInVisualViewport)
563 { 563 {
564 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll); 564 ASSERT(scrollType == ProgrammaticScroll || scrollType == UserScroll);
565 // Presumably the same issue as in setScrollTop. See crbug.com/343132. 565 // Presumably the same issue as in setScrollTop. See crbug.com/343132.
566 DisableCompositingQueryAsserts disabler; 566 DisableCompositingQueryAsserts disabler;
567 567
568 LayoutRect rectToScroll = rect;
569 if (rectToScroll.width() <= 0)
570 rectToScroll.setWidth(LayoutUnit(1));
571 if (rectToScroll.height() <= 0)
572 rectToScroll.setHeight(LayoutUnit(1));
573
568 LayoutBox* parentBox = nullptr; 574 LayoutBox* parentBox = nullptr;
569 LayoutRect newRect = rect; 575 LayoutRect newRect = rectToScroll;
570 576
571 bool restrictedByLineClamp = false; 577 bool restrictedByLineClamp = false;
572 if (parent()) { 578 if (parent()) {
573 parentBox = parent()->enclosingBox(); 579 parentBox = parent()->enclosingBox();
574 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); 580 restrictedByLineClamp = !parent()->style()->lineClamp().isNone();
575 } 581 }
576 582
577 if (hasOverflowClip() && !restrictedByLineClamp) { 583 if (hasOverflowClip() && !restrictedByLineClamp) {
578 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. 584 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
579 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. 585 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
580 newRect = getScrollableArea()->scrollIntoView(rect, alignX, alignY, scro llType); 586 newRect = getScrollableArea()->scrollIntoView(rectToScroll, alignX, alig nY, scrollType);
581 if (newRect.isEmpty()) 587 if (newRect.isEmpty())
582 return; 588 return;
583 } else if (!parentBox && canBeProgramaticallyScrolled()) { 589 } else if (!parentBox && canBeProgramaticallyScrolled()) {
584 if (FrameView* frameView = this->frameView()) { 590 if (FrameView* frameView = this->frameView()) {
585 HTMLFrameOwnerElement* ownerElement = document().localOwner(); 591 HTMLFrameOwnerElement* ownerElement = document().localOwner();
586 if (!isDisallowedAutoscroll(ownerElement, frameView)) { 592 if (!isDisallowedAutoscroll(ownerElement, frameView)) {
587 if (makeVisibleInVisualViewport) { 593 if (makeVisibleInVisualViewport) {
588 frameView->getScrollableArea()->scrollIntoView(rect, alignX, alignY, scrollType); 594 frameView->getScrollableArea()->scrollIntoView(rectToScroll, alignX, alignY, scrollType);
589 } else { 595 } else {
590 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType); 596 frameView->layoutViewportScrollableArea()->scrollIntoView(re ctToScroll, alignX, alignY, scrollType);
591 } 597 }
592 if (ownerElement && ownerElement->layoutObject()) { 598 if (ownerElement && ownerElement->layoutObject()) {
593 if (frameView->safeToPropagateScrollToParent()) { 599 if (frameView->safeToPropagateScrollToParent()) {
594 parentBox = ownerElement->layoutObject()->enclosingBox() ; 600 parentBox = ownerElement->layoutObject()->enclosingBox() ;
595 LayoutView* parentView = ownerElement->layoutObject()->v iew(); 601 LayoutView* parentView = ownerElement->layoutObject()->v iew();
596 newRect = enclosingLayoutRect(view()->localToAncestorQua d(FloatRect(rect), parentView, UseTransforms | TraverseDocumentBoundaries).bound ingBox()); 602 newRect = enclosingLayoutRect(view()->localToAncestorQua d(FloatRect(rectToScroll), parentView, UseTransforms | TraverseDocumentBoundarie s).boundingBox());
597 } else { 603 } else {
598 parentBox = nullptr; 604 parentBox = nullptr;
599 } 605 }
600 } 606 }
601 } 607 }
602 } 608 }
603 } 609 }
604 610
605 // If we are fixed-position, it is useless to scroll the parent. 611 // If we are fixed-position, it is useless to scroll the parent.
606 if (hasLayer() && layer()->scrollsWithViewport()) 612 if (hasLayer() && layer()->scrollsWithViewport())
(...skipping 4243 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 m_rareData->m_snapAreas->remove(&snapArea); 4856 m_rareData->m_snapAreas->remove(&snapArea);
4851 } 4857 }
4852 } 4858 }
4853 4859
4854 SnapAreaSet* LayoutBox::snapAreas() const 4860 SnapAreaSet* LayoutBox::snapAreas() const
4855 { 4861 {
4856 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4862 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4857 } 4863 }
4858 4864
4859 } // namespace blink 4865 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698