Changeset 164804 in webkit


Ignore:
Timestamp:
Feb 27, 2014 7:52:28 AM (10 years ago)
Author:
graouts@webkit.org
Message:

Respect SVG fragment identifiers in <img> src attribute
https://bugs.webkit.org/show_bug.cgi?id=129387

Reviewed by Antti Koivisto.

Source/WebCore:

Test: svg/css/svg-resource-fragment-identifier-img-src.html

When providing an SVG image for a given renderer, check that the URL used to load
that image is taken into account in case it featured a fragment identifier, ensuring
that the CSS :target pseudo-class is correctly handled for SVG resources. This patch
is specific to <img> elements, specific support will also need to be added for various
CSS properties that support SVG images.

  • svg/graphics/SVGImageCache.cpp:

(WebCore::SVGImageCache::imageForRenderer):
Check if the provided renderer is attached to an <img> element and, if so, pass the
resolved <img> source URL, taking into account srcset, to the SVGImageForContainer.

  • svg/graphics/SVGImageForContainer.cpp:

(WebCore::SVGImageForContainer::setURL):
Trigger the FrameView machinery to ensure that the :target pseudo-class is respected
should the provided URL feature a fragment identifier.

  • svg/graphics/SVGImageForContainer.h:

Declare the new setURL() method.

LayoutTests:

Test that we correctly handle the fragment identifier used in SVG URLs in <img> elements,
checking for correct srcset handling as well.

  • svg/css/resources/fragment-identifiers.svg: Added.
  • svg/css/svg-resource-fragment-identifier-img-src-expected.html: Added.
  • svg/css/svg-resource-fragment-identifier-img-src.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164795 r164804  
     12014-02-27  Antoine Quint  <graouts@webkit.org>
     2
     3        Respect SVG fragment identifiers in <img> src attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=129387
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Test that we correctly handle the fragment identifier used in SVG URLs in <img> elements,
     9        checking for correct srcset handling as well.
     10
     11        * svg/css/resources/fragment-identifiers.svg: Added.
     12        * svg/css/svg-resource-fragment-identifier-img-src-expected.html: Added.
     13        * svg/css/svg-resource-fragment-identifier-img-src.html: Added.
     14
    1152014-02-27  Mihai Tica  <mitica@adobe.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r164802 r164804  
     12014-02-27  Antoine Quint  <graouts@webkit.org>
     2
     3        Respect SVG fragment identifiers in <img> src attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=129387
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Test: svg/css/svg-resource-fragment-identifier-img-src.html
     9
     10        When providing an SVG image for a given renderer, check that the URL used to load
     11        that image is taken into account in case it featured a fragment identifier, ensuring
     12        that the CSS :target pseudo-class is correctly handled for SVG resources. This patch
     13        is specific to <img> elements, specific support will also need to be added for various
     14        CSS properties that support SVG images.
     15
     16        * svg/graphics/SVGImageCache.cpp:
     17        (WebCore::SVGImageCache::imageForRenderer):
     18        Check if the provided renderer is attached to an <img> element and, if so, pass the
     19        resolved <img> source URL, taking into account srcset, to the SVGImageForContainer.
     20
     21        * svg/graphics/SVGImageForContainer.cpp:
     22        (WebCore::SVGImageForContainer::setURL):
     23        Trigger the FrameView machinery to ensure that the :target pseudo-class is respected
     24        should the provided URL feature a fragment identifier.
     25
     26        * svg/graphics/SVGImageForContainer.h:
     27        Declare the new setURL() method.
     28
    1292014-02-27  Krzysztof Czech  <k.czech@samsung.com>
    230
  • trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp

    r163440 r164804  
    2424#include "FrameView.h"
    2525#include "GraphicsContext.h"
     26#include "HTMLImageElement.h"
    2627#include "ImageBuffer.h"
    2728#include "Page.h"
     
    8990
    9091    RefPtr<SVGImageForContainer> imageForContainer = it->value;
     92   
     93    Node* node = renderer->node();
     94    if (node && isHTMLImageElement(node)) {
     95        const AtomicString& urlString = toHTMLImageElement(node)->imageSourceURL();
     96        URL url = node->document().completeURL(urlString);
     97        imageForContainer->setURL(url);
     98    }
     99       
    91100    ASSERT(!imageForContainer->size().isEmpty());
    92101    return imageForContainer.get();
  • trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp

    r163440 r164804  
    2424#include "FloatRect.h"
    2525#include "FloatSize.h"
     26#include "FrameView.h"
    2627#include "Image.h"
    2728#include "SVGImage.h"
     
    5455}
    5556
     57void SVGImageForContainer::setURL(const URL& url)
     58{
     59    m_image->frameView()->scrollToFragment(url);
     60}
     61
    5662} // namespace WebCore
  • trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h

    r163440 r164804  
    3232#include "Image.h"
    3333#include "SVGImage.h"
     34#include "URL.h"
    3435
    3536namespace WebCore {
     
    4546
    4647    virtual IntSize size() const override;
     48
     49    void setURL(const URL&);
    4750
    4851    virtual bool usesContainerSize() const override { return m_image->usesContainerSize(); }
Note: See TracChangeset for help on using the changeset viewer.