Changeset 16721 in webkit


Ignore:
Timestamp:
Oct 2, 2006 4:15:31 PM (18 years ago)
Author:
bdakin
Message:

Reviewed by Darin.

Initial implementation of CSS2 counters. See http://
bugs.webkit.org/show_bug.cgi?id=4980 for more details.

  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Return the increment/reset list now that this is implemented.
  • css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::cssText):
  • css/Counter.h: (WebCore::Counter::Counter): (WebCore::Counter::~Counter): (WebCore::Counter::identifier): (WebCore::Counter::listStyle): (WebCore::Counter::separator): (WebCore::Counter::listStyleNumber): (WebCore::Counter::setIdentifier): (WebCore::Counter::setListStyle): (WebCore::Counter::setSeparator):
  • css/cssparser.cpp: (WebCore::CSSParser::addProperty): Take care of reset/increment (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseContent): content can now take counters (WebCore::CSSParser::parseCounterContent): Parse counter() and counters() (WebCore::CSSParser::parseCounter): Parse counter-reset and counter-increment
  • css/cssparser.h:
  • css/cssstyleselector.cpp: (WebCore::CSSStyleSelector::matchUARules): (WebCore::CSSStyleSelector::applyProperty):
  • platform/PlatformString.h:
  • platform/String.cpp: (WebCore::String::insert): Implemented a version of insert that accepts a UChar* and a length.
  • platform/StringImpl.cpp: (WebCore::StringImpl::insert): Same as above.
  • platform/StringImpl.h:
  • rendering/CounterListItem.h: Added.
  • rendering/CounterNode.cpp: Added. (WebCore::CounterNode::CounterNode): (WebCore::CounterNode::insertAfter): (WebCore::CounterNode::removeChild): (WebCore::CounterNode::remove): (WebCore::CounterNode::setUsesSeparator): (WebCore::CounterNode::recountAndGetNext): (WebCore::CounterNode::recountTree): (WebCore::CounterNode::setSelfDirty): (WebCore::CounterNode::setParentDirty):
  • rendering/CounterNode.h: Added. (WebCore::CounterNode::~CounterNode): (WebCore::CounterNode::parent): (WebCore::CounterNode::previousSibling): (WebCore::CounterNode::nextSibling): (WebCore::CounterNode::firstChild): (WebCore::CounterNode::lastChild): (WebCore::CounterNode::value): (WebCore::CounterNode::setValue): (WebCore::CounterNode::count): (WebCore::CounterNode::setCount): (WebCore::CounterNode::setHasSeparator): (WebCore::CounterNode::isReset): (WebCore::CounterNode::hasSeparator): (WebCore::CounterNode::willNeedLayout): (WebCore::CounterNode::setWillNeedLayout): (WebCore::CounterNode::isRoot): (WebCore::CounterNode::setRenderer): (WebCore::CounterNode::renderer):
  • rendering/CounterResetNode.cpp: Added. (WebCore::CounterResetNode::CounterResetNode): (WebCore::CounterResetNode::insertAfter): (WebCore::CounterResetNode::removeChild): (WebCore::CounterResetNode::recountAndGetNext): (WebCore::CounterResetNode::setParentDirty): (WebCore::CounterResetNode::updateTotal):
  • rendering/CounterResetNode.h: Added. (WebCore::CounterResetNode::firstChild): (WebCore::CounterResetNode::lastChild): (WebCore::CounterResetNode::isReset): (WebCore::CounterResetNode::total):
  • rendering/RenderContainer.cpp: (WebCore::RenderContainer::updatePseudoChildForObject): Account for counter content.
  • rendering/RenderCounter.cpp: Added. (WebCore::RenderCounter::RenderCounter): (WebCore::RenderCounter::layout): (WebCore::toRoman): (WebCore::toLetterString): (WebCore::toHebrew): (WebCore::RenderCounter::convertValueToType): (WebCore::RenderCounter::calcMinMaxWidth):
  • rendering/RenderCounter.h: Added. (WebCore::RenderCounter::renderName): (WebCore::RenderCounter::isCounter):
  • rendering/RenderObject.cpp: (WebCore::getRenderObjectsToCounterNodeMaps): Maps RenderObjects to maps of CounterNodes (WebCore::RenderObject::RenderObject): (WebCore::RenderObject::destroy): Destroy the maps. (WebCore::RenderObject::findCounter): Finds/creates counters.
  • rendering/RenderObject.h: (WebCore::RenderObject::isCounter):
  • rendering/RenderStyle.cpp: (WebCore::StyleVisualData::StyleVisualData): (WebCore::RenderStyle::arenaDelete): (WebCore::RenderStyle::RenderStyle): (WebCore::RenderStyle::diff): (WebCore::RenderStyle::setContent): (WebCore::ContentData::clearContent): (WebCore::RenderStyle::counterDataEquivalent): (WebCore::hasCounter): (WebCore::RenderStyle::hasCounterReset): (WebCore::RenderStyle::hasCounterIncrement): (WebCore::readCounter): (WebCore::RenderStyle::counterReset): (WebCore::RenderStyle::counterIncrement):
  • rendering/RenderStyle.h: (WebCore::StyleVisualData::operator==): (WebCore::CounterData::CounterData): (WebCore::CounterData::identifier): (WebCore::CounterData::listStyle): (WebCore::CounterData::separator): (WebCore::ContentData::contentCounter): (WebCore::ContentData::): (WebCore::RenderStyle::counterIncrement): (WebCore::RenderStyle::counterReset): (WebCore::RenderStyle::setCounterIncrement): (WebCore::RenderStyle::setCounterReset): (WebCore::RenderStyle::setCounterResetList): (WebCore::RenderStyle::setCounterIncrementList): (WebCore::RenderStyle::counterResetValueList): (WebCore::RenderStyle::counterIncrementValueList):
