Changeset 96955 in webkit


Ignore:
Timestamp:
Oct 7, 2011, 10:19:32 AM (14 years ago)
Author:
inferno@chromium.org
Message:

Merge 96632 - Source/WebCore: Hold refptr to identified previous sibling within findPlaceForCounter.

BUG=96902
Review URL: http://codereview.chromium.org/8206006

Location:
branches/chromium/874
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/chromium/874/Source/WebCore/rendering/RenderCounter.cpp

    r95430 r96955  
    304304    RenderObject* currentRenderer = previousInPreOrder(counterOwner);
    305305    previousSibling = 0;
     306    RefPtr<CounterNode> previousSiblingProtector = 0;
     307
    306308    while (currentRenderer) {
    307309        CounterNode* currentCounter = makeCounterNode(currentRenderer, identifier, false);
     
    310312            if (currentCounter) {
    311313                // We have a suitable counter on the EndSearchRenderer.
    312                 if (previousSibling) { // But we already found another counter that we come after.
     314                if (previousSiblingProtector) { // But we already found another counter that we come after.
    313315                    if (currentCounter->actsAsReset()) {
    314316                        // We found a reset counter that is on a renderer that is a sibling of ours or a parent.
     
    327329                        // In these cases the identified previousSibling will be invalid as its parent is different from
    328330                        // our identified parent.
    329                         if (previousSibling->parent() != currentCounter)
    330                             previousSibling = 0;
     331                        if (previousSiblingProtector->parent() != currentCounter)
     332                            previousSiblingProtector = 0;
     333
     334                        previousSibling = previousSiblingProtector.get();
    331335                        return true;
    332336                    }
     
    335339                        // If the node we are placing is not reset or we have found a counter that is attached
    336340                        // to an ancestor of the placed counter's owner renderer we know we are a sibling of that node.
    337                         ASSERT(currentCounter->parent() == previousSibling->parent());
     341                        ASSERT(currentCounter->parent() == previousSiblingProtector->parent());
    338342                        parent = currentCounter->parent();
     343                        previousSibling = previousSiblingProtector.get();
    339344                        return true;
    340345                    }
     
    351356                        }
    352357                        parent = currentCounter;
     358                        previousSibling = previousSiblingProtector.get();
    353359                        return true;
    354360                    }
     
    358364                        return true;
    359365                    }
    360                     previousSibling = currentCounter;
     366                    previousSiblingProtector = currentCounter;
    361367                }
    362368            }
     
    371377            if (currentCounter) {
    372378                // We found a suitable counter.
    373                 if (previousSibling) {
     379                if (previousSiblingProtector) {
    374380                    // Since we had a suitable previous counter before, we should only consider this one as our
    375381                    // previousSibling if it is a reset counter and hence the current previousSibling is its child.
    376382                    if (currentCounter->actsAsReset()) {
    377                         previousSibling = currentCounter;
     383                        previousSiblingProtector = currentCounter;
    378384                        // We are no longer interested in previous siblings of the currentRenderer or their children
    379385                        // as counters they may have attached cannot be the previous sibling of the counter we are placing.
     
    382388                    }
    383389                } else
    384                     previousSibling = currentCounter;
     390                    previousSiblingProtector = currentCounter;
    385391                currentRenderer = previousSiblingOrParent(currentRenderer);
    386392                continue;
     
    391397        // performance improvement would create more code duplication than is worthwhile in my oppinion and may further
    392398        // impede the readability of this already complex algorithm.
    393         if (previousSibling)
     399        if (previousSiblingProtector)
    394400            currentRenderer = previousSiblingOrParent(currentRenderer);
    395401        else
Note: See TracChangeset for help on using the changeset viewer.