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

Unified Diff: third_party/WebKit/Source/core/svg/SVGTitleElement.cpp

Issue 1752713002: Fix SVGDocument return title that is not a child of the root element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGTitleElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGTitleElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGTitleElement.cpp b/third_party/WebKit/Source/core/svg/SVGTitleElement.cpp
index 062cdb539a6fd0a4641394a655071217b97a5259..ebe19d2f210901b33c7ce558b534d37f1fc82bf7 100644
--- a/third_party/WebKit/Source/core/svg/SVGTitleElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGTitleElement.cpp
@@ -21,12 +21,15 @@
#include "core/svg/SVGTitleElement.h"
#include "core/SVGNames.h"
+#include "core/dom/ChildListMutationScope.h"
#include "core/dom/Document.h"
+#include "core/dom/Text.h"
namespace blink {
inline SVGTitleElement::SVGTitleElement(Document& document)
: SVGElement(SVGNames::titleTag, document)
+ , m_ignoreTitleUpdatesWhenChildrenChange(false)
{
}
@@ -52,8 +55,23 @@ void SVGTitleElement::removedFrom(ContainerNode* rootParent)
void SVGTitleElement::childrenChanged(const ChildrenChange& change)
{
SVGElement::childrenChanged(change);
- if (inDocument() && document().isSVGDocument())
+ if (inDocument() && document().isSVGDocument() && !m_ignoreTitleUpdatesWhenChildrenChange)
document().setTitleElement(this);
}
+void SVGTitleElement::setText(const String& value)
+{
+ RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this);
+ ChildListMutationScope mutation(*this);
+
+ {
+ // Avoid calling Document::setTitleElement() during intermediate steps.
+ TemporaryChange<bool> inhibitTitleUpdateScope(m_ignoreTitleUpdatesWhenChildrenChange, !value.isEmpty());
+ removeChildren(OmitSubtreeModifiedEvent);
+ }
+
+ if (!value.isEmpty())
+ appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGTitleElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698