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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 | 46 |
47 #include "core/css/PseudoStyleRequest.h" | 47 #include "core/css/PseudoStyleRequest.h" |
48 #include "core/dom/shadow/ShadowRoot.h" | 48 #include "core/dom/shadow/ShadowRoot.h" |
49 #include "core/editing/FrameSelection.h" | 49 #include "core/editing/FrameSelection.h" |
50 #include "core/html/HTMLFrameOwnerElement.h" | 50 #include "core/html/HTMLFrameOwnerElement.h" |
51 #include "core/inspector/InspectorInstrumentation.h" | 51 #include "core/inspector/InspectorInstrumentation.h" |
52 #include "core/page/EventHandler.h" | 52 #include "core/page/EventHandler.h" |
53 #include "core/page/FocusController.h" | 53 #include "core/page/FocusController.h" |
54 #include "core/frame/Frame.h" | 54 #include "core/frame/Frame.h" |
55 #include "core/frame/FrameView.h" | 55 #include "core/frame/FrameView.h" |
56 #include "core/frame/Settings.h" | |
56 #include "core/page/Page.h" | 57 #include "core/page/Page.h" |
57 #include "core/page/scrolling/ScrollingCoordinator.h" | 58 #include "core/page/scrolling/ScrollingCoordinator.h" |
58 #include "core/rendering/CompositedLayerMapping.h" | 59 #include "core/rendering/CompositedLayerMapping.h" |
59 #include "core/rendering/LayoutRectRecorder.h" | 60 #include "core/rendering/LayoutRectRecorder.h" |
60 #include "core/rendering/RenderGeometryMap.h" | 61 #include "core/rendering/RenderGeometryMap.h" |
61 #include "core/rendering/RenderLayerCompositor.h" | 62 #include "core/rendering/RenderLayerCompositor.h" |
62 #include "core/rendering/RenderScrollbar.h" | 63 #include "core/rendering/RenderScrollbar.h" |
63 #include "core/rendering/RenderScrollbarPart.h" | 64 #include "core/rendering/RenderScrollbarPart.h" |
64 #include "core/rendering/RenderView.h" | 65 #include "core/rendering/RenderView.h" |
65 #include "platform/PlatformGestureEvent.h" | 66 #include "platform/PlatformGestureEvent.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 104 |
104 RenderLayerScrollableArea::~RenderLayerScrollableArea() | 105 RenderLayerScrollableArea::~RenderLayerScrollableArea() |
105 { | 106 { |
106 if (inResizeMode() && !m_box->documentBeingDestroyed()) { | 107 if (inResizeMode() && !m_box->documentBeingDestroyed()) { |
107 if (Frame* frame = m_box->frame()) | 108 if (Frame* frame = m_box->frame()) |
108 frame->eventHandler().resizeScrollableAreaDestroyed(); | 109 frame->eventHandler().resizeScrollableAreaDestroyed(); |
109 } | 110 } |
110 | 111 |
111 if (Frame* frame = m_box->frame()) { | 112 if (Frame* frame = m_box->frame()) { |
112 if (FrameView* frameView = frame->view()) { | 113 if (FrameView* frameView = frame->view()) { |
113 frameView->removeScrollableArea(this); | 114 frameView->removeScrollableArea(this); |
Ian Vollick
2014/02/06 16:02:31
Can't we just removeAnimationScrollableArea from r
| |
115 frameView->removeAnimatingScrollableArea(this); | |
114 } | 116 } |
115 } | 117 } |
116 | 118 |
117 if (m_box->frame() && m_box->frame()->page()) { | 119 if (m_box->frame() && m_box->frame()->page()) { |
118 if (ScrollingCoordinator* scrollingCoordinator = m_box->frame()->page()- >scrollingCoordinator()) | 120 if (ScrollingCoordinator* scrollingCoordinator = m_box->frame()->page()- >scrollingCoordinator()) |
119 scrollingCoordinator->willDestroyScrollableArea(this); | 121 scrollingCoordinator->willDestroyScrollableArea(this); |
120 } | 122 } |
121 | 123 |
122 if (!m_box->documentBeingDestroyed()) { | 124 if (!m_box->documentBeingDestroyed()) { |
123 Node* node = m_box->node(); | 125 Node* node = m_box->node(); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 int RenderLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const | 505 int RenderLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const |
504 { | 506 { |
505 int length = (orientation == HorizontalScrollbar) ? | 507 int length = (orientation == HorizontalScrollbar) ? |
506 m_box->pixelSnappedClientWidth() : m_box->pixelSnappedClientHeight(); | 508 m_box->pixelSnappedClientWidth() : m_box->pixelSnappedClientHeight(); |
507 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo StepWhenPaging(); | 509 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo StepWhenPaging(); |
508 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa ges()); | 510 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa ges()); |
509 | 511 |
510 return max(pageStep, 1); | 512 return max(pageStep, 1); |
511 } | 513 } |
512 | 514 |
515 bool RenderLayerScrollableArea::registerForAnimation() | |
516 { | |
517 if (Frame* frame = m_box->frame()) { | |
518 if (FrameView* frameView = frame->view()) | |
519 return frameView->addAnimatingScrollableArea(this); | |
520 } | |
521 return false; | |
522 } | |
523 | |
524 void RenderLayerScrollableArea::deregisterForAnimation() | |
525 { | |
526 if (Frame* frame = m_box->frame()) { | |
527 if (FrameView* frameView = frame->view()) | |
528 frameView->removeAnimatingScrollableArea(this); | |
529 } | |
530 } | |
531 | |
532 bool RenderLayerScrollableArea::scheduleAnimation() | |
533 { | |
534 if (Frame* frame = m_box->frame()) { | |
535 if (FrameView* frameView = frame->view()) | |
536 return frameView->scheduleAnimation(); | |
537 } | |
538 return false; | |
539 } | |
540 | |
541 bool RenderLayerScrollableArea::compositedScrollAnimationsEnabled() const | |
542 { | |
543 if (Settings* settings = m_box->document().settings()) | |
544 return settings->compositorDrivenScrollAnimationsEnabled(); | |
545 return false; | |
546 } | |
547 | |
513 RenderLayer* RenderLayerScrollableArea::layer() const | 548 RenderLayer* RenderLayerScrollableArea::layer() const |
514 { | 549 { |
515 return m_box->layer(); | 550 return m_box->layer(); |
516 } | 551 } |
517 | 552 |
518 int RenderLayerScrollableArea::scrollWidth() const | 553 int RenderLayerScrollableArea::scrollWidth() const |
519 { | 554 { |
520 if (m_scrollDimensionsDirty) | 555 if (m_scrollDimensionsDirty) |
521 const_cast<RenderLayerScrollableArea*>(this)->computeScrollDimensions(); | 556 const_cast<RenderLayerScrollableArea*>(this)->computeScrollDimensions(); |
522 return snapSizeToPixel(m_overflowRect.width(), m_box->clientLeft() + m_box-> x()); | 557 return snapSizeToPixel(m_overflowRect.width(), m_box->clientLeft() + m_box-> x()); |
(...skipping 11 matching lines...) Expand all Loading... | |
534 m_scrollDimensionsDirty = false; | 569 m_scrollDimensionsDirty = false; |
535 | 570 |
536 m_overflowRect = m_box->layoutOverflowRect(); | 571 m_overflowRect = m_box->layoutOverflowRect(); |
537 m_box->flipForWritingMode(m_overflowRect); | 572 m_box->flipForWritingMode(m_overflowRect); |
538 | 573 |
539 int scrollableLeftOverflow = m_overflowRect.x() - m_box->borderLeft() - (m_b ox->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? m_box->vertical ScrollbarWidth() : 0); | 574 int scrollableLeftOverflow = m_overflowRect.x() - m_box->borderLeft() - (m_b ox->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? m_box->vertical ScrollbarWidth() : 0); |
540 int scrollableTopOverflow = m_overflowRect.y() - m_box->borderTop(); | 575 int scrollableTopOverflow = m_overflowRect.y() - m_box->borderTop(); |
541 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); | 576 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); |
542 } | 577 } |
543 | 578 |
544 void RenderLayerScrollableArea::scrollToOffset(const IntSize& scrollOffset, Scro llOffsetClamping clamp) | 579 void RenderLayerScrollableArea::scrollToOffset(const IntSize& scrollOffset, Scro llOffsetClamping clamp, ScrollBehavior scrollBehavior) |
545 { | 580 { |
581 cancelProgrammaticScrollAnimation(); | |
546 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s crollOffset) : scrollOffset; | 582 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s crollOffset) : scrollOffset; |
547 if (newScrollOffset != adjustedScrollOffset()) | 583 if (scrollBehavior == ScrollBehaviorAuto) |
548 scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset); | 584 scrollBehavior = m_box->style()->scrollBehavior(); |
585 if (newScrollOffset != adjustedScrollOffset()) { | |
586 if (scrollBehavior == ScrollBehaviorSmooth) | |
587 programmaticallyScrollSmoothlyToOffset(-scrollOrigin() + newScrollOf fset); | |
588 else | |
589 scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset); | |
590 } | |
549 } | 591 } |
550 | 592 |
551 void RenderLayerScrollableArea::updateAfterLayout() | 593 void RenderLayerScrollableArea::updateAfterLayout() |
552 { | 594 { |
553 // List box parts handle the scrollbars by themselves so we have nothing to do. | 595 // List box parts handle the scrollbars by themselves so we have nothing to do. |
554 if (m_box->style()->appearance() == ListboxPart) | 596 if (m_box->style()->appearance() == ListboxPart) |
555 return; | 597 return; |
556 | 598 |
557 LayoutRectRecorder recorder(*m_box); | 599 LayoutRectRecorder recorder(*m_box); |
558 | 600 |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1325 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight + difference.height()), CSSPrimitiveValue::CSS_PX); | 1367 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight + difference.height()), CSSPrimitiveValue::CSS_PX); |
1326 } | 1368 } |
1327 | 1369 |
1328 document.updateLayout(); | 1370 document.updateLayout(); |
1329 | 1371 |
1330 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view. | 1372 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view. |
1331 } | 1373 } |
1332 | 1374 |
1333 LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const S crollAlignment& alignX, const ScrollAlignment& alignY) | 1375 LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const S crollAlignment& alignX, const ScrollAlignment& alignY) |
1334 { | 1376 { |
1377 cancelProgrammaticScrollAnimation(); | |
1335 LayoutRect localExposeRect(m_box->absoluteToLocalQuad(FloatQuad(FloatRect(re ct)), UseTransforms).boundingBox()); | 1378 LayoutRect localExposeRect(m_box->absoluteToLocalQuad(FloatQuad(FloatRect(re ct)), UseTransforms).boundingBox()); |
1336 LayoutRect layerBounds(0, 0, m_box->clientWidth(), m_box->clientHeight()); | 1379 LayoutRect layerBounds(0, 0, m_box->clientWidth(), m_box->clientHeight()); |
1337 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect , alignX, alignY); | 1380 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect , alignX, alignY); |
1338 | 1381 |
1339 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() + toI ntSize(roundedIntRect(r).location())); | 1382 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() + toI ntSize(roundedIntRect(r).location())); |
1340 if (clampedScrollOffset == adjustedScrollOffset()) | 1383 if (clampedScrollOffset == adjustedScrollOffset()) |
1341 return rect; | 1384 return rect; |
1342 | 1385 |
1343 IntSize oldScrollOffset = adjustedScrollOffset(); | 1386 IntSize oldScrollOffset = adjustedScrollOffset(); |
1344 scrollToOffset(clampedScrollOffset); | 1387 scrollToOffset(clampedScrollOffset); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1495 void RenderLayerScrollableArea::setForceNeedsCompositedScrolling(ForceNeedsCompo sitedScrollingMode mode) | 1538 void RenderLayerScrollableArea::setForceNeedsCompositedScrolling(ForceNeedsCompo sitedScrollingMode mode) |
1496 { | 1539 { |
1497 if (m_forceNeedsCompositedScrolling == mode) | 1540 if (m_forceNeedsCompositedScrolling == mode) |
1498 return; | 1541 return; |
1499 | 1542 |
1500 m_forceNeedsCompositedScrolling = mode; | 1543 m_forceNeedsCompositedScrolling = mode; |
1501 layer()->didUpdateNeedsCompositedScrolling(); | 1544 layer()->didUpdateNeedsCompositedScrolling(); |
1502 } | 1545 } |
1503 | 1546 |
1504 } // Namespace WebCore | 1547 } // Namespace WebCore |
OLD | NEW |