Changeset 29864 in webkit


Ignore:
Timestamp:
Jan 29, 2008 7:50:08 PM (16 years ago)
Author:
mitz@apple.com
Message:

WebCore:

Reviewed by Dave Hyatt.

Test: fast/css/font-face-remote.html

Added an isSVGFont method to CachedFont and use it to decide how to
process the font data. Currently whether the data is SVG is determined
based on the format property in the @font-face rule, but in the future
the MIME type or other metadata may be used when the format is
unspecified.

  • css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::getFontData): Changed to parse the data as SVG only if the CachedFont is an SVG font.
  • css/CSSFontSelector.cpp: (WebCore::CSSFontSelector::addFontFaceRule): Mark the CachedFont as an SVG font based on format.
  • loader/CachedFont.cpp: (WebCore::CachedFont::CachedFont): Initialize m_isSVGFont to false. (WebCore::CachedFont::ensureCustomFontData): (WebCore::CachedFont::ensureSVGFontData): (WebCore::CachedFont::getSVGFontById):
  • loader/CachedFont.h: (WebCore::CachedFont::isSVGFont): Added. (WebCore::CachedFont::setSVGFont): Added.

LayoutTests:

Reviewed by Dave Hyatt.

This is the first @font-face test that actually tests loading font data
from a URL.

  • fast/css/font-face-remote.html: Added.
  • fast/css/resources/Ahem.ttf: Added.
  • platform/mac/fast/css/font-face-remote-expected.checksum: Added.
  • platform/mac/fast/css/font-face-remote-expected.png: Added.
  • platform/mac/fast/css/font-face-remote-expected.txt: Added.
Location:
trunk
Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r29860 r29864  
     12008-01-29  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=17085
     6          <rdar://problem/5714136> REGRESSION (r29839): All remote fonts are treated as SVG fonts
     7
     8        This is the first @font-face test that actually tests loading font data
     9        from a URL.
     10
     11        * fast/css/font-face-remote.html: Added.
     12        * fast/css/resources/Ahem.ttf: Added.
     13        * platform/mac/fast/css/font-face-remote-expected.checksum: Added.
     14        * platform/mac/fast/css/font-face-remote-expected.png: Added.
     15        * platform/mac/fast/css/font-face-remote-expected.txt: Added.
     16
    1172008-01-29  Adele Peterson  <adele@apple.com>
    218
  • trunk/WebCore/ChangeLog

    r29861 r29864  
     12008-01-29  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=17085
     6          <rdar://problem/5714136> REGRESSION (r29839): All remote fonts are treated as SVG fonts
     7
     8        Test: fast/css/font-face-remote.html
     9
     10        Added an isSVGFont method to CachedFont and use it to decide how to
     11        process the font data. Currently whether the data is SVG is determined
     12        based on the format property in the @font-face rule, but in the future
     13        the MIME type or other metadata may be used when the format is
     14        unspecified.
     15
     16        * css/CSSFontFaceSource.cpp:
     17        (WebCore::CSSFontFaceSource::getFontData): Changed to parse the data as
     18        SVG only if the CachedFont is an SVG font.
     19        * css/CSSFontSelector.cpp:
     20        (WebCore::CSSFontSelector::addFontFaceRule): Mark the CachedFont as an
     21        SVG font based on format.
     22        * loader/CachedFont.cpp:
     23        (WebCore::CachedFont::CachedFont): Initialize m_isSVGFont to false.
     24        (WebCore::CachedFont::ensureCustomFontData):
     25        (WebCore::CachedFont::ensureSVGFontData):
     26        (WebCore::CachedFont::getSVGFontById):
     27        * loader/CachedFont.h:
     28        (WebCore::CachedFont::isSVGFont): Added.
     29        (WebCore::CachedFont::setSVGFont): Added.
     30
    1312008-01-29  Antti Koivisto  <antti@apple.com>
    232
  • trunk/WebCore/css/CSSFontFaceSource.cpp

    r29839 r29864  
    119119        if (m_font) {
    120120#if ENABLE(SVG_FONTS)
    121             // For SVG fonts parse the external SVG document, and extract the <font> element.
    122             if (!m_font->ensureSVGFontData())
    123                 return 0;
     121            if (m_font->isSVGFont()) {
     122                // For SVG fonts parse the external SVG document, and extract the <font> element.
     123                if (!m_font->ensureSVGFontData())
     124                    return 0;
    124125
    125             if (!m_externalSVGFontElement)
    126                 m_externalSVGFontElement = m_font->getSVGFontById(SVGURIReference::getTarget(m_string));
     126                if (!m_externalSVGFontElement)
     127                    m_externalSVGFontElement = m_font->getSVGFontById(SVGURIReference::getTarget(m_string));
    127128
    128             if (m_externalSVGFontElement) {
     129                if (!m_externalSVGFontElement)
     130                    return 0;
     131
    129132                SVGFontFaceElement* fontFaceElement = 0;
    130133
  • trunk/WebCore/css/CSSFontSelector.cpp

    r29839 r29864  
    2929#include "CSSFontSelector.h"
    3030#include "AtomicString.h"
    31 #include "CString.h"
     31#include "CachedFont.h"
    3232#include "CSSFontFace.h"
    3333#include "CSSFontFaceRule.h"
     
    156156            if (item->isSupportedFormat()) {
    157157                CachedFont* cachedFont = m_document->docLoader()->requestFont(item->resource());
    158                 if (cachedFont)
     158                if (cachedFont) {
     159#if ENABLE(SVG_FONTS)
     160                    if (foundSVGFont)
     161                        cachedFont->setSVGFont(true);
     162#endif
    159163                    source = new CSSFontFaceSource(item->resource(), cachedFont);
     164                }
    160165            }
    161166        } else {
  • trunk/WebCore/loader/CachedFont.cpp

    r29839 r29864  
    5151CachedFont::CachedFont(DocLoader* dl, const String &url)
    5252    : CachedResource(url, FontResource), m_fontData(0)
     53    , m_isSVGFont(false)
    5354{
    5455    // Don't load the file yet.  Wait for an access before triggering the load.
     
    9495{
    9596#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK)
     97#if ENABLE(SVG_FONTS)
     98    ASSERT(!m_isSVGFont);
     99#endif
    96100    if (!m_fontData && !m_errorOccurred && !m_loading && m_data) {
    97101        m_fontData = createFontCustomPlatformData(m_data.get());
     
    120124bool CachedFont::ensureSVGFontData()
    121125{
     126    ASSERT(m_isSVGFont);
    122127    if (!m_externalSVGDocument && !m_errorOccurred && !m_loading && m_data) {
    123128        m_externalSVGDocument = new SVGDocument(DOMImplementation::instance(), 0);
     
    136141SVGFontElement* CachedFont::getSVGFontById(const String& fontName) const
    137142{
     143    ASSERT(m_isSVGFont);
    138144    RefPtr<NodeList> list = m_externalSVGDocument->getElementsByTagName(SVGNames::fontTag.localName());
    139145    if (!list)
  • trunk/WebCore/loader/CachedFont.h

    r29839 r29864  
    6464
    6565#if ENABLE(SVG_FONTS)
     66    bool isSVGFont() const { return m_isSVGFont; }
     67    void setSVGFont(bool isSVG) { m_isSVGFont = isSVG; }
    6668    bool ensureSVGFontData();
    6769    SVGFontElement* getSVGFontById(const String&) const;
     
    7375
    7476#if ENABLE(SVG_FONTS)
     77    bool m_isSVGFont;
    7578    RefPtr<SVGDocument> m_externalSVGDocument;
    7679#endif
Note: See TracChangeset for help on using the changeset viewer.