Commit 555f92e7 authored by antti@apple.com's avatar antti@apple.com

Call createTextRenderersForSiblingsAfterAttachIfNeeded only for the attach root

https://bugs.webkit.org/show_bug.cgi?id=120770

Reviewed by Andreas Kling.

There is no need to call this during recursive attach as siblings are going to be attached normally anyway.
Move call sites to attach roots only.

* style/StyleResolveTree.cpp:
(WebCore::Style::createTextRenderersForSiblingsAfterAttachIfNeeded):
        
    Factor to take reference and do the inital tests itself.

(WebCore::Style::createTextRendererIfNeeded):
(WebCore::Style::updateTextRendererAfterContentChange):
(WebCore::Style::attachChildren):
        
    Also tightened the condition where previously attached children may be encountered.

(WebCore::Style::attachRenderTree):
(WebCore::Style::resolveLocal):
(WebCore::Style::updateTextStyle):
(WebCore::Style::reattachRenderTree):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4d7e4e29
2013-09-05 Antti Koivisto <antti@apple.com>
Call createTextRenderersForSiblingsAfterAttachIfNeeded only for the attach root
https://bugs.webkit.org/show_bug.cgi?id=120770
Reviewed by Andreas Kling.
There is no need to call this during recursive attach as siblings are going to be attached normally anyway.
Move call sites to attach roots only.
* style/StyleResolveTree.cpp:
(WebCore::Style::createTextRenderersForSiblingsAfterAttachIfNeeded):
Factor to take reference and do the inital tests itself.
(WebCore::Style::createTextRendererIfNeeded):
(WebCore::Style::updateTextRendererAfterContentChange):
(WebCore::Style::attachChildren):
Also tightened the condition where previously attached children may be encountered.
(WebCore::Style::attachRenderTree):
(WebCore::Style::resolveLocal):
(WebCore::Style::updateTextStyle):
(WebCore::Style::reattachRenderTree):
2013-09-05 Enrique Ocaña González <eocanha@igalia.com>
[GTK] Assertion fails when the mouse pointer is styled with a custom cursor
......@@ -280,22 +280,19 @@ static RenderObject* nextSiblingRenderer(const Text& textNode)
return 0;
}
static void createTextRenderersForSiblingsAfterAttachIfNeeded(Node* sibling)
static void createTextRenderersForSiblingsAfterAttachIfNeeded(Node& node)
{
ASSERT(sibling->previousSibling());
ASSERT(sibling->previousSibling()->renderer());
ASSERT(!sibling->renderer());
ASSERT(sibling->attached());
if (!node.renderer())
return;
// If this node got a renderer it may be the previousRenderer() of sibling text nodes and thus affect the
// result of Text::textRendererIsNeeded() for those nodes.
for (; sibling; sibling = sibling->nextSibling()) {
for (Node* sibling = node.nextSibling(); sibling; sibling = sibling->nextSibling()) {
if (sibling->renderer())
break;
if (!sibling->attached())
break; // Assume this means none of the following siblings are attached.
if (!sibling->isTextNode())
continue;
ASSERT(!sibling->renderer());
attachTextRenderer(*toText(sibling));
// If we again decided not to create a renderer for next, we can bail out the loop,
// because it won't affect the result of Text::textRendererIsNeeded() for the rest
......@@ -385,10 +382,6 @@ static void createTextRendererIfNeeded(Text& textNode)
// Parent takes care of the animations, no need to call setAnimatableStyle.
newRenderer->setStyle(style.release());
parentRenderer->addChild(newRenderer, nextRenderer);
Node* sibling = textNode.nextSibling();
if (sibling && !sibling->renderer() && sibling->attached())
createTextRenderersForSiblingsAfterAttachIfNeeded(sibling);
}
void attachTextRenderer(Text& textNode)
......@@ -414,6 +407,7 @@ void updateTextRendererAfterContentChange(Text& textNode, unsigned offsetOfRepla
RenderText* textRenderer = toRenderText(textNode.renderer());
if (!textRenderer) {
attachTextRenderer(textNode);
createTextRenderersForSiblingsAfterAttachIfNeeded(textNode);
return;
}
RenderObject* parentRenderer = NodeRenderingTraversal::parent(&textNode)->renderer();
......@@ -425,23 +419,10 @@ void updateTextRendererAfterContentChange(Text& textNode, unsigned offsetOfRepla
textRenderer->setTextWithOffset(textNode.dataImpl(), offsetOfReplacedData, lengthOfReplacedData);
}
#ifndef NDEBUG
static bool childAttachedAllowedWhenAttachingChildren(ContainerNode& node)
{
if (node.isShadowRoot())
return true;
if (node.isInsertionPoint())
return true;
if (node.isElementNode() && toElement(&node)->shadowRoot())
return true;
return false;
}
#endif
static void attachChildren(ContainerNode& current)
{
for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
ASSERT(!child->attached() || childAttachedAllowedWhenAttachingChildren(current));
ASSERT(!child->attached() || current.shadowRoot());
if (child->attached())
continue;
if (child->isTextNode()) {
......@@ -494,10 +475,6 @@ static void attachRenderTree(Element& current, RenderStyle* resolvedStyle)
attachChildren(current);
Node* sibling = current.nextSibling();
if (current.renderer() && sibling && !sibling->renderer() && sibling->attached())
createTextRenderersForSiblingsAfterAttachIfNeeded(sibling);
current.setAttached(true);
current.clearNeedsStyleRecalc();
......@@ -612,6 +589,8 @@ static Change resolveLocal(Element& current, Change inheritedChange)
if (current.attached())
detachRenderTree(current, ReattachDetach);
attachRenderTree(current, newStyle.get());
createTextRenderersForSiblingsAfterAttachIfNeeded(current);
return Detach;
}
......@@ -652,8 +631,10 @@ static void updateTextStyle(Text& text, RenderStyle* parentElementStyle, Style::
return;
if (renderer)
renderer->setText(text.dataImpl());
else
else {
attachTextRenderer(text);
createTextRenderersForSiblingsAfterAttachIfNeeded(text);
}
text.clearNeedsStyleRecalc();
}
......@@ -836,6 +817,7 @@ void resolveTree(Document& document, Change change)
void attachRenderTree(Element& element)
{
attachRenderTree(element, nullptr);
createTextRenderersForSiblingsAfterAttachIfNeeded(element);
}
void detachRenderTree(Element& element)
......@@ -852,7 +834,7 @@ void reattachRenderTree(Element& current)
{
if (current.attached())
detachRenderTree(current, ReattachDetach);
attachRenderTree(current, nullptr);
attachRenderTree(current);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment