WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2007 06:21:47 +0000 (06:21 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2007 06:21:47 +0000 (06:21 +0000)
        Reviewed by Darin Adler and Dave Hyatt.

        - Substitute the user's preferred standard font for an unknown primary
          font before falling back on the platform's last resort font

        Cannot be tested in DumpRenderTree because it sets the standard font to
        Times, which is also the hard-coded last resort font on Mac.

        * css/CSSFontSelector.cpp:
        (WebCore::CSSFontSelector::getFontData): Changed the early bail out
        condition to allow getting generic font families from settings even if
        there are not @font-face rules. Fixed a typo that mapped fantasy to
        cursive. Added a mapping from -webkit-standard to the standard family.
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::CSSStyleSelector): Changed to always create
        a font selector.
        (WebCore::CSSRuleSet::addRulesFromSheet):
        (WebCore::CSSStyleSelector::applyProperty): Changed to always use the
        font selector.
        * css/CSSStyleSelector.h:
        (WebCore::CSSStyleSelector::fontSelector):
        * platform/graphics/FontCache.cpp:
        (WebCore::FontCache::getFontData): Try the user's preferred standard
        font before the platform's last resort font.

LayoutTests:

        - remove passing tests following the change to font fallback

        * platform/win/Skipped: Removed tests that failed only because they
        specified as primary font family a font family that was not available
        on Windows and therefore were rendered using the platform last resort
        font, Times New Roman. Now they are rendered using the 'standard'
        font family, which is set to Times on both Mac and Windows when running
        the tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28882 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/win/Skipped
WebCore/ChangeLog
WebCore/css/CSSFontSelector.cpp
WebCore/css/CSSStyleSelector.cpp
WebCore/css/CSSStyleSelector.h
WebCore/platform/graphics/FontCache.cpp

index 85d3c4718e2fddc41e208ea861fd2b8af3a80ecd..b50e02e3328473d8bfe7541c4565ef583e58794a 100644 (file)
@@ -1,3 +1,14 @@
+2007-12-19  Dan Bernstein  <mitz@apple.com>
+
+        - remove passing tests following the change to font fallback
+
+        * platform/win/Skipped: Removed tests that failed only because they
+        specified as primary font family a font family that was not available
+        on Windows and therefore were rendered using the platform last resort
+        font, Times New Roman. Now they are rendered using the 'standard'
+        font family, which is set to Times on both Mac and Windows when running
+        the tests.
+
 2007-12-19  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Darin.
index 5d60709728b6141c850947054871336dba0f8817..8875d2fbbff56f9ddb7a44a29046cbad18041926 100644 (file)
@@ -49,10 +49,8 @@ css2.1/t1202-counter-09-b.html
 css2.1/t1202-counters-09-b.html
 editing/deleting/5144139-2.html
 fast/css/beforeSelectorOnCodeElement.html
-fast/css/font_property_normal.html
 fast/css/rtl-ordering.html
 fast/css/text-security.html
-fast/encoding/denormalised-voiced-japanese-chars.html
 fast/encoding/invalid-UTF-8.html
 fast/forms/select-visual-hebrew.html
 fast/forms/select-writing-direction-natural.html
@@ -60,38 +58,19 @@ fast/forms/visual-hebrew-text-field.html
 fast/lists/w3-list-styles.html
 fast/text/international/bidi-neutral-run.html
 fast/xsl/xslt-text.xml
-svg/W3C-SVG-1.1/animate-elem-03-t.svg
-svg/W3C-SVG-1.1/animate-elem-24-t.svg
-svg/W3C-SVG-1.1/animate-elem-36-t.svg
-svg/W3C-SVG-1.1/animate-elem-40-t.svg
 svg/W3C-SVG-1.1/coords-viewattr-01-b.svg
