Changeset 148768 in webkit
- Timestamp:
- Apr 19, 2013 2:06:03 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r148751 r148768 1 2013-04-19 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Backend should detect sourceMappingURLs in CSS Resources 4 https://bugs.webkit.org/show_bug.cgi?id=114854 5 6 Test a different ways we would expect to see a sourceMapURL for 7 stylesheet resources. 8 9 Reviewed by Timothy Hatcher. 10 11 * http/tests/inspector/network/css-source-mapping-url-expected.txt: Added. 12 * http/tests/inspector/network/css-source-mapping-url.html: Added. 13 * http/tests/inspector/network/resources/source-map-test-style.css: Added. 14 * http/tests/inspector/network/resources/source-map-test-style.css.map: Added. 15 * http/tests/inspector/network/resources/source-map-test-style.scss: Added. 16 1 17 2013-04-19 Sudarsana Nagineni <sudarsana.nagineni@intel.com> 2 18 -
trunk/Source/WebCore/ChangeLog
r148765 r148768 1 2013-04-19 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Backend should detect sourceMappingURLs in CSS Resources 4 https://bugs.webkit.org/show_bug.cgi?id=114854 5 6 Reviewed by Timothy Hatcher. 7 8 Test: http/tests/inspector/network/css-source-mapping-url.html 9 10 * inspector/Inspector.json: 11 - Page.getResourceTree - add sourceMapURL to resource payloads 12 - Network.loadingFinished and Network.requestServedFromMemoryCache, 13 include the sourceMapURL in the results. 14 15 * inspector/ContentSearchUtils.h: 16 * inspector/ContentSearchUtils.cpp: 17 (WebCore::ContentSearchUtils::scriptCommentPattern): 18 (WebCore::ContentSearchUtils::stylesheetCommentPattern): 19 (WebCore::ContentSearchUtils::findMagicComment): 20 (WebCore::ContentSearchUtils::findScriptSourceURL): 21 (WebCore::ContentSearchUtils::findScriptSourceMapURL): 22 (WebCore::ContentSearchUtils::findStylesheetSourceMapURL): 23 Separate Script and Stylesheet regex pattern creation, but 24 share the search function using the pattern. 25 26 * inspector/InspectorDebuggerAgent.cpp: 27 (WebCore::InspectorDebuggerAgent::sourceMapURLForScript): 28 (WebCore::InspectorDebuggerAgent::didParseSource): 29 Update function names. Check for the SourceMap header before 30 checking for a sourceMappingURL comment. 31 32 * inspector/InspectorPageAgent.h: 33 * inspector/InspectorPageAgent.cpp: 34 (WebCore::InspectorPageAgent::sourceMapURLForResource): 35 (WebCore::InspectorPageAgent::buildObjectForFrameTree): 36 Provide the sourceMapURL for Page.getResourceTree. 37 38 * inspector/InspectorResourceAgent.cpp: 39 (WebCore::buildObjectForCachedResource): 40 (WebCore::InspectorResourceAgent::didFinishLoading): 41 (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache): 42 Include sourceMapURLs in finish loading and request served from cache. 43 1 44 2013-04-19 Shawn Singh <shawnsingh@chromium.org> 2 45 -
trunk/Source/WebCore/inspector/ContentSearchUtils.cpp
r144434 r148768 169 169 } 170 170 171 static String findMagicComment(const String& content, const String& name) 172 { 173 String patternString = "//@[\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$"; 171 static String scriptCommentPattern(const String& name) 172 { 173 // "//@ <name>=<value>" 174 return "//@[\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$"; 175 } 176 177 static String stylesheetCommentPattern(const String& name) 178 { 179 // "/*@ <name>=<value> */" 180 return "/\\*@[\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*\\*/"; 181 } 182 183 static String findMagicComment(const String& content, const String& patternString) 184 { 174 185 const char* error = 0; 175 186 JSC::Yarr::YarrPattern pattern(patternString, false, true, &error); … … 189 200 } 190 201 191 String findSourceURL(const String& content) 192 { 193 return findMagicComment(content, "sourceURL"); 194 } 195 196 String findSourceMapURL(const String& content) 197 { 198 return findMagicComment(content, "sourceMappingURL"); 202 String findScriptSourceURL(const String& content) 203 { 204 return findMagicComment(content, scriptCommentPattern("sourceURL")); 205 } 206 207 String findScriptSourceMapURL(const String& content) 208 { 209 return findMagicComment(content, scriptCommentPattern("sourceMappingURL")); 210 } 211 212 String findStylesheetSourceMapURL(const String& content) 213 { 214 return findMagicComment(content, stylesheetCommentPattern("sourceMappingURL")); 199 215 } 200 216 -
trunk/Source/WebCore/inspector/ContentSearchUtils.h
r144434 r148768 50 50 PassOwnPtr<Vector<size_t> > lineEndings(const String&); 51 51 52 String findSourceURL(const String& content); 53 String findSourceMapURL(const String& content); 52 String findScriptSourceURL(const String& content); 53 String findScriptSourceMapURL(const String& content); 54 String findStylesheetSourceMapURL(const String& content); 54 55 55 56 } // namespace ContentSearchUtils -
trunk/Source/WebCore/inspector/Inspector.json
r148723 r148768 136 136 { "name": "mimeType", "type": "string", "description": "Resource mimeType as determined by the browser." }, 137 137 { "name": "failed", "type": "boolean", "optional": true, "description": "True if the resource failed to load." }, 138 { "name": "canceled", "type": "boolean", "optional": true, "description": "True if the resource was canceled during loading." } 138 { "name": "canceled", "type": "boolean", "optional": true, "description": "True if the resource was canceled during loading." }, 139 { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with this resource (if any)." } 139 140 ] 140 141 }, … … 976 977 { "name": "type", "$ref": "Page.ResourceType", "description": "Type of this resource." }, 977 978 { "name": "response", "$ref": "Response", "optional": true, "description": "Cached response data." }, 978 { "name": "bodySize", "type": "number", "description": "Cached response body size." } 979 { "name": "bodySize", "type": "number", "description": "Cached response body size." }, 980 { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with this resource (if any)." } 979 981 ] 980 982 }, … … 1112 1114 "parameters": [ 1113 1115 { "name": "requestId", "$ref": "RequestId", "description": "Request identifier." }, 1114 { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp." } 1116 { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp." }, 1117 { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with this resource (if any)." } 1115 1118 ] 1116 1119 }, -
trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp
r147962 r148768 633 633 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) 634 634 { 635 DEFINE_STATIC_LOCAL(String, sourceMapHttpHeader, (ASCIILiteral("X-SourceMap"))); 636 637 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source); 638 if (!sourceMapURL.isEmpty()) 639 return sourceMapURL; 640 641 if (script.url.isEmpty()) 642 return String(); 643 644 InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent(); 645 if (!pageAgent) 646 return String(); 647 648 CachedResource* resource = pageAgent->cachedResource(pageAgent->mainFrame(), KURL(ParsedURLString, script.url)); 649 if (resource) 650 return resource->response().httpHeaderField(sourceMapHttpHeader); 651 return String(); 635 DEFINE_STATIC_LOCAL(String, sourceMapHTTPHeader, (ASCIILiteral("X-SourceMap"))); 636 637 if (!script.url.isEmpty()) { 638 if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent()) { 639 CachedResource* resource = pageAgent->cachedResource(pageAgent->mainFrame(), KURL(ParsedURLString, script.url)); 640 if (resource) { 641 String sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeader); 642 if (!sourceMapHeader.isEmpty()) 643 return sourceMapHeader; 644 } 645 } 646 } 647 648 return ContentSearchUtils::findScriptSourceMapURL(script.source); 652 649 } 653 650 … … 662 659 String sourceURL; 663 660 if (!script.startLine && !script.startColumn) 664 sourceURL = ContentSearchUtils::findS ourceURL(script.source);661 sourceURL = ContentSearchUtils::findScriptSourceURL(script.source); 665 662 bool hasSourceURL = !sourceURL.isEmpty(); 666 663 String scriptURL = hasSourceURL ? sourceURL : script.url; -
trunk/Source/WebCore/inspector/InspectorPageAgent.cpp
r148373 r148768 268 268 } 269 269 270 //static 271 String InspectorPageAgent::sourceMapURLForResource(CachedResource* cachedResource) 272 { 273 DEFINE_STATIC_LOCAL(String, sourceMapHTTPHeader, (ASCIILiteral("X-SourceMap"))); 274 275 if (!cachedResource) 276 return String(); 277 278 // Scripts are handled in a separate path. 279 if (cachedResource->type() != CachedResource::CSSStyleSheet) 280 return String(); 281 282 String sourceMapHeader = cachedResource->response().httpHeaderField(sourceMapHTTPHeader); 283 if (!sourceMapHeader.isEmpty()) 284 return sourceMapHeader; 285 286 String content; 287 bool base64Encoded; 288 if (InspectorPageAgent::cachedResourceContent(cachedResource, &content, &base64Encoded) && !base64Encoded) 289 return ContentSearchUtils::findStylesheetSourceMapURL(content); 290 291 return String(); 292 } 293 270 294 CachedResource* InspectorPageAgent::cachedResource(Frame* frame, const KURL& url) 271 295 { … … 1115 1139 else if (cachedResource->status() == CachedResource::LoadError) 1116 1140 resourceObject->setFailed(true); 1141 String sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(cachedResource); 1142 if (!sourceMappingURL.isEmpty()) 1143 resourceObject->setSourceMapURL(sourceMappingURL); 1117 1144 subresources->addItem(resourceObject); 1118 1145 } -
trunk/Source/WebCore/inspector/InspectorPageAgent.h
r148545 r148768 87 87 static bool sharedBufferContent(PassRefPtr<SharedBuffer>, const String& textEncodingName, bool withBase64Encode, String* result); 88 88 static void resourceContent(ErrorString*, Frame*, const KURL&, String* result, bool* base64Encoded); 89 static String sourceMapURLForResource(CachedResource*); 89 90 90 91 static PassRefPtr<SharedBuffer> resourceData(Frame*, const KURL&, String* textEncodingName); -
trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp
r148256 r148768 168 168 } 169 169 170 static PassRefPtr<TypeBuilder::Network::CachedResource> buildObjectForCachedResource( const CachedResource&cachedResource, DocumentLoader* loader)170 static PassRefPtr<TypeBuilder::Network::CachedResource> buildObjectForCachedResource(CachedResource* cachedResource, DocumentLoader* loader) 171 171 { 172 172 RefPtr<TypeBuilder::Network::CachedResource> resourceObject = TypeBuilder::Network::CachedResource::create() 173 .setUrl(cachedResource.url()) 174 .setType(InspectorPageAgent::cachedResourceTypeJson(cachedResource)) 175 .setBodySize(cachedResource.encodedSize()); 176 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForResourceResponse(cachedResource.response(), loader); 173 .setUrl(cachedResource->url()) 174 .setType(InspectorPageAgent::cachedResourceTypeJson(*cachedResource)) 175 .setBodySize(cachedResource->encodedSize()); 176 177 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForResourceResponse(cachedResource->response(), loader); 177 178 if (resourceResponse) 178 179 resourceObject->setResponse(resourceResponse); 180 181 String sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(cachedResource); 182 if (!sourceMappingURL.isEmpty()) 183 resourceObject->setSourceMapURL(sourceMappingURL); 184 179 185 return resourceObject; 180 186 } … … 293 299 finishTime = currentTime(); 294 300 295 m_frontend->loadingFinished(requestId, finishTime); 301 String sourceMappingURL; 302 NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->data(requestId); 303 if (resourceData && resourceData->cachedResource()) 304 sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(resourceData->cachedResource()); 305 306 m_frontend->loadingFinished(requestId, finishTime, !sourceMappingURL.isEmpty() ? &sourceMappingURL : 0); 296 307 } 297 308 … … 328 339 RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0); 329 340 330 m_frontend->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource( *resource, loader));341 m_frontend->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(resource, loader)); 331 342 } 332 343
Note: See TracChangeset
for help on using the changeset viewer.