Skip to content

Commit b069fcd

Browse files
[selection-api] Fix selection.modify() to use resolved text direction instead of inline base direction w3c/selection-api@b475d4b
1 parent 1072cc7 commit b069fcd

1 file changed

Lines changed: 87 additions & 79 deletions

File tree

selection-api-ja.html

Lines changed: 87 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@
266266
新たな範囲oを作成する:#_create-a-range
267267
以下略:#_omitted
268268

269+
-:#dfn-resolved-text-direction
270+
269271
●用語(外部
270272
~UA:~INFRA#user-agent
271273
~ASCII小文字~化する:~INFRA#ascii-lowercase
@@ -327,7 +329,6 @@
327329
m.document:~WINDOW#dom-window-document 結付けられた文書
328330
document:#dom-document
329331

330-
行内~基底~方向:~CSSWM#inline-base-direction
331332
v.ltr:~CSSWM#valdef-direction-ltr
332333
v.rtl:~CSSWM#valdef-direction-rtl
333334

@@ -336,6 +337,7 @@
336337
getSelectionW:getSelection
337338
W3Cbug:https://www.w3.org/Bugs/Public
338339
selectionchange-ev: <code class="event-type">selectionchange</code>
340+
UTR:https://www.unicode.org/reports
339341

340342
●●words_table
341343

@@ -384,9 +386,13 @@
384386
後方:backwards::~
385387
無方向:directionless::~
386388
支援技術:assistive technology:~
387-
書字:writing::~
389+
動き:movement:~
390+
親和性:affinity:~
391+
双向性:bidi:~
388392

389393
方向も含む:either extent or direction
394+
^i:L
395+
^i:R
390396

391397
●仕様
392398
-:suitable
@@ -785,9 +791,10 @@ <h2 title="Definition">2. 定義</h2>
785791
</p>
786792

787793
<p>
788-
各 `選択$には
794+
各 `選択$は、
789795
`方向@sL
790-
があり、[
796+
を有する
797+
— それは、[
791798
`前方@i,
792799
`後方@i,
793800
`無方向@i
@@ -807,59 +814,56 @@ <h2 title="Definition">2. 定義</h2>
807814

808815
<p>
809816
`選択$の`範囲o$sLが~scriptにより
810-
— 例えば `selectNode()$m を介して —
811-
変異したとしても
817+
— 例えば `selectNode()$m を介して —
818+
変異されたとしても
812819
当の`選択$の`方向$sLは,保全するモノトスル。
813820
814821
When the selection's range is mutated by scripts, e.g. via selectNode(node), direction of the selection must be preserved.
815822
</p>
816823

817824
<p>
818-
各 `選択$には
825+
各 `選択$ %選択 は、
819826
`~anchor@sL
820827
( `anchor^en ),
821828
`~focus@sL
822-
( `focus^en )もある
823-
【順に, “選択し始めた地点”, “選択し終えた地点” を表す】:
829+
( `focus^en )
830+
も有する
831+
【順に, “選択し始めた地点”, “選択し終えた地点” を表現する】。
832+
それらは、
833+
%選択 の`範囲o$sL %範囲o ~EQ ~NULL の場合,
834+
どちらも ~NULL になるとする
835+
— 他の場合、
836+
%選択 の`方向$sLに応じて:
824837
825838
Each selections also have an anchor and a focus.\
839+
If the selection's range is null, its anchor and focus are both null.\
840+
If the selection's range is not null and its direction\
826841
</p>
827-
<ul>
842+
<ul class="switch">
828843
<li>
829-
`選択$の`範囲o$sL ~EQ ~NULL の場合、[
830-
`~anchor$sL, `~focus$sL
831-
]どちらも ~NULL を返すとする。
844+
`前方$i
845+
⇒#
846+
`~anchor$sLは %範囲o の`始端$を指すとする。
847+
`~focus$sLは %範囲o の`終端$を指すとする。
832848
833-
If the selection's range is null, its anchor and focus are both null.\
849+
is forwards, its anchor is the range's start, and its focus is the end.\
834850
</li>
835851
<li>
836-
<p>
837-
`選択$の`範囲o$sL ~NEQ ~NULL の場合、
838-
`選択$の`方向$sLに応じて
839-
</p>
840-
<ul>
841-
<li>
842-
`前方$i ならば [
843-
`~anchor$sLは`範囲o$sLの`始端$,`~focus$sLは`範囲o$sLの`終端$
844-
]を返すとする。
845-
</li>
846-
<li>
847-
他の場合は[
848-
`~anchor$sLは`範囲o$sLの`終端$, `~focus$sLは`範囲o$sLの`始端$
849-
]を返すとする。
850-
</li>
851-
</ul>
852+
他の場合
853+
⇒#
854+
`~anchor$sLは %範囲o の`終端$を指すとする。
855+
`~focus$sLは %範囲o の`始端$を指すとする。
852856
853-
If the selection's range is not null and its direction is forwards, its anchor is the range's start, and its focus is the end. Otherwise, its focus is the start and its anchor is the end.
857+
Otherwise, its focus is the start and its anchor is the end.
854858
</li>
855859
</ul>
856860

857861
<p class="note">注記:
858862
`選択$の[
859863
`~anchor$sL, `~focus$sL
860-
]は`文書~tree$内にあるとは限らない
861-
— それは、
862-
同じ`文書$の`~shadow~tree$内にもあり得る
864+
]は
865+
`文書~tree$内に在るとは限らない
866+
同じ`文書$の`~shadow~tree$内にも在り得る
863867
864868
Note
865869

@@ -958,7 +962,7 @@ <h2 title="Selection interface">3. `Selection^I ~interface</h2>
958962

959963
<p class="trans-note">
960964
この~algoは、
961-
原文の共通な記述を集約したものである
965+
原文における共通な記述を集約するための,この訳による追加
962966
これは、
963967
所与の 2 つの境界点を,必要に応じて入れ替える。
964968
</p>
@@ -1828,16 +1832,13 @@ <h2 title="Selection interface">3. `Selection^I ~interface</h2>
18281832
<ol>
18291833
<li>
18301834
%alter ~SET `~ASCII小文字~化する$( %alter )
1831-
1832-
</li>
1835+
</li>
18331836
<li>
18341837
%direction ~SET `~ASCII小文字~化する$( %direction )
1835-
1836-
</li>
1838+
</li>
18371839
<li>
18381840
%granularity ~SET `~ASCII小文字~化する$( %granularity )
1839-
1840-
</li>
1841+
</li>
18411842
<li>
18421843
<p>
18431844
~IF[
@@ -1852,7 +1853,8 @@ <h2 title="Selection interface">3. `Selection^I ~interface</h2>
18521853
%direction ~NIN { `forward^l, `backward^l, `left^l, `right^l }
18531854
</li>
18541855
<li>
1855-
%granularity ~NIN { `character^l, `word^l, `sentence^l, `line^l, `paragraph^l, `lineboundary^l, `sentenceboundary^l, `paragraphboundary^l, `documentboundary^l </li>
1856+
%granularity ~NIN { `character^l, `word^l, `sentence^l, `line^l, `paragraph^l, `lineboundary^l, `sentenceboundary^l, `paragraphboundary^l, `documentboundary^l }
1857+
</li>
18561858
<li>
18571859
コレの`範囲o$sL ~EQ ~NULL
18581860
</li>
@@ -1862,54 +1864,43 @@ <h2 title="Selection interface">3. `Selection^I ~interface</h2>
18621864
18631865
~RET
18641866
</p>
1865-
1866-
If alter is not ASCII case-insensitive match with "extend" or "move", abort these steps.
1867-
1868-
If direction is not ASCII case-insensitive match with "forward", "backward", "left", or "right", abort these steps.
1869-
1870-
If granularity is not ASCII case-insensitive match with "character", "word", "sentence", "line", "paragraph", "lineboundary", "sentenceboundary", "paragraphboundary", "documentboundary", abort these steps.
1871-
1872-
If this selection is empty, abort these steps.
1873-
</li>
1874-
<li>
1875-
%書字~方向 ~LET コレの`~focus$sLにおける`行内~基底~方向$に応じて
1867+
</li>
1868+
<li id="dfn-resolved-text-direction">
1869+
<p>
1870+
%~text方向 ~LET コレの`~focus$sLを挟んで前後に位置する文字の`埋込み方向@~UTR/tr9/#BD3$
1871+
`UAX9$r に応じて
18761872
⇒#
1877-
`ltr$v 【左から右へ】ならば `right^l
1878-
`rtl$v 【右から左へ】ならば `left^l
1879-
1880-
</li>
1873+
`L^i 【左から右へ】ならば `right^l /
1874+
`R^i 【右から左へ】ならば `left^l
1875+
</p>
1876+
1877+
<p>【!注記: class="note"】
1878+
~UAは、
1879+
前後の文字の埋込み方向が異なる場合(`~focus$sLは双向性~境界である場合)には,
1880+
どちらを利用するか決定する際に追加的な文脈
1881+
(~cursorの動きの方向に基づく~caretとの親和性など)
1882+
を利用してもヨイ。
1883+
</p>
1884+
</li>
18811885
<li>
18821886
コレの`方向$sL ~SET [
18831887
次が満たされるならば `前方$i /
18841888
~ELSE_ `後方$i
18851889
18861890
1887-
%direction ~IN { `forward^l, %書字~方向 }
1888-
1889-
Let effectiveDirection be backwards.
1890-
1891-
If direction is ASCII case-insensitive match with "forward", set effectiveDirection to forwards.
1892-
1893-
If direction is ASCII case-insensitive match with "right" and inline base direction of this selection's focus is ltr, set effectiveDirection to forwards.
1894-
1895-
If direction is ASCII case-insensitive match with "left" and inline base direction of this selection's focus is rtl, set effectiveDirection to forwards.
1896-
1897-
Set this selection's direction to effectiveDirection.
1891+
%direction ~IN { `forward^l, %~text方向 }
18981892
</li>
18991893
<li>
19001894
<p>
19011895
%alter に応じて:
1902-
1903-
</p>
1896+
</p>
19041897
<ul class="switch">
19051898
<li>
19061899
`extend^l
19071900
19081901
コレの`~focus$sL ~SET [
19091902
利用者が選択を %granularity により拡張するよう要請した
19101903
]とするときの所在
1911-
1912-
If alter is ASCII case-insensitive match with "extend", set this selection's focus to the location as if the user had requested to extend selection by granularity.
19131904
</li>
19141905
<li>
19151906
`move^l
@@ -1919,23 +1910,40 @@ <h2 title="Selection interface">3. `Selection^I ~interface</h2>
19191910
]~SET [
19201911
利用者が選択を %granularity により移動するよう要請した
19211912
]とするときの所在
1922-
1923-
Otherwise, set this selection's focus and anchor to the location as if the user had requested to move selection by granularity.
19241913
</li>
19251914
</ul>
19261915

1927-
<p class="note">注記:
1916+
<p class="issue">【! class="note"】
19281917
%granularity により選択を[
19291918
拡張する/移動する
19301919
]とは何を意味するか,もっと精確に定義する必要がある。
1920+
</p>
1921+
</li>
1922+
</ol>
1923+
1924+
1925+
The method must follow these steps:
1926+
• If alter is not ASCII case-insensitive match with "extend" or "move", abort these steps.
1927+
• If direction is not ASCII case-insensitive match with "forward", "backward", "left", or "right", abort these steps.
1928+
• If granularity is not ASCII case-insensitive match with "character", "word", "sentence", "line", "paragraph", "lineboundary", "sentenceboundary", "paragraphboundary", "documentboundary", abort these steps.
1929+
• If this selection is empty, abort these steps.
1930+
• Let effectiveDirection be backwards.
1931+
• If direction is ASCII case-insensitive match with "forward", set effectiveDirection to forwards.
1932+
• If direction is ASCII case-insensitive match with "right" and the resolved text direction at this selection's focus is ltr, set effectiveDirection to forwards.
1933+
• If direction is ASCII case-insensitive match with "left" and the resolved text direction at this selection's focus is rtl, set effectiveDirection to forwards.
1934+
• Set this selection's direction to effectiveDirection.
1935+
• If alter is ASCII case-insensitive match with "extend", set this selection's focus to the location as if the user had requested to extend selection by granularity.
1936+
• Otherwise, set this selection's focus and anchor to the location as if the user had requested to move selection by granularity.
1937+
1938+
The resolved text direction at a boundary point is ltr if the embedding direction ([UAX9] BD3) of the character at that position is L, and rtl if the embedding direction is R.
19311939
19321940
Note
19331941

1934-
We need to more precisely define what it means to extend or move selection by each granularity.
1935-
</p>
1942+
At a bidi boundary—where adjacent characters have different embedding directions—user agents may use additional context (such as caret affinity based on the direction of cursor movement) to determine which character's embedding direction to use.
1943+
1944+
Note
19361945

1937-
</li>
1938-
</ol>
1946+
We need to more precisely define what it means to extend or move selection by each granularity.
19391947
</div>
19401948

19411949
<div class="algo">

0 commit comments

Comments
 (0)