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 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 } | 1311 } |
1312 | 1312 |
1313 return 0; | 1313 return 0; |
1314 } | 1314 } |
1315 | 1315 |
1316 IntRect RenderLayer::scrollableAreaBoundingBox() const | 1316 IntRect RenderLayer::scrollableAreaBoundingBox() const |
1317 { | 1317 { |
1318 return renderer()->absoluteBoundingBoxRect(); | 1318 return renderer()->absoluteBoundingBoxRect(); |
1319 } | 1319 } |
1320 | 1320 |
| 1321 bool RenderLayer::userInputScrollable(ScrollbarOrientation orientation) const |
| 1322 { |
| 1323 RenderBox* box = renderBox(); |
| 1324 ASSERT(box); |
| 1325 |
| 1326 EOverflow overflowStyle = (orientation == HorizontalScrollbar) ? |
| 1327 renderer()->style()->overflowX() : renderer()->style()->overflowY(); |
| 1328 return (overflowStyle == OSCROLL || overflowStyle == OAUTO); |
| 1329 } |
| 1330 |
| 1331 int RenderLayer::pageStep(ScrollbarOrientation orientation) const |
| 1332 { |
| 1333 RenderBox* box = renderBox(); |
| 1334 ASSERT(box); |
| 1335 |
| 1336 int length = (orientation == HorizontalScrollbar) ? |
| 1337 box->pixelSnappedClientWidth() : box->pixelSnappedClientHeight(); |
| 1338 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo
StepWhenPaging(); |
| 1339 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa
ges()); |
| 1340 |
| 1341 return max(pageStep, 1); |
| 1342 } |
| 1343 |
1321 RenderLayer* RenderLayer::enclosingTransformedAncestor() const | 1344 RenderLayer* RenderLayer::enclosingTransformedAncestor() const |
1322 { | 1345 { |
1323 RenderLayer* curr = parent(); | 1346 RenderLayer* curr = parent(); |
1324 while (curr && !curr->isRootLayer() && !curr->transform()) | 1347 while (curr && !curr->isRootLayer() && !curr->transform()) |
1325 curr = curr->parent(); | 1348 curr = curr->parent(); |
1326 | 1349 |
1327 return curr; | 1350 return curr; |
1328 } | 1351 } |
1329 | 1352 |
1330 static inline const RenderLayer* compositingContainer(const RenderLayer* layer) | 1353 static inline const RenderLayer* compositingContainer(const RenderLayer* layer) |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2465 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); | 2488 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); |
2466 } | 2489 } |
2467 | 2490 |
2468 document->updateLayout(); | 2491 document->updateLayout(); |
2469 | 2492 |
2470 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. | 2493 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. |
2471 } | 2494 } |
2472 | 2495 |
2473 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const | 2496 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const |
2474 { | 2497 { |
2475 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_hBar : m_vB
ar).get(); | 2498 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
2476 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; | 2499 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
2477 } | |
2478 | |
2479 int RenderLayer::scrollPosition(Scrollbar* scrollbar) const | |
2480 { | |
2481 if (scrollbar->orientation() == HorizontalScrollbar) | |
2482 return scrollXOffset(); | |
2483 if (scrollbar->orientation() == VerticalScrollbar) | |
2484 return scrollYOffset(); | |
2485 return 0; | |
2486 } | 2500 } |
2487 | 2501 |
2488 IntPoint RenderLayer::scrollPosition() const | 2502 IntPoint RenderLayer::scrollPosition() const |
2489 { | 2503 { |
2490 return IntPoint(m_scrollOffset); | 2504 return IntPoint(m_scrollOffset); |
2491 } | 2505 } |
2492 | 2506 |
2493 IntPoint RenderLayer::minimumScrollPosition() const | 2507 IntPoint RenderLayer::minimumScrollPosition() const |
2494 { | 2508 { |
2495 return -scrollOrigin(); | 2509 return -scrollOrigin(); |
2496 } | 2510 } |
2497 | 2511 |
2498 IntPoint RenderLayer::maximumScrollPosition() const | 2512 IntPoint RenderLayer::maximumScrollPosition() const |
2499 { | 2513 { |
2500 RenderBox* box = renderBox(); | 2514 RenderBox* box = renderBox(); |
2501 if (!box || !box->hasOverflowClip()) | 2515 if (!box || !box->hasOverflowClip()) |
2502 return -scrollOrigin(); | 2516 return -scrollOrigin(); |
2503 | 2517 |
2504 LayoutRect overflowRect(box->layoutOverflowRect()); | 2518 return -scrollOrigin() + enclosingIntRect(m_overflowRect).size() - enclosing
IntRect(box->clientBoxRect()).size(); |
2505 box->flipForWritingMode(overflowRect); | |
2506 return -scrollOrigin() + enclosingIntRect(overflowRect).size() - enclosingIn
tRect(box->clientBoxRect()).size(); | |
2507 } | 2519 } |
2508 | 2520 |
2509 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr
ollbarInclusion) const | 2521 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr
ollbarInclusion) const |
2510 { | 2522 { |
2511 int verticalScrollbarWidth = 0; | 2523 int verticalScrollbarWidth = 0; |
2512 int horizontalScrollbarHeight = 0; | 2524 int horizontalScrollbarHeight = 0; |
2513 if (scrollbarInclusion == IncludeScrollbars) { | 2525 if (scrollbarInclusion == IncludeScrollbars) { |
2514 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; | 2526 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; |
2515 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; | 2527 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; |
2516 } | 2528 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2836 willRemoveHorizontalScrollbar(scrollbar.get()); | 2848 willRemoveHorizontalScrollbar(scrollbar.get()); |
2837 else | 2849 else |
2838 willRemoveVerticalScrollbar(scrollbar.get()); | 2850 willRemoveVerticalScrollbar(scrollbar.get()); |
2839 } | 2851 } |
2840 | 2852 |
2841 scrollbar->removeFromParent(); | 2853 scrollbar->removeFromParent(); |
2842 scrollbar->disconnectFromScrollableArea(); | 2854 scrollbar->disconnectFromScrollableArea(); |
2843 scrollbar = 0; | 2855 scrollbar = 0; |
2844 } | 2856 } |
2845 | 2857 |
2846 bool RenderLayer::scrollsOverflow() const | |
2847 { | |
2848 if (!renderer()->isBox()) | |
2849 return false; | |
2850 | |
2851 return toRenderBox(renderer())->scrollsOverflow(); | |
2852 } | |
2853 | |
2854 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) | 2858 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) |
2855 { | 2859 { |
2856 if (hasScrollbar == hasHorizontalScrollbar()) | 2860 if (hasScrollbar == hasHorizontalScrollbar()) |
2857 return; | 2861 return; |
2858 | 2862 |
2859 if (hasScrollbar) | 2863 if (hasScrollbar) |
2860 m_hBar = createScrollbar(HorizontalScrollbar); | 2864 m_hBar = createScrollbar(HorizontalScrollbar); |
2861 else | 2865 else |
2862 destroyScrollbar(HorizontalScrollbar); | 2866 destroyScrollbar(HorizontalScrollbar); |
2863 | 2867 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 | 2969 |
2966 if (isComposited()) | 2970 if (isComposited()) |
2967 backing()->positionOverflowControlsLayers(offsetFromRoot); | 2971 backing()->positionOverflowControlsLayers(offsetFromRoot); |
2968 } | 2972 } |
2969 | 2973 |
2970 int RenderLayer::scrollWidth() const | 2974 int RenderLayer::scrollWidth() const |
2971 { | 2975 { |
2972 ASSERT(renderBox()); | 2976 ASSERT(renderBox()); |
2973 if (m_scrollDimensionsDirty) | 2977 if (m_scrollDimensionsDirty) |
2974 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | 2978 const_cast<RenderLayer*>(this)->computeScrollDimensions(); |
2975 return snapSizeToPixel(m_scrollSize.width(), renderBox()->clientLeft() + ren
derBox()->x()); | 2979 return snapSizeToPixel(m_overflowRect.width(), renderBox()->clientLeft() + r
enderBox()->x()); |
2976 } | 2980 } |
2977 | 2981 |
2978 int RenderLayer::scrollHeight() const | 2982 int RenderLayer::scrollHeight() const |
2979 { | 2983 { |
2980 ASSERT(renderBox()); | 2984 ASSERT(renderBox()); |
2981 if (m_scrollDimensionsDirty) | 2985 if (m_scrollDimensionsDirty) |
2982 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | 2986 const_cast<RenderLayer*>(this)->computeScrollDimensions(); |
2983 return snapSizeToPixel(m_scrollSize.height(), renderBox()->clientTop() + ren
derBox()->y()); | 2987 return snapSizeToPixel(m_overflowRect.height(), renderBox()->clientTop() + r
enderBox()->y()); |
2984 } | |
2985 | |
2986 LayoutUnit RenderLayer::overflowTop() const | |
2987 { | |
2988 RenderBox* box = renderBox(); | |
2989 LayoutRect overflowRect(box->layoutOverflowRect()); | |
2990 box->flipForWritingMode(overflowRect); | |
2991 return overflowRect.y(); | |
2992 } | |
2993 | |
2994 LayoutUnit RenderLayer::overflowBottom() const | |
2995 { | |
2996 RenderBox* box = renderBox(); | |
2997 LayoutRect overflowRect(box->layoutOverflowRect()); | |
2998 box->flipForWritingMode(overflowRect); | |
2999 return overflowRect.maxY(); | |
3000 } | |
3001 | |
3002 LayoutUnit RenderLayer::overflowLeft() const | |
3003 { | |
3004 RenderBox* box = renderBox(); | |
3005 LayoutRect overflowRect(box->layoutOverflowRect()); | |
3006 box->flipForWritingMode(overflowRect); | |
3007 return overflowRect.x(); | |
3008 } | |
3009 | |
3010 LayoutUnit RenderLayer::overflowRight() const | |
3011 { | |
3012 RenderBox* box = renderBox(); | |
3013 LayoutRect overflowRect(box->layoutOverflowRect()); | |
3014 box->flipForWritingMode(overflowRect); | |
3015 return overflowRect.maxX(); | |
3016 } | 2988 } |
3017 | 2989 |
3018 void RenderLayer::computeScrollDimensions() | 2990 void RenderLayer::computeScrollDimensions() |
3019 { | 2991 { |
3020 RenderBox* box = renderBox(); | 2992 RenderBox* box = renderBox(); |
3021 ASSERT(box); | 2993 ASSERT(box); |
3022 | 2994 |
3023 m_scrollDimensionsDirty = false; | 2995 m_scrollDimensionsDirty = false; |
3024 | 2996 |
3025 m_scrollSize.setWidth(overflowRight() - overflowLeft()); | 2997 m_overflowRect = box->layoutOverflowRect(); |
3026 m_scrollSize.setHeight(overflowBottom() - overflowTop()); | 2998 box->flipForWritingMode(m_overflowRect); |
3027 | 2999 |
3028 int scrollableLeftOverflow = overflowLeft() - box->borderLeft(); | 3000 int scrollableLeftOverflow = m_overflowRect.x() - box->borderLeft(); |
3029 int scrollableTopOverflow = overflowTop() - box->borderTop(); | 3001 int scrollableTopOverflow = m_overflowRect.y() - box->borderTop(); |
3030 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); | 3002 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); |
3031 } | 3003 } |
3032 | 3004 |
3033 bool RenderLayer::hasScrollableHorizontalOverflow() const | 3005 bool RenderLayer::hasScrollableHorizontalOverflow() const |
3034 { | 3006 { |
3035 return hasHorizontalOverflow() && renderBox()->scrollsOverflowX(); | 3007 return hasHorizontalOverflow() && renderBox()->scrollsOverflowX(); |
3036 } | 3008 } |
3037 | 3009 |
3038 bool RenderLayer::hasScrollableVerticalOverflow() const | 3010 bool RenderLayer::hasScrollableVerticalOverflow() const |
3039 { | 3011 { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3102 } else | 3074 } else |
3103 renderer()->layout(); | 3075 renderer()->layout(); |
3104 m_inOverflowRelayout = false; | 3076 m_inOverflowRelayout = false; |
3105 } | 3077 } |
3106 } | 3078 } |
3107 } | 3079 } |
3108 | 3080 |
3109 // Set up the range (and page step/line step). | 3081 // Set up the range (and page step/line step). |
3110 if (m_hBar) { | 3082 if (m_hBar) { |
3111 int clientWidth = box->pixelSnappedClientWidth(); | 3083 int clientWidth = box->pixelSnappedClientWidth(); |
3112 int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWh
enPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1); | 3084 m_hBar->setProportion(clientWidth, m_overflowRect.width()); |
3113 m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | |
3114 m_hBar->setProportion(clientWidth, m_scrollSize.width()); | |
3115 } | 3085 } |
3116 if (m_vBar) { | 3086 if (m_vBar) { |
3117 int clientHeight = box->pixelSnappedClientHeight(); | 3087 int clientHeight = box->pixelSnappedClientHeight(); |
3118 int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepW
henPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); | 3088 m_vBar->setProportion(clientHeight, m_overflowRect.height()); |
3119 m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | |
3120 m_vBar->setProportion(clientHeight, m_scrollSize.height()); | |
3121 } | 3089 } |
3122 | 3090 |
3123 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe
rticalOverflow()); | 3091 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe
rticalOverflow()); |
3124 } | 3092 } |
3125 | 3093 |
3126 void RenderLayer::updateScrollInfoAfterLayout() | 3094 void RenderLayer::updateScrollInfoAfterLayout() |
3127 { | 3095 { |
3128 RenderBox* box = renderBox(); | 3096 RenderBox* box = renderBox(); |
3129 if (!box) | 3097 if (!box) |
3130 return; | 3098 return; |
(...skipping 3238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6369 } | 6337 } |
6370 } | 6338 } |
6371 | 6339 |
6372 void showLayerTree(const WebCore::RenderObject* renderer) | 6340 void showLayerTree(const WebCore::RenderObject* renderer) |
6373 { | 6341 { |
6374 if (!renderer) | 6342 if (!renderer) |
6375 return; | 6343 return; |
6376 showLayerTree(renderer->enclosingLayer()); | 6344 showLayerTree(renderer->enclosingLayer()); |
6377 } | 6345 } |
6378 #endif | 6346 #endif |
OLD | NEW |