2008-11-10 Glenn Wilson <gwilson@chromium.org>
authordarin@chromium.org <darin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Nov 2008 01:45:57 +0000 (01:45 +0000)
committerdarin@chromium.org <darin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Nov 2008 01:45:57 +0000 (01:45 +0000)
        Reviewed by Dan Bernstein.

        Fixed bug http://bugs.webkit.org/show_bug.cgi?id=21953

        This fixes the crash when the small-caps font variant is used
        on a lower-case glyph that does not have a corresponding
        upper-case glyph defined in the set of available fonts.

        This changes Font.cpp to check if the font being used exists before trying to apply the small-caps variant.

        Test: fast/css/small-caps-crash.html

        * platform/graphics/Font.cpp:
        (WebCore::Font::glyphDataForCharacter):

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

LayoutTests/ChangeLog
LayoutTests/fast/css/small-caps-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/small-caps-crash.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/platform/graphics/Font.cpp

index 388c2ac..504833a 100644 (file)
@@ -1,3 +1,15 @@
+2008-11-10  Glenn Wilson  <gwilson@chromium.org>
+
+        Reviewed by Dan Bernstein.
+
+        Fixed bug http://bugs.webkit.org/show_bug.cgi?id=21953
+
+        Added layout tests to verify that characters not defined in the default font with the small-caps variant
+        won't cause a crash
+
+        * fast/css/small-caps-crash-expected.txt: Added.
+        * fast/css/small-caps-crash.html: Added.
+
 2008-11-26  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/fast/css/small-caps-crash-expected.txt b/LayoutTests/fast/css/small-caps-crash-expected.txt
new file mode 100644 (file)
index 0000000..339a00f
--- /dev/null
@@ -0,0 +1 @@
+This test verifies that using characters not found in the default font along with the small-caps font variant does not crash the browser. If successful, this test should not crash, and an odd character below: ʌ
diff --git a/LayoutTests/fast/css/small-caps-crash.html b/LayoutTests/fast/css/small-caps-crash.html
new file mode 100644 (file)
index 0000000..e59f630
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<script>
+    if(window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+</head>
+<body style="font-variant: small-caps;">
+This test verifies that using characters not found in the default font along with the small-caps font variant does
+not crash the browser.
+
+If successful, this test should not crash, and an odd character below:
+
+</body>
+</html>
index 5d16bb9..d35adc4 100644 (file)
@@ -1,3 +1,20 @@
+2008-11-10  Glenn Wilson  <gwilson@chromium.org>
+
+        Reviewed by Dan Bernstein.
+
+        Fixed bug http://bugs.webkit.org/show_bug.cgi?id=21953
+
+        This fixes the crash when the small-caps font variant is used
+        on a lower-case glyph that does not have a corresponding
+        upper-case glyph defined in the set of available fonts.
+
+        This changes Font.cpp to check if the font being used exists before trying to apply the small-caps variant.
+        
+        Test: fast/css/small-caps-crash.html
+
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::glyphDataForCharacter):
+
 2008-10-31  Tony Chang  <tony@chromium.org>
 
         Reviewed by Oliver Hunt.
index b43d9d0..62156ea 100644 (file)
@@ -239,7 +239,7 @@ const GlyphData& Font::glyphDataForCharacter(UChar32 c, bool mirror, bool forceS
         codeUnitsLength = 2;
     }
     const SimpleFontData* characterFontData = FontCache::getFontDataForCharacters(*this, codeUnits, codeUnitsLength);
-    if (useSmallCapsFont)
+    if (useSmallCapsFont && characterFontData)
         characterFontData = characterFontData->smallCapsFontData(m_fontDescription);
     if (characterFontData) {
         // Got the fallback glyph and font.