Changeset 64857 in webkit


Ignore:
Timestamp:
Aug 6, 2010 10:35:57 AM (14 years ago)
Author:
tonyg@chromium.org
Message:

2010-08-06 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Adam Barth.

Factor out PendingScript and protect its members
https://bugs.webkit.org/show_bug.cgi?id=43391

This will be shared by AsyncScriptRunner.

No new tests because no new functionality.

  • Android.mk:
  • CMakeLists.txt:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/PendingScript.cpp: Added. (WebCore::PendingScript::~PendingScript): (WebCore::PendingScript::element): (WebCore::PendingScript::releaseElementAndClear): (WebCore::PendingScript::setCachedScript): (WebCore::PendingScript::cachedScript):
  • dom/PendingScript.h: Added. (WebCore::PendingScript::PendingScript): (WebCore::PendingScript::startingLineNumber): (WebCore::PendingScript::watchingForLoad): (WebCore::PendingScript::setWatchingForLoad): (WebCore::PendingScript::hasElement): (WebCore::PendingScript::adoptElement): (WebCore::PendingScript::notifyFinished):
  • html/HTMLScriptRunner.cpp: (WebCore::HTMLScriptRunner::sourceFromPendingScript): (WebCore::HTMLScriptRunner::haveParsingBlockingScript): (WebCore::HTMLScriptRunner::requestScript):
  • html/HTMLScriptRunner.h:
