~/Projects/chrome-devtools-frontend
git clone https://code.lsong.org/chrome-devtools-frontend
Commit
- Commit
- 5a02aca17849514b1e2bc828f78aedece5161dfa
- Author
- Benedikt Meurer <[email protected]>
- Date
- 2022-11-21 10:10:44 +0100 +0100
- Diffstat
front_end/core/common/ResourceType.ts | 4 + front_end/ui/components/code_highlighter/CodeHighlighter.ts | 4 + test/unittests/front_end/core/common/ResourceType_test.ts | 9 ++++ test/unittests/front_end/ui/components/CodeHighlighter_test.ts | 8 +++
[sources] Restore pre-CodeMirror6 support for GSS. This hooks up the css/gss legacy mode to properly highlight .gss files (using the limited legacy mode language support that was already available in CodeMirror5). Before: https://imgur.com/PDtkAUU.png After: https://imgur.com/DsXi1o2.png Fixed: chromium:1391895 Bug: chromium:1385374 Change-Id: I6f9b4912d9ce6eac7056f476e530f7a029dfc8ff Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4040924 Reviewed-by: Simon Zünd <[email protected]>
diff --git a/front_end/core/common/ResourceType.ts b/front_end/core/common/ResourceType.ts index 02faf56e167b50f5a4a82e3d9eee70bb8eeff2f0..472b748e7dfd76dfaa4f95322e85492b17b6e8c4 100644 --- a/front_end/core/common/ResourceType.ts +++ b/front_end/core/common/ResourceType.ts @@ -496,6 +496,10 @@ // Shell ['sh', 'text/x-sh'], // found in the LICENSE file. + fonts: 'Fonts', + ['gss', 'text/x-gss'], + +// found in the LICENSE file. * documentation and/or other materials provided with the distribution. ['scss', 'text/x-scss'], diff --git a/front_end/ui/components/code_highlighter/CodeHighlighter.ts b/front_end/ui/components/code_highlighter/CodeHighlighter.ts index 1c83f35380492bfaf99302f257485c40082140a7..8c5666bea2bd025aeb154c3e3382ffb4b5f30aa7 100644 --- a/front_end/ui/components/code_highlighter/CodeHighlighter.ts +++ b/front_end/ui/components/code_highlighter/CodeHighlighter.ts @@ -140,6 +140,10 @@ case 'application/vnd.dart': return new CodeMirror.LanguageSupport(await CodeMirror.dart()); // Copyright 2021 The Chromium Authors. All rights reserved. + } + return new CodeMirror.LanguageSupport(await CodeMirror.gss()); + +// Copyright 2021 The Chromium Authors. All rights reserved. {tag: [t.atom, t.labelName, t.bool], class: 'token-atom'}, return new CodeMirror.LanguageSupport(await CodeMirror.less()); diff --git a/test/unittests/front_end/core/common/ResourceType_test.ts b/test/unittests/front_end/core/common/ResourceType_test.ts index 99f6b5f69839f697c8fbd5012060829b9c3550d3..d59e1e5a1c50c4a3fe334b9f5343d62b98adbb48 100644 --- a/test/unittests/front_end/core/common/ResourceType_test.ts +++ b/test/unittests/front_end/core/common/ResourceType_test.ts @@ -424,6 +424,10 @@ it('returns correct MIME type for .dart files', () => { assert.strictEqual(ResourceType.mimeFromExtension('dart'), 'application/vnd.dart'); }); + it('returns correct MIME type for .gss files', () => { + assert.strictEqual(ResourceType.mimeFromExtension('gss'), 'text/x-gss'); + }); + it('returns correct MIME type for .less files', () => { assert.strictEqual(ResourceType.mimeFromExtension('less'), 'text/x-less'); }); @@ -449,6 +453,11 @@ describe('mimeFromURL', () => { it('returns correct MIME type for .dart files', () => { const url = 'http://localhost/example.dart' as Platform.DevToolsPath.UrlString; assert.strictEqual(ResourceType.mimeFromURL(url), 'application/vnd.dart'); + }); + + it('returns correct MIME type for .gss files', () => { + const url = 'https://staging.server.com/styles.gss' as Platform.DevToolsPath.UrlString; + assert.strictEqual(ResourceType.mimeFromURL(url), 'text/x-gss'); }); it('returns correct MIME type for .less files', () => { diff --git a/test/unittests/front_end/ui/components/CodeHighlighter_test.ts b/test/unittests/front_end/ui/components/CodeHighlighter_test.ts index 12a5991b2cea5f62e3fb4f9239b81016675197aa..563ef8651bec9fd42309b8d0a551815b6c511ad9 100644 --- a/test/unittests/front_end/ui/components/CodeHighlighter_test.ts +++ b/test/unittests/front_end/ui/components/CodeHighlighter_test.ts @@ -104,6 +104,14 @@ [property color]: [number #ff2]; [property width]: [number 4px]; }`, 'text/css')); + it('can highlight GSS', testHighlight(` +[definition @component] { + [tag foo] { + [property color]: [keyword black]; + } +} +`, 'text/x-gss')); + it('can highlight LESS', testHighlight(` [definition @width]: [number 10px]; [definition @height]: [variable @width] + [number 10px];