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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 IntSize scrollDims = maximumScrollPosition() - minimumScrollPosition(); |
tdanderson
2013/07/15 23:17:44
scrollDims -> scrollDimensions
bokan
2013/07/22 15:08:47
Done.
| |
2493 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; | 2516 return (orientation == HorizontalScrollbar) ? scrollDims.width() : scrollDim s.height(); |
2494 } | |
2495 | |
2496 int RenderLayer::scrollPosition(Scrollbar* scrollbar) const | |
2497 { | |
2498 if (scrollbar->orientation() == HorizontalScrollbar) | |
2499 return scrollXOffset(); | |
2500 if (scrollbar->orientation() == VerticalScrollbar) | |
2501 return scrollYOffset(); | |
2502 return 0; | |
2503 } | 2517 } |
2504 | 2518 |
2505 IntPoint RenderLayer::scrollPosition() const | 2519 IntPoint RenderLayer::scrollPosition() const |
2506 { | 2520 { |
2507 return IntPoint(m_scrollOffset); | 2521 return IntPoint(m_scrollOffset); |
2508 } | 2522 } |
2509 | 2523 |
2510 IntPoint RenderLayer::minimumScrollPosition() const | 2524 IntPoint RenderLayer::minimumScrollPosition() const |
2511 { | 2525 { |
2512 return -scrollOrigin(); | 2526 return -scrollOrigin(); |
2513 } | 2527 } |
2514 | 2528 |
2515 IntPoint RenderLayer::maximumScrollPosition() const | 2529 IntPoint RenderLayer::maximumScrollPosition() const |
2516 { | 2530 { |
2517 RenderBox* box = renderBox(); | 2531 RenderBox* box = renderBox(); |
2518 if (!box || !box->hasOverflowClip()) | 2532 if (!box || !box->hasOverflowClip()) |
2519 return -scrollOrigin(); | 2533 return -scrollOrigin(); |
2520 | 2534 |
2521 LayoutRect overflowRect(box->layoutOverflowRect()); | 2535 return -scrollOrigin() + enclosingIntRect(m_overflowRect).size() - enclosing IntRect(box->clientBoxRect()).size(); |
2522 box->flipForWritingMode(overflowRect); | |
2523 return -scrollOrigin() + enclosingIntRect(overflowRect).size() - enclosingIn tRect(box->clientBoxRect()).size(); | |
2524 } | 2536 } |
2525 | 2537 |
2526 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr ollbarInclusion) const | 2538 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr ollbarInclusion) const |
2527 { | 2539 { |
2528 int verticalScrollbarWidth = 0; | 2540 int verticalScrollbarWidth = 0; |
2529 int horizontalScrollbarHeight = 0; | 2541 int horizontalScrollbarHeight = 0; |
2530 if (scrollbarInclusion == IncludeScrollbars) { | 2542 if (scrollbarInclusion == IncludeScrollbars) { |
2531 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; | 2543 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; |
2532 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; | 2544 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; |
2533 } | 2545 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2853 willRemoveHorizontalScrollbar(scrollbar.get()); | 2865 willRemoveHorizontalScrollbar(scrollbar.get()); |
2854 else | 2866 else |
2855 willRemoveVerticalScrollbar(scrollbar.get()); | 2867 willRemoveVerticalScrollbar(scrollbar.get()); |
2856 } | 2868 } |
2857 | 2869 |
2858 scrollbar->removeFromParent(); | 2870 scrollbar->removeFromParent(); |
2859 scrollbar->disconnectFromScrollableArea(); | 2871 scrollbar->disconnectFromScrollableArea(); |
2860 scrollbar = 0; | 2872 scrollbar = 0; |
2861 } | 2873 } |
2862 | 2874 |
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) | 2875 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) |
2872 { | 2876 { |
2873 if (hasScrollbar == hasHorizontalScrollbar()) | 2877 if (hasScrollbar == hasHorizontalScrollbar()) |
2874 return; | 2878 return; |
2875 | 2879 |
2876 if (hasScrollbar) | 2880 if (hasScrollbar) |
2877 m_hBar = createScrollbar(HorizontalScrollbar); | 2881 m_hBar = createScrollbar(HorizontalScrollbar); |
2878 else | 2882 else |
2879 destroyScrollbar(HorizontalScrollbar); | 2883 destroyScrollbar(HorizontalScrollbar); |
2880 | 2884 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2982 | 2986 |
2983 if (isComposited()) | 2987 if (isComposited()) |
2984 backing()->positionOverflowControlsLayers(offsetFromRoot); | 2988 backing()->positionOverflowControlsLayers(offsetFromRoot); |
2985 } | 2989 } |
2986 | 2990 |
2987 int RenderLayer::scrollWidth() const | 2991 int RenderLayer::scrollWidth() const |
2988 { | 2992 { |
2989 ASSERT(renderBox()); | 2993 ASSERT(renderBox()); |
2990 if (m_scrollDimensionsDirty) | 2994 if (m_scrollDimensionsDirty) |
2991 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | 2995 const_cast<RenderLayer*>(this)->computeScrollDimensions(); |
2992 return snapSizeToPixel(m_scrollSize.width(), renderBox()->clientLeft() + ren derBox()->x()); | 2996 return snapSizeToPixel(m_overflowRect.width(), renderBox()->clientLeft() + r enderBox()->x()); |
2993 } | 2997 } |
2994 | 2998 |
2995 int RenderLayer::scrollHeight() const | 2999 int RenderLayer::scrollHeight() const |
2996 { | 3000 { |
2997 ASSERT(renderBox()); | 3001 ASSERT(renderBox()); |
2998 if (m_scrollDimensionsDirty) | 3002 if (m_scrollDimensionsDirty) |
2999 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | 3003 const_cast<RenderLayer*>(this)->computeScrollDimensions(); |
3000 return snapSizeToPixel(m_scrollSize.height(), renderBox()->clientTop() + ren derBox()->y()); | 3004 return snapSizeToPixel(m_overflowRect.height(), renderBox()->clientTop() + r enderBox()->y()); |
3001 } | |
3002 | |
3003 LayoutUnit RenderLayer::overflowTop() const | |
3004 { | |
3005 RenderBox* box = renderBox(); | |
3006 LayoutRect overflowRect(box->layoutOverflowRect()); | |
3007 box->flipForWritingMode(overflowRect); | |
3008 return overflowRect.y(); | |
3009 } | |
3010 | |
3011 LayoutUnit RenderLayer::overflowBottom() const | |
3012 { | |
3013 RenderBox* box = renderBox(); | |
3014 LayoutRect overflowRect(box->layoutOverflowRect()); | |
3015 box->flipForWritingMode(overflowRect); | |
3016 return overflowRect.maxY(); | |
3017 } | |
3018 | |
3019 LayoutUnit RenderLayer::overflowLeft() const | |
3020 { | |
3021 RenderBox* box = renderBox(); | |
3022 LayoutRect overflowRect(box->layoutOverflowRect()); | |
3023 box->flipForWritingMode(overflowRect); | |
3024 return overflowRect.x(); | |
3025 } | |
3026 | |
3027 LayoutUnit RenderLayer::overflowRight() const | |
3028 { | |
3029 RenderBox* box = renderBox(); | |
3030 LayoutRect overflowRect(box->layoutOverflowRect()); | |
3031 box->flipForWritingMode(overflowRect); | |
3032 return overflowRect.maxX(); | |
3033 } | 3005 } |
3034 | 3006 |
3035 void RenderLayer::computeScrollDimensions() | 3007 void RenderLayer::computeScrollDimensions() |
3036 { | 3008 { |
3037 RenderBox* box = renderBox(); | 3009 RenderBox* box = renderBox(); |
3038 ASSERT(box); | 3010 ASSERT(box); |
3039 | 3011 |
3040 m_scrollDimensionsDirty = false; | 3012 m_scrollDimensionsDirty = false; |
3041 | 3013 |
3042 m_scrollSize.setWidth(overflowRight() - overflowLeft()); | 3014 m_overflowRect = box->layoutOverflowRect(); |
3043 m_scrollSize.setHeight(overflowBottom() - overflowTop()); | 3015 box->flipForWritingMode(m_overflowRect); |
3044 | 3016 |
3045 int scrollableLeftOverflow = overflowLeft() - box->borderLeft(); | 3017 int scrollableLeftOverflow = m_overflowRect.x() - box->borderLeft(); |
3046 int scrollableTopOverflow = overflowTop() - box->borderTop(); | 3018 int scrollableTopOverflow = m_overflowRect.y() - box->borderTop(); |
3047 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); | 3019 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); |
3048 } | 3020 } |
3049 | 3021 |
3050 bool RenderLayer::hasScrollableHorizontalOverflow() const | 3022 bool RenderLayer::hasScrollableHorizontalOverflow() const |
3051 { | 3023 { |
3052 return hasHorizontalOverflow() && renderBox()->scrollsOverflowX(); | 3024 return hasHorizontalOverflow() && renderBox()->scrollsOverflowX(); |
3053 } | 3025 } |
3054 | 3026 |
3055 bool RenderLayer::hasScrollableVerticalOverflow() const | 3027 bool RenderLayer::hasScrollableVerticalOverflow() const |
3056 { | 3028 { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3119 } else | 3091 } else |
3120 renderer()->layout(); | 3092 renderer()->layout(); |
3121 m_inOverflowRelayout = false; | 3093 m_inOverflowRelayout = false; |
3122 } | 3094 } |
3123 } | 3095 } |
3124 } | 3096 } |
3125 | 3097 |
3126 // Set up the range (and page step/line step). | 3098 // Set up the range (and page step/line step). |
3127 if (m_hBar) { | 3099 if (m_hBar) { |
3128 int clientWidth = box->pixelSnappedClientWidth(); | 3100 int clientWidth = box->pixelSnappedClientWidth(); |
3129 int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWh enPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1); | 3101 m_hBar->setProportion(clientWidth, m_overflowRect.width()); |
3130 m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | |
3131 m_hBar->setProportion(clientWidth, m_scrollSize.width()); | |
3132 } | 3102 } |
3133 if (m_vBar) { | 3103 if (m_vBar) { |
3134 int clientHeight = box->pixelSnappedClientHeight(); | 3104 int clientHeight = box->pixelSnappedClientHeight(); |
3135 int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepW henPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); | 3105 m_vBar->setProportion(clientHeight, m_overflowRect.height()); |
3136 m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | |
3137 m_vBar->setProportion(clientHeight, m_scrollSize.height()); | |
3138 } | 3106 } |
3139 | 3107 |
3140 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe rticalOverflow()); | 3108 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe rticalOverflow()); |
3141 } | 3109 } |
3142 | 3110 |
3143 void RenderLayer::updateScrollInfoAfterLayout() | 3111 void RenderLayer::updateScrollInfoAfterLayout() |
3144 { | 3112 { |
3145 RenderBox* box = renderBox(); | 3113 RenderBox* box = renderBox(); |
3146 if (!box) | 3114 if (!box) |
3147 return; | 3115 return; |
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6397 } | 6365 } |
6398 } | 6366 } |
6399 | 6367 |
6400 void showLayerTree(const WebCore::RenderObject* renderer) | 6368 void showLayerTree(const WebCore::RenderObject* renderer) |
6401 { | 6369 { |
6402 if (!renderer) | 6370 if (!renderer) |
6403 return; | 6371 return; |
6404 showLayerTree(renderer->enclosingLayer()); | 6372 showLayerTree(renderer->enclosingLayer()); |
6405 } | 6373 } |
6406 #endif | 6374 #endif |
OLD | NEW |