Skip to content

Commit e807c26

Browse files
committed
Bidi rewrites to handle <http://www.w3.org/mid/0b6b01cd34267944da0gmail.com> (<http://www.w3.org/mid/CA+FsOYYKGsKOrAoJ55jcYvYHVcWRojX4_KaCBfpQZSn8w=d3Ug@mail.gmail.com>) and hopefully align with future addition of isolation to Unicode bidi.
1 parent 51f7da3 commit e807c26

2 files changed

Lines changed: 137 additions & 111 deletions

File tree

css3-writing-modes/Overview.html

Lines changed: 85 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232

3333
<h1>CSS Writing Modes Module Level 3</h1>
3434

35-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 25 June 2012</h2>
35+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 26 June 2012</h2>
3636

3737
<dl>
3838
<dt>This version:
3939

4040
<dd><a
4141
href="http://dev.w3.org/csswg/css3-writing-modes/">http://dev.w3.org/csswg/css3-writing-modes/</a>
4242
<!--
43-
<dd><a href="http://www.w3.org/TR/2012/WD-css3-writing-modes-20120625/">http://www.w3.org/TR/2012/ED-css3-writing-modes-20120625/</a>
43+
<dd><a href="http://www.w3.org/TR/2012/WD-css3-writing-modes-20120626/">http://www.w3.org/TR/2012/ED-css3-writing-modes-20120626/</a>
4444
-->
4545

4646

@@ -533,17 +533,21 @@ <h2 id=text-direction><span class=secno>2. </span> Inline Direction and
533533

534534
<p>User agents that support bidirectional text must apply the Unicode
535535
bidirectional algorithm to every sequence of inline-level boxes
536-
uninterrupted by a forced (<a
536+
uninterrupted by any block boundary or “<a
537537
href="http://www.unicode.org/reports/tr9/#Bidirectional_Character_Types">bidi
538-
class B</a>) paragraph break or block boundary. This sequence forms the
539-
<dfn id=paragraph>paragraph</dfn> unit in the bidirectional algorithm.
538+
type B</a><dfn id=forced-paragraph-break>forced paragraph break</dfn>.
539+
This sequence forms the <dfn id=paragraph
540+
title="bidi paragraph">paragraph</dfn> unit in the bidirectional
541+
algorithm. Additionally, any such sequence forming part or all of the
542+
contents of a <a href="#bidi-isolate"><i>bidi-isolated</i></a> inline
543+
element also forms a <a href="#paragraph"><i>bidi paragraph</i></a>.
540544

541545
<p>Two CSS properties, ‘<a href="#direction0"><code
542546
class=property>direction</code></a>’ and ‘<a
543547
href="#unicode-bidi0"><code class=property>unicode-bidi</code></a>’,
544548
provide explicit embedding and override controls in the CSS layer. Because
545-
the base direction of a text depends on the structure and semantics of the
546-
document, the ‘<a href="#direction0"><code
549+
the base directionality of a text depends on the structure and semantics
550+
of the document, the ‘<a href="#direction0"><code
547551
class=property>direction</code></a>’ and ‘<a
548552
href="#unicode-bidi0"><code class=property>unicode-bidi</code></a>
549553
properties should in most cases be used only to map bidi information in
@@ -552,16 +556,19 @@ <h2 id=text-direction><span class=secno>2. </span> Inline Direction and
552556
those features instead</strong> and not specify CSS rules to override
553557
them.
554558

555-
<p>Except when the ‘<a href="#plaintext"><code
556-
class=css>plaintext</code></a>’ value of ‘<a
557-
href="#unicode-bidi0"><code class=property>unicode-bidi</code></a>’ is
558-
in effect, the paragraph embedding level is set according to the value of
559-
the ‘<a href="#direction0"><code class=property>direction</code></a>
560-
property of the paragraph's element rather than by the heuristic given in
561-
steps P2 and P3 of the Unicode algorithm. The paragraph's element is
562-
usually the containing block, but in the case of a paragraph contained by
563-
bidi <a href="#isolate">isolation</a> it is the isolating inline element
564-
instead.
559+
<p>In general, the paragraph embedding level is set according to the ‘<a
560+
href="#direction0"><code class=property>direction</code></a>’ property
561+
of the element <i>immediately containing</i> the paragraph rather than by
562+
the heuristic given in steps P2 and P3 of the Unicode algorithm. <a
563+
href="#UAX9" rel=biblioentry>[UAX9]<!--{{!UAX9}}--></a> When the computed
564+
<a href="#unicode-bidi0"><code
565+
class=property>unicode-bidi</code></a>’ of the element <i>immediately
566+
containing</i> the paragraph is ‘<a href="#plaintext"><code
567+
class=css>plaintext</code></a>’, however, the Unicode heuristics are
568+
used instead. An element <dfn id=bidi-contains>immediately contains</dfn>
569+
a bidi paragraph if the element itself, but none of its descendants, both
570+
contains the entire bidi paragraph and is a block container or <a
571+
href="#bidi-isolate"><i>bidi-isolating</i></a> inline.
565572

