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

Unified Diff: Source/WebCore/html/HTMLBodyElement.cpp

Issue 7169001: Merge 88601 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 6 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 | « Source/WebCore/html/HTMLBodyElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/html/HTMLBodyElement.cpp
===================================================================
--- Source/WebCore/html/HTMLBodyElement.cpp (revision 88860)
+++ Source/WebCore/html/HTMLBodyElement.cpp (working copy)
@@ -116,6 +116,13 @@
} else if (attr->name() == vlinkAttr ||
attr->name() == alinkAttr ||
attr->name() == linkAttr) {
+ // This tells us that we are removed from document. If our document is later destroyed
+ // (not deleted since we hold a guardRef), our stylesheet list will be null causing a crash
+ // later in document()->styleSelector(). So, we bail out early because we shouldn't be
+ // modifying anything in that document. See webkit bug 62230.
+ if (m_linkDecl && !m_linkDecl->parent())
+ return;
+
if (attr->isNull()) {
if (attr->name() == linkAttr)
document()->resetLinkColor();
@@ -202,8 +209,27 @@
if (document() && document()->page())
document()->page()->updateViewportArguments();
+
+ if (m_linkDecl)
+ m_linkDecl->setParent(document()->elementSheet());
}
+void HTMLBodyElement::removedFromDocument()
+{
+ if (m_linkDecl)
+ m_linkDecl->setParent(0);
+
+ HTMLElement::removedFromDocument();
+}
+
+void HTMLBodyElement::didMoveToNewOwnerDocument()
+{
+ if (m_linkDecl)
+ m_linkDecl->setParent(document()->elementSheet());
+
+ HTMLElement::didMoveToNewOwnerDocument();
+}
+
bool HTMLBodyElement::isURLAttribute(Attribute *attr) const
{
return attr->name() == backgroundAttr;
@@ -345,16 +371,4 @@
addSubresourceURL(urls, document()->completeURL(getAttribute(backgroundAttr)));
}
-void HTMLBodyElement::didMoveToNewOwnerDocument()
-{
- // When moving body elements between documents, we should have to reset the parent sheet for any
- // link style declarations. If we don't we might crash later.
- // In practice I can't reproduce this theoretical problem.
- // webarchive/adopt-attribute-styled-body-webarchive.html tries to make sure this crash won't surface.
- if (m_linkDecl)
- m_linkDecl->setParent(document()->elementSheet());
-
- HTMLElement::didMoveToNewOwnerDocument();
-}
-
} // namespace WebCore
« no previous file with comments | « Source/WebCore/html/HTMLBodyElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698