WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2008 05:39:39 +0000 (05:39 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2008 05:39:39 +0000 (05:39 +0000)
        Reviewed by Sam Weinig.

        - change the interpretation of unicode-range values in "from-to" form
          to include the "to" character.

        Test: fast/css/font-face-unicode-range.html

        * css/CSSParser.cpp:
        (WebCore::CSSParser::parseFontFaceUnicodeRange):
        * css/CSSSegmentedFontFace.cpp:
        (WebCore::CSSSegmentedFontFace::overlayRange):
        * platform/graphics/GlyphPageTreeNode.cpp:
        (WebCore::GlyphPageTreeNode::initializePage):
        * platform/graphics/SegmentedFontData.cpp:
        (WebCore::SegmentedFontData::fontDataForCharacter):
        (WebCore::SegmentedFontData::containsCharacters):

LayoutTests:

        Reviewed by Sam Weinig.

        - add a test for the unicode-range @font-face property
        - update @font-face rules in existing tests after changing unicode-range
          values in "from-to" form to include the "to" character

        * fast/css/font-face-unicode-range.html: Added.
        * fast/css/rtl-ordering.html:
        * fast/text/international/resources/Mac-compatible-font-fallback.css:
        * platform/mac-leopard/fast/css/font-face-unicode-range-expected.checksum: Added.
        * platform/mac-leopard/fast/css/font-face-unicode-range-expected.png: Added.
        * platform/mac/fast/css/font-face-unicode-range-expected.txt: Added.
        * platform/win/css2.1/resources/Mac-compatible-font-fallback.css:

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/font-face-unicode-range.html [new file with mode: 0644]
LayoutTests/fast/css/rtl-ordering.html
LayoutTests/fast/text/international/resources/Mac-compatible-font-fallback.css
LayoutTests/platform/mac-leopard/fast/css/font-face-unicode-range-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac-leopard/fast/css/font-face-unicode-range-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/font-face-unicode-range-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/css2.1/resources/Mac-compatible-font-fallback.css
WebCore/ChangeLog
WebCore/css/CSSParser.cpp
WebCore/css/CSSSegmentedFontFace.cpp
WebCore/platform/graphics/GlyphPageTreeNode.cpp
WebCore/platform/graphics/SegmentedFontData.cpp

index 97b96c2..f933b59 100644 (file)
@@ -1,3 +1,19 @@
+2008-01-30  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        - add a test for the unicode-range @font-face property
+        - update @font-face rules in existing tests after changing unicode-range
+          values in "from-to" form to include the "to" character
+
+        * fast/css/font-face-unicode-range.html: Added.
+        * fast/css/rtl-ordering.html:
+        * fast/text/international/resources/Mac-compatible-font-fallback.css:
+        * platform/mac-leopard/fast/css/font-face-unicode-range-expected.checksum: Added.
+        * platform/mac-leopard/fast/css/font-face-unicode-range-expected.png: Added.
+        * platform/mac/fast/css/font-face-unicode-range-expected.txt: Added.
+        * platform/win/css2.1/resources/Mac-compatible-font-fallback.css:
+
 2008-01-30  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/css/font-face-unicode-range.html b/LayoutTests/fast/css/font-face-unicode-range.html
new file mode 100644 (file)
index 0000000..3a65721
--- /dev/null
@@ -0,0 +1,129 @@
+<head>
+    <style>
+        div { border: 1px solid; padding: 0 8px; margin: 8px 0; }
+        span.ahem { font-family: 'Ahem'; }
+        span.courier { font-family: 'Courier'; }
+
+        @font-face {
+            font-family: 'test1';
+            src: local('Times');
+        }
+        @font-face {
+            font-family: 'test1';
+            src: url('resources/Ahem.ttf');
+            unicode-range: U+0041;
+        }
+
+        @font-face {
+            font-family: 'test2';
+            src: local('Times');
+        }
+        @font-face {
+            font-family: 'test2';
+            src: url('resources/Ahem.ttf');
+            unicode-range: U+004?;
+        }
+
+        @font-face {
+            font-family: 'test3';
+            src: local('Times');
+        }
+        @font-face {
+            font-family: 'test3';
+            src: url('resources/Ahem.ttf');
+            unicode-range: U+0042-0044;
+        }
+
+        @font-face {
+            font-family: 'test4';
+            src: local('Times');
+        }
+        @font-face {
+            font-family: 'test4';
+            src: url('resources/Ahem.ttf');
+            unicode-range: U+0050-0058;
+        }
+        @font-face {
+            font-family: 'test4';
+            src: local('Courier');
+            unicode-range: U+004F-0051;
+        }
+
+        @font-face {
+            font-family: 'test5';
+            src: local('Times');
+        }
+        @font-face {
+            font-family: 'test5';
+            src: url('resources/Ahem.ttf');
+            unicode-range: U+0050-0058;
+        }
+        @font-face {
+            font-family: 'test5';
+            src: local('Courier');
+            unicode-range: U+0052-0055;
+        }
+    </style>
+</head>
+<body onload="finished()">
+    <p>
+        Each box should contain two identical lines
+    </p>
+
+    <div>
+        <p style="font-family: 'test1';">
+            ABCDEFGHIJKLMNOPQRSTUVWXYZ
+        </p>
+        <p>
+            <span class="ahem">A</span>BCDEFGHIJKLMNOPQRSTUVWXYZ
+        </p>
+    </div>
+
+    <div>
+        <p style="font-family: 'test2';">
+            ABCDEFGHIJKLMNOPQRSTUVWXYZ
+        </p>
+        <p>
+            <span class="ahem">ABCDEFGHIJKLMNO</span>PQRSTUVWXYZ
+        </p>
+    </div>
+
+    <div>
+        <p style="font-family: 'test3';">
+            ABCDEFGHIJKLMNOPQRSTUVWXYZ
+        </p>
+        <p>
+            A<span class="ahem">BCD</span>EFGHIJKLMNOPQRSTUVWXYZ
+        </p>
+    </div>
+
+    <div>
+        <p style="font-family: 'test4';">
+            ABCDEFGHIJKLMNOPQRSTUVWXYZ
+        </p>
+        <p>
+            ABCDEFGHIJKLMN<span class="courier">OPQ</span><span class="ahem">RSTUVWX</span>YZ
+        </p>
+    </div>
+
+    <div>
+        <p style="font-family: 'test5';">
+            ABCDEFGHIJKLMNOPQRSTUVWXYZ
+        </p>
+        <p>
+            ABCDEFGHIJKLMNO<span class="ahem">PQ<span class="courier">RSTU</span>VWX</span>YZ
+        </p>
+    </div>
+    <script>
+        function finished()
+        {
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+
+        document.body.offsetTop;
+
+        if (window.layoutTestController)
+            layoutTestController.waitUntilDone();
+    </script>
+</body>
index 85f35d2..5ab1e59 100644 (file)
@@ -14,7 +14,7 @@
     font-family: 'times';
     src: local('Lucida Grande');
     /* Hebrew */
-    unicode-range: U+0590-0600;
+    unicode-range: U+0590-05FF;
 }
 </style>
 </head>
index c0ea428..ed7689f 100644 (file)
@@ -3,5 +3,5 @@
 @font-face {
     font-family: 'times';
     src: local('Lucida Grande');
-    unicode-range: U+0590-0600;
+    unicode-range: U+0590-05FF;
 }
diff --git a/LayoutTests/platform/mac-leopard/fast/css/font-face-unicode-range-expected.checksum b/LayoutTests/platform/mac-leopard/fast/css/font-face-unicode-range-expected.checksum
new file mode 100644 (file)
index 0000000..4789d11
--- /dev/null
@@ -0,0 +1 @@
+3313b7a12ad2033b06682453531d627a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac-leopard/fast/css/font-face-unicode-range-expected.png b/LayoutTests/platform/mac-leopard/fast/css/font-face-unicode-range-expected.png
new file mode 100644 (file)
index 0000000..c450e66
Binary files /dev/null and b/LayoutTests/platform/mac-leopard/fast/css/font-face-unicode-range-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/font-face-unicode-range-expected.txt b/LayoutTests/platform/mac/fast/css/font-face-unicode-range-expected.txt
new file mode 100644 (file)
index 0000000..bafc45c
--- /dev/null
@@ -0,0 +1,72 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 274x18
+          text run at (0,0) width 274: "Each box should contain two identical lines"
+      RenderBlock {DIV} at (0,34) size 784x86 [border: (1px solid #000000)]
+        RenderBlock {P} at (9,17) size 766x18
+          RenderText {#text} at (0,0) size 288x18
+            text run at (0,0) width 288: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+        RenderBlock {P} at (9,51) size 766x18
+          RenderInline {SPAN} at (0,0) size 16x16
+            RenderText {#text} at (0,1) size 16x16
+              text run at (0,1) width 16: "A"
+          RenderText {#text} at (16,0) size 272x18
+            text run at (16,0) width 272: "BCDEFGHIJKLMNOPQRSTUVWXYZ"
+      RenderBlock {DIV} at (0,128) size 784x86 [border: (1px solid #000000)]
+        RenderBlock {P} at (9,17) size 766x18
+          RenderText {#text} at (0,0) size 364x18
+            text run at (0,0) width 364: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+        RenderBlock {P} at (9,51) size 766x18
+          RenderInline {SPAN} at (0,0) size 240x16
+            RenderText {#text} at (0,1) size 240x16
+              text run at (0,1) width 240: "ABCDEFGHIJKLMNO"
+          RenderText {#text} at (240,0) size 124x18
+            text run at (240,0) width 124: "PQRSTUVWXYZ"
+      RenderBlock {DIV} at (0,222) size 784x86 [border: (1px solid #000000)]
+        RenderBlock {P} at (9,17) size 766x18
+          RenderText {#text} at (0,0) size 298x18
+            text run at (0,0) width 298: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+        RenderBlock {P} at (9,51) size 766x18
+          RenderText {#text} at (0,0) size 12x18
+            text run at (0,0) width 12: "A"
+          RenderInline {SPAN} at (0,0) size 48x16
+            RenderText {#text} at (12,1) size 48x16
+              text run at (12,1) width 48: "BCD"
+          RenderText {#text} at (60,0) size 238x18
+            text run at (60,0) width 238: "EFGHIJKLMNOPQRSTUVWXYZ"
+      RenderBlock {DIV} at (0,316) size 784x86 [border: (1px solid #000000)]
+        RenderBlock {P} at (9,17) size 766x18
+          RenderText {#text} at (0,0) size 312x18
+            text run at (0,0) width 312: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+        RenderBlock {P} at (9,51) size 766x18
+          RenderText {#text} at (0,0) size 148x18
+            text run at (0,0) width 148: "ABCDEFGHIJKLMN"
+          RenderInline {SPAN} at (0,0) size 30x18
+            RenderText {#text} at (148,0) size 30x18
+              text run at (148,0) width 30: "OPQ"
+          RenderInline {SPAN} at (0,0) size 112x16
+            RenderText {#text} at (178,1) size 112x16
+              text run at (178,1) width 112: "RSTUVWX"
+          RenderText {#text} at (290,0) size 22x18
+            text run at (290,0) width 22: "YZ"
+      RenderBlock {DIV} at (0,410) size 784x86 [border: (1px solid #000000)]
+        RenderBlock {P} at (9,17) size 766x18
+          RenderText {#text} at (0,0) size 302x18
+            text run at (0,0) width 302: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+        RenderBlock {P} at (9,51) size 766x18
+          RenderText {#text} at (0,0) size 160x18
+            text run at (0,0) width 160: "ABCDEFGHIJKLMNO"
+          RenderInline {SPAN} at (0,0) size 120x16
+            RenderText {#text} at (160,1) size 32x16
+              text run at (160,1) width 32: "PQ"
+            RenderInline {SPAN} at (0,0) size 40x18
+              RenderText {#text} at (192,0) size 40x18
+                text run at (192,0) width 40: "RSTU"
+            RenderText {#text} at (232,1) size 48x16
+              text run at (232,1) width 48: "VWX"
+          RenderText {#text} at (280,0) size 22x18
+            text run at (280,0) width 22: "YZ"
index b602b5c..3cd7f3e 100644 (file)
@@ -11,7 +11,7 @@
 @font-face {
     font-family: 'times' '-webkit-serif';
     src: local('WebKit Layout Tests');
-    unicode-range: U+21E6-21EA U+25FE U+262F U+2798-279B;
+    unicode-range: U+21E6-21E9 U+25FE U+262F U+2798-279A;
 }
 
 /* Hebrew, hyphen, non-breaking hyphen, upwards white arrow,
@@ -20,6 +20,6 @@
 @font-face {
     font-family: 'times';
     src: local('Lucida Grande');
-    unicode-range: U+0590-0600 U+2010-2011 U+21E7 U+25A0 U+25E6 U+FFFD;
+    unicode-range: U+0590-05FF U+2010-2011 U+21E7 U+25A0 U+25E6 U+FFFD;
 }
 
index 3304fda..1217b75 100644 (file)
@@ -1,5 +1,24 @@
 2008-01-30  Dan Bernstein  <mitz@apple.com>
 
+        Reviewed by Sam Weinig.
+
+        - change the interpretation of unicode-range values in "from-to" form
+          to include the "to" character.
+
+        Test: fast/css/font-face-unicode-range.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseFontFaceUnicodeRange):
+        * css/CSSSegmentedFontFace.cpp:
+        (WebCore::CSSSegmentedFontFace::overlayRange):
+        * platform/graphics/GlyphPageTreeNode.cpp:
+        (WebCore::GlyphPageTreeNode::initializePage):
+        * platform/graphics/SegmentedFontData.cpp:
+        (WebCore::SegmentedFontData::fontDataForCharacter):
+        (WebCore::SegmentedFontData::containsCharacters):
+
+2008-01-30  Dan Bernstein  <mitz@apple.com>
+
         Reviewed by Darin Adler.
 
         - prune references to custom fonts' SimpleFontData from the glyph page
index 9335063..f3b5baa 100644 (file)
@@ -2862,7 +2862,7 @@ bool CSSParser::parseFontFaceUnicodeRange()
             break;
 
         if (i == length)
-            to = from + 1;
+            to = from;
         else if (rangeString[i] == '?') {
             unsigned span = 1;
             while (i < length && rangeString[i] == '?') {
@@ -2872,7 +2872,7 @@ bool CSSParser::parseFontFaceUnicodeRange()
             }
             if (i < length)
                 failed = true;
-            to = from + span;
+            to = from + span - 1;
         } else {
             if (length < i + 2) {
                 failed = true;
index 05c0c79..0e7fbfb 100644 (file)
@@ -94,14 +94,14 @@ void CSSSegmentedFontFace::overlayRange(UChar32 from, UChar32 to, PassRefPtr<CSS
         m_ranges.clear();
         for (unsigned i = 0; i < size; i++) {
             const FontFaceRange& range = oldRanges[i];
-            if (range.from() >= to || range.to() <= from)
+            if (range.from() > to || range.to() < from)
                 m_ranges.append(range);
             else if (range.from() < from) {
-                m_ranges.append(FontFaceRange(range.from(), from, range.fontFace()));
+                m_ranges.append(FontFaceRange(range.from(), from - 1, range.fontFace()));
                 if (range.to() > to)
-                    m_ranges.append(FontFaceRange(to, range.to(), range.fontFace()));
+                    m_ranges.append(FontFaceRange(to + 1, range.to(), range.fontFace()));
             } else if (range.to() > to)
-                m_ranges.append(FontFaceRange(to, range.to(), range.fontFace()));
+                m_ranges.append(FontFaceRange(to + 1, range.to(), range.fontFace()));
         }
     }
     m_ranges.append(FontFaceRange(from, to, fontFace));
index 307fcde..53c94b8 100644 (file)
@@ -163,7 +163,7 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
                 for (unsigned i = 0; i < numRanges; i++) {
                     const FontDataRange& range = segmentedFontData->rangeAt(i);
                     int from = max(0, range.from() - static_cast<int>(start));
-                    int to = min(range.to() - static_cast<int>(start), static_cast<int>(GlyphPage::size));
+                    int to = 1 + min(range.to() - static_cast<int>(start), static_cast<int>(GlyphPage::size) - 1);
                     if (from < static_cast<int>(GlyphPage::size) && to > 0) {
                         if (!zeroFilled) {
                             if (from > 0 || to < static_cast<int>(GlyphPage::size)) {
index 8c8d97f..ceefe4f 100644 (file)
@@ -39,7 +39,7 @@ const SimpleFontData* SegmentedFontData::fontDataForCharacter(UChar32 c) const
 {
     Vector<FontDataRange>::const_iterator end = m_ranges.end();
     for (Vector<FontDataRange>::const_iterator it = m_ranges.begin(); it != end; ++it) {
-        if (it->from() <= c && it->to() > c)
+        if (it->from() <= c && it->to() >= c)
             return it->fontData();
     }
     return m_ranges[0].fontData();
@@ -49,7 +49,7 @@ bool SegmentedFontData::containsCharacters(const UChar* characters, int length)
 {
     Vector<FontDataRange>::const_iterator end = m_ranges.end();
     for (Vector<FontDataRange>::const_iterator it = m_ranges.begin(); it != end; ++it) {
-        if (it->from() <= characters[0] && it->to() > characters[0])
+        if (it->from() <= characters[0] && it->to() >= characters[0])
             return true;
     }
     return false;