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

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp

Issue 2896033003: Revert of No extra space emission in TextIterator::HandleTextNode (Closed)
Patch Set: Rebaseline Created 3 years, 7 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 | « third_party/WebKit/LayoutTests/virtual/without-smil/svg/animations/exposed/effect-expected.txt ('k') | 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/iterators/TextIterator.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
index cdbf1ad8321e3bc042e1c959ef09830ca6e89a1a..93268ca933c6e499123fc8de91c7db5af7237252 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -485,6 +485,25 @@ void TextIteratorAlgorithm<Strategy>::Advance() {
}
}
+static bool HasVisibleTextNode(LayoutText* layout_object) {
+ if (layout_object->Style()->Visibility() == EVisibility::kVisible)
+ return true;
+
+ if (!layout_object->IsTextFragment())
+ return false;
+
+ LayoutTextFragment* fragment = ToLayoutTextFragment(layout_object);
+ if (!fragment->IsRemainingTextLayoutObject())
+ return false;
+
+ DCHECK(fragment->GetFirstLetterPseudoElement());
+ LayoutObject* pseudo_element_layout_object =
+ fragment->GetFirstLetterPseudoElement()->GetLayoutObject();
+ return pseudo_element_layout_object &&
+ pseudo_element_layout_object->Style()->Visibility() ==
+ EVisibility::kVisible;
+}
+
template <typename Strategy>
bool TextIteratorAlgorithm<Strategy>::ShouldHandleFirstLetter(
const LayoutText& layout_text) const {
@@ -514,6 +533,18 @@ bool TextIteratorAlgorithm<Strategy>::HandleTextNode() {
// handle pre-formatted text
if (!layout_object->Style()->CollapseWhiteSpace()) {
+ if (last_text_node_ended_with_collapsed_space_ &&
+ HasVisibleTextNode(layout_object)) {
+ if (behavior_.CollapseTrailingSpace()) {
+ if (offset_ > 0 && str[offset_ - 1] == ' ') {
+ SpliceBuffer(kSpaceCharacter, text_node, 0, offset_, offset_);
+ return false;
+ }
+ } else {
+ SpliceBuffer(kSpaceCharacter, text_node, 0, offset_, offset_);
+ return false;
+ }
+ }
if (ShouldHandleFirstLetter(*layout_object)) {
HandleTextNodeFirstLetter(ToLayoutTextFragment(layout_object));
if (first_letter_text_) {
« no previous file with comments | « third_party/WebKit/LayoutTests/virtual/without-smil/svg/animations/exposed/effect-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698