Commit 3ed3289d authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Eliminate DeprecatedLower in Element::LocalNameForSelectorMatching()

This patch changes Element::LocalNameForSelectorMatching() to
use LowerASCII instead of DeprecatedLower.

DeprecatedLower has partial Unicode conversions, such as
converting U+212A to 'k', but lowering only ASCII is mandated
by the spec:
https://www.w3.org/TR/selectors-4/#case-sensitive

Currently, there are 6 usages of AtomicString::DeprecatedLower
and 37 usages of String::DeprecatedLower. This patch reduces
one of the 6 usages.

Bug: 627682
Change-Id: I49bdbbae645a287bf6dacdcb0a6481f7eb93c022
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720642
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Auto-Submit: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681724}
parent e955ed2d
......@@ -2087,7 +2087,7 @@ String Element::nodeName() const {
AtomicString Element::LocalNameForSelectorMatching() const {
if (IsHTMLElement() || !GetDocument().IsHTMLDocument())
return localName();
return localName().DeprecatedLower();
return localName().LowerASCII();
}
const AtomicString& Element::LocateNamespacePrefix(
......
<!DOCTYPE html>
<title>Test element names are case-insensitive only in ASCII range</title>
<link rel="help" href="https://www.w3.org/TR/selectors-4/#case-sensitive">
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<style>
\212A {
display: block;
background: lime;
width: 200px;
height: 100px;
}
</style>
<body>
<p>You should see a green square below.</p>
<div id="container"></div>
<script>
// Insert from JavaScript to avoid parser doing something special.
let test_element = document.createElement('\u212A');
container.appendChild(test_element);
let test_element_with_ns = document.createElementNS('https://dummy.ns', '\u212A');
container.appendChild(test_element_with_ns);
test(() => {
assert_equals(test_element.offsetHeight, 100);
}, 'CSS selector should match for Unicode uppercase element');
test(() => {
// Elements in different namespace cannot compute style or height.
// Test the height of the container instead.
assert_equals(container.offsetHeight, 200);
}, 'Elements with namespace should work the same way');
test(() => {
let e = document.querySelector('k');
assert_equals(e, null);
}, '`querySelector` should not use Unicode case-foldering');
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment