 Chromium Code Reviews
 Chromium Code Reviews Issue 1657203003:
  Detemplatize SimplifiedBackwardsTextIterator::copyTextTo with BackwardsTextBuffer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@apply_forward_buffer
    
  
    Issue 1657203003:
  Detemplatize SimplifiedBackwardsTextIterator::copyTextTo with BackwardsTextBuffer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@apply_forward_buffer| Index: third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp | 
| diff --git a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp | 
| index 3d8aeab7673cc8d8e41059adffc7ebadd6fadcd2..71181a3339945820f6e603010d54e30159c375cc 100644 | 
| --- a/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp | 
| +++ b/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp | 
| @@ -410,6 +410,42 @@ bool SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::isBetweenSurrogatePair( | 
| return position > 0 && position < length() && U16_IS_TRAIL(characterAt(position - 1)) && U16_IS_LEAD(characterAt(position)); | 
| } | 
| +template <typename Strategy> | 
| +int SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::copyTextTo(BackwardsTextBuffer* output, int position, int minLength) const | 
| +{ | 
| + int copiedLength = isBetweenSurrogatePair(position + minLength) ? minLength + 1 : minLength; | 
| + copyCodeUnitsTo(output, position, copiedLength); | 
| + return copiedLength; | 
| +} | 
| + | 
| +template <typename Strategy> | 
| +int SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::copyTextTo(BackwardsTextBuffer* output, int position) const | 
| +{ | 
| + return copyTextTo(output, position, m_textLength - position); | 
| +} | 
| + | 
| +template <typename Strategy> | 
| +void SimplifiedBackwardsTextIteratorAlgorithm<Strategy>::copyCodeUnitsTo(BackwardsTextBuffer* output, int position, int copyLength) const | 
| +{ | 
| + ASSERT(position >= 0); | 
| + ASSERT(copyLength >= 0); | 
| + ASSERT(position + copyLength <= m_textLength); | 
| + // Make sure there's no integer overflow. | 
| + ASSERT(position + copyLength >= position); | 
| + if (m_textLength == 0 || copyLength == 0) | 
| + return; | 
| + ASSERT(output); | 
| 
yosin_UTC9
2016/02/03 08:44:25
nit: We don't need to have |ASSERT(output)|, since
 
Xiaocheng
2016/02/03 08:52:46
There's a symmetric assertion in crrev.com/1651263
 | 
| + if (m_singleCharacterBuffer) { | 
| + output->pushCharacters(m_singleCharacterBuffer, 1); | 
| + return; | 
| + } | 
| + int offset = m_textOffset + m_textLength - position - copyLength; | 
| + if (m_textContainer.is8Bit()) | 
| + output->pushRange(m_textContainer.characters8() + offset, copyLength); | 
| + else | 
| + output->pushRange(m_textContainer.characters16() + offset, copyLength); | 
| +} | 
| + | 
| template class CORE_TEMPLATE_EXPORT SimplifiedBackwardsTextIteratorAlgorithm<EditingStrategy>; | 
| template class CORE_TEMPLATE_EXPORT SimplifiedBackwardsTextIteratorAlgorithm<EditingInComposedTreeStrategy>; |