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

Side by Side Diff: Source/core/editing/iterators/CharacterIterator.cpp

Issue 868463002: Support WholeWord in window.find() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: bug fix Created 5 years, 11 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
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 468 }
469 469
470 // Chinese and Japanese lack word boundary marks, and there is no clear agre ement on what constitutes 470 // Chinese and Japanese lack word boundary marks, and there is no clear agre ement on what constitutes
471 // a word, so treat the position before any CJK character as a word start. 471 // a word, so treat the position before any CJK character as a word start.
472 if (Character::isCJKIdeographOrSymbol(firstCharacter)) 472 if (Character::isCJKIdeographOrSymbol(firstCharacter))
473 return true; 473 return true;
474 474
475 size_t wordBreakSearchStart = start + length; 475 size_t wordBreakSearchStart = start + length;
476 while (wordBreakSearchStart > start) 476 while (wordBreakSearchStart > start)
477 wordBreakSearchStart = findNextWordFromIndex(m_buffer.data(), m_buffer.s ize(), wordBreakSearchStart, false /* backwards */); 477 wordBreakSearchStart = findNextWordFromIndex(m_buffer.data(), m_buffer.s ize(), wordBreakSearchStart, false /* backwards */);
478 return wordBreakSearchStart == start; 478 if (wordBreakSearchStart != start)
479 return false;
480 if (m_options & WholeWord)
481 return static_cast<int>(start + length) == findWordEndBoundary(m_buffer. data(), m_buffer.size(), wordBreakSearchStart);
482 return true;
479 } 483 }
480 484
481 inline size_t SearchBuffer::search(size_t& start) 485 inline size_t SearchBuffer::search(size_t& start)
482 { 486 {
483 size_t size = m_buffer.size(); 487 size_t size = m_buffer.size();
484 if (m_atBreak) { 488 if (m_atBreak) {
485 if (!size) 489 if (!size)
486 return 0; 490 return 0;
487 } else { 491 } else {
488 if (size != m_buffer.capacity()) 492 if (size != m_buffer.capacity())
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 resultEnd = collapseTo; 665 resultEnd = collapseTo;
662 return; 666 return;
663 } 667 }
664 } 668 }
665 669
666 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText); 670 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo rFindPlainText);
667 computeRangeIterator.calculateCharacterSubrange(matchStart, matchLength, res ultStart, resultEnd); 671 computeRangeIterator.calculateCharacterSubrange(matchStart, matchLength, res ultStart, resultEnd);
668 } 672 }
669 673
670 } // namespace blink 674 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698