Location:
trunk/WebCore
Files:
7 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r16718 r16721  
     12006-10-02  Beth Dakin  <bdakin@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Initial implementation of CSS2 counters. See http://
     6        bugs.webkit.org/show_bug.cgi?id=4980 for more details.
     7
     8        * WebCore.xcodeproj/project.pbxproj:
     9        * css/CSSComputedStyleDeclaration.cpp:
     10        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Return
     11        the increment/reset list now that this is implemented.
     12        * css/CSSPrimitiveValue.cpp:
     13        (WebCore::CSSPrimitiveValue::cssText):
     14        * css/Counter.h:
     15        (WebCore::Counter::Counter):
     16        (WebCore::Counter::~Counter):
     17        (WebCore::Counter::identifier):
     18        (WebCore::Counter::listStyle):
     19        (WebCore::Counter::separator):
     20        (WebCore::Counter::listStyleNumber):
     21        (WebCore::Counter::setIdentifier):
     22        (WebCore::Counter::setListStyle):
     23        (WebCore::Counter::setSeparator):
     24        * css/cssparser.cpp:
     25        (WebCore::CSSParser::addProperty): Take care of reset/increment
     26        (WebCore::CSSParser::parseValue):
     27        (WebCore::CSSParser::parseContent): content can now take counters
     28        (WebCore::CSSParser::parseCounterContent): Parse counter() and
     29        counters()
     30        (WebCore::CSSParser::parseCounter): Parse counter-reset and
     31        counter-increment
     32        * css/cssparser.h:
     33        * css/cssstyleselector.cpp:
     34        (WebCore::CSSStyleSelector::matchUARules):
     35        (WebCore::CSSStyleSelector::applyProperty):
     36        * platform/PlatformString.h:
     37        * platform/String.cpp:
     38        (WebCore::String::insert): Implemented a version of insert that
     39        accepts a UChar* and a length.
     40        * platform/StringImpl.cpp:
     41        (WebCore::StringImpl::insert): Same as above.
     42        * platform/StringImpl.h:
     43        * rendering/CounterListItem.h: Added.
     44        * rendering/CounterNode.cpp: Added.
     45        (WebCore::CounterNode::CounterNode):
     46        (WebCore::CounterNode::insertAfter):
     47        (WebCore::CounterNode::removeChild):
     48        (WebCore::CounterNode::remove):
     49        (WebCore::CounterNode::setUsesSeparator):
     50        (WebCore::CounterNode::recountAndGetNext):
     51        (WebCore::CounterNode::recountTree):
     52        (WebCore::CounterNode::setSelfDirty):
     53        (WebCore::CounterNode::setParentDirty):
     54        * rendering/CounterNode.h: Added.
     55        (WebCore::CounterNode::~CounterNode):
     56        (WebCore::CounterNode::parent):
     57        (WebCore::CounterNode::previousSibling):
     58        (WebCore::CounterNode::nextSibling):
     59        (WebCore::CounterNode::firstChild):
     60        (WebCore::CounterNode::lastChild):
     61        (WebCore::CounterNode::value):
     62        (WebCore::CounterNode::setValue):
     63        (WebCore::CounterNode::count):
     64        (WebCore::CounterNode::setCount):
     65        (WebCore::CounterNode::setHasSeparator):
     66        (WebCore::CounterNode::isReset):
     67        (WebCore::CounterNode::hasSeparator):
     68        (WebCore::CounterNode::willNeedLayout):
     69        (WebCore::CounterNode::setWillNeedLayout):
     70        (WebCore::CounterNode::isRoot):
     71        (WebCore::CounterNode::setRenderer):
     72        (WebCore::CounterNode::renderer):
     73        * rendering/CounterResetNode.cpp: Added.
     74        (WebCore::CounterResetNode::CounterResetNode):
     75        (WebCore::CounterResetNode::insertAfter):
     76        (WebCore::CounterResetNode::removeChild):
     77        (WebCore::CounterResetNode::recountAndGetNext):
     78        (WebCore::CounterResetNode::setParentDirty):
     79        (WebCore::CounterResetNode::updateTotal):
     80        * rendering/CounterResetNode.h: Added.
     81        (WebCore::CounterResetNode::firstChild):
     82        (WebCore::CounterResetNode::lastChild):
     83        (WebCore::CounterResetNode::isReset):
     84        (WebCore::CounterResetNode::total):
     85        * rendering/RenderContainer.cpp:
     86        (WebCore::RenderContainer::updatePseudoChildForObject): Account for
     87        counter content.
     88        * rendering/RenderCounter.cpp: Added.
     89        (WebCore::RenderCounter::RenderCounter):
     90        (WebCore::RenderCounter::layout):
     91        (WebCore::toRoman):
     92        (WebCore::toLetterString):
     93        (WebCore::toHebrew):
     94        (WebCore::RenderCounter::convertValueToType):
     95        (WebCore::RenderCounter::calcMinMaxWidth):
     96        * rendering/RenderCounter.h: Added.
     97        (WebCore::RenderCounter::renderName):
     98        (WebCore::RenderCounter::isCounter):
     99        * rendering/RenderObject.cpp:
     100        (WebCore::getRenderObjectsToCounterNodeMaps): Maps RenderObjects to
     101        maps of CounterNodes
     102        (WebCore::RenderObject::RenderObject):
     103        (WebCore::RenderObject::destroy): Destroy the maps.
     104        (WebCore::RenderObject::findCounter): Finds/creates counters.
     105        * rendering/RenderObject.h:
     106        (WebCore::RenderObject::isCounter):
     107        * rendering/RenderStyle.cpp:
     108        (WebCore::StyleVisualData::StyleVisualData):
     109        (WebCore::RenderStyle::arenaDelete):
     110        (WebCore::RenderStyle::RenderStyle):
     111        (WebCore::RenderStyle::diff):
     112        (WebCore::RenderStyle::setContent):
     113        (WebCore::ContentData::clearContent):
     114        (WebCore::RenderStyle::counterDataEquivalent):
     115        (WebCore::hasCounter):
     116        (WebCore::RenderStyle::hasCounterReset):
     117        (WebCore::RenderStyle::hasCounterIncrement):
     118        (WebCore::readCounter):
     119        (WebCore::RenderStyle::counterReset):
     120        (WebCore::RenderStyle::counterIncrement):
     121        * rendering/RenderStyle.h:
     122        (WebCore::StyleVisualData::operator==):
     123        (WebCore::CounterData::CounterData):
     124        (WebCore::CounterData::identifier):
     125        (WebCore::CounterData::listStyle):
     126        (WebCore::CounterData::separator):
     127        (WebCore::ContentData::contentCounter):
     128        (WebCore::ContentData::):
     129        (WebCore::RenderStyle::counterIncrement):
     130        (WebCore::RenderStyle::counterReset):
     131        (WebCore::RenderStyle::setCounterIncrement):
     132        (WebCore::RenderStyle::setCounterReset):
     133        (WebCore::RenderStyle::setCounterResetList):
     134        (WebCore::RenderStyle::setCounterIncrementList):
     135        (WebCore::RenderStyle::counterResetValueList):
     136        (WebCore::RenderStyle::counterIncrementValueList):
     137
    11382006-10-02  Adele Peterson  <adele@apple.com>
    2139
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r16691 r16721  
    10891089                938E683C09F0BD7B008A48EC /* GraphicsTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 938E683B09F0BD7A008A48EC /* GraphicsTypes.h */; };
    10901090                938E685409F0BE04008A48EC /* GraphicsTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 938E685309F0BE04008A48EC /* GraphicsTypes.cpp */; };
     1091                9392F1420AD185F400691BD4 /* RenderCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392F1410AD185F400691BD4 /* RenderCounter.h */; };
     1092                9392F1440AD185FE00691BD4 /* RenderCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392F1430AD185FE00691BD4 /* RenderCounter.cpp */; };
     1093                9392F1460AD1860C00691BD4 /* CounterResetNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392F1450AD1860C00691BD4 /* CounterResetNode.h */; };
     1094                9392F14A0AD1861300691BD4 /* CounterResetNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392F1490AD1861300691BD4 /* CounterResetNode.cpp */; };
     1095                9392F14C0AD1861B00691BD4 /* CounterNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392F14B0AD1861B00691BD4 /* CounterNode.h */; };
     1096                9392F1500AD1862300691BD4 /* CounterNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392F14F0AD1862300691BD4 /* CounterNode.cpp */; };
     1097                9392F1520AD1862B00691BD4 /* CounterListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 9392F1510AD1862B00691BD4 /* CounterListItem.h */; };
    10911098                939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939885C108B7E3D100E707C4 /* EventNames.cpp */; };
    10921099                939885C408B7E3D100E707C4 /* EventNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 939885C208B7E3D100E707C4 /* EventNames.h */; };
     
    36373644                938E683B09F0BD7A008A48EC /* GraphicsTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsTypes.h; sourceTree = "<group>"; };
    36383645                938E685309F0BE04008A48EC /* GraphicsTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsTypes.cpp; sourceTree = "<group>"; };
     3646                9392F1410AD185F400691BD4 /* RenderCounter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderCounter.h; sourceTree = "<group>"; };
     3647                9392F1430AD185FE00691BD4 /* RenderCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCounter.cpp; sourceTree = "<group>"; };
     3648                9392F1450AD1860C00691BD4 /* CounterResetNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CounterResetNode.h; sourceTree = "<group>"; };
     3649                9392F1490AD1861300691BD4 /* CounterResetNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CounterResetNode.cpp; sourceTree = "<group>"; };
     3650                9392F14B0AD1861B00691BD4 /* CounterNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CounterNode.h; sourceTree = "<group>"; };
     3651                9392F14F0AD1862300691BD4 /* CounterNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CounterNode.cpp; sourceTree = "<group>"; };
     3652                9392F1510AD1862B00691BD4 /* CounterListItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CounterListItem.h; sourceTree = "<group>"; };
    36393653                9394E0A403AA5BBE008635CE /* WebCorePageState.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebCorePageState.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    36403654                9394E0A503AA5BBE008635CE /* WebCorePageState.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCorePageState.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    78547868                                BCEA4815097D93020094C9E4 /* break_lines.cpp */,
    78557869                                BCEA4816097D93020094C9E4 /* break_lines.h */,
     7870                                9392F1510AD1862B00691BD4 /* CounterListItem.h */,
     7871                                9392F14F0AD1862300691BD4 /* CounterNode.cpp */,
     7872                                9392F14B0AD1861B00691BD4 /* CounterNode.h */,
     7873                                9392F1490AD1861300691BD4 /* CounterResetNode.cpp */,
     7874                                9392F1450AD1860C00691BD4 /* CounterResetNode.h */,
    78567875                                BCEA4817097D93020094C9E4 /* DataRef.h */,
    78577876                                ABE7B5210A489F830031881C /* DeprecatedRenderSelect.cpp */,
     
    78907909                                BCEA482C097D93020094C9E4 /* RenderContainer.cpp */,
    78917910                                BCEA482D097D93020094C9E4 /* RenderContainer.h */,
     7911                                9392F1430AD185FE00691BD4 /* RenderCounter.cpp */,
     7912                                9392F1410AD185F400691BD4 /* RenderCounter.h */,
    78927913                                A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */,
    78937914                                A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */,
     
    93209341                                85004DA70ACEEB5A00C438F6 /* DOMSVGEllipseElementInternal.h in Headers */,
    93219342                                ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */,
     9343                                9392F1420AD185F400691BD4 /* RenderCounter.h in Headers */,
     9344                                9392F1460AD1860C00691BD4 /* CounterResetNode.h in Headers */,
     9345                                9392F14C0AD1861B00691BD4 /* CounterNode.h in Headers */,
     9346                                9392F1520AD1862B00691BD4 /* CounterListItem.h in Headers */,
    93229347                        );
    93239348                        runOnlyForDeploymentPostprocessing = 0;
     
    1044710472                                85004D9B0ACEEAEF00C438F6 /* DOMSVGEllipseElement.mm in Sources */,
    1044810473                                ABB5419E0ACDDFE4002820EB /* RenderListBox.cpp in Sources */,
     10474                                9392F1440AD185FE00691BD4 /* RenderCounter.cpp in Sources */,
     10475                                9392F14A0AD1861300691BD4 /* CounterResetNode.cpp in Sources */,
     10476                                9392F1500AD1862300691BD4 /* CounterNode.cpp in Sources */,
    1044910477                        );
    1045010478                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r16549 r16721  
    603603        break;
    604604    case CSS_PROP_COUNTER_INCREMENT:
    605         // FIXME: unimplemented
    606         break;
     605        return style->counterIncrementValueList();
    607606    case CSS_PROP_COUNTER_RESET:
    608         // FIXME: unimplemented
    609         break;
     607        return style->counterResetValueList();
    610608    case CSS_PROP_CURSOR: {
    611609        CSSValueList* list = 0;
  • trunk/WebCore/css/CSSPrimitiveValue.cpp

    r16275 r16721  
    525525            break;
    526526        case CSS_COUNTER:
    527             // ###
     527            text = "counter(";
     528            text += String::number(m_value.num);
     529            text += ")";
     530            // FIXME: Add list-style and separator
    528531            break;
    529532        case CSS_RECT: {
  • trunk/WebCore/css/Counter.h

    r14407 r16721  
    2424#define Counter_H
    2525
     26#include "CSSPrimitiveValue.h"
     27#include "PlatformString.h"
    2628#include "Shared.h"
    27 #include "PlatformString.h"
     29#include <wtf/PassRefPtr.h>
    2830
    2931namespace WebCore {
     
    3133class Counter : public Shared<Counter> {
    3234public:
    33     String identifier() const { return m_identifier; }
    34     String listStyle() const { return m_listStyle; }
    35     String separator() const { return m_separator; }
     35    Counter() : m_identifier(0), m_listStyle(0), m_separator(0) { }
     36    Counter(PassRefPtr<CSSPrimitiveValue> identifier, PassRefPtr<CSSPrimitiveValue> listStyle,
     37        PassRefPtr<CSSPrimitiveValue> separator)
     38        : m_identifier(identifier), m_listStyle(listStyle), m_separator(separator) { }
     39    ~Counter() { }
    3640
    37 private:
    38     String m_identifier;
    39     String m_listStyle;
    40     String m_separator;
    41 };
     41    String identifier() const { return m_identifier ? m_identifier->getStringValue() : String(); }
     42    String listStyle() const { return m_listStyle ? m_listStyle->getStringValue() : String(); }
     43    String separator() const { return m_separator ? m_separator->getStringValue() : String(); }
    4244
    43 } // namespace
     45    int listStyleNumber() const { return m_listStyle ? (int) m_listStyle->getFloatValue() : 0; }
     46   
     47    void setIdentifier(PassRefPtr<CSSPrimitiveValue> identifier) { m_identifier = identifier; }
     48    void setListStyle(PassRefPtr<CSSPrimitiveValue> listStyle) { m_listStyle = listStyle; }
     49    void setSeparator(PassRefPtr<CSSPrimitiveValue> separator) { m_separator = separator; }
     50 
     51protected:
     52    RefPtr<CSSPrimitiveValue> m_identifier; // String
     53    RefPtr<CSSPrimitiveValue> m_listStyle;  // int
     54    RefPtr<CSSPrimitiveValue> m_separator;  // String
     55 };
     56
     57} //namespace
    4458
    4559#endif
  • trunk/WebCore/css/cssparser.cpp

    r16571 r16721  
    4444#include "CSSValueKeywords.h"
    4545#include "CSSValueList.h"
     46#include "Counter.h"
    4647#include "DashboardRegion.h"
    4748#include "Document.h"
     
    336337
    337338
    338 void CSSParser::addProperty(int propId, CSSValue *value, bool important)
     339void CSSParser::addProperty(int propId, PassRefPtr<CSSValue> value, bool important)
    339340{
    340341    CSSProperty *prop = new CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand);
     
    914915            valid_primitive = (!id && validUnit(value, FNumber|FLength|FPercent, strict));
    915916        break;
     917    case CSS_PROP_COUNTER_INCREMENT:    // [ <identifier> <integer>? ]+ | none | inherit
     918        if (id != CSS_VAL_NONE)
     919            return parseCounter(propId, 1, important);
     920        valid_primitive = true;
     921        break;
     922     case CSS_PROP_COUNTER_RESET:        // [ <identifier> <integer>? ]+ | none | inherit
     923        if (id != CSS_VAL_NONE)
     924            return parseCounter(propId, 0, important);
     925        valid_primitive = true;
     926        break;
    916927    case CSS_PROP_FONT_FAMILY:
    917928        // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
     
    15671578bool CSSParser::parseContent(int propId, bool important)
    15681579{
    1569     CSSValueList* values = new CSSValueList;
     1580    RefPtr<CSSValueList> values = new CSSValueList;
    15701581
    15711582    while (Value* val = valueList->current()) {
    1572         CSSValue* parsedValue = 0;
     1583        RefPtr<CSSValue> parsedValue;
    15731584        if (val->unit == CSSPrimitiveValue::CSS_URI) {
    15741585            // url
     
    15771588                String(KURL(styleElement->baseURL().deprecatedString(), value.deprecatedString()).url()), styleElement);
    15781589        } else if (val->unit == Value::Function) {
    1579             // attr(X)
     1590            // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z])
    15801591            ValueList *args = val->function->args;
    15811592            String fname = domString(val->function->name).lower();
    1582             if (fname != "attr(" || !args)
     1593            if (!args)
    15831594                return false;
    1584             if (args->size() != 1)
     1595            if (fname == "attr(") {
     1596                if (args->size() != 1)
     1597                    return false;
     1598                Value* a = args->current();
     1599                String attrName = domString(a->string);
     1600                if (document()->isHTMLDocument())
     1601                    attrName = attrName.lower();
     1602                parsedValue = new CSSPrimitiveValue(attrName, CSSPrimitiveValue::CSS_ATTR);
     1603            } else if (fname == "counter(") {
     1604                parsedValue = parseCounterContent(args, false);
     1605                if (!parsedValue) return false;
     1606            } else if (fname == "counters(") {
     1607                parsedValue = parseCounterContent(args, true);
     1608                if (!parsedValue)
     1609                    return false;
     1610            } else
    15851611                return false;
    1586             Value *a = args->current();
    1587             String attrName = domString(a->string);
    1588             if (document()->isHTMLDocument())
    1589                 attrName = attrName.lower();
    1590             parsedValue = new CSSPrimitiveValue(attrName, CSSPrimitiveValue::CSS_ATTR);
    15911612        } else if (val->unit == CSSPrimitiveValue::CSS_IDENT) {
    15921613            // open-quote
     
    16001621        if (!parsedValue)
    16011622            break;
    1602         values->append(parsedValue);
     1623        values->append(parsedValue.release());
    16031624        valueList->next();
    16041625    }
    16051626
    16061627    if (values->length()) {
    1607         addProperty(propId, values, important);
     1628        addProperty(propId, values.release(), important);
    16081629        valueList->next();
    16091630        return true;
    16101631    }
    16111632
    1612     delete values;
    16131633    return false;
    16141634}
     
    20222042#endif
    20232043
     2044PassRefPtr<CSSValue> CSSParser::parseCounterContent(ValueList* args, bool counters)
     2045{
     2046    unsigned numArgs = args->size();
     2047    if (counters && numArgs != 3 && numArgs != 5)
     2048        return 0;
     2049    if (!counters && numArgs != 1 && numArgs != 3)
     2050        return 0;
     2051   
     2052    Value* i = args->current();
     2053    RefPtr<CSSPrimitiveValue> identifier = new CSSPrimitiveValue(domString(i->string),
     2054        CSSPrimitiveValue::CSS_STRING);
     2055
     2056    RefPtr<CSSPrimitiveValue> separator;
     2057    if (!counters)
     2058        separator = new CSSPrimitiveValue(String(), CSSPrimitiveValue::CSS_STRING);
     2059    else {
     2060        i = args->next();
     2061        if (i->unit != Value::Operator || i->iValue != ',')
     2062            return 0;
     2063       
     2064        i = args->next();
     2065        if (i->unit != CSSPrimitiveValue::CSS_STRING)
     2066            return 0;
     2067       
     2068        separator = new CSSPrimitiveValue(domString(i->string), (CSSPrimitiveValue::UnitTypes) i->unit);
     2069    }
     2070
     2071    RefPtr<CSSPrimitiveValue> listStyle;
     2072    i = args->next();
     2073    if (!i) // Make the list style default decimal
     2074        listStyle = new CSSPrimitiveValue(CSS_VAL_DECIMAL - CSS_VAL_DISC, CSSPrimitiveValue::CSS_NUMBER);
     2075    else {
     2076        if (i->unit != Value::Operator || i->iValue != ',')
     2077            return 0;
     2078       
     2079        i = args->next();
     2080        if (i->unit != CSSPrimitiveValue::CSS_IDENT)
     2081            return 0;
     2082       
     2083        short ls = 0;
     2084        if (i->id == CSS_VAL_NONE)
     2085            ls = CSS_VAL_KATAKANA_IROHA - CSS_VAL_DISC + 1;
     2086        else if (i->id >= CSS_VAL_DISC && i->id <= CSS_VAL_KATAKANA_IROHA)
     2087            ls = i->id - CSS_VAL_DISC;
     2088        else
     2089            return 0;
     2090
     2091        listStyle = new CSSPrimitiveValue(ls, (CSSPrimitiveValue::UnitTypes) i->unit);
     2092    }
     2093
     2094    return new CSSPrimitiveValue(new Counter(identifier.release(), listStyle.release(), separator.release()));
     2095}
     2096
    20242097bool CSSParser::parseShape(int propId, bool important)
    20252098{
     
    27202793}
    27212794
     2795bool CSSParser::parseCounter(int propId, int defaultValue, bool important)
     2796{
     2797    enum { ID, VAL } state = ID;
     2798
     2799    RefPtr<CSSValueList> list = new CSSValueList;
     2800    RefPtr<CSSPrimitiveValue> counterName;
     2801   
     2802    while (true) {
     2803        Value* val = valueList->current();
     2804        switch (state) {
     2805            case ID:
     2806                if (val && val->unit == CSSPrimitiveValue::CSS_IDENT) {
     2807                    counterName = new CSSPrimitiveValue(domString(val->string), CSSPrimitiveValue::CSS_STRING);
     2808                    state = VAL;
     2809                    valueList->next();
     2810                    continue;
     2811                }
     2812                break;
     2813            case VAL: {
     2814                int i = defaultValue;
     2815                if (val && val->unit == CSSPrimitiveValue::CSS_NUMBER) {
     2816                    i = (int)val->fValue;
     2817                    valueList->next();
     2818                }
     2819
     2820                list->append(new CSSPrimitiveValue(new Pair(counterName.release(),
     2821                    new CSSPrimitiveValue(i, CSSPrimitiveValue::CSS_NUMBER))));
     2822                state = ID;
     2823                continue;
     2824            }
     2825        }
     2826        break;
     2827    }
     2828   
     2829    if (list->length() > 0) {
     2830        addProperty(propId, list.release(), important);
     2831        return true;
     2832    }
     2833
     2834    return false;
     2835}
     2836
    27222837#ifdef CSS_DEBUG
    27232838
  • trunk/WebCore/css/cssparser.h

    r16217 r16721  
    121121        Document* document() const;
    122122
    123         void addProperty(int propId, CSSValue*, bool important);
     123        void addProperty(int propId, PassRefPtr<CSSValue>, bool important);
    124124        void rollbackLastProperties(int num);
    125125        bool hasProperties() const { return numParsedProperties > 0; }
     
    147147        bool parseShape(int propId, bool important);
    148148        bool parseFont(bool important);
     149        bool parseCounter(int propId, int defaultValue, bool important);
    149150        CSSValueList* parseFontFamily();
    150151        bool parseColorParameters(Value*, int* colorValues, bool parseAlpha);
     
    152153        CSSPrimitiveValue* parseColor();
    153154        CSSPrimitiveValue* parseColorFromValue(Value*);
     155        PassRefPtr<CSSValue> parseCounterContent(ValueList* args, bool counters);
    154156       
    155157#ifdef SVG_SUPPORT
  • trunk/WebCore/css/cssstyleselector.cpp

    r16678 r16721  
    3939#include "CSSValueKeywords.h"
    4040#include "CSSValueList.h"
     41#include "Counter.h"
    4142#include "CachedImage.h"
    4243#include "DashboardRegion.h"
     
    758759void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule)
    759760{
    760     // 1. First we match rules from the user agent sheet.
    761     matchRules(defaultStyle, firstUARule, lastUARule);
    762 
    763     // 2. In quirks mode, we match rules from the quirks user agent sheet.
     761    // First we match rules from the user agent sheet.
     762    CSSRuleSet* userAgentStyleSheet = m_medium->mediaTypeMatch("print")
     763        ? defaultPrintStyle : defaultStyle;
     764    matchRules(userAgentStyleSheet, firstUARule, lastUARule);
     765
     766    // In quirks mode, we match rules from the quirks user agent sheet.
    764767    if (!strictParsing)
    765768        matchRules(defaultQuirksStyle, firstUARule, lastUARule);
    766 
    767     // 3. If our medium is print, then we match rules from the print sheet.
    768     if (m_medium->mediaTypeMatch("print"))
    769         matchRules(defaultPrintStyle, firstUARule, lastUARule);
    770769       
    771     // 4. If we're in view source mode, then we match rules from the view source style sheet.
     770    // If we're in view source mode, then we match rules from the view source style sheet.
    772771    if (view && view->frame() && view->frame()->inViewSourceMode())
    773772        matchRules(defaultViewSourceStyle, firstUARule, lastUARule);
     
    31773176        for (int i = 0; i < len; i++) {
    31783177            CSSValue *item = list->item(i);
    3179             if (!item->isPrimitiveValue()) continue;
     3178            if (!item->isPrimitiveValue())
     3179                continue;
     3180           
    31803181            CSSPrimitiveValue *val = static_cast<CSSPrimitiveValue*>(item);
    31813182            if (val->primitiveType()==CSSPrimitiveValue::CSS_STRING)
     
    31913192                // register the fact that the attribute value affects the style
    31923193                m_selectorAttrs.add(attr.localName().impl());
    3193             }
    3194             else if (val->primitiveType()==CSSPrimitiveValue::CSS_URI) {
     3194            } else if (val->primitiveType()==CSSPrimitiveValue::CSS_URI) {
    31953195                CSSImageValue *image = static_cast<CSSImageValue*>(val);
    31963196                style->setContent(image->image(element->document()->docLoader()), i != 0);
    3197             }
     3197            } else if (val->primitiveType()==CSSPrimitiveValue::CSS_COUNTER) {
     3198                Counter* counterValue = val->getCounterValue();
     3199                CounterData counter(counterValue->identifier(),
     3200                    (EListStyleType)counterValue->listStyleNumber(), counterValue->separator());
     3201                style->setContent(new CounterData(counter), i != 0);
     3202           }
    31983203        }
    31993204        break;
     
    32013206
    32023207    case CSS_PROP_COUNTER_INCREMENT:
    3203         // list of CSS2CounterIncrement
     3208        if (!value->isValueList())
     3209            return;
     3210        style->setCounterIncrementList(static_cast<CSSValueList*>(value));
     3211        break;
    32043212    case CSS_PROP_COUNTER_RESET:
    3205         // list of CSS2CounterReset
     3213        if (!value->isValueList())
     3214            return;
     3215        style->setCounterResetList(static_cast<CSSValueList*>(value));
    32063216        break;
    32073217    case CSS_PROP_FONT_FAMILY: {
  • trunk/WebCore/platform/PlatformString.h

    r16622 r16721  
    9292    void append(UChar);
    9393    void insert(const String&, unsigned pos);
     94    void insert(const UChar*, unsigned length, unsigned pos);
    9495
    9596    String& replace(UChar a, UChar b) { if (m_impl) m_impl = m_impl->replace(a, b); return *this; }
  • trunk/WebCore/platform/String.cpp

    r16622 r16721  
    158158}
    159159
     160void String::insert(const UChar* str, unsigned length, unsigned pos)
     161{
     162    if (!m_impl)
     163        m_impl = new StringImpl(str, length);
     164    else
     165        m_impl->insert(str, length, pos);
     166}
     167
    160168UChar String::operator[](unsigned i) const
    161169{
  • trunk/WebCore/platform/StringImpl.cpp

    r16626 r16721  
    194194        memcpy(c + pos, str->m_data, str->m_length * sizeof(UChar));
    195195        memcpy(c + pos + str->m_length, m_data + pos, (m_length - pos) * sizeof(UChar));
     196        deleteUCharVector(m_data);
     197        m_data = c;
     198        m_length = newlen;
     199        m_hasTerminatingNullCharacter = false;
     200    }
     201}
     202
     203void StringImpl::insert(const UChar* str, unsigned length, unsigned pos)
     204{
     205    assert(!m_inTable);
     206    if (pos >= m_length) {
     207        RefPtr<StringImpl> s = new StringImpl(str, length);
     208        append(s.get());
     209        return;
     210    }
     211    if (str && length != 0) {
     212        size_t newlen = m_length + length;
     213        UChar* c = newUCharVector(newlen);
     214        memcpy(c, m_data, pos * sizeof(UChar));
     215        memcpy(c + pos, str, length * sizeof(UChar));
     216        memcpy(c + pos + length, m_data + pos, (m_length - pos) * sizeof(UChar));
    196217        deleteUCharVector(m_data);
    197218        m_data = c;
  • trunk/WebCore/platform/StringImpl.h

    r16626 r16721  
    8484    void append(UChar);
    8585    void insert(const StringImpl*, unsigned pos);
     86    void insert(const UChar* str, unsigned length, unsigned pos);
    8687    void truncate(int len);
    8788    void remove(unsigned pos, int len = 1);
  • trunk/WebCore/rendering/RenderContainer.cpp

    r16250 r16721  
    55 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    66 *           (C) 2000 Dirk Mueller (mueller@kde.org)
     7 *           (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
    78 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
    89 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
     
    2930
    3031#include "htmlediting.h"
     32#include "RenderCounter.h"
    3133#include "RenderListItem.h"
    3234#include "RenderTable.h"
     
    297299        // inline should be mutated to INLINE.
    298300        pseudo->setDisplay(INLINE);
    299    
     301
    300302    if (oldContentPresent) {
    301303        if (child && child->style()->styleType() == type) {
     
    335337            pseudoContainer = RenderFlow::createAnonymousFlow(document(), pseudo); /* anonymous box */
    336338       
    337         if (contentData->contentType() == CONTENT_TEXT)
    338         {
     339        if (contentData->contentType() == CONTENT_TEXT) {
    339340            RenderText* t = new (renderArena()) RenderTextFragment(document() /*anonymous object */, contentData->contentText());
    340341            t->setStyle(pseudo);
    341342            pseudoContainer->addChild(t);
    342         }
    343         else if (contentData->contentType() == CONTENT_OBJECT)
    344         {
     343        } else if (contentData->contentType() == CONTENT_OBJECT) {
    345344            RenderImage* img = new (renderArena()) RenderImage(document()); /* Anonymous object */
    346345            RenderStyle* style = new (renderArena()) RenderStyle();
     
    349348            img->setContentObject(contentData->contentObject());
    350349            pseudoContainer->addChild(img);
     350        } else if (contentData->_contentType == CONTENT_COUNTER) {
     351            RenderCounter* c = new (renderArena()) RenderCounter(element(), contentData->contentCounter());
     352            RenderStyle* style = new (renderArena()) RenderStyle();
     353            style->inheritFrom(pseudo);
     354            c->setIsAnonymous(true);
     355            c->setStyle(style);
     356            pseudoContainer->addChild(c);
    351357        }
    352358    }
  • trunk/WebCore/rendering/RenderObject.cpp

    r16663 r16721  
    55 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    66 *           (C) 2000 Dirk Mueller (mueller@kde.org)
     7 *           (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
    78 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
    89 *
     
    3031#include "AffineTransform.h"
    3132#include "CachedImage.h"
     33#include "CounterNode.h"
     34#include "CounterResetNode.h"
    3235#include "Decoder.h"
    3336#include "Document.h"
     
    3841#include "GraphicsContext.h"
    3942#include "HTMLNames.h"
     43#include "HTMLOListElement.h"
    4044#include "Position.h"
    4145#include "RenderArena.h"
     
    6569static void *baseOfRenderObjectBeingDeleted;
    6670#endif
     71
     72typedef HashMap<String, CounterNode*> CounterNodeMap;
     73typedef HashMap<const RenderObject*, CounterNodeMap*> RenderObjectsToCounterNodeMaps;
     74
     75static RenderObjectsToCounterNodeMaps* getRenderObjectsToCounterNodeMaps()
     76{
     77    static RenderObjectsToCounterNodeMaps objectsMap;
     78    return &objectsMap;
     79}
    6780
    6881void* RenderObject::operator new(size_t sz, RenderArena* renderArena) throw()
     
    178191m_replaced( false ),
    179192m_isDragging( false ),
    180 m_hasOverflowClip(false)
     193m_hasOverflowClip(false),
     194m_hasCounterNodeMap(false)
    181195{
    182196#ifndef NDEBUG
     
    24072421void RenderObject::destroy()
    24082422{
     2423    if (m_hasCounterNodeMap) {
     2424        RenderObjectsToCounterNodeMaps* objectsMap = getRenderObjectsToCounterNodeMaps();
     2425        if (CounterNodeMap* counterNodesMap = objectsMap->get(this)) {
     2426            CounterNodeMap::const_iterator end = counterNodesMap->end();
     2427            for (CounterNodeMap::const_iterator it = counterNodesMap->begin(); it != end; ++it) {
     2428                CounterNode* counterNode = it->second;
     2429                counterNode->remove();
     2430                delete counterNode;
     2431                counterNode = 0;
     2432            }
     2433            objectsMap->remove(this);
     2434            delete counterNodesMap;
     2435        }
     2436    }
     2437   
    24092438    document()->axObjectCache()->remove(this);
    24102439
     
    28492878}
    28502879
     2880CounterNode* RenderObject::findCounter(const String& counterName, bool willNeedLayout,
     2881    bool usesSeparator, bool createIfNotFound)
     2882{
     2883    if (!style())
     2884        return 0;
     2885
     2886    RenderObjectsToCounterNodeMaps* objectsMap = getRenderObjectsToCounterNodeMaps();
     2887    CounterNode* newNode = 0;
     2888    if (CounterNodeMap* counterNodesMap = objectsMap->get(this))
     2889        if (counterNodesMap)
     2890            newNode = counterNodesMap->get(counterName);
     2891       
     2892    if (newNode)
     2893        return newNode;
     2894
     2895    int val = 0;
     2896    if (style()->hasCounterReset(counterName) || isRoot()) {
     2897        newNode = new CounterResetNode(this);
     2898        val = style()->counterReset(counterName);
     2899        if (style()->hasCounterIncrement(counterName))
     2900            val += style()->counterIncrement(counterName);
     2901        newNode->setValue(val);
     2902    } else if (style()->hasCounterIncrement(counterName)) {
     2903        newNode = new CounterNode(this);
     2904        newNode->setValue(style()->counterIncrement(counterName));
     2905    } else if (counterName == "list-item") {
     2906        if (isListItem()) {
     2907            if (element()) {
     2908                String v = static_cast<Element*>(element())->getAttribute("value");
     2909                if (!v.isEmpty()) {
     2910                    newNode = new CounterResetNode(this);
     2911                    val = v.toInt();
     2912                }
     2913            }
     2914           
     2915            if (!newNode) {
     2916                newNode = new CounterNode(this);
     2917                val = 1;
     2918            }
     2919
     2920            newNode->setValue(val);
     2921        } else if (element() && element()->hasTagName(olTag)) {
     2922            newNode = new CounterResetNode(this);
     2923            newNode->setValue(static_cast<HTMLOListElement*>(element())->start());
     2924        } else if (element() &&
     2925            (element()->hasTagName(ulTag) ||
     2926             element()->hasTagName(menuTag) ||
     2927             element()->hasTagName(dirTag))) {
     2928            newNode = new CounterResetNode(this);
     2929            newNode->setValue(0);
     2930        }
     2931    }
     2932   
     2933    if (!newNode && !createIfNotFound)
     2934        return 0;
     2935    else if (!newNode) {
     2936        newNode = new CounterNode(this);
     2937        newNode->setValue(0);
     2938    }
     2939
     2940    if (willNeedLayout)
     2941        newNode->setWillNeedLayout();
     2942    if (usesSeparator)
     2943        newNode->setUsesSeparator();
     2944
     2945    CounterNodeMap* nodeMap;
     2946    if (m_hasCounterNodeMap)
     2947        nodeMap = objectsMap->get(this);
     2948    else {
     2949        nodeMap = new CounterNodeMap;
     2950        objectsMap->set(this, nodeMap);
     2951        m_hasCounterNodeMap = true;
     2952    }
     2953   
     2954    nodeMap->set(counterName, newNode);
     2955
     2956    if (!isRoot()) {
     2957        RenderObject* n = !isListItem() && previousSibling()
     2958            ? previousSibling()->previousSibling() : previousSibling();
     2959
     2960        CounterNode* current = 0;
     2961        for (; n; n = n->previousSibling()) {
     2962            current = n->findCounter(counterName, false, false, false);
     2963            if (current)
     2964                break;
     2965        }
     2966       
     2967        CounterNode* last = current;
     2968        CounterNode* sibling = current;
     2969        if (last && !newNode->isReset()) {
     2970            // Found render-sibling, now search for later counter-siblings among its render-children
     2971            n = n->lastChild();
     2972            while (n) {
     2973                current = n->findCounter(counterName, false, false, false);
     2974                if (current && (last->parent() == current->parent() || sibling == current->parent())) {
     2975                    last = current;
     2976                    // If the current counter is not the last, search deeper
     2977                    if (current->nextSibling()) {
     2978                        n = n->lastChild();
     2979                        continue;
     2980                    } else
     2981                        break;
     2982                }
     2983                n = n->previousSibling();
     2984            }
     2985           
     2986            if (sibling->isReset()) {
     2987                if (last != sibling)
     2988                    sibling->insertAfter(newNode, last);
     2989                else
     2990                    sibling->insertAfter(newNode, 0);
     2991            } else
     2992                last->parent()->insertAfter(newNode, last);
     2993        } else {
     2994            // Nothing found among siblings, let our parent search
     2995            last = parent()->findCounter(counterName, false);
     2996            if (last->isReset())
     2997                last->insertAfter(newNode, 0);
     2998            else
     2999                last->parent()->insertAfter(newNode, last);
     3000        }
     3001    }
     3002
     3003    return newNode;
     3004}
     3005
    28513006UChar RenderObject::backslashAsCurrencySymbol() const
    28523007{
  • trunk/WebCore/rendering/RenderObject.h

    r16678 r16721  
    55 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    66 *           (C) 2000 Dirk Mueller (mueller@kde.org)
     7 *           (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
    78 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
    89 *
     
    3233#include "ScrollBar.h"
    3334#include "VisiblePosition.h"
     35#include <wtf/HashMap.h>
    3436
    3537/*
     
    4749class CollapsedBorderValue;
    4850class Color;
     51class CounterNode;
    4952class Document;
    5053class Element;
     
    194197    virtual int staticY() const { return 0; }
    195198   
     199    CounterNode* findCounter(const String& counterName, bool willNeedLayout = false,
     200        bool usesSeparator = false, bool createIfNotFound = true);
     201
     202public:
    196203    // RenderObject tree manipulation
    197204    //////////////////////////////////////////
     
    255262    virtual bool isListItem() const { return false; }
    256263    virtual bool isListMarker() const { return false; }
     264    virtual bool isCounter() const { return false; }
    257265    virtual bool isRenderView() const { return false; }
    258266    bool isRoot() const;
     
    933941   
    934942    bool m_hasOverflowClip           : 1;
    935 
    936     // note: do not add unnecessary bitflags, we have 32 bit already!
     943   
     944    bool m_hasCounterNodeMap         : 1;
     945
    937946    friend class RenderListItem;
    938947    friend class RenderContainer;
  • trunk/WebCore/rendering/RenderStyle.cpp

    r16549 r16721  
    9191    , textDecoration(RenderStyle::initialTextDecoration())
    9292    , colspan(1)
    93     , counter_increment(0)
    94     , counter_reset(0)
     93    , counterIncrement(0)
     94    , counterReset(0)
    9595{
    9696}
     
    106106    , textDecoration(o.textDecoration)
    107107    , colspan(o.colspan)
    108     , counter_increment(o.counter_increment)
    109     , counter_reset(o.counter_reset)
     108    , counterIncrement(o.counterIncrement)
     109    , counterReset(o.counterReset)
    110110{
    111111}
     
    578578    }
    579579    delete content;
    580    
    581580    delete this;
    582581   
     
    650649    , pseudoStyle(0)
    651650    , content(o.content)
     651    , counterResetList(o.counterResetList)
     652    , counterIncrementList(o.counterIncrementList)
    652653    , m_pseudoState(o.m_pseudoState)
    653654    , m_affectedByAttributeSelectors(false)
     
    839840        !(noninherited_flags._originalDisplay == other->noninherited_flags._originalDisplay) ||
    840841         visual->colspan != other->visual->colspan ||
    841          visual->counter_increment != other->visual->counter_increment ||
    842          visual->counter_reset != other->visual->counter_reset ||
     842         visual->counterIncrement != other->visual->counterIncrement ||
     843         visual->counterReset != other->visual->counterReset ||
    843844         css3NonInheritedData->textOverflow != other->css3NonInheritedData->textOverflow ||
    844845         (css3InheritedData->textSecurity != other->css3InheritedData->textSecurity))
     
    926927    if (!(css3NonInheritedData->m_dashboardRegions == other->css3NonInheritedData->m_dashboardRegions))
    927928        return Layout;
     929   
     930    // If the counter lists change, trigger a relayout to re-calc CounterNodes.
     931    if (counterResetList != other->counterResetList || counterIncrementList != other->counterIncrementList)
     932        return Layout;
    928933
    929934    // Make sure these left/top/right/bottom checks stay below all layout checks and above
     
    11101115}
    11111116
     1117void RenderStyle::setContent(CounterData* c, bool add)
     1118{
     1119    if (!c)
     1120        return;
     1121
     1122    ContentData* lastContent = content;
     1123    while (lastContent && lastContent->_nextContent)
     1124        lastContent = lastContent->_nextContent;
     1125
     1126    bool reuseContent = !add;
     1127    ContentData* newContentData = 0;
     1128    if (reuseContent && content) {
     1129        content->clearContent();
     1130        newContentData = content;
     1131    } else
     1132        newContentData = new ContentData;
     1133
     1134    if (lastContent && !reuseContent)
     1135        lastContent->_nextContent = newContentData;
     1136    else
     1137        content = newContentData;
     1138
     1139    newContentData->_content.counter = c;
     1140    newContentData->_contentType = CONTENT_COUNTER;
     1141}
     1142
    11121143ContentData::~ContentData()
    11131144{
     
    11281159            _content.text->deref();
    11291160            _content.text = 0;
     1161            break;
     1162        case CONTENT_COUNTER:
     1163            delete _content.counter;
     1164            _content.counter = 0;
     1165            break;
    11301166        default:
    11311167            ;
     
    12131249   
    12141250    return x == o.x && y == o.y && blur == o.blur && color == o.color;
     1251}
     1252
     1253bool RenderStyle::counterDataEquivalent(RenderStyle* otherStyle)
     1254{
     1255    // FIXME: Should we also compare the CounterData?
     1256    return counterResetList == otherStyle->counterResetList &&
     1257           counterIncrementList == otherStyle->counterIncrementList;
     1258}
     1259
     1260static bool hasCounter(const String& c, CSSValueList* l)
     1261{
     1262    int len = l->length();
     1263    for (int i = 0; i < len; i++) {
     1264        CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(l->item(i));
     1265        Pair* pair = primitiveValue->getPairValue();
     1266        ASSERT(pair);
     1267        CSSPrimitiveValue* counterName = static_cast<CSSPrimitiveValue*>(pair->first());
     1268        ASSERT(counterName);
     1269        if (counterName->getStringValue() == c)
     1270            return true;
     1271    }
     1272    return false;
     1273}
     1274
     1275bool RenderStyle::hasCounterReset(const String& counterName) const
     1276{
     1277    if (counterResetList)
     1278        return hasCounter(counterName, counterResetList.get());
     1279    return false;
     1280}
     1281
     1282bool RenderStyle::hasCounterIncrement(const String& counterName) const
     1283{
     1284    if (counterIncrementList)
     1285        return hasCounter(counterName, counterIncrementList.get());
     1286    return false;
     1287}
     1288
     1289static int readCounter(const String& c, CSSValueList* l, bool isReset)
     1290{
     1291    int len = l->length();
     1292    int total = 0;
     1293   
     1294    for (int i = 0; i < len; i++) {
     1295        CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(l->item(i));
     1296        Pair* pair = primitiveValue->getPairValue();
     1297        ASSERT(pair);
     1298        CSSPrimitiveValue* counterName = static_cast<CSSPrimitiveValue*>(pair->first());
     1299        CSSPrimitiveValue* counterValue = static_cast<CSSPrimitiveValue*>(pair->second());
     1300        ASSERT(counterName);
     1301        ASSERT(counterValue);
     1302
     1303        if (counterName->getStringValue() == c) {
     1304            total += (int)counterValue->getFloatValue();
     1305            if (isReset)
     1306                return total;
     1307        }
     1308    }
     1309   
     1310    return total;
     1311}
     1312
     1313int RenderStyle::counterReset(const String& counterName) const
     1314{
     1315    if (counterResetList)
     1316        return readCounter(counterName, counterResetList.get(), true);
     1317    else
     1318        return 0;
     1319}
     1320
     1321int RenderStyle::counterIncrement(const String& counterName) const
     1322{
     1323    if (counterIncrementList)
     1324        return readCounter(counterName, counterIncrementList.get(), false);
     1325    else
     1326        return 0;
    12151327}
    12161328
  • trunk/WebCore/rendering/RenderStyle.h

    r16549 r16721  
    3636 */
    3737
     38#include "CSSPrimitiveValue.h"
     39#include "CSSValueList.h"
    3840#include "Color.h"
    3941#include "CSSCursorImageValue.h"
     
    4345#include "IntRect.h"
    4446#include "Length.h"
     47#include "Pair.h"
    4548#include "Shared.h"
    4649#include "TextDirection.h"
     
    6164using std::max;
    6265
    63 class CSSStyleSelector;
    6466class CachedImage;
    6567class CachedResource;
     68class CSSStyleSelector;
     69class CSSValueList;
    6670struct CursorData;
    6771class CursorList;
     72class Pair;
    6873class RenderArena;
    6974class ShadowValue;
     
    411416                 hasClip == o.hasClip &&
    412417                 colspan == o.colspan &&
    413                  counter_increment == o.counter_increment &&
    414                  counter_reset == o.counter_reset &&
     418                 counterIncrement == o.counterIncrement &&
     419                 counterReset == o.counterReset &&
    415420                 textDecoration == o.textDecoration);
    416421    }
     
    425430    short colspan; // for html, not a css2 attribute
    426431
    427     short counter_increment; //ok, so these are not visual mode spesific
    428     short counter_reset;     //can't go to inherited, since these are not inherited
     432    short counterIncrement; // ok, so these are not visual mode specific
     433    short counterReset;     // can't go to inherited, since these are not inherited
    429434
    430435};
     
    899904};
    900905
     906class CounterData {
     907   
     908public:
     909    CounterData() {}
     910    CounterData(const String& i, EListStyleType l, const String& s)
     911        : m_identifier(i), m_listStyle(l), m_separator(s) {}
     912   
     913    String identifier() { return m_identifier; }
     914    EListStyleType listStyle() { return m_listStyle; }
     915    String separator() { return m_separator; }
     916
     917private:
     918    String m_identifier;
     919    EListStyleType m_listStyle;
     920    String m_separator;
     921};
     922
    901923struct ContentData {
    902924    ContentData() :_contentType(CONTENT_NONE), _nextContent(0) {}
     
    908930    StringImpl* contentText() { if (contentType() == CONTENT_TEXT) return _content.text; return 0; }
    909931    CachedResource* contentObject() { if (contentType() == CONTENT_OBJECT) return _content.object; return 0; }
     932    CounterData* contentCounter() { if (contentType() == CONTENT_COUNTER) return _content.counter; return 0; }
    910933   
    911934    ContentType _contentType;
     
    914937        CachedResource* object;
    915938        StringImpl* text;
    916         // counters...
     939        CounterData* counter;
    917940    } _content ;
    918941
     
    10721095    // added this here, so we can get rid of the vptr in this class.
    10731096    // makes up for the same size.
    1074     ContentData *content;
     1097    ContentData* content;
     1098    RefPtr<CSSValueList> counterResetList;
     1099    RefPtr<CSSValueList> counterIncrementList;
    10751100
    10761101    unsigned m_pseudoState : 3; // PseudoState
     
    13221347    ECaptionSide captionSide() const { return static_cast<ECaptionSide>(inherited_flags._caption_side); }
    13231348
    1324     short counterIncrement() const { return visual->counter_increment; }
    1325     short counterReset() const { return visual->counter_reset; }
     1349    short counterIncrement() const { return visual->counterIncrement; }
     1350    short counterReset() const { return visual->counterReset; }
    13261351
    13271352    EListStyleType listStyleType() const { return static_cast<EListStyleType>(inherited_flags._list_style_type); }
     
    15281553
    15291554
    1530     void setCounterIncrement(short v) {  SET_VAR(visual,counter_increment,v) }
    1531     void setCounterReset(short v) {  SET_VAR(visual,counter_reset,v) }
     1555    void setCounterIncrement(short v) {  SET_VAR(visual,counterIncrement,v) }
     1556    void setCounterReset(short v) {  SET_VAR(visual,counterReset,v) }
    15321557
    15331558    void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; }
     
    16271652    void setContent(StringImpl* s, bool add = false);
    16281653    void setContent(CachedResource* o, bool add = false);
     1654    void setContent(CounterData*, bool add = false);
     1655
     1656    bool counterDataEquivalent(RenderStyle*);
     1657    void setCounterResetList(PassRefPtr<CSSValueList> l) { counterResetList = l; }
     1658    void setCounterIncrementList(PassRefPtr<CSSValueList> l) { counterIncrementList = l; }
     1659    bool hasCounterReset(const String&) const;
     1660    bool hasCounterIncrement(const String&) const;
     1661    int counterReset(const String&) const;
     1662    int counterIncrement(const String&) const;
     1663    CSSValueList* counterResetValueList() { return counterResetList.get(); }
     1664    CSSValueList* counterIncrementValueList() { return counterIncrementList.get(); }
    16291665
    16301666    bool inheritedNotEqual( RenderStyle *other ) const;
Note: See TracChangeset for help on using the changeset viewer.