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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2456 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); | 2479 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); |
2457 } | 2480 } |
2458 | 2481 |
2459 document->updateLayout(); | 2482 document->updateLayout(); |
2460 | 2483 |
2461 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. | 2484 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. |
2462 } | 2485 } |
2463 | 2486 |
2464 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const | 2487 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const |
2465 { | 2488 { |
2466 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_hBar : m_vB
ar).get(); | 2489 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
2467 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; | 2490 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
2468 } | |
2469 | |
2470 int RenderLayer::scrollPosition(Scrollbar* scrollbar) const | |
2471 { | |
2472 if (scrollbar->orientation() == HorizontalScrollbar) | |
2473 return scrollXOffset(); | |
2474 if (scrollbar->orientation() == VerticalScrollbar) | |
2475 return scrollYOffset(); | |
2476 return 0; | |
2477 } | 2491 } |
2478 | 2492 |
2479 IntPoint RenderLayer::scrollPosition() const | 2493 IntPoint RenderLayer::scrollPosition() const |
2480 { | 2494 { |
2481 return IntPoint(m_scrollOffset); | 2495 return IntPoint(m_scrollOffset); |
2482 } | 2496 } |
2483 | 2497 |
2484 IntPoint RenderLayer::minimumScrollPosition() const | 2498 IntPoint RenderLayer::minimumScrollPosition() const |
2485 { | 2499 { |
2486 return -scrollOrigin(); | 2500 return -scrollOrigin(); |
2487 } | 2501 } |
2488 | 2502 |
2489 IntPoint RenderLayer::maximumScrollPosition() const | 2503 IntPoint RenderLayer::maximumScrollPosition() const |
2490 { | 2504 { |
2491 RenderBox* box = renderBox(); | 2505 RenderBox* box = renderBox(); |
2492 if (!box || !box->hasOverflowClip()) | 2506 if (!box || !box->hasOverflowClip()) |
2493 return -scrollOrigin(); | 2507 return -scrollOrigin(); |
2494 | 2508 |
2495 LayoutRect overflowRect(box->layoutOverflowRect()); | 2509 return -scrollOrigin() + enclosingIntRect(m_overflowRect).size() - enclosing
IntRect(box->clientBoxRect()).size(); |
2496 box->flipForWritingMode(overflowRect); | |
2497 return -scrollOrigin() + enclosingIntRect(overflowRect).size() - enclosingIn
tRect(box->clientBoxRect()).size(); | |
2498 } | 2510 } |
2499 | 2511 |
2500 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr
ollbarInclusion) const | 2512 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr
ollbarInclusion) const |
2501 { | 2513 { |
2502 int verticalScrollbarWidth = 0; | 2514 int verticalScrollbarWidth = 0; |
2503 int horizontalScrollbarHeight = 0; | 2515 int horizontalScrollbarHeight = 0; |
2504 if (scrollbarInclusion == IncludeScrollbars) { | 2516 if (scrollbarInclusion == IncludeScrollbars) { |
2505 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; | 2517 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; |
2506 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; | 2518 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; |
2507 } | 2519 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 willRemoveHorizontalScrollbar(scrollbar.get()); | 2839 willRemoveHorizontalScrollbar(scrollbar.get()); |
2828 else | 2840 else |
2829 willRemoveVerticalScrollbar(scrollbar.get()); | 2841 willRemoveVerticalScrollbar(scrollbar.get()); |
2830 } | 2842 } |
2831 | 2843 |
2832 scrollbar->removeFromParent(); | 2844 scrollbar->removeFromParent(); |
2833 scrollbar->disconnectFromScrollableArea(); | 2845 scrollbar->disconnectFromScrollableArea(); |
2834 scrollbar = 0; | 2846 scrollbar = 0; |
2835 } | 2847 } |
2836 | 2848 |
2837 bool RenderLayer::scrollsOverflow() const | |
2838 { | |
2839 if (!renderer()->isBox()) | |
2840 return false; | |
2841 | |
2842 return toRenderBox(renderer())->scrollsOverflow(); | |
2843 } | |
2844 | |
2845 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) | 2849 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) |
2846 { | 2850 { |
2847 if (hasScrollbar == hasHorizontalScrollbar()) | 2851 if (hasScrollbar == hasHorizontalScrollbar()) |
2848 return; | 2852 return; |
2849 | 2853 |
2850 if (hasScrollbar) | 2854 if (hasScrollbar) |
2851 m_hBar = createScrollbar(HorizontalScrollbar); | 2855 m_hBar = createScrollbar(HorizontalScrollbar); |
2852 else | 2856 else |
2853 destroyScrollbar(HorizontalScrollbar); | 2857 destroyScrollbar(HorizontalScrollbar); |
2854 | 2858 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2956 | 2960 |
2957 if (isComposited()) | 2961 if (isComposited()) |
2958 backing()->positionOverflowControlsLayers(offsetFromRoot); | 2962 backing()->positionOverflowControlsLayers(offsetFromRoot); |
2959 } | 2963 } |
2960 | 2964 |
2961 int RenderLayer::scrollWidth() const | 2965 int RenderLayer::scrollWidth() const |
2962 { | 2966 { |
2963 ASSERT(renderBox()); | 2967 ASSERT(renderBox()); |
2964 if (m_scrollDimensionsDirty) | 2968 if (m_scrollDimensionsDirty) |
2965 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | 2969 const_cast<RenderLayer*>(this)->computeScrollDimensions(); |
2966 return snapSizeToPixel(m_scrollSize.width(), renderBox()->clientLeft() + ren
derBox()->x()); | 2970 return snapSizeToPixel(m_overflowRect.width(), renderBox()->clientLeft() + r
enderBox()->x()); |
2967 } | 2971 } |
2968 | 2972 |
2969 int RenderLayer::scrollHeight() const | 2973 int RenderLayer::scrollHeight() const |
2970 { | 2974 { |
2971 ASSERT(renderBox()); | 2975 ASSERT(renderBox()); |
2972 if (m_scrollDimensionsDirty) | 2976 if (m_scrollDimensionsDirty) |
2973 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | 2977 const_cast<RenderLayer*>(this)->computeScrollDimensions(); |
2974 return snapSizeToPixel(m_scrollSize.height(), renderBox()->clientTop() + ren
derBox()->y()); | 2978 return snapSizeToPixel(m_overflowRect.height(), renderBox()->clientTop() + r
enderBox()->y()); |
2975 } | |
2976 | |
2977 LayoutUnit RenderLayer::overflowTop() const | |
2978 { | |
2979 RenderBox* box = renderBox(); | |
2980 LayoutRect overflowRect(box->layoutOverflowRect()); | |
2981 box->flipForWritingMode(overflowRect); | |
2982 return overflowRect.y(); | |
2983 } | |
2984 | |
2985 LayoutUnit RenderLayer::overflowBottom() const | |
2986 { | |
2987 RenderBox* box = renderBox(); | |
2988 LayoutRect overflowRect(box->layoutOverflowRect()); | |
2989 box->flipForWritingMode(overflowRect); | |
2990 return overflowRect.maxY(); | |
2991 } | |
2992 | |
2993 LayoutUnit RenderLayer::overflowLeft() const | |
2994 { | |
2995 RenderBox* box = renderBox(); | |
2996 LayoutRect overflowRect(box->layoutOverflowRect()); | |
2997 box->flipForWritingMode(overflowRect); | |
2998 return overflowRect.x(); | |
2999 } | |
3000 | |
3001 LayoutUnit RenderLayer::overflowRight() const | |
3002 { | |
3003 RenderBox* box = renderBox(); | |
3004 LayoutRect overflowRect(box->layoutOverflowRect()); | |
3005 box->flipForWritingMode(overflowRect); | |
3006 return overflowRect.maxX(); | |
3007 } | 2979 } |
3008 | 2980 |
3009 void RenderLayer::computeScrollDimensions() | 2981 void RenderLayer::computeScrollDimensions() |
3010 { | 2982 { |
3011 RenderBox* box = renderBox(); | 2983 RenderBox* box = renderBox(); |
3012 ASSERT(box); | 2984 ASSERT(box); |
3013 | 2985 |
3014 m_scrollDimensionsDirty = false; | 2986 m_scrollDimensionsDirty = false; |
3015 | 2987 |
3016 m_scrollSize.setWidth(overflowRight() - overflowLeft()); | 2988 m_overflowRect = box->layoutOverflowRect(); |
3017 m_scrollSize.setHeight(overflowBottom() - overflowTop()); | 2989 box->flipForWritingMode(m_overflowRect); |
3018 | 2990 |
3019 int scrollableLeftOverflow = overflowLeft() - box->borderLeft(); | 2991 int scrollableLeftOverflow = m_overflowRect.x() - box->borderLeft(); |
3020 int scrollableTopOverflow = overflowTop() - box->borderTop(); | 2992 int scrollableTopOverflow = m_overflowRect.y() - box->borderTop(); |
3021 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); | 2993 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); |
3022 } | 2994 } |
3023 | 2995 |
3024 bool RenderLayer::hasScrollableHorizontalOverflow() const | 2996 bool RenderLayer::hasScrollableHorizontalOverflow() const |
3025 { | 2997 { |
3026 return hasHorizontalOverflow() && renderBox()->scrollsOverflowX(); | 2998 return hasHorizontalOverflow() && renderBox()->scrollsOverflowX(); |
3027 } | 2999 } |
3028 | 3000 |
3029 bool RenderLayer::hasScrollableVerticalOverflow() const | 3001 bool RenderLayer::hasScrollableVerticalOverflow() const |
3030 { | 3002 { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3093 } else | 3065 } else |
3094 renderer()->layout(); | 3066 renderer()->layout(); |
3095 m_inOverflowRelayout = false; | 3067 m_inOverflowRelayout = false; |
3096 } | 3068 } |
3097 } | 3069 } |
3098 } | 3070 } |
3099 | 3071 |
3100 // Set up the range (and page step/line step). | 3072 // Set up the range (and page step/line step). |
3101 if (m_hBar) { | 3073 if (m_hBar) { |
3102 int clientWidth = box->pixelSnappedClientWidth(); | 3074 int clientWidth = box->pixelSnappedClientWidth(); |
3103 int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWh
enPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1); | 3075 m_hBar->setProportion(clientWidth, m_overflowRect.width()); |
3104 m_hBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | |
3105 m_hBar->setProportion(clientWidth, m_scrollSize.width()); | |
3106 } | 3076 } |
3107 if (m_vBar) { | 3077 if (m_vBar) { |
3108 int clientHeight = box->pixelSnappedClientHeight(); | 3078 int clientHeight = box->pixelSnappedClientHeight(); |
3109 int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepW
henPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); | 3079 m_vBar->setProportion(clientHeight, m_overflowRect.height()); |
3110 m_vBar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | |
3111 m_vBar->setProportion(clientHeight, m_scrollSize.height()); | |
3112 } | 3080 } |
3113 | 3081 |
3114 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe
rticalOverflow()); | 3082 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe
rticalOverflow()); |
3115 } | 3083 } |
3116 | 3084 |
3117 void RenderLayer::updateScrollInfoAfterLayout() | 3085 void RenderLayer::updateScrollInfoAfterLayout() |
3118 { | 3086 { |
3119 RenderBox* box = renderBox(); | 3087 RenderBox* box = renderBox(); |
3120 if (!box) | 3088 if (!box) |
3121 return; | 3089 return; |
(...skipping 3235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6357 } | 6325 } |
6358 } | 6326 } |
6359 | 6327 |
6360 void showLayerTree(const WebCore::RenderObject* renderer) | 6328 void showLayerTree(const WebCore::RenderObject* renderer) |
6361 { | 6329 { |
6362 if (!renderer) | 6330 if (!renderer) |
6363 return; | 6331 return; |
6364 showLayerTree(renderer->enclosingLayer()); | 6332 showLayerTree(renderer->enclosingLayer()); |
6365 } | 6333 } |
6366 #endif | 6334 #endif |
OLD | NEW |