[webkit-changes] [WebKit/WebKit] b08857: When repainting after layout, compute the outline ...

Simon Fraser noreply at github.com
Mon Dec 4 11:20:20 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b088578e1f36d5fb9ce91269eab482bbc52be91d
      https://github.com/WebKit/WebKit/commit/b088578e1f36d5fb9ce91269eab482bbc52be91d
  Author: Simon Fraser <simon.fraser at apple.com>
  Date:   2023-12-04 (Mon, 04 Dec 2023)

  Changed paths:
    M LayoutTests/fast/repaint/hidpi-transform-on-subpixel-repaintrect-expected.txt
    M LayoutTests/svg/repaint/mask-object-bounding-box-shrink-expected.txt
    M Source/WebCore/rendering/LayoutRepainter.cpp
    M Source/WebCore/rendering/LayoutRepainter.h
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderBox.h
    M Source/WebCore/rendering/RenderElement.cpp
    M Source/WebCore/rendering/RenderElement.h
    M Source/WebCore/rendering/RenderInline.cpp
    M Source/WebCore/rendering/RenderInline.h
    M Source/WebCore/rendering/RenderLayer.cpp
    M Source/WebCore/rendering/RenderLayer.h
    M Source/WebCore/rendering/RenderLineBreak.h
    M Source/WebCore/rendering/RenderObject.cpp
    M Source/WebCore/rendering/RenderObject.h
    M Source/WebCore/rendering/RenderReplaced.cpp
    M Source/WebCore/rendering/RenderReplaced.h
    M Source/WebCore/rendering/RenderTableCell.cpp
    M Source/WebCore/rendering/RenderTableCell.h
    M Source/WebCore/rendering/RenderTableCol.cpp
    M Source/WebCore/rendering/RenderTableCol.h
    M Source/WebCore/rendering/RenderTableRow.cpp
    M Source/WebCore/rendering/RenderTableRow.h
    M Source/WebCore/rendering/RenderText.cpp
    M Source/WebCore/rendering/RenderText.h
    M Source/WebCore/rendering/svg/RenderSVGBlock.cpp
    M Source/WebCore/rendering/svg/RenderSVGBlock.h
    M Source/WebCore/rendering/svg/RenderSVGGradientStop.h
    M Source/WebCore/rendering/svg/RenderSVGInline.cpp
    M Source/WebCore/rendering/svg/RenderSVGInline.h
    M Source/WebCore/rendering/svg/RenderSVGModelObject.cpp
    M Source/WebCore/rendering/svg/RenderSVGModelObject.h
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGHiddenContainer.h
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGModelObject.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGModelObject.h
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.h

  Log Message:
  -----------
  When repainting after layout, compute the outline bounds in the same pass as the clipped overflow rect
https://bugs.webkit.org/show_bug.cgi?id=265761
rdar://119101912

Reviewed by Alan Baradlay.

Currently repaints originating in RenderElement::repaintAfterLayoutIfNeeded() are computing using two rectangles:
the clippedOverflowRect, and the outlineBoundsForRepaint. These are computed in two separate ancestor traversals,
but we can make things more efficient by computing them at the same time.

The core functions that compute both rects, `computeRects()` and the virtual `computeVisibleRectsInContainer()`
that it calls were updated in previous commits (271364 at main, 271422 at main) to handle both rectangles. These
are generic functions that compute rectangles both for repaint, and other purposes.

Here we add a new, repaint-specific wrapper, `rectsForRepaintingAfterLayout()`, which returns both rectangles
via RepaintRects. Unfortunately, a number of classes specialize the calling function, `clippedOverflowRect()`,
so we need `rectsForRepaintingAfterLayout()` overrides in those classes to replicate their special behavior.

The previous `localRectForRepaint()` becomes `localRectsForRepaint()` to return the pair of rects,
optionally including the outline bounds rect.

RenderText and RenderInline are special becuase they never cares about the outline bounds rect. RenderTableRow and
RenderTableCol are special, and SVG has some special-case behavior in the non-LBSE code path.

LayoutRepainter now stores a RepaintsRect, and knows that the outline bounds is not needed if this is a full repaint.

RenderElement::repaintAfterLayoutIfNeeded() is adjusted to do the border radius computation using the outline
bounds rect (as a proxy for the border box size). Doing this computation in the clipped rect didn't make much sense.

