LibWebView: Allow using native/user style sheets on Lagom
Move the methods to set the native/user style sheets to the base ViewImplementation class. We must also generate the native style sheet explicitly for now, as LibWebView on Lagom isn't able to include the main LibWebView CMakeLists.txt file yet.
This commit is contained in:
parent
7df48756d6
commit
3f122b7335
Notes:
sideshowbarker
2024-07-17 06:00:02 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/3f122b7335 Pull-request: https://github.com/SerenityOS/serenity/pull/20792 Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 25 additions and 16 deletions
|
@ -442,6 +442,15 @@ if (BUILD_LAGOM)
|
|||
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebDriverClient.ipc WebContent/WebDriverClientEndpoint.h)
|
||||
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebDriverServer.ipc WebContent/WebDriverServerEndpoint.h)
|
||||
|
||||
embed_as_string_view(
|
||||
"NativeStyleSheetSource"
|
||||
"${SERENITY_PROJECT_ROOT}/Userland/Libraries/LibWebView/Native.css"
|
||||
"LibWebView/NativeStyleSheetSource.cpp"
|
||||
"native_stylesheet_source"
|
||||
NAMESPACE "WebView"
|
||||
)
|
||||
|
||||
list(APPEND LIBWEBVIEW_GENERATED_SOURCES LibWebView/NativeStyleSheetSource.cpp)
|
||||
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentClientEndpoint.h)
|
||||
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentServerEndpoint.h)
|
||||
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebDriverClientEndpoint.h)
|
||||
|
|
|
@ -431,15 +431,4 @@ void OutOfProcessWebView::set_content_scales_to_viewport(bool b)
|
|||
m_content_scales_to_viewport = b;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::set_user_style_sheet(String 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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,11 +54,6 @@ public:
|
|||
// In practice, this means that OOPWV may render scaled stale versions of the content while resizing.
|
||||
void set_content_scales_to_viewport(bool);
|
||||
|
||||
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:
|
||||
OutOfProcessWebView();
|
||||
|
||||
|
|
|
@ -359,4 +359,15 @@ ErrorOr<void> ViewImplementation::take_screenshot(ScreenshotType type)
|
|||
return {};
|
||||
}
|
||||
|
||||
void ViewImplementation::set_user_style_sheet(String source)
|
||||
{
|
||||
client().async_set_user_style(move(source));
|
||||
}
|
||||
|
||||
void ViewImplementation::use_native_user_style_sheet()
|
||||
{
|
||||
extern StringView native_stylesheet_source;
|
||||
set_user_style_sheet(MUST(String::from_utf8(native_stylesheet_source)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -94,6 +94,11 @@ public:
|
|||
};
|
||||
ErrorOr<void> take_screenshot(ScreenshotType);
|
||||
|
||||
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();
|
||||
|
||||
Function<void(Gfx::IntSize)> on_did_layout;
|
||||
Function<void()> on_ready_to_paint;
|
||||
Function<String(Web::HTML::ActivateTab)> on_new_tab;
|
||||
|
|
Loading…
Add table
Reference in a new issue