-svg/W3C-SVG-1.1/fonts-desc-02-t.svg
 svg/W3C-SVG-1.1/fonts-elem-01-t.svg
 svg/W3C-SVG-1.1/fonts-elem-02-t.svg
 svg/W3C-SVG-1.1/fonts-elem-03-b.svg
 svg/W3C-SVG-1.1/fonts-elem-04-b.svg
-svg/W3C-SVG-1.1/fonts-elem-05-t.svg
-svg/W3C-SVG-1.1/fonts-elem-06-t.svg
 svg/W3C-SVG-1.1/fonts-elem-07-b.svg
 svg/W3C-SVG-1.1/fonts-glyph-02-t.svg
-svg/W3C-SVG-1.1/fonts-glyph-03-t.svg
-svg/W3C-SVG-1.1/fonts-glyph-04-t.svg
-svg/W3C-SVG-1.1/fonts-kern-01-t.svg
 svg/W3C-SVG-1.1/interact-cursor-01-f.svg
-svg/W3C-SVG-1.1/masking-mask-01-b.svg
 svg/W3C-SVG-1.1/metadata-example-01-b.svg
-svg/W3C-SVG-1.1/pservers-grad-08-b.svg
-svg/W3C-SVG-1.1/render-elems-06-t.svg
-svg/W3C-SVG-1.1/render-elems-07-t.svg
 svg/W3C-SVG-1.1/render-elems-08-t.svg
 svg/W3C-SVG-1.1/render-groups-01-b.svg
-svg/W3C-SVG-1.1/render-groups-03-t.svg
-svg/W3C-SVG-1.1/text-altglyph-01-b.svg
 svg/W3C-SVG-1.1/text-fonts-01-t.svg
 svg/W3C-SVG-1.1/text-intro-05-t.svg
-svg/W3C-SVG-1.1/text-text-04-t.svg
-svg/W3C-SVG-1.1/text-text-05-t.svg
-svg/W3C-SVG-1.1/text-text-06-t.svg
 svg/W3C-SVG-1.1/text-tselect-02-f.svg
 svg/W3C-SVG-1.1/animate-elem-06-t.svg
 svg/W3C-SVG-1.1/animate-elem-07-t.svg
@@ -100,12 +79,6 @@ svg/W3C-SVG-1.1/text-path-01-b.svg
 svg/batik/text/smallFonts.svg
 svg/batik/text/textAnchor.svg
 svg/batik/text/textBiDi.svg
-svg/batik/text/textEffect3.svg
-svg/batik/text/textEffect.svg
-svg/batik/text/textFeatures.svg
-svg/batik/text/textPosition2.svg
-svg/batik/text/textProperties2.svg
-svg/batik/text/textStyles.svg
 svg/batik/paints/patternRegions.svg
 svg/carto.net/button.svg
 svg/carto.net/colourpicker.svg
@@ -120,21 +93,15 @@ svg/custom/circular-marker-reference-4.svg
 svg/custom/control-points-for-S-and-T.svg
 svg/custom/coords-relative-units-transforms.svg
 svg/custom/marker-changes.svg
-svg/custom/scrolling-embedded-svg-file-image-repaint-problem.html
 svg/custom/use-referencing-nonexisting-symbol.svg
 svg/custom/width-full-percentage.svg
 svg/hixie/text/003.html
 svg/hixie/text/003a.xml
 svg/hixie/viewbox/preserveAspectRatio/002.xml
-svg/text/text-altglyph-01-b.svg
 svg/text/text-fonts-01-t.svg
 svg/text/text-intro-05-t.svg
-svg/text/text-text-04-t.svg
-svg/text/text-text-05-t.svg
-svg/text/text-text-06-t.svg
 svg/text/text-tselect-02-f.svg
 tables/mozilla/core/bloomberg.html
-tables/mozilla/bugs/bug8381.html
 tables/mozilla/bugs/bug10633.html
 tables/mozilla/bugs/bug23151.html
 tables/mozilla/bugs/bug113424.html
