mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 21:12:26 +00:00
LibURL+LibWeb: Make URL::Origin default constructor private
Instead, porting over all users to use the newly created Origin::create_opaque factory function. This also requires porting over some users of Origin to avoid default construction.
This commit is contained in:
parent
5deb8ba2f8
commit
e0d7278820
Notes:
github-actions[bot]
2025-06-17 18:55:18 +00:00
Author: https://github.com/shannonbooth
Commit: e0d7278820
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5094
Reviewed-by: https://github.com/gmta ✅
16 changed files with 70 additions and 66 deletions
|
@ -10,6 +10,12 @@
|
|||
|
||||
namespace URL {
|
||||
|
||||
// FIXME: This should be generating a unique origin identifer that can be used for equality checks.
|
||||
Origin Origin::create_opaque()
|
||||
{
|
||||
return Origin {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#same-site
|
||||
bool Origin::is_same_site(Origin const& other) const
|
||||
{
|
||||
|
|
|
@ -15,10 +15,6 @@ namespace URL {
|
|||
|
||||
class Origin {
|
||||
public:
|
||||
// FIXME: This should be generating a unique origin identifer that can be used for equality checks.
|
||||
// Probably we should remove the default constructor, and instead expose this as a factory method.
|
||||
Origin() = default;
|
||||
|
||||
Origin(Optional<String> const& scheme, Host const& host, Optional<u16> port)
|
||||
: m_state(State {
|
||||
.scheme = scheme,
|
||||
|
@ -28,6 +24,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static Origin create_opaque();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque
|
||||
bool is_opaque() const { return !m_state.has_value(); }
|
||||
|
||||
|
@ -102,6 +100,8 @@ public:
|
|||
bool operator==(Origin const& other) const { return is_same_origin(other); }
|
||||
|
||||
private:
|
||||
Origin() = default;
|
||||
|
||||
struct State {
|
||||
Optional<String> scheme;
|
||||
Host host;
|
||||
|
|
|
@ -345,14 +345,14 @@ Origin URL::origin() const
|
|||
|
||||
// 3. If pathURL is failure, then return a new opaque origin.
|
||||
if (!path_url.has_value())
|
||||
return Origin {};
|
||||
return Origin::create_opaque();
|
||||
|
||||
// 4. If pathURL’s scheme is "http", "https", or "file", then return pathURL’s origin.
|
||||
if (path_url->scheme().is_one_of("http"sv, "https"sv, "file"sv))
|
||||
return path_url->origin();
|
||||
|
||||
// 5. Return a new opaque origin.
|
||||
return Origin {};
|
||||
return Origin::create_opaque();
|
||||
}
|
||||
|
||||
// -> "ftp"
|
||||
|
@ -375,7 +375,7 @@ Origin URL::origin() const
|
|||
|
||||
// -> Otherwise
|
||||
// Return a new opaque origin.
|
||||
return Origin {};
|
||||
return Origin::create_opaque();
|
||||
}
|
||||
|
||||
bool URL::equals(URL const& other, ExcludeFragment exclude_fragments) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue