Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp

Issue 2833343002: Change SelectionStartEnd() returning values instead of assigning into ref args. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // See the corresponding code in InlineTextBox::getSelectionState. 131 // See the corresponding code in InlineTextBox::getSelectionState.
132 int e_pos = std::min(end_pos - start_, int(len_) + (IsLineBreak() ? 0 : 1)); 132 int e_pos = std::min(end_pos - start_, int(len_) + (IsLineBreak() ? 0 : 1));
133 return (s_pos < e_pos); 133 return (s_pos < e_pos);
134 } 134 }
135 135
136 SelectionState InlineTextBox::GetSelectionState() const { 136 SelectionState InlineTextBox::GetSelectionState() const {
137 SelectionState state = GetLineLayoutItem().GetSelectionState(); 137 SelectionState state = GetLineLayoutItem().GetSelectionState();
138 if (state == SelectionStart || state == SelectionEnd || 138 if (state == SelectionStart || state == SelectionEnd ||
139 state == SelectionBoth) { 139 state == SelectionBoth) {
140 int start_pos, end_pos; 140 int start_pos, end_pos;
141 GetLineLayoutItem().SelectionStartEnd(start_pos, end_pos); 141 std::tie(start_pos, end_pos) = GetLineLayoutItem().SelectionStartEnd();
142 // The position after a hard line break is considered to be past its end. 142 // The position after a hard line break is considered to be past its end.
143 // See the corresponding code in InlineTextBox::isSelected. 143 // See the corresponding code in InlineTextBox::isSelected.
144 int last_selectable = Start() + Len() - (IsLineBreak() ? 1 : 0); 144 int last_selectable = Start() + Len() - (IsLineBreak() ? 1 : 0);
145 145
146 // FIXME: Remove -webkit-line-break: LineBreakAfterWhiteSpace. 146 // FIXME: Remove -webkit-line-break: LineBreakAfterWhiteSpace.
147 int end_of_line_adjustment_for_css_line_break = 147 int end_of_line_adjustment_for_css_line_break =
148 GetLineLayoutItem().Style()->GetLineBreak() == kLineBreakAfterWhiteSpace 148 GetLineLayoutItem().Style()->GetLineBreak() == kLineBreakAfterWhiteSpace
149 ? -1 149 ? -1
150 : 0; 150 : 0;
151 bool start = (state != SelectionEnd && start_pos >= start_ && 151 bool start = (state != SelectionEnd && start_pos >= start_ &&
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 LayoutUnit /*lineBottom*/) const { 495 LayoutUnit /*lineBottom*/) const {
496 InlineTextBoxPainter(*this).Paint(paint_info, paint_offset); 496 InlineTextBoxPainter(*this).Paint(paint_info, paint_offset);
497 } 497 }
498 498
499 void InlineTextBox::SelectionStartEnd(int& s_pos, int& e_pos) const { 499 void InlineTextBox::SelectionStartEnd(int& s_pos, int& e_pos) const {
500 int start_pos, end_pos; 500 int start_pos, end_pos;
501 if (GetLineLayoutItem().GetSelectionState() == SelectionInside) { 501 if (GetLineLayoutItem().GetSelectionState() == SelectionInside) {
502 start_pos = 0; 502 start_pos = 0;
503 end_pos = GetLineLayoutItem().TextLength(); 503 end_pos = GetLineLayoutItem().TextLength();
504 } else { 504 } else {
505 GetLineLayoutItem().SelectionStartEnd(start_pos, end_pos); 505 std::tie(start_pos, end_pos) = GetLineLayoutItem().SelectionStartEnd();
506 if (GetLineLayoutItem().GetSelectionState() == SelectionStart) 506 if (GetLineLayoutItem().GetSelectionState() == SelectionStart)
507 end_pos = GetLineLayoutItem().TextLength(); 507 end_pos = GetLineLayoutItem().TextLength();
508 else if (GetLineLayoutItem().GetSelectionState() == SelectionEnd) 508 else if (GetLineLayoutItem().GetSelectionState() == SelectionEnd)
509 start_pos = 0; 509 start_pos = 0;
510 } 510 }
511 511
512 s_pos = std::max(start_pos - start_, 0); 512 s_pos = std::max(start_pos - start_, 0);
513 e_pos = std::min(end_pos - start_, (int)len_); 513 e_pos = std::min(end_pos - start_, (int)len_);
514 } 514 }
515 515
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 for (; printed_characters < kLayoutObjectCharacterOffset; 722 for (; printed_characters < kLayoutObjectCharacterOffset;
723 printed_characters++) 723 printed_characters++)
724 fputc(' ', stderr); 724 fputc(' ', stderr);
725 fprintf(stderr, "(%d,%d) \"%s\"\n", Start(), Start() + Len(), 725 fprintf(stderr, "(%d,%d) \"%s\"\n", Start(), Start() + Len(),
726 value.Utf8().data()); 726 value.Utf8().data());
727 } 727 }
728 728
729 #endif 729 #endif
730 730
731 } // namespace blink 731 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/api/LineLayoutText.h ('k') | third_party/WebKit/Source/core/page/TouchAdjustment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698