-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[selectors4] Implement :dir pseudo-class
This patch adds support for the new ":dir" pseudo-class. The patch is covered by several of tests imported from the web tests including generic tests in addition to the tests from Firefox and apart from some minor changes on current tests to add the new selector. Intent-to-ship thread is available at: https://groups.google.com/u/1/a/chromium.org/g/blink-dev/c/p0Wc66rbVOc BUG=576815 Change-Id: I503c6af95d9c5817e3e71b1b2025a5562929f0d8
- Loading branch information
1 parent
005f922
commit b56e9ed
Showing
11 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style type="text/css"> | ||
span { background-color: lime } | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<div> | ||
<div></div> | ||
<span>The background color should be lime</span> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Level 4 Test: Check for correctly updating :dir matching on dir attribute change from default(ltr) to rtl</title> | ||
<link rel="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com"> | ||
<link rel="help" href="http://www.w3.org/TR/selectors4/#dir-pseudo"> | ||
<link rel="match" href="selectors-dir-selector-change-001-ref.html"> | ||
<style type="text/css"> | ||
#x:dir(rtl) + span { background-color: lime } | ||
#outer { direction:ltr } | ||
</style> | ||
</head> | ||
<body> | ||
<div id="outer"> | ||
<div> | ||
<div id="x"></div> | ||
<span>The background color should be lime</span> | ||
</div> | ||
</div> | ||
<script> | ||
// force a style update | ||
outer.offsetTop; | ||
outer.setAttribute("dir", "rtl"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Level 4 Test: Check for correctly updating :dir matching on dir attribute change from default(ltr) to rtl</title> | ||
<link rel="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com"> | ||
<link rel="help" href="http://www.w3.org/TR/selectors4/#dir-pseudo"> | ||
<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> | ||
<style type="text/css"> | ||
div { | ||
width: 100px; | ||
height: 100px; | ||
background-color: red; | ||
} | ||
|
||
div:dir(rtl) { | ||
background-color: green; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div id="inner"></div> | ||
<script> | ||
inner.setAttribute("dir", "rtl"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style type="text/css"> | ||
span { background-color: lime } | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<div> | ||
<div></div> | ||
<span>The background color should be lime</span> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Level 4 Test: Check for correctly updating :dir matching on dir attribute change from rtl to auto</title> | ||
<link rel="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com"> | ||
<link rel="help" href="http://www.w3.org/TR/selectors4/#dir-pseudo"> | ||
<link rel="match" href="selectors-dir-selector-change-003-ref.html"> | ||
<style type="text/css"> | ||
#x:dir(ltr) + span { background-color: lime } | ||
</style> | ||
</head> | ||
<body> | ||
<div id="outer" dir="rtl"> | ||
<div> | ||
<div id="x"></div> | ||
<span>The background color should be lime</span> | ||
</div> | ||
</div> | ||
<script> | ||
outer.setAttribute("dir", "auto"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<style type="text/css"> | ||
span { background-color: lime } | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<div dir="rtl"> | ||
<div></div> | ||
<span>מקור השם עברית</span> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Level 4 Test: Check for correctly updating :dir matching on directionality change from ltr to rtl</title> | ||
<link rel="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com"> | ||
<link rel="help" href="http://www.w3.org/TR/selectors4/#dir-pseudo"> | ||
<link rel="match" href="selectors-dir-selector-change-004-ref.html"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<style type="text/css"> | ||
#x:dir(rtl) + span { background-color: lime } | ||
</style> | ||
</head> | ||
<body> | ||
<div dir="auto"> | ||
<div> | ||
<div id="x"></div> | ||
<span id="inner">The background color should be lime</span> | ||
</div> | ||
</div> | ||
<script> | ||
inner.innerHTML = "מקור השם עברית"; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Level 4 Test: exception handling for an invalid identifier of dir()</title> | ||
<link rel="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com"> | ||
<link rel="help" href="http://www.w3.org/TR/selectors4/#dir-pseudo"> | ||
<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> | ||
<meta name="flags" content=""> | ||
<meta name="assert" content="The invalid identifier of :dir(ltrr) pseudo-class doesn't match an element that has a directionality of (ltr). Even if the div element has dir=ltr, the selector should not match."> | ||
<style type="text/css"> | ||
div { | ||
width: 100px; | ||
height: 100px; | ||
background-color: green; | ||
} | ||
|
||
div:dir(ltrr) { | ||
background-color: red; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div dir="ltr"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Level 4 Test: exception handling for multiple identifiers of dir() </title> | ||
<link rel="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com"> | ||
<link rel="help" href="http://www.w3.org/TR/selectors4/#dir-pseudo"> | ||
<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> | ||
<meta name="flags" content=""> | ||
<meta name="assert" content="The multiple identifiers of :dir(ltr, rtl) pseudo-class don't match an element that has a directionality of (ltr). Even if the div element has dir=ltr, the selector should not match."> | ||
<style type="text/css"> | ||
div { | ||
width: 100px; | ||
height: 100px; | ||
background-color: green; | ||
} | ||
|
||
div:dir(ltr, rtl) { | ||
background-color: red; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div dir="ltr"></div> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
css/selectors/selectors-dir-selector-white-space-001-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style type="text/css"> | ||
div { | ||
width: 100px; | ||
height: 100px; | ||
background-color: green; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div></div> | ||
<div></div> | ||
<div></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Level 4 Test: Verify for an identifier with leading and tailing whitespace of dir() </title> | ||
<link rel="author" title="Miyoung Shin" href="mailto:myid.shin@igalia.com"> | ||
<link rel="help" href="http://www.w3.org/TR/selectors4/#dir-pseudo"> | ||
<link rel="match" href="selectors-dir-selector-white-space-001-ref.html"> | ||
<meta name="assert" content="The :dir(ltr) pseudo-class matches an element that has a directionality of (ltr). Since the div element has dir=ltr, the selector matches."> | ||
<style type="text/css"> | ||
div { | ||
width: 100px; | ||
height: 100px; | ||
background-color: red; | ||
} | ||
|
||
#a:dir( ltr) { background-color: green; } | ||
#b:dir(ltr ) { background-color: green; } | ||
#c:dir( ltr ) { background-color: green; } | ||
</style> | ||
</head> | ||
<body> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div id="a" dir="ltr"></div> | ||
<div id="b" dir="ltr"></div> | ||
<div id="c" dir="ltr"></div> | ||
</body> | ||
</html> |