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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2938373002: Introduce CanNotContinueOnNextLine() for DoesContinueOnNextLine() (Closed)
Patch Set: 2017-06-16T16:18:00 Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 } 1426 }
1427 1427
1428 if (CanBeBackwardCaretPosition(text_layout_object, 1428 if (CanBeBackwardCaretPosition(text_layout_object,
1429 current_pos.OffsetInLeafNode())) { 1429 current_pos.OffsetInLeafNode())) {
1430 return current_pos.ComputePosition(); 1430 return current_pos.ComputePosition();
1431 } 1431 }
1432 } 1432 }
1433 return last_visible.DeprecatedComputePosition(); 1433 return last_visible.DeprecatedComputePosition();
1434 } 1434 }
1435 1435
1436 // Returns true if |box| at |text_offset| can not continue on next line.
1437 static bool CanNotContinueOnNextLine(const LayoutText& text_layout_object,
1438 InlineBox* box,
1439 unsigned text_offset) {
1440 InlineTextBox* const last_text_box = text_layout_object.LastTextBox();
1441 if (box == last_text_box)
1442 return true;
1443 return LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()) ==
1444 text_layout_object &&
1445 ToInlineTextBox(box)->Start() >= text_offset;
1446 }
1447
1436 // The text continues on the next line only if the last text box is not on this 1448 // The text continues on the next line only if the last text box is not on this
1437 // line and none of the boxes on this line have a larger start offset. 1449 // line and none of the boxes on this line have a larger start offset.
1438 static bool DoesContinueOnNextLine(const LayoutText& text_layout_object, 1450 static bool DoesContinueOnNextLine(const LayoutText& text_layout_object,
1439 InlineBox* box, 1451 InlineBox* box,
1440 unsigned text_offset) { 1452 unsigned text_offset) {
1441 InlineTextBox* const last_text_box = text_layout_object.LastTextBox(); 1453 InlineTextBox* const last_text_box = text_layout_object.LastTextBox();
1442 DCHECK_NE(box, last_text_box); 1454 DCHECK_NE(box, last_text_box);
1443 for (InlineBox* runner = box->NextLeafChild(); runner; 1455 for (InlineBox* runner = box->NextLeafChild(); runner;
1444 runner = runner->NextLeafChild()) { 1456 runner = runner->NextLeafChild()) {
1445 if (runner == last_text_box) 1457 if (CanNotContinueOnNextLine(text_layout_object, runner, text_offset))
1446 return false;
1447 if (LineLayoutAPIShim::LayoutObjectFrom(runner->GetLineLayoutItem()) ==
1448 text_layout_object &&
1449 ToInlineTextBox(runner)->Start() >= text_offset)
1450 return false; 1458 return false;
1451 } 1459 }
1452 1460
1453 for (InlineBox* runner = box->PrevLeafChild(); runner; 1461 for (InlineBox* runner = box->PrevLeafChild(); runner;
1454 runner = runner->PrevLeafChild()) { 1462 runner = runner->PrevLeafChild()) {
1455 if (runner == last_text_box) 1463 if (CanNotContinueOnNextLine(text_layout_object, runner, text_offset))
1456 return false;
1457 if (LineLayoutAPIShim::LayoutObjectFrom(runner->GetLineLayoutItem()) ==
1458 text_layout_object &&
1459 ToInlineTextBox(runner)->Start() >= text_offset)
1460 return false; 1464 return false;
1461 } 1465 }
1462 1466
1463 return true; 1467 return true;
1464 } 1468 }
1465 1469
1466 // TODO(editing-dev): This function is just moved out from 1470 // TODO(editing-dev): This function is just moved out from
1467 // |MostBackwardCaretPosition()|. We should study this function more and 1471 // |MostBackwardCaretPosition()|. We should study this function more and
1468 // name it appropriately. See https://trac.webkit.org/changeset/32438/ 1472 // name it appropriately. See https://trac.webkit.org/changeset/32438/
1469 // which introduce this. 1473 // which introduce this.
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 2085
2082 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { 2086 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) {
2083 return EnclosingIntRect(ComputeTextRectTemplate(range)); 2087 return EnclosingIntRect(ComputeTextRectTemplate(range));
2084 } 2088 }
2085 2089
2086 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { 2090 FloatRect ComputeTextFloatRect(const EphemeralRange& range) {
2087 return ComputeTextRectTemplate(range); 2091 return ComputeTextRectTemplate(range);
2088 } 2092 }
2089 2093
2090 } // namespace blink 2094 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698