Changeset 91336 in webkit
- Timestamp:
- Jul 19, 2011 10:41:16 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r91333 r91336 1 2011-07-19 Luke Macpherson <macpherson@chromium.org> 2 3 Implement CSSPropertyCounterIncrement and CounterReset in CSSStyleApplyProperty. 4 https://bugs.webkit.org/show_bug.cgi?id=64846 5 6 Reviewed by Dimitri Glazkov. 7 8 No new tests / refactoring only. 9 10 * css/CSSStyleApplyProperty.cpp: 11 (WebCore::ApplyPropertyCounter 12 Added class to handle counter properties. 13 (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): 14 Initialize counter property handlers. 15 * css/CSSStyleSelector.cpp: 16 (WebCore::CSSStyleSelector::applyProperty): 17 Remove old handlers. 18 1 19 2011-07-19 Kent Tamura <tkent@chromium.org> 2 20 -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r91283 r91336 506 506 } 507 507 }; 508 509 enum CounterBehavior {Increment = 0, Reset}; 510 template <CounterBehavior counterBehavior> 511 class ApplyPropertyCounter : public ApplyPropertyBase { 512 private: 513 virtual void applyInheritValue(CSSStyleSelector*) const { } 514 virtual void applyInitialValue(CSSStyleSelector*) const { } 515 516 virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const 517 { 518 if (!value->isValueList()) 519 return; 520 521 CSSValueList* list = static_cast<CSSValueList*>(value); 522 523 CounterDirectiveMap& map = selector->style()->accessCounterDirectives(); 524 typedef CounterDirectiveMap::iterator Iterator; 525 526 Iterator end = map.end(); 527 for (Iterator it = map.begin(); it != end; ++it) 528 if (counterBehavior) 529 it->second.m_reset = false; 530 else 531 it->second.m_increment = false; 532 533 int length = list ? list->length() : 0; 534 for (int i = 0; i < length; ++i) { 535 CSSValue* currValue = list->itemWithoutBoundsCheck(i); 536 if (!currValue->isPrimitiveValue()) 537 continue; 538 539 Pair* pair = static_cast<CSSPrimitiveValue*>(currValue)->getPairValue(); 540 if (!pair || !pair->first() || !pair->second()) 541 continue; 542 543 AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue(); 544 // FIXME: What about overflow? 545 int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue(); 546 CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).first->second; 547 if (counterBehavior) { 548 directives.m_reset = true; 549 directives.m_resetValue = value; 550 } else { 551 if (directives.m_increment) 552 directives.m_incrementValue += value; 553 else { 554 directives.m_increment = true; 555 directives.m_incrementValue = value; 556 } 557 } 558 } 559 } 560 }; 561 508 562 509 563 class ApplyPropertyCursor : public ApplyPropertyBase { … … 669 723 setPropertyHandler(CSSPropertyCursor, new ApplyPropertyCursor()); 670 724 725 setPropertyHandler(CSSPropertyCounterIncrement, new ApplyPropertyCounter<Increment>()); 726 setPropertyHandler(CSSPropertyCounterReset, new ApplyPropertyCounter<Reset>()); 727 671 728 setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff)); 672 729 setPropertyHandler(CSSPropertyFontVariant, new ApplyPropertyFont<FontSmallCaps>(&FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff)); -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r91286 r91336 3563 3563 } 3564 3564 3565 static void applyCounterList(RenderStyle* style, CSSValueList* list, bool isReset)3566 {3567 CounterDirectiveMap& map = style->accessCounterDirectives();3568 typedef CounterDirectiveMap::iterator Iterator;3569 3570 Iterator end = map.end();3571 for (Iterator it = map.begin(); it != end; ++it)3572 if (isReset)3573 it->second.m_reset = false;3574 else3575 it->second.m_increment = false;3576 3577 int length = list ? list->length() : 0;3578 for (int i = 0; i < length; ++i) {3579 CSSValue* currValue = list->itemWithoutBoundsCheck(i);3580 if (!currValue->isPrimitiveValue())3581 continue;3582 3583 Pair* pair = static_cast<CSSPrimitiveValue*>(currValue)->getPairValue();3584 if (!pair || !pair->first() || !pair->second())3585 continue;3586 3587 AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();3588 // FIXME: What about overflow?3589 int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();3590 CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).first->second;3591 if (isReset) {3592 directives.m_reset = true;3593 directives.m_resetValue = value;3594 } else {3595 if (directives.m_increment)3596 directives.m_incrementValue += value;3597 else {3598 directives.m_increment = true;3599 directives.m_incrementValue = value;3600 }3601 }3602 }3603 }3604 3605 3565 void CSSStyleSelector::applyPropertyToStyle(int id, CSSValue *value, RenderStyle* style) 3606 3566 { … … 4188 4148 } 4189 4149 return; 4190 4191 case CSSPropertyCounterIncrement:4192 applyCounterList(style(), value->isValueList() ? static_cast<CSSValueList*>(value) : 0, false);4193 return;4194 case CSSPropertyCounterReset:4195 applyCounterList(style(), value->isValueList() ? static_cast<CSSValueList*>(value) : 0, true);4196 return;4197 4198 4150 case CSSPropertyFontFamily: { 4199 4151 // list of strings and ids … … 5334 5286 case CSSPropertyWebkitBorderHorizontalSpacing: 5335 5287 case CSSPropertyWebkitBorderVerticalSpacing: 5288 case CSSPropertyCounterIncrement: 5289 case CSSPropertyCounterReset: 5336 5290 case CSSPropertyLetterSpacing: 5337 5291 case CSSPropertyWordSpacing:
Note: See TracChangeset
for help on using the changeset viewer.