Chromium Code Reviews

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

Issue 1774943003: blink: Rename platform/ methods to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-platform: rebase-yayyyyyyyy Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 238 matching lines...)
249 else 249 else
250 unmarkOrthogonalWritingModeRoot(); 250 unmarkOrthogonalWritingModeRoot();
251 } 251 }
252 252
253 clearPercentHeightDescendants(); 253 clearPercentHeightDescendants();
254 } 254 }
255 255
256 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the 256 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the
257 // new zoomed coordinate space. 257 // new zoomed coordinate space.
258 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e ffectiveZoom()) { 258 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e ffectiveZoom()) {
259 PaintLayerScrollableArea* scrollableArea = this->scrollableArea(); 259 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea();
260 ASSERT(scrollableArea); 260 ASSERT(scrollableArea);
261 if (int left = scrollableArea->scrollXOffset()) { 261 if (int left = scrollableArea->scrollXOffset()) {
262 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ; 262 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ;
263 scrollableArea->scrollToXOffset(left); 263 scrollableArea->scrollToXOffset(left);
264 } 264 }
265 if (int top = scrollableArea->scrollYOffset()) { 265 if (int top = scrollableArea->scrollYOffset()) {
266 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); 266 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom();
267 scrollableArea->scrollToYOffset(top); 267 scrollableArea->scrollToYOffset(top);
268 } 268 }
269 } 269 }
270 270
271 // Our opaqueness might have changed without triggering layout. 271 // Our opaqueness might have changed without triggering layout.
272 if (diff.needsPaintInvalidation()) { 272 if (diff.needsPaintInvalidation()) {
273 LayoutObject* parentToInvalidate = parent(); 273 LayoutObject* parentToInvalidate = parent();
274 for (unsigned i = 0; i < backgroundObscurationTestMaxDepth && parentToIn validate; ++i) { 274 for (unsigned i = 0; i < backgroundObscurationTestMaxDepth && parentToIn validate; ++i) {
275 parentToInvalidate->invalidateBackgroundObscurationStatus(); 275 parentToInvalidate->invalidateBackgroundObscurationStatus();
276 parentToInvalidate = parentToInvalidate->parent(); 276 parentToInvalidate = parentToInvalidate->parent();
277 } 277 }
278 } 278 }
279 279
280 if (isDocumentElement() || isBody()) { 280 if (isDocumentElement() || isBody()) {
281 document().view()->recalculateScrollbarOverlayStyle(document().view()->d ocumentBackgroundColor()); 281 document().view()->recalculateScrollbarOverlayStyle(document().view()->d ocumentBackgroundColor());
282 document().view()->recalculateCustomScrollbarStyle(); 282 document().view()->recalculateCustomScrollbarStyle();
283 if (LayoutView* layoutView = view()) { 283 if (LayoutView* layoutView = view()) {
284 if (PaintLayerScrollableArea* scrollableArea = layoutView->scrollabl eArea()) { 284 if (PaintLayerScrollableArea* scrollableArea = layoutView->getScroll ableArea()) {
285 if (scrollableArea->horizontalScrollbar() && scrollableArea->hor izontalScrollbar()->isCustomScrollbar()) 285 if (scrollableArea->horizontalScrollbar() && scrollableArea->hor izontalScrollbar()->isCustomScrollbar())
286 scrollableArea->horizontalScrollbar()->styleChanged(); 286 scrollableArea->horizontalScrollbar()->styleChanged();
287 if (scrollableArea->verticalScrollbar() && scrollableArea->verti calScrollbar()->isCustomScrollbar()) 287 if (scrollableArea->verticalScrollbar() && scrollableArea->verti calScrollbar()->isCustomScrollbar())
288 scrollableArea->verticalScrollbar()->styleChanged(); 288 scrollableArea->verticalScrollbar()->styleChanged();
289 } 289 }
290 } 290 }
291 } 291 }
292 updateShapeOutsideInfoAfterStyleChange(*style(), oldStyle); 292 updateShapeOutsideInfoAfterStyleChange(*style(), oldStyle);
293 updateGridPositionAfterStyleChange(oldStyle); 293 updateGridPositionAfterStyleChange(oldStyle);
294 294
(...skipping 137 matching lines...)
432 } 432 }
433 433
434 int LayoutBox::pixelSnappedOffsetHeight() const 434 int LayoutBox::pixelSnappedOffsetHeight() const
435 { 435 {
436 return snapSizeToPixel(offsetHeight(), location().y() + clientTop()); 436 return snapSizeToPixel(offsetHeight(), location().y() + clientTop());
437 } 437 }
438 438
439 LayoutUnit LayoutBox::scrollWidth() const 439 LayoutUnit LayoutBox::scrollWidth() const
440 { 440 {
441 if (hasOverflowClip()) 441 if (hasOverflowClip())
442 return scrollableArea()->scrollWidth(); 442 return getScrollableArea()->scrollWidth();
443 // For objects with visible overflow, this matches IE. 443 // For objects with visible overflow, this matches IE.
444 // FIXME: Need to work right with writing modes. 444 // FIXME: Need to work right with writing modes.
445 if (style()->isLeftToRightDirection()) 445 if (style()->isLeftToRightDirection())
446 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( )); 446 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( ));
447 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor derLeft()); 447 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor derLeft());
448 } 448 }
449 449
450 LayoutUnit LayoutBox::scrollHeight() const 450 LayoutUnit LayoutBox::scrollHeight() const
451 { 451 {
452 if (hasOverflowClip()) 452 if (hasOverflowClip())
453 return scrollableArea()->scrollHeight(); 453 return getScrollableArea()->scrollHeight();
454 // For objects with visible overflow, this matches IE. 454 // For objects with visible overflow, this matches IE.
455 // FIXME: Need to work right with writing modes. 455 // FIXME: Need to work right with writing modes.
456 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); 456 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop());
457 } 457 }
458 458
459 LayoutUnit LayoutBox::scrollLeft() const 459 LayoutUnit LayoutBox::scrollLeft() const
460 { 460 {
461 return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollXOffset()) : L ayoutUnit(); 461 return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollXOffset()) : LayoutUnit();
462 } 462 }
463 463
464 LayoutUnit LayoutBox::scrollTop() const 464 LayoutUnit LayoutBox::scrollTop() const
465 { 465 {
466 return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollYOffset()) : L ayoutUnit(); 466 return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollYOffset()) : LayoutUnit();
467 } 467 }
468 468
469 int LayoutBox::pixelSnappedScrollWidth() const 469 int LayoutBox::pixelSnappedScrollWidth() const
470 { 470 {
471 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); 471 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft());
472 } 472 }
473 473
474 int LayoutBox::pixelSnappedScrollHeight() const 474 int LayoutBox::pixelSnappedScrollHeight() const
475 { 475 {
476 if (hasOverflowClip()) 476 if (hasOverflowClip())
477 return snapSizeToPixel(scrollableArea()->scrollHeight(), location().y() + clientTop()); 477 return snapSizeToPixel(getScrollableArea()->scrollHeight(), location().y () + clientTop());
478 // For objects with visible overflow, this matches IE. 478 // For objects with visible overflow, this matches IE.
479 // FIXME: Need to work right with writing modes. 479 // FIXME: Need to work right with writing modes.
480 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); 480 return snapSizeToPixel(scrollHeight(), location().y() + clientTop());
481 } 481 }
482 482
483 void LayoutBox::setScrollLeft(LayoutUnit newLeft) 483 void LayoutBox::setScrollLeft(LayoutUnit newLeft)
484 { 484 {
485 // This doesn't hit in any tests, but since the equivalent code in setScroll Top 485 // This doesn't hit in any tests, but since the equivalent code in setScroll Top
486 // does, presumably this code does as well. 486 // does, presumably this code does as well.
487 DisableCompositingQueryAsserts disabler; 487 DisableCompositingQueryAsserts disabler;
488 488
489 if (hasOverflowClip()) 489 if (hasOverflowClip())
490 scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, ScrollBe haviorAuto); 490 getScrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, Scrol lBehaviorAuto);
491 } 491 }
492 492
493 void LayoutBox::setScrollTop(LayoutUnit newTop) 493 void LayoutBox::setScrollTop(LayoutUnit newTop)
494 { 494 {
495 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers .html 495 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers .html
496 DisableCompositingQueryAsserts disabler; 496 DisableCompositingQueryAsserts disabler;
497 497
498 if (hasOverflowClip()) 498 if (hasOverflowClip())
499 scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, ScrollBeh aviorAuto); 499 getScrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, Scroll BehaviorAuto);
500 } 500 }
501 501
502 void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe havior) 502 void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe havior)
503 { 503 {
504 // This doesn't hit in any tests, but since the equivalent code in setScroll Top 504 // This doesn't hit in any tests, but since the equivalent code in setScroll Top
505 // does, presumably this code does as well. 505 // does, presumably this code does as well.
506 DisableCompositingQueryAsserts disabler; 506 DisableCompositingQueryAsserts disabler;
507 507
508 if (hasOverflowClip()) 508 if (hasOverflowClip())
509 scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, scrollBeha vior); 509 getScrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, scrollB ehavior);
510 } 510 }
511 511
512 // Returns true iff we are attempting an autoscroll inside an iframe with scroll ing="no". 512 // Returns true iff we are attempting an autoscroll inside an iframe with scroll ing="no".
513 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, FrameVie w* frameView) 513 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, FrameVie w* frameView)
514 { 514 {
515 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { 515 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) {
516 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); 516 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment);
517 if (Page* page = frameView->frame().page()) { 517 if (Page* page = frameView->frame().page()) {
518 return page->autoscrollController().autoscrollInProgress() 518 return page->autoscrollController().autoscrollInProgress()
519 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; 519 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff;
(...skipping 13 matching lines...)
533 533
534 bool restrictedByLineClamp = false; 534 bool restrictedByLineClamp = false;
535 if (parent()) { 535 if (parent()) {
536 parentBox = parent()->enclosingBox(); 536 parentBox = parent()->enclosingBox();
537 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); 537 restrictedByLineClamp = !parent()->style()->lineClamp().isNone();
538 } 538 }
539 539
540 if (hasOverflowClip() && !restrictedByLineClamp) { 540 if (hasOverflowClip() && !restrictedByLineClamp) {
541 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. 541 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
542 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. 542 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
543 newRect = scrollableArea()->scrollIntoView(rect, alignX, alignY, scrollT ype); 543 newRect = getScrollableArea()->scrollIntoView(rect, alignX, alignY, scro llType);
544 } else if (!parentBox && canBeProgramaticallyScrolled()) { 544 } else if (!parentBox && canBeProgramaticallyScrolled()) {
545 if (FrameView* frameView = this->frameView()) { 545 if (FrameView* frameView = this->frameView()) {
546 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); 546 HTMLFrameOwnerElement* ownerElement = document().ownerElement();
547 if (!isDisallowedAutoscroll(ownerElement, frameView)) { 547 if (!isDisallowedAutoscroll(ownerElement, frameView)) {
548 if (makeVisibleInVisualViewport) { 548 if (makeVisibleInVisualViewport) {
549 frameView->scrollableArea()->scrollIntoView(rect, alignX, al ignY, scrollType); 549 frameView->getScrollableArea()->scrollIntoView(rect, alignX, alignY, scrollType);
550 } else { 550 } else {
551 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType); 551 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType);
552 } 552 }
553 if (ownerElement && ownerElement->layoutObject()) { 553 if (ownerElement && ownerElement->layoutObject()) {
554 if (frameView->safeToPropagateScrollToParent()) { 554 if (frameView->safeToPropagateScrollToParent()) {
555 parentBox = ownerElement->layoutObject()->enclosingBox() ; 555 parentBox = ownerElement->layoutObject()->enclosingBox() ;
556 // FIXME: This doesn't correctly convert the rect to 556 // FIXME: This doesn't correctly convert the rect to
557 // absolute coordinates in the parent. 557 // absolute coordinates in the parent.
558 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x()); 558 newRect.setX(rect.x() - frameView->scrollX() + frameView ->x());
559 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y()); 559 newRect.setY(rect.y() - frameView->scrollY() + frameView ->y());
(...skipping 77 matching lines...)
637 637
638 return logicalHeight; 638 return logicalHeight;
639 } 639 }
640 640
641 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint& location) 641 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint& location)
642 { 642 {
643 if (hasOverflowClip()) { 643 if (hasOverflowClip()) {
644 IntSize oldPixelSnappedBorderRectSize = pixelSnappedBorderBoxRect().size (); 644 IntSize oldPixelSnappedBorderRectSize = pixelSnappedBorderBoxRect().size ();
645 setLocation(location); 645 setLocation(location);
646 if (pixelSnappedBorderBoxRect().size() != oldPixelSnappedBorderRectSize) 646 if (pixelSnappedBorderBoxRect().size() != oldPixelSnappedBorderRectSize)
647 scrollableArea()->updateAfterLayout(); 647 getScrollableArea()->updateAfterLayout();
648 return; 648 return;
649 } 649 }
650 650
651 setLocation(location); 651 setLocation(location);
652 } 652 }
653 653
654 IntRect LayoutBox::absoluteContentBox() const 654 IntRect LayoutBox::absoluteContentBox() const
655 { 655 {
656 // This is wrong with transforms and flipped writing modes. 656 // This is wrong with transforms and flipped writing modes.
657 IntRect rect = pixelSnappedIntRect(contentBoxRect()); 657 IntRect rect = pixelSnappedIntRect(contentBoxRect());
(...skipping 72 matching lines...)
730 break; 730 break;
731 } 731 }
732 return result; 732 return result;
733 } 733 }
734 734
735 int LayoutBox::verticalScrollbarWidth() const 735 int LayoutBox::verticalScrollbarWidth() const
736 { 736 {
737 if (!hasOverflowClip() || style()->overflowY() == OverflowOverlay) 737 if (!hasOverflowClip() || style()->overflowY() == OverflowOverlay)
738 return 0; 738 return 0;
739 739
740 return scrollableArea()->verticalScrollbarWidth(); 740 return getScrollableArea()->verticalScrollbarWidth();
741 } 741 }
742 742
743 int LayoutBox::horizontalScrollbarHeight() const 743 int LayoutBox::horizontalScrollbarHeight() const
744 { 744 {
745 if (!hasOverflowClip() || style()->overflowX() == OverflowOverlay) 745 if (!hasOverflowClip() || style()->overflowX() == OverflowOverlay)
746 return 0; 746 return 0;
747 747
748 return scrollableArea()->horizontalScrollbarHeight(); 748 return getScrollableArea()->horizontalScrollbarHeight();
749 } 749 }
750 750
751 int LayoutBox::intrinsicScrollbarLogicalWidth() const 751 int LayoutBox::intrinsicScrollbarLogicalWidth() const
752 { 752 {
753 if (!hasOverflowClip()) 753 if (!hasOverflowClip())
754 return 0; 754 return 0;
755 755
756 ASSERT(scrollableArea()); 756 ASSERT(getScrollableArea());
757 757
758 if (isHorizontalWritingMode() && style()->overflowY() == OverflowScroll) { 758 if (isHorizontalWritingMode() && style()->overflowY() == OverflowScroll) {
759 // Even with OverflowScroll, the scrollbar may not exist (crbug.com/4150 31). 759 // Even with OverflowScroll, the scrollbar may not exist (crbug.com/4150 31).
760 return scrollableArea()->hasVerticalScrollbar() ? verticalScrollbarWidth () : 0; 760 return getScrollableArea()->hasVerticalScrollbar() ? verticalScrollbarWi dth() : 0;
761 } 761 }
762 762
763 if (!isHorizontalWritingMode() && style()->overflowX() == OverflowScroll) { 763 if (!isHorizontalWritingMode() && style()->overflowX() == OverflowScroll) {
764 // Even with OverflowScroll, the scrollbar may not exist (crbug.com/4150 31). 764 // Even with OverflowScroll, the scrollbar may not exist (crbug.com/4150 31).
765 return scrollableArea()->hasHorizontalScrollbar() ? horizontalScrollbarH eight() : 0; 765 return getScrollableArea()->hasHorizontalScrollbar() ? horizontalScrollb arHeight() : 0;
766 } 766 }
767 767
768 return 0; 768 return 0;
769 } 769 }
770 770
771 ScrollResult LayoutBox::scroll(ScrollGranularity granularity, const FloatSize& d elta) 771 ScrollResult LayoutBox::scroll(ScrollGranularity granularity, const FloatSize& d elta)
772 { 772 {
773 // Presumably the same issue as in setScrollTop. See crbug.com/343132. 773 // Presumably the same issue as in setScrollTop. See crbug.com/343132.
774 DisableCompositingQueryAsserts disabler; 774 DisableCompositingQueryAsserts disabler;
775 775
776 if (!scrollableArea()) 776 if (!getScrollableArea())
777 return ScrollResult(); 777 return ScrollResult();
778 778
779 return scrollableArea()->userScroll(granularity, delta); 779 return getScrollableArea()->userScroll(granularity, delta);
780 } 780 }
781 781
782 bool LayoutBox::canBeScrolledAndHasScrollableArea() const 782 bool LayoutBox::canBeScrolledAndHasScrollableArea() const
783 { 783 {
784 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth() ); 784 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth() );
785 } 785 }
786 786
787 bool LayoutBox::canBeProgramaticallyScrolled() const 787 bool LayoutBox::canBeProgramaticallyScrolled() const
788 { 788 {
789 Node* node = this->node(); 789 Node* node = this->node();
(...skipping 123 matching lines...)
913 void LayoutBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin g clamp) 913 void LayoutBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin g clamp)
914 { 914 {
915 if (delta.isZero()) 915 if (delta.isZero())
916 return; 916 return;
917 917
918 bool restrictedByLineClamp = false; 918 bool restrictedByLineClamp = false;
919 if (parent()) 919 if (parent())
920 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); 920 restrictedByLineClamp = !parent()->style()->lineClamp().isNone();
921 921
922 if (hasOverflowClip() && !restrictedByLineClamp) { 922 if (hasOverflowClip() && !restrictedByLineClamp) {
923 PaintLayerScrollableArea* scrollableArea = this->scrollableArea(); 923 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea();
924 ASSERT(scrollableArea); 924 ASSERT(scrollableArea);
925 925
926 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + de lta; 926 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + de lta;
927 scrollableArea->scrollToOffset(newScrollOffset, clamp); 927 scrollableArea->scrollToOffset(newScrollOffset, clamp);
928 928
929 // If this layer can't do the scroll we ask the next layer up that can s croll to try 929 // If this layer can't do the scroll we ask the next layer up that can s croll to try
930 DoubleSize remainingScrollOffset = newScrollOffset - scrollableArea->adj ustedScrollOffset(); 930 DoubleSize remainingScrollOffset = newScrollOffset - scrollableArea->adj ustedScrollOffset();
931 if (!remainingScrollOffset.isZero() && parent()) { 931 if (!remainingScrollOffset.isZero() && parent()) {
932 if (LayoutBox* scrollableBox = enclosingScrollableBox()) 932 if (LayoutBox* scrollableBox = enclosingScrollableBox())
933 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ; 933 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ;
(...skipping 16 matching lines...)
950 bool LayoutBox::needsPreferredWidthsRecalculation() const 950 bool LayoutBox::needsPreferredWidthsRecalculation() const
951 { 951 {
952 return style()->paddingStart().hasPercent() || style()->paddingEnd().hasPerc ent(); 952 return style()->paddingStart().hasPercent() || style()->paddingEnd().hasPerc ent();
953 } 953 }
954 954
955 IntSize LayoutBox::scrolledContentOffset() const 955 IntSize LayoutBox::scrolledContentOffset() const
956 { 956 {
957 ASSERT(hasOverflowClip()); 957 ASSERT(hasOverflowClip());
958 ASSERT(hasLayer()); 958 ASSERT(hasLayer());
959 // FIXME: Return DoubleSize here. crbug.com/414283. 959 // FIXME: Return DoubleSize here. crbug.com/414283.
960 return flooredIntSize(scrollableArea()->scrollOffset()); 960 return flooredIntSize(getScrollableArea()->scrollOffset());
961 } 961 }
962 962
963 void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const 963 void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const
964 { 964 {
965 ASSERT(hasLayer()); 965 ASSERT(hasLayer());
966 ASSERT(hasOverflowClip()); 966 ASSERT(hasOverflowClip());
967 967
968 LayoutSize offset = LayoutSize(-scrolledContentOffset()); 968 LayoutSize offset = LayoutSize(-scrolledContentOffset());
969 if (UNLIKELY(hasFlippedBlocksWritingMode())) { 969 if (UNLIKELY(hasFlippedBlocksWritingMode())) {
970 if (isHorizontalWritingMode()) 970 if (isHorizontalWritingMode())
(...skipping 478 matching lines...)
1449 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t()); 1449 screenArea = static_cast<uint32_t>(screenRect.width() * screenRect.heigh t());
1450 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea); 1450 return ResourcePriority(isVisible ? ResourcePriority::Visible : ResourcePrio rity::NotVisible, screenArea);
1451 } 1451 }
1452 1452
1453 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground) 1453 bool LayoutBox::invalidatePaintOfLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground)
1454 { 1454 {
1455 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y())) 1455 if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBod y()))
1456 return false; 1456 return false;
1457 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) { 1457 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex t()) {
1458 if (curLayer->image() && image == curLayer->image()->data()) { 1458 if (curLayer->image() && image == curLayer->image()->data()) {
1459 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->image() && curLayer->image()->cachedImage()->image()->may beAnimated(); 1459 bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->i mage()->cachedImage()->getImage() && curLayer->image()->cachedImage()->getImage( )->maybeAnimated();
1460 if (maybeAnimated && drawingBackground) 1460 if (maybeAnimated && drawingBackground)
1461 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 1461 setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
1462 else 1462 else
1463 setShouldDoFullPaintInvalidation(); 1463 setShouldDoFullPaintInvalidation();
1464 1464
1465 if (drawingBackground) 1465 if (drawingBackground)
1466 invalidateBackgroundObscurationStatus(); 1466 invalidateBackgroundObscurationStatus();
1467 return true; 1467 return true;
1468 } 1468 }
1469 } 1469 }
1470 return false; 1470 return false;
1471 } 1471 }
1472 1472
1473 bool LayoutBox::intersectsVisibleViewport() 1473 bool LayoutBox::intersectsVisibleViewport()
1474 { 1474 {
1475 LayoutRect rect = visualOverflowRect(); 1475 LayoutRect rect = visualOverflowRect();
1476 LayoutView* layoutView = view(); 1476 LayoutView* layoutView = view();
1477 while (layoutView->frame()->ownerLayoutObject()) 1477 while (layoutView->frame()->ownerLayoutObject())
1478 layoutView = layoutView->frame()->ownerLayoutObject()->view(); 1478 layoutView = layoutView->frame()->ownerLayoutObject()->view();
1479 mapToVisibleRectInAncestorSpace(layoutView, rect, nullptr); 1479 mapToVisibleRectInAncestorSpace(layoutView, rect, nullptr);
1480 return rect.intersects(LayoutRect(layoutView->frameView()->scrollableArea()- >visibleContentRectDouble())); 1480 return rect.intersects(LayoutRect(layoutView->frameView()->getScrollableArea ()->visibleContentRectDouble()));
1481 } 1481 }
1482 1482
1483 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(PaintInvalidationStat e& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContaine r) 1483 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(PaintInvalidationStat e& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContaine r)
1484 { 1484 {
1485 if (isFloating()) 1485 if (isFloating())
1486 paintInvalidationState.enclosingSelfPaintingLayer(*this).setNeedsPaintPh aseFloat(); 1486 paintInvalidationState.enclosingSelfPaintingLayer(*this).setNeedsPaintPh aseFloat();
1487 1487
1488 if (hasBoxDecorationBackground() 1488 if (hasBoxDecorationBackground()
1489 // We also paint overflow controls in background phase. 1489 // We also paint overflow controls in background phase.
1490 || (hasOverflowClip() && scrollableArea()->hasOverflowControls())) { 1490 || (hasOverflowClip() && getScrollableArea()->hasOverflowControls())) {
1491 PaintLayer& layer = paintInvalidationState.enclosingSelfPaintingLayer(*t his); 1491 PaintLayer& layer = paintInvalidationState.enclosingSelfPaintingLayer(*t his);
1492 if (layer.layoutObject() != this) 1492 if (layer.layoutObject() != this)
1493 layer.setNeedsPaintPhaseDescendantBlockBackgrounds(); 1493 layer.setNeedsPaintPhaseDescendantBlockBackgrounds();
1494 } 1494 }
1495 1495
1496 PaintInvalidationReason fullInvalidationReason = fullPaintInvalidationReason (); 1496 PaintInvalidationReason fullInvalidationReason = fullPaintInvalidationReason ();
1497 // If the current paint invalidation reason is PaintInvalidationDelayedFull, then this paint invalidation can delayed if the 1497 // If the current paint invalidation reason is PaintInvalidationDelayedFull, then this paint invalidation can delayed if the
1498 // LayoutBox in question is not on-screen. The logic to decide whether this is appropriate exists at the site of the original 1498 // LayoutBox in question is not on-screen. The logic to decide whether this is appropriate exists at the site of the original
1499 // paint invalidation that chose PaintInvalidationDelayedFull. 1499 // paint invalidation that chose PaintInvalidationDelayedFull.
1500 if (fullInvalidationReason == PaintInvalidationDelayedFull) { 1500 if (fullInvalidationReason == PaintInvalidationDelayedFull) {
1501 if (!intersectsVisibleViewport()) 1501 if (!intersectsVisibleViewport())
1502 return PaintInvalidationDelayedFull; 1502 return PaintInvalidationDelayedFull;
1503 1503
1504 // Reset state back to regular full paint invalidation if the object is onscreen. 1504 // Reset state back to regular full paint invalidation if the object is onscreen.
1505 setShouldDoFullPaintInvalidation(PaintInvalidationFull); 1505 setShouldDoFullPaintInvalidation(PaintInvalidationFull);
1506 } 1506 }
1507 1507
1508 PaintInvalidationReason reason = LayoutBoxModelObject::invalidatePaintIfNeed ed(paintInvalidationState, paintInvalidationContainer); 1508 PaintInvalidationReason reason = LayoutBoxModelObject::invalidatePaintIfNeed ed(paintInvalidationState, paintInvalidationContainer);
1509 1509
1510 if (!view()->doingFullPaintInvalidation() && !isFullPaintInvalidationReason( reason)) 1510 if (!view()->doingFullPaintInvalidation() && !isFullPaintInvalidationReason( reason))
1511 invalidatePaintForOverflowIfNeeded(); 1511 invalidatePaintForOverflowIfNeeded();
1512 1512
1513 if (PaintLayerScrollableArea* area = scrollableArea()) 1513 if (PaintLayerScrollableArea* area = getScrollableArea())
1514 area->invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState, pa intInvalidationContainer); 1514 area->invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState, pa intInvalidationContainer);
1515 1515
1516 // This is for the next invalidatePaintIfNeeded so must be at the end. 1516 // This is for the next invalidatePaintIfNeeded so must be at the end.
1517 savePreviousBoxSizesIfNeeded(); 1517 savePreviousBoxSizesIfNeeded();
1518 return reason; 1518 return reason;
1519 } 1519 }
1520 1520
1521 void LayoutBox::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& childP aintInvalidationState) 1521 void LayoutBox::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& childP aintInvalidationState)
1522 { 1522 {
1523 LayoutBoxModelObject::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidati onState); 1523 LayoutBoxModelObject::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidati onState);
(...skipping 12 matching lines...)
1536 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft( ), borderTop())); 1536 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft( ), borderTop()));
1537 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(), borderTop() + borderBottom())); 1537 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(), borderTop() + borderBottom()));
1538 1538
1539 if (hasOverflowClip()) 1539 if (hasOverflowClip())
1540 excludeScrollbars(clipRect, relevancy); 1540 excludeScrollbars(clipRect, relevancy);
1541 return clipRect; 1541 return clipRect;
1542 } 1542 }
1543 1543
1544 void LayoutBox::excludeScrollbars(LayoutRect& rect, OverlayScrollbarSizeRelevanc y relevancy) const 1544 void LayoutBox::excludeScrollbars(LayoutRect& rect, OverlayScrollbarSizeRelevanc y relevancy) const
1545 { 1545 {
1546 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) { 1546 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) {
1547 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 1547 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
1548 rect.move(scrollableArea->verticalScrollbarWidth(relevancy), 0); 1548 rect.move(scrollableArea->verticalScrollbarWidth(relevancy), 0);
1549 rect.contract(scrollableArea->verticalScrollbarWidth(relevancy), scrolla bleArea->horizontalScrollbarHeight(relevancy)); 1549 rect.contract(scrollableArea->verticalScrollbarWidth(relevancy), scrolla bleArea->horizontalScrollbarHeight(relevancy));
1550 } 1550 }
1551 } 1551 }
1552 1552
1553 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const 1553 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const
1554 { 1554 {
1555 LayoutRect borderBoxRect = this->borderBoxRect(); 1555 LayoutRect borderBoxRect = this->borderBoxRect();
1556 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border BoxRect.size()); 1556 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border BoxRect.size());
(...skipping 2064 matching lines...)
3621 } 3621 }
3622 3622
3623 // If height of box is smaller than font height, use the latter one, 3623 // If height of box is smaller than font height, use the latter one,
3624 // otherwise the caret might become invisible. 3624 // otherwise the caret might become invisible.
3625 // 3625 //
3626 // Also, if the box is not an atomic inline-level element, always use the fo nt height. 3626 // Also, if the box is not an atomic inline-level element, always use the fo nt height.
3627 // This prevents the "big caret" bug described in: 3627 // This prevents the "big caret" bug described in:
3628 // <rdar://problem/3777804> Deleting all content in a document can result in giant tall-as-window insertion point 3628 // <rdar://problem/3777804> Deleting all content in a document can result in giant tall-as-window insertion point
3629 // 3629 //
3630 // FIXME: ignoring :first-line, missing good reason to take care of 3630 // FIXME: ignoring :first-line, missing good reason to take care of
3631 LayoutUnit fontHeight = LayoutUnit(style()->fontMetrics().height()); 3631 LayoutUnit fontHeight = LayoutUnit(style()->getFontMetrics().height());
3632 if (fontHeight > rect.height() || (!isAtomicInlineLevel() && !isTable())) 3632 if (fontHeight > rect.height() || (!isAtomicInlineLevel() && !isTable()))
3633 rect.setHeight(fontHeight); 3633 rect.setHeight(fontHeight);
3634 3634
3635 if (extraWidthToEndOfLine) 3635 if (extraWidthToEndOfLine)
3636 *extraWidthToEndOfLine = location().x() + size().width() - rect.maxX(); 3636 *extraWidthToEndOfLine = location().x() + size().width() - rect.maxX();
3637 3637
3638 // Move to local coords 3638 // Move to local coords
3639 rect.moveBy(-location()); 3639 rect.moveBy(-location());
3640 3640
3641 // FIXME: Border/padding should be added for all elements but this workaroun d 3641 // FIXME: Border/padding should be added for all elements but this workaroun d
(...skipping 110 matching lines...)
3752 return node && node->isElementNode() && (toElement(node)->isFormControlEleme nt() || isHTMLImageElement(toElement(node))); 3752 return node && node->isElementNode() && (toElement(node)->isFormControlEleme nt() || isHTMLImageElement(toElement(node)));
3753 } 3753 }
3754 3754
3755 bool LayoutBox::avoidsFloats() const 3755 bool LayoutBox::avoidsFloats() const
3756 { 3756 {
3757 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint() || style()->containsLayout(); 3757 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint() || style()->containsLayout();
3758 } 3758 }
3759 3759
3760 bool LayoutBox::hasNonCompositedScrollbars() const 3760 bool LayoutBox::hasNonCompositedScrollbars() const
3761 { 3761 {
3762 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) { 3762 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) {
3763 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerFo rHorizontalScrollbar()) 3763 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerFo rHorizontalScrollbar())
3764 return true; 3764 return true;
3765 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV erticalScrollbar()) 3765 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV erticalScrollbar())
3766 return true; 3766 return true;
3767 } 3767 }
3768 return false; 3768 return false;
3769 } 3769 }
3770 3770
3771 PaintInvalidationReason LayoutBox::getPaintInvalidationReason(const LayoutBoxMod elObject& paintInvalidationContainer, 3771 PaintInvalidationReason LayoutBox::getPaintInvalidationReason(const LayoutBoxMod elObject& paintInvalidationContainer,
3772 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const 3772 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const
(...skipping 60 matching lines...)
3833 return PaintInvalidationBorderBoxChange; 3833 return PaintInvalidationBorderBoxChange;
3834 3834
3835 if (style()->hasVisualOverflowingEffect() || style()->hasAppearance() || sty le()->hasFilter() || style()->resize() != RESIZE_NONE) 3835 if (style()->hasVisualOverflowingEffect() || style()->hasAppearance() || sty le()->hasFilter() || style()->resize() != RESIZE_NONE)
3836 return PaintInvalidationBorderBoxChange; 3836 return PaintInvalidationBorderBoxChange;
3837 3837
3838 if (style()->hasBorderRadius()) { 3838 if (style()->hasBorderRadius()) {
3839 // If a border-radius exists and width/height is smaller than radius wid th/height, 3839 // If a border-radius exists and width/height is smaller than radius wid th/height,
3840 // we need to fully invalidate to cover the changed radius. 3840 // we need to fully invalidate to cover the changed radius.
3841 FloatRoundedRect oldRoundedRect = style()->getRoundedBorderFor(LayoutRec t(LayoutPoint(0, 0), oldBorderBoxSize)); 3841 FloatRoundedRect oldRoundedRect = style()->getRoundedBorderFor(LayoutRec t(LayoutPoint(0, 0), oldBorderBoxSize));
3842 FloatRoundedRect newRoundedRect = style()->getRoundedBorderFor(LayoutRec t(LayoutPoint(0, 0), newBorderBoxSize)); 3842 FloatRoundedRect newRoundedRect = style()->getRoundedBorderFor(LayoutRec t(LayoutPoint(0, 0), newBorderBoxSize));
3843 if (oldRoundedRect.radii() != newRoundedRect.radii()) 3843 if (oldRoundedRect.getRadii() != newRoundedRect.getRadii())
3844 return PaintInvalidationBorderBoxChange; 3844 return PaintInvalidationBorderBoxChange;
3845 } 3845 }
3846 3846
3847 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange()) 3847 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa ckgroundOrBorderPaintOnWidthChange())
3848 return PaintInvalidationBorderBoxChange; 3848 return PaintInvalidationBorderBoxChange;
3849 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange()) 3849 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate BackgroundOrBorderPaintOnHeightChange())
3850 return PaintInvalidationBorderBoxChange; 3850 return PaintInvalidationBorderBoxChange;
3851 3851
3852 return PaintInvalidationIncremental; 3852 return PaintInvalidationIncremental;
3853 } 3853 }
(...skipping 785 matching lines...)
4639 } 4639 }
4640 4640
4641 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const 4641 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const
4642 { 4642 {
4643 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; 4643 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr;
4644 } 4644 }
4645 4645
4646 void LayoutBox::clearPreviousPaintInvalidationRects() 4646 void LayoutBox::clearPreviousPaintInvalidationRects()
4647 { 4647 {
4648 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); 4648 LayoutBoxModelObject::clearPreviousPaintInvalidationRects();
4649 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) 4649 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea())
4650 scrollableArea->clearPreviousPaintInvalidationRects(); 4650 scrollableArea->clearPreviousPaintInvalidationRects();
4651 } 4651 }
4652 4652
4653 void LayoutBox::setPercentHeightContainer(LayoutBlock* container) 4653 void LayoutBox::setPercentHeightContainer(LayoutBlock* container)
4654 { 4654 {
4655 ASSERT(!container || !percentHeightContainer()); 4655 ASSERT(!container || !percentHeightContainer());
4656 if (!container && !m_rareData) 4656 if (!container && !m_rareData)
4657 return; 4657 return;
4658 ensureRareData().m_percentHeightContainer = container; 4658 ensureRareData().m_percentHeightContainer = container;
4659 } 4659 }
(...skipping 18 matching lines...)
4678 } 4678 }
4679 4679
4680 void LayoutBox::IntrinsicSizingInfo::transpose() 4680 void LayoutBox::IntrinsicSizingInfo::transpose()
4681 { 4681 {
4682 size = size.transposedSize(); 4682 size = size.transposedSize();
4683 aspectRatio = aspectRatio.transposedSize(); 4683 aspectRatio = aspectRatio.transposedSize();
4684 std::swap(hasWidth, hasHeight); 4684 std::swap(hasWidth, hasHeight);
4685 } 4685 }
4686 4686
4687 } // namespace blink 4687 } // namespace blink
OLDNEW

Powered by Google App Engine