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

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

Issue 16982005: Allow objects without scrollbars to be scrollable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: CR fixes Created 7 years, 6 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
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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 } 1322 }
1323 1323
1324 return 0; 1324 return 0;
1325 } 1325 }
1326 1326
1327 IntRect RenderLayer::scrollableAreaBoundingBox() const 1327 IntRect RenderLayer::scrollableAreaBoundingBox() const
1328 { 1328 {
1329 return renderer()->absoluteBoundingBoxRect(); 1329 return renderer()->absoluteBoundingBoxRect();
1330 } 1330 }
1331 1331
1332 bool RenderLayer::userInputScrollable(ScrollbarOrientation orientation) const
1333 {
1334 RenderBox* box = renderBox();
1335 ASSERT(box);
1336
1337 EOverflow overflowStyle = (orientation == HorizontalScrollbar) ?
1338 renderer()->style()->overflowX() : renderer()->style()->overflowY();
1339 return (overflowStyle == OSCROLL || overflowStyle == OAUTO);
1340 }
1341
1342 int RenderLayer::pageStep(ScrollbarOrientation orientation) const
1343 {
1344 RenderBox* box = renderBox();
1345 ASSERT(box);
1346
1347 int length = (orientation == HorizontalScrollbar) ?
1348 box->pixelSnappedClientWidth() : box->pixelSnappedClientHeight();
1349 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo StepWhenPaging();
1350 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa ges());
1351
1352 return max(pageStep, 1);
1353 }
1354
1332 RenderLayer* RenderLayer::enclosingTransformedAncestor() const 1355 RenderLayer* RenderLayer::enclosingTransformedAncestor() const
1333 { 1356 {
1334 RenderLayer* curr = parent(); 1357 RenderLayer* curr = parent();
1335 while (curr && !curr->isRootLayer() && !curr->transform()) 1358 while (curr && !curr->isRootLayer() && !curr->transform())
1336 curr = curr->parent(); 1359 curr = curr->parent();
1337 1360
1338 return curr; 1361 return curr;
1339 } 1362 }
1340 1363
1341 static inline const RenderLayer* compositingContainer(const RenderLayer* layer) 1364 static inline const RenderLayer* compositingContainer(const RenderLayer* layer)
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number( roundToInt(baseHeight + difference.height())) + "px", false); 2505 styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number( roundToInt(baseHeight + difference.height())) + "px", false);
2483 } 2506 }
2484 2507
2485 document->updateLayout(); 2508 document->updateLayout();
2486 2509
2487 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view. 2510 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view.
2488 } 2511 }
2489 2512
2490 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const 2513 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const
2491 { 2514 {
2492 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_hBar : m_vB ar).get(); 2515 RenderBox* box = renderBox();
2493 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; 2516 ASSERT(box);
2494 }
2495 2517
2496 int RenderLayer::scrollPosition(Scrollbar* scrollbar) const 2518 if (orientation == HorizontalScrollbar)
2497 { 2519 return m_scrollSize.width() - box->pixelSnappedClientWidth();
2498 if (scrollbar->orientation() == HorizontalScrollbar) 2520
2499 return scrollXOffset(); 2521 return m_scrollSize.height() - box->pixelSnappedClientHeight();
trchen 2013/06/20 01:46:43 Whoa. scrollSize() looks like an accessor to m_scr
bokan 2013/06/20 19:00:16 Done.
2500 if (scrollbar->orientation() == VerticalScrollbar)
2501 return scrollYOffset();
2502 return 0;
2503 } 2522 }
2504 2523
2505 IntPoint RenderLayer::scrollPosition() const 2524 IntPoint RenderLayer::scrollPosition() const
2506 { 2525 {
2507 return IntPoint(m_scrollOffset); 2526 return IntPoint(m_scrollOffset);
2508 } 2527 }
2509 2528
2510 IntPoint RenderLayer::minimumScrollPosition() const 2529 IntPoint RenderLayer::minimumScrollPosition() const
2511 { 2530 {
2512 return -scrollOrigin(); 2531 return -scrollOrigin();
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 willRemoveHorizontalScrollbar(scrollbar.get()); 2872 willRemoveHorizontalScrollbar(scrollbar.get());
2854 else 2873 else
2855 willRemoveVerticalScrollbar(scrollbar.get()); 2874 willRemoveVerticalScrollbar(scrollbar.get());
2856 } 2875 }
2857 2876
2858 scrollbar->removeFromParent(); 2877 scrollbar->removeFromParent();
2859 scrollbar->disconnectFromScrollableArea(); 2878 scrollbar->disconnectFromScrollableArea();
2860 scrollbar = 0; 2879 scrollbar = 0;
2861 } 2880 }
2862 2881
2863 bool RenderLayer::scrollsOverflow() const
2864 {
2865 if (!renderer()->isBox())
2866 return false;
2867
2868 return toRenderBox(renderer())->scrollsOverflow();
2869 }
2870
2871 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) 2882 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar)
2872 { 2883 {
2873 if (hasScrollbar == hasHorizontalScrollbar()) 2884 if (hasScrollbar == hasHorizontalScrollbar())
2874 return; 2885 return;
2875 2886
2876 if (hasScrollbar) 2887 if (hasScrollbar)
2877 m_hBar = createScrollbar(HorizontalScrollbar); 2888 m_hBar = createScrollbar(HorizontalScrollbar);
2878 else 2889 else
2879 destroyScrollbar(HorizontalScrollbar); 2890 destroyScrollbar(HorizontalScrollbar);
2880 2891
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3119 } else 3130 } else
3120 renderer()->layout(); 3131 renderer()->layout();
3121 m_inOverflowRelayout = false; 3132 m_inOverflowRelayout = false;
3122 } 3133 }
3123 } 3134 }
3124 } 3135 }
3125 3136
3126 // Set up the range (and page step/line step). 3137 // Set up the range (and page step/line step).
3127 if (m_hBar) { 3138 if (m_hBar) {
3128 int clientWidth = box->pixelSnappedClientWidth(); 3139 int clientWidth = box->pixelSnappedClientWidth();
3129 int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWh enPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1);
3130 m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
3131 m_hBar->setProportion(clientWidth, m_scrollSize.width()); 3140 m_hBar->setProportion(clientWidth, m_scrollSize.width());
3132 } 3141 }
3133 if (m_vBar) { 3142 if (m_vBar) {
3134 int clientHeight = box->pixelSnappedClientHeight(); 3143 int clientHeight = box->pixelSnappedClientHeight();
3135 int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepW henPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1);
3136 m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
3137 m_vBar->setProportion(clientHeight, m_scrollSize.height()); 3144 m_vBar->setProportion(clientHeight, m_scrollSize.height());
3138 } 3145 }
3139 3146
3140 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe rticalOverflow()); 3147 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe rticalOverflow());
3141 } 3148 }
3142 3149
3143 void RenderLayer::updateScrollInfoAfterLayout() 3150 void RenderLayer::updateScrollInfoAfterLayout()
3144 { 3151 {
3145 RenderBox* box = renderBox(); 3152 RenderBox* box = renderBox();
3146 if (!box) 3153 if (!box)
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after
6397 } 6404 }
6398 } 6405 }
6399 6406
6400 void showLayerTree(const WebCore::RenderObject* renderer) 6407 void showLayerTree(const WebCore::RenderObject* renderer)
6401 { 6408 {
6402 if (!renderer) 6409 if (!renderer)
6403 return; 6410 return;
6404 showLayerTree(renderer->enclosingLayer()); 6411 showLayerTree(renderer->enclosingLayer());
6405 } 6412 }
6406 #endif 6413 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698