Changeset 40278 in webkit


Ignore:
Timestamp:
Jan 26, 2009 4:45:36 PM (15 years ago)
Author:
weinig@apple.com
Message:

WebCore:

2009-01-26 Sam Weinig <sam@webkit.org>

Reviewed by Dan Bernstein.

Fix for https://bugs.webkit.org/show_bug.cgi?id=18141
Acid3 tests 77 and 78 fail on reload due to SVG font race
<rdar://problem/6504899>

Match Opera's behavior of loading SVGFonts as soon as <font-face-uri>
tag is inserted into the document and not at the first use of the font
as is done for CSS web fonts.

This fixes a race condition noticeable by some in the Acid3 test that
happened because the onload event handler for an iframe containing a
<font-face-uri> with an external reference was not delayed by the pending
load of the font.

Test: http/tests/misc/SVGFont-delayed-load.html

  • svg/SVGFontFaceUriElement.cpp: (WebCore::SVGFontFaceUriElement::~SVGFontFaceUriElement): (WebCore::SVGFontFaceUriElement::parseMappedAttribute): Call loadFont if the href attribute changes. (WebCore::SVGFontFaceUriElement::insertedIntoDocument): Call loadFont. (WebCore::SVGFontFaceUriElement::loadFont): Force a load of the font specified in href attribute.
  • svg/SVGFontFaceUriElement.h:

LayoutTests:

2009-01-26 Sam Weinig <sam@webkit.org>

Reviewed by Dan Bernstein.

