Skip to content

Commit

Permalink
Member: Don't rely on implicit opterator T* [3/n]
Browse files Browse the repository at this point in the history
Similar to https://crrev.com/4943090 with a few more iteration on a
compile-fix cycle as that still uncovers new errors.

Manual edits:
- third_party/blink/renderer/core/style/style_variables.h
- third_party/blink/renderer/core/css/css_value_pool.h
- third_party/blink/renderer/core/dom/container_node.h

Bug: chromium:1492410
Change-Id: Iba22eb58aa372d25db961e2b10a82385cd178113
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4946319
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1211343}
  • Loading branch information
mlippautz authored and Chromium LUCI CQ committed Oct 18, 2023
1 parent 9d41d22 commit 47259a1
Show file tree
Hide file tree
Showing 107 changed files with 185 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,31 +187,31 @@ ScriptValue ScriptCustomElementDefinition::GetConstructorForScript() {
}

bool ScriptCustomElementDefinition::HasConnectedCallback() const {
return connected_callback_;
return connected_callback_ != nullptr;
}

bool ScriptCustomElementDefinition::HasDisconnectedCallback() const {
return disconnected_callback_;
return disconnected_callback_ != nullptr;
}

bool ScriptCustomElementDefinition::HasAdoptedCallback() const {
return adopted_callback_;
return adopted_callback_ != nullptr;
}

bool ScriptCustomElementDefinition::HasFormAssociatedCallback() const {
return form_associated_callback_;
return form_associated_callback_ != nullptr;
}

bool ScriptCustomElementDefinition::HasFormResetCallback() const {
return form_reset_callback_;
return form_reset_callback_ != nullptr;
}

bool ScriptCustomElementDefinition::HasFormDisabledCallback() const {
return form_disabled_callback_;
return form_disabled_callback_ != nullptr;
}

bool ScriptCustomElementDefinition::HasFormStateRestoreCallback() const {
return form_state_restore_callback_;
return form_state_restore_callback_ != nullptr;
}