Location:
trunk/WebCore
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/Android.mk

    r64845 r64857  
    159159        dom/OverflowEvent.cpp \
    160160        dom/PageTransitionEvent.cpp \
     161        dom/PendingScript.cpp \
    161162        dom/Position.cpp \
    162163        dom/PositionIterator.cpp \
  • trunk/WebCore/CMakeLists.txt

    r64846 r64857  
    838838    dom/OverflowEvent.cpp
    839839    dom/PageTransitionEvent.cpp
     840    dom/PendingScript.cpp
    840841    dom/PopStateEvent.cpp
    841842    dom/Position.cpp
  • trunk/WebCore/ChangeLog

    r64855 r64857  
     12010-08-06  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Factor out PendingScript and protect its members
     6        https://bugs.webkit.org/show_bug.cgi?id=43391
     7
     8        This will be shared by AsyncScriptRunner.
     9
     10        No new tests because no new functionality.
     11
     12        * Android.mk:
     13        * CMakeLists.txt:
     14        * GNUmakefile.am:
     15        * WebCore.gypi:
     16        * WebCore.pro:
     17        * WebCore.vcproj/WebCore.vcproj:
     18        * WebCore.xcodeproj/project.pbxproj:
     19        * dom/PendingScript.cpp: Added.
     20        (WebCore::PendingScript::~PendingScript):
     21        (WebCore::PendingScript::element):
     22        (WebCore::PendingScript::releaseElementAndClear):
     23        (WebCore::PendingScript::setCachedScript):
     24        (WebCore::PendingScript::cachedScript):
     25        * dom/PendingScript.h: Added.
     26        (WebCore::PendingScript::PendingScript):
     27        (WebCore::PendingScript::startingLineNumber):
     28        (WebCore::PendingScript::watchingForLoad):
     29        (WebCore::PendingScript::setWatchingForLoad):
     30        (WebCore::PendingScript::hasElement):
     31        (WebCore::PendingScript::adoptElement):
     32        (WebCore::PendingScript::notifyFinished):
     33        * html/HTMLScriptRunner.cpp:
     34        (WebCore::HTMLScriptRunner::sourceFromPendingScript):
     35        (WebCore::HTMLScriptRunner::haveParsingBlockingScript):
     36        (WebCore::HTMLScriptRunner::requestScript):
     37        * html/HTMLScriptRunner.h:
     38
    1392010-08-06  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    240
  • trunk/WebCore/GNUmakefile.am

    r64846 r64857  
    11161116        WebCore/dom/PageTransitionEvent.cpp \
    11171117        WebCore/dom/PageTransitionEvent.h \
     1118        WebCore/dom/PendingScript.cpp \
     1119        WebCore/dom/PendingScript.h \
    11181120        WebCore/dom/Position.cpp \
    11191121        WebCore/dom/Position.h \
  • trunk/WebCore/WebCore.gypi

    r64846 r64857  
    12251225            'dom/PageTransitionEvent.cpp',
    12261226            'dom/PageTransitionEvent.h',
     1227            'dom/PendingScript.cpp',
     1228            'dom/PendingScript.h',
    12271229            'dom/Position.cpp',
    12281230            'dom/Position.h',
  • trunk/WebCore/WebCore.pro

    r64846 r64857  
    526526    dom/OverflowEvent.cpp \
    527527    dom/PageTransitionEvent.cpp \
     528    dom/PendingScript.cpp \
    528529    dom/PopStateEvent.cpp \
    529530    dom/Position.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r64846 r64857  
    3308233082                        </File>
    3308333083                        <File
     33084                                RelativePath="..\dom\PendingScript.cpp"
     33085                                >
     33086                        </File>
     33087                        <File
     33088                                RelativePath="..\dom\PendingScript.h"
     33089                                >
     33090                        </File>
     33091                        <File
    3308433092                                RelativePath="..\dom\PageTransitionEvent.cpp"
    3308533093                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r64846 r64857  
    23572357                89CD029411C85B870070B791 /* JSBlobBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 89CD029211C85B870070B791 /* JSBlobBuilder.h */; };
    23582358                8A12E35D11FA33280025836A /* DocumentLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2359                8A7CC96B12076D73001D4588 /* PendingScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A7CC96A12076D73001D4588 /* PendingScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2360                8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A7CC96F12076F8A001D4588 /* PendingScript.cpp */; };
    23592361                8A81BF8511DCFD9000DA2B98 /* ResourceLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A81BF8411DCFD9000DA2B98 /* ResourceLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23602362                8A844D0411D3C18E0014065C /* Performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A844D0111D3C18E0014065C /* Performance.cpp */; };
     
    81588160                89CD029211C85B870070B791 /* JSBlobBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBlobBuilder.h; sourceTree = "<group>"; };
    81598161                8A12E35C11FA33280025836A /* DocumentLoadTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentLoadTiming.h; sourceTree = "<group>"; };
     8162                8A7CC96A12076D73001D4588 /* PendingScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScript.h; sourceTree = "<group>"; };
     8163                8A7CC96F12076F8A001D4588 /* PendingScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingScript.cpp; sourceTree = "<group>"; };
    81608164                8A81BF8411DCFD9000DA2B98 /* ResourceLoadTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadTiming.h; sourceTree = "<group>"; };
    81618165                8A844D0111D3C18E0014065C /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; };
     
    1726717271                                E1284AE010447D4500EAEB52 /* PageTransitionEvent.h */,
    1726817272                                E1284AD910447AEB00EAEB52 /* PageTransitionEvent.idl */,
     17273                                8A7CC96F12076F8A001D4588 /* PendingScript.cpp */,
     17274                                8A7CC96A12076D73001D4588 /* PendingScript.h */,
    1726917275                                41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */,
    1727017276                                41BF700E0FE86F61005E8DEC /* PlatformMessagePortChannel.h */,
     
    2007620082                                31FB1A5D120A5D0600DC02A0 /* DeviceMotionEvent.h in Headers */,
    2007720083                                31FB1A66120A5D3F00DC02A0 /* JSDeviceMotionEvent.h in Headers */,
     20084                                8A7CC96B12076D73001D4588 /* PendingScript.h in Headers */,
    2007820085                        );
    2007920086                        runOnlyForDeploymentPostprocessing = 0;
     
    2249122498                                31FB1A65120A5D3F00DC02A0 /* JSDeviceMotionEvent.cpp in Sources */,
    2249222499                                31FB1A6C120A5D6900DC02A0 /* JSDeviceMotionEventCustom.cpp in Sources */,
     22500                                8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */,
    2249322501                        );
    2249422502                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/html/HTMLScriptRunner.cpp

    r64704 r64857  
    106106    }
    107107    errorOccurred = false;
    108     return ScriptSourceCode(script.element->textContent(), documentURLForScriptExecution(m_document), script.startingLineNumber);
     108    return ScriptSourceCode(script.element()->textContent(), documentURLForScriptExecution(m_document), script.startingLineNumber());
    109109}
    110110
     
    196196bool HTMLScriptRunner::haveParsingBlockingScript() const
    197197{
    198     return !!m_parsingBlockingScript.element;
     198    return !!m_parsingBlockingScript.element();
    199199}
    200200
     
    231231void HTMLScriptRunner::requestScript(Element* script)
    232232{
    233     ASSERT(!m_parsingBlockingScript.element);
     233    ASSERT(!m_parsingBlockingScript.element());
    234234    AtomicString srcValue = script->getAttribute(srcAttr);
    235235    // Allow the host to disllow script loads (using the XSSAuditor, etc.)
     
    239239    if (!script->dispatchBeforeLoadEvent(srcValue))
    240240        return;
    241     m_parsingBlockingScript.element = script;
     241    m_parsingBlockingScript.adoptElement(script);
    242242    // This should correctly return 0 for empty or invalid srcValues.
    243243    CachedScript* cachedScript = m_document->docLoader()->requestScript(srcValue, toScriptElement(script)->scriptCharset());
     
    279279}
    280280
    281 HTMLScriptRunner::PendingScript::~PendingScript()
    282 {
    283     if (m_cachedScript)
    284         m_cachedScript->removeClient(this);
    285 }
    286 
    287 PassRefPtr<Element> HTMLScriptRunner::PendingScript::releaseElementAndClear()
    288 {
    289     setCachedScript(0);
    290     startingLineNumber = 0;
    291     m_watchingForLoad = false;
    292     return element.release();
    293 }
    294 
    295 void HTMLScriptRunner::PendingScript::setCachedScript(CachedScript* cachedScript)
    296 {
    297     if (m_cachedScript == cachedScript)
    298         return;
    299     if (m_cachedScript)
    300         m_cachedScript->removeClient(this);
    301     m_cachedScript = cachedScript;
    302     if (m_cachedScript)
    303         m_cachedScript->addClient(this);
    304 }
    305 
    306 CachedScript* HTMLScriptRunner::PendingScript::cachedScript() const
    307 {
    308     return m_cachedScript.get();
    309 }
    310 
    311 }
     281}
  • trunk/WebCore/html/HTMLScriptRunner.h

    r64704 r64857  
    2727#define HTMLScriptRunner_h
    2828
    29 #include "CachedResourceClient.h"
    30 #include "CachedResourceHandle.h"
     29#include "PendingScript.h"
    3130#include <wtf/Noncopyable.h>
    3231#include <wtf/PassRefPtr.h>
     
    3433namespace WebCore {
    3534
    36 class CachedResourceClient;
     35class CachedResource;
    3736class CachedScript;
    3837class Document;
     
    5756
    5857private:
    59     // A container for an external script which may be loaded and executed.
    60     //
    61     // A CachedResourceHandle alone does not prevent the underlying CachedResource
    62     // from purging its data buffer. This class holds a dummy client open for its
    63     // lifetime in order to guarantee that the data buffer will not be purged.
    64     //
    65     // FIXME: Finish turning this into a proper class.
    66     class PendingScript : public CachedResourceClient, Noncopyable {
    67     public:
    68         PendingScript()
    69             : startingLineNumber(0)
    70             , m_watchingForLoad(false)
    71         {
    72         }
    73 
    74         ~PendingScript();
    75 
    76         PassRefPtr<Element> releaseElementAndClear();
    77 
    78         bool watchingForLoad() const { return m_watchingForLoad; }
    79         void setWatchingForLoad(bool b) { m_watchingForLoad = b; }
    80 
    81         CachedScript* cachedScript() const;
    82         void setCachedScript(CachedScript*);
    83 
    84         virtual void notifyFinished(CachedResource*)
    85         {
    86         }
    87 
    88         RefPtr<Element> element;
    89         int startingLineNumber; // Only used for inline script tags.
    90         // HTML5 has an isReady parameter, however isReady ends up equivalent to
    91         // m_document->haveStylesheetsLoaded() && cachedScript->isLoaded()
    92 
    93     private:
    94         bool m_watchingForLoad;
    95         CachedResourceHandle<CachedScript> m_cachedScript;
    96     };
    97 
    9858    Frame* frame() const;
    9959
Note: See TracChangeset for help on using the changeset viewer.