RenderLayer no longer needs its own RepaintRects class. Also remove the assertions about invalid repaint rects;
they fired too often, and didn't clearly reflect real bugs.

There is a minor behavior change here that affects two tests: the results of the outline bounds rect computation
are snapped to device pixels, which did not happen before. This turns some full repaints into non-full repaints,
affecting fast/repaint/hidpi-transform-on-subpixel-repaintrect.html and svg/repaint/mask-object-bounding-box-shrink.html.
Testing shows that the former still repaints correctly. The latter fails to repaint, but I think that reflects
the fact that SVG should probably treat all post-layout repaints as full repaints (webkit.org/b/265723).

* LayoutTests/fast/repaint/hidpi-transform-on-subpixel-repaintrect-expected.txt:
* LayoutTests/svg/repaint/mask-object-bounding-box-shrink-expected.txt:
* Source/WebCore/rendering/LayoutRepainter.cpp:
(WebCore::LayoutRepainter::LayoutRepainter):
(WebCore::LayoutRepainter::repaintAfterLayout):
* Source/WebCore/rendering/LayoutRepainter.h:
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::localOutlineBoundsRepaintRect const):
(WebCore::RenderBox::outlineBoundsForRepaint const):
(WebCore::RenderBox::localRectsForRepaint const):
(WebCore::RenderBox::localRectForRepaint const): Deleted.
* Source/WebCore/rendering/RenderBox.h:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::repaintAfterLayoutIfNeeded):
* Source/WebCore/rendering/RenderElement.h:
* Source/WebCore/rendering/RenderInline.cpp:
(WebCore::RenderInline::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/RenderInline.h:
* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::recursiveUpdateLayerPositions):
(WebCore::RenderLayer::computeRepaintRects):
(WebCore::RenderLayer::setRepaintRects):
(WebCore::RenderLayer::recursiveUpdateLayerPositionsAfterScroll):
* Source/WebCore/rendering/RenderLayer.h:
(WebCore::RenderLayer::repaintRects const):
* Source/WebCore/rendering/RenderLineBreak.h:
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::localRectsForRepaint const):
(WebCore::RenderObject::rectsForRepaintingAfterLayout const):
(WebCore::RenderObject::clippedOverflowRect const):
(WebCore::RenderObject::localRectForRepaint const): Deleted.
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::RepaintRects::RepaintRects):
(WebCore::RenderObject::outlineBoundsForRepaint const):
(WebCore::RenderObject::computeRectForRepaint const):
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::localRectsForRepaint const):
(WebCore::RenderReplaced::localRectForRepaint const): Deleted.
* Source/WebCore/rendering/RenderReplaced.h:
* Source/WebCore/rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::localRectsForRepaint const):
(WebCore::RenderTableCell::localRectForRepaint const): Deleted.
* Source/WebCore/rendering/RenderTableCell.h:
* Source/WebCore/rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/RenderTableCol.h:
* Source/WebCore/rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/RenderTableRow.h:
* Source/WebCore/rendering/RenderText.cpp:
(WebCore::RenderText::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/RenderText.h:
* Source/WebCore/rendering/svg/RenderSVGBlock.cpp:
(WebCore::RenderSVGBlock::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/svg/RenderSVGBlock.h:
* Source/WebCore/rendering/svg/RenderSVGGradientStop.h:
* Source/WebCore/rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/svg/RenderSVGInline.h:
* Source/WebCore/rendering/svg/RenderSVGModelObject.cpp:
(WebCore::RenderSVGModelObject::localRectsForRepaint const):
(WebCore::RenderSVGModelObject::localRectForRepaint const): Deleted.
* Source/WebCore/rendering/svg/RenderSVGModelObject.h:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGHiddenContainer.h:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGModelObject.cpp:
(WebCore::LegacyRenderSVGModelObject::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGModelObject.h:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::localClippedOverflowRect const):
(WebCore::LegacyRenderSVGRoot::clippedOverflowRect const):
(WebCore::LegacyRenderSVGRoot::rectsForRepaintingAfterLayout const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.h:

Canonical link: https://commits.webkit.org/271495@main




More information about the webkit-changes mailing list