Source/WebCore/ChangeLog

 12011-04-27 Levi Weintraub <leviw@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Add support for unicode-bidi:plaintext CSS property
 6 https://bugs.webkit.org/show_bug.cgi?id=50949
 7
 8 Adding support for unicode-bidi: plaintext. This involves invoking P2 and P3
 9 of the Unicode BiDi algorithm on each paragraph of a block with that style.
 10 This is similar to dir=auto but done per-paragraph instead of per element.
 11
 12 Test: fast/text/international/unicode-bidi-plaintext.html
 13
 14 * css/CSSParser.cpp:
 15 (WebCore::CSSParser::parseValue): Added plaintext.
 16 * css/CSSPrimitiveValueMappings.h:
 17 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto.
 18 (WebCore::CSSPrimitiveValue::operator EUnicodeBidi): Ditto.
 19 * css/CSSValueKeywords.in: Ditto.
 20 * html/HTMLElement.cpp:
 21 (WebCore::unicodeBidiAttributeForDirAuto): Helper to map elements with dir=auto
 22 to their proper unicode-bidi attribute.
 23 (WebCore::HTMLElement::parseMappedAttribute): Assign plaintext to pre and textarea
 24 when dir=auto.
 25 * platform/text/UnicodeBidi.h: Added plaintext.
 26 * rendering/RenderBlockLineLayout.cpp:
 27 (WebCore::determineParagraphDirection): Determines the direction of a paragraph
 28 based on the first strong character. Stops at first paragraph separator.
 29 (WebCore::RenderBlock::layoutInlineChildren): Uses determineParagraphDirection
 30 when in unicode-bidi: plaintext mode (and operating at the block's BidiContext)
 31 to set each paragraph to the proper base BidiContext.
 32 (WebCore::RenderBlock::determineStartPosition): Ditto.
 33 * rendering/style/RenderStyle.h: Gave _unicodebidi another bit to accomodate
 34 for plaintext.
 35
1362011-06-21 Dmitry Lomov <dslomov@google.com>
237
338 Reviewed by Adam Barth.
89391

Source/WebCore/css/CSSParser.cpp

@@bool CSSParser::parseValue(int propId, b
832832 else
833833 return parseQuotes(propId, important);
834834 break;
835  case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | inherit
 835 case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | plaintext | inherit
836836 if (id == CSSValueNormal
837837 || id == CSSValueEmbed
838838 || id == CSSValueBidiOverride
839  || id == CSSValueWebkitIsolate)
 839 || id == CSSValueWebkitIsolate
 840 || id == CSSValueWebkitPlaintext)
840841 validPrimitive = true;
841842 break;
842843
89391

Source/WebCore/css/CSSPrimitiveValueMappings.h

@@template<> inline CSSPrimitiveValue::CSS
17551755 break;
17561756 case Isolate:
17571757 m_value.ident = CSSValueWebkitIsolate;
 1758 break;
 1759 case Plaintext:
 1760 m_value.ident = CSSValueWebkitPlaintext;
 1761 break;
17581762 }
17591763}
17601764

@@template<> inline CSSPrimitiveValue::ope
17691773 return Override;
17701774 case CSSValueWebkitIsolate:
17711775 return Isolate;
 1776 case CSSValueWebkitPlaintext:
 1777 return Plaintext;
17721778 default:
17731779 ASSERT_NOT_REACHED();
17741780 return UBNormal;
89391

Source/WebCore/css/CSSValueKeywords.in

@@hide
408408higher
409409invert
410410-webkit-isolate
 411-webkit-plaintext
411412landscape
412413ledger
413414legal
89391

Source/WebCore/html/HTMLElement.cpp

@@bool HTMLElement::mapToEntry(const Quali
125125
126126 return StyledElement::mapToEntry(attrName, result);
127127}
128 
 128
 129static int unicodeBidiAttributeForDirAuto(HTMLElement* element)
 130{
 131 if (element->hasLocalName(bdoTag))
 132 return CSSValueBidiOverride;
 133 if (element->hasLocalName(preTag) || element->hasLocalName(textareaTag))
 134 return CSSValueWebkitPlaintext;
 135 return CSSValueEmbed;
 136}
 137
