Skip to content
Permalink
Browse files
2010-07-15 Yuzo Fujishima <yuzo@google.com>
        Reviewed by Dan Bernstein.

        Fix for Bug 42342 - Font download error for an @font-face rule invalidates other @font-face rules for the same font-family
        https://bugs.webkit.org/show_bug.cgi?id=42342

        * fast/css/font-face-download-error-expected.txt: Added.
        * fast/css/font-face-download-error.html: Added.
2010-07-15  Yuzo Fujishima  <yuzo@google.com>

        Reviewed by Dan Bernstein.

        Fix for Bug 42342 - Font download error for an @font-face rule invalidates other @font-face rules for the same font-family
        https://bugs.webkit.org/show_bug.cgi?id=42342

        Test: fast/css/font-face-download-error.html

        * css/CSSSegmentedFontFace.cpp:
        (WebCore::CSSSegmentedFontFace::isValid): Valid if at least one font
        face is valid.
        (WebCore::CSSSegmentedFontFace::getFontData): Check validity for each
        font face.
        * css/CSSSegmentedFontFace.h: Make isValid private.

Canonical link: https://commits.webkit.org/54557@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Yuzo Fujishima committed Jul 20, 2010
1 parent a11395f commit ad3e36b25412b895213475d53489788dc690b8e1
@@ -1,3 +1,13 @@
2010-07-15 Yuzo Fujishima <yuzo@google.com>

Reviewed by Dan Bernstein.

Fix for Bug 42342 - Font download error for an @font-face rule invalidates other @font-face rules for the same font-family
https://bugs.webkit.org/show_bug.cgi?id=42342

* fast/css/font-face-download-error-expected.txt: Added.
* fast/css/font-face-download-error.html: Added.

2010-07-19 Anders Carlsson <andersca@apple.com>

Reviewed by Maciej Stachowiak.
@@ -0,0 +1,36 @@
If no font resources are available for an @font-face rule due to download errors, the rule must be ignored but others must remain in effect.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

iiiiiiiiii test_0_0
iiiiiiiiii ref_0_0
jjjjjjjjjj test_0_1
jjjjjjjjjj ref_0_1

iiiiiiiiii test_1_0
iiiiiiiiii ref_1_0
jjjjjjjjjj test_1_1
jjjjjjjjjj ref_1_1

iiiiiiiiii test_2_0
iiiiiiiiii ref_2_0
jjjjjjjjjj test_2_1
jjjjjjjjjj ref_2_1

iiiiiiiiii test_3_0
iiiiiiiiii ref_3_0
jjjjjjjjjj test_3_1
jjjjjjjjjj ref_3_1

PASS successfullyParsed is true

TEST COMPLETE
PASS document.getElementById('test_0_0').offsetWidth is document.getElementById('ref_0_0').offsetWidth
PASS document.getElementById('test_0_1').offsetWidth is document.getElementById('ref_0_1').offsetWidth
PASS document.getElementById('test_1_0').offsetWidth is document.getElementById('ref_1_0').offsetWidth
PASS document.getElementById('test_1_1').offsetWidth is document.getElementById('ref_1_1').offsetWidth
PASS document.getElementById('test_2_0').offsetWidth is document.getElementById('ref_2_0').offsetWidth
PASS document.getElementById('test_2_1').offsetWidth is document.getElementById('ref_2_1').offsetWidth
PASS document.getElementById('test_3_0').offsetWidth is document.getElementById('ref_3_0').offsetWidth
PASS document.getElementById('test_3_1').offsetWidth is document.getElementById('ref_3_1').offsetWidth

@@ -0,0 +1,136 @@
<!doctype html>
<html>
<head>
<title>Test for Bug 42342 - Font download error for an @font-face rule invalidates other @font-face rules for the same font-family</title>
<style>
.test {
font-family: Times;
border: solid 1px;
}

/* Test 0: Download sucess */
@font-face {
font-family:myfont_0;
src: local('Courier');
}
@font-face {
font-family:myfont_0;
src: url('resources/Ahem.otf');
unicode-range: u+69; /* 'i' */
}

/* Test 1: Download error */
@font-face {
font-family:myfont_1;
src: local('Courier');
}
@font-face {
font-family:myfont_1;
src: url('resources/DownLoadErrorAhem.otf');
unicode-range: u+69; /* 'i' */
}

/* Test 2: Download error followed by success */
@font-face {
font-family:myfont_2;
src: local('Courier');
}
@font-face {
font-family:myfont_2;
src: url('resources/DownLoadErrorAhem.otf'), url('resources/Ahem.otf');
unicode-range: u+69; /* 'i' */
}

/* Test 3: Download error followed by existing local font */
@font-face {
font-family:myfont_3;
src: local('Courier');
}
@font-face {
font-family:myfont_3;
src: url('resources/DownLoadErrorAhem.otf'), local(Arial);
unicode-range: u+69; /* 'i' */
}

</style>
<link rel="stylesheet" href="../js/resources/js-test-style.css"/>
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="tests"></div>

