Changeset 109806 in webkit
- Timestamp:
- Mar 5, 2012 3:09:22 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109799 r109806 1 2012-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 1 16 2012-03-05 Tony Chang <tony@chromium.org> 2 17 -
trunk/Source/WebCore/ChangeLog
r109805 r109806 1 2012-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 1 59 2012-03-05 Emil A Eklund <eae@chromium.org> 2 60 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r109785 r109806 1129 1129 } 1130 1130 1131 static 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 1131 1156 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration, CSSValuePool* cssValuePool) 1132 1157 { … … 1898 1923 return getPositionOffsetValue(style.get(), CSSPropertyTop, cssValuePool); 1899 1924 case CSSPropertyUnicodeBidi: 1900 return cssValuePool->createValue(style->unicodeBidi());1925 return renderUnicodeBidiFlagsToCSSValue(style->unicodeBidi(), cssValuePool); 1901 1926 case CSSPropertyVerticalAlign: 1902 1927 switch (style->verticalAlign()) { -
trunk/Source/WebCore/css/CSSParser.cpp
r109785 r109806 969 969 return parseQuotes(propId, important); 970 970 break; 971 case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate| plaintext | inherit971 case CSSPropertyUnicodeBidi: // normal | embed | (bidi-override || isolate) | plaintext | inherit 972 972 if (id == CSSValueNormal 973 973 || id == CSSValueEmbed 974 || id == CSSValueBidiOverride975 || id == CSSValueWebkitIsolate976 974 || id == CSSValueWebkitPlaintext) 977 975 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 } 978 995 break; 979 996 -
trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h
r109231 r109806 2207 2207 } 2208 2208 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 2232 2209 template<> inline CSSPrimitiveValue::operator EUnicodeBidi() const 2233 2210 { -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r109785 r109806 1141 1141 { 1142 1142 PropertyHandler handler = ApplyPropertyDefaultBase<ETextDecoration, &RenderStyle::textDecoration, ETextDecoration, &RenderStyle::setTextDecoration, ETextDecoration, &RenderStyle::initialTextDecoration>::createHandler(); 1143 return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); 1144 } 1145 }; 1146 1147 class ApplyPropertyUnicodeBidi { 1148 public: 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(); 1143 1173 return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); 1144 1174 } … … 1795 1825 setPropertyHandler(CSSPropertyTextTransform, ApplyPropertyDefault<ETextTransform, &RenderStyle::textTransform, ETextTransform, &RenderStyle::setTextTransform, ETextTransform, &RenderStyle::initialTextTransform>::createHandler()); 1796 1826 setPropertyHandler(CSSPropertyTop, ApplyPropertyLength<&RenderStyle::top, &RenderStyle::setTop, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); 1797 setPropertyHandler(CSSPropertyUnicodeBidi, ApplyProperty Default<EUnicodeBidi, &RenderStyle::unicodeBidi, EUnicodeBidi, &RenderStyle::setUnicodeBidi, EUnicodeBidi, &RenderStyle::initialUnicodeBidi>::createHandler());1827 setPropertyHandler(CSSPropertyUnicodeBidi, ApplyPropertyUnicodeBidi::createHandler()); 1798 1828 setPropertyHandler(CSSPropertyVerticalAlign, ApplyPropertyVerticalAlign::createHandler()); 1799 1829 setPropertyHandler(CSSPropertyVisibility, ApplyPropertyDefault<EVisibility, &RenderStyle::visibility, EVisibility, &RenderStyle::setVisibility, EVisibility, &RenderStyle::initialVisibility>::createHandler()); -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r109062 r109806 2029 2029 TextDirection direction = computedStyle ? computedStyle->direction() : LTR; 2030 2030 bool isRTL = direction == RTL; 2031 bool override = computedStyle ? computedStyle->unicodeBidi() == Override: false;2031 bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false; 2032 2032 2033 2033 unsigned length = text.length(); -
trunk/Source/WebCore/platform/text/UnicodeBidi.h
r107000 r109806 34 34 Override, 35 35 Isolate, 36 Plaintext 36 Plaintext, 37 OverrideIsolate, 37 38 }; 38 39 39 40 inline bool isIsolated(const EUnicodeBidi& unicodeBidi) 40 41 { 41 return unicodeBidi == Isolate || unicodeBidi == Plaintext; 42 return unicodeBidi == Isolate || unicodeBidi == OverrideIsolate || unicodeBidi == Plaintext; 43 } 44 45 inline bool isOverride(EUnicodeBidi unicodeBidi) 46 { 47 return unicodeBidi == Override || unicodeBidi == OverrideIsolate; 42 48 } 43 49 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r109805 r109806 7345 7345 textDirection = style->direction(); 7346 7346 if (flags & RespectDirectionOverride) 7347 directionalOverride |= style->unicodeBidi() == Override;7347 directionalOverride |= isOverride(style->unicodeBidi()); 7348 7348 } 7349 7349 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r109378 r109806 944 944 945 945 // FIXME: This should be a BidiStatus constructor or create method. 946 static inline BidiStatus statusWithDirection(TextDirection textDirection )946 static inline BidiStatus statusWithDirection(TextDirection textDirection, bool isOverride) 947 947 { 948 948 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); 950 950 951 951 // This copies BidiStatus and may churn the ref on BidiContext. I doubt it matters. … … 981 981 determineDirectionality(direction, InlineIterator(isolatedInline, isolatedRun->object(), 0)); 982 982 else { 983 ASSERT(unicodeBidi == Isolate );983 ASSERT(unicodeBidi == Isolate || unicodeBidi == OverrideIsolate); 984 984 direction = isolatedInline->style()->direction(); 985 985 } 986 isolatedResolver.setStatus(statusWithDirection(direction ));986 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(unicodeBidi))); 987 987 988 988 // FIXME: The fact that we have to construct an Iterator here … … 1273 1273 TextDirection direction = styleToUse->direction(); 1274 1274 determineDirectionality(direction, resolver.position()); 1275 resolver.setStatus(BidiStatus(direction, styleToUse->unicodeBidi() == Override));1275 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->unicodeBidi()))); 1276 1276 } 1277 1277 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. … … 1683 1683 if (style()->unicodeBidi() == Plaintext) 1684 1684 determineDirectionality(direction, InlineIterator(this, bidiFirstSkippingEmptyInlines(this), 0)); 1685 resolver.setStatus(BidiStatus(direction, style()->unicodeBidi() == Override));1685 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi()))); 1686 1686 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines(this, &resolver), 0); 1687 1687 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r109378 r109806 410 410 unsigned length = itemText.length(); 411 411 const UChar* string = itemText.characters(); 412 TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), i temStyle->unicodeBidi() == Override, TextRun::NoRounding);412 TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), isOverride(itemStyle->unicodeBidi()), TextRun::NoRounding); 413 413 Font itemFont = style()->font(); 414 414 LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex); -
trunk/Source/WebCore/rendering/RenderMenuList.cpp
r109785 r109806 448 448 449 449 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(); 451 452 } 452 453 … … 477 478 { 478 479 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())); 480 482 } 481 483 -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r109503 r109806 622 622 PopupMenuStyle RenderTextControlSingleLine::menuStyle() const 623 623 { 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())); 625 626 } 626 627 -
trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
r104683 r109806 76 76 , TextRun::AllowTrailingExpansion 77 77 , style->direction() 78 , style->unicodeBidi() == Override/* directionalOverride */);78 , isOverride(style->unicodeBidi()) /* directionalOverride */); 79 79 80 80 if (textRunNeedsRenderingContext(style->font()))
Note: See TracChangeset
for help on using the changeset viewer.