Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make position-fallback a tree-scoped name/reference
In preparation for doing tree-scoped name lookup for @position-fallback rules. Also added tests for tree-scoped @position-fallback lookups. Bug: 1381623 Change-Id: I6f9dc5ecaac2773c8deff9b9f6c66f389eb5e977 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4055466 Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1075628}
- Loading branch information
Rune Lillesveen
authored and
Chromium LUCI CQ
committed
Nov 24, 2022
1 parent
b9e27b3
commit 8664557
Showing
6 changed files
with
134 additions
and
6 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
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
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
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
12 changes: 12 additions & 0 deletions
12
...web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped-expected.txt
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,12 @@ | ||
This is a testharness.js-based test. | ||
PASS Document position-fallback matches @position-fallback in document scope | ||
PASS Document position-fallback does not match @position-fallback in #outer_host scope | ||
PASS Document position-fallback does not match @position-fallback in #inner_host scope | ||
PASS Outer position-fallback matches @position-fallback in document scope | ||
FAIL Outer position-fallback matches @position-fallback in #outer_host scope assert_equals: expected 200 but got 0 | ||
PASS Outer position-fallback does not match @position-fallback in #inner_host scope | ||
PASS Inner position-fallback matches @position-fallback in document scope | ||
FAIL Inner position-fallback matches @position-fallback in #outer_host scope assert_equals: expected 200 but got 0 | ||
FAIL Inner position-fallback matches @position-fallback in #inner_host scope assert_equals: expected 300 but got 0 | ||
Harness: the test ran to completion. | ||
|
112 changes: 112 additions & 0 deletions
112
...y/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped.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,112 @@ | ||
<!DOCTYPE html> | ||
<title>CSS Anchor Positioning Test: @position-fallback - tree scoped names</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback-rule"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/declarative-shadow-dom-polyfill.js"></script> | ||
|
||
<style> | ||
body { margin: 0; } | ||
|
||
@position-fallback --doc { | ||
@try { | ||
left: 100px; | ||
} | ||
} | ||
|
||
.abs { position: absolute; } | ||
|
||
#doc_pf_doc { position-fallback: --doc; } | ||
#doc_pf_outer { position-fallback: --outer; } | ||
#doc_pf_inner { position-fallback: --inner; } | ||
</style> | ||
|
||
<div id="doc_pf_doc" class="abs"></div> | ||
<div id="doc_pf_outer" class="abs"></div> | ||
<div id="doc_pf_inner" class="abs"></div> | ||
<div id="outer_host"> | ||
<template shadowroot="open"> | ||
<style> | ||
@position-fallback --outer { | ||
@try { | ||
left: 200px; | ||
} | ||
} | ||
|
||
.abs { position: absolute; } | ||
|
||
#outer_pf_doc { position-fallback: --doc; } | ||
#outer_pf_outer { position-fallback: --outer; } | ||
#outer_pf_inner { position-fallback: --inner; } | ||
</style> | ||
<div id="outer_pf_doc" class="abs"></div> | ||
<div id="outer_pf_outer" class="abs"></div> | ||
<div id="outer_pf_inner" class="abs"></div> | ||
<div id="inner_host"> | ||
<template shadowroot="open"> | ||
<style> | ||
@position-fallback --inner { | ||
@try { | ||
left: 300px; | ||
} | ||
} | ||
|
||
.abs { position: absolute; } | ||
|
||
#inner_pf_doc { position-fallback: --doc; } | ||
#inner_pf_outer { position-fallback: --outer; } | ||
#inner_pf_inner { position-fallback: --inner; } | ||
</style> | ||
<div id="inner_pf_doc" class="abs"></div> | ||
<div id="inner_pf_outer" class="abs"></div> | ||
<div id="inner_pf_inner" class="abs"></div> | ||
</template> | ||
</div> | ||
</template> | ||
</div> | ||
|
||
<script> | ||
setup(() => { | ||
polyfill_declarative_shadow_dom(outer_host); | ||
}); | ||
|
||
test(() => { | ||
assert_equals(doc_pf_doc.offsetLeft, 100); | ||
}, "Document position-fallback matches @position-fallback in document scope"); | ||
|
||
test(() => { | ||
assert_equals(doc_pf_outer.offsetLeft, 0); | ||
}, "Document position-fallback does not match @position-fallback in #outer_host scope"); | ||
|
||
test(() => { | ||
assert_equals(doc_pf_inner.offsetLeft, 0); | ||
}, "Document position-fallback does not match @position-fallback in #inner_host scope"); | ||
|
||
const outer_root = outer_host.shadowRoot; | ||
const inner_root = outer_root.querySelector("#inner_host").shadowRoot; | ||
|
||
test(() => { | ||
assert_equals(outer_root.querySelector("#outer_pf_doc").offsetLeft, 100); | ||
}, "Outer position-fallback matches @position-fallback in document scope"); | ||
|
||
test(() => { | ||
assert_equals(outer_root.querySelector("#outer_pf_outer").offsetLeft, 200); | ||
}, "Outer position-fallback matches @position-fallback in #outer_host scope"); | ||
|
||
test(() => { | ||
assert_equals(outer_root.querySelector("#outer_pf_inner").offsetLeft, 0); | ||
}, "Outer position-fallback does not match @position-fallback in #inner_host scope"); | ||
|
||
test(() => { | ||
assert_equals(inner_root.querySelector("#inner_pf_doc").offsetLeft, 100) | ||
}, "Inner position-fallback matches @position-fallback in document scope"); | ||
|
||
test(() => { | ||
assert_equals(inner_root.querySelector("#inner_pf_outer").offsetLeft, 200); | ||
}, "Inner position-fallback matches @position-fallback in #outer_host scope"); | ||
|
||
test(() => { | ||
assert_equals(inner_root.querySelector("#inner_pf_inner").offsetLeft, 300); | ||
}, "Inner position-fallback matches @position-fallback in #inner_host scope"); | ||
|
||
</script> |