mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Add a separate UA style sheet for documents in quirks mode
We need to make some additional tweaks to the default UA style when displaying documents in quirks mode.
This commit is contained in:
parent
1cb8be9906
commit
96fc476107
Notes:
sideshowbarker
2024-07-19 02:15:38 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/96fc4761078
4 changed files with 25 additions and 5 deletions
|
@ -16,6 +16,7 @@ set(SOURCES
|
|||
CSS/Parser/CSSParser.cpp
|
||||
CSS/PropertyID.cpp
|
||||
CSS/PropertyID.h
|
||||
CSS/QuirksModeStyleSheetSource.cpp
|
||||
CSS/Selector.cpp
|
||||
CSS/SelectorEngine.cpp
|
||||
CSS/StyleDeclaration.cpp
|
||||
|
@ -329,5 +330,13 @@ add_custom_command(
|
|||
MAIN_DEPENDENCY CSS/Default.css
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT CSS/QuirksModeStyleSheetSource.cpp
|
||||
COMMAND ${write_if_different} CSS/QuirksModeStyleSheetSource.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/GenerateStyleSheetSource.sh quirks_mode_stylesheet_source ${CMAKE_CURRENT_SOURCE_DIR}/CSS/QuirksMode.css
|
||||
VERBATIM
|
||||
DEPENDS Scripts/GenerateStyleSheetSource.sh
|
||||
MAIN_DEPENDENCY CSS/Default.css
|
||||
)
|
||||
|
||||
serenity_lib(LibWeb web)
|
||||
target_link_libraries(LibWeb LibCore LibJS LibMarkdown LibGemini LibGUI LibGfx LibTextCodec LibProtocol LibImageDecoderClient)
|
||||
|
|
|
@ -147,8 +147,3 @@ blockquote {
|
|||
margin-left: 25px;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
/* FIXME: I think this should only apply in quirks mode. */
|
||||
table {
|
||||
text-align: left;
|
||||
}
|
||||
|
|
3
Libraries/LibWeb/CSS/QuirksMode.css
Normal file
3
Libraries/LibWeb/CSS/QuirksMode.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
table {
|
||||
text-align: left;
|
||||
}
|
|
@ -57,10 +57,23 @@ static StyleSheet& default_stylesheet()
|
|||
return *sheet;
|
||||
}
|
||||
|
||||
static StyleSheet& quirks_mode_stylesheet()
|
||||
{
|
||||
static StyleSheet* sheet;
|
||||
if (!sheet) {
|
||||
extern const char quirks_mode_stylesheet_source[];
|
||||
String css = quirks_mode_stylesheet_source;
|
||||
sheet = parse_css(CSS::ParsingContext(), css).leak_ref();
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void StyleResolver::for_each_stylesheet(Callback callback) const
|
||||
{
|
||||
callback(default_stylesheet());
|
||||
if (document().in_quirks_mode())
|
||||
callback(quirks_mode_stylesheet());
|
||||
for (auto& sheet : document().style_sheets().sheets()) {
|
||||
callback(sheet);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue