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
bug-159607-20160709212352.patch (text/plain), 10.64 KB, created by
Myles C. Maxfield
on 2016-07-09 21:24:31 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2016-07-09 21:24:31 PDT
Size:
10.64 KB
patch
obsolete
>Subversion Revision: 203018 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1094e74b0c444ba4820aa2a3ae60371ddf51fe2a..da221cde3a32ebaca72c1fb10135ed9ffbee73fa 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,24 @@ >+2016-07-09 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 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-08 Chris Dumez <cdumez@apple.com> > > adoptNode() changes css class to lowercase for document loaded with XHR responseType = "document" >diff --git a/Source/WebCore/css/CSSFontFace.cpp b/Source/WebCore/css/CSSFontFace.cpp >index 6e0aba6ad02cc2e8a7a5a783ed40a3bcedcdb705..824687515544d087e1c7e391ad1c91188d9ddc53 100644 >--- a/Source/WebCore/css/CSSFontFace.cpp >+++ b/Source/WebCore/css/CSSFontFace.cpp >@@ -370,6 +370,15 @@ void CSSFontFace::setFeatureSettings(CSSValue& featureSettings) > }); > } > >+bool CSSFontFace::rangesMatchCodePoint(UChar32 character) const >+{ >+ 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 7dc5ebd52afbe262ebc0835751a42fdc31698847..68dc7a1287ab676e47dcfe3dd142671009001e36 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2016-07-09 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 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/text/unicode-range-javascript-expected.txt: Added. >+ * fast/text/unicode-range-javascript.html: Added. >+ > 2016-07-08 Chris Dumez <cdumez@apple.com> > > adoptNode() changes css class to lowercase for document loaded with XHR responseType = "document" >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:
zalan
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 159607
: 283279 |
283345
|
283346
|
283350
|
283353
|
283354