summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/rendering/RenderObjectChildList.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-18 13:36:51 +0100
committerSteve Block <steveblock@google.com>2011-05-24 15:38:28 +0100
commit2fc2651226baac27029e38c9d6ef883fa32084db (patch)
treee396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/rendering/RenderObjectChildList.cpp
parentb3725cedeb43722b3b175aaeff70552e562d2c94 (diff)
downloadexternal_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/rendering/RenderObjectChildList.cpp')
-rw-r--r--Source/WebCore/rendering/RenderObjectChildList.cpp130
1 files changed, 72 insertions, 58 deletions
diff --git a/Source/WebCore/rendering/RenderObjectChildList.cpp b/Source/WebCore/rendering/RenderObjectChildList.cpp
index fa4f902..6a773dc 100644
--- a/Source/WebCore/rendering/RenderObjectChildList.cpp
+++ b/Source/WebCore/rendering/RenderObjectChildList.cpp
@@ -128,6 +128,9 @@ RenderObject* RenderObjectChildList::removeChildNode(RenderObject* owner, Render
oldChild->setNextSibling(0);
oldChild->setParent(0);
+ if (oldChild->m_hasCounterNodeMap)
+ RenderCounter::destroyCounterNodes(oldChild);
+
if (AXObjectCache::accessibilityEnabled())
owner->document()->axObjectCache()->childrenChanged(owner);
@@ -175,6 +178,7 @@ void RenderObjectChildList::appendChildNode(RenderObject* owner, RenderObject* n
owner->dirtyLinesFromChangedChild(newChild);
}
+ RenderCounter::rendererSubtreeAttached(newChild);
newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing block hierarchy.
if (!owner->normalChildNeedsLayout())
owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.
@@ -234,6 +238,7 @@ void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* c
owner->dirtyLinesFromChangedChild(child);
}
+ RenderCounter::rendererSubtreeAttached(child);
child->setNeedsLayoutAndPrefWidthsRecalc();
if (!owner->normalChildNeedsLayout())
owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.
@@ -242,59 +247,6 @@ void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* c
owner->document()->axObjectCache()->childrenChanged(owner);
}
-static RenderObject* beforeAfterContainer(RenderObject* container, PseudoId type)
-{
- if (type == BEFORE) {
- // An anonymous (generated) inline run-in that has PseudoId BEFORE must come from a grandparent.
- // Therefore we should skip these generated run-ins when checking our immediate children.
- // If we don't find our :before child immediately, then we should check if we own a
- // generated inline run-in in the next level of children.
- RenderObject* first = container;
- do {
- // Skip list markers and generated run-ins
- first = first->firstChild();
- while (first && (first->isListMarker() || (first->isRenderInline() && first->isRunIn() && first->isAnonymous())))
- first = first->nextSibling();
- } while (first && first->isAnonymous() && first->style()->styleType() == NOPSEUDO);
-
- if (!first)
- return 0;
-
- if (first->style()->styleType() == type)
- return first;
-
- // Check for a possible generated run-in, using run-in positioning rules.
- // Skip inlines and floating / positioned blocks, and place as the first child.
- first = container->firstChild();
- if (!first->isRenderBlock())
- return 0;
- while (first && first->isFloatingOrPositioned())
- first = first->nextSibling();
- if (first) {
- first = first->firstChild();
- // We still need to skip any list markers that could exist before the run-in.
- while (first && first->isListMarker())
- first = first->nextSibling();
- if (first && first->style()->styleType() == type && first->isRenderInline() && first->isRunIn() && first->isAnonymous())
- return first;
- }
- return 0;
- }
-
- if (type == AFTER) {
- RenderObject* last = container;
- do {
- last = last->lastChild();
- } while (last && last->isAnonymous() && last->style()->styleType() == NOPSEUDO && !last->isListMarker());
- if (last && last->style()->styleType() != type)
- return 0;
- return last;
- }
-
- ASSERT_NOT_REACHED();
- return 0;
-}
-
static RenderObject* findBeforeAfterParent(RenderObject* object)
{
// Only table parts need to search for the :before or :after parent
@@ -325,14 +277,63 @@ static void invalidateCountersInContainer(RenderObject* container, const AtomicS
}
}
-void RenderObjectChildList::invalidateCounters(RenderObject* owner, const AtomicString& identifier)
+void RenderObjectChildList::invalidateCounters(const RenderObject* owner, const AtomicString& identifier)
{
ASSERT(!owner->documentBeingDestroyed());
- invalidateCountersInContainer(beforeAfterContainer(owner, BEFORE), identifier);
- invalidateCountersInContainer(beforeAfterContainer(owner, AFTER), identifier);
+ invalidateCountersInContainer(beforePseudoElementRenderer(owner), identifier);
+ invalidateCountersInContainer(afterPseudoElementRenderer(owner), identifier);
}
-void RenderObjectChildList::updateBeforeAfterContent(RenderObject* owner, PseudoId type, RenderObject* styledObject)
+RenderObject* RenderObjectChildList::beforePseudoElementRenderer(const RenderObject* owner) const
+{
+ // An anonymous (generated) inline run-in that has PseudoId BEFORE must come from a grandparent.
+ // Therefore we should skip these generated run-ins when checking our immediate children.
+ // If we don't find our :before child immediately, then we should check if we own a
+ // generated inline run-in in the next level of children.
+ RenderObject* first = const_cast<RenderObject*>(owner);
+ do {
+ // Skip list markers and generated run-ins
+ first = first->firstChild();
+ while (first && (first->isListMarker() || (first->isRenderInline() && first->isRunIn() && first->isAnonymous())))
+ first = first->nextSibling();
+ } while (first && first->isAnonymous() && first->style()->styleType() == NOPSEUDO);
+
+ if (!first)
+ return 0;
+
+ if (first->style()->styleType() == BEFORE)
+ return first;
+
+ // Check for a possible generated run-in, using run-in positioning rules.
+ // Skip inlines and floating / positioned blocks, and place as the first child.
+ first = owner->firstChild();
+ if (!first->isRenderBlock())
+ return 0;
+ while (first && first->isFloatingOrPositioned())
+ first = first->nextSibling();
+ if (first) {
+ first = first->firstChild();
+ // We still need to skip any list markers that could exist before the run-in.
+ while (first && first->isListMarker())
+ first = first->nextSibling();
+ if (first && first->style()->styleType() == BEFORE && first->isRenderInline() && first->isRunIn() && first->isAnonymous())
+ return first;
+ }
+ return 0;
+}
+
+RenderObject* RenderObjectChildList::afterPseudoElementRenderer(const RenderObject* owner) const
+{
+ RenderObject* last = const_cast<RenderObject*>(owner);
+ do {
+ last = last->lastChild();
+ } while (last && last->isAnonymous() && last->style()->styleType() == NOPSEUDO && !last->isListMarker());
+ if (last && last->style()->styleType() != AFTER)
+ return 0;
+ return last;
+}
+
+void RenderObjectChildList::updateBeforeAfterContent(RenderObject* owner, PseudoId type, const RenderObject* styledObject)
{
// Double check that the document did in fact use generated content rules. Otherwise we should not have been called.
ASSERT(owner->document()->usesBeforeAfterRules());
@@ -345,7 +346,18 @@ void RenderObjectChildList::updateBeforeAfterContent(RenderObject* owner, Pseudo
styledObject = owner;
RenderStyle* pseudoElementStyle = styledObject->getCachedPseudoStyle(type);
- RenderObject* child = beforeAfterContainer(owner, type);
+ RenderObject* child;
+ switch (type) {
+ case BEFORE:
+ child = beforePseudoElementRenderer(owner);
+ break;
+ case AFTER:
+ child = afterPseudoElementRenderer(owner);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
// Whether or not we currently have generated content attached.
bool oldContentPresent = child;
@@ -459,6 +471,8 @@ void RenderObjectChildList::updateBeforeAfterContent(RenderObject* owner, Pseudo
// Make a generated box that might be any display type now that we are able to drill down into children
// to find the original content properly.
generatedContentContainer = RenderObject::createObject(owner->document(), pseudoElementStyle);
+ ASSERT(styledObject->node()); // The styled object cannot be anonymous or else it could not have ':before' or ':after' pseudo elements.
+ generatedContentContainer->setNode(styledObject->node()); // This allows access to the generatingNode.
generatedContentContainer->setStyle(pseudoElementStyle);
owner->addChild(generatedContentContainer, insertBefore);
}