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/Lexer.h

    r188824 r191135  
    8989    bool sawError() const { return m_error; }
    9090    String getErrorMessage() const { return m_lexErrorMessage; }
     91    String sourceURL() const { return m_sourceURL; }
     92    String sourceMappingURL() const { return m_sourceMappingURL; }
    9193    void clear();
    9294    void setOffset(int offset, int lineStartOffset)
     
    114116        m_terminator = terminator;
    115117    }
    116 
    117     SourceProvider* sourceProvider() const { return m_source->provider(); }
    118118
    119119    JSTokenType lexExpectIdentifier(JSToken*, unsigned, bool strictMode);
     
    153153
    154154    ALWAYS_INLINE bool lastTokenWasRestrKeyword() const;
     155   
     156    ALWAYS_INLINE void skipWhitespace();
    155157
    156158    template <int shiftAmount> void internalShift();
     
    178180    ALWAYS_INLINE bool parseNumberAfterExponentIndicator();
    179181    ALWAYS_INLINE bool parseMultilineComment();
     182
     183    ALWAYS_INLINE void parseCommentDirective();
     184    ALWAYS_INLINE String parseCommentDirectiveValue();
     185
     186    template <unsigned length>
     187    ALWAYS_INLINE bool consume(const char (&input)[length]);
    180188
    181189    static const size_t initialReadBufferCapacity = 32;
     
    204212    String m_lexErrorMessage;
    205213
     214    String m_sourceURL;
     215    String m_sourceMappingURL;
     216
    206217    T m_current;
    207218
Note: See TracChangeset for help on using the changeset viewer.