<div id="console"></div>
<div id="out"></div>
<script>
if (window.layoutTestController)
window.layoutTestController.waitUntilDone();

description("If no font resources are available for an @font-face rule due to download errors, the rule must be ignored but others must remain in effect.");

var testsElement = document.getElementById("tests");
var testStrings = [
"iiiiiiiiii",
"jjjjjjjjjj"
];
var expectedResults = [
// Effective font family for "i" and "j"
["Ahem", "Courier"],
["Courier", "Courier"],
["Ahem", "Courier"],
["Arial", "Courier"]
];

function createAndAppendSpan(id, subId, fontFamily)
{
var span = document.createElement("span");
span.id = id;
span.className = "test";
span.style.fontFamily = fontFamily;
span.innerHTML = testStrings[subId];
testsElement.appendChild(span);
testsElement.appendChild(document.createTextNode(" " + id));
testsElement.appendChild(document.createElement("br"));
}

function testId(mainTestId, subTestId)
{
return "test_" + mainTestId + "_" + subTestId;
}

function refId(mainTestId, subTestId)
{
return "ref_" + mainTestId + "_" + subTestId;
}

function test()
{
for (var mainTestId = 0; mainTestId < expectedResults.length; mainTestId++) {
for (var subTestId = 0; subTestId < testStrings.length; subTestId++) {
shouldBe("document.getElementById('" + testId(mainTestId, subTestId) + "').offsetWidth", "document.getElementById('" + refId(mainTestId, subTestId) + "').offsetWidth");
}
}
if (window.layoutTestController)
window.layoutTestController.notifyDone();
}

for (var mainTestId = 0; mainTestId < expectedResults.length; mainTestId++) {
for (var subTestId = 0; subTestId < testStrings.length; subTestId++) {
var testFontFamily = "myfont_" + mainTestId;
createAndAppendSpan(testId(mainTestId, subTestId), subTestId, testFontFamily);
var refFontFamily = expectedResults[mainTestId][subTestId];
createAndAppendSpan(refId(mainTestId, subTestId), subTestId, refFontFamily);
}
testsElement.appendChild(document.createElement("br"));
}

// We need to run tests after the font downloading succeeded or failed.
// Using a timer is not ideal, but there seems to be no better options.
window.setTimeout(test, 100);

var successfullyParsed = true;
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>

@@ -1,3 +1,19 @@
2010-07-15 Yuzo Fujishima <yuzo@google.com>

Reviewed by Dan Bernstein.

Fix for Bug 42342 - Font download error for an @font-face rule invalidates other @font-face rules for the same font-family
https://bugs.webkit.org/show_bug.cgi?id=42342

Test: fast/css/font-face-download-error.html

* css/CSSSegmentedFontFace.cpp:
(WebCore::CSSSegmentedFontFace::isValid): Valid if at least one font
face is valid.
(WebCore::CSSSegmentedFontFace::getFontData): Check validity for each
font face.
* css/CSSSegmentedFontFace.h: Make isValid private.

2010-07-19 Kent Tamura <tkent@chromium.org>

Reviewed by Shinichiro Hamaji.
@@ -61,12 +61,13 @@ void CSSSegmentedFontFace::pruneTable()

bool CSSSegmentedFontFace::isValid() const
{
// Valid if at least one font face is valid.
unsigned size = m_fontFaces.size();
for (unsigned i = 0; i < size; i++) {
if (!m_fontFaces[i]->isValid())
return false;
if (m_fontFaces[i]->isValid())
return true;
}
return true;
return false;
}

void CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
@@ -97,6 +98,8 @@ FontData* CSSSegmentedFontFace::getFontData(const FontDescription& fontDescripti

unsigned size = m_fontFaces.size();
for (unsigned i = 0; i < size; i++) {
if (!m_fontFaces[i]->isValid())
continue;
FontTraitsMask traitsMask = m_fontFaces[i]->traitsMask();
bool syntheticBold = !(traitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTraitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask));
bool syntheticItalic = !(traitsMask & FontStyleItalicMask) && (desiredTraitsMask & FontStyleItalicMask);
@@ -45,7 +45,6 @@ class CSSSegmentedFontFace : public RefCounted<CSSSegmentedFontFace> {
static PassRefPtr<CSSSegmentedFontFace> create(CSSFontSelector* selector) { return adoptRef(new CSSSegmentedFontFace(selector)); }
~CSSSegmentedFontFace();

bool isValid() const;
CSSFontSelector* fontSelector() const { return m_fontSelector; }

void fontLoaded(CSSFontFace*);
@@ -58,6 +57,7 @@ class CSSSegmentedFontFace : public RefCounted<CSSSegmentedFontFace> {
CSSSegmentedFontFace(CSSFontSelector*);

void pruneTable();
bool isValid() const;

CSSFontSelector* m_fontSelector;
HashMap<unsigned, SegmentedFontData*> m_fontDataTable;

0 comments on commit ad3e36b

Please sign in to comment.