mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 02:56:10 +00:00
LibWeb: Add Document::get_style_sheet_source()
This returns the source text of the specified style sheet. StyleComputer now exposes user agent style sheets so that these can also be requested.
This commit is contained in:
parent
51a426cc05
commit
49b2eb5f51
Notes:
github-actions[bot]
2024-09-03 09:13:03 +00:00
Author: https://github.com/AtkinsSJ
Commit: 49b2eb5f51
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1168
Reviewed-by: https://github.com/trflynn89
4 changed files with 98 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -254,6 +254,24 @@ static CSSStyleSheet& svg_stylesheet(DOM::Document const& document)
|
|||
return *sheet;
|
||||
}
|
||||
|
||||
Optional<String> StyleComputer::user_agent_style_sheet_source(StringView name)
|
||||
{
|
||||
extern String default_stylesheet_source;
|
||||
extern String quirks_mode_stylesheet_source;
|
||||
extern String mathml_stylesheet_source;
|
||||
extern String svg_stylesheet_source;
|
||||
|
||||
if (name == "CSS/Default.css"sv)
|
||||
return default_stylesheet_source;
|
||||
if (name == "CSS/QuirksMode.css"sv)
|
||||
return quirks_mode_stylesheet_source;
|
||||
if (name == "MathML/Default.css"sv)
|
||||
return mathml_stylesheet_source;
|
||||
if (name == "SVG/Default.css"sv)
|
||||
return svg_stylesheet_source;
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void StyleComputer::for_each_stylesheet(CascadeOrigin cascade_origin, Callback callback) const
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2024, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -116,6 +116,8 @@ public:
|
|||
static void set_property_expanding_shorthands(StyleProperties&, PropertyID, CSSStyleValue const&, CSS::CSSStyleDeclaration const*, StyleProperties const& style_for_revert, Important = Important::No);
|
||||
static NonnullRefPtr<CSSStyleValue const> get_inherit_value(JS::Realm& initial_value_context_realm, CSS::PropertyID, DOM::Element const*, Optional<CSS::Selector::PseudoElement::Type> = {});
|
||||
|
||||
static Optional<String> user_agent_style_sheet_source(StringView name);
|
||||
|
||||
explicit StyleComputer(DOM::Document&);
|
||||
~StyleComputer();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue