| Index: Source/core/html/HTMLTitleElement.cpp
|
| diff --git a/Source/core/html/HTMLTitleElement.cpp b/Source/core/html/HTMLTitleElement.cpp
|
| index 872ca280e1356f5134c9bc1c04d0ee49e34acffe..ff62d1c92a0824c76b4ba392ea626248a62fec5d 100644
|
| --- a/Source/core/html/HTMLTitleElement.cpp
|
| +++ b/Source/core/html/HTMLTitleElement.cpp
|
| @@ -25,6 +25,7 @@
|
|
|
| #include "HTMLNames.h"
|
| #include "bindings/v8/ExceptionStatePlaceholder.h"
|
| +#include "core/dom/ChildListMutationScope.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/Text.h"
|
| #include "core/rendering/style/RenderStyle.h"
|
| @@ -37,6 +38,7 @@ using namespace HTMLNames;
|
|
|
| inline HTMLTitleElement::HTMLTitleElement(Document& document)
|
| : HTMLElement(titleTag, document)
|
| + , m_ignoreTitleUpdatesWhenChildrenChange(false)
|
| {
|
| setHasCustomStyleCallbacks();
|
| ScriptWrappable::init(this);
|
| @@ -65,7 +67,7 @@ void HTMLTitleElement::removedFrom(ContainerNode* insertionPoint)
|
| void HTMLTitleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
|
| {
|
| HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
|
| - if (inDocument() && !isInShadowTree())
|
| + if (inDocument() && !isInShadowTree() && !m_ignoreTitleUpdatesWhenChildrenChange)
|
| document().setTitleElement(text(), this);
|
| }
|
|
|
| @@ -84,23 +86,14 @@ String HTMLTitleElement::text() const
|
| void HTMLTitleElement::setText(const String &value)
|
| {
|
| RefPtr<Node> protectFromMutationEvents(this);
|
| + ChildListMutationScope mutation(*this);
|
|
|
| - int numChildren = childNodeCount();
|
| -
|
| - if (numChildren == 1 && firstChild()->isTextNode()) {
|
| - toText(firstChild())->setData(value);
|
| - document().setTitleElement(text(), this);
|
| - } else {
|
| - // We make a copy here because entity of "value" argument can be Document::m_title,
|
| - // which goes empty during removeChildren() invocation below,
|
| - // which causes HTMLTitleElement::childrenChanged(), which ends up Document::setTitle().
|
| - String valueCopy(value);
|
| + // Avoid calling Document::setTitleElement() during intermediate steps.
|
| + m_ignoreTitleUpdatesWhenChildrenChange = true;
|
| + removeChildren();
|
| + m_ignoreTitleUpdatesWhenChildrenChange = false;
|
|
|
| - if (numChildren > 0)
|
| - removeChildren();
|
| -
|
| - appendChild(document().createTextNode(valueCopy.impl()), IGNORE_EXCEPTION);
|
| - }
|
| + appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION);
|
| }
|
|
|
| }
|
|
|