Changeset 61607 in webkit


Ignore:
Timestamp:
Jun 22, 2010 12:56:26 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-06-22 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Expose HTMLInputStream to ScriptRunner so that ScriptRunner can save the insertion point itself
https://bugs.webkit.org/show_bug.cgi?id=40975

This saves us having to call back into the HTML5DocumentParser each
time we need to save the insertion point. This prepares us for another
place we need to save the insertion point.

  • html/HTML5DocumentParser.cpp:
  • html/HTML5DocumentParser.h: (WebCore::HTML5DocumentParser::inputStream):
  • html/HTML5ScriptRunner.cpp: (WebCore::HTML5ScriptRunner::executeScript): (WebCore::HTML5ScriptRunner::requestScript):
  • html/HTML5ScriptRunnerHost.h:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r61606 r61607  
     12010-06-22  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Expose HTMLInputStream to ScriptRunner so that ScriptRunner can save the insertion point itself
     6        https://bugs.webkit.org/show_bug.cgi?id=40975
     7
     8        This saves us having to call back into the HTML5DocumentParser each
     9        time we need to save the insertion point.  This prepares us for another
     10        place we need to save the insertion point.
     11
     12        * html/HTML5DocumentParser.cpp:
     13        * html/HTML5DocumentParser.h:
     14        (WebCore::HTML5DocumentParser::inputStream):
     15        * html/HTML5ScriptRunner.cpp:
     16        (WebCore::HTML5ScriptRunner::executeScript):
     17        (WebCore::HTML5ScriptRunner::requestScript):
     18        * html/HTML5ScriptRunnerHost.h:
     19
    1202010-06-22  Adam Barth  <abarth@webkit.org>
    221
  • trunk/WebCore/html/HTML5DocumentParser.cpp

    r61604 r61607  
    395395}
    396396
    397 void HTML5DocumentParser::executeScript(const ScriptSourceCode& sourceCode)
    398 {
    399     ASSERT(m_scriptRunner->inScriptExecution());
    400     if (!m_document->frame())
    401         return;
    402     InsertionPointRecord savedInsertionPoint(m_input);
    403     m_document->frame()->script()->executeScript(sourceCode);
    404 }
    405 
    406 bool HTML5DocumentParser::dispatchBeforeLoad(Element* script, const AtomicString& srcValue)
    407 {
    408     InsertionPointRecord savedInsertionPoint(m_input);
    409     return script->dispatchBeforeLoadEvent(srcValue);
    410 }
    411 
    412397void HTML5DocumentParser::notifyFinished(CachedResource* cachedResource)
    413398{
  • trunk/WebCore/html/HTML5DocumentParser.h

    r61606 r61607  
    7373    virtual void stopWatchingForLoad(CachedResource*);
    7474    virtual bool shouldLoadExternalScriptFromSrc(const AtomicString&);
    75     virtual void executeScript(const ScriptSourceCode&);
    76     virtual bool dispatchBeforeLoad(Element* script, const AtomicString& srcValue);
     75    virtual HTMLInputStream& inputStream() { return m_input; }
    7776
    7877    // CachedResourceClient
  • trunk/WebCore/html/HTML5ScriptRunner.cpp

    r61604 r61607  
    3434#include "Frame.h"
    3535#include "HTML5ScriptRunnerHost.h"
     36#include "HTMLInputStream.h"
    3637#include "HTMLNames.h"
    3738#include "NotImplemented.h"
     
    136137    if (!scriptElement->shouldExecuteAsJavaScript())
    137138        return;
    138 
    139     // Always use the delegate to execute the script so that it can save any
    140     // necessary state to prepare for rentrancy.
    141     m_host->executeScript(sourceCode);
     139    ASSERT(inScriptExecution());
     140    if (!m_document->frame())
     141        return;
     142
     143    InsertionPointRecord savedInsertionPoint(m_host->inputStream());
     144    m_document->frame()->script()->executeScript(sourceCode);
    142145}
    143146
     
    234237        return;
    235238    // FIXME: We need to resolve the url relative to the element.
    236     if (!m_host->dispatchBeforeLoad(script, srcValue))
    237         return;
     239    {
     240        InsertionPointRecord savedInsertionPoint(m_host->inputStream());
     241        if (!script->dispatchBeforeLoadEvent(srcValue))
     242            return;
     243    }
    238244    m_parsingBlockingScript.element = script;
    239245    // This should correctly return 0 for empty or invalid srcValues.
  • trunk/WebCore/html/HTML5ScriptRunnerHost.h

    r61604 r61607  
    3232class CachedResource;
    3333class Element;
     34class HTMLInputStream;
    3435class ScriptSourceCode;
    3536
     
    4546    // Implementors can block certain script loads (for XSSAuditor, etc.)
    4647    virtual bool shouldLoadExternalScriptFromSrc(const AtomicString&) = 0;
    47     // Implementors should handle possible rentry before/after calling ScriptController::executeScript
    48     virtual void executeScript(const ScriptSourceCode&) = 0;
    49     virtual bool dispatchBeforeLoad(Element* script, const AtomicString& srcValue) = 0;
     48    virtual HTMLInputStream& inputStream() = 0;
    5049};
    5150
Note: See TracChangeset for help on using the changeset viewer.