Commit e511667b authored by Hayato Ito's avatar Hayato Ito Committed by Commit Bot

Make TreeScope::Retarget() return a reference

The return value is always non-null there.

Change-Id: I114d563d10736cfb4cefdf0b40ec44d645ebeed4
Reviewed-on: https://chromium-review.googlesource.com/c/1496269
Auto-Submit: Hayato Ito <hayato@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Hayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636744}
parent d84ac2de
...@@ -3375,7 +3375,7 @@ void Element::ActivateDisplayLockIfNeeded() { ...@@ -3375,7 +3375,7 @@ void Element::ActivateDisplayLockIfNeeded() {
if (!context->IsActivatable()) if (!context->IsActivatable())
return; return;
activatable_targets.push_back(std::make_pair( activatable_targets.push_back(std::make_pair(
&ToElement(ancestor), ancestor.GetTreeScope().Retarget(*this))); &ToElement(ancestor), &ancestor.GetTreeScope().Retarget(*this)));
} }
} }
......
...@@ -268,7 +268,7 @@ Element* TreeScope::HitTestPointInternal(Node* node, ...@@ -268,7 +268,7 @@ Element* TreeScope::HitTestPointInternal(Node* node,
if (!element) if (!element)
return nullptr; return nullptr;
if (type == HitTestPointType::kWebExposed) if (type == HitTestPointType::kWebExposed)
return Retarget(*element); return &Retarget(*element);
return element; return element;
} }
...@@ -425,10 +425,10 @@ void TreeScope::AdoptIfNeeded(Node& node) { ...@@ -425,10 +425,10 @@ void TreeScope::AdoptIfNeeded(Node& node) {
// This retargets |target| against the root of |this|. // This retargets |target| against the root of |this|.
// The steps are different with the spec for performance reasons, // The steps are different with the spec for performance reasons,
// but the results should be the same. // but the results should be the same.
Element* TreeScope::Retarget(const Element& target) const { Element& TreeScope::Retarget(const Element& target) const {
const TreeScope& target_scope = target.GetTreeScope(); const TreeScope& target_scope = target.GetTreeScope();
if (!target_scope.RootNode().IsShadowRoot()) if (!target_scope.RootNode().IsShadowRoot())
return const_cast<Element*>(&target); return const_cast<Element&>(target);
HeapVector<Member<const TreeScope>> target_ancestor_scopes; HeapVector<Member<const TreeScope>> target_ancestor_scopes;
HeapVector<Member<const TreeScope>> context_ancestor_scopes; HeapVector<Member<const TreeScope>> context_ancestor_scopes;
...@@ -449,10 +449,10 @@ Element* TreeScope::Retarget(const Element& target) const { ...@@ -449,10 +449,10 @@ Element* TreeScope::Retarget(const Element& target) const {
} }
if (target_ancestor_riterator == target_ancestor_scopes.rend()) if (target_ancestor_riterator == target_ancestor_scopes.rend())
return const_cast<Element*>(&target); return const_cast<Element&>(target);
Node& first_different_scope_root = Node& first_different_scope_root =
(*target_ancestor_riterator).Get()->RootNode(); (*target_ancestor_riterator).Get()->RootNode();
return &To<ShadowRoot>(first_different_scope_root).host(); return To<ShadowRoot>(first_different_scope_root).host();
} }
Element* TreeScope::AdjustedFocusedElementInternal( Element* TreeScope::AdjustedFocusedElementInternal(
......
...@@ -99,7 +99,7 @@ class CORE_EXPORT TreeScope : public GarbageCollectedMixin { ...@@ -99,7 +99,7 @@ class CORE_EXPORT TreeScope : public GarbageCollectedMixin {
DOMSelection* GetSelection() const; DOMSelection* GetSelection() const;
Element* Retarget(const Element& target) const; Element& Retarget(const Element& target) const;
Element* AdjustedFocusedElementInternal(const Element& target) const; Element* AdjustedFocusedElementInternal(const Element& target) const;
......
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