Commit 0af8bdb3 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Revert "Fix CSSPreloadScanner to avoid missing rules"

This reverts commit 6eb116c4.

Reason for revert: The CL added files to non-existent WebKit/LayoutTests/.

Original change's description:
> Fix CSSPreloadScanner to avoid missing rules
> 
> This fixes a couple of bugs with the CSSPReloadScanner that made it miss
> rules in which the URL wasn't quoted or the rule didn't end with a
> semicolon. It also adds tentative WPT tests for that functionality, as
> the tests are also relevant for WebKit.
> 
> Bug: 903785
> Change-Id: I6d7dae1db3617184148fd71dfdb62fa1ee19e74f
> Reviewed-on: https://chromium-review.googlesource.com/c/1331042
> Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
> Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#610744}

TBR=kouhei@chromium.org,csharrison@chromium.org,yoavweiss@chromium.org

Change-Id: Ib2dcae03345d0f05f970b226a727f28e11a6c866
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 903785
Reviewed-on: https://chromium-review.googlesource.com/c/1350014Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610749}
parent 8100d4b5
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test('Imported inline CSS with no quote is not blocked on pending CSS');
</script>
<link rel=stylesheet href="resources/dummy.css?first&pipe=trickle(d1)">
<script>
var this_script_is_neccessary_to_block_the_inline_style_processing = true;
</script>
<style>
@import url(resources/dummy.css?second);
</style>
<script>
window.addEventListener("load", t.step_func_done(() => {
let entries = performance.getEntriesByType('resource');
let first;
let second;
for (entry of entries) {
if (entry.name.includes("first")) {
first = entry;
}
if (entry.name.includes("second")) {
second = entry;
}
}
assert_true(first.responseEnd > second.startTime, "The second resource start time should not be blocked on the first resource response");
}));
</script>
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test('Imported inline CSS with no semicolon is not blocked on pending CSS');
</script>
<link rel=stylesheet href="resources/dummy.css?first&pipe=trickle(d1)">
<script>
var this_script_is_neccessary_to_block_the_inline_style_processing = true;
</script>
<style>
@import url("resources/dummy.css?second")
</style>
<script>
window.addEventListener("load", t.step_func_done(() => {
let entries = performance.getEntriesByType('resource');
let first;
let second;
for (entry of entries) {
if (entry.name.includes("first")) {
first = entry;
}
if (entry.name.includes("second")) {
second = entry;
}
}
assert_true(first.responseEnd > second.startTime, "The second resource start time should not be blocked on the first resource response");
}));
</script>
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test('Imported inline CSS with no quote is not blocked on pending CSS');
</script>
<link rel=stylesheet href="resources/dummy.css?first&pipe=trickle(d1)">
<script>
var this_script_is_neccessary_to_block_the_inline_style_processing = true;
</script>
<style>@import url("resources/dummy.css?second")</style>
<script>
window.addEventListener("load", t.step_func_done(() => {
let entries = performance.getEntriesByType('resource');
let first;
let second;
for (entry of entries) {
if (entry.name.includes("first")) {
first = entry;
}
if (entry.name.includes("second")) {
second = entry;
}
}
assert_true(first.responseEnd > second.startTime, "The second resource start time should not be blocked on the first resource response");
}));
</script>
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test('Imported inline CSS is not blocked on pending CSS');
</script>
<link rel=stylesheet href="resources/dummy.css?first&pipe=trickle(d1)">
<script>
var this_script_is_neccessary_to_block_the_inline_style_processing = true;
</script>
<style>
@import url('resources/dummy.css?second');
</style>
<script>
window.addEventListener("load", t.step_func_done(() => {
let entries = performance.getEntriesByType('resource');
let first;
let second;
for (entry of entries) {
if (entry.name.includes("first")) {
first = entry;
}
if (entry.name.includes("second")) {
second = entry;
}
}
assert_true(first.responseEnd > second.startTime, "The second resource start time should not be blocked on the first resource response");
}));
</script>
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test('Imported inline CSS is not blocked on pending CSS');
</script>
<link rel=stylesheet href="resources/dummy.css?first&pipe=trickle(d1)">
<script>
var this_script_is_neccessary_to_block_the_inline_style_processing = true;
</script>
<style>
@import url("resources/dummy.css?second");
</style>
<script>
window.addEventListener("load", t.step_func_done(() => {
let entries = performance.getEntriesByType('resource');
let first;
let second;
for (entry of entries) {
if (entry.name.includes("first")) {
first = entry;
}
if (entry.name.includes("second")) {
second = entry;
}
}
assert_true(first.responseEnd > second.startTime, "The second resource start time should not be blocked on the first resource response");
}));
</script>
......@@ -156,18 +156,12 @@ inline void CSSPreloadScanner::Tokenize(UChar c,
}
break;
case kRuleValue:
if (IsHTMLSpace<UChar>(c)) {
if (IsHTMLSpace<UChar>(c))
state_ = kAfterRuleValue;
} else if (c == ';') {
else if (c == ';')
EmitRule(source);
} else {
else
rule_value_.Append(c);
// When reading the rule and hitting ')', which signifies the URL end,
// emit the rule.
if (c == ')') {
EmitRule(source);
}
}
break;
case kAfterRuleValue:
if (IsHTMLSpace<UChar>(c))
......@@ -191,20 +185,14 @@ static String ParseCSSStringOrURL(const String& string) {
wtf_size_t offset = 0;
wtf_size_t reduced_length = string.length();
// Remove whitespace from the rule start
while (reduced_length && IsHTMLSpace<UChar>(string[offset])) {
++offset;
--reduced_length;
}
// Remove whitespace from the rule end
// TODO(yoav): Evaluate performance benefits of using raw string operations.
// TODO(yoav): Look into moving parsing to use better parsing primitives.
while (reduced_length &&
IsHTMLSpace<UChar>(string[offset + reduced_length - 1])) {
IsHTMLSpace<UChar>(string[offset + reduced_length - 1]))
--reduced_length;
}
// Skip the "url(" prefix and the ")" suffix
if (reduced_length >= 5 && (string[offset] == 'u' || string[offset] == 'U') &&
(string[offset + 1] == 'r' || string[offset + 1] == 'R') &&
(string[offset + 2] == 'l' || string[offset + 2] == 'L') &&
......@@ -213,23 +201,28 @@ static String ParseCSSStringOrURL(const String& string) {
reduced_length -= 5;
}
// Skip whitespace before and after the URL inside the "url()" parenthesis.
while (reduced_length && IsHTMLSpace<UChar>(string[offset])) {
++offset;
--reduced_length;
}
while (reduced_length &&
IsHTMLSpace<UChar>(string[offset + reduced_length - 1])) {
IsHTMLSpace<UChar>(string[offset + reduced_length - 1]))
--reduced_length;
}
// Remove single-quotes or double-quotes from the URL
if ((reduced_length >= 2) &&
(string[offset] == string[offset + reduced_length - 1]) &&
(string[offset] == '\'' || string[offset] == '"')) {
offset++;
reduced_length -= 2;
if (reduced_length < 2 ||
string[offset] != string[offset + reduced_length - 1] ||
!(string[offset] == '\'' || string[offset] == '"'))
return String();
offset++;
reduced_length -= 2;
while (reduced_length && IsHTMLSpace<UChar>(string[offset])) {
++offset;
--reduced_length;
}
while (reduced_length &&
IsHTMLSpace<UChar>(string[offset + reduced_length - 1]))
--reduced_length;
return string.Substring(offset, reduced_length);
}
......
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