Skip to content

Commit

Permalink
Add client coordinate definition and note on usage during scroll (#85)
Browse files Browse the repository at this point in the history
There are ReSpec errors because "client coordinate system" is used but not defined. I didn't find a good definition from another spec, so I've added a definition here.

Per #39, add a note on the fact that authors may want to adjust coordinates during scroll if they want to the IME window position to move with the content.

Closes #39.
  • Loading branch information
dandclark committed Dec 20, 2023
1 parent 01d8a77 commit dcf8246
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ <h4>EditContext state</h4>
<li><dfn>composition start</dfn> which refers to the offset in [=text=] representing the start position of the text being actively composed. The initial value is 0.</p></li>
<li><dfn>composition end</dfn> which refers to the offset in [=text=] representing the end position of the text being actively composed. The initial value is 0. [=composition end=] must always be greater than or equal to [=composition start=].</li>
<li><dfn>text formats</dfn> which is an array of [=text format=]. The array is initially empty.</li>
<li><dfn>control bounds</dfn> is a rectangle describing the area of the screen in which [=text=] is displayed. It is in the [=client coordinate=] system and the initial x, y, width, and height all 0.</li>
<li><dfn>selection bounds</dfn> is the rectangle describing the position of selection. It is in the [=client coordinate=] system and the initial x, y, width, and height are all 0.</li>
<li><dfn>control bounds</dfn> is a {{DOMRect}} describing the area of the viewport in which [=text=] is displayed. It is in the [=client coordinate system=] and the initial x, y, width, and height are all 0.</li>
<li><dfn>selection bounds</dfn> is a {{DOMRect}} describing the position of selection. It is in the [=client coordinate system=] and the initial x, y, width, and height are all 0.</li>
<li><dfn>codepoint rects start index</dfn> which is an offset into [=text=] that respresents the position before the first codepoint whose location is reported by the first member of [=codepoint rects=] array.</li>
<li><dfn>codepoint rects</dfn> is an array of {{DOMRect}} defining the bounding box of each codepoint. The array is initially empty.</li>
</ul>
Expand All @@ -135,6 +135,36 @@ <h4>EditContext state</h4>
from the [=Text Input Service=]. The user agent will indicate which positions are
required by firing {{CharacterBoundsUpdateEvent}}.
</p>
<p>
[=Control bounds=], [=selection bounds=], and [=codepoint rects=] are given in the
<dfn>client coordinate system</dfn>, which is defined as a two-dimensional Cartesian
coordinate system (x, y) where the origin is the top-left corner of the
<a href="https://drafts.csswg.org/cssom-view/#layout-viewport">layout viewport</a>,
the x-axis points towards the top-right of the
<a href="https://drafts.csswg.org/cssom-view/#layout-viewport">layout viewport</a>,
and the y-axis points towards the bottom-left of the
<a href="https://drafts.csswg.org/cssom-view/#layout-viewport">layout viewport</a>.
The units of the client coordinate system are
<a href="https://drafts.csswg.org/css-values/#px">CSS pixels</a>.
</p>
<div class="note">
<p>
Since EditContext bounds are defined in
<a data-lt="client coordinate system">client coordinates</a>, the coordinates
indicating a given piece of content on a page will change as the user scrolls the
document even if the content itself does not change position in the document. A
scenario where authors may want to take this into account is the case where the user
scrolls the page where the user has an active composition. If the author does not
update the EditContext's bounds information (e.g. during a scroll event listener),
the IME window may no longer line up with the text being composed for the duration
of the composition.
</p>
<p>
However, some platforms do not adjust IME windows during an active composition,
so updating bounds information mid-composition does not guarantee that the IME
window will be repositioned until it's closed and reopened.
</p>
</div>
<h4>Association and activation</h4>
<p>
An {{EditContext}} has an <dfn data-for="edit-context">associated element</dfn>, an {{HTMLElement}}.
Expand Down

0 comments on commit dcf8246

Please sign in to comment.