| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 if (box().frame() && box().frame()->page()) { | 121 if (box().frame() && box().frame()->page()) { |
| 122 if (ScrollingCoordinator* scrollingCoordinator = box().frame()->page()->
scrollingCoordinator()) | 122 if (ScrollingCoordinator* scrollingCoordinator = box().frame()->page()->
scrollingCoordinator()) |
| 123 scrollingCoordinator->willDestroyScrollableArea(this); | 123 scrollingCoordinator->willDestroyScrollableArea(this); |
| 124 } | 124 } |
| 125 | 125 |
| 126 if (!box().documentBeingDestroyed()) { | 126 if (!box().documentBeingDestroyed()) { |
| 127 Node* node = box().node(); | 127 Node* node = box().node(); |
| 128 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/4142
83. |
| 128 if (node && node->isElementNode()) | 129 if (node && node->isElementNode()) |
| 129 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset); | 130 toElement(node)->setSavedLayerScrollOffset(flooredIntSize(m_scrollOf
fset)); |
| 130 } | 131 } |
| 131 | 132 |
| 132 if (LocalFrame* frame = box().frame()) { | 133 if (LocalFrame* frame = box().frame()) { |
| 133 if (FrameView* frameView = frame->view()) | 134 if (FrameView* frameView = frame->view()) |
| 134 frameView->removeResizerArea(box()); | 135 frameView->removeResizerArea(box()); |
| 135 } | 136 } |
| 136 | 137 |
| 137 destroyScrollbar(HorizontalScrollbar); | 138 destroyScrollbar(HorizontalScrollbar); |
| 138 destroyScrollbar(VerticalScrollbar); | 139 destroyScrollbar(VerticalScrollbar); |
| 139 | 140 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 338 } |
| 338 | 339 |
| 339 int RenderLayerScrollableArea::scrollSize(ScrollbarOrientation orientation) cons
t | 340 int RenderLayerScrollableArea::scrollSize(ScrollbarOrientation orientation) cons
t |
| 340 { | 341 { |
| 341 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; | 342 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
| 342 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); | 343 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
| 343 } | 344 } |
| 344 | 345 |
| 345 void RenderLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset) | 346 void RenderLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset) |
| 346 { | 347 { |
| 348 setScrollOffset(DoublePoint(newScrollOffset)); |
| 349 } |
| 350 |
| 351 void RenderLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffs
et) |
| 352 { |
| 347 if (!box().isMarquee()) { | 353 if (!box().isMarquee()) { |
| 348 // Ensure that the dimensions will be computed if they need to be (for o
verflow:hidden blocks). | 354 // Ensure that the dimensions will be computed if they need to be (for o
verflow:hidden blocks). |
| 349 if (m_scrollDimensionsDirty) | 355 if (m_scrollDimensionsDirty) |
| 350 computeScrollDimensions(); | 356 computeScrollDimensions(); |
| 351 } | 357 } |
| 352 | 358 |
| 353 if (scrollOffset() == toIntSize(newScrollOffset)) | 359 if (scrollOffset() == toDoubleSize(newScrollOffset)) |
| 354 return; | 360 return; |
| 355 | 361 |
| 356 m_scrollOffset = toIntSize(newScrollOffset); | 362 m_scrollOffset = toDoubleSize(newScrollOffset); |
| 357 | 363 |
| 358 LocalFrame* frame = box().frame(); | 364 LocalFrame* frame = box().frame(); |
| 359 ASSERT(frame); | 365 ASSERT(frame); |
| 360 | 366 |
| 361 RefPtr<FrameView> frameView = box().frameView(); | 367 RefPtr<FrameView> frameView = box().frameView(); |
| 362 | 368 |
| 363 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ScrollLayer",
"data", InspectorScrollLayerEvent::data(&box())); | 369 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ScrollLayer",
"data", InspectorScrollLayerEvent::data(&box())); |
| 364 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 370 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
| 365 InspectorInstrumentation::willScrollLayer(&box()); | 371 InspectorInstrumentation::willScrollLayer(&box()); |
| 366 | 372 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 box().node()->document().enqueueScrollEventForNode(box().node()); | 416 box().node()->document().enqueueScrollEventForNode(box().node()); |
| 411 | 417 |
| 412 if (AXObjectCache* cache = box().document().existingAXObjectCache()) | 418 if (AXObjectCache* cache = box().document().existingAXObjectCache()) |
| 413 cache->handleScrollPositionChanged(&box()); | 419 cache->handleScrollPositionChanged(&box()); |
| 414 | 420 |
| 415 InspectorInstrumentation::didScrollLayer(&box()); | 421 InspectorInstrumentation::didScrollLayer(&box()); |
| 416 } | 422 } |
| 417 | 423 |
| 418 IntPoint RenderLayerScrollableArea::scrollPosition() const | 424 IntPoint RenderLayerScrollableArea::scrollPosition() const |
| 419 { | 425 { |
| 420 return IntPoint(m_scrollOffset); | 426 return IntPoint(flooredIntSize(m_scrollOffset)); |
| 427 } |
| 428 |
| 429 DoublePoint RenderLayerScrollableArea::scrollPositionDouble() const |
| 430 { |
| 431 return DoublePoint(m_scrollOffset); |
| 421 } | 432 } |
| 422 | 433 |
| 423 IntPoint RenderLayerScrollableArea::minimumScrollPosition() const | 434 IntPoint RenderLayerScrollableArea::minimumScrollPosition() const |
| 424 { | 435 { |
| 425 return -scrollOrigin(); | 436 return -scrollOrigin(); |
| 426 } | 437 } |
| 427 | 438 |
| 428 IntPoint RenderLayerScrollableArea::maximumScrollPosition() const | 439 IntPoint RenderLayerScrollableArea::maximumScrollPosition() const |
| 429 { | 440 { |
| 430 if (!box().hasOverflowClip()) | 441 if (!box().hasOverflowClip()) |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 m_scrollDimensionsDirty = false; | 566 m_scrollDimensionsDirty = false; |
| 556 | 567 |
| 557 m_overflowRect = box().layoutOverflowRect(); | 568 m_overflowRect = box().layoutOverflowRect(); |
| 558 box().flipForWritingMode(m_overflowRect); | 569 box().flipForWritingMode(m_overflowRect); |
| 559 | 570 |
| 560 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box(
).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr
ollbarWidth() : 0); | 571 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box(
).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr
ollbarWidth() : 0); |
| 561 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); | 572 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); |
| 562 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); | 573 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); |
| 563 } | 574 } |
| 564 | 575 |
| 565 void RenderLayerScrollableArea::scrollToOffset(const IntSize& scrollOffset, Scro
llOffsetClamping clamp) | 576 void RenderLayerScrollableArea::scrollToOffset(const DoubleSize& scrollOffset, S
crollOffsetClamping clamp) |
| 566 { | 577 { |
| 567 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s
crollOffset) : scrollOffset; | 578 DoubleSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffse
t(scrollOffset) : scrollOffset; |
| 568 if (newScrollOffset != adjustedScrollOffset()) | 579 if (newScrollOffset != adjustedScrollOffset()) { |
| 569 scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset); | 580 DoublePoint origin(scrollOrigin()); |
| 581 // FIXME: Make scrollToOffsetWithoutAnimation take DoublePoint. crbug.co
m/414283. |
| 582 scrollToOffsetWithoutAnimation(toFloatPoint(-origin + newScrollOffset)); |
| 583 } |
| 570 } | 584 } |
| 571 | 585 |
| 572 void RenderLayerScrollableArea::updateAfterLayout() | 586 void RenderLayerScrollableArea::updateAfterLayout() |
| 573 { | 587 { |
| 574 m_scrollDimensionsDirty = true; | 588 m_scrollDimensionsDirty = true; |
| 575 IntSize originalScrollOffset = adjustedScrollOffset(); | 589 DoubleSize originalScrollOffset = adjustedScrollOffset(); |
| 576 | 590 |
| 577 computeScrollDimensions(); | 591 computeScrollDimensions(); |
| 578 | 592 |
| 579 if (!box().isMarquee()) { | 593 if (!box().isMarquee()) { |
| 580 // Layout may cause us to be at an invalid scroll position. In this case
we need | 594 // Layout may cause us to be at an invalid scroll position. In this case
we need |
| 581 // to pull our scroll offsets back to the max (or push them up to the mi
n). | 595 // to pull our scroll offsets back to the max (or push them up to the mi
n). |
| 582 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); | 596 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset(
)); |
| 583 if (clampedScrollOffset != adjustedScrollOffset()) | 597 if (clampedScrollOffset != adjustedScrollOffset()) |
| 584 scrollToOffset(clampedScrollOffset); | 598 scrollToOffset(clampedScrollOffset); |
| 585 } | 599 } |
| 586 | 600 |
| 587 if (originalScrollOffset != adjustedScrollOffset()) | 601 if (originalScrollOffset != adjustedScrollOffset()) { |
| 588 scrollToOffsetWithoutAnimation(-scrollOrigin() + adjustedScrollOffset())
; | 602 DoublePoint origin(scrollOrigin()); |
| 603 scrollToOffsetWithoutAnimation(toFloatPoint(-origin + adjustedScrollOffs
et())); |
| 604 } |
| 589 | 605 |
| 590 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 606 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 591 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 607 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 592 | 608 |
| 593 { | 609 { |
| 594 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. | 610 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html. |
| 595 DisableCompositingQueryAsserts disabler; | 611 DisableCompositingQueryAsserts disabler; |
| 596 | 612 |
| 597 // overflow:scroll should just enable/disable. | 613 // overflow:scroll should just enable/disable. |
| 598 if (box().style()->overflowX() == OSCROLL) | 614 if (box().style()->overflowX() == OSCROLL) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 } | 784 } |
| 769 | 785 |
| 770 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 786 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 771 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 787 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 772 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() &&
(hasHorizontalScrollbar() != hasHorizontalOverflow); | 788 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() &&
(hasHorizontalScrollbar() != hasHorizontalOverflow); |
| 773 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has
VerticalScrollbar() != hasVerticalOverflow); | 789 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has
VerticalScrollbar() != hasVerticalOverflow); |
| 774 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) | 790 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) |
| 775 box().setNeedsLayoutAndFullPaintInvalidation(); | 791 box().setNeedsLayoutAndFullPaintInvalidation(); |
| 776 } | 792 } |
| 777 | 793 |
| 778 IntSize RenderLayerScrollableArea::clampScrollOffset(const IntSize& scrollOffset
) const | 794 DoubleSize RenderLayerScrollableArea::clampScrollOffset(const DoubleSize& scroll
Offset) const |
| 779 { | 795 { |
| 780 int maxX = scrollWidth() - box().pixelSnappedClientWidth(); | 796 int maxX = scrollWidth() - box().pixelSnappedClientWidth(); |
| 781 int maxY = scrollHeight() - box().pixelSnappedClientHeight(); | 797 int maxY = scrollHeight() - box().pixelSnappedClientHeight(); |
| 782 | 798 |
| 783 int x = std::max(std::min(scrollOffset.width(), maxX), 0); | 799 double x = std::max(std::min(scrollOffset.width(), static_cast<double>(maxX)
), 0.0); |
| 784 int y = std::max(std::min(scrollOffset.height(), maxY), 0); | 800 double y = std::max(std::min(scrollOffset.height(), static_cast<double>(maxY
)), 0.0); |
| 785 return IntSize(x, y); | 801 return DoubleSize(x, y); |
| 786 } | 802 } |
| 787 | 803 |
| 788 IntRect RenderLayerScrollableArea::rectForHorizontalScrollbar(const IntRect& bor
derBoxRect) const | 804 IntRect RenderLayerScrollableArea::rectForHorizontalScrollbar(const IntRect& bor
derBoxRect) const |
| 789 { | 805 { |
| 790 if (!m_hBar) | 806 if (!m_hBar) |
| 791 return IntRect(); | 807 return IntRect(); |
| 792 | 808 |
| 793 const IntRect& scrollCorner = scrollCornerRect(); | 809 const IntRect& scrollCorner = scrollCornerRect(); |
| 794 | 810 |
| 795 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), | 811 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 | 1394 |
| 1379 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. | 1395 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. |
| 1380 } | 1396 } |
| 1381 | 1397 |
| 1382 LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const S
crollAlignment& alignX, const ScrollAlignment& alignY) | 1398 LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const S
crollAlignment& alignX, const ScrollAlignment& alignY) |
| 1383 { | 1399 { |
| 1384 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec
t)), UseTransforms).boundingBox()); | 1400 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec
t)), UseTransforms).boundingBox()); |
| 1385 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight()); | 1401 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight()); |
| 1386 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect
, alignX, alignY); | 1402 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect
, alignX, alignY); |
| 1387 | 1403 |
| 1388 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() + toI
ntSize(roundedIntRect(r).location())); | 1404 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() +
toIntSize(roundedIntRect(r).location())); |
| 1389 if (clampedScrollOffset == adjustedScrollOffset()) | 1405 if (clampedScrollOffset == adjustedScrollOffset()) |
| 1390 return rect; | 1406 return rect; |
| 1391 | 1407 |
| 1392 IntSize oldScrollOffset = adjustedScrollOffset(); | 1408 DoubleSize oldScrollOffset = adjustedScrollOffset(); |
| 1393 scrollToOffset(clampedScrollOffset); | 1409 scrollToOffset(clampedScrollOffset); |
| 1394 IntSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset; | 1410 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset
; |
| 1395 localExposeRect.move(-scrollOffsetDifference); | 1411 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); |
| 1396 return LayoutRect(box().localToAbsoluteQuad(FloatQuad(FloatRect(localExposeR
ect)), UseTransforms).boundingBox()); | 1412 return LayoutRect(box().localToAbsoluteQuad(FloatQuad(FloatRect(localExposeR
ect)), UseTransforms).boundingBox()); |
| 1397 } | 1413 } |
| 1398 | 1414 |
| 1399 void RenderLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) | 1415 void RenderLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) |
| 1400 { | 1416 { |
| 1401 LocalFrame* frame = box().frame(); | 1417 LocalFrame* frame = box().frame(); |
| 1402 if (!frame) | 1418 if (!frame) |
| 1403 return; | 1419 return; |
| 1404 | 1420 |
| 1405 FrameView* frameView = frame->view(); | 1421 FrameView* frameView = frame->view(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild) | 1486 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild) |
| 1471 { | 1487 { |
| 1472 // We only want to track the topmost scroll child for scrollable areas with | 1488 // We only want to track the topmost scroll child for scrollable areas with |
| 1473 // overlay scrollbars. | 1489 // overlay scrollbars. |
| 1474 if (!hasOverlayScrollbars()) | 1490 if (!hasOverlayScrollbars()) |
| 1475 return; | 1491 return; |
| 1476 m_nextTopmostScrollChild = scrollChild; | 1492 m_nextTopmostScrollChild = scrollChild; |
| 1477 } | 1493 } |
| 1478 | 1494 |
| 1479 } // namespace blink | 1495 } // namespace blink |
| OLD | NEW |