Changeset 107731 in webkit
- Timestamp:
- Feb 14, 2012 1:17:27 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107729 r107731 1 2012-02-14 Levi Weintraub <leviw@chromium.org> 2 3 Update usage of LayoutUnits in RenderLayer 4 https://bugs.webkit.org/show_bug.cgi?id=78511 5 6 Reviewed by Simon Fraser. 7 8 Updating RenderLayer to properly use LayoutUnits. See descriptions below for the rationale behind all 9 the changes. Also adding a roundedIntSize method that takes a LayoutSize. 10 11 No new tests. No change in behavior. 12 13 * rendering/LayoutTypes.h: 14 (WebCore::roundedIntSize): Inline method that currently does nothing, but will round a LayoutSize 15 to an IntSize. 16 * rendering/RenderLayer.cpp: 17 (WebCore::RenderLayer::updateLayerPositions): Switching repaint and outline boxes to LayoutRects, as 18 it's important to keep the precision of these rects until handing off to the embedder (in FrameView). 19 (WebCore::RenderLayer::computeRepaintRects): Repaint rects should be preserved in subpixel units until 20 being passed to the embedding layer. This prevents needless repaints. 21 (WebCore::RenderLayer::convertToPixelSnappedLayerCoords): Convenience function to return pixel snapped rects 22 (WebCore): 23 (WebCore::RenderLayer::convertToLayerCoords): Fixing a style flaw. 24 (WebCore::RenderLayer::scrollRectToVisible): Pixel snapping the rect when handing off to the embedder. 25 (WebCore::RenderLayer::maximumScrollPosition): Scroll offsets are rounded. 26 (WebCore::RenderLayer::scrollCornerRect): Scrollbars are drawn natively and should be positioned on pixel 27 boundaries. 28 (WebCore::RenderLayer::scrollCornerAndResizerRect): Resize corner doesn't influence the size/position of 29 render objects. It is only painted and hit tested. Therefor it should use integers. 30 (WebCore::RenderLayer::offsetFromResizeCorner): Ditto. 31 (WebCore::RenderLayer::positionOverflowControls): Overflow controls are drawn natively and should be 32 positioned on integer boundaries. 33 (WebCore::RenderLayer::paintOverflowControls): Ditto. 34 (WebCore::RenderLayer::paintScrollCorner): Ditto. 35 (WebCore::RenderLayer::drawPlatformResizerImage): Ditto. 36 (WebCore::RenderLayer::paintResizer): Ditto. 37 (WebCore::RenderLayer::hitTestOverflowControls): Hit testing & overflow controls both use integers. 38 (WebCore::RenderLayer::clipToRect): Clipping to actual painted (pixel snapped) layer bounds in the 39 graphics context. 40 (WebCore::RenderLayer::paintLayerContents): Calling paintOverflowControls at pixel bounds. 41 (WebCore::RenderLayer::hitTest): Intersecting the hit test area with pixel snapped boundaries. 42 (WebCore::RenderLayer::setBackingNeedsRepaintInRect): Sending pixelSnapped rects to the backing 43 store, which only cares about pixels, and hence integers. 44 * rendering/RenderLayer.h: 45 (WebCore::RenderLayer::scrolledContentOffset): RenderLayer's scroll offsets are used in platform 46 code, so we need to return them as integers. Rounding the scroll overflow before adding it to the 47 scroll offset, which was already stored in integers. 48 (RenderLayer): 49 1 50 2012-02-14 Abhishek Arya <inferno@chromium.org> 2 51 -
trunk/Source/WebCore/rendering/LayoutTypes.h
r107465 r107731 55 55 { 56 56 return rect; 57 } 58 59 inline IntSize roundedIntSize(const LayoutSize& s) 60 { 61 return s; 57 62 } 58 63 -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r107605 r107731 359 359 convertToLayerCoords(root(), offset); 360 360 } 361 positionOverflowControls(toSize( offset));361 positionOverflowControls(toSize(roundedIntPoint(offset))); 362 362 363 363 updateVisibilityStatus(); … … 377 377 378 378 RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint(); 379 IntRect oldRepaintRect = m_repaintRect;380 IntRect oldOutlineBox = m_outlineBox;379 LayoutRect oldRepaintRect = m_repaintRect; 380 LayoutRect oldOutlineBox = m_outlineBox; 381 381 computeRepaintRects(offsetFromRoot); 382 382 // FIXME: Should ASSERT that value calculated for m_outlineBox using the cached offset is the same … … 435 435 } 436 436 437 void RenderLayer::computeRepaintRects( IntPoint* offsetFromRoot)437 void RenderLayer::computeRepaintRects(LayoutPoint* offsetFromRoot) 438 438 { 439 439 ASSERT(!m_visibleContentStatusDirty); … … 1239 1239 } 1240 1240 1241 void 1242 RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint& location) const 1241 void RenderLayer::convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntPoint& roundedLocation) const 1242 { 1243 LayoutPoint location = roundedLocation; 1244 convertToLayerCoords(ancestorLayer, location); 1245 roundedLocation = roundedIntPoint(location); 1246 } 1247 1248 void RenderLayer::convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntRect& roundedRect) const 1249 { 1250 LayoutRect rect = roundedRect; 1251 convertToLayerCoords(ancestorLayer, rect); 1252 roundedRect = pixelSnappedIntRect(rect); 1253 } 1254 1255 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint& location) const 1243 1256 { 1244 1257 if (ancestorLayer == this) … … 1327 1340 } 1328 1341 1329 void 1330 RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect& rect) const 1342 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect& rect) const 1331 1343 { 1332 1344 LayoutPoint delta; … … 1790 1802 { 1791 1803 // FIXME: m_scrollSize may not be up-to-date if m_scrollDimensionsDirty is true. 1792 return scrollOrigin() + m_scrollSize- visibleContentRect(true).size();1804 return scrollOrigin() + roundedIntSize(m_scrollSize) - visibleContentRect(true).size(); 1793 1805 } 1794 1806 … … 1852 1864 bool hasResizer = renderer()->style()->resize() != RESIZE_NONE; 1853 1865 if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar))) 1854 return cornerRect(this, renderBox()->borderBoxRect());1866 return cornerRect(this, pixelSnappedIntRect(renderBox()->borderBoxRect())); 1855 1867 return IntRect(); 1856 1868 } … … 1871 1883 IntRect scrollCornerAndResizer = scrollCornerRect(); 1872 1884 if (scrollCornerAndResizer.isEmpty()) 1873 scrollCornerAndResizer = resizerCornerRect(this, box->borderBoxRect());1885 scrollCornerAndResizer = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect())); 1874 1886 return scrollCornerAndResizer; 1875 1887 } … … 2133 2145 } 2134 2146 2135 LayoutSize RenderLayer::offsetFromResizeCorner(const LayoutPoint& absolutePoint) const2147 IntSize RenderLayer::offsetFromResizeCorner(const IntPoint& absolutePoint) const 2136 2148 { 2137 2149 // Currently the resize corner is always the bottom right corner … … 2147 2159 } 2148 2160 2149 void RenderLayer::positionOverflowControls(const LayoutSize& offsetFromLayer)2161 void RenderLayer::positionOverflowControls(const IntSize& offsetFromLayer) 2150 2162 { 2151 2163 if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE)) … … 2399 2411 } 2400 2412 2401 void RenderLayer::paintOverflowControls(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& damageRect, bool paintingOverlayControls)2413 void RenderLayer::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls) 2402 2414 { 2403 2415 // Don't do anything if we have no overflow. … … 2423 2435 return; 2424 2436 2425 LayoutPoint adjustedPaintOffset = paintOffset;2437 IntPoint adjustedPaintOffset = paintOffset; 2426 2438 if (paintingOverlayControls) 2427 2439 adjustedPaintOffset = m_cachedOverlayScrollbarOffset; … … 2459 2471 } 2460 2472 2461 void RenderLayer::paintScrollCorner(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& damageRect)2473 void RenderLayer::paintScrollCorner(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect) 2462 2474 { 2463 2475 RenderBox* box = renderBox(); 2464 2476 ASSERT(box); 2465 2477 2466 LayoutRect absRect = scrollCornerRect();2478 IntRect absRect = scrollCornerRect(); 2467 2479 absRect.moveBy(paintOffset); 2468 2480 if (!absRect.intersects(damageRect)) … … 2485 2497 } 2486 2498 2487 void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, LayoutRect resizerCornerRect)2499 void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, IntRect resizerCornerRect) 2488 2500 { 2489 2501 float deviceScaleFactor = WebCore::deviceScaleFactor(renderer()->frame()); … … 2506 2518 } 2507 2519 2508 void RenderLayer::paintResizer(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& damageRect)2520 void RenderLayer::paintResizer(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect) 2509 2521 { 2510 2522 if (renderer()->style()->resize() == RESIZE_NONE) … … 2514 2526 ASSERT(box); 2515 2527 2516 LayoutRect absRect = resizerCornerRect(this, box->borderBoxRect());2528 IntRect absRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect())); 2517 2529 absRect.moveBy(paintOffset); 2518 2530 if (!absRect.intersects(damageRect)) … … 2536 2548 GraphicsContextStateSaver stateSaver(*context); 2537 2549 context->clip(absRect); 2538 LayoutRect largerCorner = absRect;2539 largerCorner.setSize( LayoutSize(largerCorner.width() + 1, largerCorner.height() + 1));2550 IntRect largerCorner = absRect; 2551 largerCorner.setSize(IntSize(largerCorner.width() + 1, largerCorner.height() + 1)); 2540 2552 context->setStrokeColor(Color(makeRGB(217, 217, 217)), ColorSpaceDeviceRGB); 2541 2553 context->setStrokeThickness(1.0f); … … 2559 2571 } 2560 2572 2561 bool RenderLayer::hitTestOverflowControls(HitTestResult& result, const LayoutPoint& localPoint)2573 bool RenderLayer::hitTestOverflowControls(HitTestResult& result, const IntPoint& localPoint) 2562 2574 { 2563 2575 if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZE_NONE)) … … 2569 2581 IntRect resizeControlRect; 2570 2582 if (renderer()->style()->resize() != RESIZE_NONE) { 2571 resizeControlRect = resizerCornerRect(this, box->borderBoxRect());2583 resizeControlRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect())); 2572 2584 if (resizeControlRect.contains(localPoint)) 2573 2585 return true; … … 2647 2659 return; 2648 2660 context->save(); 2649 context->clip( clipRect.rect());2661 context->clip(pixelSnappedIntRect(clipRect.rect())); 2650 2662 2651 2663 if (!clipRect.hasRadius()) … … 2948 2960 if (isPaintingOverlayScrollbars) { 2949 2961 clipToRect(rootLayer, context, paintDirtyRect, damageRect); 2950 paintOverflowControls(context, roundedIntPoint(paintOffset), damageRect.rect(), true);2962 paintOverflowControls(context, roundedIntPoint(paintOffset), pixelSnappedIntRect(damageRect.rect()), true); 2951 2963 restoreClip(context, paintDirtyRect, damageRect); 2952 2964 } … … 3112 3124 renderer()->document()->updateLayout(); 3113 3125 3114 LayoutRect hitTestArea = renderer()->isRenderFlowThread() ? toRenderFlowThread(renderer())->borderBoxRect() : renderer()->view()->documentRect();3126 IntRect hitTestArea = renderer()->isRenderFlowThread() ? toRenderFlowThread(renderer())->borderBoxRect() : renderer()->view()->documentRect(); 3115 3127 if (!request.ignoreClipping()) 3116 hitTestArea.intersect( frameVisibleRect(renderer()));3128 hitTestArea.intersect(pixelSnappedIntRect(frameVisibleRect(renderer()))); 3117 3129 3118 3130 RenderLayer* insideLayer = hitTestLayer(this, 0, request, result, hitTestArea, result.point(), false); … … 4271 4283 view->repaintViewRectangle(absRect); 4272 4284 } else 4273 backing()->setContentsNeedDisplayInRect( r);4285 backing()->setContentsNeedDisplayInRect(pixelSnappedIntRect(r)); 4274 4286 } 4275 4287 -
trunk/Source/WebCore/rendering/RenderLayer.h
r107422 r107731 296 296 void scrollByRecursively(LayoutUnit xDelta, LayoutUnit yDelta, ScrollOffsetClamping = ScrollOffsetUnclamped); 297 297 298 LayoutSize scrolledContentOffset() const { return scrollOffset() + m_scrollOverflow; }298 IntSize scrolledContentOffset() const { return scrollOffset() + roundedIntSize(m_scrollOverflow); } 299 299 300 300 int scrollXOffset() const { return m_scrollOffset.width() + scrollOrigin().x(); } … … 328 328 329 329 bool hasOverflowControls() const; 330 bool isPointInResizeControl(const LayoutPoint& absolutePoint) const;331 bool hitTestOverflowControls(HitTestResult&, const LayoutPoint& localPoint);332 LayoutSize offsetFromResizeCorner(const LayoutPoint& absolutePoint) const;333 334 void paintOverflowControls(GraphicsContext*, const LayoutPoint&, const LayoutRect& damageRect, bool paintingOverlayControls = false);335 void paintScrollCorner(GraphicsContext*, const LayoutPoint&, const LayoutRect& damageRect);336 void paintResizer(GraphicsContext*, const LayoutPoint&, const LayoutRect& damageRect);330 bool isPointInResizeControl(const IntPoint& absolutePoint) const; 331 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); 332 IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const; 333 334 void paintOverflowControls(GraphicsContext*, const IntPoint&, const IntRect& damageRect, bool paintingOverlayControls = false); 335 void paintScrollCorner(GraphicsContext*, const IntPoint&, const IntRect& damageRect); 336 void paintResizer(GraphicsContext*, const IntPoint&, const IntRect& damageRect); 337 337 338 338 void updateScrollInfoAfterLayout(); … … 426 426 #endif 427 427 428 void convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntPoint& location) const; 429 void convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntRect&) const; 428 430 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint& location) const; 429 431 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&) const; … … 569 571 void updateZOrderListsSlowCase(); 570 572 571 void computeRepaintRects( IntPoint* offsetFromRoot = 0);573 void computeRepaintRects(LayoutPoint* offsetFromRoot = 0); 572 574 void clearRepaintRects(); 573 575 … … 714 716 LayoutPoint absoluteToContents(const LayoutPoint&) const; 715 717 716 void positionOverflowControls(const LayoutSize&);718 void positionOverflowControls(const IntSize&); 717 719 void updateScrollCornerStyle(); 718 720 void updateResizerStyle(); 719 721 720 void drawPlatformResizerImage(GraphicsContext*, LayoutRect resizerCornerRect);722 void drawPlatformResizerImage(GraphicsContext*, IntRect resizerCornerRect); 721 723 722 724 void updatePagination(); … … 822 824 823 825 // The width/height of our scrolled area. 824 IntSize m_scrollSize;826 LayoutSize m_scrollSize; 825 827 826 828 // For layers with overflow, we have a pair of scrollbars. … … 844 846 #endif 845 847 846 LayoutPoint m_cachedOverlayScrollbarOffset;848 IntPoint m_cachedOverlayScrollbarOffset; 847 849 848 850 RenderMarquee* m_marquee; // Used by layers with overflow:marquee
Note: See TracChangeset
for help on using the changeset viewer.