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

Side by Side Diff: Source/core/editing/TextIterator.cpp

Issue 214523008: Use RenderStyle::isCollapsibleWhiteSpace when renderer is available. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address reviewer comments. Created 6 years, 8 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 | « Source/core/editing/TextIterator.h ('k') | Source/core/editing/htmlediting.h » ('j') | 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, 2010, 2012 Apple Inc. All r ights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
3 * Copyright (C) 2005 Alexey Proskuryakov. 3 * Copyright (C) 2005 Alexey Proskuryakov.
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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 unsigned start = m_offset; 661 unsigned start = m_offset;
662 unsigned end = (m_node == m_endContainer) ? static_cast<unsigned>(m_endOffse t) : INT_MAX; 662 unsigned end = (m_node == m_endContainer) ? static_cast<unsigned>(m_endOffse t) : INT_MAX;
663 while (m_textBox) { 663 while (m_textBox) {
664 unsigned textBoxStart = m_textBox->start(); 664 unsigned textBoxStart = m_textBox->start();
665 unsigned runStart = max(textBoxStart, start); 665 unsigned runStart = max(textBoxStart, start);
666 666
667 // Check for collapsed space at the start of this run. 667 // Check for collapsed space at the start of this run.
668 InlineTextBox* firstTextBox = renderer->containsReversedText() ? (m_sort edTextBoxes.isEmpty() ? 0 : m_sortedTextBoxes[0]) : renderer->firstTextBox(); 668 InlineTextBox* firstTextBox = renderer->containsReversedText() ? (m_sort edTextBoxes.isEmpty() ? 0 : m_sortedTextBoxes[0]) : renderer->firstTextBox();
669 bool needSpace = m_lastTextNodeEndedWithCollapsedSpace 669 bool needSpace = m_lastTextNodeEndedWithCollapsedSpace
670 || (m_textBox == firstTextBox && textBoxStart == runStart && runStar t > 0); 670 || (m_textBox == firstTextBox && textBoxStart == runStart && runStar t > 0);
671 if (needSpace && !isCollapsibleWhitespace(m_lastCharacter) && m_lastChar acter) { 671 if (needSpace && !renderer->style()->isCollapsibleWhiteSpace(m_lastChara cter) && m_lastCharacter) {
672 if (m_lastTextNode == m_node && runStart > 0 && str[runStart - 1] == ' ') { 672 if (m_lastTextNode == m_node && runStart > 0 && str[runStart - 1] == ' ') {
673 unsigned spaceRunStart = runStart - 1; 673 unsigned spaceRunStart = runStart - 1;
674 while (spaceRunStart > 0 && str[spaceRunStart - 1] == ' ') 674 while (spaceRunStart > 0 && str[spaceRunStart - 1] == ' ')
675 --spaceRunStart; 675 --spaceRunStart;
676 emitText(m_node, renderer, spaceRunStart, spaceRunStart + 1); 676 emitText(m_node, renderer, spaceRunStart, spaceRunStart + 1);
677 } else { 677 } else {
678 emitCharacter(' ', m_node, 0, runStart, runStart); 678 emitCharacter(' ', m_node, 0, runStart, runStart);
679 } 679 }
680 return; 680 return;
681 } 681 }
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 const Position& collapseTo = options & Backwards ? start : end; 2159 const Position& collapseTo = options & Backwards ? start : end;
2160 return Range::create(*start.document(), collapseTo, collapseTo); 2160 return Range::create(*start.document(), collapseTo, collapseTo);
2161 } 2161 }
2162 } 2162 }
2163 2163
2164 CharacterIterator computeRangeIterator(start, end, iteratorFlagsForFindPlain Text); 2164 CharacterIterator computeRangeIterator(start, end, iteratorFlagsForFindPlain Text);
2165 return characterSubrange(computeRangeIterator, matchStart, matchLength); 2165 return characterSubrange(computeRangeIterator, matchStart, matchLength);
2166 } 2166 }
2167 2167
2168 } 2168 }
OLDNEW
« no previous file with comments | « Source/core/editing/TextIterator.h ('k') | Source/core/editing/htmlediting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698