Changeset 89864 in webkit


Ignore:
Timestamp:
Jun 27, 2011 3:01:38 PM (13 years ago)
Author:
leviw@chromium.org
Message:

2011-06-27 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

Add support for unicode-bidi:plaintext CSS property
https://bugs.webkit.org/show_bug.cgi?id=50949
Adding support for the 'plaintext' mode of unicode-bidi.

  • fast/text/international/unicode-bidi-plaintext.html: Added.
  • platform/chromium-linux/fast/text/international/unicode-bidi-plaintext-expected.txt: added
  • platform/mac/fast/text/international/unicode-bidi-plaintext-expected.png: Added.
  • platform/mac/fast/text/international/unicode-bidi-plaintext-expected.txt: Added.

2011-06-27 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

Add support for unicode-bidi:plaintext CSS property
https://bugs.webkit.org/show_bug.cgi?id=50949

Adding support for unicode-bidi: plaintext. This involves invoking P2 and P3
of the Unicode BiDi algorithm on each paragraph of a block with that style.
This is similar to dir=auto but done per-paragraph instead of per element.

Test: fast/text/international/unicode-bidi-plaintext.html

  • css/CSSParser.cpp: (WebCore::CSSParser::parseValue): Added plaintext.
  • css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto. (WebCore::CSSPrimitiveValue::operator EUnicodeBidi): Ditto.
  • css/CSSValueKeywords.in: Ditto.
  • html/HTMLElement.cpp: (WebCore::unicodeBidiAttributeForDirAuto): Helper to map elements with dir=auto to their proper unicode-bidi attribute. (WebCore::HTMLElement::parseMappedAttribute): Assign plaintext to pre and textarea when dir=auto.
  • platform/text/UnicodeBidi.h: Added plaintext.
  • rendering/RenderBlockLineLayout.cpp: (WebCore::determineParagraphDirection): Determines the direction of a paragraph based on the first strong character. Stops at first paragraph separator. (WebCore::RenderBlock::layoutInlineChildren): Uses determineParagraphDirection when in unicode-bidi: plaintext mode (and operating at the block's BidiContext) to set each paragraph to the proper base BidiContext. (WebCore::RenderBlock::determineStartPosition): Ditto.
  • rendering/style/RenderStyle.h: Gave _unicodebidi another bit to accomodate for plaintext.
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89863 r89864  
     12011-06-27  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     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/chromium-linux/fast/text/international/unicode-bidi-plaintext-expected.txt: added
     11        * platform/mac/fast/text/international/unicode-bidi-plaintext-expected.png: Added.
     12        * platform/mac/fast/text/international/unicode-bidi-plaintext-expected.txt: Added.
     13
    1142011-06-27  Jessie Berlin  <jberlin@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r89858 r89864  
     12011-06-27  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     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-27  Alexis Menard  <alexis.menard@openbossa.org>
    237
  • trunk/Source/WebCore/css/CSSParser.cpp

    r89712 r89864  
    861861            return parseQuotes(propId, important);
    862862        break;
    863     case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | inherit
     863    case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | plaintext | inherit
    864864        if (id == CSSValueNormal
    865865            || id == CSSValueEmbed
    866866            || id == CSSValueBidiOverride
    867             || id == CSSValueWebkitIsolate)
     867            || id == CSSValueWebkitIsolate
     868            || id == CSSValueWebkitPlaintext)
    868869            validPrimitive = true;
    869870        break;
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r89495 r89864  
    17721772    case Isolate:
    17731773        m_value.ident = CSSValueWebkitIsolate;
     1774        break;
     1775    case Plaintext:
     1776        m_value.ident = CSSValueWebkitPlaintext;
     1777        break;
    17741778    }
    17751779}
     
    17861790    case CSSValueWebkitIsolate:
    17871791        return Isolate;
     1792    case CSSValueWebkitPlaintext:
     1793        return Plaintext;
    17881794    default:
    17891795        ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r89712 r89864  
    411411invert
    412412-webkit-isolate
     413-webkit-plaintext
    413414landscape
    414415ledger
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r87125 r89864  
    126126    return StyledElement::mapToEntry(attrName, result);
    127127}
    128    
     128
     129static inline 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{
     
    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();
  • trunk/Source/WebCore/platform/text/UnicodeBidi.h

    r82828 r89864  
    3333    Embed,
    3434    Override,
    35     Isolate
     35    Isolate,
     36    Plaintext
    3637};
    3738
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r89769 r89864  
    111111    }
    112112    return extraWidth;
     113}
     114
     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    }
    113133}
    114134
     
    945965
    946966        InlineIterator oldEnd = end;
     967        bool isNewUBAParagraph = lineInfo.previousLineBrokeCleanly();
    947968        FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0;
    948969        end = lineBreaker.nextLineBreak(resolver, lineInfo, lineBreakIteratorInfo, lastFloatFromPreviousLine);
     
    963984        } else {
    964985            VisualDirectionOverride override = (style()->rtlOrdering() == VisualOrder ? (style()->direction() == LTR ? VisualLeftToRightOverride : VisualRightToLeftOverride) : NoVisualOverride);
     986
     987            if (isNewUBAParagraph && style()->unicodeBidi() == Plaintext && !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();
     
    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    }
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r89142 r89864  
    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        // 53 bits
    262262    } noninherited_flags;
    263263
Note: See TracChangeset for help on using the changeset viewer.