diff options
| author | Steve Block <steveblock@google.com> | 2011-06-08 08:26:01 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-08 08:26:01 -0700 |
| commit | 3742ac093d35d923c81693096ab6671e9b147700 (patch) | |
| tree | c2add9100f789dad45ef1ec5328bddde02c47a4c /Source/WebCore/rendering/CounterNode.cpp | |
| parent | 901401d90459bc22580842455d4588b9a697514d (diff) | |
| parent | e5926f4a0d6adc9ad4a75824129f117181953560 (diff) | |
| download | external_webkit-3742ac093d35d923c81693096ab6671e9b147700.zip external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.gz external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.bz2 | |
Merge changes I55c6d71a,Ifb3277d4,Ia1b847a2,I7ba9cf3f,Ida2b2a8a,I1280ec90,I72f818d5,I2e3b588b,I9a4e6289,Ia724c78b,Icd8612c8,Ie31b15d7,Ie125edae,I77941a88,I89dae78b,I3516e5ca,I1a4c17b5,I2c4ecc1a,I9c8e6537,Ifac13115,Ie1f80e09,Ia541ed77,I60ce9d78
* changes:
Merge WebKit at r82507: Update ThirdPartyProject.prop
Merge WebKit at r82507: Cherry-pick change r88166 to add INSPECTOR guards to ScriptProfiler
Merge WebKit at r82507: Work around a V8 bug
Merge WebKit at r82507: JNIType renamed to JavaType
Merge WebKit at r82507: IconDatabaseClient interface expanded
Merge WebKit at r82507: Don't use new loss-free code path in HTMLCanvasElement::toDataURL()
Merge WebKit at r82507: IcondDatabaseBase::iconForPageURL() renamed
Merge WebKit at r82507: IconDatabaseBase::Open() signature changed
Merge WebKit at r82507: Node::isContentEditable() renamed
Merge WebKit at r82507: Use icon database through IconDatabaseBase
Merge WebKit at r82507: toInputElement() is now a member of Node
Merge WebKit at r82507: FrameLoaderClient::objectContentType() signature changed
Merge WebKit at r82507: StringImpl::computeHash() removed
Merge WebKit at r82507: Stub out FontPlatformData::setOrientation()
Merge WebKit at r82507: Path::strokeBoundingRect() is now const
Merge WebKit at r82507: Add missing UnusedParam.h include in ApplicationCacheGroup.cpp
Merge WebKit at r82507: Continue to use Android's version of FontPlatformData.h
Merge WebKit at r82507: Update signature of FontCustomPlatformData::fontPlatformData()
Merge WebKit at r82507: Fix conflicts due to JNI refactoring
Merge WebKit at r82507: Fix conflicts due to new StorageTracker
Merge WebKit at r82507: Fix conflicts
Merge WebKit at r82507: Fix makefiles
Merge WebKit at r82507: Initial merge by git
Diffstat (limited to 'Source/WebCore/rendering/CounterNode.cpp')
| -rw-r--r-- | Source/WebCore/rendering/CounterNode.cpp | 99 |
1 files changed, 79 insertions, 20 deletions
diff --git a/Source/WebCore/rendering/CounterNode.cpp b/Source/WebCore/rendering/CounterNode.cpp index eadd386..323f5db 100644 --- a/Source/WebCore/rendering/CounterNode.cpp +++ b/Source/WebCore/rendering/CounterNode.cpp @@ -32,7 +32,8 @@ CounterNode::CounterNode(RenderObject* o, bool hasResetType, int value) : m_hasResetType(hasResetType) , m_value(value) , m_countInParent(0) - , m_renderer(o) + , m_owner(o) + , m_rootRenderer(0) , m_parent(0) , m_previousSibling(0) , m_nextSibling(0) @@ -41,9 +42,14 @@ CounterNode::CounterNode(RenderObject* o, bool hasResetType, int value) { } -PassRefPtr<CounterNode> CounterNode::create(RenderObject* renderer, bool hasResetType, int value) +CounterNode::~CounterNode() { - return adoptRef(new CounterNode(renderer, hasResetType, value)); + resetRenderers(); +} + +PassRefPtr<CounterNode> CounterNode::create(RenderObject* owner, bool hasResetType, int value) +{ + return adoptRef(new CounterNode(owner, hasResetType, value)); } CounterNode* CounterNode::nextInPreOrderAfterChildren(const CounterNode* stayWithin) const @@ -102,24 +108,76 @@ int CounterNode::computeCountInParent() const return m_parent->m_value + increment; } -void CounterNode::resetRenderer(const AtomicString& identifier) const +void CounterNode::addRenderer(RenderCounter* value) +{ + if (!value) { + ASSERT_NOT_REACHED(); + return; + } + if (value->m_counterNode) { + ASSERT_NOT_REACHED(); + value->m_counterNode->removeRenderer(value); + } + ASSERT(!value->m_nextForSameCounter); + for (RenderCounter* iterator = m_rootRenderer;iterator; iterator = iterator->m_nextForSameCounter) { + if (iterator == value) { + ASSERT_NOT_REACHED(); + return; + } + } + value->m_nextForSameCounter = m_rootRenderer; + m_rootRenderer = value; + if (value->m_counterNode != this) { + if (value->m_counterNode) { + ASSERT_NOT_REACHED(); + value->m_counterNode->removeRenderer(value); + } + value->m_counterNode = this; + } +} + +void CounterNode::removeRenderer(RenderCounter* value) { - if (!m_renderer || m_renderer->documentBeingDestroyed()) + if (!value) { + ASSERT_NOT_REACHED(); return; - if (RenderObjectChildList* children = m_renderer->virtualChildren()) - children->invalidateCounters(m_renderer, identifier); + } + if (value->m_counterNode && value->m_counterNode != this) { + ASSERT_NOT_REACHED(); + value->m_counterNode->removeRenderer(value); + } + RenderCounter* previous = 0; + for (RenderCounter* iterator = m_rootRenderer;iterator; iterator = iterator->m_nextForSameCounter) { + if (iterator == value) { + if (previous) + previous->m_nextForSameCounter = value->m_nextForSameCounter; + else + m_rootRenderer = value->m_nextForSameCounter; + value->m_nextForSameCounter = 0; + value->m_counterNode = 0; + return; + } + previous = iterator; + } + ASSERT_NOT_REACHED(); +} + +void CounterNode::resetRenderers() +{ + while (m_rootRenderer) + m_rootRenderer->invalidate(); // This makes m_rootRenderer point to the next renderer if any since it disconnects the m_rootRenderer from this. } -void CounterNode::resetRenderers(const AtomicString& identifier) const +void CounterNode::resetThisAndDescendantsRenderers() { - const CounterNode* node = this; + CounterNode* node = this; do { - node->resetRenderer(identifier); + node->resetRenderers(); node = node->nextInPreOrder(this); } while (node); } -void CounterNode::recount(const AtomicString& identifier) +void CounterNode::recount() { for (CounterNode* node = this; node; node = node->m_nextSibling) { int oldCount = node->m_countInParent; @@ -127,7 +185,7 @@ void CounterNode::recount(const AtomicString& identifier) if (oldCount == newCount) break; node->m_countInParent = newCount; - node->resetRenderers(identifier); + node->resetThisAndDescendantsRenderers(); } } @@ -141,7 +199,7 @@ void CounterNode::insertAfter(CounterNode* newChild, CounterNode* refChild, cons if (newChild->m_hasResetType) { while (m_lastChild != refChild) - RenderCounter::destroyCounterNode(m_lastChild->renderer(), identifier); + RenderCounter::destroyCounterNode(m_lastChild->owner(), identifier); } CounterNode* next; @@ -168,9 +226,9 @@ void CounterNode::insertAfter(CounterNode* newChild, CounterNode* refChild, cons } newChild->m_countInParent = newChild->computeCountInParent(); - newChild->resetRenderers(identifier); + newChild->resetThisAndDescendantsRenderers(); if (next) - next->recount(identifier); + next->recount(); return; } @@ -203,11 +261,11 @@ void CounterNode::insertAfter(CounterNode* newChild, CounterNode* refChild, cons newChild->m_firstChild = 0; newChild->m_lastChild = 0; newChild->m_countInParent = newChild->computeCountInParent(); - newChild->resetRenderer(identifier); - first->recount(identifier); + newChild->resetRenderers(); + first->recount(); } -void CounterNode::removeChild(CounterNode* oldChild, const AtomicString& identifier) +void CounterNode::removeChild(CounterNode* oldChild) { ASSERT(oldChild); ASSERT(!oldChild->m_firstChild); @@ -235,7 +293,7 @@ void CounterNode::removeChild(CounterNode* oldChild, const AtomicString& identif } if (next) - next->recount(identifier); + next->recount(); } #ifndef NDEBUG @@ -253,8 +311,9 @@ static void showTreeAndMark(const CounterNode* node) fprintf(stderr, "%p %s: %d %d P:%p PS:%p NS:%p R:%p\n", current, current->actsAsReset() ? "reset____" : "increment", current->value(), current->countInParent(), current->parent(), current->previousSibling(), - current->nextSibling(), current->renderer()); + current->nextSibling(), current->owner()); } + fflush(stderr); } #endif |
