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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutText.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 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 return first_text_box_ ? first_text_box_->Y().ToFloat() : 0; 1552 return first_text_box_ ? first_text_box_->Y().ToFloat() : 0;
1553 } 1553 }
1554 1554
1555 void LayoutText::SetSelectionState(SelectionState state) { 1555 void LayoutText::SetSelectionState(SelectionState state) {
1556 LayoutObject::SetSelectionState(state); 1556 LayoutObject::SetSelectionState(state);
1557 1557
1558 if (CanUpdateSelectionOnRootLineBoxes()) { 1558 if (CanUpdateSelectionOnRootLineBoxes()) {
1559 if (state == SelectionStart || state == SelectionEnd || 1559 if (state == SelectionStart || state == SelectionEnd ||
1560 state == SelectionBoth) { 1560 state == SelectionBoth) {
1561 int start_pos, end_pos; 1561 int start_pos, end_pos;
1562 SelectionStartEnd(start_pos, end_pos); 1562 std::tie(start_pos, end_pos) = SelectionStartEnd();
1563 if (GetSelectionState() == SelectionStart) { 1563 if (GetSelectionState() == SelectionStart) {
1564 end_pos = TextLength(); 1564 end_pos = TextLength();
1565 1565
1566 // to handle selection from end of text to end of line 1566 // to handle selection from end of text to end of line
1567 if (start_pos && start_pos == end_pos) 1567 if (start_pos && start_pos == end_pos)
1568 start_pos = end_pos - 1; 1568 start_pos = end_pos - 1;
1569 } else if (GetSelectionState() == SelectionEnd) { 1569 } else if (GetSelectionState() == SelectionEnd) {
1570 start_pos = 0; 1570 start_pos = 0;
1571 } 1571 }
1572 1572
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 return LayoutRect(); 2018 return LayoutRect();
2019 2019
2020 // Now calculate startPos and endPos for painting selection. 2020 // Now calculate startPos and endPos for painting selection.
2021 // We include a selection while endPos > 0 2021 // We include a selection while endPos > 0
2022 int start_pos, end_pos; 2022 int start_pos, end_pos;
2023 if (GetSelectionState() == SelectionInside) { 2023 if (GetSelectionState() == SelectionInside) {
2024 // We are fully selected. 2024 // We are fully selected.
2025 start_pos = 0; 2025 start_pos = 0;
2026 end_pos = TextLength(); 2026 end_pos = TextLength();
2027 } else { 2027 } else {
2028 SelectionStartEnd(start_pos, end_pos); 2028 std::tie(start_pos, end_pos) = SelectionStartEnd();
2029 if (GetSelectionState() == SelectionStart) 2029 if (GetSelectionState() == SelectionStart)
2030 end_pos = TextLength(); 2030 end_pos = TextLength();
2031 else if (GetSelectionState() == SelectionEnd) 2031 else if (GetSelectionState() == SelectionEnd)
2032 start_pos = 0; 2032 start_pos = 0;
2033 } 2033 }
2034 2034
2035 LayoutRect rect; 2035 LayoutRect rect;
2036 2036
2037 if (start_pos == end_pos) 2037 if (start_pos == end_pos)
2038 return rect; 2038 return rect;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 LayoutRect rect = LayoutRect( 2130 LayoutRect rect = LayoutRect(
2131 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); 2131 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height()));
2132 LayoutBlock* block = ContainingBlock(); 2132 LayoutBlock* block = ContainingBlock();
2133 if (block && HasTextBoxes()) 2133 if (block && HasTextBoxes())
2134 block->AdjustChildDebugRect(rect); 2134 block->AdjustChildDebugRect(rect);
2135 2135
2136 return rect; 2136 return rect;
2137 } 2137 }
2138 2138
2139 } // namespace blink 2139 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.cpp ('k') | third_party/WebKit/Source/core/layout/api/LineLayoutText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698