WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for committing
bug-159607-20160711143827.patch (text/plain), 14.03 KB, created by
Myles C. Maxfield
on 2016-07-11 14:39:09 PDT
(
hide
)
Description:
Patch for committing
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2016-07-11 14:39:09 PDT
Size:
14.03 KB
patch
obsolete
>Subversion Revision: 203078 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9dbe36c09e7bae2cbfd91a42b613b827b0f88daa..7471f70b24e768960dd076291decc89c91af5285 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2016-07-11 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ Honor the second argument to FontFaceSet.load and FontFaceSet.check >+ https://bugs.webkit.org/show_bug.cgi?id=159607 >+ <rdar://problem/27284902> >+ >+ Reviewed by Zalan Bujtas. >+ >+ This second argument is used in conjunction with the unicode-range CSS property, so that >+ loading from a FontFaceSet only loads the fonts which actually match the characters given. >+ Previously, we hadn't implemented proper support for this unicode-range property, but now >+ that we have implemented it, we should honor this second argument. >+ >+ Test: fast/text/unicode-range-javascript.html >+ >+ * css/CSSFontFace.cpp: >+ (WebCore::CSSFontFace::rangesMatchCodePoint): >+ * css/CSSFontFace.h: >+ * css/CSSFontFaceSet.cpp: >+ (WebCore::codePointsFromString): >+ (WebCore::CSSFontFaceSet::matchingFaces): >+ > 2016-07-11 Brent Fulgham <bfulgham@apple.com> > > [WebGL] Check for existing buffer exists for enabled vertex array attributes before permitting glDrawArrays to execute >diff --git a/Source/WebCore/css/CSSFontFace.cpp b/Source/WebCore/css/CSSFontFace.cpp >index 6e0aba6ad02cc2e8a7a5a783ed40a3bcedcdb705..5182af7b27a137f446630d7a468d4083c1e8018f 100644 >--- a/Source/WebCore/css/CSSFontFace.cpp >+++ b/Source/WebCore/css/CSSFontFace.cpp >@@ -370,6 +370,18 @@ void CSSFontFace::setFeatureSettings(CSSValue& featureSettings) > }); > } > >+bool CSSFontFace::rangesMatchCodePoint(UChar32 character) const >+{ >+ if (m_ranges.isEmpty()) >+ return true; >+ >+ for (auto& range : m_ranges) { >+ if (range.from <= character && character <= range.to) >+ return true; >+ } >+ return false; >+} >+ > void CSSFontFace::fontLoadEventOccurred() > { > Ref<CSSFontFace> protectedThis(*this); >diff --git a/Source/WebCore/css/CSSFontFace.h b/Source/WebCore/css/CSSFontFace.h >index a2b0c97af1034c9937747fa3c6cf1b835902d3e0..2e1003a9cfd44fdcd2007258e497fc02b7994b4e 100644 >--- a/Source/WebCore/css/CSSFontFace.h >+++ b/Source/WebCore/css/CSSFontFace.h >@@ -133,6 +133,8 @@ public: > UChar32 to; > }; > >+ bool rangesMatchCodePoint(UChar32) const; >+ > // We don't guarantee that the FontFace wrapper will be the same every time you ask for it. > Ref<FontFace> wrapper(); > void setWrapper(FontFace&); >diff --git a/Source/WebCore/css/CSSFontFaceSet.cpp b/Source/WebCore/css/CSSFontFaceSet.cpp >index 10e623afc60b64dd7667d4107b4b0459e0671886..1bb634454633823710fe443829d45957f6195381 100644 >--- a/Source/WebCore/css/CSSFontFaceSet.cpp >+++ b/Source/WebCore/css/CSSFontFaceSet.cpp >@@ -308,7 +308,23 @@ static Optional<FontTraitsMask> computeFontTraitsMask(MutableStyleProperties& st > return static_cast<FontTraitsMask>(static_cast<unsigned>(styleMask) | static_cast<unsigned>(weightMask)); > } > >-Vector<std::reference_wrapper<CSSFontFace>> CSSFontFaceSet::matchingFaces(const String& font, const String&, ExceptionCode& ec) >+static HashSet<UChar32> codePointsFromString(StringView stringView) >+{ >+ HashSet<UChar32> result; >+ auto graphemeClusters = stringView.graphemeClusters(); >+ for (auto cluster : graphemeClusters) { >+ ASSERT(cluster.length() > 0); >+ UChar32 character = 0; >+ if (cluster.is8Bit()) >+ character = cluster[0]; >+ else >+ U16_GET(cluster.characters16(), 0, 0, cluster.length(), character); >+ result.add(character); >+ } >+ return result; >+} >+ >+Vector<std::reference_wrapper<CSSFontFace>> CSSFontFaceSet::matchingFaces(const String& font, const String& string, ExceptionCode& ec) > { > Vector<std::reference_wrapper<CSSFontFace>> result; > auto style = MutableStyleProperties::create(); >@@ -334,21 +350,37 @@ Vector<std::reference_wrapper<CSSFontFace>> CSSFontFaceSet::matchingFaces(const > CSSValueList& familyList = downcast<CSSValueList>(*family); > > HashSet<AtomicString> uniqueFamilies; >+ Vector<AtomicString> familyOrder; > for (auto& family : familyList) { > const CSSPrimitiveValue& primitive = downcast<CSSPrimitiveValue>(family.get()); > if (!primitive.isFontFamily()) > continue; >- uniqueFamilies.add(primitive.fontFamily().familyName); >+ if (uniqueFamilies.add(primitive.fontFamily().familyName).isNewEntry) >+ familyOrder.append(primitive.fontFamily().familyName); > } > >- for (auto& family : uniqueFamilies) { >- CSSSegmentedFontFace* faces = getFontFace(fontTraitsMask, family); >- if (!faces) >- continue; >- for (auto& constituentFace : faces->constituentFaces()) >- result.append(constituentFace.get()); >+ HashSet<CSSFontFace*> resultConstituents; >+ for (auto codePoint : codePointsFromString(string)) { >+ bool found = false; >+ for (auto& family : familyOrder) { >+ CSSSegmentedFontFace* faces = getFontFace(fontTraitsMask, family); >+ if (!faces) >+ continue; >+ for (auto& constituentFace : faces->constituentFaces()) { >+ if (constituentFace->rangesMatchCodePoint(codePoint)) { >+ resultConstituents.add(constituentFace.ptr()); >+ found = true; >+ break; >+ } >+ } >+ if (found) >+ break; >+ } > } > >+ for (auto* constituent : resultConstituents) >+ result.append(*constituent); >+ > return result; > } > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index d02284fa39c12b90ac670f4429170da41a2f85e2..d9857f3bb63e72d6a345cb263c772ec9ed72f93b 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,18 @@ >+2016-07-11 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ Honor the second argument to FontFaceSet.load and FontFaceSet.check >+ https://bugs.webkit.org/show_bug.cgi?id=159607 >+ <rdar://problem/27284902> >+ >+ Reviewed by Zalan Bujtas. >+ >+ * fast/text/font-face-set-document-expected.txt: >+ * fast/text/font-face-set-document.html: >+ * fast/text/font-face-set-javascript-expected.txt: >+ * fast/text/font-face-set-javascript.html: >+ * fast/text/unicode-range-javascript-expected.txt: Added. >+ * fast/text/unicode-range-javascript.html: Added. >+ > 2016-07-11 Brent Fulgham <bfulgham@apple.com> > > [WebGL] Check for existing buffer exists for enabled vertex array attributes before permitting glDrawArrays to execute >diff --git a/LayoutTests/fast/text/font-face-set-document-expected.txt b/LayoutTests/fast/text/font-face-set-document-expected.txt >index 8244e0dec13919849629b58c20d07c1302339358..402a99cad670e1c3c23d7f86fc9cfc3724f5a9fd 100644 >--- a/LayoutTests/fast/text/font-face-set-document-expected.txt >+++ b/LayoutTests/fast/text/font-face-set-document-expected.txt >@@ -12,9 +12,8 @@ PASS object.value.family is "MyFont2" > PASS object.done is true > PASS document.getElementById("testElement").offsetWidth is not originalWidth > PASS document.getElementById("testElement").offsetWidth is originalWidth >-PASS object.length is 2 >+PASS object.length is 1 > PASS object[0].family is "MyFont3" >-PASS object[1].family is "MyFont3" > PASS document.getElementById("testElement").offsetWidth is not originalWidth > PASS document.getElementById("testElement").offsetWidth is originalWidth > PASS successfullyParsed is true >diff --git a/LayoutTests/fast/text/font-face-set-document.html b/LayoutTests/fast/text/font-face-set-document.html >index f7453d3f4af571cea696002fbd984109afa9dbe2..c7d42784f00471df748c3586bca8a35869c0cc9d 100644 >--- a/LayoutTests/fast/text/font-face-set-document.html >+++ b/LayoutTests/fast/text/font-face-set-document.html >@@ -76,9 +76,8 @@ function startLoading() { > return document.fonts.load("50px MyFont3"); > }).then(function(x) { > object = x; >- shouldBe("object.length", "2"); >+ shouldBe("object.length", "1"); > shouldBeEqualToString("object[0].family", "MyFont3"); >- shouldBeEqualToString("object[1].family", "MyFont3"); > object = undefined; > appliedFont = new FontFace("AppliedFont", "url(\"../../resources/Ahem.otf\")", {}); > document.fonts.add(appliedFont); >diff --git a/LayoutTests/fast/text/font-face-set-javascript-expected.txt b/LayoutTests/fast/text/font-face-set-javascript-expected.txt >index 99eb12575dafe8bfd572b66e60c18e1cb7a760ec..5b2b12ec09695073258327de0a14cf66d082a08f 100644 >--- a/LayoutTests/fast/text/font-face-set-javascript-expected.txt >+++ b/LayoutTests/fast/text/font-face-set-javascript-expected.txt >@@ -45,7 +45,7 @@ PASS fontFaceSet.check('16px family3') is true > PASS fontFaceSet.status is "loaded" > PASS fontFaceSet.status is "loaded" > PASS item is [fontFace3] >-PASS item is [fontFace3, fontFace4] >+PASS item is [fontFace3] > PASS item is fontFaceSet > PASS fontFaceSet.status is "loaded" > PASS fontFaceSet.status is "loading" >diff --git a/LayoutTests/fast/text/font-face-set-javascript.html b/LayoutTests/fast/text/font-face-set-javascript.html >index 4e64517a281dfaaa97a701c1fb36310e57fdc662..f0ffdc41105e6fd73148df3ebfede7cc1f0ea47f 100644 >--- a/LayoutTests/fast/text/font-face-set-javascript.html >+++ b/LayoutTests/fast/text/font-face-set-javascript.html >@@ -126,7 +126,7 @@ fontFaceSet.load("garbage").then(function(arg) { > finishJSTest(); > }).then(function(arg) { > item = arg; >- shouldBe("item", "[fontFace3, fontFace4]"); >+ shouldBe("item", "[fontFace3]"); > fontFaceSet.add(fontFace4); > fontFaceSet.load("16px family3"); > return fontFaceSet.ready; >diff --git a/LayoutTests/fast/text/unicode-range-javascript-expected.txt b/LayoutTests/fast/text/unicode-range-javascript-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..86d2112b1bfca2ab0523a97a59f9c5f11a582920 >--- /dev/null >+++ b/LayoutTests/fast/text/unicode-range-javascript-expected.txt >@@ -0,0 +1,29 @@ >+js-test-post.js - willSendRequest <NSURLRequest URL js-test-post.js, main document URL unicode-range-javascript.html, http method GET> redirectResponse (null) >+js-test-pre.js - didFinishLoading >+js-test-post.js - didReceiveResponse <NSURLResponse js-test-post.js, http status code 0> >+js-test-post.js - didFinishLoading >+Ahem.otf - willSendRequest <NSURLRequest URL Ahem.otf, main document URL unicode-range-javascript.html, http method GET> redirectResponse (null) >+js-test-post.js - didReceiveResponse <NSURLResponse js-test-post.js, http status code 0> >+js-test-post.js - didFinishLoading >+Ahem.otf - didReceiveResponse <NSURLResponse Ahem.otf, http status code 0> >+Ahem.otf - didFinishLoading >+Ahem.woff - willSendRequest <NSURLRequest URL Ahem.woff, main document URL unicode-range-javascript.html, http method GET> redirectResponse (null) >+Ahem.woff - didReceiveResponse <NSURLResponse Ahem.woff, http status code 0> >+Ahem.woff - didFinishLoading >+This test makes sure that the second argument to FontFaceSet.load() and FontFaceSet.check() is honored. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS faces.length is 1 >+PASS faces[0].unicodeRange is "U+41-41" >+PASS document.fonts.check('14px WebFont', 'A') is true >+PASS faces.length is 1 >+PASS faces[0].family is "WebFont" >+PASS faces[0].unicodeRange is "U+41-41" >+PASS document.fonts.check('14px WebFont3', 'A') is false >+PASS document.fonts.check('14px WebFont3', 'A') is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/text/unicode-range-javascript.html b/LayoutTests/fast/text/unicode-range-javascript.html >new file mode 100644 >index 0000000000000000000000000000000000000000..0707bf0d32909b27a95283bb7f86ed1f29a1a01e >--- /dev/null >+++ b/LayoutTests/fast/text/unicode-range-javascript.html >@@ -0,0 +1,80 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../resources/js-test-pre.js"></script> >+<script> >+if (window.testRunner) { >+ testRunner.dumpResourceLoadCallbacks(); >+ testRunner.dumpAsText(); >+} >+if (window.internals) { >+ internals.clearMemoryCache(); >+ internals.invalidateFontCache(); >+} >+</script> >+<style> >+@font-face { >+ font-family: WebFont; >+ src: url("../../resources/Ahem.ttf") format("truetype"); >+ unicode-range: U+42; >+} >+@font-face { >+ font-family: WebFont; >+ src: url("../../resources/Ahem.otf") format("opentype"); >+ unicode-range: U+41; >+} >+@font-face { >+ font-family: WebFont2; >+ src: url("../../resources/Ahem.otf") format("opentype"); >+ unicode-range: U+41-42; >+} >+@font-face { >+ font-family: WebFont3; >+ src: url("notafont.ttf") format("truetype"); >+ unicode-range: U+42; >+} >+@font-face { >+ font-family: WebFont3; >+ src: url("../../resources/Ahem.woff") format("woff"); >+ unicode-range: U+41; >+} >+</style> >+</head> >+<body> >+<script> >+self.jsTestIsAsync = true; >+ >+description("This test makes sure that the second argument to FontFaceSet.load() and FontFaceSet.check() is honored."); >+ >+function failure() { >+ testFailed("Promise should not fail."); >+ finishJSTest(); >+} >+ >+var faces; >+document.fonts.load("14px WebFont", "A").then(function(facesArgument) { >+ faces = facesArgument; >+ shouldBe("faces.length", "1"); >+ shouldBeEqualToString("faces[0].unicodeRange", "U+41-41"); >+ shouldBeTrue("document.fonts.check('14px WebFont', 'A')"); >+ return document.fonts.load("14px WebFont, WebFont2", "A"); >+}, failure).then(function(facesArgument) { >+ faces = facesArgument; >+ shouldBe("faces.length", "1"); >+ shouldBeEqualToString("faces[0].family", "WebFont"); >+ shouldBeEqualToString("faces[0].unicodeRange", "U+41-41"); >+ shouldBeFalse("document.fonts.check('14px WebFont3', 'A')"); >+ for (let f of document.fonts) { >+ if (f.family == "WebFont3" && f.unicodeRange == "U+41-41") >+ return f.load(); >+ } >+ testFailed("Should find font."); >+ finishJSTest(); >+}, failure).then(function(face) { >+ shouldBeTrue("document.fonts.check('14px WebFont3', 'A')"); >+ finishJSTest(); >+}, failure); >+</script> >+<script src="../../resources/js-test-post.js"></script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
buildbot
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 159607
:
283279
|
283345
| 283346 |
283350
|
283353
|
283354