Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1090)

Unified Diff: Source/core/html/HTMLTitleElement.cpp

Issue 128603002: Inhibit title update when removing children before setting new value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/core/dom/Document.cpp ('K') | « Source/core/html/HTMLTitleElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTitleElement.cpp
diff --git a/Source/core/html/HTMLTitleElement.cpp b/Source/core/html/HTMLTitleElement.cpp
index fc50fdc83c2fa64a66f3baf86492d44b4e87217b..8e6ca9aa5348cb9bccdf3d7bd69fe7e535ee3bbd 100644
--- a/Source/core/html/HTMLTitleElement.cpp
+++ b/Source/core/html/HTMLTitleElement.cpp
@@ -37,6 +37,7 @@ using namespace HTMLNames;
inline HTMLTitleElement::HTMLTitleElement(Document& document)
: HTMLElement(titleTag, document)
+ , m_ignoreTitleUpdatesWhenChildrenChange(false)
{
setHasCustomStyleCallbacks();
ScriptWrappable::init(this);
@@ -65,7 +66,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);
}
@@ -90,15 +91,12 @@ void HTMLTitleElement::setText(const String &value)
if (numChildren == 1 && firstChild()->isTextNode())
toText(firstChild())->setData(value);
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 in Document::setTitleElement().
- String valueCopy(value);
-
- if (numChildren > 0)
+ if (numChildren > 0) {
+ IgnoreTitleUpdatesWhenChildrenChange inhibitor(this);
jochen (gone - plz use gerrit) 2014/01/09 12:17:33 here you can then set the bool directly and don't
removeChildren();
+ }
- appendChild(document().createTextNode(valueCopy.impl()), IGNORE_EXCEPTION);
+ appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION);
}
}
« Source/core/dom/Document.cpp ('K') | « Source/core/html/HTMLTitleElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698