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(); |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 // It should be possible to not dirty the grid in some cases (like moving an explicitly placed grid item). | 371 // It should be possible to not dirty the grid in some cases (like moving an explicitly placed grid item). |
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(); | |
380 bool rootLayerScrolls = document().settings() && document().settings()->root LayerScrolls(); | |
381 | |
382 // LayoutView of the main frame is resposible from painting base background. | |
383 if (isViewObject && !document().ownerElement()) | |
384 setHasBoxDecorationBackground(true); | |
Xianzhu
2016/02/26 20:12:57
BTW the above three lines are moved into LayoutVie
| |
385 | |
386 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); | 381 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); |
387 | |
388 bool boxHasOverflowClip = false; | |
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()); | 382 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); |
405 setHasReflection(styleToUse.boxReflect()); | 383 setHasReflection(styleToUse.boxReflect()); |
406 } | 384 } |
407 | 385 |
408 void LayoutBox::layout() | 386 void LayoutBox::layout() |
409 { | 387 { |
410 ASSERT(needsLayout()); | 388 ASSERT(needsLayout()); |
411 LayoutAnalyzer::Scope analyzer(*this); | 389 LayoutAnalyzer::Scope analyzer(*this); |
412 | 390 |
413 LayoutObject* child = slowFirstChild(); | 391 LayoutObject* child = slowFirstChild(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 } | 432 } |
455 | 433 |
456 int LayoutBox::pixelSnappedOffsetHeight() const | 434 int LayoutBox::pixelSnappedOffsetHeight() const |
457 { | 435 { |
458 return snapSizeToPixel(offsetHeight(), location().y() + clientTop()); | 436 return snapSizeToPixel(offsetHeight(), location().y() + clientTop()); |
459 } | 437 } |
460 | 438 |
461 LayoutUnit LayoutBox::scrollWidth() const | 439 LayoutUnit LayoutBox::scrollWidth() const |
462 { | 440 { |
463 if (hasOverflowClip()) | 441 if (hasOverflowClip()) |
464 return layer()->scrollableArea()->scrollWidth(); | 442 return scrollableArea()->scrollWidth(); |
465 // For objects with visible overflow, this matches IE. | 443 // For objects with visible overflow, this matches IE. |
466 // FIXME: Need to work right with writing modes. | 444 // FIXME: Need to work right with writing modes. |
467 if (style()->isLeftToRightDirection()) | 445 if (style()->isLeftToRightDirection()) |
468 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( )); | 446 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( )); |
469 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor derLeft()); | 447 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor derLeft()); |
470 } | 448 } |
471 | 449 |
472 LayoutUnit LayoutBox::scrollHeight() const | 450 LayoutUnit LayoutBox::scrollHeight() const |
473 { | 451 { |
474 if (hasOverflowClip()) | 452 if (hasOverflowClip()) |
475 return layer()->scrollableArea()->scrollHeight(); | 453 return scrollableArea()->scrollHeight(); |
476 // For objects with visible overflow, this matches IE. | 454 // For objects with visible overflow, this matches IE. |
477 // FIXME: Need to work right with writing modes. | 455 // FIXME: Need to work right with writing modes. |
478 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); | 456 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); |
479 } | 457 } |
480 | 458 |
481 LayoutUnit LayoutBox::scrollLeft() const | 459 LayoutUnit LayoutBox::scrollLeft() const |
482 { | 460 { |
483 return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollXOffs et()) : LayoutUnit(); | 461 return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollXOffset()) : L ayoutUnit(); |
484 } | 462 } |
485 | 463 |
486 LayoutUnit LayoutBox::scrollTop() const | 464 LayoutUnit LayoutBox::scrollTop() const |
487 { | 465 { |
488 return hasOverflowClip() ? LayoutUnit(layer()->scrollableArea()->scrollYOffs et()) : LayoutUnit(); | 466 return hasOverflowClip() ? LayoutUnit(scrollableArea()->scrollYOffset()) : L ayoutUnit(); |
489 } | 467 } |
490 | 468 |
491 int LayoutBox::pixelSnappedScrollWidth() const | 469 int LayoutBox::pixelSnappedScrollWidth() const |
492 { | 470 { |
493 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); | 471 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); |
494 } | 472 } |
495 | 473 |
496 int LayoutBox::pixelSnappedScrollHeight() const | 474 int LayoutBox::pixelSnappedScrollHeight() const |
497 { | 475 { |
498 if (hasOverflowClip()) | 476 if (hasOverflowClip()) |
499 return snapSizeToPixel(layer()->scrollableArea()->scrollHeight(), locati on().y() + clientTop()); | 477 return snapSizeToPixel(scrollableArea()->scrollHeight(), location().y() + clientTop()); |
500 // For objects with visible overflow, this matches IE. | 478 // For objects with visible overflow, this matches IE. |
501 // FIXME: Need to work right with writing modes. | 479 // FIXME: Need to work right with writing modes. |
502 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); | 480 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); |
503 } | 481 } |
504 | 482 |
505 void LayoutBox::setScrollLeft(LayoutUnit newLeft) | 483 void LayoutBox::setScrollLeft(LayoutUnit newLeft) |
506 { | 484 { |
507 // 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 |
508 // does, presumably this code does as well. | 486 // does, presumably this code does as well. |
509 DisableCompositingQueryAsserts disabler; | 487 DisableCompositingQueryAsserts disabler; |
510 | 488 |
511 if (hasOverflowClip()) | 489 if (hasOverflowClip()) |
512 layer()->scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, ScrollBehaviorAuto); | 490 scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, ScrollBe haviorAuto); |
513 } | 491 } |
514 | 492 |
515 void LayoutBox::setScrollTop(LayoutUnit newTop) | 493 void LayoutBox::setScrollTop(LayoutUnit newTop) |
516 { | 494 { |
517 // 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 |
518 DisableCompositingQueryAsserts disabler; | 496 DisableCompositingQueryAsserts disabler; |
519 | 497 |
520 if (hasOverflowClip()) | 498 if (hasOverflowClip()) |
521 layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, ScrollBehaviorAuto); | 499 scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, ScrollBeh aviorAuto); |
522 } | 500 } |
523 | 501 |
524 void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe havior) | 502 void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe havior) |
525 { | 503 { |
526 // 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 |
527 // does, presumably this code does as well. | 505 // does, presumably this code does as well. |
528 DisableCompositingQueryAsserts disabler; | 506 DisableCompositingQueryAsserts disabler; |
529 | 507 |
530 if (hasOverflowClip()) | 508 if (hasOverflowClip()) |
531 layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, s crollBehavior); | 509 scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, scrollBeha vior); |
532 } | 510 } |
533 | 511 |
534 // 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". |
535 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, FrameVie w* frameView) | 513 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, FrameVie w* frameView) |
536 { | 514 { |
537 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { | 515 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { |
538 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); | 516 HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerEle ment); |
539 if (Page* page = frameView->frame().page()) { | 517 if (Page* page = frameView->frame().page()) { |
540 return page->autoscrollController().autoscrollInProgress() | 518 return page->autoscrollController().autoscrollInProgress() |
541 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; | 519 && frameElementBase->scrollingMode() == ScrollbarAlwaysOff; |
(...skipping 13 matching lines...) Expand all Loading... | |
555 | 533 |
556 bool restrictedByLineClamp = false; | 534 bool restrictedByLineClamp = false; |
557 if (parent()) { | 535 if (parent()) { |
558 parentBox = parent()->enclosingBox(); | 536 parentBox = parent()->enclosingBox(); |
559 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 537 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
560 } | 538 } |
561 | 539 |
562 if (hasOverflowClip() && !restrictedByLineClamp) { | 540 if (hasOverflowClip() && !restrictedByLineClamp) { |
563 // 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. |
564 // 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. |
565 newRect = layer()->scrollableArea()->scrollIntoView(rect, alignX, alignY , scrollType); | 543 newRect = scrollableArea()->scrollIntoView(rect, alignX, alignY, scrollT ype); |
566 } else if (!parentBox && canBeProgramaticallyScrolled()) { | 544 } else if (!parentBox && canBeProgramaticallyScrolled()) { |
567 if (FrameView* frameView = this->frameView()) { | 545 if (FrameView* frameView = this->frameView()) { |
568 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); | 546 HTMLFrameOwnerElement* ownerElement = document().ownerElement(); |
569 if (!isDisallowedAutoscroll(ownerElement, frameView)) { | 547 if (!isDisallowedAutoscroll(ownerElement, frameView)) { |
570 if (makeVisibleInVisualViewport) { | 548 if (makeVisibleInVisualViewport) { |
571 frameView->scrollableArea()->scrollIntoView(rect, alignX, al ignY, scrollType); | 549 frameView->scrollableArea()->scrollIntoView(rect, alignX, al ignY, scrollType); |
572 } else { | 550 } else { |
573 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType); | 551 frameView->layoutViewportScrollableArea()->scrollIntoView(re ct, alignX, alignY, scrollType); |
574 } | 552 } |
575 if (ownerElement && ownerElement->layoutObject()) { | 553 if (ownerElement && ownerElement->layoutObject()) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 break; | 730 break; |
753 } | 731 } |
754 return result; | 732 return result; |
755 } | 733 } |
756 | 734 |
757 int LayoutBox::verticalScrollbarWidth() const | 735 int LayoutBox::verticalScrollbarWidth() const |
758 { | 736 { |
759 if (!hasOverflowClip() || style()->overflowY() == OOVERLAY) | 737 if (!hasOverflowClip() || style()->overflowY() == OOVERLAY) |
760 return 0; | 738 return 0; |
761 | 739 |
762 return layer()->scrollableArea()->verticalScrollbarWidth(); | 740 return scrollableArea()->verticalScrollbarWidth(); |
763 } | 741 } |
764 | 742 |
765 int LayoutBox::horizontalScrollbarHeight() const | 743 int LayoutBox::horizontalScrollbarHeight() const |
766 { | 744 { |
767 if (!hasOverflowClip() || style()->overflowX() == OOVERLAY) | 745 if (!hasOverflowClip() || style()->overflowX() == OOVERLAY) |
768 return 0; | 746 return 0; |
769 | 747 |
770 return layer()->scrollableArea()->horizontalScrollbarHeight(); | 748 return scrollableArea()->horizontalScrollbarHeight(); |
771 } | 749 } |
772 | 750 |
773 int LayoutBox::intrinsicScrollbarLogicalWidth() const | 751 int LayoutBox::intrinsicScrollbarLogicalWidth() const |
774 { | 752 { |
775 if (!hasOverflowClip()) | 753 if (!hasOverflowClip()) |
776 return 0; | 754 return 0; |
777 | 755 |
756 ASSERT(scrollableArea()); | |
757 | |
778 if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) { | 758 if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) { |
779 ASSERT(layer()->scrollableArea()); | |
780 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). | 759 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). |
781 return layer()->scrollableArea()->hasVerticalScrollbar() ? verticalScrol lbarWidth() : 0; | 760 return scrollableArea()->hasVerticalScrollbar() ? verticalScrollbarWidth () : 0; |
782 } | 761 } |
783 | 762 |
784 if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) { | 763 if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) { |
785 ASSERT(layer()->scrollableArea()); | |
786 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). | 764 // Even with OSCROLL, the scrollbar may not exist (crbug.com/415031). |
787 return layer()->scrollableArea()->hasHorizontalScrollbar() ? horizontalS crollbarHeight() : 0; | 765 return scrollableArea()->hasHorizontalScrollbar() ? horizontalScrollbarH eight() : 0; |
788 } | 766 } |
789 | 767 |
790 return 0; | 768 return 0; |
791 } | 769 } |
792 | 770 |
793 ScrollResultOneDimensional LayoutBox::scroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta) | 771 ScrollResultOneDimensional LayoutBox::scroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta) |
794 { | 772 { |
795 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 773 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
796 DisableCompositingQueryAsserts disabler; | 774 DisableCompositingQueryAsserts disabler; |
797 | 775 |
798 if (!layer() || !layer()->scrollableArea()) | 776 if (!scrollableArea()) |
799 return ScrollResultOneDimensional(false); | 777 return ScrollResultOneDimensional(false); |
800 | 778 |
801 return layer()->scrollableArea()->userScroll(direction, granularity, delta); | 779 return scrollableArea()->userScroll(direction, granularity, delta); |
802 } | 780 } |
803 | 781 |
804 bool LayoutBox::canBeScrolledAndHasScrollableArea() const | 782 bool LayoutBox::canBeScrolledAndHasScrollableArea() const |
805 { | 783 { |
806 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth() ); | 784 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth() ); |
807 } | 785 } |
808 | 786 |
809 bool LayoutBox::canBeProgramaticallyScrolled() const | 787 bool LayoutBox::canBeProgramaticallyScrolled() const |
810 { | 788 { |
811 Node* node = this->node(); | 789 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) | 913 void LayoutBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin g clamp) |
936 { | 914 { |
937 if (delta.isZero()) | 915 if (delta.isZero()) |
938 return; | 916 return; |
939 | 917 |
940 bool restrictedByLineClamp = false; | 918 bool restrictedByLineClamp = false; |
941 if (parent()) | 919 if (parent()) |
942 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 920 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
943 | 921 |
944 if (hasOverflowClip() && !restrictedByLineClamp) { | 922 if (hasOverflowClip() && !restrictedByLineClamp) { |
945 DoubleSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOf fset() + delta; | 923 PaintLayerScrollableArea* scrollableArea = this->scrollableArea(); |
946 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); | 924 ASSERT(scrollableArea); |
925 | |
926 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + de lta; | |
927 scrollableArea->scrollToOffset(newScrollOffset, clamp); | |
947 | 928 |
948 // 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 |
949 DoubleSize remainingScrollOffset = newScrollOffset - layer()->scrollable Area()->adjustedScrollOffset(); | 930 DoubleSize remainingScrollOffset = newScrollOffset - scrollableArea->adj ustedScrollOffset(); |
950 if (!remainingScrollOffset.isZero() && parent()) { | 931 if (!remainingScrollOffset.isZero() && parent()) { |
951 if (LayoutBox* scrollableBox = enclosingScrollableBox()) | 932 if (LayoutBox* scrollableBox = enclosingScrollableBox()) |
952 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ; | 933 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ; |
953 | 934 |
954 LocalFrame* frame = this->frame(); | 935 LocalFrame* frame = this->frame(); |
955 if (frame && frame->page()) | 936 if (frame && frame->page()) |
956 frame->page()->autoscrollController().updateAutoscrollLayoutObje ct(); | 937 frame->page()->autoscrollController().updateAutoscrollLayoutObje ct(); |
957 } | 938 } |
958 } else if (view()->frameView()) { | 939 } else if (view()->frameView()) { |
959 // If we are here, we were called on a layoutObject that can be programm atically scrolled, but doesn't | 940 // 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. | 941 // 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. | 942 // FIXME: Pass in DoubleSize. crbug.com/414283. |
962 view()->frameView()->scrollBy(flooredIntSize(delta), UserScroll); | 943 view()->frameView()->scrollBy(flooredIntSize(delta), UserScroll); |
963 | 944 |
964 // FIXME: If we didn't scroll the whole way, do we want to try looking a t the frames ownerElement? | 945 // 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 | 946 // https://bugs.webkit.org/show_bug.cgi?id=28237 |
966 } | 947 } |
967 } | 948 } |
968 | 949 |
969 bool LayoutBox::needsPreferredWidthsRecalculation() const | 950 bool LayoutBox::needsPreferredWidthsRecalculation() const |
970 { | 951 { |
971 return style()->paddingStart().hasPercent() || style()->paddingEnd().hasPerc ent(); | 952 return style()->paddingStart().hasPercent() || style()->paddingEnd().hasPerc ent(); |
972 } | 953 } |
973 | 954 |
974 IntSize LayoutBox::scrolledContentOffset() const | 955 IntSize LayoutBox::scrolledContentOffset() const |
975 { | 956 { |
976 ASSERT(hasOverflowClip()); | 957 ASSERT(hasOverflowClip()); |
977 ASSERT(hasLayer()); | 958 ASSERT(hasLayer()); |
978 // FIXME: Return DoubleSize here. crbug.com/414283. | 959 // FIXME: Return DoubleSize here. crbug.com/414283. |
979 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); | 960 return flooredIntSize(scrollableArea()->scrollOffset()); |
980 } | 961 } |
981 | 962 |
982 void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const | 963 void LayoutBox::mapScrollingContentsRectToBoxSpace(LayoutRect& rect) const |
983 { | 964 { |
984 ASSERT(hasLayer()); | 965 ASSERT(hasLayer()); |
985 ASSERT(hasOverflowClip()); | 966 ASSERT(hasOverflowClip()); |
986 | 967 |
987 LayoutSize offset = LayoutSize(-scrolledContentOffset()); | 968 LayoutSize offset = LayoutSize(-scrolledContentOffset()); |
988 if (UNLIKELY(hasFlippedBlocksWritingMode())) { | 969 if (UNLIKELY(hasFlippedBlocksWritingMode())) { |
989 if (isHorizontalWritingMode()) | 970 if (isHorizontalWritingMode()) |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1555 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft( ), borderTop())); | 1536 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft( ), borderTop())); |
1556 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(), borderTop() + borderBottom())); | 1537 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(), borderTop() + borderBottom())); |
1557 | 1538 |
1558 if (hasOverflowClip()) | 1539 if (hasOverflowClip()) |
1559 excludeScrollbars(clipRect, relevancy); | 1540 excludeScrollbars(clipRect, relevancy); |
1560 return clipRect; | 1541 return clipRect; |
1561 } | 1542 } |
1562 | 1543 |
1563 void LayoutBox::excludeScrollbars(LayoutRect& rect, OverlayScrollbarSizeRelevanc y relevancy) const | 1544 void LayoutBox::excludeScrollbars(LayoutRect& rect, OverlayScrollbarSizeRelevanc y relevancy) const |
1564 { | 1545 { |
1565 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1546 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) { |
1566 rect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevancy), 0); | 1547 if (shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
1567 rect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevancy), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); | 1548 rect.move(scrollableArea->verticalScrollbarWidth(relevancy), 0); |
1549 rect.contract(scrollableArea->verticalScrollbarWidth(relevancy), scrolla bleArea->horizontalScrollbarHeight(relevancy)); | |
1550 } | |
1568 } | 1551 } |
1569 | 1552 |
1570 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const | 1553 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) const |
1571 { | 1554 { |
1572 LayoutRect borderBoxRect = this->borderBoxRect(); | 1555 LayoutRect borderBoxRect = this->borderBoxRect(); |
1573 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border BoxRect.size()); | 1556 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border BoxRect.size()); |
1574 | 1557 |
1575 if (!style()->clipLeft().isAuto()) { | 1558 if (!style()->clipLeft().isAuto()) { |
1576 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width() ); | 1559 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width() ); |
1577 clipRect.move(c, LayoutUnit()); | 1560 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))); | 3737 return node && node->isElementNode() && (toElement(node)->isFormControlEleme nt() || isHTMLImageElement(toElement(node))); |
3755 } | 3738 } |
3756 | 3739 |
3757 bool LayoutBox::avoidsFloats() const | 3740 bool LayoutBox::avoidsFloats() const |
3758 { | 3741 { |
3759 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint(); | 3742 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint(); |
3760 } | 3743 } |
3761 | 3744 |
3762 bool LayoutBox::hasNonCompositedScrollbars() const | 3745 bool LayoutBox::hasNonCompositedScrollbars() const |
3763 { | 3746 { |
3764 if (PaintLayer* layer = this->layer()) { | 3747 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) { |
3765 if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) { | 3748 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->layerFo rHorizontalScrollbar()) |
3766 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->lay erForHorizontalScrollbar()) | 3749 return true; |
3767 return true; | 3750 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layerForV erticalScrollbar()) |
3768 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layer ForVerticalScrollbar()) | 3751 return true; |
3769 return true; | |
3770 } | |
3771 } | 3752 } |
3772 return false; | 3753 return false; |
3773 } | 3754 } |
3774 | 3755 |
3775 PaintInvalidationReason LayoutBox::paintInvalidationReason(const LayoutBoxModelO bject& paintInvalidationContainer, | 3756 PaintInvalidationReason LayoutBox::paintInvalidationReason(const LayoutBoxModelO bject& paintInvalidationContainer, |
3776 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const | 3757 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec t& newBounds, const LayoutPoint& newLocation) const |
3777 { | 3758 { |
3778 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::paintInva lidationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, ne wLocation); | 3759 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::paintInva lidationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, ne wLocation); |
3779 if (isFullPaintInvalidationReason(invalidationReason)) | 3760 if (isFullPaintInvalidationReason(invalidationReason)) |
3780 return invalidationReason; | 3761 return invalidationReason; |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4682 } | 4663 } |
4683 | 4664 |
4684 void LayoutBox::IntrinsicSizingInfo::transpose() | 4665 void LayoutBox::IntrinsicSizingInfo::transpose() |
4685 { | 4666 { |
4686 size = size.transposedSize(); | 4667 size = size.transposedSize(); |
4687 aspectRatio = aspectRatio.transposedSize(); | 4668 aspectRatio = aspectRatio.transposedSize(); |
4688 std::swap(hasWidth, hasHeight); | 4669 std::swap(hasWidth, hasHeight); |
4689 } | 4670 } |
4690 | 4671 |
4691 } // namespace blink | 4672 } // namespace blink |
OLD | NEW |