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

Side by Side Diff: Source/core/dom/ScriptLoader.cpp

Issue 288033006: Revert a series of wrong fixes for crbug.com/361011 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 ASSERT(resource); 356 ASSERT(resource);
357 if (resource->errorOccurred()) { 357 if (resource->errorOccurred()) {
358 dispatchErrorEvent(); 358 dispatchErrorEvent();
359 } else if (!resource->wasCanceled()) { 359 } else if (!resource->wasCanceled()) {
360 executeScript(ScriptSourceCode(resource)); 360 executeScript(ScriptSourceCode(resource));
361 dispatchLoadEvent(); 361 dispatchLoadEvent();
362 } 362 }
363 resource->removeClient(this); 363 resource->removeClient(this);
364 } 364 }
365 365
366 void ScriptLoader::cancel(Document* contextDocument)
367 {
368 if (!m_resource)
369 return;
370 finishLoading(contextDocument, FinishWithCancel);
371 }
372
373 void ScriptLoader::notifyFinished(Resource* resource) 366 void ScriptLoader::notifyFinished(Resource* resource)
374 { 367 {
368 ASSERT(!m_willBeParserExecuted);
369
370 RefPtr<Document> elementDocument(m_element->document());
371 RefPtr<Document> contextDocument = elementDocument->contextDocument().get();
372 if (!contextDocument)
373 return;
374
375 // Resource possibly invokes this notifyFinished() more than 375 // Resource possibly invokes this notifyFinished() more than
376 // once because ScriptLoader doesn't unsubscribe itself from 376 // once because ScriptLoader doesn't unsubscribe itself from
377 // Resource here and does it in execute() instead. 377 // Resource here and does it in execute() instead.
378 // We use m_resource to check if this function is already called. 378 // We use m_resource to check if this function is already called.
379 ASSERT_UNUSED(resource, resource == m_resource); 379 ASSERT_UNUSED(resource, resource == m_resource);
380 if (!m_resource) 380 if (!m_resource)
381 return; 381 return;
382 382 if (m_resource->errorOccurred()) {
383 RefPtr<Document> elementDocument(m_element->document());
384 RefPtr<Document> contextDocument = elementDocument->contextDocument().get();
385 finishLoading(contextDocument.get(), resource->errorOccurred() ? FinishWithE rror : FinishSuccessfully);
386 }
387
388 void ScriptLoader::finishLoading(Document* contextDocument, ScriptLoader::Finish Type type)
389 {
390 if (!contextDocument)
391 return;
392
393 switch (type) {
394 case FinishWithCancel:
395 if (!m_willBeParserExecuted)
396 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willE xecuteInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION );
397 stopLoadRequest();
398 break;
399 case FinishWithError:
400 ASSERT(!m_willBeParserExecuted);
401 dispatchErrorEvent(); 383 dispatchErrorEvent();
402 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecu teInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION); 384 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecu teInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION);
403 m_resource = 0; 385 return;
404 break;
405 case FinishSuccessfully:
406 ASSERT(!m_willBeParserExecuted);
407 contextDocument->scriptRunner()->notifyScriptReady(this, m_willExecuteIn Order ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION);
408 m_resource = 0;
409 break;
410 } 386 }
387 if (m_willExecuteInOrder)
388 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::I N_ORDER_EXECUTION);
389 else
390 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::A SYNC_EXECUTION);
391
392 m_resource = 0;
411 } 393 }
412 394
413 bool ScriptLoader::ignoresLoadRequest() const 395 bool ScriptLoader::ignoresLoadRequest() const
414 { 396 {
415 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen t() || !element()->inDocument(); 397 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen t() || !element()->inDocument();
416 } 398 }
417 399
418 bool ScriptLoader::isScriptForEventSupported() const 400 bool ScriptLoader::isScriptForEventSupported() const
419 { 401 {
420 String eventAttribute = client()->eventAttributeValue(); 402 String eventAttribute = client()->eventAttributeValue();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 if (isHTMLScriptLoader(element)) 435 if (isHTMLScriptLoader(element))
454 return toHTMLScriptElement(element)->loader(); 436 return toHTMLScriptElement(element)->loader();
455 437
456 if (isSVGScriptLoader(element)) 438 if (isSVGScriptLoader(element))
457 return toSVGScriptElement(element)->loader(); 439 return toSVGScriptElement(element)->loader();
458 440
459 return 0; 441 return 0;
460 } 442 }
461 443
462 } 444 }
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698