haikuwebkit/LayoutTests/fast/css-generated-content/quotes-lang-2.html

39 lines
1.1 KiB
HTML
Raw Permalink Normal View History

Locale-specific quotes infrastructure needs to compare locale strings properly https://bugs.webkit.org/show_bug.cgi?id=213827 Reviewed by Darin Adler. Source/WebCore: Before this patch, WebKit is selecting which quotes to display on <q> elements by doing a raw strcmp() on the locale string with a big table of locale strings. strcmp() is the wrong way to compare locale strings. The HTML spec has a list of locales and their associated quotes[1]. It is formulated in terms of CSS using the "lang()" pseudoclass. The spec of the lang() pseudoclass[2] describes that locale comparison needs to be done according to section 3.3.2 in RFC4647[3]. This algorithm is a pretty general algorithm, and implementing it naively would mean turning our O(log(n)) algorithm into a O(n) algorithm, which would be unfortunate. Instead, we can use a few observations about the set of locale strings we are comparing against, in order to preserve the O(log(n)) runtime: - All the locales have either 1 or 2 subtags - None of the subtags in any of the ranges are wildcards - The list is sorted, so a locale string that is a prefix of another one is listed before it. [1] https://html.spec.whatwg.org/multipage/rendering.html#quotes [2] https://drafts.csswg.org/selectors-4/#the-lang-pseudo [3] https://tools.ietf.org/html/rfc4647#page-10 Test: fast/css-generated-content/quotes-lang-2.html * WebCore.xcodeproj/xcshareddata/xcschemes/WebCore.xcscheme: * rendering/RenderQuote.cpp: (WebCore::subtagCompare): (WebCore::quoteTableLanguageComparisonFunction): (WebCore::quotesForLanguage): (WebCore::RenderQuote::computeText const): LayoutTests: * fast/css-generated-content/quotes-lang-2-expected.html: Added. * fast/css-generated-content/quotes-lang-2.html: Added. Canonical link: https://commits.webkit.org/226816@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-06 23:59:23 +00:00
<!DOCTYPE html>
<style>
q {
font-family: "Times";
}
</style>
<p>
You should see the quotes for the specified language on each line below,
and not just basic " and ' characters unless no language is specified.
</p>
<q lang="agq"><q>agq</q></q>
<q lang="ag"><q>ag</q></q>
<q lang="gq"><q>gq</q></q>
<q lang="az"><q>az</q></q>
<q lang="zh-han"><q>zh-han</q></q>
<q lang="zh-ant"><q>zh-ant</q></q>
<q lang="az-cyrl-abc"><q>az-cyrl-abc</q></q>
<q lang="de-abc"><q>de-abc</q></q>
<q lang="de-ch-abc"><q>de-ch-abc</q></q>
<q lang="de-abc-ch"><q>de-abc-ch</q></q>
<q lang="fr-abc"><q>fr-abc</q></q>
<q lang="fr-ca-abc"><q>fr-ca-abc</q></q>
<q lang="fr-ch-abc"><q>fr-ch-abc</q></q>
<q lang="fr-abc-ca"><q>fr-abc-ca</q></q>
<q lang="fr-abc-ch"><q>fr-abc-ch</q></q>
<q lang="af-x"><q>af-x</q></q>
<q lang="de-x"><q>de-x</q></q>
<q lang="de-ch-x"><q>de-ch-x</q></q>
<q lang="de-x-ch"><q>de-x-ch</q></q>
<q lang="fr-x"><q>fr-x</q></q>
<q lang="fr-ca-x"><q>fr-ca-x</q></q>
<q lang="fr-ch-x"><q>fr-ch-x</q></q>
<q lang="fr-x-ca"><q>fr-x-ca</q></q>
<q lang="fr-x-ch"><q>fr-x-ch</q></q>
<q lang="en-ch"><q>en-ch</q></q>