mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibWebView: Add a standard "look like the OS" style sheet
It's quite common to want the web-view to match the native OS widgets, so let's make that easy to do.
This commit is contained in:
parent
84a5c67d6b
commit
7436f4fec2
4 changed files with 53 additions and 0 deletions
|
@ -10,11 +10,20 @@ set(SOURCES
|
||||||
WebSocketClientAdapter.cpp
|
WebSocketClientAdapter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
embed_as_string_view(
|
||||||
|
"NativeStyleSheetSource.cpp"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/Native.css"
|
||||||
|
"NativeStyleSheetSource.cpp"
|
||||||
|
"native_stylesheet_source"
|
||||||
|
NAMESPACE "WebView"
|
||||||
|
)
|
||||||
|
|
||||||
set(GENERATED_SOURCES
|
set(GENERATED_SOURCES
|
||||||
../../Services/RequestServer/RequestClientEndpoint.h
|
../../Services/RequestServer/RequestClientEndpoint.h
|
||||||
../../Services/RequestServer/RequestServerEndpoint.h
|
../../Services/RequestServer/RequestServerEndpoint.h
|
||||||
../../Services/WebContent/WebContentClientEndpoint.h
|
../../Services/WebContent/WebContentClientEndpoint.h
|
||||||
../../Services/WebContent/WebContentServerEndpoint.h
|
../../Services/WebContent/WebContentServerEndpoint.h
|
||||||
|
NativeStyleSheetSource.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_lib(LibWebView webview)
|
serenity_lib(LibWebView webview)
|
||||||
|
|
35
Userland/Libraries/LibWebView/Native.css
Normal file
35
Userland/Libraries/LibWebView/Native.css
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Stylesheet designed to be used as the user stylesheet by apps that want their
|
||||||
|
* web content to look like the native GUI.
|
||||||
|
*/
|
||||||
|
|
||||||
|
html {
|
||||||
|
background-color: -libweb-palette-base;
|
||||||
|
color: -libweb-palette-base-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, textarea {
|
||||||
|
border-color: -libweb-palette-threed-shadow1;
|
||||||
|
}
|
||||||
|
|
||||||
|
button, input[type=submit], input[type=button], input[type=reset] {
|
||||||
|
background-color: -libweb-palette-button;
|
||||||
|
border-color: -libweb-palette-threed-shadow1;
|
||||||
|
color: -libweb-palette-button-text;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover, input[type=submit]:hover, input[type=button]:hover, input[type=reset]:hover {
|
||||||
|
background-color: -libweb-palette-hover-highlight;
|
||||||
|
}
|
||||||
|
|
||||||
|
:link {
|
||||||
|
color: -libweb-link;
|
||||||
|
}
|
||||||
|
|
||||||
|
:visited {
|
||||||
|
color: -libweb-palette-visited-link;
|
||||||
|
}
|
||||||
|
|
||||||
|
:link:active, :visited:active {
|
||||||
|
color: -libweb-palette-active-link;
|
||||||
|
}
|
|
@ -436,4 +436,10 @@ void OutOfProcessWebView::set_user_style_sheet(String source)
|
||||||
client().async_set_user_style(source);
|
client().async_set_user_style(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OutOfProcessWebView::use_native_user_style_sheet()
|
||||||
|
{
|
||||||
|
extern StringView native_stylesheet_source;
|
||||||
|
set_user_style_sheet(MUST(String::from_utf8(native_stylesheet_source)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,9 @@ public:
|
||||||
void set_content_scales_to_viewport(bool);
|
void set_content_scales_to_viewport(bool);
|
||||||
|
|
||||||
void set_user_style_sheet(String source);
|
void set_user_style_sheet(String source);
|
||||||
|
// Load Native.css as the User style sheet, which attempts to make WebView content look as close to
|
||||||
|
// native GUI::Widgets as possible.
|
||||||
|
void use_native_user_style_sheet();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OutOfProcessWebView();
|
OutOfProcessWebView();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue