Skip to content
  • wangxianzhu@chromium.org's avatar
    Focus ring for a child layer is incorrectly offset by ancestor composited layer's position · 64f38297
    wangxianzhu@chromium.org authored
    https://bugs.webkit.org/show_bug.cgi?id=110895
    
    Reviewed by Simon Fraser.
    
    Source/WebCore:
    
    Test: compositing/sub-layer-focus-ring.html
    
    The problem occurs in RenderBlock::addFocusRingRects() where the absolute position of a sub-layer is used to calculate the focus ring rect of the layer.
    Should use the relative position to the current paintContainer instead.
    
    To fix the issue:
    - RenderLayer passes LayerPaintingInfo.rootLayer to PaintInfo.paintContainer
    - Let RenderObject::paintFocusRing() and RenderObject::paintOutline() take PaintInfo instead of GraphicsContext* so that the paintContainer can be passed
    - RenderBlock::addFocusRingRects() uses localToContainerPoint(FloatPoint(), paintContainer) instead of localToAbsolute() to calculate the focus ring rect of a sublayer.
    
    * rendering/PaintInfo.h:
    (WebCore):
    (WebCore::PaintInfo::PaintInfo): Add a field paintContainer (the RenderLayerModelObject which originates the current painting)
    (PaintInfo):
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::paintObject):
    (WebCore::RenderBlock::paintContinuationOutlines):
    (WebCore::RenderBlock::addFocusRingRects): Use the added paintContainer parameter to calculate the relative offset of the child layer.
    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::paintBackgroundForFragments): Pass LayerPaintingInfo.rootLayer to PaintInfo.paintContainer.
    (WebCore::RenderLayer::paintForegroundForFragmentsWithPhase): Ditto.
    (WebCore::RenderLayer::paintOutlineForFragments): Ditto.
    (WebCore::RenderLayer::paintMaskForFragments): Ditto.
    * rendering/RenderLayer.cpp:
    * rendering/RenderObject.cpp:
    (WebCore::RenderObject::paintFocusRing): Now takes PaintInfo instead of GraphicsContext*. Pass paintInfo.paintContainer to addFocusRingRects().
    (WebCore::RenderObject::paintOutline): Now takes PaintInfo instead of GraphicsContext*.
    (WebCore::RenderObject::absoluteFocusRingQuads):
    * rendering/RenderObject.h:
    (WebCore::RenderObject::addFocusRingRects): Add paintContainer parameter.
    
    LayoutTests:
    
    New ref test for the bug.
    
    * compositing/sub-layer-focus-ring-expected.html: Added.
    * compositing/sub-layer-focus-ring.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@144350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    64f38297