| OLD | NEW |
| 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 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 float LayoutText::FirstRunY() const { | 1439 float LayoutText::FirstRunY() const { |
| 1440 return first_text_box_ ? first_text_box_->Y().ToFloat() : 0; | 1440 return first_text_box_ ? first_text_box_->Y().ToFloat() : 0; |
| 1441 } | 1441 } |
| 1442 | 1442 |
| 1443 void LayoutText::SetSelectionState(SelectionState state) { | 1443 void LayoutText::SetSelectionState(SelectionState state) { |
| 1444 LayoutObject::SetSelectionState(state); | 1444 LayoutObject::SetSelectionState(state); |
| 1445 | 1445 |
| 1446 if (CanUpdateSelectionOnRootLineBoxes()) { | 1446 if (CanUpdateSelectionOnRootLineBoxes()) { |
| 1447 if (state == SelectionStart || state == SelectionEnd || | 1447 if (state == SelectionState::kStart || state == SelectionState::kEnd || |
| 1448 state == SelectionBoth) { | 1448 state == SelectionState::kStartAndEnd) { |
| 1449 int start_pos, end_pos; | 1449 int start_pos, end_pos; |
| 1450 std::tie(start_pos, end_pos) = SelectionStartEnd(); | 1450 std::tie(start_pos, end_pos) = SelectionStartEnd(); |
| 1451 if (GetSelectionState() == SelectionStart) { | 1451 if (GetSelectionState() == SelectionState::kStart) { |
| 1452 end_pos = TextLength(); | 1452 end_pos = TextLength(); |
| 1453 | 1453 |
| 1454 // to handle selection from end of text to end of line | 1454 // to handle selection from end of text to end of line |
| 1455 if (start_pos && start_pos == end_pos) | 1455 if (start_pos && start_pos == end_pos) |
| 1456 start_pos = end_pos - 1; | 1456 start_pos = end_pos - 1; |
| 1457 } else if (GetSelectionState() == SelectionEnd) { | 1457 } else if (GetSelectionState() == SelectionState::kEnd) { |
| 1458 start_pos = 0; | 1458 start_pos = 0; |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { | 1461 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { |
| 1462 if (box->IsSelected(start_pos, end_pos)) { | 1462 if (box->IsSelected(start_pos, end_pos)) { |
| 1463 box->Root().SetHasSelectedChildren(true); | 1463 box->Root().SetHasSelectedChildren(true); |
| 1464 } | 1464 } |
| 1465 } | 1465 } |
| 1466 } else { | 1466 } else { |
| 1467 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { | 1467 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { |
| 1468 box->Root().SetHasSelectedChildren(state == SelectionInside); | 1468 box->Root().SetHasSelectedChildren(state == SelectionState::kInside); |
| 1469 } | 1469 } |
| 1470 } | 1470 } |
| 1471 } | 1471 } |
| 1472 | 1472 |
| 1473 // The containing block can be null in case of an orphaned tree. | 1473 // The containing block can be null in case of an orphaned tree. |
| 1474 LayoutBlock* containing_block = this->ContainingBlock(); | 1474 LayoutBlock* containing_block = this->ContainingBlock(); |
| 1475 if (containing_block && !containing_block->IsLayoutView()) | 1475 if (containing_block && !containing_block->IsLayoutView()) |
| 1476 containing_block->SetSelectionState(state); | 1476 containing_block->SetSelectionState(state); |
| 1477 } | 1477 } |
| 1478 | 1478 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 LayoutRect LayoutText::LocalVisualRect() const { | 1892 LayoutRect LayoutText::LocalVisualRect() const { |
| 1893 if (Style()->Visibility() != EVisibility::kVisible) | 1893 if (Style()->Visibility() != EVisibility::kVisible) |
| 1894 return LayoutRect(); | 1894 return LayoutRect(); |
| 1895 | 1895 |
| 1896 return UnionRect(VisualOverflowRect(), LocalSelectionRect()); | 1896 return UnionRect(VisualOverflowRect(), LocalSelectionRect()); |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 LayoutRect LayoutText::LocalSelectionRect() const { | 1899 LayoutRect LayoutText::LocalSelectionRect() const { |
| 1900 DCHECK(!NeedsLayout()); | 1900 DCHECK(!NeedsLayout()); |
| 1901 | 1901 |
| 1902 if (GetSelectionState() == SelectionNone) | 1902 if (GetSelectionState() == SelectionState::kNone) |
| 1903 return LayoutRect(); | 1903 return LayoutRect(); |
| 1904 LayoutBlock* cb = ContainingBlock(); | 1904 LayoutBlock* cb = ContainingBlock(); |
| 1905 if (!cb) | 1905 if (!cb) |
| 1906 return LayoutRect(); | 1906 return LayoutRect(); |
| 1907 | 1907 |
| 1908 // Now calculate startPos and endPos for painting selection. | 1908 // Now calculate startPos and endPos for painting selection. |
| 1909 // We include a selection while endPos > 0 | 1909 // We include a selection while endPos > 0 |
| 1910 int start_pos, end_pos; | 1910 int start_pos, end_pos; |
| 1911 if (GetSelectionState() == SelectionInside) { | 1911 if (GetSelectionState() == SelectionState::kInside) { |
| 1912 // We are fully selected. | 1912 // We are fully selected. |
| 1913 start_pos = 0; | 1913 start_pos = 0; |
| 1914 end_pos = TextLength(); | 1914 end_pos = TextLength(); |
| 1915 } else { | 1915 } else { |
| 1916 std::tie(start_pos, end_pos) = SelectionStartEnd(); | 1916 std::tie(start_pos, end_pos) = SelectionStartEnd(); |
| 1917 if (GetSelectionState() == SelectionStart) | 1917 if (GetSelectionState() == SelectionState::kStart) |
| 1918 end_pos = TextLength(); | 1918 end_pos = TextLength(); |
| 1919 else if (GetSelectionState() == SelectionEnd) | 1919 else if (GetSelectionState() == SelectionState::kEnd) |
| 1920 start_pos = 0; | 1920 start_pos = 0; |
| 1921 } | 1921 } |
| 1922 | 1922 |
| 1923 LayoutRect rect; | 1923 LayoutRect rect; |
| 1924 | 1924 |
| 1925 if (start_pos == end_pos) | 1925 if (start_pos == end_pos) |
| 1926 return rect; | 1926 return rect; |
| 1927 | 1927 |
| 1928 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { | 1928 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { |
| 1929 rect.Unite(box->LocalSelectionRect(start_pos, end_pos)); | 1929 rect.Unite(box->LocalSelectionRect(start_pos, end_pos)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 LayoutRect rect = LayoutRect( | 2001 LayoutRect rect = LayoutRect( |
| 2002 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); | 2002 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); |
| 2003 LayoutBlock* block = ContainingBlock(); | 2003 LayoutBlock* block = ContainingBlock(); |
| 2004 if (block && HasTextBoxes()) | 2004 if (block && HasTextBoxes()) |
| 2005 block->AdjustChildDebugRect(rect); | 2005 block->AdjustChildDebugRect(rect); |
| 2006 | 2006 |
| 2007 return rect; | 2007 return rect; |
| 2008 } | 2008 } |
| 2009 | 2009 |
| 2010 } // namespace blink | 2010 } // namespace blink |
| OLD | NEW |