Changeset 199247 in webkit


Ignore:
Timestamp:
Apr 8, 2016 2:01:50 PM (8 years ago)
Author:
Alan Bujtas
Message:

Focus ring drawn at incorrect location on image map with CSS transform.
https://bugs.webkit.org/show_bug.cgi?id=143527
<rdar://problem/21908735>

Reviewed by Simon Fraser.

Source/WebCore:

Implement pathForFocusRing for HTMLAreaElement. It follows the logic of RenderObject::addFocusRingRects().

Tests: fast/images/image-map-outline-in-positioned-container.html

fast/images/image-map-outline-with-paint-root-offset.html
fast/images/image-map-outline-with-scale-transform.html
fast/images/image-map-outline.html

  • html/HTMLAreaElement.cpp:

(WebCore::HTMLAreaElement::pathForFocusRing):

  • html/HTMLAreaElement.h:
  • rendering/RenderElement.cpp:

(WebCore::RenderElement::paintFocusRing): Move addFocusRingRects() out of focus ring painting.
(WebCore::RenderElement::paintOutline):

  • rendering/RenderElement.h:
  • rendering/RenderImage.cpp:

(WebCore::RenderImage::paint):
(WebCore::RenderImage::paintAreaElementFocusRing):

  • rendering/RenderImage.h:
  • rendering/RenderInline.cpp:

(WebCore::RenderInline::paintOutline):

LayoutTests:

Implement pathForFocusRing for HTMLAreaElement.

  • fast/images/image-map-outline-in-positioned-container-expected.html: Added.
  • fast/images/image-map-outline-in-positioned-container.html: Added.
  • fast/images/image-map-outline-with-paint-root-offset-expected.html: Added.
  • fast/images/image-map-outline-with-paint-root-offset.html: Added.
  • fast/images/image-map-outline-with-scale-transform-expected.html: Added.
  • fast/images/image-map-outline-with-scale-transform.html: Added.
