Skip to content

Commit

Permalink
Make TextCluster an opaque object
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresRPerez12 committed Feb 12, 2025
1 parent 1b9e735 commit 9cab38c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -65632,6 +65632,7 @@ interface <dfn interface>TextMetrics</dfn> {

[Exposed=(Window,Worker)]
interface <dfn interface>TextCluster</dfn> {
// opaque object
readonly attribute double <span data-x="dom-TextCluster-x">x</span>;
readonly attribute double <span data-x="dom-TextCluster-y">y</span>;
readonly attribute unsigned long <span data-x="dom-TextCluster-begin">begin</span>;
Expand Down Expand Up @@ -69257,10 +69258,9 @@ try {
<ol>
<li><p>If any of the arguments are infinite or NaN, then return.</p></li>

<li><p>Run the <span>text preparation algorithm</span>, passing it the <var>text</var>
originally passed to <code data-x="dom-context-2d-measureText">measureText()</code> to obtain
the cluster, and an object with the <code>CanvasTextDrawingStyles</code> values as they were
when the cluster was measured, with the exception of <code
<li><p>Run the <span>text preparation algorithm</span>, passing it the complete text and the
<code>CanvasTextDrawingStyles</code> from the opaque <code>TextCluster</code>
<var>cluster</var>, with the exception of <code
data-x="dom-context-2d-textAlign">textAlign</code> and <code
data-x="dom-context-2d-textBaseline">textBaseline</code>, which are taken from the <code
data-x="dom-TextCluster-align">align</code> and <code
Expand Down Expand Up @@ -69489,8 +69489,14 @@ try {
<p>Splits the given range of the text into <span
data-x="grapheme cluster">grapheme clusters</span>, and returns the positional data for each
cluster. The range includes the character at the <var>start</var> index but stops before the
<var>end</var> index. The result is a list of new <code>TextCluster</code> objects with members
behaving as described in the following list: <ref>UNICODE</ref></p>
<var>end</var> index. The result is a list of new <code>TextCluster</code> objects. These
objects are opaque as they encapsulate the complete text that was segmented, along with the
<code>CanvasTextDrawingStyles</code> values that were active at the time <code
data-x="dom-context-2d-measureText">measureText()</code> was called. Note that <code
data-x="dom-context-2d-textAlign">textAlign</code> and
<code data-x="dom-context-2d-textBaseline">textBaseline</code> are exceptions, as they are explicitly set attributes and are handled separately. Each
<code>TextCluster</code> object has members behaving as described in the following list:
<ref>UNICODE</ref></p>

<dl>
<dt><dfn attribute for="TextCluster"><code data-x="dom-TextCluster-x">x</code></dfn> attribute</dt>
Expand Down Expand Up @@ -69555,11 +69561,6 @@ try {
that this doesn't change the origin of the coordinate system, just which point is specified
for each cluster.</p></dd>
</dl>

<p class="note">The user agent might internally store in the <code>TextCluster</code> object the
complete text, as well as all the <code>CanvasTextDrawingStyles</code> at the time that <code
data-x="dom-context-2d-measureText">measureText()</code> was called, as they will be needed to
correctly render the clusters as they were measured.</p>
</dd>
</dl>

Expand Down

0 comments on commit 9cab38c

Please sign in to comment.