Changeset 109806 in webkit


Ignore:
Timestamp:
Mar 5, 2012 3:09:22 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

unicode-bidi should support isolate override and override isolate
https://bugs.webkit.org/show_bug.cgi?id=73164

Reviewed by Eric Seidel.

Source/WebCore:

Updated CSS parser and CSS style selector to support the union of bidi-override and isolate in
unicode-bidi property. Added OverrideIsolate to EUnicodeBidi instead of turning Override and Isolate
into bit flags to avoid increasing the number of bits required to store the unicodeBidi flag.

Also fixed a bug in RenderBlock::constructTextRun to actually check whether an isolated run's direction
is overridden or not when constructing one.

Tests: fast/css/unicode-bidi-computed-value.html

fast/text/bidi-override-isolate.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::renderUnicodeBidiFlagsToCSSValue): Added; Create a CSSValueList when unicode-bidi has both
isolate and bidi-override specified.
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Calls renderUnicodeBidiFlagsToCSSValue.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue): Support parsing combinations of -webkit-isolate and bidi-override;
Create a CSSValueList in such cases.

  • css/CSSPrimitiveValueMappings.h:

(WebCore):

  • css/CSSStyleApplyProperty.cpp:

(ApplyPropertyUnicodeBidi):
(WebCore::ApplyPropertyUnicodeBidi::applyValue): Support combinations of -webkit-isolate and
bidi-override. Set the unicodeBidi flag to OverrideIsolate in such cases.
(WebCore::ApplyPropertyUnicodeBidi::createHandler):
(WebCore):
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::drawTextInternal):

  • platform/text/UnicodeBidi.h: Added OverrideIsolate. We don't use bit flags to avoid increasing the

number of bits required to store flags especially because isolate and bidi-override are only values
that can be combined.
(WebCore::isIsolated):
(WebCore):
(WebCore::isOverride):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::constructTextRun):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::statusWithDirection): Takes isOverride; we used to assume it's always false.
(WebCore::constructBidiRuns): Instantiate isolatedResolver with a proper value of isOverride.
(WebCore::RenderBlock::layoutRunsAndFloatsInRange):
(WebCore::RenderBlock::determineStartPosition):

  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::paintItemForeground):

  • rendering/RenderMenuList.cpp:

(WebCore::RenderMenuList::itemStyle):
(WebCore::RenderMenuList::menuStyle):

  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::menuStyle):

  • rendering/svg/SVGTextMetrics.cpp:

(WebCore::SVGTextMetrics::constructTextRun):

LayoutTests:

Added a test for retrieving computed value of unicode-bidi property
and also added a test to render "unicode-bidi: -webkit-isolate bidi-override".

  • fast/css/unicode-bidi-computed-value-expected.txt: Added.
  • fast/css/unicode-bidi-computed-value.html: Added.
  • fast/text/bidi-override-isolate-expected.html: Added.
  • fast/text/bidi-override-isolate.html: Added.
