← All issues

[LBSE] Preserve paint order of non-composited children around composited SVG siblings

ea0009d

LBSE(Layer-Based SVG Engine)는 레거시 단일 backing store SVG 렌더러와 달리, SVG 요소를 HTML과 유사한 방식으로 RenderLayer에 매핑합니다. Compositor는 컨테이너 자식들로 구성된 GraphicsLayer 형제 목록을 조립하는데, composited 자식(will-change, 3D transform, opacity 승격)은 독립적인 GraphicsLayer가 되고 non-composited 자식은 backing store를 공유합니다. Compositor는 목록 순서대로 layer를 쌓기 때문에, non-composited backing 하나와 여러 composited 형제가 섞인 컨테이너에서는 임의의 DOM paint order를 표현할 수 없습니다. 공유 layer는 모든 composited 형제의 완전히 뒤쪽 또는 완전히 앞쪽에 배치될 수밖에 없기 때문입니다.

LayoutTests/TestExpectations

-# webkit.org/b/308565 LBSE specific compositing tests
-svg/compositing/foreground-layer-composited-html-in-foreignobject-between-rects.html [ ImageOnlyFailure ]
-svg/compositing/foreground-layer-composited-svg-rect-and-foreignobject-interleaved.html [ ImageOnlyFailure ]
-svg/compositing/foreground-layer-mixed-svg-and-foreignobject-composited.html [ ImageOnlyFailure ]
-svg/compositing/foreground-layer-multiple-foreignobjects-composited.html [ ImageOnlyFailure ]

Source/WebCore/rendering/RenderLayerBackingSVGAdditions.cpp

+WebCore::RenderLayerBacking::updateSVGSegmentLayers
+WebCore::RenderLayerBacking::clearSVGSegmentLayers
+WebCore::RenderLayerBacking::svgSegmentLayerAfterCompositedChild
+WebCore::RenderLayerBacking::svgSegmentRangeForGraphicsLayer
+WebCore::RenderLayerBacking::computeSVGSegmentBounds
+WebCore::RenderLayerBacking::updateSVGSegmentLayerGeometry

이 commit은 paint order segment overlay GraphicsLayer를 도입합니다. SVG의 flat child 목록은 각 "anchor"(composited child) 경계에서 [begin, end) 형태의 index range로 분할됩니다. 첫 번째 구간은 컨테이너의 backing store에서 직접 렌더링됩니다. 이후 각 non-composited 자식 구간에는 "(svg segment N)"이라는 이름의 GraphicsLayer가 할당되고, compositor의 child 목록에서 직전 anchor 바로 뒤에 삽입됩니다. 한편 "derived anchor"는 자손이 composited이기 때문에 anchor가 되는 요소로, 인라인으로 paint됩니다. 이런 요소가 있으면 경계 감지가 복잡해지는데, derived anchor 앞의 빈 leading 구간에서도 반드시 segment를 생성해야 하기 때문입니다. RenderSVGForeignObject는 SVG DOM 순서 paint path가 아닌 HTML 방식의 z-order 목록으로 paint되기 때문에 segmentation 대상에서 제외됩니다.

Flat child list: [r1, a1(composited), r2, r3, a2(composited), r4]

Before (broken):                     After (correct):
  container-primary → r1,r2,r3,r4      container-primary → slice [0,1) → r1
  a1 GraphicsLayer                     a1 GraphicsLayer   → a1's content
  a2 GraphicsLayer                     (svg segment 1)    → slice [2,4) → r2,r3
                                       a2 GraphicsLayer   → a2's content
                                       (svg segment 2)    → slice [4,6) → r4

이 commit은 새로운 LBSE compositing pipeline에서 발생하던 근본적인 z-order 정확성 위반을 수정합니다. 애니메이션 또는 transform이 적용된 요소의 non-composited SVG 형제 요소가 잘못된 순서로 렌더링되던 문제가 해결되었습니다. 아울러 복잡한 lifetime 관리, index 연산, 동적 업데이트 로직을 포함하는 상당한 규모의 새로운 compositing 서브시스템이 도입되었으며, 이는 새로운 attack surface로 작용합니다.

🔒

New segment index arithmetic, derived-anchor boundary detection, and dynamic overlay layer lifecycle all present audit-worthy security investigation points.

더 확인하려면 구독해 주세요