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

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

Issue 14703004: Reland "Unifies ScrollView and RenderLayer to use non-shi..." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerBacking.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 2195
2196 int x = max(min(scrollOffset.width(), maxX), 0); 2196 int x = max(min(scrollOffset.width(), maxX), 0);
2197 int y = max(min(scrollOffset.height(), maxY), 0); 2197 int y = max(min(scrollOffset.height(), maxY), 0);
2198 return IntSize(x, y); 2198 return IntSize(x, y);
2199 } 2199 }
2200 2200
2201 void RenderLayer::scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClampi ng clamp) 2201 void RenderLayer::scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClampi ng clamp)
2202 { 2202 {
2203 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s crollOffset) : scrollOffset; 2203 IntSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(s crollOffset) : scrollOffset;
2204 if (newScrollOffset != adjustedScrollOffset()) 2204 if (newScrollOffset != adjustedScrollOffset())
2205 scrollToOffsetWithoutAnimation(IntPoint(newScrollOffset)); 2205 scrollToOffsetWithoutAnimation(-scrollOrigin() + newScrollOffset);
2206 } 2206 }
2207 2207
2208 void RenderLayer::scrollTo(int x, int y) 2208 void RenderLayer::setScrollOffset(const IntPoint& newScrollOffset)
2209 { 2209 {
2210 RenderBox* box = renderBox(); 2210 RenderBox* box = renderBox();
2211 if (!box) 2211 if (!box)
2212 return; 2212 return;
2213 2213
2214 if (box->style()->overflowX() != OMARQUEE) { 2214 if (box->style()->overflowX() != OMARQUEE) {
2215 // Ensure that the dimensions will be computed if they need to be (for o verflow:hidden blocks). 2215 // Ensure that the dimensions will be computed if they need to be (for o verflow:hidden blocks).
2216 if (m_scrollDimensionsDirty) 2216 if (m_scrollDimensionsDirty)
2217 computeScrollDimensions(); 2217 computeScrollDimensions();
2218 } 2218 }
2219 2219
2220 // FIXME: Eventually, we will want to perform a blit. For now never 2220 if (m_scrollOffset == toIntSize(newScrollOffset))
2221 // blit, since the check for blitting is going to be very
2222 // complicated (since it will involve testing whether our layer
2223 // is either occluded by another layer or clipped by an enclosing
2224 // layer or contains fixed backgrounds, etc.).
2225 IntSize newScrollOffset = IntSize(x - scrollOrigin().x(), y - scrollOrigin() .y());
2226 if (m_scrollOffset == newScrollOffset)
2227 return; 2221 return;
2228 m_scrollOffset = newScrollOffset; 2222 m_scrollOffset = toIntSize(newScrollOffset);
2229 2223
2230 Frame* frame = renderer()->frame(); 2224 Frame* frame = renderer()->frame();
2231 InspectorInstrumentation::willScrollLayer(frame); 2225 InspectorInstrumentation::willScrollLayer(frame);
2232 2226
2233 RenderView* view = renderer()->view(); 2227 RenderView* view = renderer()->view();
2234 2228
2235 // We should have a RenderView if we're trying to scroll. 2229 // We should have a RenderView if we're trying to scroll.
2236 ASSERT(view); 2230 ASSERT(view);
2237 2231
2238 // Update the positions of our child layers (if needed as only fixed layers should be impacted by a scroll). 2232 // Update the positions of our child layers (if needed as only fixed layers should be impacted by a scroll).
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 2568
2575 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view. 2569 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to keep the point under the cursor in view.
2576 } 2570 }
2577 2571
2578 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const 2572 int RenderLayer::scrollSize(ScrollbarOrientation orientation) const
2579 { 2573 {
2580 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_hBar : m_vB ar).get(); 2574 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_hBar : m_vB ar).get();
2581 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; 2575 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0;
2582 } 2576 }
2583 2577
2584 void RenderLayer::setScrollOffset(const IntPoint& offset)
2585 {
2586 scrollTo(offset.x(), offset.y());
2587 }
2588
2589 int RenderLayer::scrollPosition(Scrollbar* scrollbar) const 2578 int RenderLayer::scrollPosition(Scrollbar* scrollbar) const
2590 { 2579 {
2591 if (scrollbar->orientation() == HorizontalScrollbar) 2580 if (scrollbar->orientation() == HorizontalScrollbar)
2592 return scrollXOffset(); 2581 return scrollXOffset();
2593 if (scrollbar->orientation() == VerticalScrollbar) 2582 if (scrollbar->orientation() == VerticalScrollbar)
2594 return scrollYOffset(); 2583 return scrollYOffset();
2595 return 0; 2584 return 0;
2596 } 2585 }
2597 2586
2598 IntPoint RenderLayer::scrollPosition() const 2587 IntPoint RenderLayer::scrollPosition() const
2599 { 2588 {
2600 return IntPoint(m_scrollOffset); 2589 return IntPoint(m_scrollOffset);
2601 } 2590 }
2602 2591
2603 IntPoint RenderLayer::minimumScrollPosition() const 2592 IntPoint RenderLayer::minimumScrollPosition() const
2604 { 2593 {
2605 return -scrollOrigin(); 2594 return -scrollOrigin();
2606 } 2595 }
2607 2596
2608 IntPoint RenderLayer::maximumScrollPosition() const 2597 IntPoint RenderLayer::maximumScrollPosition() const
2609 { 2598 {
2610 // FIXME: m_scrollSize may not be up-to-date if m_scrollDimensionsDirty is t rue. 2599 RenderBox* box = renderBox();
2611 return -scrollOrigin() + roundedIntSize(m_scrollSize) - visibleContentRect(I ncludeScrollbars).size(); 2600 if (!box)
2601 return -scrollOrigin();
2602
2603 LayoutRect overflowRect(box->layoutOverflowRect());
2604 box->flipForWritingMode(overflowRect);
2605 return -scrollOrigin() + enclosingIntRect(overflowRect).size() - enclosingIn tRect(box->clientBoxRect()).size();
2612 } 2606 }
2613 2607
2614 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr ollbarInclusion) const 2608 IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scr ollbarInclusion) const
2615 { 2609 {
2616 int verticalScrollbarWidth = 0; 2610 int verticalScrollbarWidth = 0;
2617 int horizontalScrollbarHeight = 0; 2611 int horizontalScrollbarHeight = 0;
2618 if (scrollbarInclusion == IncludeScrollbars) { 2612 if (scrollbarInclusion == IncludeScrollbars) {
2619 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; 2613 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i sOverlayScrollbar()) ? verticalScrollbar()->width() : 0;
2620 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; 2614 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0;
2621 } 2615 }
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
3243 // Layout may cause us to be at an invalid scroll position. In this case we need 3237 // Layout may cause us to be at an invalid scroll position. In this case we need
3244 // to pull our scroll offsets back to the max (or push them up to the mi n). 3238 // to pull our scroll offsets back to the max (or push them up to the mi n).
3245 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); 3239 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset());
3246 if (clampedScrollOffset != adjustedScrollOffset()) 3240 if (clampedScrollOffset != adjustedScrollOffset())
3247 scrollToOffset(clampedScrollOffset); 3241 scrollToOffset(clampedScrollOffset);
3248 } 3242 }
3249 3243
3250 updateScrollbarsAfterLayout(); 3244 updateScrollbarsAfterLayout();
3251 3245
3252 if (originalScrollOffset != adjustedScrollOffset()) 3246 if (originalScrollOffset != adjustedScrollOffset())
3253 scrollToOffsetWithoutAnimation(IntPoint(adjustedScrollOffset())); 3247 scrollToOffsetWithoutAnimation(-scrollOrigin() + adjustedScrollOffset()) ;
3254 3248
3255 // Composited scrolling may need to be enabled or disabled if the amount of overflow changed. 3249 // Composited scrolling may need to be enabled or disabled if the amount of overflow changed.
3256 if (renderer()->view() && compositor()->updateLayerCompositingState(this)) 3250 if (renderer()->view() && compositor()->updateLayerCompositingState(this))
3257 compositor()->setCompositingLayersNeedRebuild(); 3251 compositor()->setCompositingLayersNeedRebuild();
3258 } 3252 }
3259 3253
3260 bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const 3254 bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const
3261 { 3255 {
3262 const IntRect borderBox = renderBox()->pixelSnappedBorderBoxRect(); 3256 const IntRect borderBox = renderBox()->pixelSnappedBorderBoxRect();
3263 3257
(...skipping 3224 matching lines...) Expand 10 before | Expand all | Expand 10 after
6488 } 6482 }
6489 } 6483 }
6490 6484
6491 void showLayerTree(const WebCore::RenderObject* renderer) 6485 void showLayerTree(const WebCore::RenderObject* renderer)
6492 { 6486 {
6493 if (!renderer) 6487 if (!renderer)
6494 return; 6488 return;
6495 showLayerTree(renderer->enclosingLayer()); 6489 showLayerTree(renderer->enclosingLayer());
6496 } 6490 }
6497 #endif 6491 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerBacking.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698