From f10cfc965b2af0b4d09d7d02d6c0200609d0c96f Mon Sep 17 00:00:00 2001 From: Siye Liu Date: Wed, 29 May 2024 10:15:03 -0700 Subject: [PATCH] Add a new options argument to `document.caretPositionFromPoint` API. Per https://github.com/w3c/csswg-drafts/issues/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 --- ...ocument-caretPositionFromPoint.tentative.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shadow-dom/Document-caretPositionFromPoint.tentative.html b/shadow-dom/Document-caretPositionFromPoint.tentative.html index f3053ee7115093..b01bc0ae6edfef 100644 --- a/shadow-dom/Document-caretPositionFromPoint.tentative.html +++ b/shadow-dom/Document-caretPositionFromPoint.tentative.html @@ -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"); @@ -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"); @@ -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"); @@ -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"); @@ -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"); @@ -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"); @@ -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"); @@ -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");