566573
<p>The HTML specifications (<a href="#HTML401"
567574
rel=biblioentry>[HTML401]<!--{{HTML401}}--></a>, section 8.2, and <a
@@ -762,7 +769,7 @@ <h3 id=unicode-bidi><span class=secno>2.2. </span> Embeddings and
762769
title="Within the element, content is ordered as if...">Inside</abbr>
763770

764771
<th><abbr
765-
title="the element's boundaries were strong characters of the element's 'direction'.">embed</abbr>
772+
title="the element's boundaries were strong characters of the element's 'direction'.">scoped</abbr>
766773

767774

768775
<td><a href="#embed"><code class=css>embed</code></a>
@@ -813,22 +820,25 @@ <h3 id=unicode-bidi><span class=secno>2.2. </span> Embeddings and
813820

814821
<dt><dfn id=isolate>isolate</dfn>
815822

816-
<dd>For the purposes of the Unicode bidirectional algorithm, the contents
817-
of the element are considered to be inside a separate, independent
818-
paragraph with a base directionality given by the element's ‘<a
819-
href="#direction0"><code class=property>direction</code></a>’ property,
820-
and for the purpose of bidi resolution in its containing bidi paragraph
821-
(if any), the element itself is treated as if it were an Object
823+
<dd>On an inline element, <dfn id=bidi-isolate
824+
title="bidi-isolate|bidi isolation|isolation">bidi-isolates</dfn> its
825+
contents: for the purpose of bidi resolution in its containing bidi
826+
paragraph (if any), the element is treated as if it were an Object
822827
Replacement Character (U+FFFC). (If the element is broken across multiple
823828
lines, then each box of the element is treated as an Object Replacement
824-
Character.)
829+
Character.) Within the element, its contents are considered, for the
830+
purposes of bidi resolution, to be inside a separate, independent
831+
document whose <a href="#paragraph"><i>bidi paragraphs</i></a> are
832+
assigned the base directionality given by the element's ‘<a
833+
href="#direction0"><code class=property>direction</code></a>’ property.
825834

826835
<dt><dfn id=bidi-override>bidi-override</dfn>
827836

828-
<dd>For inline elements this creates an override. For block-container
829-
elements this creates an override for inline-level descendants not within
830-
another block container element. This means that inside the element,
831-
reordering is strictly in sequence according to the ‘<a
837+
<dd>For inline elements this creates an <dfn id=override>override</dfn>.
838+
(For block-container elements this creates an <a
839+
href="#override"><i>override</i></a> for inline-level descendants not
840+
within another block container element.) This means that inside the
841+
element, reordering is strictly in sequence according to the ‘<a
832842
href="#direction0"><code class=property>direction</code></a>’ property;
833843
the implicit part of the bidirectional algorithm is ignored. This
834844
corresponds to adding a LRO (U+202D), for ‘<code class=css>direction:
@@ -838,8 +848,9 @@ <h3 id=unicode-bidi><span class=secno>2.2. </span> Embeddings and
838848

839849
<dt><dfn id=isolate-override>isolate-override<dfn></dfn></dfn>
840850

841-
<dd>This combines the isolation behavior of ‘<a href="#isolate"><code
842-
class=css>isolate</code></a>’ with the override behavior of ‘<a
851+
<dd>This combines the <a href="#bidi-isolate"><i>isolation</i></a>
852+
behavior of ‘<a href="#isolate"><code class=css>isolate</code></a>
853+
with the <a href="#override"><i>override</i></a> behavior of ‘<a
843854
href="#bidi-override"><code class=css>bidi-override</code></a>’: to
844855
surrounding content, it is equivalent to ‘<a href="#isolate"><code
845856
class=css>isolate</code></a>’, but within the element content is
@@ -851,14 +862,12 @@ <h3 id=unicode-bidi><span class=secno>2.2. </span> Embeddings and
851862
<dd>
852863
<p>This value behaves as ‘<a href="#isolate"><code
853864
class=css>isolate</code></a>’ except that for the purposes of the
854-
Unicode bidirectional algorithm, the base directionality of each bidi
855-
paragraph immediately contained by the element is determined not by the
856-
element's computed ‘<a href="#direction0"><code
857-
class=property>direction</code></a>’ as usual, but by following the
858-
heuristic in rules P2 and P3 of the Unicode bidirectional algorithm. An
859-
element immediately contains a bidi paragraph if the element itself, but
860-
none of its descendants, both contains the entire bidi paragraph and is
861-
a block container or bidi-isolating inline.
865+
Unicode bidirectional algorithm, the base directionality of each of the
866+
element's <a href="#paragraph"><i>bidi paragraphs</i></a> is determined
867+
by following the heuristic in rules P2 and P3 of the Unicode
868+
bidirectional algorithm (rather than by using the ‘<a
869+
href="#direction0"><code class=property>direction</code></a>’ property
870+
of the element).
862871
</dl>
863872

