OLD | NEW |
---|---|
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = nullptr; | 81 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = nullptr; |
82 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = nullptr; | 82 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = nullptr; |
83 static OverrideSizeMap* gExtraInlineOffsetMap = nullptr; | 83 static OverrideSizeMap* gExtraInlineOffsetMap = nullptr; |
84 static OverrideSizeMap* gExtraBlockOffsetMap = nullptr; | 84 static OverrideSizeMap* gExtraBlockOffsetMap = nullptr; |
85 | 85 |
86 | 86 |
87 // Size of border belt for autoscroll. When mouse pointer in border belt, | 87 // Size of border belt for autoscroll. When mouse pointer in border belt, |
88 // autoscroll is started. | 88 // autoscroll is started. |
89 static const int autoscrollBeltSize = 20; | 89 static const int autoscrollBeltSize = 20; |
90 static const unsigned backgroundObscurationTestMaxDepth = 4; | 90 static const unsigned backgroundObscurationTestMaxDepth = 4; |
91 static const ScrollAlignment alignNoScroll = { ScrollAlignmentNoScroll, ScrollAl ignmentNoScroll, ScrollAlignmentNoScroll }; | |
91 | 92 |
92 LayoutBox::LayoutBox(ContainerNode* node) | 93 LayoutBox::LayoutBox(ContainerNode* node) |
93 : LayoutBoxModelObject(node) | 94 : LayoutBoxModelObject(node) |
94 , m_intrinsicContentLogicalHeight(-1) | 95 , m_intrinsicContentLogicalHeight(-1) |
95 , m_minPreferredLogicalWidth(-1) | 96 , m_minPreferredLogicalWidth(-1) |
96 , m_maxPreferredLogicalWidth(-1) | 97 , m_maxPreferredLogicalWidth(-1) |
97 { | 98 { |
98 setIsBox(); | 99 setIsBox(); |
99 } | 100 } |
100 | 101 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { | 497 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { |
497 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); | 498 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); |
498 if (Page* page = frameView->frame().page()) { | 499 if (Page* page = frameView->frame().page()) { |
499 return page->autoscrollController().autoscrollInProgress() | 500 return page->autoscrollController().autoscrollInProgress() |
500 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; | 501 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; |
501 } | 502 } |
502 } | 503 } |
503 return false; | 504 return false; |
504 } | 505 } |
505 | 506 |
506 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY) | 507 bool LayoutBox::scrollRestrictedByLineClamp() const |
508 { | |
509 return parent() ? !parent()->style()->lineClamp().isNone() : false; | |
510 } | |
511 | |
512 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY, bool programmaticScroll) | |
507 { | 513 { |
508 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 514 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
509 DisableCompositingQueryAsserts disabler; | 515 DisableCompositingQueryAsserts disabler; |
510 | 516 |
511 LayoutBox* parentBox = nullptr; | 517 LayoutBox* parentBox = nullptr; |
512 LayoutRect newRect = rect; | 518 LayoutRect newRect = rect; |
513 | 519 |
514 bool restrictedByLineClamp = false; | |
515 if (parent()) { | 520 if (parent()) { |
516 parentBox = parent()->enclosingBox(); | 521 parentBox = parent()->enclosingBox(); |
517 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | |
518 } | 522 } |
519 | 523 |
520 if (hasOverflowClip() && !restrictedByLineClamp) { | 524 // If the computed style has overflowX/Y set to hidden, we shouldn't scroll |
521 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. | 525 // into view unless its a programmatic scroll. Note that some LayoutObjects |
522 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. | 526 // have overflow:hidden set by default (input fields), and so we need to |
523 newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY ); | 527 // override this behavior subclasses. |
524 } else if (!parentBox && canBeProgramaticallyScrolled()) { | 528 if (programmaticScroll || style()->overflowX() != OHIDDEN || style()->overfl owY() != OHIDDEN) { |
bokan
2015/09/25 22:26:26
Hmm...I don't like that the knowledge of when scro
| |
525 if (FrameView* frameView = this->frameView()) { | 529 ScrollAlignment newAlignX, newAlignY; |
526 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); | 530 newAlignX = !programmaticScroll && style()->overflowX() == OHIDDEN ? ali gnNoScroll : alignX; |
527 if (!isDisallowedAutoscroll(ownerElement, frameView)) { | 531 newAlignY = !programmaticScroll && style()->overflowY() == OHIDDEN ? ali gnNoScroll : alignY; |
528 frameView->scrollableArea()->scrollIntoView(rect, alignX, alignY ); | 532 if (hasOverflowClip() && !scrollRestrictedByLineClamp()) { |
533 // Don't scroll to reveal an overflow layer that is restricted by th e -webkit-line-clamp property. | |
534 // This will prevent us from revealing text hidden by the slider in Safari RSS. | |
535 newRect = layer()->scrollableArea()->scrollIntoView(rect, newAlignX, newAlignY); | |
536 } else if (!parentBox && canBeProgramaticallyScrolled()) { | |
bokan
2015/09/25 22:26:26
canBeProgrammaticallyScrolled seems like it should
| |
537 if (FrameView* frameView = this->frameView()) { | |
538 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); | |
539 if (!isDisallowedAutoscroll(ownerElement, frameView)) { | |
540 frameView->scrollableArea()->scrollIntoView(rect, newAlignX, newAlignY); | |
529 | 541 |
530 if (ownerElement && ownerElement->layoutObject()) { | 542 if (ownerElement && ownerElement->layoutObject()) { |
531 if (frameView->safeToPropagateScrollToParent()) { | 543 if (frameView->safeToPropagateScrollToParent()) { |
532 parentBox = ownerElement->layoutObject()->enclosingBox() ; | 544 parentBox = ownerElement->layoutObject()->enclosingB ox(); |
533 // FIXME: This doesn't correctly convert the rect to | 545 // FIXME: This doesn't correctly convert the rect to |
534 // absolute coordinates in the parent. | 546 // absolute coordinates in the parent. |
535 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x()); | 547 newRect.setX(rect.x() - frameView->scrollX() + frame View->x()); |
536 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y()); | 548 newRect.setY(rect.y() - frameView->scrollY() + frame View->y()); |
537 } else { | 549 } else { |
538 parentBox = nullptr; | 550 parentBox = nullptr; |
551 } | |
539 } | 552 } |
540 } | 553 } |
541 } | 554 } |
542 } | 555 } |
543 } | 556 } |
544 | 557 |
545 // If we are fixed-position, it is useless to scroll the parent. | 558 // If we are fixed-position, it is useless to scroll the parent. |
546 if (hasLayer() && layer()->scrollsWithViewport()) | 559 if (hasLayer() && layer()->scrollsWithViewport()) |
547 return; | 560 return; |
548 | 561 |
549 if (frame()->page()->autoscrollController().autoscrollInProgress()) | 562 if (frame()->page()->autoscrollController().autoscrollInProgress()) |
550 parentBox = enclosingScrollableBox(); | 563 parentBox = enclosingScrollableBox(); |
551 | 564 |
552 if (parentBox) | 565 if (parentBox) |
553 parentBox->scrollRectToVisible(newRect, alignX, alignY); | 566 parentBox->scrollRectToVisible(newRect, alignX, alignY, programmaticScro ll); |
554 } | 567 } |
555 | 568 |
556 void LayoutBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumul atedOffset) const | 569 void LayoutBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumul atedOffset) const |
557 { | 570 { |
558 rects.append(pixelSnappedIntRect(accumulatedOffset, size())); | 571 rects.append(pixelSnappedIntRect(accumulatedOffset, size())); |
559 } | 572 } |
560 | 573 |
561 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const | 574 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const |
562 { | 575 { |
563 quads.append(localToAbsoluteQuad(FloatRect(0, 0, m_frameRect.width().toFloat (), m_frameRect.height().toFloat()), 0 /* mode */, wasFixed)); | 576 quads.append(localToAbsoluteQuad(FloatRect(0, 0, m_frameRect.width().toFloat (), m_frameRect.height().toFloat()), 0 /* mode */, wasFixed)); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 { | 779 { |
767 LocalFrame* frame = this->frame(); | 780 LocalFrame* frame = this->frame(); |
768 if (!frame) | 781 if (!frame) |
769 return; | 782 return; |
770 | 783 |
771 FrameView* frameView = frame->view(); | 784 FrameView* frameView = frame->view(); |
772 if (!frameView) | 785 if (!frameView) |
773 return; | 786 return; |
774 | 787 |
775 IntPoint positionInContent = frameView->rootFrameToContents(positionInRootFr ame); | 788 IntPoint positionInContent = frameView->rootFrameToContents(positionInRootFr ame); |
776 scrollRectToVisible(LayoutRect(positionInContent, LayoutSize(1, 1)), ScrollA lignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded); | 789 scrollRectToVisible(LayoutRect(positionInContent, LayoutSize(1, 1)), ScrollA lignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, false); |
777 } | 790 } |
778 | 791 |
779 // There are two kinds of layoutObject that can autoscroll. | 792 // There are two kinds of layoutObject that can autoscroll. |
780 bool LayoutBox::canAutoscroll() const | 793 bool LayoutBox::canAutoscroll() const |
781 { | 794 { |
782 if (node() && node()->isDocumentNode()) | 795 if (node() && node()->isDocumentNode()) |
783 return view()->frameView()->isScrollable(); | 796 return view()->frameView()->isScrollable(); |
784 | 797 |
785 // Check for a box that can be scrolled in its own right. | 798 // Check for a box that can be scrolled in its own right. |
786 return canBeScrolledAndHasScrollableArea(); | 799 return canBeScrolledAndHasScrollableArea(); |
(...skipping 3961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4748 StyleImage* borderImage = style()->borderImage().image(); | 4761 StyleImage* borderImage = style()->borderImage().image(); |
4749 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); | 4762 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); |
4750 } | 4763 } |
4751 | 4764 |
4752 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const | 4765 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const |
4753 { | 4766 { |
4754 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; | 4767 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; |
4755 } | 4768 } |
4756 | 4769 |
4757 } // namespace blink | 4770 } // namespace blink |
OLD | NEW |