Ignore:
Timestamp:
Oct 15, 2015, 1:50:02 PM (10 years ago)
Author:
[email protected]
Message:

Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives
https://bugs.webkit.org/show_bug.cgi?id=150096

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-10-15
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

  • inspector/ContentSearchUtilities.cpp:

(Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted.
(Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted.
(Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted.

  • inspector/ContentSearchUtilities.h:

No longer need to search script content.

  • inspector/ScriptDebugServer.cpp:

(Inspector::ScriptDebugServer::dispatchDidParseSource):
Carry over the sourceURL and sourceMappingURL from the SourceProvider.

  • inspector/agents/InspectorDebuggerAgent.cpp:

(Inspector::InspectorDebuggerAgent::sourceMapURLForScript):
(Inspector::InspectorDebuggerAgent::didParseSource):
No longer do content searching.

  • parser/Lexer.cpp:

(JSC::Lexer<T>::setCode):
(JSC::Lexer<T>::skipWhitespace):
(JSC::Lexer<T>::parseCommentDirective):
(JSC::Lexer<T>::parseCommentDirectiveValue):
(JSC::Lexer<T>::consume):
(JSC::Lexer<T>::lex):

  • parser/Lexer.h:

(JSC::Lexer::sourceURL):
(JSC::Lexer::sourceMappingURL):
(JSC::Lexer::sourceProvider): Deleted.
Give lexer the ability to detect script comment directives.
This just consumes characters in single line comments and
ultimately sets the sourceURL or sourceMappingURL found.

  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):

  • parser/SourceProvider.h:

(JSC::SourceProvider::url):
(JSC::SourceProvider::sourceURL):
(JSC::SourceProvider::sourceMappingURL):
(JSC::SourceProvider::setSourceURL):
(JSC::SourceProvider::setSourceMappingURL):
After parsing a script, update the Source Provider with the
value of directives that may have been found in the script.

Source/WebInspectorUI:

  • UserInterface/Test/InspectorProtocol.js:

(InspectorProtocol._sendMessage):
(InspectorProtocol.dispatchMessageFromBackend):
This is only used for tests, so avoid console.log
and just dump directly to the system console.

LayoutTests:

  • inspector/debugger/sourceURLs-expected.txt: Added.
  • inspector/debugger/sourceURLs.html: Added.

sourceURL and sourceMappingURL detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SourceProvider.h

    r187677 r191135  
    5050        }
    5151
    52         const String& url() { return m_url; }
     52        const String& url() const { return m_url; }
     53        const String& sourceURL() const { return m_sourceURL; }
     54        const String& sourceMappingURL() const { return m_sourceMappingURL; }
     55
    5356        TextPosition startPosition() const { return m_startPosition; }
    5457        intptr_t asID()
     
    6366
    6467    private:
     68        template <typename T> friend class Parser;
     69
     70        void setSourceURL(const String& sourceURL) { m_sourceURL = sourceURL; }
     71        void setSourceMappingURL(const String& sourceMappingURL) { m_sourceMappingURL = sourceMappingURL; }
    6572
    6673        JS_EXPORT_PRIVATE void getID();
     
    6875
    6976        String m_url;
     77        String m_sourceURL;
     78        String m_sourceMappingURL;
    7079        TextPosition m_startPosition;
    7180        bool m_validated : 1;
Note: See TracChangeset for help on using the changeset viewer.