Location:
trunk
Files:
6 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r199240 r199247  
     12016-04-08  Zalan Bujtas  <zalan@apple.com>
     2
     3        Focus ring drawn at incorrect location on image map with CSS transform.
     4        https://bugs.webkit.org/show_bug.cgi?id=143527
     5        <rdar://problem/21908735>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Implement pathForFocusRing for HTMLAreaElement.
     10
     11        * fast/images/image-map-outline-in-positioned-container-expected.html: Added.
     12        * fast/images/image-map-outline-in-positioned-container.html: Added.
     13        * fast/images/image-map-outline-with-paint-root-offset-expected.html: Added.
     14        * fast/images/image-map-outline-with-paint-root-offset.html: Added.
     15        * fast/images/image-map-outline-with-scale-transform-expected.html: Added.
     16        * fast/images/image-map-outline-with-scale-transform.html: Added.
     17
    1182016-04-08  Filip Pizlo  <fpizlo@apple.com>
    219
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r199183 r199247  
    30233023fast/forms/listbox-padding-clip.html [ ImageOnlyFailure ]
    30243024fast/forms/listbox-padding-clip-overlay.html [ ImageOnlyFailure ]
     3025
     3026# No focusring on iOS.
     3027fast/images/image-map-outline-in-positioned-container.html [ Pass ImageOnlyFailure ]
     3028fast/images/image-map-outline-with-paint-root-offset.html [ Pass ImageOnlyFailure ]
     3029fast/images/image-map-outline-with-scale-transform.html [ Pass ImageOnlyFailure ]
     3030 
  • trunk/Source/WebCore/ChangeLog

    r199245 r199247  
     12016-04-08  Zalan Bujtas  <zalan@apple.com>
     2
     3        Focus ring drawn at incorrect location on image map with CSS transform.
     4        https://bugs.webkit.org/show_bug.cgi?id=143527
     5        <rdar://problem/21908735>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Implement pathForFocusRing for HTMLAreaElement. It follows the logic of RenderObject::addFocusRingRects().
     10
     11        Tests: fast/images/image-map-outline-in-positioned-container.html
     12               fast/images/image-map-outline-with-paint-root-offset.html
     13               fast/images/image-map-outline-with-scale-transform.html
     14               fast/images/image-map-outline.html
     15
     16        * html/HTMLAreaElement.cpp:
     17        (WebCore::HTMLAreaElement::pathForFocusRing):
     18        * html/HTMLAreaElement.h:
     19        * rendering/RenderElement.cpp:
     20        (WebCore::RenderElement::paintFocusRing): Move addFocusRingRects() out of focus ring painting.
     21        (WebCore::RenderElement::paintOutline):
     22        * rendering/RenderElement.h:
     23        * rendering/RenderImage.cpp:
     24        (WebCore::RenderImage::paint):
     25        (WebCore::RenderImage::paintAreaElementFocusRing):
     26        * rendering/RenderImage.h:
     27        * rendering/RenderInline.cpp:
     28        (WebCore::RenderInline::paintOutline):
     29
    1302016-04-08  Brent Fulgham  <bfulgham@apple.com>
    231
  • trunk/Source/WebCore/html/HTMLAreaElement.cpp

    r195452 r199247  
    117117}
    118118
     119Path HTMLAreaElement::computePathForFocusRing(const LayoutSize& elementSize) const
     120{
     121    return getRegion(m_shape == Default ? elementSize : m_lastSize);
     122}
     123
    119124// FIXME: Use RenderElement* instead of RenderObject* once we upstream iOS's DOMUIKitExtensions.{h, mm}.
    120125LayoutRect HTMLAreaElement::computeRect(RenderObject* obj) const
  • trunk/Source/WebCore/html/HTMLAreaElement.h

    r197563 r199247  
    4545    LayoutRect computeRect(RenderObject*) const;
    4646    Path computePath(RenderObject*) const;
     47    Path computePathForFocusRing(const LayoutSize& elementSize) const;
    4748
    4849    // The parent map's image.
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r199154 r199247  
    20412041}
    20422042
    2043 void RenderElement::paintFocusRing(PaintInfo& paintInfo, const LayoutPoint& paintOffset, const RenderStyle& style)
     2043void RenderElement::paintFocusRing(PaintInfo& paintInfo, const RenderStyle& style, const Vector<LayoutRect>& focusRingRects)
    20442044{
    20452045    ASSERT(style.outlineStyleIsAuto());
    2046 
    2047     Vector<LayoutRect> focusRingRects;
    2048     addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
    20492046    float outlineOffset = style.outlineOffset();
    20502047    Vector<FloatRect> pixelSnappedFocusRingRects;
     
    20872084
    20882085    // Only paint the focus ring by hand if the theme isn't able to draw it.
    2089     if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse))
    2090         paintFocusRing(paintInfo, paintRect.location(), styleToUse);
     2086    if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse)) {
     2087        Vector<LayoutRect> focusRingRects;
     2088        addFocusRingRects(focusRingRects, paintRect.location(), paintInfo.paintContainer);
     2089        paintFocusRing(paintInfo, styleToUse, focusRingRects);
     2090    }
    20912091
    20922092    if (hasOutlineAnnotation() && !styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse))
  • trunk/Source/WebCore/rendering/RenderElement.h

    r198943 r199247  
    268268    bool renderBlockFlowHasMarkupTruncation() const { return m_renderBlockFlowHasMarkupTruncation; }
    269269
    270     void paintFocusRing(PaintInfo&, const LayoutPoint&, const RenderStyle&);
     270    void paintFocusRing(PaintInfo&, const RenderStyle&, const Vector<LayoutRect>& focusRingRects);
    271271    void paintOutline(PaintInfo&, const LayoutRect&);
    272272    void updateOutlineAutoAncestor(bool hasOutlineAuto) const;
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r198074 r199247  
    3131#include "BitmapImage.h"
    3232#include "CachedImage.h"
     33#include "FocusController.h"
    3334#include "FontCache.h"
    3435#include "FontCascade.h"
     
    485486   
    486487    if (paintInfo.phase == PaintPhaseOutline)
    487         paintAreaElementFocusRing(paintInfo);
     488        paintAreaElementFocusRing(paintInfo, paintOffset);
    488489}
    489490   
    490 void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo)
     491void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    491492{
    492493#if PLATFORM(IOS)
    493494    UNUSED_PARAM(paintInfo);
     495    UNUSED_PARAM(paintOffset);
    494496#else
    495497    if (document().printing() || !frame().selection().isFocusedAndActive())
     
    499501        return;
    500502
     503    if (!document().page())
     504        return;
     505
    501506    Element* focusedElement = document().focusedElement();
    502507    if (!is<HTMLAreaElement>(focusedElement))
     
    507512        return;
    508513
     514    auto* areaElementStyle = areaElement.computedStyle();
     515    if (!areaElementStyle)
     516        return;
     517
     518    float outlineWidth = areaElementStyle->outlineWidth();
     519    if (!outlineWidth)
     520        return;
     521
    509522    // Even if the theme handles focus ring drawing for entire elements, it won't do it for
    510523    // an area within an image, so we don't call RenderTheme::supportsFocusRing here.
    511 
    512     Path path = areaElement.computePath(this);
     524    auto path = areaElement.computePathForFocusRing(size());
    513525    if (path.isEmpty())
    514526        return;
    515527
    516     // FIXME: Do we need additional code to clip the path to the image's bounding box?
    517 
    518     RenderStyle* areaElementStyle = areaElement.computedStyle();
    519     float outlineWidth = areaElementStyle->outlineWidth();
    520     if (!outlineWidth)
    521         return;
    522 
    523     paintInfo.context().drawFocusRing(path, outlineWidth,
    524         areaElementStyle->outlineOffset(),
    525         areaElementStyle->visitedDependentColor(CSSPropertyOutlineColor));
     528    AffineTransform zoomTransform;
     529    zoomTransform.scale(style().effectiveZoom());
     530    path.transform(zoomTransform);
     531
     532    auto adjustedOffset = paintOffset;
     533    adjustedOffset.moveBy(location());
     534    path.translate(toFloatSize(adjustedOffset));
     535
     536#if PLATFORM(MAC)
     537    bool needsRepaint;
     538    paintInfo.context().drawFocusRing(path, document().page()->focusController().timeSinceFocusWasSet(), needsRepaint);
     539    if (needsRepaint)
     540        document().page()->focusController().setFocusedElementNeedsRepaint();
     541#else
     542    paintInfo.context().drawFocusRing(path, outlineWidth, areaElementStyle->outlineOffset(), areaElementStyle->visitedDependentColor(CSSPropertyOutlineColor));
     543#endif
    526544#endif
    527545}
  • trunk/Source/WebCore/rendering/RenderImage.h

    r197566 r199247  
    118118    void updateInnerContentRect();
    119119
    120     void paintAreaElementFocusRing(PaintInfo&);
     120    void paintAreaElementFocusRing(PaintInfo&, const LayoutPoint& paintOffset);
    121121   
    122122    void layoutShadowControls(const LayoutSize& oldSize);
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r198753 r199247  
    16041604    RenderStyle& styleToUse = style();
    16051605    // Only paint the focus ring by hand if the theme isn't able to draw it.
    1606     if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse))
    1607         paintFocusRing(paintInfo, paintOffset, styleToUse);
     1606    if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse)) {
     1607        Vector<LayoutRect> focusRingRects;
     1608        addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer);
     1609        paintFocusRing(paintInfo, styleToUse, focusRingRects);
     1610    }
    16081611
    16091612    if (hasOutlineAnnotation() && !styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse))
Note: See TracChangeset for help on using the changeset viewer.