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

Unified Diff: third_party/WebKit/Source/core/html/ImageDocument.cpp

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Last nits Created 4 years, 9 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
Index: third_party/WebKit/Source/core/html/ImageDocument.cpp
diff --git a/third_party/WebKit/Source/core/html/ImageDocument.cpp b/third_party/WebKit/Source/core/html/ImageDocument.cpp
index 845152f0d3de10c18d6022ea074d79a59a661c3c..29e2ba9eb916bea219657e9f910b28a18ddda41e 100644
--- a/third_party/WebKit/Source/core/html/ImageDocument.cpp
+++ b/third_party/WebKit/Source/core/html/ImageDocument.cpp
@@ -146,9 +146,7 @@ void ImageDocumentParser::appendBytes(const char* data, size_t length)
document()->cachedImage()->appendData(data, length);
}
- // TODO(esprehn): These null checks on Document don't make sense, document()
- // will ASSERT if it was null. Do these want to check isDetached() ?
- if (document())
+ if (!isDetached())
document()->imageUpdated();
}
@@ -171,14 +169,14 @@ void ImageDocumentParser::finish()
if (fileName.isEmpty())
fileName = document()->url().host();
document()->setTitle(imageTitle(fileName, size));
+ if (isDetached())
+ return;
}
document()->imageUpdated();
}
- // TODO(esprehn): These null checks on Document don't make sense, document()
- // will ASSERT if it was null. Do these want to check isDetached() ?
- if (document())
+ if (!isDetached())
document()->finishedParsing();
}
@@ -207,8 +205,10 @@ void ImageDocument::createDocumentStructure()
appendChild(rootElement);
rootElement->insertedByParser();
- if (frame())
- frame()->loader().dispatchDocumentElementAvailable();
+ frame()->loader().dispatchDocumentElementAvailable();
+ frame()->loader().runScriptsAtDocumentElementAvailable();
+ if (isStopped())
+ return; // runScriptsAtDocumentElementAvailable can detach the frame.
RefPtrWillBeRawPtr<HTMLHeadElement> head = HTMLHeadElement::create(*this);
RefPtrWillBeRawPtr<HTMLMetaElement> meta = HTMLMetaElement::create(*this);
@@ -219,8 +219,7 @@ void ImageDocument::createDocumentStructure()
RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*this);
body->setAttribute(styleAttr, "margin: 0px;");
- if (frame())
- frame()->loader().client()->dispatchWillInsertBody();
+ frame()->loader().client()->dispatchWillInsertBody();
m_imageElement = HTMLImageElement::create(*this);
m_imageElement->setAttribute(styleAttr, "-webkit-user-select: none");
@@ -405,8 +404,13 @@ void ImageDocument::windowSizeChanged(ScaleType type)
ImageResource* ImageDocument::cachedImage()
{
- if (!m_imageElement)
+ if (!m_imageElement) {
createDocumentStructure();
+ if (isStopped()) {
+ m_imageElement = nullptr;
+ return nullptr;
+ }
+ }
return m_imageElement->cachedImage();
}
« no previous file with comments | « extensions/shell/renderer/shell_content_renderer_client.cc ('k') | third_party/WebKit/Source/core/html/MediaDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698