Commit e6b955fb authored by Hwanseung Lee's avatar Hwanseung Lee Committed by Commit Bot

Use Node& instead of Node* as a parameter

there are some functions which node object was passed as a parameter
at child_list_mutation_scope.h. and the object is never nullptr.
so it can be changed to reference instead of pointer.

Bug: 874385
Change-Id: I66f3840c688b50fe622712727e1c3fb0c90bae92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1604394Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Commit-Queue: Hwanseung Lee <hs1217.lee@samsung.com>
Cr-Commit-Position: refs/heads/master@{#658994}
parent b6220572
......@@ -84,45 +84,45 @@ ChildListMutationAccumulator* ChildListMutationAccumulator::GetOrCreate(
return accumulator;
}
inline bool ChildListMutationAccumulator::IsAddedNodeInOrder(Node* child) {
return IsEmpty() || (last_added_ == child->previousSibling() &&
next_sibling_ == child->nextSibling());
inline bool ChildListMutationAccumulator::IsAddedNodeInOrder(Node& child) {
return IsEmpty() || (last_added_ == child.previousSibling() &&
next_sibling_ == child.nextSibling());
}
void ChildListMutationAccumulator::ChildAdded(Node* child) {
void ChildListMutationAccumulator::ChildAdded(Node& child) {
DCHECK(HasObservers());
if (!IsAddedNodeInOrder(child))
EnqueueMutationRecord();
if (IsEmpty()) {
previous_sibling_ = child->previousSibling();
next_sibling_ = child->nextSibling();
previous_sibling_ = child.previousSibling();
next_sibling_ = child.nextSibling();
}
last_added_ = child;
added_nodes_.push_back(child);
last_added_ = &child;
added_nodes_.push_back(&child);
}
inline bool ChildListMutationAccumulator::IsRemovedNodeInOrder(Node* child) {
return IsEmpty() || next_sibling_ == child;
inline bool ChildListMutationAccumulator::IsRemovedNodeInOrder(Node& child) {
return IsEmpty() || next_sibling_ == &child;
}
void ChildListMutationAccumulator::WillRemoveChild(Node* child) {
void ChildListMutationAccumulator::WillRemoveChild(Node& child) {
DCHECK(HasObservers());
if (!added_nodes_.IsEmpty() || !IsRemovedNodeInOrder(child))
EnqueueMutationRecord();
if (IsEmpty()) {
previous_sibling_ = child->previousSibling();
next_sibling_ = child->nextSibling();
last_added_ = child->previousSibling();
previous_sibling_ = child.previousSibling();
next_sibling_ = child.nextSibling();
last_added_ = child.previousSibling();
} else {
next_sibling_ = child->nextSibling();
next_sibling_ = child.nextSibling();
}
removed_nodes_.push_back(child);
removed_nodes_.push_back(&child);
}
void ChildListMutationAccumulator::EnqueueMutationRecord() {
......
......@@ -56,8 +56,8 @@ class ChildListMutationAccumulator final
ChildListMutationAccumulator(Node*, MutationObserverInterestGroup*);
void ChildAdded(Node*);
void WillRemoveChild(Node*);
void ChildAdded(Node&);
void WillRemoveChild(Node&);
bool HasObservers() const { return observers_; }
......@@ -71,8 +71,8 @@ class ChildListMutationAccumulator final
private:
void EnqueueMutationRecord();
bool IsEmpty();
bool IsAddedNodeInOrder(Node*);
bool IsRemovedNodeInOrder(Node*);
bool IsAddedNodeInOrder(Node&);
bool IsRemovedNodeInOrder(Node&);
Member<Node> target_;
......@@ -110,12 +110,12 @@ class ChildListMutationScope final {
void ChildAdded(Node& child) {
if (accumulator_ && accumulator_->HasObservers())
accumulator_->ChildAdded(&child);
accumulator_->ChildAdded(child);
}
void WillRemoveChild(Node& child) {
if (accumulator_ && accumulator_->HasObservers())
accumulator_->WillRemoveChild(&child);
accumulator_->WillRemoveChild(child);
}
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment