Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: Source/core/rendering/RenderLayerScrollableArea.cpp

Issue 134443003: Implement CSSOM Smooth Scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 #include "config.h" 44 #include "config.h"
45 #include "core/rendering/RenderLayer.h" 45 #include "core/rendering/RenderLayer.h"
46 46
47 #include "core/accessibility/AXObjectCache.h" 47 #include "core/accessibility/AXObjectCache.h"
48 #include "core/css/PseudoStyleRequest.h" 48 #include "core/css/PseudoStyleRequest.h"
49 #include "core/dom/shadow/ShadowRoot.h" 49 #include "core/dom/shadow/ShadowRoot.h"
50 #include "core/editing/FrameSelection.h" 50 #include "core/editing/FrameSelection.h"
51 #include "core/frame/FrameView.h" 51 #include "core/frame/FrameView.h"
52 #include "core/frame/LocalFrame.h" 52 #include "core/frame/LocalFrame.h"
53 #include "core/frame/Settings.h"
53 #include "core/html/HTMLFrameOwnerElement.h" 54 #include "core/html/HTMLFrameOwnerElement.h"
54 #include "core/inspector/InspectorInstrumentation.h" 55 #include "core/inspector/InspectorInstrumentation.h"
55 #include "core/inspector/InspectorTraceEvents.h" 56 #include "core/inspector/InspectorTraceEvents.h"
56 #include "core/page/EventHandler.h" 57 #include "core/page/EventHandler.h"
57 #include "core/page/FocusController.h" 58 #include "core/page/FocusController.h"
58 #include "core/page/Page.h" 59 #include "core/page/Page.h"
59 #include "core/page/scrolling/ScrollingCoordinator.h" 60 #include "core/page/scrolling/ScrollingCoordinator.h"
60 #include "core/rendering/RenderGeometryMap.h" 61 #include "core/rendering/RenderGeometryMap.h"
61 #include "core/rendering/RenderScrollbar.h" 62 #include "core/rendering/RenderScrollbar.h"
62 #include "core/rendering/RenderScrollbarPart.h" 63 #include "core/rendering/RenderScrollbarPart.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 RenderLayerScrollableArea::~RenderLayerScrollableArea() 105 RenderLayerScrollableArea::~RenderLayerScrollableArea()
105 { 106 {
106 if (inResizeMode() && !box().documentBeingDestroyed()) { 107 if (inResizeMode() && !box().documentBeingDestroyed()) {
107 if (LocalFrame* frame = box().frame()) 108 if (LocalFrame* frame = box().frame())
108 frame->eventHandler().resizeScrollableAreaDestroyed(); 109 frame->eventHandler().resizeScrollableAreaDestroyed();
109 } 110 }
110 111
111 if (LocalFrame* frame = box().frame()) { 112 if (LocalFrame* frame = box().frame()) {
112 if (FrameView* frameView = frame->view()) { 113 if (FrameView* frameView = frame->view()) {
113 frameView->removeScrollableArea(this); 114 frameView->removeScrollableArea(this);
115 frameView->removeAnimatingScrollableArea(this);
114 } 116 }
115 } 117 }
116 118
117 if (box().frame() && box().frame()->page()) { 119 if (box().frame() && box().frame()->page()) {
118 if (ScrollingCoordinator* scrollingCoordinator = box().frame()->page()-> scrollingCoordinator()) 120 if (ScrollingCoordinator* scrollingCoordinator = box().frame()->page()-> scrollingCoordinator())
119 scrollingCoordinator->willDestroyScrollableArea(this); 121 scrollingCoordinator->willDestroyScrollableArea(this);
120 } 122 }
121 123
122 if (!box().documentBeingDestroyed()) { 124 if (!box().documentBeingDestroyed()) {
123 Node* node = box().node(); 125 Node* node = box().node();
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 int RenderLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const 513 int RenderLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const
512 { 514 {
513 int length = (orientation == HorizontalScrollbar) ? 515 int length = (orientation == HorizontalScrollbar) ?
514 box().pixelSnappedClientWidth() : box().pixelSnappedClientHeight(); 516 box().pixelSnappedClientWidth() : box().pixelSnappedClientHeight();
515 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo StepWhenPaging(); 517 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo StepWhenPaging();
516 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa ges()); 518 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa ges());
517 519
518 return max(pageStep, 1); 520 return max(pageStep, 1);
519 } 521 }
520 522
523 void RenderLayerScrollableArea::registerForAnimation()
524 {
525 box().frameView()->addAnimatingScrollableArea(this);
526 }
527
528 void RenderLayerScrollableArea::deregisterForAnimation()
529 {
530 if (FrameView* frameView = box().frameView()) {
531 frameView->removeAnimatingScrollableArea(this);
532 }
533 }
534
535 bool RenderLayerScrollableArea::scheduleAnimation()
536 {
537 return box().frameView()->scheduleAnimation();
538 }
539
521 RenderBox& RenderLayerScrollableArea::box() const 540 RenderBox& RenderLayerScrollableArea::box() const
522 { 541 {
523 return *m_layer.renderBox(); 542 return *m_layer.renderBox();
524 } 543 }
525 544
526 RenderLayer* RenderLayerScrollableArea::layer() const 545 RenderLayer* RenderLayerScrollableArea::layer() const
527 { 546 {
528 return &m_layer; 547 return &m_layer;
529 } 548 }
530 549
(...skipping 26 matching lines...) Expand all
557 m_scrollDimensionsDirty = false; 576 m_scrollDimensionsDirty = false;
558 577
559 m_overflowRect = box().layoutOverflowRect(); 578 m_overflowRect = box().layoutOverflowRect();
560 box().flipForWritingMode(m_overflowRect); 579 box().flipForWritingMode(m_overflowRect);
561 580
562 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box( ).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr ollbarWidth() : 0); 581 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box( ).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr ollbarWidth() : 0);
563 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); 582 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop();
564 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); 583 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow));
565 } 584 }
566 585
567 void RenderLayerScrollableArea::scrollToOffset(const IntSize& scrollOffset, Scro llOffsetClamping clamp) 586 void RenderLayerScrollableArea::scrollToOffset(const IntSize& scrollOffset, Scro llOffsetClamping clamp, ScrollBehavior scrollBehavior)
568 { 587 {
588 cancelProgrammaticScrollAnimation();
569 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s crollOffset) : scrollOffset; 589 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s crollOffset) : scrollOffset;
570 if (newScrollOffset != adjustedScrollOffset()) 590 if (scrollBehavior == ScrollBehaviorAuto)
571 scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset); 591 scrollBehavior = box().style()->scrollBehavior();
592 if (newScrollOffset != adjustedScrollOffset()) {
593 if (scrollBehavior == ScrollBehaviorSmooth)
594 programmaticallyScrollSmoothlyToOffset(-scrollOrigin() + newScrollOf fset);
595 else
596 scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset);
597 }
572 } 598 }
573 599
574 void RenderLayerScrollableArea::updateAfterLayout() 600 void RenderLayerScrollableArea::updateAfterLayout()
575 { 601 {
576 // List box parts handle the scrollbars by themselves so we have nothing to do. 602 // List box parts handle the scrollbars by themselves so we have nothing to do.
577 if (box().style()->appearance() == ListboxPart) 603 if (box().style()->appearance() == ListboxPart)
578 return; 604 return;
579 605
580 m_scrollDimensionsDirty = true; 606 m_scrollDimensionsDirty = true;
581 IntSize originalScrollOffset = adjustedScrollOffset(); 607 IntSize originalScrollOffset = adjustedScrollOffset();
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight + difference.height()), CSSPrimitiveValue::CSS_PX); 1402 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight + difference.height()), CSSPrimitiveValue::CSS_PX);
1377 } 1403 }
1378 1404
1379 document.updateLayout(); 1405 document.updateLayout();
1380 1406
1381 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view. 1407 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view.
1382 } 1408 }
1383 1409
1384 LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const S crollAlignment& alignX, const ScrollAlignment& alignY) 1410 LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const S crollAlignment& alignX, const ScrollAlignment& alignY)
1385 { 1411 {
1412 cancelProgrammaticScrollAnimation();
1386 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec t)), UseTransforms).boundingBox()); 1413 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec t)), UseTransforms).boundingBox());
1387 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight()); 1414 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight());
1388 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect , alignX, alignY); 1415 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect , alignX, alignY);
1389 1416
1390 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() + toI ntSize(roundedIntRect(r).location())); 1417 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() + toI ntSize(roundedIntRect(r).location()));
1391 if (clampedScrollOffset == adjustedScrollOffset()) 1418 if (clampedScrollOffset == adjustedScrollOffset())
1392 return rect; 1419 return rect;
1393 1420
1394 IntSize oldScrollOffset = adjustedScrollOffset(); 1421 IntSize oldScrollOffset = adjustedScrollOffset();
1395 scrollToOffset(clampedScrollOffset); 1422 scrollToOffset(clampedScrollOffset);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild) 1491 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild)
1465 { 1492 {
1466 // We only want to track the topmost scroll child for scrollable areas with 1493 // We only want to track the topmost scroll child for scrollable areas with
1467 // overlay scrollbars. 1494 // overlay scrollbars.
1468 if (!hasOverlayScrollbars()) 1495 if (!hasOverlayScrollbars())
1469 return; 1496 return;
1470 m_nextTopmostScrollChild = scrollChild; 1497 m_nextTopmostScrollChild = scrollChild;
1471 } 1498 }
1472 1499
1473 } // Namespace WebCore 1500 } // Namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerScrollableArea.h ('k') | Source/core/rendering/RenderListBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698