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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "core/rendering/RenderLayer.h" | 45 #include "core/rendering/RenderLayer.h" |
46 | 46 |
47 #include "CSSPropertyNames.h" | 47 #include "CSSPropertyNames.h" |
48 #include "HTMLNames.h" | 48 #include "HTMLNames.h" |
49 #include "RuntimeEnabledFeatures.h" | 49 #include "RuntimeEnabledFeatures.h" |
50 #include "SVGNames.h" | 50 #include "SVGNames.h" |
51 #include "core/css/PseudoStyleRequest.h" | 51 #include "core/css/PseudoStyleRequest.h" |
52 #include "core/dom/Document.h" | 52 #include "core/dom/Document.h" |
53 #include "core/dom/DocumentEventQueue.h" | 53 #include "core/dom/DocumentEventQueue.h" |
54 #include "core/dom/shadow/ShadowRoot.h" | 54 #include "core/dom/shadow/ShadowRoot.h" |
55 #include "core/editing/FrameSelection.h" | |
56 #include "core/html/HTMLFrameElement.h" | 55 #include "core/html/HTMLFrameElement.h" |
57 #include "core/html/HTMLFrameOwnerElement.h" | 56 #include "core/html/HTMLFrameOwnerElement.h" |
58 #include "core/inspector/InspectorInstrumentation.h" | |
59 #include "core/page/EventHandler.h" | 57 #include "core/page/EventHandler.h" |
60 #include "core/page/FocusController.h" | 58 #include "core/page/FocusController.h" |
61 #include "core/page/Frame.h" | 59 #include "core/page/Frame.h" |
62 #include "core/page/FrameView.h" | 60 #include "core/page/FrameView.h" |
63 #include "core/page/Page.h" | 61 #include "core/page/Page.h" |
64 #include "core/page/Settings.h" | 62 #include "core/page/Settings.h" |
65 #include "core/page/UseCounter.h" | 63 #include "core/page/UseCounter.h" |
66 #include "core/page/animation/AnimationController.h" | 64 #include "core/page/animation/AnimationController.h" |
67 #include "core/page/scrolling/ScrollingCoordinator.h" | 65 #include "core/page/scrolling/ScrollingCoordinator.h" |
68 #include "core/platform/HistogramSupport.h" | 66 #include "core/platform/HistogramSupport.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const int MinimumHeightWhileResizing = 40; | 116 const int MinimumHeightWhileResizing = 40; |
119 const int ResizerControlExpandRatioForTouch = 2; | 117 const int ResizerControlExpandRatioForTouch = 2; |
120 | 118 |
121 bool ClipRect::intersects(const HitTestLocation& hitTestLocation) const | 119 bool ClipRect::intersects(const HitTestLocation& hitTestLocation) const |
122 { | 120 { |
123 return hitTestLocation.intersects(m_rect); | 121 return hitTestLocation.intersects(m_rect); |
124 } | 122 } |
125 | 123 |
126 RenderLayer::RenderLayer(RenderLayerModelObject* renderer) | 124 RenderLayer::RenderLayer(RenderLayerModelObject* renderer) |
127 : m_inResizeMode(false) | 125 : m_inResizeMode(false) |
128 , m_scrollDimensionsDirty(true) | |
129 , m_normalFlowListDirty(true) | 126 , m_normalFlowListDirty(true) |
130 , m_hasSelfPaintingLayerDescendant(false) | 127 , m_hasSelfPaintingLayerDescendant(false) |
131 , m_hasSelfPaintingLayerDescendantDirty(false) | 128 , m_hasSelfPaintingLayerDescendantDirty(false) |
132 , m_hasOutOfFlowPositionedDescendant(false) | 129 , m_hasOutOfFlowPositionedDescendant(false) |
133 , m_hasOutOfFlowPositionedDescendantDirty(true) | 130 , m_hasOutOfFlowPositionedDescendantDirty(true) |
134 , m_hasUnclippedDescendant(false) | 131 , m_hasUnclippedDescendant(false) |
135 , m_isUnclippedDescendant(false) | 132 , m_isUnclippedDescendant(false) |
136 , m_needsCompositedScrolling(false) | 133 , m_needsCompositedScrolling(false) |
137 , m_canBePromotedToStackingContainer(false) | 134 , m_canBePromotedToStackingContainer(false) |
138 , m_canBePromotedToStackingContainerDirty(true) | 135 , m_canBePromotedToStackingContainerDirty(true) |
(...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 { | 2168 { |
2172 if (delta.isZero()) | 2169 if (delta.isZero()) |
2173 return; | 2170 return; |
2174 | 2171 |
2175 bool restrictedByLineClamp = false; | 2172 bool restrictedByLineClamp = false; |
2176 if (renderer()->parent()) | 2173 if (renderer()->parent()) |
2177 restrictedByLineClamp = !renderer()->parent()->style()->lineClamp().isNo
ne(); | 2174 restrictedByLineClamp = !renderer()->parent()->style()->lineClamp().isNo
ne(); |
2178 | 2175 |
2179 if (renderer()->hasOverflowClip() && !restrictedByLineClamp) { | 2176 if (renderer()->hasOverflowClip() && !restrictedByLineClamp) { |
2180 IntSize newScrollOffset = adjustedScrollOffset() + delta; | 2177 IntSize newScrollOffset = adjustedScrollOffset() + delta; |
2181 scrollToOffset(newScrollOffset, clamp); | 2178 m_scrollableArea->scrollToOffset(newScrollOffset, clamp); |
2182 | 2179 |
2183 // If this layer can't do the scroll we ask the next layer up that can s
croll to try | 2180 // If this layer can't do the scroll we ask the next layer up that can s
croll to try |
2184 IntSize remainingScrollOffset = newScrollOffset - adjustedScrollOffset()
; | 2181 IntSize remainingScrollOffset = newScrollOffset - adjustedScrollOffset()
; |
2185 if (!remainingScrollOffset.isZero() && renderer()->parent()) { | 2182 if (!remainingScrollOffset.isZero() && renderer()->parent()) { |
2186 if (RenderLayer* scrollableLayer = enclosingScrollableLayer()) | 2183 if (RenderLayer* scrollableLayer = enclosingScrollableLayer()) |
2187 scrollableLayer->scrollByRecursively(remainingScrollOffset, clam
p); | 2184 scrollableLayer->scrollByRecursively(remainingScrollOffset, clam
p); |
2188 | 2185 |
2189 Frame* frame = renderer()->frame(); | 2186 Frame* frame = renderer()->frame(); |
2190 if (frame && frame->page()) | 2187 if (frame && frame->page()) |
2191 frame->page()->updateAutoscrollRenderer(); | 2188 frame->page()->updateAutoscrollRenderer(); |
2192 } | 2189 } |
2193 } else if (renderer()->view()->frameView()) { | 2190 } else if (renderer()->view()->frameView()) { |
2194 // If we are here, we were called on a renderer that can be programmatic
ally scrolled, but doesn't | 2191 // If we are here, we were called on a renderer that can be programmatic
ally scrolled, but doesn't |
2195 // have an overflow clip. Which means that it is a document node that ca
n be scrolled. | 2192 // have an overflow clip. Which means that it is a document node that ca
n be scrolled. |
2196 renderer()->view()->frameView()->scrollBy(delta); | 2193 renderer()->view()->frameView()->scrollBy(delta); |
2197 | 2194 |
2198 // FIXME: If we didn't scroll the whole way, do we want to try looking a
t the frames ownerElement? | 2195 // FIXME: If we didn't scroll the whole way, do we want to try looking a
t the frames ownerElement? |
2199 // https://bugs.webkit.org/show_bug.cgi?id=28237 | 2196 // https://bugs.webkit.org/show_bug.cgi?id=28237 |
2200 } | 2197 } |
2201 } | 2198 } |
2202 | 2199 |
2203 IntSize RenderLayer::clampScrollOffset(const IntSize& scrollOffset) const | |
2204 { | |
2205 RenderBox* box = renderBox(); | |
2206 ASSERT(box); | |
2207 | |
2208 int maxX = scrollWidth() - box->pixelSnappedClientWidth(); | |
2209 int maxY = scrollHeight() - box->pixelSnappedClientHeight(); | |
2210 | |
2211 int x = max(min(scrollOffset.width(), maxX), 0); | |
2212 int y = max(min(scrollOffset.height(), maxY), 0); | |
2213 return IntSize(x, y); | |
2214 } | |
2215 | |
2216 void RenderLayer::scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClampi
ng clamp) | 2200 void RenderLayer::scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClampi
ng clamp) |
2217 { | 2201 { |
2218 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s
crollOffset) : scrollOffset; | 2202 m_scrollableArea->scrollToOffset(scrollOffset, clamp); |
2219 if (newScrollOffset != adjustedScrollOffset()) | |
2220 m_scrollableArea->scrollToOffsetWithoutAnimation(-scrollOrigin() + newSc
rollOffset); | |
2221 } | |
2222 | |
2223 void RenderLayer::setScrollOffset(const IntPoint& newScrollOffset) | |
2224 { | |
2225 RenderBox* box = renderBox(); | |
2226 if (!box) | |
2227 return; | |
2228 | |
2229 if (!box->isMarquee()) { | |
2230 // Ensure that the dimensions will be computed if they need to be (for o
verflow:hidden blocks). | |
2231 if (m_scrollDimensionsDirty) | |
2232 computeScrollDimensions(); | |
2233 } | |
2234 | |
2235 if (m_scrollableArea->scrollOffset() == toIntSize(newScrollOffset)) | |
2236 return; | |
2237 m_scrollableArea->setScrollOffset(toIntSize(newScrollOffset)); | |
2238 | |
2239 Frame* frame = renderer()->frame(); | |
2240 InspectorInstrumentation::willScrollLayer(renderer()); | |
2241 | |
2242 RenderView* view = renderer()->view(); | |
2243 | |
2244 // We should have a RenderView if we're trying to scroll. | |
2245 ASSERT(view); | |
2246 | |
2247 // Update the positions of our child layers (if needed as only fixed layers
should be impacted by a scroll). | |
2248 // We don't update compositing layers, because we need to do a deep update f
rom the compositing ancestor. | |
2249 bool inLayout = view ? view->frameView()->isInLayout() : false; | |
2250 if (!inLayout) { | |
2251 // If we're in the middle of layout, we'll just update layers once layou
t has finished. | |
2252 updateLayerPositionsAfterOverflowScroll(); | |
2253 if (view) { | |
2254 // Update regions, scrolling may change the clip of a particular reg
ion. | |
2255 view->frameView()->updateAnnotatedRegions(); | |
2256 view->updateWidgetPositions(); | |
2257 } | |
2258 | |
2259 updateCompositingLayersAfterScroll(); | |
2260 } | |
2261 | |
2262 RenderLayerModelObject* repaintContainer = renderer()->containerForRepaint()
; | |
2263 if (frame) { | |
2264 // The caret rect needs to be invalidated after scrolling | |
2265 frame->selection().setCaretRectNeedsUpdate(); | |
2266 | |
2267 FloatQuad quadForFakeMouseMoveEvent = FloatQuad(m_repaintRect); | |
2268 if (repaintContainer) | |
2269 quadForFakeMouseMoveEvent = repaintContainer->localToAbsoluteQuad(qu
adForFakeMouseMoveEvent); | |
2270 frame->eventHandler()->dispatchFakeMouseMoveEventSoonInQuad(quadForFakeM
ouseMoveEvent); | |
2271 } | |
2272 | |
2273 bool requiresRepaint = true; | |
2274 | |
2275 if (compositor()->inCompositingMode() && usesCompositedScrolling()) | |
2276 requiresRepaint = false; | |
2277 | |
2278 // Just schedule a full repaint of our object. | |
2279 if (view && requiresRepaint) | |
2280 renderer()->repaintUsingContainer(repaintContainer, pixelSnappedIntRect(
m_repaintRect)); | |
2281 | |
2282 // Schedule the scroll DOM event. | |
2283 if (renderer()->node()) | |
2284 renderer()->node()->document().eventQueue()->enqueueOrDispatchScrollEven
t(renderer()->node(), DocumentEventQueue::ScrollEventElementTarget); | |
2285 | |
2286 InspectorInstrumentation::didScrollLayer(renderer()); | |
2287 } | 2203 } |
2288 | 2204 |
2289 static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameEl
ementBase, FrameView* frameView) | 2205 static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameEl
ementBase, FrameView* frameView) |
2290 { | 2206 { |
2291 // If scrollbars aren't explicitly forbidden, permit scrolling. | 2207 // If scrollbars aren't explicitly forbidden, permit scrolling. |
2292 if (frameElementBase && frameElementBase->scrollingMode() != ScrollbarAlways
Off) | 2208 if (frameElementBase && frameElementBase->scrollingMode() != ScrollbarAlways
Off) |
2293 return true; | 2209 return true; |
2294 | 2210 |
2295 // If scrollbars are forbidden, user initiated scrolls should obviously be i
gnored. | 2211 // If scrollbars are forbidden, user initiated scrolls should obviously be i
gnored. |
2296 if (frameView->wasScrolledByUser()) | 2212 if (frameView->wasScrolledByUser()) |
(...skipping 26 matching lines...) Expand all Loading... |
2323 | 2239 |
2324 if (renderer()->hasOverflowClip() && !restrictedByLineClamp) { | 2240 if (renderer()->hasOverflowClip() && !restrictedByLineClamp) { |
2325 // Don't scroll to reveal an overflow layer that is restricted by the -w
ebkit-line-clamp property. | 2241 // Don't scroll to reveal an overflow layer that is restricted by the -w
ebkit-line-clamp property. |
2326 // This will prevent us from revealing text hidden by the slider in Safa
ri RSS. | 2242 // This will prevent us from revealing text hidden by the slider in Safa
ri RSS. |
2327 RenderBox* box = renderBox(); | 2243 RenderBox* box = renderBox(); |
2328 ASSERT(box); | 2244 ASSERT(box); |
2329 LayoutRect localExposeRect(box->absoluteToLocalQuad(FloatQuad(FloatRect(
rect)), UseTransforms).boundingBox()); | 2245 LayoutRect localExposeRect(box->absoluteToLocalQuad(FloatQuad(FloatRect(
rect)), UseTransforms).boundingBox()); |
2330 LayoutRect layerBounds(0, 0, box->clientWidth(), box->clientHeight()); | 2246 LayoutRect layerBounds(0, 0, box->clientWidth(), box->clientHeight()); |
2331 LayoutRect r = getRectToExpose(layerBounds, localExposeRect, alignX, ali
gnY); | 2247 LayoutRect r = getRectToExpose(layerBounds, localExposeRect, alignX, ali
gnY); |
2332 | 2248 |
2333 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() +
toIntSize(roundedIntRect(r).location())); | 2249 IntSize clampedScrollOffset = m_scrollableArea->clampScrollOffset(adjust
edScrollOffset() + toIntSize(roundedIntRect(r).location())); |
2334 if (clampedScrollOffset != adjustedScrollOffset()) { | 2250 if (clampedScrollOffset != adjustedScrollOffset()) { |
2335 IntSize oldScrollOffset = adjustedScrollOffset(); | 2251 IntSize oldScrollOffset = adjustedScrollOffset(); |
2336 scrollToOffset(clampedScrollOffset); | 2252 m_scrollableArea->scrollToOffset(clampedScrollOffset); |
2337 IntSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollO
ffset; | 2253 IntSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollO
ffset; |
2338 localExposeRect.move(-scrollOffsetDifference); | 2254 localExposeRect.move(-scrollOffsetDifference); |
2339 newRect = LayoutRect(box->localToAbsoluteQuad(FloatQuad(FloatRect(lo
calExposeRect)), UseTransforms).boundingBox()); | 2255 newRect = LayoutRect(box->localToAbsoluteQuad(FloatQuad(FloatRect(lo
calExposeRect)), UseTransforms).boundingBox()); |
2340 } | 2256 } |
2341 } else if (!parentLayer && renderer()->isBox() && renderBox()->canBePrograma
ticallyScrolled()) { | 2257 } else if (!parentLayer && renderer()->isBox() && renderBox()->canBePrograma
ticallyScrolled()) { |
2342 if (frameView) { | 2258 if (frameView) { |
2343 Element* ownerElement = renderer()->document().ownerElement(); | 2259 Element* ownerElement = renderer()->document().ownerElement(); |
2344 | 2260 |
2345 if (ownerElement && ownerElement->renderer()) { | 2261 if (ownerElement && ownerElement->renderer()) { |
2346 HTMLFrameElementBase* frameElementBase = 0; | 2262 HTMLFrameElementBase* frameElementBase = 0; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2569 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); | 2485 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); |
2570 } | 2486 } |
2571 | 2487 |
2572 document.updateLayout(); | 2488 document.updateLayout(); |
2573 | 2489 |
2574 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. | 2490 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. |
2575 } | 2491 } |
2576 | 2492 |
2577 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const | 2493 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const |
2578 { | 2494 { |
2579 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; | 2495 IntSize scrollDimensions = scrollableArea()->maximumScrollPosition() - scrol
lableArea()->minimumScrollPosition(); |
2580 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); | 2496 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
2581 } | 2497 } |
2582 | 2498 |
2583 IntPoint RenderLayer::minimumScrollPosition() const | |
2584 { | |
2585 return -scrollOrigin(); | |
2586 } | |
2587 | |
2588 IntPoint RenderLayer::maximumScrollPosition() const | |
2589 { | |
2590 RenderBox* box = renderBox(); | |
2591 if (!box || !box->hasOverflowClip()) | |
2592 return -scrollOrigin(); | |
2593 | |
2594 return -scrollOrigin() + enclosingIntRect(m_overflowRect).size() - enclosing
IntRect(box->clientBoxRect()).size(); | |
2595 } | |
2596 | |
2597 IntSize RenderLayer::overhangAmount() const | 2499 IntSize RenderLayer::overhangAmount() const |
2598 { | 2500 { |
2599 return IntSize(); | 2501 return IntSize(); |
2600 } | 2502 } |
2601 | 2503 |
2602 bool RenderLayer::isActive() const | 2504 bool RenderLayer::isActive() const |
2603 { | 2505 { |
2604 Page* page = renderer()->frame()->page(); | 2506 Page* page = renderer()->frame()->page(); |
2605 return page && page->focusController().isActive(); | 2507 return page && page->focusController().isActive(); |
2606 } | 2508 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 RenderView* view = renderer()->view(); | 2628 RenderView* view = renderer()->view(); |
2727 if (!view) | 2629 if (!view) |
2728 return parentPoint; | 2630 return parentPoint; |
2729 | 2631 |
2730 IntPoint point = view->frameView()->convertToRenderer(renderer(), parentPoin
t); | 2632 IntPoint point = view->frameView()->convertToRenderer(renderer(), parentPoin
t); |
2731 | 2633 |
2732 point.move(-scrollbarOffset(scrollbar)); | 2634 point.move(-scrollbarOffset(scrollbar)); |
2733 return point; | 2635 return point; |
2734 } | 2636 } |
2735 | 2637 |
2736 IntSize RenderLayer::contentsSize() const | |
2737 { | |
2738 return IntSize(scrollWidth(), scrollHeight()); | |
2739 } | |
2740 | |
2741 int RenderLayer::visibleHeight() const | 2638 int RenderLayer::visibleHeight() const |
2742 { | 2639 { |
2743 return m_layerSize.height(); | 2640 return m_layerSize.height(); |
2744 } | 2641 } |
2745 | 2642 |
2746 int RenderLayer::visibleWidth() const | 2643 int RenderLayer::visibleWidth() const |
2747 { | 2644 { |
2748 return m_layerSize.width(); | 2645 return m_layerSize.width(); |
2749 } | 2646 } |
2750 | 2647 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3028 m_scrollCorner->setFrameRect(scrollCorner); | 2925 m_scrollCorner->setFrameRect(scrollCorner); |
3029 if (m_resizer) | 2926 if (m_resizer) |
3030 m_resizer->setFrameRect(resizerCornerRect(borderBox, ResizerForPointer))
; | 2927 m_resizer->setFrameRect(resizerCornerRect(borderBox, ResizerForPointer))
; |
3031 | 2928 |
3032 if (isComposited()) | 2929 if (isComposited()) |
3033 backing()->positionOverflowControlsLayers(offsetFromRoot); | 2930 backing()->positionOverflowControlsLayers(offsetFromRoot); |
3034 } | 2931 } |
3035 | 2932 |
3036 int RenderLayer::scrollWidth() const | 2933 int RenderLayer::scrollWidth() const |
3037 { | 2934 { |
3038 ASSERT(renderBox()); | 2935 return m_scrollableArea->scrollWidth(); |
3039 if (m_scrollDimensionsDirty) | |
3040 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | |
3041 return snapSizeToPixel(m_overflowRect.width(), renderBox()->clientLeft() + r
enderBox()->x()); | |
3042 } | 2936 } |
3043 | 2937 |
3044 int RenderLayer::scrollHeight() const | 2938 int RenderLayer::scrollHeight() const |
3045 { | 2939 { |
3046 ASSERT(renderBox()); | 2940 return m_scrollableArea->scrollHeight(); |
3047 if (m_scrollDimensionsDirty) | |
3048 const_cast<RenderLayer*>(this)->computeScrollDimensions(); | |
3049 return snapSizeToPixel(m_overflowRect.height(), renderBox()->clientTop() + r
enderBox()->y()); | |
3050 } | |
3051 | |
3052 void RenderLayer::computeScrollDimensions() | |
3053 { | |
3054 RenderBox* box = renderBox(); | |
3055 ASSERT(box); | |
3056 | |
3057 m_scrollDimensionsDirty = false; | |
3058 | |
3059 m_overflowRect = box->layoutOverflowRect(); | |
3060 box->flipForWritingMode(m_overflowRect); | |
3061 | |
3062 int scrollableLeftOverflow = m_overflowRect.x() - box->borderLeft(); | |
3063 int scrollableTopOverflow = m_overflowRect.y() - box->borderTop(); | |
3064 m_scrollableArea->setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrolla
bleTopOverflow)); | |
3065 } | |
3066 | |
3067 bool RenderLayer::hasScrollableHorizontalOverflow() const | |
3068 { | |
3069 return hasHorizontalOverflow() && renderBox()->scrollsOverflowX(); | |
3070 } | |
3071 | |
3072 bool RenderLayer::hasScrollableVerticalOverflow() const | |
3073 { | |
3074 return hasVerticalOverflow() && renderBox()->scrollsOverflowY(); | |
3075 } | |
3076 | |
3077 bool RenderLayer::hasHorizontalOverflow() const | |
3078 { | |
3079 ASSERT(!m_scrollDimensionsDirty); | |
3080 | |
3081 return scrollWidth() > renderBox()->pixelSnappedClientWidth(); | |
3082 } | |
3083 | |
3084 bool RenderLayer::hasVerticalOverflow() const | |
3085 { | |
3086 ASSERT(!m_scrollDimensionsDirty); | |
3087 | |
3088 return scrollHeight() > renderBox()->pixelSnappedClientHeight(); | |
3089 } | 2941 } |
3090 | 2942 |
3091 void RenderLayer::updateScrollbarsAfterLayout() | 2943 void RenderLayer::updateScrollbarsAfterLayout() |
3092 { | 2944 { |
3093 RenderBox* box = renderBox(); | 2945 RenderBox* box = renderBox(); |
3094 ASSERT(box); | 2946 ASSERT(box); |
3095 | 2947 |
3096 // List box parts handle the scrollbars by themselves so we have nothing to
do. | 2948 // List box parts handle the scrollbars by themselves so we have nothing to
do. |
3097 if (box->style()->appearance() == ListboxPart) | 2949 if (box->style()->appearance() == ListboxPart) |
3098 return; | 2950 return; |
3099 | 2951 |
3100 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 2952 bool hasHorizontalOverflow = m_scrollableArea->hasHorizontalOverflow(); |
3101 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 2953 bool hasVerticalOverflow = m_scrollableArea->hasVerticalOverflow(); |
3102 | 2954 |
3103 // overflow:scroll should just enable/disable. | 2955 // overflow:scroll should just enable/disable. |
3104 if (renderer()->style()->overflowX() == OSCROLL) | 2956 if (renderer()->style()->overflowX() == OSCROLL) |
3105 m_hBar->setEnabled(hasHorizontalOverflow); | 2957 m_hBar->setEnabled(hasHorizontalOverflow); |
3106 if (renderer()->style()->overflowY() == OSCROLL) | 2958 if (renderer()->style()->overflowY() == OSCROLL) |
3107 m_vBar->setEnabled(hasVerticalOverflow); | 2959 m_vBar->setEnabled(hasVerticalOverflow); |
3108 | 2960 |
3109 // overflow:auto may need to lay out again if scrollbars got added/removed. | 2961 // overflow:auto may need to lay out again if scrollbars got added/removed. |
3110 bool autoHorizontalScrollBarChanged = box->hasAutoHorizontalScrollbar() && (
hasHorizontalScrollbar() != hasHorizontalOverflow); | 2962 bool autoHorizontalScrollBarChanged = box->hasAutoHorizontalScrollbar() && (
hasHorizontalScrollbar() != hasHorizontalOverflow); |
3111 bool autoVerticalScrollBarChanged = box->hasAutoVerticalScrollbar() && (hasV
erticalScrollbar() != hasVerticalOverflow); | 2963 bool autoVerticalScrollBarChanged = box->hasAutoVerticalScrollbar() && (hasV
erticalScrollbar() != hasVerticalOverflow); |
(...skipping 25 matching lines...) Expand all Loading... |
3137 } else | 2989 } else |
3138 renderer()->layout(); | 2990 renderer()->layout(); |
3139 m_inOverflowRelayout = false; | 2991 m_inOverflowRelayout = false; |
3140 } | 2992 } |
3141 } | 2993 } |
3142 } | 2994 } |
3143 | 2995 |
3144 // Set up the range (and page step/line step). | 2996 // Set up the range (and page step/line step). |
3145 if (m_hBar) { | 2997 if (m_hBar) { |
3146 int clientWidth = box->pixelSnappedClientWidth(); | 2998 int clientWidth = box->pixelSnappedClientWidth(); |
3147 m_hBar->setProportion(clientWidth, m_overflowRect.width()); | 2999 m_hBar->setProportion(clientWidth, m_scrollableArea->overflowRect().widt
h()); |
3148 } | 3000 } |
3149 if (m_vBar) { | 3001 if (m_vBar) { |
3150 int clientHeight = box->pixelSnappedClientHeight(); | 3002 int clientHeight = box->pixelSnappedClientHeight(); |
3151 m_vBar->setProportion(clientHeight, m_overflowRect.height()); | 3003 m_vBar->setProportion(clientHeight, m_scrollableArea->overflowRect().hei
ght()); |
3152 } | 3004 } |
3153 | 3005 |
3154 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollableVe
rticalOverflow()); | 3006 updateScrollableAreaSet(m_scrollableArea->hasScrollableHorizontalOverflow()
|| m_scrollableArea->hasScrollableVerticalOverflow()); |
3155 } | 3007 } |
3156 | 3008 |
3157 void RenderLayer::updateScrollInfoAfterLayout() | 3009 void RenderLayer::updateScrollInfoAfterLayout() |
3158 { | 3010 { |
3159 RenderBox* box = renderBox(); | 3011 RenderBox* box = renderBox(); |
3160 if (!box) | 3012 if (!box) |
3161 return; | 3013 return; |
3162 | 3014 |
3163 m_scrollDimensionsDirty = true; | 3015 m_scrollableArea->updateAfterLayout(); |
3164 IntSize originalScrollOffset = adjustedScrollOffset(); | |
3165 | |
3166 computeScrollDimensions(); | |
3167 | |
3168 if (!box->isMarquee()) { | |
3169 // Layout may cause us to be at an invalid scroll position. In this case
we need | |
3170 // to pull our scroll offsets back to the max (or push them up to the mi
n). | |
3171 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); | |
3172 if (clampedScrollOffset != adjustedScrollOffset()) | |
3173 scrollToOffset(clampedScrollOffset); | |
3174 } | |
3175 | |
3176 updateScrollbarsAfterLayout(); | 3016 updateScrollbarsAfterLayout(); |
3177 | 3017 |
3178 if (originalScrollOffset != adjustedScrollOffset()) | |
3179 scrollableArea()->scrollToOffsetWithoutAnimation(-scrollOrigin() + adjus
tedScrollOffset()); | |
3180 | |
3181 // Composited scrolling may need to be enabled or disabled if the amount of
overflow changed. | 3018 // Composited scrolling may need to be enabled or disabled if the amount of
overflow changed. |
3182 if (renderer()->view() && compositor()->updateLayerCompositingState(this)) | 3019 if (renderer()->view() && compositor()->updateLayerCompositingState(this)) |
3183 compositor()->setCompositingLayersNeedRebuild(); | 3020 compositor()->setCompositingLayersNeedRebuild(); |
3184 } | 3021 } |
3185 | 3022 |
3186 bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const | 3023 bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const |
3187 { | 3024 { |
3188 const IntRect borderBox = renderBox()->pixelSnappedBorderBoxRect(); | 3025 const IntRect borderBox = renderBox()->pixelSnappedBorderBoxRect(); |
3189 | 3026 |
3190 if (rectForHorizontalScrollbar(borderBox).intersects(localRect)) | 3027 if (rectForHorizontalScrollbar(borderBox).intersects(localRect)) |
(...skipping 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5989 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL
&& overflowX != OSCROLL) { | 5826 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL
&& overflowX != OSCROLL) { |
5990 ASSERT(hasHorizontalScrollbar()); | 5827 ASSERT(hasHorizontalScrollbar()); |
5991 m_hBar->setEnabled(true); | 5828 m_hBar->setEnabled(true); |
5992 } | 5829 } |
5993 | 5830 |
5994 if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL &
& overflowY != OSCROLL) { | 5831 if (needsVerticalScrollbar && oldStyle && oldStyle->overflowY() == OSCROLL &
& overflowY != OSCROLL) { |
5995 ASSERT(hasVerticalScrollbar()); | 5832 ASSERT(hasVerticalScrollbar()); |
5996 m_vBar->setEnabled(true); | 5833 m_vBar->setEnabled(true); |
5997 } | 5834 } |
5998 | 5835 |
5999 if (!m_scrollDimensionsDirty) | 5836 m_scrollableArea->updateAfterStyleChange(oldStyle); |
6000 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollab
leVerticalOverflow()); | |
6001 } | 5837 } |
6002 | 5838 |
6003 void RenderLayer::updateOutOfFlowPositioned(const RenderStyle* oldStyle) | 5839 void RenderLayer::updateOutOfFlowPositioned(const RenderStyle* oldStyle) |
6004 { | 5840 { |
6005 if (oldStyle && (renderer()->style()->position() == oldStyle->position())) | 5841 if (oldStyle && (renderer()->style()->position() == oldStyle->position())) |
6006 return; | 5842 return; |
6007 | 5843 |
6008 bool wasOutOfFlowPositioned = oldStyle && (oldStyle->position() == AbsoluteP
osition || oldStyle->position() == FixedPosition); | 5844 bool wasOutOfFlowPositioned = oldStyle && (oldStyle->position() == AbsoluteP
osition || oldStyle->position() == FixedPosition); |
6009 bool isOutOfFlowPositioned = renderer()->isOutOfFlowPositioned(); | 5845 bool isOutOfFlowPositioned = renderer()->isOutOfFlowPositioned(); |
6010 if (!wasOutOfFlowPositioned && !isOutOfFlowPositioned) | 5846 if (!wasOutOfFlowPositioned && !isOutOfFlowPositioned) |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6404 | 6240 |
6405 void RenderLayer::addLayerHitTestRects(LayerHitTestRects& rects) const | 6241 void RenderLayer::addLayerHitTestRects(LayerHitTestRects& rects) const |
6406 { | 6242 { |
6407 if (!size().isEmpty()) { | 6243 if (!size().isEmpty()) { |
6408 Vector<LayoutRect> rect; | 6244 Vector<LayoutRect> rect; |
6409 | 6245 |
6410 if (renderBox() && renderBox()->scrollsOverflow()) { | 6246 if (renderBox() && renderBox()->scrollsOverflow()) { |
6411 // For scrolling layers, rects are taken to be in the space of the c
ontents. | 6247 // For scrolling layers, rects are taken to be in the space of the c
ontents. |
6412 // We need to include both the entire contents, and also the boundin
g box | 6248 // We need to include both the entire contents, and also the boundin
g box |
6413 // of the layer in the space of it's parent (eg. for border / scroll
bars). | 6249 // of the layer in the space of it's parent (eg. for border / scroll
bars). |
6414 rect.append(m_overflowRect); | 6250 rect.append(m_scrollableArea->overflowRect()); |
6415 rects.set(this, rect); | 6251 rects.set(this, rect); |
6416 if (const RenderLayer* parentLayer = parent()) { | 6252 if (const RenderLayer* parentLayer = parent()) { |
6417 LayerHitTestRects::iterator iter = rects.find(parentLayer); | 6253 LayerHitTestRects::iterator iter = rects.find(parentLayer); |
6418 if (iter == rects.end()) | 6254 if (iter == rects.end()) |
6419 iter = rects.add(parentLayer, Vector<LayoutRect>()).iterator
; | 6255 iter = rects.add(parentLayer, Vector<LayoutRect>()).iterator
; |
6420 iter->value.append(boundingBox(parentLayer)); | 6256 iter->value.append(boundingBox(parentLayer)); |
6421 } | 6257 } |
6422 } else { | 6258 } else { |
6423 rect.append(localBoundingBox()); | 6259 rect.append(localBoundingBox()); |
6424 rects.set(this, rect); | 6260 rects.set(this, rect); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6473 } | 6309 } |
6474 } | 6310 } |
6475 | 6311 |
6476 void showLayerTree(const WebCore::RenderObject* renderer) | 6312 void showLayerTree(const WebCore::RenderObject* renderer) |
6477 { | 6313 { |
6478 if (!renderer) | 6314 if (!renderer) |
6479 return; | 6315 return; |
6480 showLayerTree(renderer->enclosingLayer()); | 6316 showLayerTree(renderer->enclosingLayer()); |
6481 } | 6317 } |
6482 #endif | 6318 #endif |
OLD | NEW |