Test for https://bugs.webkit.org/show_bug.cgi?id=18141
Acid3 tests 77 and 78 fail on reload due to SVG font race
<rdar://problem/6504899>

  • http/tests/misc/SVGFont-delayed-load-expected.txt: Added.
  • http/tests/misc/SVGFont-delayed-load.html: Added.
  • http/tests/misc/resources/SVGFont-delayed-loader.svg: Added.
  • svg/custom/acid3-test-77.html:
  • svg/custom/resources/Acid3Font-loader.svg:
Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r40276 r40278  
     12009-01-26  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Test for https://bugs.webkit.org/show_bug.cgi?id=18141
     6        Acid3 tests 77 and 78 fail on reload due to SVG font race
     7        <rdar://problem/6504899>
     8
     9        * http/tests/misc/SVGFont-delayed-load-expected.txt: Added.
     10        * http/tests/misc/SVGFont-delayed-load.html: Added.
     11        * http/tests/misc/resources/SVGFont-delayed-loader.svg: Added.
     12        * svg/custom/acid3-test-77.html:
     13        * svg/custom/resources/Acid3Font-loader.svg:
     14
    1152009-01-26  Pierre-Olivier Latour  <pol@apple.com>
    216
  • trunk/LayoutTests/svg/custom/acid3-test-77.html

    r35146 r40278  
    5252    text.setAttribute("y", "1em");
    5353    text.setAttribute("font-size", "4000");
    54     window.setTimeout("executeTest()", 150);
     54    executeTest();
    5555  }
    5656   
  • trunk/LayoutTests/svg/custom/resources/Acid3Font-loader.svg

    r30767 r40278  
    1111    </defs>
    1212    <text>X</text>
    13 
    14     <!-- Adding this possibly fixes the problem that acid3-test-77.html is timing dependa though it currently crashes us
    15     <script>document.documentElement.offsetWidth;</script> -->
    1613</svg>
  • trunk/WebCore/ChangeLog

    r40275 r40278  
     12009-01-26  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=18141
     6        Acid3 tests 77 and 78 fail on reload due to SVG font race
     7        <rdar://problem/6504899>
     8
     9        Match Opera's behavior of loading SVGFonts as soon as <font-face-uri>
     10        tag is inserted into the document and not at the first use of the font
     11        as is done for CSS web fonts.
     12
     13        This fixes a race condition noticeable by some in the Acid3 test that
     14        happened because the onload event handler for an iframe containing a
     15        <font-face-uri> with an external reference was not delayed by the pending
     16        load of the font.
     17
     18        Test: http/tests/misc/SVGFont-delayed-load.html
     19
     20        * svg/SVGFontFaceUriElement.cpp:
     21        (WebCore::SVGFontFaceUriElement::~SVGFontFaceUriElement):
     22        (WebCore::SVGFontFaceUriElement::parseMappedAttribute): Call loadFont if
     23        the href attribute changes.
     24        (WebCore::SVGFontFaceUriElement::insertedIntoDocument): Call loadFont.
     25        (WebCore::SVGFontFaceUriElement::loadFont): Force a load of the
     26        font specified in href attribute.
     27        * svg/SVGFontFaceUriElement.h:
     28
    1292009-01-26  Timothy Hatcher  <timothy@apple.com>
    230
  • trunk/WebCore/svg/SVGFontFaceUriElement.cpp

    r34627 r40278  
    11/*
    22   Copyright (C) 2007 Eric Seidel <eric@webkit.org>
     3   Copyright (C) 2009 Apple Inc. All rights reserved.
    34
    45   This library is free software; you can redistribute it and/or
     
    2425
    2526#include "CSSFontFaceSrcValue.h"
     27#include "CachedFont.h"
     28#include "DocLoader.h"
     29#include "Document.h"
    2630#include "SVGFontFaceElement.h"
    2731#include "SVGNames.h"
     
    3741}
    3842
     43SVGFontFaceUriElement::~SVGFontFaceUriElement()
     44{
     45    if (m_cachedFont)
     46        m_cachedFont->removeClient(this);
     47}
     48
    3949PassRefPtr<CSSFontFaceSrcValue> SVGFontFaceUriElement::srcValue() const
    4050{
     
    4353    src->setFormat(value.isEmpty() ? "svg" : value); // Default format
    4454    return src.release();
     55}
     56
     57void SVGFontFaceUriElement::parseMappedAttribute(MappedAttribute* attr)
     58{
     59    const QualifiedName& attrName = attr->name();
     60    if (attrName == XLinkNames::hrefAttr)
     61        loadFont();
     62    else
     63        SVGElement::parseMappedAttribute(attr);
    4564}
    4665
     
    5776}
    5877
     78void SVGFontFaceUriElement::insertedIntoDocument()
     79{
     80    loadFont();
     81    SVGElement::insertedIntoDocument();
     82}
     83
     84void SVGFontFaceUriElement::loadFont()
     85{
     86    if (m_cachedFont)
     87        m_cachedFont->removeClient(this);
     88
     89    String href = getAttribute(XLinkNames::hrefAttr);
     90    if (!href.isNull()) {       
     91        DocLoader* docLoader = document()->docLoader();
     92        m_cachedFont = docLoader->requestFont(href);
     93        m_cachedFont->setSVGFont(true);
     94        m_cachedFont->addClient(this);
     95        m_cachedFont->beginLoadIfNeeded(docLoader);
     96    } else
     97        m_cachedFont = 0;
     98}
     99
    59100}
    60101
  • trunk/WebCore/svg/SVGFontFaceUriElement.h

    r30633 r40278  
    2222
    2323#if ENABLE(SVG_FONTS)
     24#include "CachedResourceClient.h"
     25#include "CachedResourceHandle.h"
    2426#include "SVGElement.h"
    2527
    2628namespace WebCore {
     29
    2730    class CSSFontFaceSrcValue;
    28     class SVGFontFaceUriElement : public SVGElement {
     31    class CachedFont;
     32
     33    class SVGFontFaceUriElement : public SVGElement, public CachedResourceClient {
    2934    public:
    3035        SVGFontFaceUriElement(const QualifiedName&, Document*);
     36        ~SVGFontFaceUriElement();
    3137       
    3238        PassRefPtr<CSSFontFaceSrcValue> srcValue() const;
    33        
     39
     40        virtual void parseMappedAttribute(MappedAttribute*);
    3441        virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     42        virtual void insertedIntoDocument();
     43
     44    private:
     45        void loadFont();
     46
     47        CachedResourceHandle<CachedFont> m_cachedFont;
    3548    };
    3649
Note: See TracChangeset for help on using the changeset viewer.