| 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. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
| 7 * All rights reserved. | 7 * All rights reserved. |
| 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (isOrthogonalWritingModeRoot()) | 256 if (isOrthogonalWritingModeRoot()) |
| 257 markOrthogonalWritingModeRoot(); | 257 markOrthogonalWritingModeRoot(); |
| 258 else | 258 else |
| 259 unmarkOrthogonalWritingModeRoot(); | 259 unmarkOrthogonalWritingModeRoot(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 clearPercentHeightDescendants(); | 262 clearPercentHeightDescendants(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to | 265 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to |
| 266 // adjust that value into the new zoomed coordinate space. | 266 // adjust that value into the new zoomed coordinate space. Note that the new |
| 267 // scroll position may be outside the normal min/max range of the scrollable |
| 268 // area, which is weird but OK, because the scrollable area will update its |
| 269 // min/max in updateAfterLayout(). |
| 267 if (hasOverflowClip() && oldStyle && | 270 if (hasOverflowClip() && oldStyle && |
| 268 oldStyle->effectiveZoom() != newStyle.effectiveZoom()) { | 271 oldStyle->effectiveZoom() != newStyle.effectiveZoom()) { |
| 269 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); | 272 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); |
| 270 ASSERT(scrollableArea); | 273 ASSERT(scrollableArea); |
| 271 if (int left = scrollableArea->scrollXOffset()) { | 274 // We use scrollPosition() rather than adjustedScrollPosition(), because |
| 272 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); | 275 // scrollPosition is the distance from the beginning of flow for the box, |
| 273 scrollableArea->scrollToXOffset(left); | 276 // which is the dimension we want to preserve. |
| 274 } | 277 DoublePoint oldPosition = scrollableArea->scrollPositionDouble(); |
| 275 if (int top = scrollableArea->scrollYOffset()) { | 278 if (oldPosition.x() || oldPosition.y()) { |
| 276 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); | 279 DoublePoint newPosition = oldPosition.scaledBy(newStyle.effectiveZoom() / |
| 277 scrollableArea->scrollToYOffset(top); | 280 oldStyle->effectiveZoom()); |
| 281 scrollableArea->setScrollPositionUnconditionally(newPosition); |
| 278 } | 282 } |
| 279 } | 283 } |
| 280 | 284 |
| 281 // Our opaqueness might have changed without triggering layout. | 285 // Our opaqueness might have changed without triggering layout. |
| 282 if (diff.needsPaintInvalidation()) { | 286 if (diff.needsPaintInvalidation()) { |
| 283 LayoutObject* parentToInvalidate = parent(); | 287 LayoutObject* parentToInvalidate = parent(); |
| 284 for (unsigned i = 0; | 288 for (unsigned i = 0; |
| 285 i < backgroundObscurationTestMaxDepth && parentToInvalidate; ++i) { | 289 i < backgroundObscurationTestMaxDepth && parentToInvalidate; ++i) { |
| 286 parentToInvalidate->invalidateBackgroundObscurationStatus(); | 290 parentToInvalidate->invalidateBackgroundObscurationStatus(); |
| 287 parentToInvalidate = parentToInvalidate->parent(); | 291 parentToInvalidate = parentToInvalidate->parent(); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 519 |
| 516 LayoutUnit LayoutBox::scrollHeight() const { | 520 LayoutUnit LayoutBox::scrollHeight() const { |
| 517 if (hasOverflowClip()) | 521 if (hasOverflowClip()) |
| 518 return getScrollableArea()->scrollHeight(); | 522 return getScrollableArea()->scrollHeight(); |
| 519 // For objects with visible overflow, this matches IE. | 523 // For objects with visible overflow, this matches IE. |
| 520 // FIXME: Need to work right with writing modes. | 524 // FIXME: Need to work right with writing modes. |
| 521 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); | 525 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); |
| 522 } | 526 } |
| 523 | 527 |
| 524 LayoutUnit LayoutBox::scrollLeft() const { | 528 LayoutUnit LayoutBox::scrollLeft() const { |
| 525 return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollXOffset()) | 529 return hasOverflowClip() |
| 526 : LayoutUnit(); | 530 ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().width()) |
| 531 : LayoutUnit(); |
| 527 } | 532 } |
| 528 | 533 |
| 529 LayoutUnit LayoutBox::scrollTop() const { | 534 LayoutUnit LayoutBox::scrollTop() const { |
| 530 return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollYOffset()) | 535 return hasOverflowClip() |
| 531 : LayoutUnit(); | 536 ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().height()) |
| 537 : LayoutUnit(); |
| 532 } | 538 } |
| 533 | 539 |
| 534 int LayoutBox::pixelSnappedScrollWidth() const { | 540 int LayoutBox::pixelSnappedScrollWidth() const { |
| 535 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); | 541 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); |
| 536 } | 542 } |
| 537 | 543 |
| 538 int LayoutBox::pixelSnappedScrollHeight() const { | 544 int LayoutBox::pixelSnappedScrollHeight() const { |
| 539 if (hasOverflowClip()) | 545 if (hasOverflowClip()) |
| 540 return snapSizeToPixel(getScrollableArea()->scrollHeight(), | 546 return snapSizeToPixel(getScrollableArea()->scrollHeight(), |
| 541 location().y() + clientTop()); | 547 location().y() + clientTop()); |
| 542 // For objects with visible overflow, this matches IE. | 548 // For objects with visible overflow, this matches IE. |
| 543 // FIXME: Need to work right with writing modes. | 549 // FIXME: Need to work right with writing modes. |
| 544 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); | 550 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); |
| 545 } | 551 } |
| 546 | 552 |
| 547 void LayoutBox::setScrollLeft(LayoutUnit newLeft) { | 553 void LayoutBox::setScrollLeft(LayoutUnit newLeft) { |
| 548 // This doesn't hit in any tests, but since the equivalent code in | 554 // This doesn't hit in any tests, but since the equivalent code in |
| 549 // setScrollTop does, presumably this code does as well. | 555 // setScrollTop does, presumably this code does as well. |
| 550 DisableCompositingQueryAsserts disabler; | 556 DisableCompositingQueryAsserts disabler; |
| 551 | 557 |
| 552 if (hasOverflowClip()) | 558 if (hasOverflowClip()) { |
| 553 getScrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped, | 559 PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
| 554 ScrollBehaviorAuto); | 560 scrollableArea->scrollToOffset( |
| 561 DoubleSize(newLeft, scrollableArea->adjustedScrollOffset().height()), |
| 562 ScrollBehaviorAuto); |
| 563 } |
| 555 } | 564 } |
| 556 | 565 |
| 557 void LayoutBox::setScrollTop(LayoutUnit newTop) { | 566 void LayoutBox::setScrollTop(LayoutUnit newTop) { |
| 558 // Hits in | 567 // Hits in |
| 559 // compositing/overflow/do-not-assert-on-invisible-composited-layers.html | 568 // compositing/overflow/do-not-assert-on-invisible-composited-layers.html |
| 560 DisableCompositingQueryAsserts disabler; | 569 DisableCompositingQueryAsserts disabler; |
| 561 | 570 |
| 562 if (hasOverflowClip()) | 571 if (hasOverflowClip()) { |
| 563 getScrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped, | 572 PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
| 564 ScrollBehaviorAuto); | 573 scrollableArea->scrollToOffset( |
| 574 DoubleSize(scrollableArea->adjustedScrollOffset().width(), newTop), |
| 575 ScrollBehaviorAuto); |
| 576 } |
| 565 } | 577 } |
| 566 | 578 |
| 567 void LayoutBox::scrollToOffset(const DoubleSize& offset, | 579 void LayoutBox::scrollToOffset(const DoubleSize& offset, |
| 568 ScrollBehavior scrollBehavior) { | 580 ScrollBehavior scrollBehavior) { |
| 569 // This doesn't hit in any tests, but since the equivalent code in | 581 // This doesn't hit in any tests, but since the equivalent code in |
| 570 // setScrollTop does, presumably this code does as well. | 582 // setScrollTop does, presumably this code does as well. |
| 571 DisableCompositingQueryAsserts disabler; | 583 DisableCompositingQueryAsserts disabler; |
| 572 | 584 |
| 573 if (hasOverflowClip()) | 585 if (hasOverflowClip()) |
| 574 getScrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, | 586 getScrollableArea()->scrollToOffset(offset, scrollBehavior); |
| 575 scrollBehavior); | |
| 576 } | 587 } |
| 577 | 588 |
| 578 // Returns true iff we are attempting an autoscroll inside an iframe with | 589 // Returns true iff we are attempting an autoscroll inside an iframe with |
| 579 // scrolling="no". | 590 // scrolling="no". |
| 580 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, | 591 static bool isDisallowedAutoscroll(HTMLFrameOwnerElement* ownerElement, |
| 581 FrameView* frameView) { | 592 FrameView* frameView) { |
| 582 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { | 593 if (ownerElement && isHTMLFrameElementBase(*ownerElement)) { |
| 583 HTMLFrameElementBase* frameElementBase = | 594 HTMLFrameElementBase* frameElementBase = |
| 584 toHTMLFrameElementBase(ownerElement); | 595 toHTMLFrameElementBase(ownerElement); |
| 585 if (Page* page = frameView->frame().page()) { | 596 if (Page* page = frameView->frame().page()) { |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 | 1097 |
| 1087 // at the center we let the space for the icon. | 1098 // at the center we let the space for the icon. |
| 1088 if (abs(delta.width()) <= AutoscrollController::noMiddleClickAutoscrollRadius) | 1099 if (abs(delta.width()) <= AutoscrollController::noMiddleClickAutoscrollRadius) |
| 1089 delta.setWidth(0); | 1100 delta.setWidth(0); |
| 1090 if (abs(delta.height()) <= | 1101 if (abs(delta.height()) <= |
| 1091 AutoscrollController::noMiddleClickAutoscrollRadius) | 1102 AutoscrollController::noMiddleClickAutoscrollRadius) |
| 1092 delta.setHeight(0); | 1103 delta.setHeight(0); |
| 1093 scroll(ScrollByPixel, FloatSize(adjustedScrollDelta(delta))); | 1104 scroll(ScrollByPixel, FloatSize(adjustedScrollDelta(delta))); |
| 1094 } | 1105 } |
| 1095 | 1106 |
| 1096 void LayoutBox::scrollByRecursively(const DoubleSize& delta, | 1107 void LayoutBox::scrollByRecursively(const DoubleSize& delta) { |
| 1097 ScrollOffsetClamping clamp) { | |
| 1098 if (delta.isZero()) | 1108 if (delta.isZero()) |
| 1099 return; | 1109 return; |
| 1100 | 1110 |
| 1101 bool restrictedByLineClamp = false; | 1111 bool restrictedByLineClamp = false; |
| 1102 if (parent()) | 1112 if (parent()) |
| 1103 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 1113 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
| 1104 | 1114 |
| 1105 if (hasOverflowClip() && !restrictedByLineClamp) { | 1115 if (hasOverflowClip() && !restrictedByLineClamp) { |
| 1106 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); | 1116 PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); |
| 1107 ASSERT(scrollableArea); | 1117 ASSERT(scrollableArea); |
| 1108 | 1118 |
| 1109 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + delta; | 1119 DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + delta; |
| 1110 scrollableArea->scrollToOffset(newScrollOffset, clamp); | 1120 scrollableArea->scrollToOffset(newScrollOffset); |
| 1111 | 1121 |
| 1112 // If this layer can't do the scroll we ask the next layer up that can | 1122 // If this layer can't do the scroll we ask the next layer up that can |
| 1113 // scroll to try. | 1123 // scroll to try. |
| 1114 DoubleSize remainingScrollOffset = | 1124 DoubleSize remainingScrollOffset = |
| 1115 newScrollOffset - scrollableArea->adjustedScrollOffset(); | 1125 newScrollOffset - scrollableArea->adjustedScrollOffset(); |
| 1116 if (!remainingScrollOffset.isZero() && parent()) { | 1126 if (!remainingScrollOffset.isZero() && parent()) { |
| 1117 if (LayoutBox* scrollableBox = enclosingScrollableBox()) | 1127 if (LayoutBox* scrollableBox = enclosingScrollableBox()) |
| 1118 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp); | 1128 scrollableBox->scrollByRecursively(remainingScrollOffset); |
| 1119 | 1129 |
| 1120 LocalFrame* frame = this->frame(); | 1130 LocalFrame* frame = this->frame(); |
| 1121 if (frame && frame->page()) | 1131 if (frame && frame->page()) |
| 1122 frame->page()->autoscrollController().updateAutoscrollLayoutObject(); | 1132 frame->page()->autoscrollController().updateAutoscrollLayoutObject(); |
| 1123 } | 1133 } |
| 1124 } else if (view()->frameView()) { | 1134 } else if (view()->frameView()) { |
| 1125 // If we are here, we were called on a layoutObject that can be | 1135 // If we are here, we were called on a layoutObject that can be |
| 1126 // programmatically scrolled, but doesn't have an overflow clip. Which means | 1136 // programmatically scrolled, but doesn't have an overflow clip. Which means |
| 1127 // that it is a document node that can be scrolled. | 1137 // that it is a document node that can be scrolled. |
| 1128 // FIXME: Pass in DoubleSize. crbug.com/414283. | 1138 // FIXME: Pass in DoubleSize. crbug.com/414283. |
| (...skipping 4493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5622 LayoutRect rect = frameRect(); | 5632 LayoutRect rect = frameRect(); |
| 5623 | 5633 |
| 5624 LayoutBlock* block = containingBlock(); | 5634 LayoutBlock* block = containingBlock(); |
| 5625 if (block) | 5635 if (block) |
| 5626 block->adjustChildDebugRect(rect); | 5636 block->adjustChildDebugRect(rect); |
| 5627 | 5637 |
| 5628 return rect; | 5638 return rect; |
| 5629 } | 5639 } |
| 5630 | 5640 |
| 5631 } // namespace blink | 5641 } // namespace blink |
| OLD | NEW |