129138void HTMLElement::parseMappedAttribute(Attribute* attr)
130139{
131140 if (isIdAttributeName(attr->name()) || attr->name() == classAttr || attr->name() == styleAttr)

@@void HTMLElement::parseMappedAttribute(A
156165 if (!equalIgnoringCase(attr->value(), "auto"))
157166 addCSSProperty(attr, CSSPropertyDirection, attr->value());
158167 dirAttributeChanged(attr);
159  addCSSProperty(attr, CSSPropertyUnicodeBidi, hasLocalName(bdoTag) ? CSSValueBidiOverride : CSSValueEmbed);
 168 addCSSProperty(attr, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(this));
160169 } else if (attr->name() == draggableAttr) {
161170 const AtomicString& value = attr->value();
162171 if (equalIgnoringCase(value, "true")) {
89391

Source/WebCore/platform/text/UnicodeBidi.h

@@enum EUnicodeBidi {
3232 UBNormal,
3333 Embed,
3434 Override,
35  Isolate
 35 Isolate,
 36 Plaintext
3637};
3738
3839}
89391

Source/WebCore/rendering/RenderBlockLineLayout.cpp

@@static int inlineLogicalWidth(RenderObje
112112 return extraWidth;
113113}
114114
 115static void determineParagraphDirection(TextDirection& dir, InlineIterator iter)
 116{
 117 while (!iter.atEnd()) {
 118 if (iter.atParagraphSeparator())
 119 return;
 120 if (UChar current = iter.current()) {
 121 Direction charDirection = direction(current);
 122 if (charDirection == LeftToRight) {
 123 dir = LTR;
 124 return;
 125 }
 126 if (charDirection == RightToLeft || charDirection == RightToLeftArabic) {
 127 dir = RTL;
 128 return;
 129 }
 130 }
 131 iter.increment();
 132 }
 133}
 134
115135static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator& lBreak)
116136{
117137 // Check to see if our last midpoint is a start point beyond the line break. If so,

@@void RenderBlock::layoutRunsAndFloats(Li
944964 lineInfo.setEmpty(true);
945965
946966 InlineIterator oldEnd = end;
 967 bool isNewParagraph = lineInfo.previousLineBrokeCleanly();
947968 FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0;
948969 end = lineBreaker.nextLineBreak(resolver, lineInfo, lineBreakIteratorInfo, lastFloatFromPreviousLine);
949970 if (resolver.position().atEnd()) {

@@void RenderBlock::layoutRunsAndFloats(Li
962983 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.status());
963984 } else {
964985 VisualDirectionOverride override = (style()->rtlOrdering() == VisualOrder ? (style()->direction() == LTR ? VisualLeftToRightOverride : VisualRightToLeftOverride) : NoVisualOverride);
 986
 987 if (style()->unicodeBidi() == Plaintext && isNewParagraph && !resolver.context()->parent()) {
 988 TextDirection direction = style()->direction();
 989 determineParagraphDirection(direction, resolver.position());
 990 resolver.setStatus(BidiStatus(direction, style()->unicodeBidi() == Override));
 991 }
965992 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine.
966993 BidiRunList<BidiRun>& bidiRuns = resolver.runs();
967994 resolver.createBidiRunsForLine(end, override, lineInfo.previousLineBrokeCleanly());

@@RootInlineBox* RenderBlock::determineSta
13491376 resolver.setPosition(InlineIterator(this, last->lineBreakObj(), last->lineBreakPos()));
13501377 resolver.setStatus(last->lineBreakBidiStatus());
13511378 } else {
1352  resolver.setStatus(BidiStatus(style()->direction(), style()->unicodeBidi() == Override));
 1379 TextDirection direction = style()->direction();
 1380 if (style()->unicodeBidi() == Plaintext)
 1381 determineParagraphDirection(direction, InlineIterator(this, bidiFirstNotSkippingInlines(this), 0));
 1382 resolver.setStatus(BidiStatus(direction, style()->unicodeBidi() == Override));
13531383 resolver.setPosition(InlineIterator(this, bidiFirstSkippingInlines(this, &resolver), 0));
13541384 }
13551385 return curr;
89391

Source/WebCore/rendering/style/RenderStyle.h

@@protected:
256256 bool _affectedByActive : 1;
257257 bool _affectedByDrag : 1;
258258 unsigned _pseudoBits : 7;
259  unsigned _unicodeBidi : 2; // EUnicodeBidi
 259 unsigned _unicodeBidi : 3; // EUnicodeBidi
260260 bool _isLink : 1;
261  // 50 bits
 261 // 51 bits
262262 } noninherited_flags;
263263
264264// !END SYNC!
89391

LayoutTests/ChangeLog

 12011-04-06 Levi Weintraub <leviw@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Add support for unicode-bidi:plaintext CSS property
 6 https://bugs.webkit.org/show_bug.cgi?id=50949
 7 Adding support for the 'plaintext' mode of unicode-bidi.
 8
 9 * fast/text/international/unicode-bidi-plaintext.html: Added.
 10 * platform/mac/fast/text/international/unicode-bidi-plaintext-expected.png: Added.
 11 * platform/mac/fast/text/international/unicode-bidi-plaintext-expected.txt: Added.
 12
1132011-06-21 Dmitry Titov <dimich@chromium.org>
214
315 [Chromium] Unreviewed update of test expectations.
89391

LayoutTests/fast/text/international/unicode-bidi-plaintext.html

 1<!DOCTYPE html>
 2
 3<html>
 4<head>
 5<style>
 6.resultsDiv {
 7 position: absolute;
 8 top: 0px;
 9 left: 0px;
 10 -moz-column-width: 13em;
 11 -webkit-column-width: 13em;
 12 -moz-column-gap: 5em;
 13 -webkit-column-gap: 5em;
 14 height: 400px;
 15}
 16</style>
 17<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 18</head>
 19<body>
 20<div>This tests proper handling of unicode-bidi: plaintext. You should not see any red.</div>
 21
 22<div style="position:relative">
 23<div class="resultsDiv">
 24<div style="color: red; unicode-bidi: -webkit-plaintext;">
 25!hello.
 26<br>
 27!שלום.
 28<br>
 29hello, לוי!
 30<br>
 31שלום, WebKit!
 32</div>
 33<pre style="color: red; margin: 0;" dir="auto">
 34a
 35(
 36שלום, WebKit!
 37hello, לוי!
 38)
 39</pre>
 40</div>
 41</div>
 42
 43<div style="position: relative;">
 44<div style="color:green;" class="resultsDiv" dir=ltr>
 45!hello.<br>
 46<span dir=rtl>
 47!שלום.
 48</span><br>
 49<span dir=ltr>
 50hello, לוי!
 51</span><br>
 52<span dir=rtl>
 53שלום, WebKit!</span><br>
 54<pre style="color: green; margin: 0;">
 55a
 56(
 57!WebKit ,שלום
 58hello, לוי!
 59)
 60</pre>
 61</div>
0

LayoutTests/platform/mac/fast/text/international/unicode-bidi-plaintext-expected.txt

 1layer at (0,0) size 800x600
 2 RenderView at (0,0) size 800x600
 3layer at (0,0) size 800x34
 4 RenderBlock {HTML} at (0,0) size 800x34
 5 RenderBody {BODY} at (8,8) size 784x18
 6 RenderBlock {DIV} at (0,0) size 784x18
 7 RenderText {#text} at (0,0) size 510x18
 8 text run at (0,0) width 510: "This tests proper handling of unicode-bidi: plaintext. You should not see any red."
 9layer at (8,26) size 102x400
 10 RenderBlock (positioned) {DIV} at (0,0) size 102x400
 11 RenderBlock {DIV} at (0,0) size 102x75 [color=#FF0000]
 12 RenderText {#text} at (0,0) size 44x18
 13 text run at (0,0) width 44: "!hello. "
 14 RenderBR {BR} at (44,0) size 0x18
 15 RenderText {#text} at (0,19) size 50x18
 16 text run at (0,19) width 50 RTL: "!\x{5E9}\x{5DC}\x{5D5}\x{5DD}. "
 17 RenderBR {BR} at (0,19) size 0x18
 18 RenderText {#text} at (0,38) size 67x18
 19 text run at (0,38) width 39: "hello, "
 20 text run at (39,38) width 19 RTL: "\x{5DC}\x{5D5}\x{5D9}"
 21 text run at (57,38) width 10: "! "
 22 RenderBR {BR} at (66,38) size 1x18
 23 RenderText {#text} at (0,57) size 100x18
 24 text run at (0,57) width 5 RTL: "!"
 25 text run at (5,57) width 50: "WebKit"
 26 text run at (55,57) width 45 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}, "
 27 RenderBlock {PRE} at (0,75) size 102x77 [color=#FF0000]
 28 RenderText {#text} at (0,0) size 102x77
 29 text run at (0,0) width 8: "a"
 30 text run at (8,0) width 0: " "
 31 text run at (0,15) width 8: "("
 32 text run at (8,15) width 0: " "
 33 text run at (0,31) width 0 RTL: " "
 34 text run at (0,31) width 8 RTL: "!"
 35 text run at (8,31) width 48: "WebKit"
 36 text run at (56,31) width 46 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}, "
 37 text run at (0,47) width 56: "hello, "
 38 text run at (56,47) width 16 RTL: "\x{5DC}\x{5D5}\x{5D9}"
 39 text run at (71,47) width 9: "!"
 40 text run at (79,47) width 1: " "
 41 text run at (0,62) width 8: ")"
 42 text run at (8,62) width 0: " "
 43layer at (8,26) size 102x400
 44 RenderBlock (positioned) {DIV} at (0,0) size 102x400 [color=#008000]
 45 RenderBlock (anonymous) at (0,0) size 102x75
 46 RenderText {#text} at (0,0) size 40x18
 47 text run at (0,0) width 40: "!hello."
 48 RenderBR {BR} at (40,0) size 0x18
 49 RenderInline {SPAN} at (0,0) size 50x18
 50 RenderText {#text} at (0,19) size 50x18
 51 text run at (0,19) width 50 RTL: "!\x{5E9}\x{5DC}\x{5D5}\x{5DD}. "
 52 RenderBR {BR} at (49,19) size 1x18
 53 RenderInline {SPAN} at (0,0) size 67x18
 54 RenderText {#text} at (0,38) size 67x18
 55 text run at (0,38) width 39: "hello, "
 56 text run at (39,38) width 19 RTL: "\x{5DC}\x{5D5}\x{5D9}"
 57 text run at (57,38) width 10: "! "
 58 RenderBR {BR} at (66,38) size 1x18
 59 RenderInline {SPAN} at (0,0) size 100x18
 60 RenderText {#text} at (0,57) size 100x18
 61 text run at (0,57) width 5 RTL: "!"
 62 text run at (5,57) width 50: "WebKit"
 63 text run at (55,57) width 45 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}, "
 64 RenderBR {BR} at (99,57) size 1x18
 65 RenderBlock {PRE} at (0,75) size 102x77
 66 RenderText {#text} at (0,0) size 102x77
 67 text run at (0,0) width 8: "a"
 68 text run at (8,0) width 0: " "
 69 text run at (0,15) width 8: "("
 70 text run at (8,15) width 0: " "
 71 text run at (0,31) width 72: "!WebKit ,"
 72 text run at (72,31) width 30 RTL: "\x{5E9}\x{5DC}\x{5D5}\x{5DD}"
 73 text run at (101,31) width 1: " "
 74 text run at (0,47) width 56: "hello, "
 75 text run at (56,47) width 16 RTL: "\x{5DC}\x{5D5}\x{5D9}"
 76 text run at (71,47) width 9: "!"
 77 text run at (79,47) width 1: " "
 78 text run at (0,62) width 8: ")"
 79 text run at (8,62) width 0: " "
0

LayoutTests/platform/mac/fast/text/international/unicode-bidi-plaintext-expected.png

6ee5c82763c2f5f0bc79a0f49b73bbf2