Location:
trunk
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109799 r109806  
     12012-03-02  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        unicode-bidi should support isolate override and override isolate
     4        https://bugs.webkit.org/show_bug.cgi?id=73164
     5
     6        Reviewed by Eric Seidel.
     7
     8        Added a test for retrieving computed value of unicode-bidi property
     9        and also added a test to render "unicode-bidi: -webkit-isolate bidi-override".
     10
     11        * fast/css/unicode-bidi-computed-value-expected.txt: Added.
     12        * fast/css/unicode-bidi-computed-value.html: Added.
     13        * fast/text/bidi-override-isolate-expected.html: Added.
     14        * fast/text/bidi-override-isolate.html: Added.
     15
    1162012-03-05  Tony Chang  <tony@chromium.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r109805 r109806  
     12012-03-05  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        unicode-bidi should support isolate override and override isolate
     4        https://bugs.webkit.org/show_bug.cgi?id=73164
     5
     6        Reviewed by Eric Seidel.
     7
     8        Updated CSS parser and CSS style selector to support the union of bidi-override and isolate in
     9        unicode-bidi property. Added OverrideIsolate to EUnicodeBidi instead of turning Override and Isolate
     10        into bit flags to avoid increasing the number of bits required to store the unicodeBidi flag.
     11
     12        Also fixed a bug in RenderBlock::constructTextRun to actually check whether an isolated run's direction
     13        is overridden or not when constructing one.
     14
     15        Tests: fast/css/unicode-bidi-computed-value.html
     16               fast/text/bidi-override-isolate.html
     17
     18        * css/CSSComputedStyleDeclaration.cpp:
     19        (WebCore::renderUnicodeBidiFlagsToCSSValue): Added; Create a CSSValueList when unicode-bidi has both
     20        isolate and bidi-override specified.
     21        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):  Calls renderUnicodeBidiFlagsToCSSValue.
     22        * css/CSSParser.cpp:
     23        (WebCore::CSSParser::parseValue): Support parsing combinations of -webkit-isolate and bidi-override;
     24        Create a CSSValueList in such cases.
     25        * css/CSSPrimitiveValueMappings.h:
     26        (WebCore):
     27        * css/CSSStyleApplyProperty.cpp:
     28        (ApplyPropertyUnicodeBidi):
     29        (WebCore::ApplyPropertyUnicodeBidi::applyValue): Support combinations of -webkit-isolate and
     30        bidi-override. Set the unicodeBidi flag to OverrideIsolate in such cases.
     31        (WebCore::ApplyPropertyUnicodeBidi::createHandler):
     32        (WebCore):
     33        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
     34        * html/canvas/CanvasRenderingContext2D.cpp:
     35        (WebCore::CanvasRenderingContext2D::drawTextInternal):
     36        * platform/text/UnicodeBidi.h: Added OverrideIsolate. We don't use bit flags to avoid increasing the
     37        number of bits required to store flags especially because isolate and bidi-override are only values
     38        that can be combined.
     39        (WebCore::isIsolated):
     40        (WebCore):
     41        (WebCore::isOverride):
     42        * rendering/RenderBlock.cpp:
     43        (WebCore::RenderBlock::constructTextRun):
     44        * rendering/RenderBlockLineLayout.cpp:
     45        (WebCore::statusWithDirection): Takes isOverride; we used to assume it's always false.
     46        (WebCore::constructBidiRuns): Instantiate isolatedResolver with a proper value of isOverride.
     47        (WebCore::RenderBlock::layoutRunsAndFloatsInRange):
     48        (WebCore::RenderBlock::determineStartPosition):
     49        * rendering/RenderListBox.cpp:
     50        (WebCore::RenderListBox::paintItemForeground):
     51        * rendering/RenderMenuList.cpp:
     52        (WebCore::RenderMenuList::itemStyle):
     53        (WebCore::RenderMenuList::menuStyle):
     54        * rendering/RenderTextControlSingleLine.cpp:
     55        (WebCore::RenderTextControlSingleLine::menuStyle):
     56        * rendering/svg/SVGTextMetrics.cpp:
     57        (WebCore::SVGTextMetrics::constructTextRun):
     58
    1592012-03-05  Emil A Eklund  <eae@chromium.org>
    260
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r109785 r109806  
    11291129}
    11301130
     1131static PassRefPtr<CSSValue> renderUnicodeBidiFlagsToCSSValue(EUnicodeBidi unicodeBidi, CSSValuePool* cssValuePool)
     1132{
     1133    switch (unicodeBidi) {
     1134    case UBNormal:
     1135        return cssValuePool->createIdentifierValue(CSSValueNormal);
     1136    case Embed:
     1137        return cssValuePool->createIdentifierValue(CSSValueEmbed);
     1138    case Plaintext:
     1139        return cssValuePool->createIdentifierValue(CSSValueWebkitPlaintext);
     1140    case Override:
     1141        return cssValuePool->createIdentifierValue(CSSValueBidiOverride);
     1142    case Isolate:
     1143        return cssValuePool->createIdentifierValue(CSSValueWebkitIsolate);
     1144    case OverrideIsolate:
     1145    {
     1146        RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     1147        list->append(cssValuePool->createIdentifierValue(CSSValueBidiOverride));
     1148        list->append(cssValuePool->createIdentifierValue(CSSValueWebkitIsolate));
     1149        return list;
     1150    }
     1151    }
     1152    ASSERT_NOT_REACHED();
     1153    return 0;
     1154}
     1155
    11311156static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration, CSSValuePool* cssValuePool)
    11321157{
     
    18981923            return getPositionOffsetValue(style.get(), CSSPropertyTop, cssValuePool);
    18991924        case CSSPropertyUnicodeBidi:
    1900             return cssValuePool->createValue(style->unicodeBidi());
     1925            return renderUnicodeBidiFlagsToCSSValue(style->unicodeBidi(), cssValuePool);
    19011926        case CSSPropertyVerticalAlign:
    19021927            switch (style->verticalAlign()) {
  • trunk/Source/WebCore/css/CSSParser.cpp

    r109785 r109806  
    969969            return parseQuotes(propId, important);
    970970        break;
    971     case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | plaintext | inherit
     971    case CSSPropertyUnicodeBidi: // normal | embed | (bidi-override || isolate) | plaintext | inherit
    972972        if (id == CSSValueNormal
    973973            || id == CSSValueEmbed
    974             || id == CSSValueBidiOverride
    975             || id == CSSValueWebkitIsolate
    976974            || id == CSSValueWebkitPlaintext)
    977975            validPrimitive = true;
     976        else {
     977            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     978            bool isValid = true;
     979            while (isValid && value) {
     980                switch (value->id) {
     981                case CSSValueBidiOverride:
     982                case CSSValueWebkitIsolate:
     983                    list->append(cssValuePool()->createIdentifierValue(value->id));
     984                    break;
     985                default:
     986                    isValid = false;
     987                }
     988                value = m_valueList->next();
     989            }
     990            if (list->length() && isValid) {
     991                parsedValue = list.release();
     992                m_valueList->next();
     993            }
     994        }
    978995        break;
    979996
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r109231 r109806  
    22072207}
    22082208
    2209 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUnicodeBidi e)
    2210     : CSSValue(PrimitiveClass)
    2211 {
    2212     m_primitiveUnitType = CSS_IDENT;
    2213     switch (e) {
    2214     case UBNormal:
    2215         m_value.ident = CSSValueNormal;
    2216         break;
    2217     case Embed:
    2218         m_value.ident = CSSValueEmbed;
    2219         break;
    2220     case Override:
    2221         m_value.ident = CSSValueBidiOverride;
    2222         break;
    2223     case Isolate:
    2224         m_value.ident = CSSValueWebkitIsolate;
    2225         break;
    2226     case Plaintext:
    2227         m_value.ident = CSSValueWebkitPlaintext;
    2228         break;
    2229     }
    2230 }
    2231 
    22322209template<> inline CSSPrimitiveValue::operator EUnicodeBidi() const
    22332210{
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r109785 r109806  
    11411141    {
    11421142        PropertyHandler handler = ApplyPropertyDefaultBase<ETextDecoration, &RenderStyle::textDecoration, ETextDecoration, &RenderStyle::setTextDecoration, ETextDecoration, &RenderStyle::initialTextDecoration>::createHandler();
     1143        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
     1144    }
     1145};
     1146
     1147class ApplyPropertyUnicodeBidi {
     1148public:
     1149    static void applyValue(CSSStyleSelector* selector, CSSValue* value)
     1150    {
     1151        if (value->isValueList()) {
     1152            EUnicodeBidi rendererUnicodeBidi = RenderStyle::initialUnicodeBidi();
     1153            for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
     1154                CSSValue* item = i.value();
     1155                ASSERT(item->isPrimitiveValue());
     1156                EUnicodeBidi currentValue = *static_cast<CSSPrimitiveValue*>(item);
     1157                ASSERT(currentValue == Override || currentValue == Isolate);
     1158                if (currentValue != rendererUnicodeBidi && rendererUnicodeBidi != RenderStyle::initialUnicodeBidi())
     1159                    rendererUnicodeBidi = OverrideIsolate;
     1160                else
     1161                    rendererUnicodeBidi = currentValue;
     1162            }
     1163            selector->style()->setUnicodeBidi(rendererUnicodeBidi);
     1164        }
     1165        if (!value->isPrimitiveValue())
     1166            return;
     1167        CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     1168        selector->style()->setUnicodeBidi(*primitiveValue);
     1169    }
     1170    static PropertyHandler createHandler()
     1171    {
     1172        PropertyHandler handler = ApplyPropertyDefaultBase<EUnicodeBidi, &RenderStyle::unicodeBidi, EUnicodeBidi, &RenderStyle::setUnicodeBidi, EUnicodeBidi, &RenderStyle::initialUnicodeBidi>::createHandler();
    11431173        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    11441174    }
     
    17951825    setPropertyHandler(CSSPropertyTextTransform, ApplyPropertyDefault<ETextTransform, &RenderStyle::textTransform, ETextTransform, &RenderStyle::setTextTransform, ETextTransform, &RenderStyle::initialTextTransform>::createHandler());
    17961826    setPropertyHandler(CSSPropertyTop, ApplyPropertyLength<&RenderStyle::top, &RenderStyle::setTop, &RenderStyle::initialOffset, AutoEnabled>::createHandler());
    1797     setPropertyHandler(CSSPropertyUnicodeBidi, ApplyPropertyDefault<EUnicodeBidi, &RenderStyle::unicodeBidi, EUnicodeBidi, &RenderStyle::setUnicodeBidi, EUnicodeBidi, &RenderStyle::initialUnicodeBidi>::createHandler());
     1827    setPropertyHandler(CSSPropertyUnicodeBidi, ApplyPropertyUnicodeBidi::createHandler());
    17981828    setPropertyHandler(CSSPropertyVerticalAlign, ApplyPropertyVerticalAlign::createHandler());
    17991829    setPropertyHandler(CSSPropertyVisibility, ApplyPropertyDefault<EVisibility, &RenderStyle::visibility, EVisibility, &RenderStyle::setVisibility, EVisibility, &RenderStyle::initialVisibility>::createHandler());
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r109062 r109806  
    20292029    TextDirection direction = computedStyle ? computedStyle->direction() : LTR;
    20302030    bool isRTL = direction == RTL;
    2031     bool override = computedStyle ? computedStyle->unicodeBidi() == Override : false;
     2031    bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
    20322032
    20332033    unsigned length = text.length();
  • trunk/Source/WebCore/platform/text/UnicodeBidi.h

    r107000 r109806  
    3434    Override,
    3535    Isolate,
    36     Plaintext
     36    Plaintext,
     37    OverrideIsolate,
    3738};
    3839
    3940inline bool isIsolated(const EUnicodeBidi& unicodeBidi)
    4041{
    41     return unicodeBidi == Isolate || unicodeBidi == Plaintext;
     42    return unicodeBidi == Isolate || unicodeBidi == OverrideIsolate || unicodeBidi == Plaintext;
     43}
     44
     45inline bool isOverride(EUnicodeBidi unicodeBidi)
     46{
     47    return unicodeBidi == Override || unicodeBidi == OverrideIsolate;
    4248}
    4349
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r109805 r109806  
    73457345            textDirection = style->direction();
    73467346        if (flags & RespectDirectionOverride)
    7347             directionalOverride |= style->unicodeBidi() == Override;
     7347            directionalOverride |= isOverride(style->unicodeBidi());
    73487348    }
    73497349
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r109378 r109806  
    944944
    945945// FIXME: This should be a BidiStatus constructor or create method.
    946 static inline BidiStatus statusWithDirection(TextDirection textDirection)
     946static inline BidiStatus statusWithDirection(TextDirection textDirection, bool isOverride)
    947947{
    948948    WTF::Unicode::Direction direction = textDirection == LTR ? LeftToRight : RightToLeft;
    949     RefPtr<BidiContext> context = BidiContext::create(textDirection == LTR ? 0 : 1, direction, false, FromStyleOrDOM);
     949    RefPtr<BidiContext> context = BidiContext::create(textDirection == LTR ? 0 : 1, direction, isOverride, FromStyleOrDOM);
    950950
    951951    // This copies BidiStatus and may churn the ref on BidiContext. I doubt it matters.
     
    981981            determineDirectionality(direction, InlineIterator(isolatedInline, isolatedRun->object(), 0));
    982982        else {
    983             ASSERT(unicodeBidi == Isolate);
     983            ASSERT(unicodeBidi == Isolate || unicodeBidi == OverrideIsolate);
    984984            direction = isolatedInline->style()->direction();
    985985        }
    986         isolatedResolver.setStatus(statusWithDirection(direction));
     986        isolatedResolver.setStatus(statusWithDirection(direction, isOverride(unicodeBidi)));
    987987
    988988        // FIXME: The fact that we have to construct an Iterator here
     
    12731273                TextDirection direction = styleToUse->direction();
    12741274                determineDirectionality(direction, resolver.position());
    1275                 resolver.setStatus(BidiStatus(direction, styleToUse->unicodeBidi() == Override));
     1275                resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->unicodeBidi())));
    12761276            }
    12771277            // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine.
     
    16831683        if (style()->unicodeBidi() == Plaintext)
    16841684            determineDirectionality(direction, InlineIterator(this, bidiFirstSkippingEmptyInlines(this), 0));
    1685         resolver.setStatus(BidiStatus(direction, style()->unicodeBidi() == Override));
     1685        resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi())));
    16861686        InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines(this, &resolver), 0);
    16871687        resolver.setPosition(iter, numberOfIsolateAncestors(iter));
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r109378 r109806  
    410410    unsigned length = itemText.length();
    411411    const UChar* string = itemText.characters();
    412     TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), itemStyle->unicodeBidi() == Override, TextRun::NoRounding);
     412    TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), isOverride(itemStyle->unicodeBidi()), TextRun::NoRounding);
    413413    Font itemFont = style()->font();
    414414    LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex);
  • trunk/Source/WebCore/rendering/RenderMenuList.cpp

    r109785 r109806  
    448448   
    449449    RenderStyle* style = element->renderStyle() ? element->renderStyle() : element->computedStyle();
    450     return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor), itemBackgroundColor(listIndex), style->font(), style->visibility() == VISIBLE, style->display() == NONE, style->textIndent(), style->direction(), style->unicodeBidi() == Override) : menuStyle();
     450    return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor), itemBackgroundColor(listIndex), style->font(), style->visibility() == VISIBLE,
     451        style->display() == NONE, style->textIndent(), style->direction(), isOverride(style->unicodeBidi())) : menuStyle();
    451452}
    452453
     
    477478{
    478479    RenderStyle* s = m_innerBlock ? m_innerBlock->style() : style();
    479     return PopupMenuStyle(s->visitedDependentColor(CSSPropertyColor), s->visitedDependentColor(CSSPropertyBackgroundColor), s->font(), s->visibility() == VISIBLE, s->display() == NONE, s->textIndent(), style()->direction(), style()->unicodeBidi() == Override);
     480    return PopupMenuStyle(s->visitedDependentColor(CSSPropertyColor), s->visitedDependentColor(CSSPropertyBackgroundColor), s->font(), s->visibility() == VISIBLE,
     481        s->display() == NONE, s->textIndent(), style()->direction(), isOverride(style()->unicodeBidi()));
    480482}
    481483
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r109503 r109806  
    622622PopupMenuStyle RenderTextControlSingleLine::menuStyle() const
    623623{
    624     return PopupMenuStyle(style()->visitedDependentColor(CSSPropertyColor), style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->font(), style()->visibility() == VISIBLE, style()->display() == NONE, style()->textIndent(), style()->direction(), style()->unicodeBidi() == Override);
     624    return PopupMenuStyle(style()->visitedDependentColor(CSSPropertyColor), style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->font(), style()->visibility() == VISIBLE,
     625        style()->display() == NONE, style()->textIndent(), style()->direction(), isOverride(style()->unicodeBidi()));
    625626}
    626627
  • trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp

    r104683 r109806  
    7676                , TextRun::AllowTrailingExpansion
    7777                , style->direction()
    78                 , style->unicodeBidi() == Override /* directionalOverride */);
     78                , isOverride(style->unicodeBidi()) /* directionalOverride */);
    7979
    8080    if (textRunNeedsRenderingContext(style->font()))
Note: See TracChangeset for help on using the changeset viewer.