Diff
Modified: trunk/Source/WebCore/ChangeLog (99327 => 99328)
--- trunk/Source/WebCore/ChangeLog 2011-11-04 22:16:25 UTC (rev 99327)
+++ trunk/Source/WebCore/ChangeLog 2011-11-04 22:24:17 UTC (rev 99328)
@@ -1,3 +1,22 @@
+2011-11-04 Michael Nordman <[email protected]>
+
+ Allow ScriptExecutionContext::addMessage to be called from background threads.
+ https://bugs.webkit.org/show_bug.cgi?id=71575
+
+ Reviewed by Nate Chapin.
+
+ No new tests.
+
+ * dom/Document.cpp:
+ (WebCore::Document::addMessage):
+ * dom/ScriptExecutionContext.cpp:
+ * dom/ScriptExecutionContext.h:
+ (WebCore::ScriptExecutionContext::AddConsoleMessageTask::create):
+ (WebCore::ScriptExecutionContext::AddConsoleMessageTask::performTask):
+ (WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask):
+ * workers/WorkerContext.cpp:
+ (WebCore::WorkerContext::addMessage):
+
2011-11-04 Shawn Singh <[email protected]>
[chromium] Re-named the original scissorRect to clipRect
Modified: trunk/Source/WebCore/dom/Document.cpp (99327 => 99328)
--- trunk/Source/WebCore/dom/Document.cpp 2011-11-04 22:16:25 UTC (rev 99327)
+++ trunk/Source/WebCore/dom/Document.cpp 2011-11-04 22:24:17 UTC (rev 99328)
@@ -4603,6 +4603,11 @@
void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
{
+ if (!isContextThread()) {
+ postTask(AddConsoleMessageTask::create(source, type, level, message));
+ return;
+ }
+
if (DOMWindow* window = domWindow())
window->console()->addMessage(source, type, level, message, lineNumber, sourceURL, callStack);
}
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (99327 => 99328)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2011-11-04 22:16:25 UTC (rev 99327)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2011-11-04 22:24:17 UTC (rev 99328)
@@ -83,6 +83,11 @@
RefPtr<ScriptCallStack> m_callStack;
};
+void ScriptExecutionContext::AddConsoleMessageTask::performTask(ScriptExecutionContext *context)
+{
+ context->addMessage(m_source, m_type, m_level, m_message, 0, String(), 0);
+}
+
ScriptExecutionContext::ScriptExecutionContext()
: m_iteratingActiveDOMObjects(false)
, m_inDestructor(false)
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (99327 => 99328)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.h 2011-11-04 22:16:25 UTC (rev 99327)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h 2011-11-04 22:24:17 UTC (rev 99328)
@@ -163,6 +163,27 @@
virtual EventQueue* eventQueue() const = 0;
protected:
+ class AddConsoleMessageTask : public Task {
+ public:
+ static PassOwnPtr<AddConsoleMessageTask> create(MessageSource source, MessageType type, MessageLevel level, const String& message)
+ {
+ return adoptPtr(new AddConsoleMessageTask(source, type, level, message));
+ }
+ virtual void performTask(ScriptExecutionContext*);
+ private:
+ AddConsoleMessageTask(MessageSource source, MessageType type, MessageLevel level, const String& message)
+ : m_source(source)
+ , m_type(type)
+ , m_level(level)
+ , m_message(message.isolatedCopy())
+ {
+ }
+ MessageSource m_source;
+ MessageType m_type;
+ MessageLevel m_level;
+ String m_message;
+ };
+
// Explicitly override the security origin for this script context.
// Note: It is dangerous to change the security origin of a script context
// that already contains content.
Modified: trunk/Source/WebCore/workers/WorkerContext.cpp (99327 => 99328)
--- trunk/Source/WebCore/workers/WorkerContext.cpp 2011-11-04 22:16:25 UTC (rev 99327)
+++ trunk/Source/WebCore/workers/WorkerContext.cpp 2011-11-04 22:24:17 UTC (rev 99328)
@@ -299,6 +299,10 @@
void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>)
{
+ if (!isContextThread()) {
+ postTask(AddConsoleMessageTask::create(source, type, level, message));
+ return;
+ }
thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, type, level, message, lineNumber, sourceURL);
}