summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakayoshi Kochi <kochi@chromium.org>2016-03-09 14:02:13 +0900
committerTakayoshi Kochi <kochi@chromium.org>2016-03-09 05:04:06 +0000
commit9154f3d7ad33e79b6f4d9934f2bc1bbc74387892 (patch)
tree8621e6bccfd5e3e96083385a6ba534dc70691553
parent0eea8b3b09706687bb828790362c140dfdda1a46 (diff)
downloadchromium_src-9154f3d7ad33e79b6f4d9934f2bc1bbc74387892.zip
chromium_src-9154f3d7ad33e79b6f4d9934f2bc1bbc74387892.tar.gz
chromium_src-9154f3d7ad33e79b6f4d9934f2bc1bbc74387892.tar.bz2
Allow simple selectors after ::content for compat.
Allow simple selectors which are not pseudo elements after ::content in compound selectors. Polymer 0.5 content sometimes use ::content[attr] instead of [attr]::content. This was made invalid with r369760. R=timloh@chromium.org BUG=589252 Review URL: https://codereview.chromium.org/1749713002 Cr-Commit-Position: refs/heads/master@{#378331} (cherry picked from commit b9661ac4a6e7f0cfcd9b6fc8b25b074cac3b7bed) Review URL: https://codereview.chromium.org/1771853005 . Cr-Commit-Position: refs/branch-heads/2623@{#603} Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last-expected.txt10
-rw-r--r--third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last.html13
-rw-r--r--third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp2
-rw-r--r--third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp8
4 files changed, 29 insertions, 4 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last-expected.txt
new file mode 100644
index 0000000..69b030a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last-expected.txt
@@ -0,0 +1,10 @@
+Accept simple selectors after ::content For Polymer 0.5 compat
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS getComputedStyle(distributed).color is "rgb(0, 128, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This text should be green
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last.html
new file mode 100644
index 0000000..39e13ed
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/content-pseudo-element-not-last.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<script src="../../../resources/js-test.js"></script>
+<div id="host">
+ <span id="distributed">This text should be green</span>
+</div>
+<script>
+ description("Accept simple selectors after ::content For Polymer 0.5 compat");
+
+ var root = host.createShadowRoot();
+ root.innerHTML = '<style>[select]::content.x span { color: green }</style><content class="x" select="span"></content>';
+
+ shouldBeEqualToString("getComputedStyle(distributed).color", "rgb(0, 128, 0)");
+</script>
diff --git a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
index 61024f5..5ce5f53 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
@@ -225,6 +225,8 @@ bool isSimpleSelectorValidAfterPseudoElement(const CSSParserSelector& simpleSele
{
if (compoundPseudoElement == CSSSelector::PseudoUnknown)
return true;
+ if (compoundPseudoElement == CSSSelector::PseudoContent)
+ return simpleSelector.match() != CSSSelector::PseudoElement;
if (simpleSelector.match() != CSSSelector::PseudoClass)
return false;
CSSSelector::PseudoType pseudo = simpleSelector.pseudoType();
diff --git a/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp b/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
index 9391da4..6a4d51c 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
@@ -119,6 +119,10 @@ TEST(CSSSelectorParserTest, ShadowDomPseudoInCompound)
{ ".a::shadow", ".a::shadow" },
{ "::content", "::content" },
{ ".a::content", ".a::content" },
+ { "::content.a", "::content.a" },
+ { "::content.a.b", "::content.a.b" },
+ { ".a::content.b", ".a::content.b" },
+ { "::content:not(#id)", "::content:not(#id)" }
};
for (auto testCase : testCases) {
@@ -182,12 +186,8 @@ TEST(CSSSelectorParserTest, InvalidSimpleAfterPseudoElementInCompound)
"::shadow.class",
"::selection:window-inactive::before",
"::-webkit-volume-slider.class",
- "::content.a",
- "::content.a.b",
- ".a::content.b",
"::before:not(.a)",
"::shadow:not(::after)",
- "::content:not(#id)",
"::-webkit-scrollbar:vertical:not(:first-child)",
"video::-webkit-media-text-track-region-container.scrolling",
"div ::before.a"