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

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

Issue 2940293002: Introduce HasVisibleFirstLetter() for CanBeBackwardCaretPosition() (Closed)
Patch Set: 2017-06-16T15:29:55 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 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 return false; 1456 return false;
1457 if (LineLayoutAPIShim::LayoutObjectFrom(runner->GetLineLayoutItem()) == 1457 if (LineLayoutAPIShim::LayoutObjectFrom(runner->GetLineLayoutItem()) ==
1458 text_layout_object && 1458 text_layout_object &&
1459 ToInlineTextBox(runner)->Start() >= text_offset) 1459 ToInlineTextBox(runner)->Start() >= text_offset)
1460 return false; 1460 return false;
1461 } 1461 }
1462 1462
1463 return true; 1463 return true;
1464 } 1464 }
1465 1465
1466 // Returns true if |text_layout_object| has visible first-letter.
1467 bool IsVisibleFirstLetter(const LayoutText& text_layout_object) {
yoichio 2017/06/16 07:48:50 Function name is "Has"VisibleFirstLetter ?
yosin_UTC9 2017/06/16 07:58:18 Done.
1468 if (!text_layout_object.IsTextFragment())
1469 return false;
1470 const LayoutTextFragment& layout_text_fragment =
1471 ToLayoutTextFragment(text_layout_object);
1472 if (!layout_text_fragment.IsRemainingTextLayoutObject())
1473 return false;
1474 const LayoutObject* first_letter_layout_object =
1475 layout_text_fragment.GetFirstLetterPseudoElement()->GetLayoutObject();
1476 if (!first_letter_layout_object)
1477 return false;
1478 return first_letter_layout_object->Style()->Visibility() ==
1479 EVisibility::kVisible;
1480 }
1481
1466 // TODO(editing-dev): This function is just moved out from 1482 // TODO(editing-dev): This function is just moved out from
1467 // |MostBackwardCaretPosition()|. We should study this function more and 1483 // |MostBackwardCaretPosition()|. We should study this function more and
1468 // name it appropriately. See https://trac.webkit.org/changeset/32438/ 1484 // name it appropriately. See https://trac.webkit.org/changeset/32438/
1469 // which introduce this. 1485 // which introduce this.
1470 static bool CanBeBackwardCaretPosition(const LayoutText* text_layout_object, 1486 static bool CanBeBackwardCaretPosition(const LayoutText* text_layout_object,
1471 int offset_in_node) { 1487 int offset_in_node) {
1472 const unsigned text_start_offset = text_layout_object->TextStartOffset(); 1488 const unsigned text_start_offset = text_layout_object->TextStartOffset();
1473 DCHECK_GE(offset_in_node, static_cast<int>(text_start_offset)); 1489 DCHECK_GE(offset_in_node, static_cast<int>(text_start_offset));
1474 const unsigned text_offset = offset_in_node - text_start_offset; 1490 const unsigned text_offset = offset_in_node - text_start_offset;
1475 InlineTextBox* const last_text_box = text_layout_object->LastTextBox(); 1491 InlineTextBox* const last_text_box = text_layout_object->LastTextBox();
1476 for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) { 1492 for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
1477 if (text_offset == box->Start()) { 1493 if (text_offset == box->Start()) {
1478 if (text_layout_object->IsTextFragment() && 1494 if (IsVisibleFirstLetter(*text_layout_object)) {
1479 ToLayoutTextFragment(text_layout_object)
1480 ->IsRemainingTextLayoutObject()) {
1481 // |offset_in_node| is at start of remaining text of 1495 // |offset_in_node| is at start of remaining text of
1482 // |Text| node with :first-letter. 1496 // |Text| node with :first-letter.
1483 DCHECK_GE(offset_in_node, 1); 1497 DCHECK_GE(offset_in_node, 1);
1484 LayoutObject* first_letter_layout_object = 1498 return true;
1485 ToLayoutTextFragment(text_layout_object)
1486 ->GetFirstLetterPseudoElement()
1487 ->GetLayoutObject();
1488 if (first_letter_layout_object &&
1489 first_letter_layout_object->Style()->Visibility() ==
1490 EVisibility::kVisible)
1491 return true;
1492 } 1499 }
1493 continue; 1500 continue;
1494 } 1501 }
1495 if (text_offset <= box->Start() + box->Len()) { 1502 if (text_offset <= box->Start() + box->Len()) {
1496 if (text_offset > box->Start()) 1503 if (text_offset > box->Start())
1497 return true; 1504 return true;
1498 continue; 1505 continue;
1499 } 1506 }
1500 1507
1501 if (box == last_text_box || text_offset != box->Start() + box->Len() + 1) 1508 if (box == last_text_box || text_offset != box->Start() + box->Len() + 1)
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 2088
2082 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { 2089 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) {
2083 return EnclosingIntRect(ComputeTextRectTemplate(range)); 2090 return EnclosingIntRect(ComputeTextRectTemplate(range));
2084 } 2091 }
2085 2092
2086 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { 2093 FloatRect ComputeTextFloatRect(const EphemeralRange& range) {
2087 return ComputeTextRectTemplate(range); 2094 return ComputeTextRectTemplate(range);
2088 } 2095 }
2089 2096
2090 } // namespace blink 2097 } // 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