void ScriptCustomElementDefinition::RunConnectedCallback(Element& element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool AnnotationAgentImpl::IsAttached() const {
bool AnnotationAgentImpl::IsAttachmentPending() const {
// This can be an invalid range but still returns true because the attachment
// is still in progress until the DomMutation task runs in the next rAF.
return pending_range_;
return pending_range_ != nullptr;
}

bool AnnotationAgentImpl::IsBoundForTesting() const {
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/css/counters_scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ CounterNode* CountersScope::FindPreviousCounterWithinStyleScope(
wtf_size_t pos =
FindCounterIndexPrecedingCounter(counter, scope->Counters());
if (pos != kNotFound) {
return scope->Counters().at(pos);
return scope->Counters().at(pos).Get();
}
if (search_scope == SearchScope::SelfSearch) {
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CSSFontFamilyValue* CSSFontFamilyValue::Create(
entry.stored_value->value =
MakeGarbageCollected<CSSFontFamilyValue>(family_name);
}
return entry.stored_value->value;
return entry.stored_value->value.Get();
}

CSSFontFamilyValue::CSSFontFamilyValue(const AtomicString& str)
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/css/css_font_selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ FontMatchingMetrics* CSSFontSelector::GetFontMatchingMetrics() const {
}

bool CSSFontSelector::IsAlive() const {
return tree_scope_;
return tree_scope_ != nullptr;
}

void CSSFontSelector::Trace(Visitor* visitor) const {
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/css/css_style_sheet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class StyleSheetCSSRuleList final : public CSSRuleList {
return style_sheet_->item(index);
}

CSSStyleSheet* GetStyleSheet() const override { return style_sheet_; }
CSSStyleSheet* GetStyleSheet() const override { return style_sheet_.Get(); }

Member<CSSStyleSheet> style_sheet_;
};
Expand Down
14 changes: 9 additions & 5 deletions third_party/blink/renderer/core/css/css_value_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,35 @@ class CORE_EXPORT CSSValuePool final : public GarbageCollected<CSSValuePool> {
}
CSSIdentifierValue* SetIdentifierCacheValue(CSSValueID ident,
CSSIdentifierValue* css_value) {
return identifier_value_cache_[static_cast<int>(ident)] = css_value;
identifier_value_cache_[static_cast<int>(ident)] = css_value;
return css_value;
}
CSSNumericLiteralValue* PixelCacheValue(int int_value) {
return pixel_value_cache_[int_value].Get();
}
CSSNumericLiteralValue* SetPixelCacheValue(
int int_value,
CSSNumericLiteralValue* css_value) {
return pixel_value_cache_[int_value] = css_value;
pixel_value_cache_[int_value] = css_value;
return css_value;
}
CSSNumericLiteralValue* PercentCacheValue(int int_value) {
return percent_value_cache_[int_value].Get();
}
CSSNumericLiteralValue* SetPercentCacheValue(
int int_value,
CSSNumericLiteralValue* css_value) {
return percent_value_cache_[int_value] = css_value;
percent_value_cache_[int_value] = css_value;
return css_value;
}
CSSNumericLiteralValue* NumberCacheValue(int int_value) {
return number_value_cache_[int_value].Get();
}
CSSNumericLiteralValue* SetNumberCacheValue(
int int_value,
CSSNumericLiteralValue* css_value) {
return number_value_cache_[int_value] = css_value;
number_value_cache_[int_value] = css_value;
return css_value;
}

// Hash map caches.
Expand All @@ -151,7 +155,7 @@ class CORE_EXPORT CSSValuePool final : public GarbageCollected<CSSValuePool> {

unsigned hash = color.GetHash();
if (Member<CSSColor>* found = color_value_cache_.Find(color, hash); found) {
return *found;
return found->Get();
}
return color_value_cache_.Insert(
color, MakeGarbageCollected<CSSColor>(color), hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool ComputedStylePropertyMap::ComparePropertyNames(
Element* ComputedStylePropertyMap::StyledElement() const {
DCHECK(element_);
if (!pseudo_id_) {
return element_;
return element_.Get();
}
if (PseudoElement* pseudo_element = element_->GetPseudoElement(pseudo_id_)) {
return pseudo_element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CORE_EXPORT CustomProperty : public Variable {
const LayoutObject*,
bool allow_visited_style) const override;

bool IsRegistered() const { return registration_; }
bool IsRegistered() const { return registration_ != nullptr; }

bool HasInitialValue() const;

Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/css/rule_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ class CORE_EXPORT RuleSet final : public GarbageCollected<RuleSet> {
return slotted_pseudo_element_rules_;
}

bool HasCascadeLayers() const { return implicit_outer_layer_; }
bool HasCascadeLayers() const { return implicit_outer_layer_ != nullptr; }
const CascadeLayer& CascadeLayers() const {
DCHECK(implicit_outer_layer_);
return *implicit_outer_layer_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ StyleContainmentScopeTree::FindOrCreateEnclosingScopeForElement(
return scope;
}
// Return root scope if nothing found.
return root_scope_;
return root_scope_.Get();
}

void StyleContainmentScopeTree::DestroyScopeForElement(const Element& element) {
Expand All @@ -61,7 +61,7 @@ StyleContainmentScope* StyleContainmentScopeTree::CreateScopeForElement(
const Element& element) {
auto entry = scopes_.find(&element);
if (entry != scopes_.end()) {
return entry->value;
return entry->value.Get();
}
StyleContainmentScope* scope =
MakeGarbageCollected<StyleContainmentScope>(&element, this);
Expand Down Expand Up @@ -121,7 +121,7 @@ StyleContainmentScope* FindCommonAncestor(StyleContainmentScope* scope1,
--anc2;
}
int pos = anc1 == int(ancestors1.size()) - 1 ? anc1 : anc1 + 1;
return ancestors1[pos];
return ancestors1[pos].Get();
}

} // namespace
Expand Down
4 changes: 3 additions & 1 deletion third_party/blink/renderer/core/css/style_sheet_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ class CORE_EXPORT StyleSheetContents final
bool IsUsedFromTextCache() const { return is_used_from_text_cache_; }
void SetIsUsedFromTextCache() { is_used_from_text_cache_ = true; }

bool IsReferencedFromResource() const { return referenced_from_resource_; }
bool IsReferencedFromResource() const {
return referenced_from_resource_ != nullptr;
}
void SetReferencedFromResource(CSSStyleSheetResource*);
void ClearReferencedFromResource();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class CORE_EXPORT DisplayLockDocumentState final

void ForceLockIfNeeded(Element* new_locked_element);
DisplayLockUtilities::ScopedForcedUpdate::Impl* Chain() const {
return chain_;
return chain_.Get();
}

void Trace(Visitor* visitor) const {
Expand All @@ -170,7 +170,7 @@ class CORE_EXPORT DisplayLockDocumentState final

void ForceLockIfNeeded(Element* new_locked_element);
DisplayLockUtilities::ScopedForcedUpdate::Impl* Chain() const {
return chain_;
return chain_.Get();
}

void Trace(Visitor* visitor) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ChildListMutationAccumulator final
void ChildAdded(Node&);
void WillRemoveChild(Node&);

bool HasObservers() const { return observers_; }
bool HasObservers() const { return observers_ != nullptr; }

// Register and unregister mutation scopes that are using this mutation
// accumulator.
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/dom/container_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ struct DowncastTraits<ContainerNode> {
};

inline bool ContainerNode::HasChildCount(unsigned count) const {
Node* child = first_child_;
Node* child = first_child_.Get();
while (count && child) {
child = child->nextSibling();
--count;
Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/core/dom/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1603,11 +1603,11 @@ class CORE_EXPORT Document : public ContainerNode,
// https://github.com/WICG/webcomponents/blob/gh-pages/proposals/DOM-Parts.md.
DocumentPartRoot& getPartRoot();
DocumentPartRoot& EnsureDocumentPartRoot();
bool DOMPartsInUse() const { return document_part_root_; }
bool DOMPartsInUse() const { return document_part_root_ != nullptr; }

// A non-null template_document_host_ implies that |this| was created by
// EnsureTemplateDocument().
bool IsTemplateDocument() const { return template_document_host_; }
bool IsTemplateDocument() const { return template_document_host_ != nullptr; }
Document& EnsureTemplateDocument();
Document* TemplateDocumentHost() { return template_document_host_.Get(); }

Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/core/dom/node_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool NodeIterator::NodePointer::MoveToNext(Node* root) {
return true;
}
node = NodeTraversal::Next(*node, root);
return node;
return node != nullptr;
}

bool NodeIterator::NodePointer::MoveToPrevious(Node* root) {
Expand All @@ -60,7 +60,7 @@ bool NodeIterator::NodePointer::MoveToPrevious(Node* root) {
return true;
}
node = NodeTraversal::Previous(*node, root);
return node;
return node != nullptr;
}

NodeIterator::NodeIterator(Node* root_node,
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/dom/shadow_root.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CORE_EXPORT ShadowRoot final : public DocumentFragment,
return *slot_assignment_;
}

bool HasSlotAssignment() { return slot_assignment_; }
bool HasSlotAssignment() { return slot_assignment_ != nullptr; }

HTMLSlotElement* AssignedSlotFor(const Node&);
void DidAddSlot(HTMLSlotElement&);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TemplateContentDocumentFragment final : public DocumentFragment {
TemplateContentDocumentFragment(Document& document, Element* host)
: DocumentFragment(&document, kCreateDocumentFragment), host_(host) {}

Element* Host() const { return host_; }
Element* Host() const { return host_.Get(); }

void Trace(Visitor* visitor) const override {
visitor->Trace(host_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ InputEvent::InputType DeleteSelectionCommand::GetInputType() const {
// typing. The Bold typing style shouldn't stick around. Deletion should
// preserve a typing style that *it* sets, however.
bool DeleteSelectionCommand::PreservesTypingStyle() const {
return typing_style_;
return typing_style_ != nullptr;
}

void DeleteSelectionCommand::Trace(Visitor* visitor) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ class CORE_EXPORT FindTaskController final
bool aborted,
base::TimeTicks task_start_time);

Range* ResumeFindingFromRange() const { return resume_finding_from_range_; }
Range* ResumeFindingFromRange() const {
return resume_finding_from_range_.Get();
}
int CurrentMatchCount() const { return current_match_count_; }

// When invoked this will search for a given text and notify us
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ DocumentMarkerList* DocumentMarkerController::FindMarkers(
auto it = marker_map->find(key);
if (it != marker_map->end()) {
DCHECK(it->value);
return it->value;
return it->value.Get();
}
return nullptr;
}
Expand Down Expand Up @@ -648,7 +648,7 @@ DocumentMarkerGroup* DocumentMarkerController::GetMarkerGroupForMarker(
if (marker) {
auto it = marker_groups_.find(marker);
if (it != marker_groups_.end()) {
return it->value;
return it->value.Get();
}
}
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DocumentMarker* DocumentMarkerGroup::GetMarkerForText(
const Text* text) const {
for (const auto& marker_text : marker_text_map_) {
if (marker_text.value == text) {
return marker_text.key;
return marker_text.key.Get();
}
}
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/editing/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class PositionTemplate {
bool IsValidFor(const Document&) const;

bool IsNull() const { return !anchor_node_; }
bool IsNotNull() const { return anchor_node_; }
bool IsNotNull() const { return anchor_node_ != nullptr; }
bool IsOrphan() const { return anchor_node_ && !IsConnected(); }

// Note: Comparison of positions require both parameters are non-null. You
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ void SelectionEditor::CacheRangeOfDocument(Range* range) {
}

Range* SelectionEditor::DocumentCachedRange() const {
return cached_range_;
return cached_range_.Get();
}

void SelectionEditor::ClearDocumentCachedRange() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class CORE_EXPORT SpellCheckRequest final
~SpellCheckRequest();
void Dispose();

Range* CheckingRange() const { return checking_range_; }
Element* RootEditableElement() const { return root_editable_element_; }
Range* CheckingRange() const { return checking_range_.Get(); }
Element* RootEditableElement() const { return root_editable_element_.Get(); }

void SetCheckerAndSequence(SpellCheckRequester*, int sequence);
int Sequence() const { return sequence_; }
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/fetch/body.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class BodyConsumerBase : public GarbageCollected<BodyConsumerBase>,
BodyConsumerBase(const BodyConsumerBase&) = delete;
BodyConsumerBase& operator=(const BodyConsumerBase&) = delete;

ScriptPromiseResolver* Resolver() { return resolver_; }
ScriptPromiseResolver* Resolver() { return resolver_.Get(); }
void DidFetchDataLoadFailed() override {
ScriptState::Scope scope(Resolver()->GetScriptState());
resolver_->Reject(V8ThrowException::CreateTypeError(
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/fetch/fetch_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ class FetchLaterManager::DeferredLoader final
}
}

FetchLaterResult* fetch_later_result() { return fetch_later_result_; }
FetchLaterResult* fetch_later_result() { return fetch_later_result_.Get(); }

// FetchLoaderBase overrides:
void Dispose() override {
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/fetch/response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ String Response::statusText() const {

Headers* Response::headers() const {
// "The headers attribute's getter must return the associated Headers object."
return headers_;
return headers_.Get();
}

Response* Response::clone(ScriptState* script_state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ ContentSecurityPolicy::ContentSecurityPolicy()
mojom::blink::InsecureRequestPolicy::kLeaveInsecureRequestsAlone) {}

bool ContentSecurityPolicy::IsBound() {
return delegate_;
return delegate_ != nullptr;
}

void ContentSecurityPolicy::BindToDelegate(
Expand Down

0 comments on commit 47259a1

Please sign in to comment.