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

Unified Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2940293002: Introduce HasVisibleFirstLetter() for CanBeBackwardCaretPosition() (Closed)
Patch Set: 2017-06-16T16:57:17 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
index 0fe37bfec988ce5ee355ab3af0f81238c6e28496..00d5a2ddf47d0ad3c69797b4ca4f7fec85df99fa 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -1463,6 +1463,22 @@ static bool DoesContinueOnNextLine(const LayoutText& text_layout_object,
return true;
}
+// Returns true if |text_layout_object| has visible first-letter.
+bool HasVisibleFirstLetter(const LayoutText& text_layout_object) {
+ if (!text_layout_object.IsTextFragment())
+ return false;
+ const LayoutTextFragment& layout_text_fragment =
+ ToLayoutTextFragment(text_layout_object);
+ if (!layout_text_fragment.IsRemainingTextLayoutObject())
+ return false;
+ const LayoutObject* first_letter_layout_object =
+ layout_text_fragment.GetFirstLetterPseudoElement()->GetLayoutObject();
+ if (!first_letter_layout_object)
+ return false;
+ return first_letter_layout_object->Style()->Visibility() ==
+ EVisibility::kVisible;
+}
+
// TODO(editing-dev): This function is just moved out from
// |MostBackwardCaretPosition()|. We should study this function more and
// name it appropriately. See https://trac.webkit.org/changeset/32438/
@@ -1475,20 +1491,11 @@ static bool CanBeBackwardCaretPosition(const LayoutText* text_layout_object,
InlineTextBox* const last_text_box = text_layout_object->LastTextBox();
for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
if (text_offset == box->Start()) {
- if (text_layout_object->IsTextFragment() &&
- ToLayoutTextFragment(text_layout_object)
- ->IsRemainingTextLayoutObject()) {
+ if (HasVisibleFirstLetter(*text_layout_object)) {
// |offset_in_node| is at start of remaining text of
// |Text| node with :first-letter.
DCHECK_GE(offset_in_node, 1);
- LayoutObject* first_letter_layout_object =
- ToLayoutTextFragment(text_layout_object)
- ->GetFirstLetterPseudoElement()
- ->GetLayoutObject();
- if (first_letter_layout_object &&
- first_letter_layout_object->Style()->Visibility() ==
- EVisibility::kVisible)
- return true;
+ return true;
}
continue;
}
« 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