Skip to content

Commit

Permalink
Add a new options argument to document.caretPositionFromPoint API.
Browse files Browse the repository at this point in the history
Per w3c/csswg-drafts#10345, we should change
`shadowRoots` parameter from a rest parameter to a dictionary which
contains an array of shadow roots.

Bug: 41487363
Change-Id: I0686d1eae75797ae07cad215a71a24ab54c7398d
  • Loading branch information
siliu1 authored and chromium-wpt-export-bot committed May 29, 2024
1 parent 6618b73 commit f10cfc9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions shadow-dom/Document-caretPositionFromPoint.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Get x and y coordinate at `he|llo, world`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y);
const caretPosition = document.caretPositionFromPoint(x, y, {});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -68,7 +68,7 @@
// Get x and y coordinate at `he|llo, world`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, shadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [shadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand All @@ -92,7 +92,7 @@
// Get x and y coordinate at `ab|cd`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, shadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [shadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand All @@ -113,7 +113,7 @@
// Get x and y coordinate at left-most location inside input element.
const x = rect.left + 1;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, shadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [shadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Node);
assert_equals(typeof(caretPosition.offset), "number");
Expand All @@ -134,7 +134,7 @@
// Get x and y coordinate at left-most location inside input element.
const x = rect.left + 1;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: []});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Node);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -215,7 +215,7 @@
// Get x and y coordinate at `so|me text`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, innerShadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [innerShadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -244,7 +244,7 @@
// Get x and y coordinate at `so|me text`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, outerShadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [outerShadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Node);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -274,7 +274,7 @@
// Get x and y coordinate at `so|me text`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, outerShadowRoot, innerShadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [innerShadowRoot, outerShadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down

0 comments on commit f10cfc9

Please sign in to comment.