Commit 171f3b5c authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make TextIteratorTextState::EmitText() to take const Text&

This patch changes |TextIteratorTextState::EmitText()| to take |const Text&|
since it doesn't take |nullptr| and all call sites passed non-null |Text| node
for improving code health.

Change-Id: I6ef1fb5d5dc85f0e4edc16be3d27913ac73648d4
Reviewed-on: https://chromium-review.googlesource.com/1025452Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553425}
parent 12278932
...@@ -241,8 +241,9 @@ bool SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::HandleTextNode() { ...@@ -241,8 +241,9 @@ bool SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::HandleTextNode() {
const int text_length = position_end_offset - position_start_offset; const int text_length = position_end_offset - position_start_offset;
const int text_offset = position_start_offset - offset_in_node; const int text_offset = position_start_offset - offset_in_node;
CHECK_LE(static_cast<unsigned>(text_offset + text_length), text.length()); CHECK_LE(static_cast<unsigned>(text_offset + text_length), text.length());
text_state_.EmitText(node_, position_start_offset, position_end_offset, text, text_state_.EmitText(ToText(*node_), position_start_offset,
text_offset, text_offset + text_length); position_end_offset, text, text_offset,
text_offset + text_length);
return !should_handle_first_letter_; return !should_handle_first_letter_;
} }
......
...@@ -125,7 +125,7 @@ void TextIteratorTextNodeHandler::HandleTextNodeWithLayoutNG() { ...@@ -125,7 +125,7 @@ void TextIteratorTextNodeHandler::HandleTextNodeWithLayoutNG() {
const String& string = string_and_offsets.string; const String& string = string_and_offsets.string;
const unsigned text_content_start = string_and_offsets.start; const unsigned text_content_start = string_and_offsets.start;
const unsigned text_content_end = string_and_offsets.end; const unsigned text_content_end = string_and_offsets.end;
text_state_.EmitText(text_node_, run_start, run_end, string, text_state_.EmitText(*text_node_, run_start, run_end, string,
text_content_start, text_content_end); text_content_start, text_content_end);
offset_ = run_end; offset_ = run_end;
return; return;
...@@ -568,7 +568,7 @@ void TextIteratorTextNodeHandler::EmitText(const LayoutText* layout_object, ...@@ -568,7 +568,7 @@ void TextIteratorTextNodeHandler::EmitText(const LayoutText* layout_object,
: layout_object->GetText(); : layout_object->GetText();
if (behavior_.EmitsSpaceForNbsp()) if (behavior_.EmitsSpaceForNbsp())
string.Replace(kNoBreakSpaceCharacter, kSpaceCharacter); string.Replace(kNoBreakSpaceCharacter, kSpaceCharacter);
text_state_.EmitText(text_node_, text_state_.EmitText(*text_node_,
text_start_offset + layout_object->TextStartOffset(), text_start_offset + layout_object->TextStartOffset(),
text_end_offset + layout_object->TextStartOffset(), text_end_offset + layout_object->TextStartOffset(),
string, text_start_offset, text_end_offset); string, text_start_offset, text_end_offset);
......
...@@ -149,15 +149,18 @@ void TextIteratorTextState::SpliceBuffer(UChar c, ...@@ -149,15 +149,18 @@ void TextIteratorTextState::SpliceBuffer(UChar c,
last_character_ = c; last_character_ = c;
} }
void TextIteratorTextState::EmitText(const Node* text_node, void TextIteratorTextState::EmitText(const Text& text_node,
unsigned position_start_offset, unsigned position_start_offset,
unsigned position_end_offset, unsigned position_end_offset,
const String& string, const String& string,
unsigned text_start_offset, unsigned text_start_offset,
unsigned text_end_offset) { unsigned text_end_offset) {
DCHECK(text_node); DCHECK_LE(position_start_offset, position_end_offset);
// TODO(editing-dev): text-transform:uppercase can make text longer, e.g.
// "U+00DF" to "SS". See "fast/css/case-transform.html"
// DCHECK_LE(position_end_offset, text_node.length());
text_ = text_ =
behavior_.EmitsSmallXForTextSecurity() && IsTextSecurityNode(*text_node) behavior_.EmitsSmallXForTextSecurity() && IsTextSecurityNode(text_node)
? RepeatString("x", string.length()) ? RepeatString("x", string.length())
: string, : string,
...@@ -166,7 +169,7 @@ void TextIteratorTextState::EmitText(const Node* text_node, ...@@ -166,7 +169,7 @@ void TextIteratorTextState::EmitText(const Node* text_node,
DCHECK_LE(text_end_offset, text_.length()); DCHECK_LE(text_end_offset, text_.length());
DCHECK_LE(text_start_offset, text_end_offset); DCHECK_LE(text_start_offset, text_end_offset);
position_node_ = text_node; position_node_ = &text_node;
position_offset_base_node_ = nullptr; position_offset_base_node_ = nullptr;
position_start_offset_ = position_start_offset; position_start_offset_ = position_start_offset;
position_end_offset_ = position_end_offset; position_end_offset_ = position_end_offset;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
namespace blink { namespace blink {
class BackwardsTextBuffer; class BackwardsTextBuffer;
class Text;
class CORE_EXPORT TextIteratorTextState { class CORE_EXPORT TextIteratorTextState {
STACK_ALLOCATED(); STACK_ALLOCATED();
...@@ -61,7 +62,7 @@ class CORE_EXPORT TextIteratorTextState { ...@@ -61,7 +62,7 @@ class CORE_EXPORT TextIteratorTextState {
const Node* offset_base_node, const Node* offset_base_node,
unsigned text_start_offset, unsigned text_start_offset,
unsigned text_end_offset); unsigned text_end_offset);
void EmitText(const Node*, void EmitText(const Text&,
unsigned position_start_offset, unsigned position_start_offset,
unsigned position_end_offset, unsigned position_end_offset,
const String&, const String&,
......
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