Chromium Code Reviews| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 markOrthogonalWritingModeRoot(); | 248 markOrthogonalWritingModeRoot(); |
| 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() && layer()) { | 258 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e ffectiveZoom()) { |
| 259 if (int left = layer()->scrollableArea()->scrollXOffset()) { | 259 PaintLayerScrollableArea* scrollableArea = this->scrollableArea(); |
|
chrishtr
2016/02/26 19:07:42
Here and in the various places below, why is the s
Xianzhu
2016/02/26 19:09:54
We always create scrollable area if hasOverflowCli
| |
| 260 ASSERT(scrollableArea); | |
| 261 if (int left = scrollableArea->scrollXOffset()) { | |
| 260 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ; | 262 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ; |
| 261 layer()->scrollableArea()->scrollToXOffset(left); | 263 scrollableArea->scrollToXOffset(left); |
| 262 } | 264 } |
| 263 if (int top = layer()->scrollableArea()->scrollYOffset()) { | 265 if (int top = scrollableArea->scrollYOffset()) { |
| 264 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); | 266 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); |
| 265 layer()->scrollableArea()->scrollToYOffset(top); | 267 scrollableArea->scrollToYOffset(top); |
| 266 } | 268 } |
| 267 } | 269 } |
| 268 | 270 |
| 269 // Our opaqueness might have changed without triggering layout. | 271 // Our opaqueness might have changed without triggering layout. |
| 270 if (diff.needsPaintInvalidation()) { | 272 if (diff.needsPaintInvalidation()) { |
| 271 LayoutObject* parentToInvalidate = parent(); | 273 LayoutObject* parentToInvalidate = parent(); |
| 272 for (unsigned i = 0; i < backgroundObscurationTestMaxDepth && parentToIn validate; ++i) { | 274 for (unsigned i = 0; i < backgroundObscurationTestMaxDepth && parentToIn validate; ++i) { |
| 273 parentToInvalidate->invalidateBackgroundObscurationStatus(); | 275 parentToInvalidate->invalidateBackgroundObscurationStatus(); |
| 274 parentToInvalidate = parentToInvalidate->parent(); | 276 parentToInvalidate = parentToInvalidate->parent(); |
| 275 } | 277 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 // For now, it's more simple to just always recompute the grid. | 372 // For now, it's more simple to just always recompute the grid. |
| 371 toLayoutGrid(parent())->dirtyGrid(); | 373 toLayoutGrid(parent())->dirtyGrid(); |
| 372 } | 374 } |
| 373 | 375 |
| 374 void LayoutBox::updateFromStyle() | 376 void LayoutBox::updateFromStyle() |
| 375 { | 377 { |
| 376 LayoutBoxModelObject::updateFromStyle(); | 378 LayoutBoxModelObject::updateFromStyle(); |
| 377 | 379 |
| 378 const ComputedStyle& styleToUse = styleRef(); | 380 const ComputedStyle& styleToUse = styleRef(); |
| 379 bool isViewObject = isLayoutView(); | 381 bool isViewObject = isLayoutView(); |
| 380 bool rootLayerScrolls = document().settings() && document().settings()->root LayerScrolls(); | |
| 381 | 382 |
| 382 // LayoutView of the main frame is resposible from painting base background. | 383 // LayoutView of the main frame is resposible from painting base background. |
| 383 if (isViewObject && !document().ownerElement()) | 384 if (isViewObject && !document().ownerElement()) |
| 384 setHasBoxDecorationBackground(true); | 385 setHasBoxDecorationBackground(true); |
| 385 | 386 |
| 386 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); | 387 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); |
| 387 | |
| 388 bool boxHasOverflowClip = false; | |
|
Xianzhu
2016/02/25 19:57:51
This part is moved into LayoutBlock::updateFromSty
| |
| 389 if (!styleToUse.isOverflowVisible() && isLayoutBlock() && (rootLayerScrolls || !isViewObject)) { | |
| 390 // If overflow has been propagated to the viewport, it has no effect her e. | |
| 391 if (node() != document().viewportDefiningElement()) | |
| 392 boxHasOverflowClip = true; | |
| 393 } | |
| 394 | |
| 395 if (boxHasOverflowClip != hasOverflowClip()) { | |
| 396 // FIXME: This shouldn't be required if we tracked the visual overflow | |
| 397 // generated by positioned children or self painting layers. crbug.com/3 45403 | |
| 398 for (LayoutObject* child = slowFirstChild(); child; child = child->nextS ibling()) | |
| 399 child->setMayNeedPaintInvalidation(); | |
| 400 } | |
| 401 | |
| 402 setHasOverflowClip(boxHasOverflowClip); | |
| 403 | |
| 404 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); | 388 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); |
| 405 setHasReflection(styleToUse.boxReflect()); | 389 setHasReflection(styleToUse.boxReflect()); |
| 406 } | 390 } |
| 407 | 391 |
| 408 void LayoutBox::layout() | 392 void LayoutBox::layout() |
| 409 { | 393 { |
| 410 ASSERT(needsLayout()); | 394 ASSERT(needsLayout()); |
| 411 LayoutAnalyzer::Scope analyzer(*this); | 395 LayoutAnalyzer::Scope analyzer(*this); |
| 412 | 396 |
| 413 LayoutObject* child = slowFirstChild(); | 397 LayoutObject* child = slowFirstChild(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 } | 438 } |
| 455 | 439 |
| 456 int LayoutBox::pixelSnappedOffsetHeight() const | 440 int LayoutBox::pixelSnappedOffsetHeight() const |
| 457 { | 441 { |
| 458 return snapSizeToPixel(offsetHeight(), location().y() + clientTop()); | 442 return snapSizeToPixel(offsetHeight(), location().y() + clientTop()); |
| 459 } | 443 } |
| 460 | 444 |
| 461 LayoutUnit LayoutBox::scrollWidth() const | 445 LayoutUnit LayoutBox::scrollWidth() const |
| 462 { | 446 { |
| 463 if (hasOverflowClip()) | 447 if (hasOverflowClip()) |
| 464 return layer()->scrollableArea()->scrollWidth(); | 448 return scrollableArea()->scrollWidth(); |
| 465 // For objects with visible overflow, this matches IE. | 449 // For objects with visible overflow, this matches IE. |
| 466 // FIXME: Need to work right with writing modes. | 450 // FIXME: Need to work right with writing modes. |
| 467 if (style()->isLeftToRightDirection()) | 451 if (style()->isLeftToRightDirection()) |
| 468 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( )); | 452 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( )); |
| 469 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor derLeft()); | 453 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor derLeft()); |
| 470 } | 454 } |
| 471 | 455 |
| 472 LayoutUnit LayoutBox::scrollHeight() const | 456 LayoutUnit LayoutBox::scrollHeight() const |
| 473 { | 457 { |
| 474 if (hasOverflowClip()) | 458 if (hasOverflowClip()) |
| 475 return layer()->scrollableArea()->scrollHeight(); | 459 return scrollableArea()->scrollHeight(); |
| 476 // For objects with visible overflow, this matches IE. | 460 // For objects with visible overflow, this matches IE. |
| 477 // FIXME: Need to work right with writing modes. | 461 // FIXME: Need to work right with writing modes. |
| 478 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); | 462 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); |
| 479 } | 463 } |
| 480 | 464 |
| 481 LayoutUnit LayoutBox::scrollLeft() const | 465 LayoutUnit LayoutBox::scrollLeft() const |
| 482 { | 466 { |
| 483 return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollXOffs et()) : LayoutUnit(); | 467 return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollXOffset()) : L ayoutUnit(); |
| 484 } | 468 } |
| 485 | 469 |
| 486 LayoutUnit LayoutBox::scrollTop() const | 470 LayoutUnit LayoutBox::scrollTop() const |
| 487 { | 471 { |
| 488 return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollYOffs et()) : LayoutUnit(); | 472 return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollYOffset()) : L ayoutUnit(); |
| 489 } | 473 } |
| 490 | 474 |
| 491 int LayoutBox::pixelSnappedScrollWidth() const | 475 int LayoutBox::pixelSnappedScrollWidth() const |
| 492 { | 476 { |
| 493 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); | 477 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); |
| 494 } | 478 } |
| 495 | 479 |
| 496 int LayoutBox::pixelSnappedScrollHeight() const | 480 int LayoutBox::pixelSnappedScrollHeight() const |
| 497 { | 481 { |
| 498 if (hasOverflowClip()) | 482 if (hasOverflowClip()) |
| 499 return snapSizeToPixel(layer()->scrollableArea()->scrollHeight(), locati on().y() + clientTop()); | 483 return snapSizeToPixel(scrollableArea()->scrollHeight(), location().y() + clientTop()); |
| 500 // For objects with visible overflow, this matches IE. | 484 // For objects with visible overflow, this matches IE. |
| 501 // FIXME: Need to work right with writing modes. | 485 // FIXME: Need to work right with writing modes. |
| 502 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); | 486 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); |
| 503 } | 487 } |
| 504 | 488 |
| 505 void LayoutBox::setScrollLeft(LayoutUnit newLeft) | 489 void LayoutBox::setScrollLeft(LayoutUnit newLeft) |
| 506 { | 490 { |
| 507 // This doesn't hit in any tests, but since the equivalent code in setScroll Top | 491 // This doesn't hit in any tests, but since the equivalent code in setScroll Top |
| 508 // does, presumably this code does as well. | 492 // does, presumably this code does as well. |
| 509 DisableCompositingQueryAsserts disabler; | 493 DisableCompositingQueryAsserts disabler; |
| 510 | 494 |
| 511 if (hasOverflowClip()) | 495 if (hasOverflowClip()) |
| 512 layer()->scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, ScrollBehaviorAuto); | 496 scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, ScrollBe haviorAuto); |
| 513 } | 497 } |
| 514 | 498 |
| 515 void LayoutBox::setScrollTop(LayoutUnit newTop) | 499 void LayoutBox::setScrollTop(LayoutUnit newTop) |
| 516 { | 500 { |
| 517 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers .html | 501 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers .html |
| 518 DisableCompositingQueryAsserts disabler; | 502 DisableCompositingQueryAsserts disabler; |
| 519 | 503 |
| 520 if (hasOverflowClip()) | 504 if (hasOverflowClip()) |
| 521 layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, ScrollBehaviorAuto); | 505 scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, ScrollBeh aviorAuto); |
| 522 } | 506 } |
| 523 | 507 |
| 524 void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe havior) | 508 void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe havior) |
| 525 { | 509 { |
| 526 // This doesn't hit in any tests, but since the equivalent code in setScroll Top | 510 // This doesn't hit in any tests, but since the equivalent code in setScroll Top |
| 527 // does, presumably this code does as well. | 511 // does, presumably this code does as well. |
| 528 DisableCompositingQueryAsserts disabler; | 512 DisableCompositingQueryAsserts disabler; |
| 529 | 513 |
| 530 if (hasOverflowClip()) | 514 if (hasOverflowClip()) |
| 531 layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, s crollBehavior); | 515 scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, scrollBeha vior); |
| 532 } | 516 } |
| 533 | 517 |
| 534 // Returns true iff we are attempting an autoscroll inside an iframe with scroll ing="no". | 518 // Returns true iff we are attempting an autoscroll inside an iframe with scroll ing="no". |
| 535 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, FrameVie w* frameView) | 519 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, FrameVie w* frameView) |
| 536 { | 520 { |
| 537 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { | 521 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { |
| 538 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); | 522 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); |
| 539 if (Page* page = frameView->frame().page()) { | 523 if (Page* page = frameView->frame().page()) { |
| 540 return page->autoscrollController().autoscrollInProgress() | 524 return page->autoscrollController().autoscrollInProgress() |
| 541 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; | 525 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 555 | 539 |
| 556 bool restrictedByLineClamp = false; | 540 bool restrictedByLineClamp = false; |
| 557 if (parent()) { | 541 if (parent()) { |
| 558 parentBox = parent()->enclosingBox(); | 542 parentBox = parent()->enclosingBox(); |
| 559 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 543 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
| 560 } | 544 } |
| 561 | 545 |
| 562 if (hasOverflowClip() && !restrictedByLineClamp) { | 546 if (hasOverflowClip() && !restrictedByLineClamp) { |
| 563 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. | 547 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. |
| 564 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. | 548 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. |
| 565 newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY , scrollType); | 549 newRect = scrollableArea()->scrollIntoView(rect, alignX, alignY, scrollT ype); |
| 566 } else if (!parentBox && canBeProgramaticallyScrolled()) { | 550 } else if (!parentBox && canBeProgramaticallyScrolled()) { |
| 567 if (FrameView* frameView = this->frameView()) { | 551 if (FrameView* frameView = this->frameView()) { |
| 568 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); | 552 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); |
| 569 if (!isDisallowedAutoscroll(ownerElement, frameView)) { | 553 if (!isDisallowedAutoscroll(ownerElement, frameView)) { |
| 570 if (makeVisibleInVisualViewport) { | 554 if (makeVisibleInVisualViewport) { |
| 571 frameView->scrollableArea()->scrollIntoView(rect, alignX, al ignY, scrollType); | 555 frameView->scrollableArea()->scrollIntoView(rect, alignX, al ignY, scrollType); |
| 572 } else { | 556 } else { |
| 573 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType); | 557 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType); |
| 574 } | 558 } |
| 575 if (ownerElement && ownerElement->layoutObject()) { | 559 if (ownerElement && ownerElement->layoutObject()) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 break; | 736 break; |
| 753 } | 737 } |
| 754 return result; | 738 return result; |
| 755 } | 739 } |
| 756 | 740 |
| 757 int LayoutBox::verticalScrollbarWidth() const | 741 int LayoutBox::verticalScrollbarWidth() const |
| 758 { | 742 { |
| 759 if (!hasOverflowClip() || style()->overflowY() == OOVERLAY) | 743 if (!hasOverflowClip() || style()->overflowY() == OOVERLAY) |
| 760 return 0; | 744 return 0; |
| 761 | 745 |
| 762 return layer()->scrollableArea()->verticalScrollbarWidth(); | 746 return scrollableArea()->verticalScrollbarWidth(); |
| 763 } | 747 } |
| 764 | 748 |
| 765 int LayoutBox::horizontalScrollbarHeight() const | 749 int LayoutBox::horizontalScrollbarHeight() const |
| 766 { | 750 { |
| 767 if (!hasOverflowClip() || style()->overflowX() == OOVERLAY) | 751 if (!hasOverflowClip() || style()->overflowX() == OOVERLAY) |
| 768 return 0; | 752 return 0; |
| 769 | 753 |
| 770 return layer()->scrollableArea()->horizontalScrollbarHeight(); | 754 return scrollableArea()->horizontalScrollbarHeight(); |
| 771 } | 755 } |
| 772 | 756 |
| 773 int LayoutBox::intrinsicScrollbarLogicalWidth() const | 757 int LayoutBox::intrinsicScrollbarLogicalWidth() const |
| 774 { | 758 { |
| 775 if (!hasOverflowClip()) | 759 if (!hasOverflowClip()) |
| 776 return 0; | 760 return 0; |
| 777 | 761 |
| 762 ASSERT(scrollableArea()); | |
| 763 | |
| 778 if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) { | 764 if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) { |
| 779 ASSERT(layer()->scrollableArea()); | |
| 780 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). | 765 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). |
| 781 return layer()->scrollableArea()->hasVerticalScrollbar() ? verticalScrol lbarWidth() : 0; | 766 return scrollableArea()->hasVerticalScrollbar() ? verticalScrollbarWidth () : 0; |
| 782 } | 767 } |
| 783 | 768 |
| 784 if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) { | 769 if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) { |
| 785 ASSERT(layer()->scrollableArea()); | |
| 786 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). | 770 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). |
| 787 return layer()->scrollableArea()->hasHorizontalScrollbar() ? horizontalS crollbarHeight() : 0; | 771 return scrollableArea()->hasHorizontalScrollbar() ? horizontalScrollbarH eight() : 0; |
| 788 } | 772 } |
| 789 | 773 |
| 790 return 0; | 774 return 0; |
| 791 } | 775 } |
| 792 | 776 |
| 793 ScrollResultOneDimensional LayoutBox::scroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta) | 777 ScrollResultOneDimensional LayoutBox::scroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta) |
| 794 { | 778 { |
| 795 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 779 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
| 796 DisableCompositingQueryAsserts disabler; | 780 DisableCompositingQueryAsserts disabler; |
| 797 | 781 |
| 798 if (!layer() || !layer()->scrollableArea()) | 782 if (!scrollableArea()) |
| 799 return ScrollResultOneDimensional(false); | 783 return ScrollResultOneDimensional(false); |
| 800 | 784 |
| 801 return layer()->scrollableArea()->userScroll(direction, granularity, delta); | 785 return scrollableArea()->userScroll(direction, granularity, delta); |
| 802 } | 786 } |
| 803 | 787 |
| 804 bool LayoutBox::canBeScrolledAndHasScrollableArea() const | 788 bool LayoutBox::canBeScrolledAndHasScrollableArea() const |
| 805 { | 789 { |
| 806 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth() ); | 790 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth() ); |
| 807 } | 791 } |
| 808 | 792 |
| 809 bool LayoutBox::canBeProgramaticallyScrolled() const | 793 bool LayoutBox::canBeProgramaticallyScrolled() const |
| 810 { | 794 { |
| 811 Node* node = this->node(); | 795 Node* node = this->node(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 935 void LayoutBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin g clamp) | 919 void LayoutBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin g clamp) |
| 936 { | 920 { |
| 937 if (delta.isZero()) | 921 if (delta.isZero()) |
| 938 return; | 922 return; |
| 939 | 923 |
| 940 bool restrictedByLineClamp = false; | 924 bool restrictedByLineClamp = false; |
| 941 if (parent()) | 925 if (parent()) |
| 942 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 926 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
| 943 | 927 |
| 944 if (hasOverflowClip() && !restrictedByLineClamp) { | 928 if (hasOverflowClip() && !restrictedByLineClamp) { |
| 945 DoubleSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOf fset() + delta; | 929 PaintLayerScrollableArea* scrollableArea = this->scrollableArea(); |
| 946 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); | 930 ASSERT(scrollableArea); |
| 931 | |
| 932 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + de lta; | |
| 933 scrollableArea->scrollToOffset(newScrollOffset, clamp); | |
| 947 | 934 |
| 948 // If this layer can't do the scroll we ask the next layer up that can s croll to try | 935 // If this layer can't do the scroll we ask the next layer up that can s croll to try |
| 949 DoubleSize remainingScrollOffset = newScrollOffset - layer()->scrollable Area()->adjustedScrollOffset(); | 936 DoubleSize remainingScrollOffset = newScrollOffset - scrollableArea->adj ustedScrollOffset(); |
| 950 if (!remainingScrollOffset.isZero() && parent()) { | 937 if (!remainingScrollOffset.isZero() && parent()) { |
| 951 if (LayoutBox* scrollableBox = enclosingScrollableBox()) | 938 if (LayoutBox* scrollableBox = enclosingScrollableBox()) |
| 952 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ; | 939 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ; |
| 953 | 940 |
| 954 LocalFrame* frame = this->frame(); | 941 LocalFrame* frame = this->frame(); |
| 955 if (frame && frame->page()) | 942 if (frame && frame->page()) |
| 956 frame->page()->autoscrollController().updateAutoscrollLayoutObje ct(); | 943 frame->page()->autoscrollController().updateAutoscrollLayoutObje ct(); |
| 957 } | 944 } |
| 958 } else if (view()->frameView()) { | 945 } else if (view()->frameView()) { |
| 959 // If we are here, we were called on a layoutObject that can be programm atically scrolled, but doesn't | 946 // If we are here, we were called on a layoutObject that can be programm atically scrolled, but doesn't |
| 960 // have an overflow clip. Which means that it is a document node that ca n be scrolled. | 947 // have an overflow clip. Which means that it is a document node that ca n be scrolled. |
| 961 // FIXME: Pass in DoubleSize. crbug.com/414283. | 948 // FIXME: Pass in DoubleSize. crbug.com/414283. |
| 962 view()->frameView()->scrollBy(flooredIntSize(delta), UserScroll); | 949 view()->frameView()->scrollBy(flooredIntSize(delta), UserScroll); |
| 963 | 950 |
| 964 // FIXME: If we didn't scroll the whole way, do we want to try looking a t the frames ownerElement? | 951 // FIXME: If we didn't scroll the whole way, do we want to try looking a t the frames ownerElement? |
| 965 // https://bugs.webkit.org/show_bug.cgi?id=28237 | 952 // https://bugs.webkit.org/show_bug.cgi?id=28237 |
| 966 } | 953 } |
| 967 } | 954 } |
| 968 | 955 |
| 969 bool LayoutBox::needsPreferredWidthsRecalculation() const | 956 bool LayoutBox::needsPreferredWidthsRecalculation() const |
| 970 { | 957 { |
| 971 return style()->paddingStart().hasPercent() || style()->paddingEnd().hasPerc ent(); | 958 return style()->paddingStart().hasPercent() || style()->paddingEnd().hasPerc ent(); |
| 972 } | 959 } |
| 973 | 960 |
| 974 IntSize LayoutBox::scrolledContentOffset() const | 961 IntSize LayoutBox::scrolledContentOffset() const |
| 975 { | 962 { |
| 976 ASSERT(hasOverflowClip()); | 963 ASSERT(hasOverflowClip()); |
| 977 ASSERT(hasLayer()); | 964 ASSERT(hasLayer()); |
| 978 // FIXME: Return DoubleSize here. crbug.com/414283. | 965 // FIXME: Return DoubleSize here. crbug.com/414283. |
| 979 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); | 966 return flooredIntSize(scrollableArea()->scrollOffset()); |
| 980 } | 967 } |
| 981 | 968 |
| 982 void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const | 969 void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const |
| 983 { | 970 { |
| 984 ASSERT(hasLayer()); | 971 ASSERT(hasLayer()); |
| 985 ASSERT(hasOverflowClip()); | 972 ASSERT(hasOverflowClip()); |
| 986 | 973 |
| 987 LayoutSize offset = LayoutSize(-scrolledContentOffset()); | 974 LayoutSize offset = LayoutSize(-scrolledContentOffset()); |
| 988 if (UNLIKELY(hasFlippedBlocksWritingMode())) { | 975 if (UNLIKELY(hasFlippedBlocksWritingMode())) { |
| 989 if (isHorizontalWritingMode()) | 976 if (isHorizontalWritingMode()) |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1555 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft( ), borderTop())); | 1542 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft( ), borderTop())); |
| 1556 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(), borderTop() + borderBottom())); | 1543 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(), borderTop() + borderBottom())); |
| 1557 | 1544 |
| 1558 if (hasOverflowClip()) | 1545 if (hasOverflowClip()) |
| 1559 excludeScrollbars(clipRect, relevancy); | 1546 excludeScrollbars(clipRect, relevancy); |
| 1560 return clipRect; | 1547 return clipRect; |
| 1561 } | 1548 } |
| 1562 | 1549 |
| 1563 void LayoutBox::excludeScrollbars(LayoutRect& rect, OverlayScrollbarSizeRelevanc y relevancy) const | 1550 void LayoutBox::excludeScrollbars(LayoutRect& rect, OverlayScrollbarSizeRelevanc y relevancy) const |
| 1564 { | 1551 { |
| 1565 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1552 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) { |
| 1566 rect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevancy), 0); | 1553 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 1567 rect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevancy), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); | 1554 rect.move(scrollableArea->verticalScrollbarWidth(relevancy), 0); |
| 1555 rect.contract(scrollableArea->verticalScrollbarWidth(relevancy), scrolla bleArea->horizontalScrollbarHeight(relevancy)); | |
| 1556 } | |
| 1568 } | 1557 } |
| 1569 | 1558 |
| 1570 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const | 1559 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const |
| 1571 { | 1560 { |
| 1572 LayoutRect borderBoxRect = this->borderBoxRect(); | 1561 LayoutRect borderBoxRect = this->borderBoxRect(); |
| 1573 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border BoxRect.size()); | 1562 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border BoxRect.size()); |
| 1574 | 1563 |
| 1575 if (!style()->clipLeft().isAuto()) { | 1564 if (!style()->clipLeft().isAuto()) { |
| 1576 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width() ); | 1565 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width() ); |
| 1577 clipRect.move(c, LayoutUnit()); | 1566 clipRect.move(c, LayoutUnit()); |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3754 return node && node->isElementNode() && (toElement(node)->isFormControlEleme nt() || isHTMLImageElement(toElement(node))); | 3743 return node && node->isElementNode() && (toElement(node)->isFormControlEleme nt() || isHTMLImageElement(toElement(node))); |
| 3755 } | 3744 } |
| 3756 | 3745 |
| 3757 bool LayoutBox::avoidsFloats() const | 3746 bool LayoutBox::avoidsFloats() const |
| 3758 { | 3747 { |
| 3759 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint(); | 3748 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint(); |
| 3760 } | 3749 } |
| 3761 | 3750 |
| 3762 bool LayoutBox::hasNonCompositedScrollbars() const | 3751 bool LayoutBox::hasNonCompositedScrollbars() const |
| 3763 { | 3752 { |
| 3764 if (PaintLayer* layer = this->layer()) { | 3753 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) { |
| 3765 if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) { | 3754 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerFo rHorizontalScrollbar()) |
| 3766 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->lay erForHorizontalScrollbar()) | 3755 return true; |
| 3767 return true; | 3756 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV erticalScrollbar()) |
| 3768 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layer ForVerticalScrollbar()) | 3757 return true; |
| 3769 return true; | |
| 3770 } | |
| 3771 } | 3758 } |
| 3772 return false; | 3759 return false; |
| 3773 } | 3760 } |
| 3774 | 3761 |
| 3775 PaintInvalidationReason LayoutBox::paintInvalidationReason(const LayoutBoxModelO bject& paintInvalidationContainer, | 3762 PaintInvalidationReason LayoutBox::paintInvalidationReason(const LayoutBoxModelO bject& paintInvalidationContainer, |
| 3776 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const | 3763 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const |
| 3777 { | 3764 { |
| 3778 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::paintInva lidationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, ne wLocation); | 3765 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::paintInva lidationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, ne wLocation); |
| 3779 if (isFullPaintInvalidationReason(invalidationReason)) | 3766 if (isFullPaintInvalidationReason(invalidationReason)) |
| 3780 return invalidationReason; | 3767 return invalidationReason; |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4682 } | 4669 } |
| 4683 | 4670 |
| 4684 void LayoutBox::IntrinsicSizingInfo::transpose() | 4671 void LayoutBox::IntrinsicSizingInfo::transpose() |
| 4685 { | 4672 { |
| 4686 size = size.transposedSize(); | 4673 size = size.transposedSize(); |
| 4687 aspectRatio = aspectRatio.transposedSize(); | 4674 aspectRatio = aspectRatio.transposedSize(); |
| 4688 std::swap(hasWidth, hasHeight); | 4675 std::swap(hasWidth, hasHeight); |
| 4689 } | 4676 } |
| 4690 | 4677 |
| 4691 } // namespace blink | 4678 } // namespace blink |
| OLD | NEW |