864873
<p class=note>Because the ‘<a href="#unicode-bidi0"><code
@@ -877,41 +886,43 @@ <h3 id=unicode-bidi><span class=secno>2.2. </span> Embeddings and
877886
href="#direction0"><code class=property>direction</code></a>’-dependent
878887
layout calculations.
879888

880-
<p>The final order of characters within in each bidi paragraph is the same
881-
as if the bidi control codes had been added as described above, markup had
882-
been stripped, and the resulting character sequence had been passed to an
883-
implementation of the Unicode bidirectional algorithm for plain text that
884-
produced the same line-breaks as the styled text.
889+
<p>The final order of characters within in each <a
890+
href="#paragraph"><i>bidi paragraph</i></a> is the same as if the bidi
891+
control codes had been added as described above, markup had been stripped,
892+
and the resulting character sequence had been passed to an implementation
893+
of the Unicode bidirectional algorithm for plain text that produced the
894+
same line-breaks as the styled text.
885895

886896
<p>In this process, replaced elements with ‘<code class=css>display:
887897
inline</code>’ are treated as neutral characters, unless their ‘<a
888898
href="#unicode-bidi0"><code class=property>unicode-bidi</code></a>
889-
property has a value other than ‘<a href="#normal"><code
890-
class=property>normal</code></a>’, in which case they are treated as
891-
strong characters in the ‘<a href="#direction0"><code
899+
property is either ‘<a href="#embed"><code
900+
class=property>embed</code></a>’ or ‘<a href="#bidi-override"><code
901+
class=property>bidi-override</code></a>’, in which case they are treated
902+
as strong characters in the ‘<a href="#direction0"><code
892903
class=property>direction</code></a>’ specified for the element. All
893904
other atomic inline-level boxes are treated as neutral characters always.
894905

895-
<p>If an inline element is broken around a bidi paragraph boundary (e.g. if
896-
split by a block or forced paragraph break), then the bidi control codes
897-
corresponding to the end of the element are added before the interruption
898-
and the codes corresponding to the start of the element are added after
899-
it. (In other words, any embedding levels or overrides started by the
900-
element are closed at the paragraph break and reopened on the other side
901-
of it.)
902-
903-
<p>Because the Unicode algorithm has a limit of <em
904-
title="According to unicode 3.0, chapter 3, section 12, definition BD2. Specifically, page 58 here: http://www.unicode.org/unicode/uni2book/ch03.pdf">
905-
61 levels</em> of embedding, care should be taken not to use <a
906-
class=propinst-unicode-bidi href="#unicode-bidi0"><code
907-
class=property>unicode-bidi</code></a> with a value other than ‘<a
906+
<p>If an inline element is broken around a <a href="#paragraph"><i>bidi
907+
paragraph</i></a> boundary (e.g. if split by a block or <a
908+
href="#forced-paragraph-break"><i>forced paragraph break</i></a>), then
909+
the bidi control codes corresponding to the end of the element are added
910+
before the interruption and the codes corresponding to the start of the
911+
element are added after it. (In other words, any embedding levels or
912+
overrides started by the element are closed at the paragraph break and
913+
reopened on the other side of it.)
914+
915+
<p>Because the Unicode algorithm has a limit of 61 levels of embedding,
916+
care should be taken not to use ‘<a href="#unicode-bidi0"><code
917+
class=property>unicode-bidi</code></a>’ with a value other than ‘<a
908918
href="#normal"><code class=property>normal</code></a>’ unless
909919
appropriate. In particular, a value of ‘<code
910-
class=property>inherit</code>’ should be used with extreme caution.
911-
However, for elements that are, in general, intended to be displayed as
912-
blocks, a setting of ‘<code class=css>unicode-bidi: isolate</code>’ is
913-
preferred to keep the element together in case display is changed to
914-
inline (see example below).
920+
class=css>inherit</code>’ should be used with extreme caution. However,
921+
for elements that are, in general, intended to be displayed as blocks, a
922+
setting of ‘<code class=css>unicode-bidi: isolate</code>’ is preferred
923+
to keep the element together in case the ‘<code
924+
class=property>display</code>’ is changed to ‘<code
925+
class=css>inline</code>’ (see example below).
915926

916927
<h3 id=bidi-example><span class=secno>2.3. </span> Example of Bidirectional
917928
Text</h3>
@@ -4272,6 +4283,15 @@ <h3 class=no-num id=normative-references> Normative references</h3>
42724283
</dd>
42734284
<!---->
42744285

4286+
<dt id=UAX9>[UAX9]
4287+
4288+
<dd>Mark Davis. <a
4289+
href="http://www.unicode.org/reports/tr9/"><cite>Unicode Bidirectional
4290+
Algorithm.</cite></a> 16 January 2012. Unicode Standard Annex #9. URL: <a
4291+
href="http://www.unicode.org/reports/tr9/">http://www.unicode.org/reports/tr9/</a>
4292+
</dd>
4293+
<!---->
4294+
42754295
<dt id=UNICODE>[UNICODE]
42764296

42774297
<dd>The Unicode Consortium. <a

0 commit comments

Comments
 (0)