Skip to content

Commit f17317b

Browse files
AtkinsSJawesomekling
authored andcommitted
LibDevTools: Annotate style sheets how Firefox expects
Mark UA style sheets as "system", which makes them read-only in the Firefox dev tools. Also give them an href with a fake resource:// URL so that they don't appear as "<inline style sheet>", and don't set the href for actual inline style sheets, for the opposite reason. I've kept the title for UA style sheets, because that means we see `Thing/Default.css` instead of just `Default.css` for all of them.
1 parent 086ef9e commit f17317b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Libraries/LibDevTools/Actors/FrameActor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,13 @@ void FrameActor::style_sheets_available(JsonObject& response, Vector<Web::CSS::S
161161
JsonValue title;
162162

163163
if (style_sheet.url.has_value()) {
164-
// LibWeb sets the URL to a style sheet name for UA style sheets. DevTools would reject these invalid URLs.
165164
if (style_sheet.type == Web::CSS::StyleSheetIdentifier::Type::UserAgent) {
165+
// LibWeb sets the URL to a style sheet name for UA style sheets. DevTools would reject these invalid URLs.
166+
href = MUST(String::formatted("resource://{}", style_sheet.url.value()));
166167
title = *style_sheet.url;
167168
source_map_base_url = tab_url;
169+
} else if (style_sheet.type == Web::CSS::StyleSheetIdentifier::Type::StyleElement) {
170+
source_map_base_url = *style_sheet.url;
168171
} else {
169172
href = *style_sheet.url;
170173
source_map_base_url = *style_sheet.url;
@@ -186,7 +189,7 @@ void FrameActor::style_sheets_available(JsonObject& response, Vector<Web::CSS::S
186189
sheet.set("sourceMapBaseURL"sv, move(source_map_base_url));
187190
sheet.set("sourceMapURL"sv, ""sv);
188191
sheet.set("styleSheetIndex"sv, i);
189-
sheet.set("system"sv, false);
192+
sheet.set("system"sv, style_sheet.type == Web::CSS::StyleSheetIdentifier::Type::UserAgent);
190193
sheet.set("title"sv, move(title));
191194

192195
sheets.must_append(move(sheet));

0 commit comments

Comments
 (0)