Changeset 52450 in webkit


Ignore:
Timestamp:
Dec 21, 2009 12:11:47 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-21 Carol Szabo <carol.szabo@nokia.com>

Reviewed by Darin Adler.

Inconsistent use of counterName and identifier in CSS counter code and loss of information about the counter type.
https://bugs.webkit.org/show_bug.cgi?id=31814

No new tests because there are no functional changes in this patch.

  • rendering/CounterNode.cpp: (WebCore::CounterNode::CounterNode): (WebCore::CounterNode::computeCountInParent): (WebCore::showTreeAndMark):
  • rendering/RenderCounter.cpp: (WebCore::planCounter): (WebCore::findPlaceForCounter): (WebCore::makeCounterNode): (WebCore::RenderCounter::originalText): Changed to use identifier instead of counterName and actsAsReset or hasResetType, as appropriate instead of isReset.
  • rendering/CounterNode.h: (WebCore::CounterNode::actsAsReset): (WebCore::CounterNode::hasResetType):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52449 r52450  
     12009-12-21  Carol Szabo  <carol.szabo@nokia.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Inconsistent use of counterName and identifier in CSS counter code and loss of information about the counter type.
     6        https://bugs.webkit.org/show_bug.cgi?id=31814
     7
     8        No new tests because there are no functional changes in this patch.
     9
     10        * rendering/CounterNode.cpp:
     11        (WebCore::CounterNode::CounterNode):
     12        (WebCore::CounterNode::computeCountInParent):
     13        (WebCore::showTreeAndMark):
     14        * rendering/RenderCounter.cpp:
     15        (WebCore::planCounter):
     16        (WebCore::findPlaceForCounter):
     17        (WebCore::makeCounterNode):
     18        (WebCore::RenderCounter::originalText):
     19        Changed to use identifier instead of counterName and actsAsReset or hasResetType, as appropriate instead of isReset.
     20        * rendering/CounterNode.h:
     21        (WebCore::CounterNode::actsAsReset):
     22        (WebCore::CounterNode::hasResetType):
     23
    1242009-12-21  Dirk Schulze  <krit@webkit.org>
    225
  • trunk/WebCore/rendering/CounterNode.cpp

    r50966 r52450  
    3535namespace WebCore {
    3636
    37 CounterNode::CounterNode(RenderObject* o, bool isReset, int value)
    38     : m_isReset(isReset)
     37CounterNode::CounterNode(RenderObject* o, bool hasResetType, int value)
     38    : m_hasResetType(hasResetType)
    3939    , m_value(value)
    4040    , m_countInParent(0)
     
    101101int CounterNode::computeCountInParent() const
    102102{
    103     int increment = m_isReset ? 0 : m_value;
     103    int increment = actsAsReset() ? 0 : m_value;
    104104    if (m_previousSibling)
    105105        return m_previousSibling->m_countInParent + increment;
     
    107107    return m_parent->m_value + increment;
    108108}
    109 
    110109
    111110void CounterNode::resetRenderer(const AtomicString& identifier) const
     
    217216            fwrite("  ", 1, 2, stderr);
    218217        fprintf(stderr, "%p %s: %d %d P:%p PS:%p NS:%p R:%p\n",
    219             current, current->isReset() ? "reset____" : "increment", current->value(),
     218            current, current->actsAsReset() ? "reset____" : "increment", current->value(),
    220219            current->countInParent(), current->parent(), current->previousSibling(),
    221220            current->nextSibling(), current->renderer());
  • trunk/WebCore/rendering/CounterNode.h

    r50960 r52450  
    4343    CounterNode(RenderObject*, bool isReset, int value);
    4444
    45     bool isReset() const { return m_isReset; }
     45    bool actsAsReset() const { return m_hasResetType || !m_parent; }
     46    bool hasResetType() const { return m_hasResetType; }
    4647    int value() const { return m_value; }
    4748    int countInParent() const { return m_countInParent; }
     
    5960
    6061    void insertAfter(CounterNode* newChild, CounterNode* beforeChild, const AtomicString& identifier);
     62
     63    // identifier must match the identifier of this counter.
    6164    void removeChild(CounterNode*, const AtomicString& identifier);
    6265
     
    6467    int computeCountInParent() const;
    6568    void recount(const AtomicString& identifier);
     69
     70    // Invalidates the text in the renderer of this counter, if any.
     71    // identifier must match the identifier of this counter.
    6672    void resetRenderer(const AtomicString& identifier) const;
     73
     74    // Invalidates the text in the renderer of this counter, if any,
     75    // and in the renderers of all descendants of this counter, if any.
     76    // identifier must match the identifier of this counter.
    6777    void resetRenderers(const AtomicString& identifier) const;
    6878
    69     bool m_isReset;
     79    bool m_hasResetType;
    7080    int m_value;
    7181    int m_countInParent;
  • trunk/WebCore/rendering/RenderCounter.cpp

    r51851 r52450  
    3939typedef HashMap<const RenderObject*, CounterMap*> CounterMaps;
    4040
    41 static CounterNode* makeCounterNode(RenderObject*, const AtomicString& counterName, bool alwaysCreateCounter);
     41static CounterNode* makeCounterNode(RenderObject*, const AtomicString& identifier, bool alwaysCreateCounter);
    4242
    4343static CounterMaps& counterMaps()
     
    5454}
    5555
    56 static bool planCounter(RenderObject* object, const AtomicString& counterName, bool& isReset, int& value)
     56static bool planCounter(RenderObject* object, const AtomicString& identifier, bool& isReset, int& value)
    5757{
    5858    ASSERT(object);
     
    6767
    6868    if (const CounterDirectiveMap* directivesMap = style->counterDirectives()) {
    69         CounterDirectives directives = directivesMap->get(counterName.impl());
     69        CounterDirectives directives = directivesMap->get(identifier.impl());
    7070        if (directives.m_reset) {
    7171            value = directives.m_resetValue;
     
    8282    }
    8383
    84     if (counterName == "list-item") {
     84    if (identifier == "list-item") {
    8585        if (object->isListItem()) {
    8686            if (toRenderListItem(object)->hasExplicitValue()) {
     
    143143                // We have a suitable counter on the EndSearchRenderer.
    144144                if (previousSibling) { // But we already found another counter that we come after.
    145                     if (currentCounter->isReset()) {
     145                    if (currentCounter->actsAsReset()) {
    146146                        // We found a reset counter that is on a renderer that is a sibling of ours or a parent.
    147147                        if (isReset && currentRenderer->parent() == counterOwner->parent()) {
     
    172172                    // previousSibling, and when we are a sibling of the end counter we must set previousSibling
    173173                    // to currentCounter.
    174                     if (currentCounter->isReset()) {
     174                    if (currentCounter->actsAsReset()) {
    175175                        if (isReset && currentRenderer->parent() == counterOwner->parent()) {
    176176                            parent = currentCounter->parent();
     
    202202                    // Since we had a suitable previous counter before, we should only consider this one as our
    203203                    // previousSibling if it is a reset counter and hence the current previousSibling is its child.
    204                     if (currentCounter->isReset()) {
     204                    if (currentCounter->actsAsReset()) {
    205205                        previousSibling = currentCounter;
    206206                        // We are no longer interested in previous siblings of the currentRenderer or their children
     
    227227}
    228228
    229 static CounterNode* makeCounterNode(RenderObject* object, const AtomicString& counterName, bool alwaysCreateCounter)
     229static CounterNode* makeCounterNode(RenderObject* object, const AtomicString& identifier, bool alwaysCreateCounter)
    230230{
    231231    ASSERT(object);
     
    233233    if (object->m_hasCounterNodeMap)
    234234        if (CounterMap* nodeMap = counterMaps().get(object))
    235             if (CounterNode* node = nodeMap->get(counterName.impl()))
     235            if (CounterNode* node = nodeMap->get(identifier.impl()))
    236236                return node;
    237237
    238238    bool isReset = false;
    239239    int value = 0;
    240     if (!planCounter(object, counterName, isReset, value) && !alwaysCreateCounter)
     240    if (!planCounter(object, identifier, isReset, value) && !alwaysCreateCounter)
    241241        return 0;
    242242
    243243    CounterNode* newParent = 0;
    244244    CounterNode* newPreviousSibling = 0;
    245     CounterNode* newNode;
    246     if (findPlaceForCounter(object, counterName, isReset, newParent, newPreviousSibling)) {
    247         newNode = new CounterNode(object, isReset, value);
    248         newParent->insertAfter(newNode, newPreviousSibling, counterName);
    249     } else {
    250         // Make a reset node for counters that aren't inside an existing reset node.
    251         newNode = new CounterNode(object, true, value);
    252     }
    253 
     245    CounterNode* newNode = new CounterNode(object, isReset, value);
     246    if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousSibling))
     247        newParent->insertAfter(newNode, newPreviousSibling, identifier);
    254248    CounterMap* nodeMap;
    255249    if (object->m_hasCounterNodeMap)
     
    260254        object->m_hasCounterNodeMap = true;
    261255    }
    262     nodeMap->set(counterName.impl(), newNode);
    263 
     256    nodeMap->set(identifier.impl(), newNode);
    264257    return newNode;
    265258}
     
    291284
    292285    CounterNode* child = m_counterNode;
    293     int value = child->isReset() ? child->value() : child->countInParent();
     286    int value = child->actsAsReset() ? child->value() : child->countInParent();
    294287
    295288    String text = listMarkerText(m_counter.listStyle(), value);
    296289
    297290    if (!m_counter.separator().isNull()) {
    298         if (!child->isReset())
     291        if (!child->actsAsReset())
    299292            child = child->parent();
    300293        while (CounterNode* parent = child->parent()) {
Note: See TracChangeset for help on using the changeset viewer.