index 1d61eaa532f91eed59f71c6caf108c2acfb43da9..08385658afda3169e890f09c9c9bafce1570767a 100644 (file)
@@ -1,3 +1,30 @@
+2007-12-19  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler and Dave Hyatt.
+
+        - Substitute the user's preferred standard font for an unknown primary
+          font before falling back on the platform's last resort font
+
+        Cannot be tested in DumpRenderTree because it sets the standard font to
+        Times, which is also the hard-coded last resort font on Mac.
+
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::getFontData): Changed the early bail out
+        condition to allow getting generic font families from settings even if
+        there are not @font-face rules. Fixed a typo that mapped fantasy to
+        cursive. Added a mapping from -webkit-standard to the standard family.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::CSSStyleSelector): Changed to always create
+        a font selector.
+        (WebCore::CSSRuleSet::addRulesFromSheet):
+        (WebCore::CSSStyleSelector::applyProperty): Changed to always use the
+        font selector.
+        * css/CSSStyleSelector.h:
+        (WebCore::CSSStyleSelector::fontSelector):
+        * platform/graphics/FontCache.cpp:
+        (WebCore::FontCache::getFontData): Try the user's preferred standard
+        font before the platform's last resort font.
+
 2007-12-19  Sven Herzberg  <sven@imendio.com>
 
         Reviewed by Alp Toker.
index 0b92413b4f819be5f965790ded708cc0792153f8..0a8973f944e9380256f4665f3597369791d91688 100644 (file)
@@ -199,7 +199,7 @@ void CSSFontSelector::fontLoaded(CSSFontFace*)
 
 FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName)
 {
-    if (m_fonts.isEmpty())
+    if (m_fonts.isEmpty() && !familyName.startsWith("-webkit-"))
         return 0;
     
     bool bold = fontDescription.bold();
@@ -246,9 +246,11 @@ FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, c
         else if (familyName == "-webkit-cursive")
             genericFamily = settings->cursiveFontFamily();
         else if (familyName == "-webkit-fantasy")
-            genericFamily = settings->cursiveFontFamily();
+            genericFamily = settings->fantasyFontFamily();
         else if (familyName == "-webkit-monospace")
             genericFamily = settings->fixedFontFamily();
+        else if (familyName == "-webkit-standard")
+            genericFamily = settings->standardFontFamily();
         
         if (!genericFamily.isEmpty())
             return FontCache::getCachedFontData(FontCache::getCachedFontPlatformData(fontDescription, genericFamily));
index 50778d31b01f060606ca7a2b85365b18189f5710..ab95a9548f43c80db50ef4d2465dc48d5c292f3c 100644 (file)
@@ -247,6 +247,7 @@ CSSStyleSelector::CSSStyleSelector(Document* doc, const String& userStyleSheet,
     init();
     
     m_document = doc;
+    m_fontSelector = new CSSFontSelector(doc);
 
     m_matchAuthorAndUserStyles = matchAuthorAndUserStyles;
 
@@ -298,10 +299,6 @@ CSSStyleSelector::CSSStyleSelector(Document* doc, const String& userStyleSheet,
     for (; it.current(); ++it)
         if (it.current()->isCSSStyleSheet() && !it.current()->disabled())
             m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), *m_medium, this);
-
-    // Just delete our font selector if we end up with nothing but invalid @font-face rules.
-    if (m_fontSelector && m_fontSelector->isEmpty())
-        m_fontSelector = 0;
 }
 
 void CSSStyleSelector::init()
@@ -1819,14 +1816,14 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat
                     } else if (item->isFontFaceRule() && styleSelector) {
                         // Add this font face to our set.
                         const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(item);
-                        styleSelector->ensureFontSelector()->addFontFaceRule(fontFaceRule);
+                        styleSelector->fontSelector()->addFontFaceRule(fontFaceRule);
                     }
                 }   // for rules
             }   // if rules
         } else if (item->isFontFaceRule() && styleSelector) {
             // Add this font face to our set.
             const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(item);
-            styleSelector->ensureFontSelector()->addFontFaceRule(fontFaceRule);
+            styleSelector->fontSelector()->addFontFaceRule(fontFaceRule);
         }
     }
 }
