diff --git a/chromium/base/bit_cast.h b/chromium/base/bit_cast.h index a3fe20995f8..e57d03d6e2f 100644 --- a/chromium/base/bit_cast.h +++ b/chromium/base/bit_cast.h @@ -7,6 +7,11 @@ #include +#include "base/compiler_specific.h" +#if !HAS_BUILTIN(__builtin_bit_cast) +#include +#endif + namespace base { // This is an equivalent to C++20's std::bit_cast<>(), but with additional @@ -18,8 +23,14 @@ namespace base { // reinterpret_cast<>(), and then look at https://eel.is/c++draft/basic.lval#11 // as that's probably UB also. -template -constexpr Dest bit_cast(const Source& source) { +template +#if !HAS_BUILTIN(__builtin_bit_cast) +constexpr +#else +inline +#endif + Dest + bit_cast(const Source& source) { static_assert(!std::is_pointer_v, "bit_cast must not be used on pointer types"); static_assert(!std::is_pointer_v, @@ -36,8 +47,13 @@ constexpr Dest bit_cast(const Source& source) { static_assert( std::is_trivially_copyable_v, "bit_cast requires the destination type to be trivially copyable"); - +#if HAS_BUILTIN(__builtin_bit_cast) return __builtin_bit_cast(Dest, source); +#else + Dest dest; + memcpy(&dest, &source, sizeof(dest)); + return dest; +#endif } } // namespace base diff --git a/chromium/base/time/time.h b/chromium/base/time/time.h index 0efbea85491..03774d83672 100644 --- a/chromium/base/time/time.h +++ b/chromium/base/time/time.h @@ -319,9 +319,24 @@ class BASE_EXPORT TimeDelta { } // Comparison operators. - friend constexpr bool operator==(TimeDelta, TimeDelta) = default; - friend constexpr std::strong_ordering operator<=>(TimeDelta, - TimeDelta) = default; + constexpr bool operator==(TimeDelta other) const { + return delta_ == other.delta_; + } + constexpr bool operator!=(TimeDelta other) const { + return delta_ != other.delta_; + } + constexpr bool operator<(TimeDelta other) const { + return delta_ < other.delta_; + } + constexpr bool operator<=(TimeDelta other) const { + return delta_ <= other.delta_; + } + constexpr bool operator>(TimeDelta other) const { + return delta_ > other.delta_; + } + constexpr bool operator>=(TimeDelta other) const { + return delta_ >= other.delta_; + } // Returns this delta, ceiled/floored/rounded-away-from-zero to the nearest // multiple of |interval|. @@ -471,9 +486,24 @@ class TimeBase { } // Comparison operators - friend constexpr bool operator==(const TimeBase&, const TimeBase&) = default; - friend constexpr std::strong_ordering operator<=>(const TimeBase&, - const TimeBase&) = default; + constexpr bool operator==(const TimeBase& other) const { + return us_ == other.us_; + } + constexpr bool operator!=(const TimeBase& other) const { + return us_ != other.us_; + } + constexpr bool operator<(const TimeBase& other) const { + return us_ < other.us_; + } + constexpr bool operator<=(const TimeBase& other) const { + return us_ <= other.us_; + } + constexpr bool operator>(const TimeBase& other) const { + return us_ > other.us_; + } + constexpr bool operator>=(const TimeBase& other) const { + return us_ >= other.us_; + } protected: constexpr explicit TimeBase(int64_t us) : us_(us) {} diff --git a/chromium/base/token.h b/chromium/base/token.h index d5dd6573427..f38fd934355 100644 --- a/chromium/base/token.h +++ b/chromium/base/token.h @@ -12,9 +12,9 @@ #include -#include #include #include +#include #include "base/base_export.h" #include "base/containers/span.h" @@ -56,11 +56,18 @@ class BASE_EXPORT Token { return as_bytes(make_span(words_)); } - friend constexpr auto operator<=>(const Token& lhs, - const Token& rhs) = default; - friend constexpr bool operator==(const Token& lhs, - const Token& rhs) = default; + constexpr bool operator==(const Token& other) const { + return words_[0] == other.words_[0] && words_[1] == other.words_[1]; + } + + constexpr bool operator!=(const Token& other) const { + return !(*this == other); + } + constexpr bool operator<(const Token& other) const { + return std::tie(words_[0], words_[1]) < + std::tie(other.words_[0], other.words_[1]); + } // Generates a string representation of this Token useful for e.g. logging. std::string ToString() const; diff --git a/chromium/base/types/strong_alias.h b/chromium/base/types/strong_alias.h index b58353f26e4..d6a3c07a48a 100644 --- a/chromium/base/types/strong_alias.h +++ b/chromium/base/types/strong_alias.h @@ -101,17 +101,24 @@ class StrongAlias { constexpr explicit operator const UnderlyingType&() const& { return value_; } - // Comparison operators that default to the behavior of `UnderlyingType`. - // Note that if you wish to compare `StrongAlias`, e.g., - // by using `operator<` in a `std::set`, then `UnderlyingType` must - // implement `operator<=>`. If you cannot modify `UnderlyingType` (e.g., - // because it is from an external library), then a work-around is to create a - // thin wrapper `W` around it, define `operator<=>` for the wrapper and create - // a `StrongAlias`. - friend auto operator<=>(const StrongAlias& lhs, - const StrongAlias& rhs) = default; - friend bool operator==(const StrongAlias& lhs, - const StrongAlias& rhs) = default; + constexpr bool operator==(const StrongAlias& other) const { + return value_ == other.value_; + } + constexpr bool operator!=(const StrongAlias& other) const { + return value_ != other.value_; + } + constexpr bool operator<(const StrongAlias& other) const { + return value_ < other.value_; + } + constexpr bool operator<=(const StrongAlias& other) const { + return value_ <= other.value_; + } + constexpr bool operator>(const StrongAlias& other) const { + return value_ > other.value_; + } + constexpr bool operator>=(const StrongAlias& other) const { + return value_ >= other.value_; + } // Hasher to use in std::unordered_map, std::unordered_set, etc. // diff --git a/chromium/base/types/token_type.h b/chromium/base/types/token_type.h index abb8b7b4df7..3d877e1fa87 100644 --- a/chromium/base/types/token_type.h +++ b/chromium/base/types/token_type.h @@ -5,7 +5,6 @@ #ifndef BASE_TYPES_TOKEN_TYPE_H_ #define BASE_TYPES_TOKEN_TYPE_H_ -#include #include #include "base/check.h" @@ -42,13 +41,6 @@ class TokenType : public StrongAlias { // StrongAlias doesn't define <=> because not all underlying types will // implement it. TokenType can define it using UnguessableToken's // implementation, though. - friend constexpr auto operator<=>(const TokenType& lhs, - const TokenType& rhs) { - return lhs.value() <=> rhs.value(); - } - friend constexpr bool operator==(const TokenType& lhs, const TokenType& rhs) { - return lhs.value() == rhs.value(); - } // Hash functor for use in unordered containers. struct Hasher { diff --git a/chromium/base/unguessable_token.cc b/chromium/base/unguessable_token.cc index 1f91a938caf..3e4f7832526 100644 --- a/chromium/base/unguessable_token.cc +++ b/chromium/base/unguessable_token.cc @@ -56,13 +56,14 @@ std::optional UnguessableToken::DeserializeFromString( return UnguessableToken(token.value()); } -bool operator==(const UnguessableToken& lhs, const UnguessableToken& rhs) { +bool UnguessableToken::operator==(const UnguessableToken& other) const { #if BUILDFLAG(IS_NACL) // BoringSSL is unavailable for NaCl builds so it remains timing dependent. - return lhs.token_ == rhs.token_; + return token_ == other.token_; #else - auto bytes = lhs.token_.AsBytes(); - auto other_bytes = rhs.token_.AsBytes(); + auto bytes = token_.AsBytes(); + auto other_bytes = other.token_.AsBytes(); + return CRYPTO_memcmp(bytes.data(), other_bytes.data(), bytes.size()) == 0; #endif } diff --git a/chromium/base/unguessable_token.h b/chromium/base/unguessable_token.h index 2ec3340af04..593dd79c46a 100644 --- a/chromium/base/unguessable_token.h +++ b/chromium/base/unguessable_token.h @@ -106,12 +106,15 @@ class BASE_EXPORT UnguessableToken { span AsBytes() const { return token_.AsBytes(); } - friend constexpr auto operator<=>(const UnguessableToken& lhs, - const UnguessableToken& rhs) = default; + constexpr bool operator<(const UnguessableToken& other) const { + return token_ < other.token_; + } + + bool operator==(const UnguessableToken& other) const; - // operator== uses constant-time comparison for security where available. - friend BASE_EXPORT bool operator==(const UnguessableToken& lhs, - const UnguessableToken& rhs); + bool operator!=(const UnguessableToken& other) const { + return !(*this == other); + } #if defined(UNIT_TEST) static UnguessableToken CreateForTesting(uint64_t high, uint64_t low) { @@ -128,9 +131,6 @@ class BASE_EXPORT UnguessableToken { base::Token token_; }; -BASE_EXPORT bool operator==(const UnguessableToken& lhs, - const UnguessableToken& rhs); - BASE_EXPORT std::ostream& operator<<(std::ostream& out, const UnguessableToken& token); diff --git a/chromium/components/autofill/core/common/form_field_data.cc b/chromium/components/autofill/core/common/form_field_data.cc index dfc4642ce99..67ad50ffcbe 100644 --- a/chromium/components/autofill/core/common/form_field_data.cc +++ b/chromium/components/autofill/core/common/form_field_data.cc @@ -254,6 +254,14 @@ bool DeserializeSection11(base::PickleIterator* iter, } // namespace +bool operator==(const SelectOption& lhs, const SelectOption& rhs) { + return std::tie(lhs.value, lhs.content) == std::tie(rhs.value, rhs.content); +} + +bool operator!=(const SelectOption& lhs, const SelectOption& rhs) { + return !(lhs == rhs); +} + Section Section::FromAutocomplete(Section::Autocomplete autocomplete) { Section section; if (autocomplete.section.empty() && autocomplete.mode == HtmlFieldMode::kNone) @@ -290,6 +298,48 @@ Section::Section(const Section& section) = default; Section::~Section() = default; +bool operator==(const Section::Autocomplete& a, + const Section::Autocomplete& b) { + return std::tie(a.section, a.mode) == std::tie(b.section, b.mode); +} + +bool operator!=(const Section::Autocomplete& a, + const Section::Autocomplete& b) { + return !(a == b); +} + +bool operator<(const Section::Autocomplete& a, const Section::Autocomplete& b) { + return std::tie(a.section, a.mode) < std::tie(b.section, b.mode); +} + +bool operator==(const Section::FieldIdentifier& a, + const Section::FieldIdentifier& b) { + return std::tie(a.field_name, a.local_frame_id, a.field_renderer_id) == + std::tie(b.field_name, b.local_frame_id, b.field_renderer_id); +} + +bool operator!=(const Section::FieldIdentifier& a, + const Section::FieldIdentifier& b) { + return !(a == b); +} + +bool operator<(const Section::FieldIdentifier& a, + const Section::FieldIdentifier& b) { + return std::tie(a.field_name, a.local_frame_id, a.field_renderer_id) < + std::tie(b.field_name, b.local_frame_id, b.field_renderer_id); +} + +bool operator==(const Section& a, const Section& b) { + return a.value_ == b.value_; +} + +bool operator!=(const Section& a, const Section& b) { + return !(a == b); +} +bool operator<(const Section& a, const Section& b) { + return a.value_ < b.value_; +} + Section::operator bool() const { return !is_default(); } diff --git a/chromium/components/autofill/core/common/form_field_data.h b/chromium/components/autofill/core/common/form_field_data.h index bb87d5577c6..051d9a93f0b 100644 --- a/chromium/components/autofill/core/common/form_field_data.h +++ b/chromium/components/autofill/core/common/form_field_data.h @@ -7,7 +7,6 @@ #include -#include #include #include #include @@ -74,9 +73,6 @@ using FieldPropertiesMask = std::underlying_type_t; // For the HTML snippet ||, the // value is "US" and the contents is "United States". struct SelectOption { - friend bool operator==(const SelectOption& lhs, - const SelectOption& rhs) = default; - std::u16string value; std::u16string content; }; @@ -85,11 +81,6 @@ struct SelectOption { class Section { public: struct Autocomplete { - friend auto operator<=>(const Autocomplete& lhs, - const Autocomplete& rhs) = default; - friend bool operator==(const Autocomplete& lhs, - const Autocomplete& rhs) = default; - std::string section; HtmlFieldMode mode = HtmlFieldMode::kNone; }; @@ -105,10 +96,9 @@ class Section { local_frame_id(local_frame_id), field_renderer_id(field_renderer_id) {} - friend auto operator<=>(const FieldIdentifier& lhs, - const FieldIdentifier& rhs) = default; - friend bool operator==(const FieldIdentifier& lhs, - const FieldIdentifier& rhs) = default; + friend bool operator==(const FieldIdentifier& a, const FieldIdentifier& b); + friend bool operator!=(const FieldIdentifier& a, const FieldIdentifier& b); + friend bool operator<(const FieldIdentifier& a, const FieldIdentifier& b); std::string field_name; size_t local_frame_id; @@ -124,14 +114,11 @@ class Section { Section(const Section& section); ~Section(); - // `absl::variant` does not implement `operator<=>` - therefore the ordering - // needs to be specified manually. Once `absl::variant` is `std::variant`, - // this return type can become `auto`. - friend std::strong_ordering operator<=>(const Section& lhs, - const Section& rhs) = default; - friend bool operator==(const Section& lhs, const Section& rhs) = default; - explicit operator bool() const; + friend bool operator==(const Section& a, const Section& b); + friend bool operator!=(const Section& a, const Section& b); + friend bool operator<(const Section& a, const Section& b); + explicit operator bool() const; bool is_from_autocomplete() const; bool is_from_fieldidentifier() const; bool is_default() const; diff --git a/chromium/components/autofill/core/common/unique_ids.h b/chromium/components/autofill/core/common/unique_ids.h index 416adc29ff0..08aca04432f 100644 --- a/chromium/components/autofill/core/common/unique_ids.h +++ b/chromium/components/autofill/core/common/unique_ids.h @@ -8,6 +8,9 @@ #include #include +#include +#include + #include "base/types/id_type.h" #include "base/unguessable_token.h" #include "build/build_config.h" @@ -134,12 +137,22 @@ struct GlobalId { explicit constexpr operator bool() const { return static_cast(renderer_id); } - - friend auto operator<=>(const GlobalId& lhs, - const GlobalId& rhs) = default; - friend bool operator==(const GlobalId& lhs, - const GlobalId& rhs) = default; }; +template +bool operator==(const GlobalId& a, const GlobalId& b) { + return a.renderer_id == b.renderer_id && a.frame_token == b.frame_token; +} + +template +bool operator!=(const GlobalId& a, const GlobalId& b) { + return !(a == b); +} + +template +bool operator<(const GlobalId& a, const GlobalId& b) { + return std::tie(a.frame_token, a.renderer_id) < + std::tie(b.frame_token, b.renderer_id); +} } // namespace internal diff --git a/chromium/components/performance_manager/public/resource_attribution/frame_context.h b/chromium/components/performance_manager/public/resource_attribution/frame_context.h index 6baee52c3f8..9ab1b821bf5 100644 --- a/chromium/components/performance_manager/public/resource_attribution/frame_context.h +++ b/chromium/components/performance_manager/public/resource_attribution/frame_context.h @@ -5,7 +5,6 @@ #ifndef COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RESOURCE_ATTRIBUTION_FRAME_CONTEXT_H_ #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RESOURCE_ATTRIBUTION_FRAME_CONTEXT_H_ -#include #include #include @@ -71,25 +70,39 @@ class FrameContext { // convenience. std::string ToString() const; - // Compare FrameContexts by GlobalRenderFrameHostId. - constexpr friend auto operator<=>(const FrameContext& a, - const FrameContext& b) { - return a.id_ <=> b.id_; - } - - // Test FrameContexts for equality by GlobalRenderFrameHostId. - constexpr friend bool operator==(const FrameContext& a, - const FrameContext& b) { - return a.id_ == b.id_; - } - private: + friend bool operator<(const FrameContext&, const FrameContext&); + friend bool operator==(const FrameContext&, const FrameContext&); + FrameContext(content::GlobalRenderFrameHostId id, base::WeakPtr weak_node); content::GlobalRenderFrameHostId id_; base::WeakPtr weak_node_; }; +inline bool operator<(const FrameContext& a, const FrameContext& b) { + return a.id_ < b.id_; +} + +inline bool operator==(const FrameContext& a, const FrameContext& b) { + return a.id_ == b.id_; +} + +inline bool operator!=(const FrameContext& a, const FrameContext& b) { + return !(a == b); +} + +inline bool operator<=(const FrameContext& a, const FrameContext& b) { + return !(b < a); +} + +inline bool operator>(const FrameContext& a, const FrameContext& b) { + return !(a < b || a == b); +} + +inline bool operator>=(const FrameContext& a, const FrameContext& b) { + return !(a > b); +} } // namespace resource_attribution diff --git a/chromium/components/performance_manager/public/resource_attribution/page_context.h b/chromium/components/performance_manager/public/resource_attribution/page_context.h index 5c9d272cb01..6d6ba77eafa 100644 --- a/chromium/components/performance_manager/public/resource_attribution/page_context.h +++ b/chromium/components/performance_manager/public/resource_attribution/page_context.h @@ -67,15 +67,9 @@ class PageContext { std::string ToString() const; // Compare PageContexts by PageNode token. - constexpr friend auto operator<=>(const PageContext& a, - const PageContext& b) { - return a.token_ <=> b.token_; - } - // Test PageContexts for equality by PageNode token. - constexpr friend bool operator==(const PageContext& a, const PageContext& b) { - return a.token_ == b.token_; - } + friend bool operator<(const PageContext&, const PageContext&); + friend bool operator==(const PageContext&, const PageContext&); private: PageContext(base::UnguessableToken token, @@ -95,6 +89,33 @@ class PageContext { // A pointer to the PageNode that must be dereferenced on the PM sequence. base::WeakPtr weak_node_; }; +inline bool operator<(const PageContext& a, const PageContext& b) { + CHECK(!a.token_.is_empty()); + CHECK(!b.token_.is_empty()); + return a.token_ < b.token_; +} + +inline bool operator==(const PageContext& a, const PageContext& b) { + CHECK(!a.token_.is_empty()); + CHECK(!b.token_.is_empty()); + return a.token_ == b.token_; +} + +inline bool operator!=(const PageContext& a, const PageContext& b) { + return !(a == b); +} + +inline bool operator<=(const PageContext& a, const PageContext& b) { + return !(b < a); +} + +inline bool operator>(const PageContext& a, const PageContext& b) { + return !(a < b || a == b); +} + +inline bool operator>=(const PageContext& a, const PageContext& b) { + return !(a > b); +} } // namespace resource_attribution diff --git a/chromium/components/viz/common/surfaces/local_surface_id.h b/chromium/components/viz/common/surfaces/local_surface_id.h index c4b6a17f3b4..269d1782123 100644 --- a/chromium/components/viz/common/surfaces/local_surface_id.h +++ b/chromium/components/viz/common/surfaces/local_surface_id.h @@ -117,8 +117,15 @@ class VIZ_COMMON_EXPORT LocalSurfaceId { // with submission of a CompositorFrame to a surface with this LocalSurfaceId. uint64_t submission_trace_id() const { return (persistent_hash() << 1) | 1; } - friend std::strong_ordering operator<=>(const LocalSurfaceId&, - const LocalSurfaceId&) = default; + bool operator==(const LocalSurfaceId& other) const { + return parent_sequence_number_ == other.parent_sequence_number_ && + child_sequence_number_ == other.child_sequence_number_ && + embed_token_ == other.embed_token_; + } + + bool operator!=(const LocalSurfaceId& other) const { + return !(*this == other); + } // This implementation is fast and appropriate for a hash table lookup. // However the hash differs per process, and is inappropriate for tracing. @@ -159,6 +166,7 @@ class VIZ_COMMON_EXPORT LocalSurfaceId { friend class ParentLocalSurfaceIdAllocator; friend class ChildLocalSurfaceIdAllocator; + friend bool operator<(const LocalSurfaceId& lhs, const LocalSurfaceId& rhs); uint32_t parent_sequence_number_; uint32_t child_sequence_number_; @@ -169,6 +177,24 @@ VIZ_COMMON_EXPORT std::ostream& operator<<( std::ostream& out, const LocalSurfaceId& local_surface_id); +inline bool operator<(const LocalSurfaceId& lhs, const LocalSurfaceId& rhs) { + return std::tie(lhs.parent_sequence_number_, lhs.child_sequence_number_, + lhs.embed_token_) < std::tie(rhs.parent_sequence_number_, + rhs.child_sequence_number_, + rhs.embed_token_); +} + +inline bool operator>(const LocalSurfaceId& lhs, const LocalSurfaceId& rhs) { + return operator<(rhs, lhs); +} + +inline bool operator<=(const LocalSurfaceId& lhs, const LocalSurfaceId& rhs) { + return !operator>(lhs, rhs); +} + +inline bool operator>=(const LocalSurfaceId& lhs, const LocalSurfaceId& rhs) { + return !operator<(lhs, rhs); +} } // namespace viz #endif // COMPONENTS_VIZ_COMMON_SURFACES_LOCAL_SURFACE_ID_H_ diff --git a/chromium/components/viz/common/surfaces/surface_id.h b/chromium/components/viz/common/surfaces/surface_id.h index a4994179979..119d4c102b0 100644 --- a/chromium/components/viz/common/surfaces/surface_id.h +++ b/chromium/components/viz/common/surfaces/surface_id.h @@ -7,7 +7,6 @@ #include -#include #include #include @@ -77,8 +76,17 @@ class VIZ_COMMON_EXPORT SurfaceId { // Returns whether this SurfaceId has the same embed token as |other|. bool HasSameEmbedTokenAs(const SurfaceId& other) const; - friend std::strong_ordering operator<=>(const SurfaceId&, - const SurfaceId&) = default; + bool operator==(const SurfaceId& other) const { + return frame_sink_id_ == other.frame_sink_id_ && + local_surface_id_ == other.local_surface_id_; + } + + bool operator!=(const SurfaceId& other) const { return !(*this == other); } + + bool operator<(const SurfaceId& other) const { + return std::tie(frame_sink_id_, local_surface_id_) < + std::tie(other.frame_sink_id_, other.local_surface_id_); + } private: friend struct mojo::StructTraits; diff --git a/chromium/components/viz/common/surfaces/surface_range.cc b/chromium/components/viz/common/surfaces/surface_range.cc index 53176cc6fef..41ac37d3ac1 100644 --- a/chromium/components/viz/common/surfaces/surface_range.cc +++ b/chromium/components/viz/common/surfaces/surface_range.cc @@ -24,6 +24,18 @@ SurfaceRange::SurfaceRange(const SurfaceRange& other) = default; SurfaceRange& SurfaceRange::operator=(const SurfaceRange& other) = default; +bool SurfaceRange::operator==(const SurfaceRange& other) const { + return start_ == other.start() && end_ == other.end(); +} + +bool SurfaceRange::operator!=(const SurfaceRange& other) const { + return !(*this == other); +} + +bool SurfaceRange::operator<(const SurfaceRange& other) const { + return std::tie(end_, start_) < std::tie(other.end(), other.start()); +} + bool SurfaceRange::IsInRangeExclusive(const SurfaceId& surface_id) const { if (!start_) return end_.IsNewerThan(surface_id); diff --git a/chromium/components/viz/common/surfaces/surface_range.h b/chromium/components/viz/common/surfaces/surface_range.h index 364332d0b42..2d71b278e30 100644 --- a/chromium/components/viz/common/surfaces/surface_range.h +++ b/chromium/components/viz/common/surfaces/surface_range.h @@ -33,8 +33,9 @@ class VIZ_COMMON_EXPORT SurfaceRange { SurfaceRange(const SurfaceRange& other); SurfaceRange& operator=(const SurfaceRange& other); - friend std::strong_ordering operator<=>(const SurfaceRange&, - const SurfaceRange&) = default; + bool operator==(const SurfaceRange& other) const; + bool operator!=(const SurfaceRange& other) const; + bool operator<(const SurfaceRange& other) const; // Check if |surface_id| falls within |this| SurfaceRange but is neither the // start nor end of the range. The FrameSinkId of |surface_id| must match diff --git a/chromium/components/viz/service/surfaces/surface_reference.h b/chromium/components/viz/service/surfaces/surface_reference.h index 6e1e6f6bce9..532cb1bc70e 100644 --- a/chromium/components/viz/service/surfaces/surface_reference.h +++ b/chromium/components/viz/service/surfaces/surface_reference.h @@ -31,9 +31,18 @@ class VIZ_SERVICE_EXPORT SurfaceReference { static_cast(child_id_.hash())); } - friend std::strong_ordering operator<=>(const SurfaceReference&, - const SurfaceReference&) = default; + bool operator==(const SurfaceReference& other) const { + return parent_id_ == other.parent_id_ && child_id_ == other.child_id_; + } + + bool operator!=(const SurfaceReference& other) const { + return !(*this == other); + } + bool operator<(const SurfaceReference& other) const { + return std::tie(parent_id_, child_id_) < + std::tie(other.parent_id_, other.child_id_); + } std::string ToString() const; private: diff --git a/chromium/content/public/browser/global_routing_id.h b/chromium/content/public/browser/global_routing_id.h index 099dc55473b..ef0ec52c942 100644 --- a/chromium/content/public/browser/global_routing_id.h +++ b/chromium/content/public/browser/global_routing_id.h @@ -5,8 +5,8 @@ #ifndef CONTENT_PUBLIC_BROWSER_GLOBAL_ROUTING_ID_H_ #define CONTENT_PUBLIC_BROWSER_GLOBAL_ROUTING_ID_H_ -#include #include +#include #include "base/hash/hash.h" #include "base/i18n/number_formatting.h" @@ -39,11 +39,21 @@ struct CONTENT_EXPORT GlobalRoutingID { // The route ID. int route_id = -1; + friend bool operator<(const GlobalRoutingID& lhs, + const GlobalRoutingID& rhs) { + return std::tie(lhs.child_id, lhs.route_id) < + std::tie(rhs.child_id, rhs.route_id); + } + + friend bool operator==(const GlobalRoutingID& lhs, + const GlobalRoutingID& rhs) { + return lhs.child_id == rhs.child_id && lhs.route_id == rhs.route_id; + } - constexpr friend auto operator<=>(const GlobalRoutingID&, - const GlobalRoutingID&) = default; - constexpr friend bool operator==(const GlobalRoutingID&, - const GlobalRoutingID&) = default; + friend bool operator!=(const GlobalRoutingID& lhs, + const GlobalRoutingID& rhs) { + return !(lhs == rhs); + } }; inline std::ostream& operator<<(std::ostream& os, const GlobalRoutingID& id) { @@ -75,10 +85,22 @@ struct CONTENT_EXPORT GlobalRenderFrameHostId { // RenderFrameHost::GetRoutingID(). int frame_routing_id = MSG_ROUTING_NONE; - constexpr friend auto operator<=>(const GlobalRenderFrameHostId&, - const GlobalRenderFrameHostId&) = default; - constexpr friend bool operator==(const GlobalRenderFrameHostId&, - const GlobalRenderFrameHostId&) = default; + friend bool operator<(const GlobalRenderFrameHostId& lhs, + const GlobalRenderFrameHostId& rhs) { + return std::tie(lhs.child_id, lhs.frame_routing_id) < + std::tie(rhs.child_id, rhs.frame_routing_id); + } + + friend bool operator==(const GlobalRenderFrameHostId& lhs, + const GlobalRenderFrameHostId& rhs) { + return lhs.child_id == rhs.child_id && + lhs.frame_routing_id == rhs.frame_routing_id; + } + + friend bool operator!=(const GlobalRenderFrameHostId& lhs, + const GlobalRenderFrameHostId& rhs) { + return !(lhs == rhs); + } explicit operator bool() const { return frame_routing_id != MSG_ROUTING_NONE; @@ -114,11 +136,21 @@ struct GlobalRenderFrameHostToken { // RenderFrameHost::GetFrameToken(). blink::LocalFrameToken frame_token; - constexpr friend auto operator<=>(const GlobalRenderFrameHostToken&, - const GlobalRenderFrameHostToken&) = - default; - constexpr friend bool operator==(const GlobalRenderFrameHostToken&, - const GlobalRenderFrameHostToken&) = default; + friend bool operator<(const GlobalRenderFrameHostToken& lhs, + const GlobalRenderFrameHostToken& rhs) { + return std::tie(lhs.child_id, lhs.frame_token) < + std::tie(rhs.child_id, rhs.frame_token); + } + + friend bool operator==(const GlobalRenderFrameHostToken& lhs, + const GlobalRenderFrameHostToken& rhs) { + return lhs.child_id == rhs.child_id && lhs.frame_token == rhs.frame_token; + } + + friend bool operator!=(const GlobalRenderFrameHostToken& lhs, + const GlobalRenderFrameHostToken& rhs) { + return !(lhs == rhs); + } }; inline std::ostream& operator<<(std::ostream& os, diff --git a/chromium/gpu/command_buffer/client/gl_helper.h b/chromium/gpu/command_buffer/client/gl_helper.h index f7ed136f8f5..0e221481022 100644 --- a/chromium/gpu/command_buffer/client/gl_helper.h +++ b/chromium/gpu/command_buffer/client/gl_helper.h @@ -34,7 +34,7 @@ class ScopedGLuint { GenFunc gen_func, DeleteFunc delete_func) : gl_(gl), id_(0u), delete_func_(delete_func) { - (gl_->*gen_func)(1, &id_); + (gl_.get()->*gen_func)(1, &id_); } operator GLuint() const { return id_; } @@ -46,7 +46,7 @@ class ScopedGLuint { ~ScopedGLuint() { if (id_ != 0) { - (gl_->*delete_func_)(1, &id_); + (gl_.get()->*delete_func_)(1, &id_); } } @@ -86,13 +86,13 @@ class ScopedBinder { typedef void (gles2::GLES2Interface::*BindFunc)(GLenum target, GLuint id); ScopedBinder(gles2::GLES2Interface* gl, GLuint id, BindFunc bind_func) : gl_(gl), bind_func_(bind_func) { - (gl_->*bind_func_)(Target, id); + (gl_.get()->*bind_func_)(Target, id); } ScopedBinder(const ScopedBinder&) = delete; ScopedBinder& operator=(const ScopedBinder&) = delete; - virtual ~ScopedBinder() { (gl_->*bind_func_)(Target, 0); } + virtual ~ScopedBinder() { (gl_.get()->*bind_func_)(Target, 0); } private: raw_ptr gl_; diff --git a/chromium/gpu/command_buffer/common/sync_token.h b/chromium/gpu/command_buffer/common/sync_token.h index d6de7cb7299..1fecca066f5 100644 --- a/chromium/gpu/command_buffer/common/sync_token.h +++ b/chromium/gpu/command_buffer/common/sync_token.h @@ -7,8 +7,8 @@ #include -#include #include +#include #include #include "base/containers/span.h" @@ -71,10 +71,20 @@ struct GPU_EXPORT SyncToken { CommandBufferId command_buffer_id() const { return command_buffer_id_; } uint64_t release_count() const { return release_count_; } - friend bool operator==(const SyncToken&, const SyncToken&) = default; - friend std::strong_ordering operator<=>(const SyncToken&, - const SyncToken&) = default; + bool operator<(const SyncToken& other) const { + return std::tie(namespace_id_, command_buffer_id_, release_count_) < + std::tie(other.namespace_id_, other.command_buffer_id_, + other.release_count_); + } + + bool operator==(const SyncToken& other) const { + return verified_flush_ == other.verified_flush() && + namespace_id_ == other.namespace_id() && + command_buffer_id_ == other.command_buffer_id() && + release_count_ == other.release_count(); + } + bool operator!=(const SyncToken& other) const { return !(*this == other); } std::string ToDebugString() const; private: diff --git a/chromium/third_party/blink/renderer/bindings/core/v8/async_iterable.h b/chromium/third_party/blink/renderer/bindings/core/v8/async_iterable.h index 7bb8c90cc64..1e62199bbcb 100644 --- a/chromium/third_party/blink/renderer/bindings/core/v8/async_iterable.h +++ b/chromium/third_party/blink/renderer/bindings/core/v8/async_iterable.h @@ -245,7 +245,7 @@ class PairAsyncIterable { private: virtual IterationSource* CreateIterationSource( ScriptState* script_state, - IterationSource::Kind kind, + blink::bindings::AsyncIteratorBase::IterationSourceBase::Kind kind, InitArgs... args, ExceptionState& exception_state) = 0; }; @@ -291,7 +291,7 @@ class ValueAsyncIterable { private: virtual IterationSource* CreateIterationSource( ScriptState* script_state, - IterationSource::Kind kind, + blink::bindings::AsyncIteratorBase::IterationSourceBase::Kind kind, InitArgs... args, ExceptionState& exception_state) = 0; }; diff --git a/chromium/third_party/dawn/src/dawn/common/Compiler.h b/chromium/third_party/dawn/src/dawn/common/Compiler.h index 32994827364..5ae6ff7dd71 100644 --- a/chromium/third_party/dawn/src/dawn/common/Compiler.h +++ b/chromium/third_party/dawn/src/dawn/common/Compiler.h @@ -130,8 +130,10 @@ // DAWN_FORCE_INLINE // // Annotate a function indicating it should really never be inline, even in debug mode. -#if DAWN_COMPILER_IS(CLANG) && defined(NDEBUG) && DAWN_HAS_CPP_ATTRIBUTE(clang::always_inline) +#if DAWN_COMPILER_IS(CLANG) && defined(NDEBUG) +#if DAWN_HAS_CPP_ATTRIBUTE(clang::always_inline) #define DAWN_FORCE_INLINE [[clang::always_inline]] inline +#endif #elif DAWN_COMPILER_IS(GCC) && defined(NDEBUG) && DAWN_HAS_ATTRIBUTE(always_inline) #define DAWN_FORCE_INLINE inline __attribute__((always_inline)) #elif DAWN_COMPILER_IS(MSVC) && defined(NDEBUG) diff --git a/chromium/third_party/xnnpack/BUILD.gn b/chromium/third_party/xnnpack/BUILD.gn index 9560581080e..ee8bf060e7f 100644 --- a/chromium/third_party/xnnpack/BUILD.gn +++ b/chromium/third_party/xnnpack/BUILD.gn @@ -102,6 +102,7 @@ if (current_cpu == "x64" || current_cpu == "x86") { ":subgraph_x64_standalone", ":tables_x64_standalone", ] + } else if (current_cpu == "arm64") { xnnpack_deps = [ ":amalgam_arch=armv8.2-a+dotprod", diff --git a/chromium/ui/views/layout/flex_layout_types.cc b/chromium/ui/views/layout/flex_layout_types.cc index a7bf909a22c..4a72e596e89 100644 --- a/chromium/ui/views/layout/flex_layout_types.cc +++ b/chromium/ui/views/layout/flex_layout_types.cc @@ -59,7 +59,7 @@ class LazySize { const gfx::Size& operator*() const { return *get(); } const gfx::Size* get() const { if (!size_) - size_ = (view_->*size_func_)(); + size_ = (view_.get()->*size_func_)(); return &size_.value(); } LazyDimension width() const {