Commit ce6ace7f authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make TextIterator::CurrentContainer() to return const Node&

This patch changes |TextIterator::CurrentContainer()| to return |const Node&|
instead of |const Node*| since it always non-null for improving code health.

Change-Id: Idb0a827d78afe7a8b27e398db7023527a2f2380a
Reviewed-on: https://chromium-review.googlesource.com/1050053
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557144}
parent 99e7ef1f
......@@ -64,7 +64,7 @@ const Document& CharacterIteratorAlgorithm<Strategy>::OwnerDocument() const {
template <typename Strategy>
const Node* CharacterIteratorAlgorithm<Strategy>::CurrentContainer() const {
return text_iterator_.CurrentContainer();
return &text_iterator_.CurrentContainer();
}
template <typename Strategy>
......@@ -104,9 +104,9 @@ PositionTemplate<Strategy> CharacterIteratorAlgorithm<Strategy>::StartPosition()
const {
if (!text_iterator_.AtEnd()) {
if (text_iterator_.length() > 1) {
const Node* n = text_iterator_.CurrentContainer();
const Node& node = text_iterator_.CurrentContainer();
int offset = text_iterator_.StartOffsetInCurrentContainer() + run_offset_;
return PositionTemplate<Strategy>::EditingPositionOf(n, offset);
return PositionTemplate<Strategy>::EditingPositionOf(&node, offset);
}
DCHECK(!run_offset_);
}
......@@ -118,9 +118,9 @@ PositionTemplate<Strategy> CharacterIteratorAlgorithm<Strategy>::EndPosition()
const {
if (!text_iterator_.AtEnd()) {
if (text_iterator_.length() > 1) {
const Node* n = text_iterator_.CurrentContainer();
const Node& node = text_iterator_.CurrentContainer();
int offset = text_iterator_.StartOffsetInCurrentContainer() + run_offset_;
return PositionTemplate<Strategy>::EditingPositionOf(n, offset + 1);
return PositionTemplate<Strategy>::EditingPositionOf(&node, offset + 1);
}
DCHECK(!run_offset_);
}
......
......@@ -844,10 +844,10 @@ const Document& TextIteratorAlgorithm<Strategy>::OwnerDocument() const {
template <typename Strategy>
const Node* TextIteratorAlgorithm<Strategy>::GetNode() const {
const Node* node = CurrentContainer();
if (node->IsCharacterDataNode())
return node;
return Strategy::ChildAt(*node, StartOffsetInCurrentContainer());
const Node& node = CurrentContainer();
if (node.IsCharacterDataNode())
return &node;
return Strategy::ChildAt(node, StartOffsetInCurrentContainer());
}
template <typename Strategy>
......@@ -867,11 +867,11 @@ int TextIteratorAlgorithm<Strategy>::EndOffsetInCurrentContainer() const {
}
template <typename Strategy>
const Node* TextIteratorAlgorithm<Strategy>::CurrentContainer() const {
const Node& TextIteratorAlgorithm<Strategy>::CurrentContainer() const {
if (!text_state_.PositionNode())
return end_container_;
return *end_container_;
EnsurePositionContainer();
return text_state_.PositionContainerNode();
return *text_state_.PositionContainerNode();
}
template <typename Strategy>
......@@ -947,14 +947,14 @@ template <typename Strategy>
PositionTemplate<Strategy>
TextIteratorAlgorithm<Strategy>::StartPositionInCurrentContainer() const {
return PositionTemplate<Strategy>::EditingPositionOf(
CurrentContainer(), StartOffsetInCurrentContainer());
&CurrentContainer(), StartOffsetInCurrentContainer());
}
template <typename Strategy>
PositionTemplate<Strategy>
TextIteratorAlgorithm<Strategy>::EndPositionInCurrentContainer() const {
return PositionTemplate<Strategy>::EditingPositionOf(
CurrentContainer(), EndOffsetInCurrentContainer());
&CurrentContainer(), EndOffsetInCurrentContainer());
}
template <typename Strategy>
......
......@@ -75,7 +75,7 @@ class CORE_TEMPLATE_CLASS_EXPORT TextIteratorAlgorithm {
const Node* GetNode() const;
const Document& OwnerDocument() const;
const Node* CurrentContainer() const;
const Node& CurrentContainer() const;
int StartOffsetInCurrentContainer() const;
int EndOffsetInCurrentContainer() const;
PositionTemplate<Strategy> StartPositionInCurrentContainer() const;
......
......@@ -232,7 +232,7 @@ void DocumentMarkerController::RemoveMarkers(
int start_offset = marked_text.StartOffsetInCurrentContainer();
int end_offset = marked_text.EndOffsetInCurrentContainer();
RemoveMarkersInternal(marked_text.CurrentContainer(), start_offset,
RemoveMarkersInternal(&marked_text.CurrentContainer(), start_offset,
end_offset - start_offset, marker_types);
}
}
......@@ -267,13 +267,13 @@ void DocumentMarkerController::AddMarkerInternal(
// Ignore text emitted by TextIterator for non-text nodes (e.g. implicit
// newlines)
const Node* const node = marked_text.CurrentContainer();
if (!node->IsTextNode())
const Node& node = marked_text.CurrentContainer();
if (!node.IsTextNode())
continue;
DocumentMarker* const new_marker = create_marker_from_offsets(
start_offset_in_current_container, end_offset_in_current_container);
AddMarkerToNode(node, new_marker);
AddMarkerToNode(&node, new_marker);
}
}
......
......@@ -87,8 +87,8 @@ NSAttributedString* AttributedSubstringFromRange(const EphemeralRange& range,
if (!num_characters)
continue;
const Node* container = it.CurrentContainer();
LayoutObject* layout_object = container->GetLayoutObject();
const Node& container = it.CurrentContainer();
LayoutObject* layout_object = container.GetLayoutObject();
DCHECK(layout_object);
if (!layout_object)
continue;
......
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