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 if (oldStyle) { | 248 if (oldStyle) { |
| 249 if (isOrthogonalWritingModeRoot()) | 249 if (isOrthogonalWritingModeRoot()) |
| 250 markOrthogonalWritingModeRoot(); | 250 markOrthogonalWritingModeRoot(); |
| 251 else | 251 else |
| 252 unmarkOrthogonalWritingModeRoot(); | 252 unmarkOrthogonalWritingModeRoot(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 clearPercentHeightDescendants(); | 255 clearPercentHeightDescendants(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the | 258 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to |
| 259 // new zoomed coordinate space. | 259 // adjust that value into the new zoomed coordinate space. Note that the new |
| 260 // scroll position may be outside the normal min/max range of the scrollable | |
| 261 // area, which is weird but OK, because the scrollable area will update its | |
| 262 // min/max in updateAfterLayout(). | |
| 260 if (hasOverflowClip() && oldStyle && | 263 if (hasOverflowClip() && oldStyle && |
| 261 oldStyle->effectiveZoom() != newStyle.effectiveZoom()) { | 264 oldStyle->effectiveZoom() != newStyle.effectiveZoom()) { |
| 262 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); | 265 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); |
| 263 ASSERT(scrollableArea); | 266 ASSERT(scrollableArea); |
| 264 if (int left = scrollableArea->scrollXOffset()) { | 267 // We use scrollPosition() rather than adjustedScrollPosition(), because |
| 265 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); | 268 // scrollPosition is the distance from the beginning of flow for the box, |
| 266 scrollableArea->scrollToXOffset(left); | 269 // which is the dimension we want to preserve. |
| 267 } | 270 DoublePoint oldPosition = scrollableArea->scrollPositionDouble(); |
| 268 if (int top = scrollableArea->scrollYOffset()) { | 271 if (oldPosition.x() || oldPosition.y()) { |
| 269 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); | 272 DoublePoint newPosition = oldPosition.scaledBy(newStyle.effectiveZoom() / |
| 270 scrollableArea->scrollToYOffset(top); | 273 oldStyle->effectiveZoom()); |
| 274 scrollableArea->setScrollPositionUnconditionally(newPosition); | |
| 271 } | 275 } |
| 272 } | 276 } |
| 273 | 277 |
| 274 // Our opaqueness might have changed without triggering layout. | 278 // Our opaqueness might have changed without triggering layout. |
| 275 if (diff.needsPaintInvalidation()) { | 279 if (diff.needsPaintInvalidation()) { |
| 276 LayoutObject* parentToInvalidate = parent(); | 280 LayoutObject* parentToInvalidate = parent(); |
| 277 for (unsigned i = 0; | 281 for (unsigned i = 0; |
| 278 i < backgroundObscurationTestMaxDepth && parentToInvalidate; ++i) { | 282 i < backgroundObscurationTestMaxDepth && parentToInvalidate; ++i) { |
| 279 parentToInvalidate->invalidateBackgroundObscurationStatus(); | 283 parentToInvalidate->invalidateBackgroundObscurationStatus(); |
| 280 parentToInvalidate = parentToInvalidate->parent(); | 284 parentToInvalidate = parentToInvalidate->parent(); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 | 509 |
| 506 LayoutUnit LayoutBox::scrollHeight() const { | 510 LayoutUnit LayoutBox::scrollHeight() const { |
| 507 if (hasOverflowClip()) | 511 if (hasOverflowClip()) |
| 508 return getScrollableArea()->scrollHeight(); | 512 return getScrollableArea()->scrollHeight(); |
| 509 // For objects with visible overflow, this matches IE. | 513 // For objects with visible overflow, this matches IE. |
| 510 // FIXME: Need to work right with writing modes. | 514 // FIXME: Need to work right with writing modes. |
| 511 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); | 515 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); |
| 512 } | 516 } |
| 513 | 517 |
| 514 LayoutUnit LayoutBox::scrollLeft() const { | 518 LayoutUnit LayoutBox::scrollLeft() const { |
| 515 return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollXOffset()) | 519 return hasOverflowClip() |
| 516 : LayoutUnit(); | 520 ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().width()) |
| 521 : LayoutUnit(); | |
| 517 } | 522 } |
| 518 | 523 |
| 519 LayoutUnit LayoutBox::scrollTop() const { | 524 LayoutUnit LayoutBox::scrollTop() const { |
| 520 return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollYOffset()) | 525 return hasOverflowClip() |
| 521 : LayoutUnit(); | 526 ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().height()) |
| 527 : LayoutUnit(); | |
| 522 } | 528 } |
| 523 | 529 |
| 524 int LayoutBox::pixelSnappedScrollWidth() const { | 530 int LayoutBox::pixelSnappedScrollWidth() const { |
| 525 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); | 531 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); |
| 526 } | 532 } |
| 527 | 533 |
| 528 int LayoutBox::pixelSnappedScrollHeight() const { | 534 int LayoutBox::pixelSnappedScrollHeight() const { |
| 529 if (hasOverflowClip()) | 535 if (hasOverflowClip()) |
| 530 return snapSizeToPixel(getScrollableArea()->scrollHeight(), | 536 return snapSizeToPixel(getScrollableArea()->scrollHeight(), |
| 531 location().y() + clientTop()); | 537 location().y() + clientTop()); |
| 532 // For objects with visible overflow, this matches IE. | 538 // For objects with visible overflow, this matches IE. |
| 533 // FIXME: Need to work right with writing modes. | 539 // FIXME: Need to work right with writing modes. |
| 534 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); | 540 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); |
| 535 } | 541 } |
| 536 | 542 |
| 537 void LayoutBox::setScrollLeft(LayoutUnit newLeft) { | 543 void LayoutBox::setScrollLeft(LayoutUnit newLeft) { |
| 538 // This doesn't hit in any tests, but since the equivalent code in setScrollTo p | 544 // This doesn't hit in any tests, but since the equivalent code in setScrollTo p |
| 539 // does, presumably this code does as well. | 545 // does, presumably this code does as well. |
| 540 DisableCompositingQueryAsserts disabler; | 546 DisableCompositingQueryAsserts disabler; |
| 541 | 547 |
| 542 if (hasOverflowClip()) | 548 if (hasOverflowClip()) { |
| 543 getScrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, | 549 PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
| 544 ScrollBehaviorAuto); | 550 getScrollableArea()->scrollToOffset( |
|
skobes
2016/10/04 22:25:26
nit: use local scrollableArea var
szager1
2016/10/04 22:54:13
Done.
| |
| 551 DoubleSize(newLeft, scrollableArea->adjustedScrollOffset().height()), | |
| 552 ScrollBehaviorAuto); | |
| 553 } | |
| 545 } | 554 } |
| 546 | 555 |
| 547 void LayoutBox::setScrollTop(LayoutUnit newTop) { | 556 void LayoutBox::setScrollTop(LayoutUnit newTop) { |
| 548 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers.h tml | 557 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers.h tml |
| 549 DisableCompositingQueryAsserts disabler; | 558 DisableCompositingQueryAsserts disabler; |
| 550 | 559 |
| 551 if (hasOverflowClip()) | 560 if (hasOverflowClip()) { |
| 552 getScrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, | 561 PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
| 553 ScrollBehaviorAuto); | 562 getScrollableArea()->scrollToOffset( |
|
skobes
2016/10/04 22:25:26
nit: use local scrollableArea var
szager1
2016/10/04 22:54:13
Done.
| |
| 563 DoubleSize(scrollableArea->adjustedScrollOffset().width(), newTop), | |
| 564 ScrollBehaviorAuto); | |
| 565 } | |
| 554 } | 566 } |
| 555 | 567 |
| 556 void LayoutBox::scrollToOffset(const DoubleSize& offset, | 568 void LayoutBox::scrollToOffset(const DoubleSize& offset, |
| 557 ScrollBehavior scrollBehavior) { | 569 ScrollBehavior scrollBehavior) { |
| 558 // This doesn't hit in any tests, but since the equivalent code in setScrollTo p | 570 // This doesn't hit in any tests, but since the equivalent code in setScrollTo p |
| 559 // does, presumably this code does as well. | 571 // does, presumably this code does as well. |
| 560 DisableCompositingQueryAsserts disabler; | 572 DisableCompositingQueryAsserts disabler; |
| 561 | 573 |
| 562 if (hasOverflowClip()) | 574 if (hasOverflowClip()) |
| 563 getScrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, | 575 getScrollableArea()->scrollToOffset(offset, scrollBehavior); |
| 564 scrollBehavior); | |
| 565 } | 576 } |
| 566 | 577 |
| 567 // Returns true iff we are attempting an autoscroll inside an iframe with scroll ing="no". | 578 // Returns true iff we are attempting an autoscroll inside an iframe with scroll ing="no". |
| 568 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, | 579 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, |
| 569 FrameView* frameView) { | 580 FrameView* frameView) { |
| 570 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { | 581 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { |
| 571 HTMLFrameElementBase* frameElementBase = | 582 HTMLFrameElementBase* frameElementBase = |
| 572 toHTMLFrameElementBase(ownerElement); | 583 toHTMLFrameElementBase(ownerElement); |
| 573 if (Page* page = frameView->frame().page()) { | 584 if (Page* page = frameView->frame().page()) { |
| 574 return page->autoscrollController().autoscrollInProgress() && | 585 return page->autoscrollController().autoscrollInProgress() && |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1069 if (abs(delta.width()) <= | 1080 if (abs(delta.width()) <= |
| 1070 AutoscrollController:: | 1081 AutoscrollController:: |
| 1071 noMiddleClickAutoscrollRadius) // at the center we let the space for the icon | 1082 noMiddleClickAutoscrollRadius) // at the center we let the space for the icon |
| 1072 delta.setWidth(0); | 1083 delta.setWidth(0); |
| 1073 if (abs(delta.height()) <= | 1084 if (abs(delta.height()) <= |
| 1074 AutoscrollController::noMiddleClickAutoscrollRadius) | 1085 AutoscrollController::noMiddleClickAutoscrollRadius) |
| 1075 delta.setHeight(0); | 1086 delta.setHeight(0); |
| 1076 scroll(ScrollByPixel, FloatSize(adjustedScrollDelta(delta))); | 1087 scroll(ScrollByPixel, FloatSize(adjustedScrollDelta(delta))); |
| 1077 } | 1088 } |
| 1078 | 1089 |
| 1079 void LayoutBox::scrollByRecursively(const DoubleSize& delta, | 1090 void LayoutBox::scrollByRecursively(const DoubleSize& delta) { |
| 1080 ScrollOffsetClamping clamp) { | |
| 1081 if (delta.isZero()) | 1091 if (delta.isZero()) |
| 1082 return; | 1092 return; |
| 1083 | 1093 |
| 1084 bool restrictedByLineClamp = false; | 1094 bool restrictedByLineClamp = false; |
| 1085 if (parent()) | 1095 if (parent()) |
| 1086 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 1096 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
| 1087 | 1097 |
| 1088 if (hasOverflowClip() && !restrictedByLineClamp) { | 1098 if (hasOverflowClip() && !restrictedByLineClamp) { |
| 1089 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); | 1099 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); |
| 1090 ASSERT(scrollableArea); | 1100 ASSERT(scrollableArea); |
| 1091 | 1101 |
| 1092 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + delta; | 1102 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + delta; |
| 1093 scrollableArea->scrollToOffset(newScrollOffset, clamp); | 1103 scrollableArea->scrollToOffset(newScrollOffset); |
| 1094 | 1104 |
| 1095 // If this layer can't do the scroll we ask the next layer up that can scrol l to try | 1105 // If this layer can't do the scroll we ask the next layer up that can scrol l to try |
| 1096 DoubleSize remainingScrollOffset = | 1106 DoubleSize remainingScrollOffset = |
| 1097 newScrollOffset - scrollableArea->adjustedScrollOffset(); | 1107 newScrollOffset - scrollableArea->adjustedScrollOffset(); |
| 1098 if (!remainingScrollOffset.isZero() && parent()) { | 1108 if (!remainingScrollOffset.isZero() && parent()) { |
| 1099 if (LayoutBox* scrollableBox = enclosingScrollableBox()) | 1109 if (LayoutBox* scrollableBox = enclosingScrollableBox()) |
| 1100 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp); | 1110 scrollableBox->scrollByRecursively(remainingScrollOffset); |
| 1101 | 1111 |
| 1102 LocalFrame* frame = this->frame(); | 1112 LocalFrame* frame = this->frame(); |
| 1103 if (frame && frame->page()) | 1113 if (frame && frame->page()) |
| 1104 frame->page()->autoscrollController().updateAutoscrollLayoutObject(); | 1114 frame->page()->autoscrollController().updateAutoscrollLayoutObject(); |
| 1105 } | 1115 } |
| 1106 } else if (view()->frameView()) { | 1116 } else if (view()->frameView()) { |
| 1107 // If we are here, we were called on a layoutObject that can be programmatic ally scrolled, but doesn't | 1117 // If we are here, we were called on a layoutObject that can be programmatic ally scrolled, but doesn't |
| 1108 // have an overflow clip. Which means that it is a document node that can be scrolled. | 1118 // have an overflow clip. Which means that it is a document node that can be scrolled. |
| 1109 // FIXME: Pass in DoubleSize. crbug.com/414283. | 1119 // FIXME: Pass in DoubleSize. crbug.com/414283. |
| 1110 view()->frameView()->scrollBy(flooredIntSize(delta), UserScroll); | 1120 view()->frameView()->scrollBy(flooredIntSize(delta), UserScroll); |
| (...skipping 4366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5477 LayoutRect rect = frameRect(); | 5487 LayoutRect rect = frameRect(); |
| 5478 | 5488 |
| 5479 LayoutBlock* block = containingBlock(); | 5489 LayoutBlock* block = containingBlock(); |
| 5480 if (block) | 5490 if (block) |
| 5481 block->adjustChildDebugRect(rect); | 5491 block->adjustChildDebugRect(rect); |
| 5482 | 5492 |
| 5483 return rect; | 5493 return rect; |
| 5484 } | 5494 } |
| 5485 | 5495 |
| 5486 } // namespace blink | 5496 } // namespace blink |
| OLD | NEW |