Skip to content

Commit

Permalink
LibWeb: Rename 'cross-origin opener policy' to 'opener policy'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkon1 authored and Julius Elshoff committed Sep 23, 2024
2 parents d17fe78 + 2d34e79 commit 4a7bb79
Show file tree
Hide file tree
Showing 331 changed files with 5,660 additions and 5,488 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/libjs-test262.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build unzip gcc-13 g++-13 jq wget curl zip tar autoconf autoconf-archive automake nasm pkg-config libgl1-mesa-dev
sudo apt-get install -y ninja-build unzip gcc-13 g++-13 jq wget curl zip tar autoconf autoconf-archive automake nasm pkg-config libgl1-mesa-dev rsync
test -e /opt/wabt-1.0.35 || (
cd /tmp
wget https://github.com/WebAssembly/wabt/releases/download/1.0.35/wabt-1.0.35-ubuntu-20.04.tar.gz
Expand Down
4 changes: 4 additions & 0 deletions AK/Debug.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
# cmakedefine01 CSS_TOKENIZER_DEBUG
#endif

#ifndef CSS_TRANSITIONS_DEBUG
# cmakedefine01 CSS_TRANSITIONS_DEBUG
#endif

#ifndef EDITOR_DEBUG
# cmakedefine01 EDITOR_DEBUG
#endif
Expand Down
18 changes: 0 additions & 18 deletions AK/Utf16View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ ErrorOr<void> code_point_to_utf16(Utf16Data& string, u32 code_point, Endianness

size_t utf16_code_unit_length_from_utf8(StringView string)
{
// FIXME: The CPU-specific implementations behave differently on null inputs. We treat null views as an empty string.
if (string.is_empty())
return 0;

return simdutf::utf16_length_from_utf8(string.characters_without_null_termination(), string.length());
}

Expand Down Expand Up @@ -300,10 +296,6 @@ bool Utf16View::starts_with(Utf16View const& needle) const

bool Utf16View::validate() const
{
// FIXME: The CPU-specific implementations behave differently on null inputs. We treat null views as an empty string.
if (is_empty())
return true;

switch (m_endianness) {
case Endianness::Host:
return simdutf::validate_utf16(char_data(), length_in_code_units());
Expand All @@ -317,12 +309,6 @@ bool Utf16View::validate() const

bool Utf16View::validate(size_t& valid_code_units) const
{
// FIXME: The CPU-specific implementations behave differently on null inputs. We treat null views as an empty string.
if (is_empty()) {
valid_code_units = 0;
return true;
}

auto result = [&]() {
switch (m_endianness) {
case Endianness::Host:
Expand All @@ -341,10 +327,6 @@ bool Utf16View::validate(size_t& valid_code_units) const

size_t Utf16View::calculate_length_in_code_points() const
{
// FIXME: The CPU-specific implementations behave differently on null inputs. We treat null views as an empty string.
if (is_empty())
return 0;

// FIXME: simdutf's code point length method assumes valid UTF-16, whereas Utf16View uses U+FFFD as a replacement
// for invalid code points. If we change Utf16View to only accept valid encodings as an invariant, we can
// remove this branch.
Expand Down
10 changes: 0 additions & 10 deletions AK/Utf8View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ Utf8View Utf8View::unicode_substring_view(size_t code_point_offset, size_t code_

size_t Utf8View::calculate_length() const
{
// FIXME: The CPU-specific implementations behave differently on null inputs. We treat null views as an empty string.
if (is_empty())
return 0;

// FIXME: simdutf's code point length method assumes valid UTF-8, whereas Utf8View uses U+FFFD as a replacement
// for invalid code points. If we change Utf8View to only accept valid encodings as an invariant, we can
// remove this branch.
Expand Down Expand Up @@ -157,12 +153,6 @@ Utf8View Utf8View::trim(Utf8View const& characters, TrimMode mode) const

bool Utf8View::validate(size_t& valid_bytes, AllowSurrogates allow_surrogates) const
{
// FIXME: The CPU-specific implementations behave differently on null inputs. We treat null views as an empty string.
if (is_empty()) {
valid_bytes = 0;
return true;
}

auto result = simdutf::validate_utf8_with_errors(m_string.characters_without_null_termination(), m_string.length());
valid_bytes = result.count;

Expand Down
Binary file added Base/res/fonts/NotoEmoji.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion Documentation/BuildInstructionsLadybird.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ sudo pacman -S --needed autoconf-archive automake base-devel ccache cmake curl f

### Fedora or derivatives:
```
sudo dnf install autoconf-archive automake ccache cmake curl libavcodec-free-devel libavformat-free-devel liberation-sans-fonts libglvnd-devel nasm ninja-build qt6-qtbase-devel qt6-qtmultimedia-devel qt6-qttools-devel qt6-qtwayland-devel tar unzip zip zlib-ng-compat-static
sudo dnf install autoconf-archive automake ccache cmake curl libavcodec-free-devel libavformat-free-devel liberation-sans-fonts libglvnd-devel nasm ninja-build perl-FindBin perl-IPC-Cmd qt6-qtbase-devel qt6-qtmultimedia-devel qt6-qttools-devel qt6-qtwayland-devel tar unzip zip zlib-ng-compat-static
```

### openSUSE:
Expand Down
3 changes: 2 additions & 1 deletion Documentation/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ladybird Documentation

Ladybird development moves quickly, so some of these might be out of date. Please let us know if something here is wrong,
or submit a PR with any additions or corrections! If you have any questions that are not answered here or in the [FAQ](FAQ.md),
or submit a PR with any additions or corrections! If you have any questions that are not answered here or in the [FAQ](FAQ.md),
you are welcome to ask on [Discord](../README.md#get-in-touch-and-participate).

## Building and Running
Expand Down Expand Up @@ -34,6 +34,7 @@ you are welcome to ask on [Discord](../README.md#get-in-touch-and-participate).
* [Ladybird Browser Build Instructions](BuildInstructionsLadybird.md)
* [General Architecture](Browser/ProcessArchitecture.md)
* [LibWeb: From Loading to Painting](Browser/LibWebFromLoadingToPainting.md)
* [LibWeb: Browsing Contexts and Navigables](Browser/BrowsingContextsAndNavigables.md)
* [How to Add an IDL File](Browser/AddNewIDLFile.md)
* [LibWeb Code Style & Patterns](Browser/Patterns.md)
* [CSS Generated Files](Browser/CSSGeneratedFiles.md)
5 changes: 0 additions & 5 deletions Ladybird/AppKit/Application/Application.mm
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ - (void)setupWebViewApplication:(Main::Arguments&)arguments
return worker_client->dup_socket();
}

- (void)dumpConnectionInfo:(id)sender
{
m_request_server_client->dump_connection_info();
}

#pragma mark - NSApplication

- (void)terminate:(id)sender
Expand Down
6 changes: 6 additions & 0 deletions Ladybird/AppKit/Application/ApplicationDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <LibWeb/CSS/PreferredContrast.h>
#include <LibWeb/CSS/PreferredMotion.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWebView/Forward.h>

#import <Cocoa/Cocoa.h>

Expand All @@ -32,6 +33,11 @@
fromTab:(nullable Tab*)tab
activateTab:(Web::HTML::ActivateTab)activate_tab;

- (nonnull TabController*)createChildTab:(Optional<URL::URL> const&)url
fromTab:(nonnull Tab*)tab
activateTab:(Web::HTML::ActivateTab)activate_tab
pageIndex:(u64)page_index;

- (void)setActiveTab:(nonnull Tab*)tab;
- (nullable Tab*)activeTab;

Expand Down
46 changes: 41 additions & 5 deletions Ladybird/AppKit/Application/ApplicationDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ - (TabController*)createNewTab:(Optional<URL::URL> const&)url
activateTab:(Web::HTML::ActivateTab)activate_tab
{
auto* controller = [self createNewTab:activate_tab fromTab:tab];
[controller loadURL:url.value_or(WebView::Application::chrome_options().new_tab_page_url)];

if (url.has_value()) {
[controller loadURL:*url];
}

return controller;
}
Expand All @@ -113,6 +116,20 @@ - (nonnull TabController*)createNewTab:(StringView)html
return controller;
}

- (nonnull TabController*)createChildTab:(Optional<URL::URL> const&)url
fromTab:(nonnull Tab*)tab
activateTab:(Web::HTML::ActivateTab)activate_tab
pageIndex:(u64)page_index
{
auto* controller = [self createChildTab:activate_tab fromTab:tab pageIndex:page_index];

if (url.has_value()) {
[controller loadURL:*url];
}

return controller;
}

- (void)setActiveTab:(Tab*)tab
{
self.active_tab = tab;
Expand Down Expand Up @@ -172,6 +189,29 @@ - (nonnull TabController*)createNewTab:(Web::HTML::ActivateTab)activate_tab
fromTab:(nullable Tab*)tab
{
auto* controller = [[TabController alloc] init];
[self initializeTabController:controller
activateTab:activate_tab
fromTab:tab];

return controller;
}

- (nonnull TabController*)createChildTab:(Web::HTML::ActivateTab)activate_tab
fromTab:(nonnull Tab*)tab
pageIndex:(u64)page_index
{
auto* controller = [[TabController alloc] initAsChild:tab pageIndex:page_index];
[self initializeTabController:controller
activateTab:activate_tab
fromTab:tab];

return controller;
}

- (void)initializeTabController:(TabController*)controller
activateTab:(Web::HTML::ActivateTab)activate_tab
fromTab:(nullable Tab*)tab
{
[controller showWindow:nil];

if (tab) {
Expand All @@ -189,7 +229,6 @@ - (nonnull TabController*)createNewTab:(Web::HTML::ActivateTab)activate_tab

[self.managed_tabs addObject:controller];
[controller onCreateNewTab];
return controller;
}

- (void)closeCurrentTab:(id)sender
Expand Down Expand Up @@ -603,9 +642,6 @@ - (NSMenuItem*)createDebugMenu
[submenu addItem:[[NSMenuItem alloc] initWithTitle:@"Dump Local Storage"
action:@selector(dumpLocalStorage:)
keyEquivalent:@""]];
[submenu addItem:[[NSMenuItem alloc] initWithTitle:@"Dump Connection Info"
action:@selector(dumpConnectionInfo:)
keyEquivalent:@""]];
[submenu addItem:[NSMenuItem separatorItem]];

[submenu addItem:[[NSMenuItem alloc] initWithTitle:@"Show Line Box Borders"
Expand Down
9 changes: 8 additions & 1 deletion Ladybird/AppKit/UI/LadybirdWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@

@protocol LadybirdWebViewObserver <NSObject>

- (String const&)onCreateNewTab:(URL::URL const&)url
- (String const&)onCreateNewTab:(Optional<URL::URL> const&)url
activateTab:(Web::HTML::ActivateTab)activate_tab;

- (String const&)onCreateNewTab:(StringView)html
url:(URL::URL const&)url
activateTab:(Web::HTML::ActivateTab)activate_tab;

- (String const&)onCreateChildTab:(Optional<URL::URL> const&)url
activateTab:(Web::HTML::ActivateTab)activate_tab
pageIndex:(u64)page_index;

- (void)loadURL:(URL::URL const&)url;
- (void)onLoadStart:(URL::URL const&)url isRedirect:(BOOL)is_redirect;
- (void)onLoadFinish:(URL::URL const&)url;
Expand All @@ -47,6 +51,9 @@
@interface LadybirdWebView : NSClipView <NSMenuDelegate>

- (instancetype)init:(id<LadybirdWebViewObserver>)observer;
- (instancetype)initAsChild:(id<LadybirdWebViewObserver>)observer
parent:(LadybirdWebView*)parent
pageIndex:(u64)page_index;

- (void)loadURL:(URL::URL const&)url;
- (void)loadHTML:(StringView)html;
Expand Down
79 changes: 29 additions & 50 deletions Ladybird/AppKit/UI/LadybirdWebView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <LibURL/URL.h>
#include <LibWeb/HTML/SelectedFile.h>
#include <LibWebView/Application.h>
#include <LibWebView/CookieJar.h>
#include <LibWebView/SearchEngine.h>
#include <LibWebView/SourceHighlighter.h>
#include <LibWebView/URL.h>
Expand Down Expand Up @@ -88,6 +87,26 @@ @implementation LadybirdWebView
@synthesize status_label = _status_label;

- (instancetype)init:(id<LadybirdWebViewObserver>)observer
{
if (self = [self initWebView:observer]) {
m_web_view_bridge->initialize_client();
}

return self;
}

- (instancetype)initAsChild:(id<LadybirdWebViewObserver>)observer
parent:(LadybirdWebView*)parent
pageIndex:(u64)page_index
{
if (self = [self initWebView:observer]) {
m_web_view_bridge->initialize_client_as_child(*parent->m_web_view_bridge, page_index);
}

return self;
}

- (instancetype)initWebView:(id<LadybirdWebViewObserver>)observer
{
if (self = [super init]) {
self.observer = observer;
Expand All @@ -109,8 +128,6 @@ - (instancetype)init:(id<LadybirdWebViewObserver>)observer
m_web_view_bridge = MUST(Ladybird::WebViewBridge::create(move(screen_rects), device_pixel_ratio, [delegate preferredColorScheme], [delegate preferredContrast], [delegate preferredMotion]));
[self setWebViewCallbacks];

m_web_view_bridge->initialize_client();

auto* area = [[NSTrackingArea alloc] initWithRect:[self bounds]
options:NSTrackingActiveInKeyWindow | NSTrackingInVisibleRect | NSTrackingMouseMoved
owner:self
Expand Down Expand Up @@ -317,13 +334,19 @@ - (void)setWebViewCallbacks
[self setNeedsDisplay:YES];
};

m_web_view_bridge->on_new_web_view = [weak_self](auto activate_tab, auto, auto) {
m_web_view_bridge->on_new_web_view = [weak_self](auto activate_tab, auto, auto page_index) {
LadybirdWebView* self = weak_self;
if (self == nil) {
return String {};
}
// FIXME: Create a child tab that re-uses the ConnectionFromClient of the parent tab
return [self.observer onCreateNewTab:"about:blank"sv activateTab:activate_tab];

if (page_index.has_value()) {
return [self.observer onCreateChildTab:{}
activateTab:activate_tab
pageIndex:*page_index];
}

return [self.observer onCreateNewTab:{} activateTab:activate_tab];
};

m_web_view_bridge->on_request_web_content = [weak_self]() {
Expand Down Expand Up @@ -531,30 +554,6 @@ - (void)setWebViewCallbacks
[self updateViewportRect:Ladybird::WebViewBridge::ForResize::Yes];
};

m_web_view_bridge->on_navigate_back = [weak_self]() {
LadybirdWebView* self = weak_self;
if (self == nil) {
return;
}
[self navigateBack];
};

m_web_view_bridge->on_navigate_forward = [weak_self]() {
LadybirdWebView* self = weak_self;
if (self == nil) {
return;
}
[self navigateForward];
};

m_web_view_bridge->on_refresh = [weak_self]() {
LadybirdWebView* self = weak_self;
if (self == nil) {
return;
}
[self reload];
};

m_web_view_bridge->on_request_tooltip_override = [weak_self](auto, auto const& tooltip) {
LadybirdWebView* self = weak_self;
if (self == nil) {
Expand Down Expand Up @@ -974,26 +973,6 @@ - (void)setWebViewCallbacks
[NSMenu popUpContextMenu:self.select_dropdown withEvent:event forView:self];
};

m_web_view_bridge->on_get_all_cookies = [](auto const& url) {
return WebView::Application::cookie_jar().get_all_cookies(url);
};

m_web_view_bridge->on_get_named_cookie = [](auto const& url, auto const& name) {
return WebView::Application::cookie_jar().get_named_cookie(url, name);
};

m_web_view_bridge->on_get_cookie = [](auto const& url, auto source) {
return WebView::Application::cookie_jar().get_cookie(url, source);
};

m_web_view_bridge->on_set_cookie = [](auto const& url, auto const& cookie, auto source) {
WebView::Application::cookie_jar().set_cookie(url, cookie, source);
};

m_web_view_bridge->on_update_cookie = [](auto const& cookie) {
WebView::Application::cookie_jar().update_cookie(cookie);
};

m_web_view_bridge->on_restore_window = [weak_self]() {
LadybirdWebView* self = weak_self;
if (self == nil) {
Expand Down
Loading

0 comments on commit 4a7bb79

Please sign in to comment.