@@ -3132,23 +3129,23 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                         face = settings->standardFontFamily();
                         break;
                     case CSS_VAL_SERIF:
-                        face = m_fontSelector ? "-webkit-serif" : settings->serifFontFamily();
+                        face = "-webkit-serif";
                         fontDescription.setGenericFamily(FontDescription::SerifFamily);
                         break;
                     case CSS_VAL_SANS_SERIF:
-                        face = m_fontSelector ? "-webkit-sans-serif" : settings->sansSerifFontFamily();
+                        face = "-webkit-sans-serif";
                         fontDescription.setGenericFamily(FontDescription::SansSerifFamily);
                         break;
                     case CSS_VAL_CURSIVE:
-                        face = m_fontSelector ? "-webkit-cursive" : settings->cursiveFontFamily();
+                        face = "-webkit-cursive";
                         fontDescription.setGenericFamily(FontDescription::CursiveFamily);
                         break;
                     case CSS_VAL_FANTASY:
-                        face = m_fontSelector ? "-webkit-fantasy" : settings->fantasyFontFamily();
+                        face = "-webkit-fantasy";
                         fontDescription.setGenericFamily(FontDescription::FantasyFamily);
                         break;
                     case CSS_VAL_MONOSPACE:
-                        face = m_fontSelector ? "-webkit-monospace" : settings->fixedFontFamily();
+                        face = "-webkit-monospace";
                         fontDescription.setGenericFamily(FontDescription::MonospaceFamily);
                         break;
                 }
@@ -4720,11 +4717,4 @@ bool CSSStyleSelector::hasSelectorForAttribute(const AtomicString &attrname)
     return m_selectorAttrs.contains(attrname.impl());
 }
 
-CSSFontSelector* CSSStyleSelector::ensureFontSelector()
-{
-    if (!m_fontSelector.get())
-        m_fontSelector = new CSSFontSelector(m_document);
-    return m_fontSelector.get();
-}
-
 } // namespace WebCore
index 0ccf7d57ebff1d7b76b191cb47cdbd9b282b08aa..a844e5c06eee6162141404be5e752d1c6dda1da2 100644 (file)
@@ -128,7 +128,6 @@ class StyledElement;
         bool hasSelectorForAttribute(const AtomicString &attrname);
  
         CSSFontSelector* fontSelector() { return m_fontSelector.get(); }
-        CSSFontSelector* ensureFontSelector();
 
     protected:
 
index d1aba16ec0415aea9ba9315c47415c52a4281093..7cf9fbb280c3af2bf638331e98fb29540979f8d3 100644 (file)
@@ -252,10 +252,19 @@ const FontData* FontCache::getFontData(const Font& font, int& familyIndex, FontS
         // Geeza Pro font.
         result = getSimilarFontPlatformData(font);
 
-    if (!result && startIndex == 0)
-        // We still don't have a result.  Hand back our last resort fallback font.  We only do the last resort fallback
-        // when trying to find the primary font.  Otherwise our fallback will rely on the actual characters used.
+    if (!result && startIndex == 0) {
+        // If it's the primary font that we couldn't find, we try the following. In all other cases, we will
+        // just use per-character system fallback.
+
+        if (fontSelector) {
+            // Try the user's preferred standard font.
+            if (FontData* data = fontSelector->getFontData(font.fontDescription(), "-webkit-standard"))
+                return data;
+        }
+
+        // Still no result.  Hand back our last resort fallback font.
         result = getLastResortFallbackFont(font.fontDescription());
+    }
 
     // Now that we have a result, we need to go from FontPlatformData -> FontData.
     return getCachedFontData(result);