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

Unified Diff: Source/core/editing/TextIterator.cpp

Issue 329183002: Removing "using" declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
Index: Source/core/editing/TextIterator.cpp
diff --git a/Source/core/editing/TextIterator.cpp b/Source/core/editing/TextIterator.cpp
index 5d2291d87bd10ecf24a58ab966db2d9bd58a5395..5b7b415a42dbc7614541b52902342cde97d54adb 100644
--- a/Source/core/editing/TextIterator.cpp
+++ b/Source/core/editing/TextIterator.cpp
@@ -55,7 +55,6 @@
#include <unicode/utf16.h>
using namespace WTF::Unicode;
-using namespace std;
namespace WebCore {
@@ -75,29 +74,29 @@ public:
// Returns number of characters appended; guaranteed to be in the range [1, length].
template<typename CharType>
- void append(const CharType*, size_t length);
- size_t numberOfCharactersJustAppended() const { return m_numberOfCharactersJustAppended; }
+ void append(const CharType*, std::size_t length);
+ std::size_t numberOfCharactersJustAppended() const { return m_numberOfCharactersJustAppended; }
bool needsMoreContext() const;
- void prependContext(const UChar*, size_t length);
+ void prependContext(const UChar*, std::size_t length);
void reachedBreak();
// Result is the size in characters of what was found.
// And <startOffset> is the number of characters back to the start of what was found.
- size_t search(size_t& startOffset);
+ std::size_t search(std::size_t& startOffset);
bool atBreak() const;
private:
- bool isBadMatch(const UChar*, size_t length) const;
- bool isWordStartMatch(size_t start, size_t length) const;
+ bool isBadMatch(const UChar*, std::size_t length) const;
+ bool isWordStartMatch(std::size_t start, std::size_t length) const;
Vector<UChar> m_target;
FindOptions m_options;
Vector<UChar> m_buffer;
- size_t m_overlap;
- size_t m_prefixLength;
- size_t m_numberOfCharactersJustAppended;
+ std::size_t m_overlap;
+ std::size_t m_prefixLength;
+ std::size_t m_numberOfCharactersJustAppended;
bool m_atBreak;
bool m_needsMoreContext;
@@ -230,8 +229,8 @@ static void setUpFullyClippedStack(BitStack& stack, Node* node)
ancestry.append(parent);
// Call pushFullyClippedState on each node starting with the earliest ancestor.
- size_t size = ancestry.size();
- for (size_t i = 0; i < size; ++i)
+ std::size_t size = ancestry.size();
+ for (std::size_t i = 0; i < size; ++i)
pushFullyClippedState(stack, ancestry[size - i - 1]);
pushFullyClippedState(stack, node);
@@ -618,7 +617,7 @@ bool TextIterator::handleTextNode()
return false;
int strLength = str.length();
int end = (m_node == m_endContainer) ? m_endOffset : INT_MAX;
- int runEnd = min(strLength, end);
+ int runEnd = std::min(strLength, end);
if (runStart >= runEnd)
return true;
@@ -671,7 +670,7 @@ void TextIterator::handleTextBox()
unsigned end = (m_node == m_endContainer) ? static_cast<unsigned>(m_endOffset) : INT_MAX;
while (m_textBox) {
unsigned textBoxStart = m_textBox->start();
- unsigned runStart = max(textBoxStart, start);
+ unsigned runStart = std::max(textBoxStart, start);
// Check for collapsed space at the start of this run.
InlineTextBox* firstTextBox = renderer->containsReversedText() ? (m_sortedTextBoxes.isEmpty() ? 0 : m_sortedTextBoxes[0]) : renderer->firstTextBox();
@@ -689,7 +688,7 @@ void TextIterator::handleTextBox()
return;
}
unsigned textBoxEnd = textBoxStart + m_textBox->len();
- unsigned runEnd = min(textBoxEnd, end);
+ unsigned runEnd = std::min(textBoxEnd, end);
// Determine what the next text box will be, but don't advance yet
InlineTextBox* nextTextBox = 0;
@@ -709,7 +708,7 @@ void TextIterator::handleTextBox()
emitCharacter(' ', m_node, 0, runStart, runStart + 1);
m_offset = runStart + 1;
} else {
- size_t subrunEnd = str.find('\n', runStart);
+ std::size_t subrunEnd = str.find('\n', runStart);
if (subrunEnd == kNotFound || subrunEnd > runEnd)
subrunEnd = runEnd;
@@ -1735,7 +1734,7 @@ UChar WordAwareIterator::characterAt(unsigned index) const
// --------
-static const size_t minimumSearchBufferSize = 8192;
+static const std::size_t minimumSearchBufferSize = 8192;
#ifndef NDEBUG
static bool searcherInUse;
@@ -1791,8 +1790,8 @@ inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)
// to add tailoring on top of the locale-specific tailoring as of this writing.
foldQuoteMarksAndSoftHyphens(m_target.data(), m_target.size());
- size_t targetLength = m_target.size();
- m_buffer.reserveInitialCapacity(max(targetLength * 8, minimumSearchBufferSize));
+ std::size_t targetLength = m_target.size();
+ m_buffer.reserveInitialCapacity(std::max(targetLength * 8, minimumSearchBufferSize));
m_overlap = m_buffer.capacity() / 4;
if ((m_options & AtWordStarts) && targetLength) {
@@ -1840,7 +1839,7 @@ inline SearchBuffer::~SearchBuffer()
}
template<typename CharType>
-inline void SearchBuffer::append(const CharType* characters, size_t length)
+inline void SearchBuffer::append(const CharType* characters, std::size_t length)
{
ASSERT(length);
@@ -1850,12 +1849,12 @@ inline void SearchBuffer::append(const CharType* characters, size_t length)
m_atBreak = false;
} else if (m_buffer.size() == m_buffer.capacity()) {
memcpy(m_buffer.data(), m_buffer.data() + m_buffer.size() - m_overlap, m_overlap * sizeof(UChar));
- m_prefixLength -= min(m_prefixLength, m_buffer.size() - m_overlap);
+ m_prefixLength -= std::min(m_prefixLength, m_buffer.size() - m_overlap);
m_buffer.shrink(m_overlap);
}
- size_t oldLength = m_buffer.size();
- size_t usableLength = min(m_buffer.capacity() - oldLength, length);
+ std::size_t oldLength = m_buffer.size();
+ std::size_t usableLength = std::min(m_buffer.capacity() - oldLength, length);
ASSERT(usableLength);
m_buffer.resize(oldLength + usableLength);
UChar* destination = m_buffer.data() + oldLength;
@@ -1869,7 +1868,7 @@ inline bool SearchBuffer::needsMoreContext() const
return m_needsMoreContext;
}
-inline void SearchBuffer::prependContext(const UChar* characters, size_t length)
+inline void SearchBuffer::prependContext(const UChar* characters, std::size_t length)
{
ASSERT(m_needsMoreContext);
ASSERT(m_prefixLength == m_buffer.size());
@@ -1879,13 +1878,13 @@ inline void SearchBuffer::prependContext(const UChar* characters, size_t length)
m_atBreak = false;
- size_t wordBoundaryContextStart = length;
+ std::size_t wordBoundaryContextStart = length;
if (wordBoundaryContextStart) {
U16_BACK_1(characters, 0, wordBoundaryContextStart);
wordBoundaryContextStart = startOfLastWordBoundaryContext(characters, wordBoundaryContextStart);
}
- size_t usableLength = min(m_buffer.capacity() - m_prefixLength, length - wordBoundaryContextStart);
+ std::size_t usableLength = std::min(m_buffer.capacity() - m_prefixLength, length - wordBoundaryContextStart);
m_buffer.prepend(characters + length - usableLength, usableLength);
m_prefixLength += usableLength;
@@ -1903,7 +1902,7 @@ inline void SearchBuffer::reachedBreak()
m_atBreak = true;
}
-inline bool SearchBuffer::isBadMatch(const UChar* match, size_t matchLength) const
+inline bool SearchBuffer::isBadMatch(const UChar* match, std::size_t matchLength) const
{
// This function implements the kana workaround. If usearch treats
// it as a match, but we do not want to, then it's a "bad match".
@@ -1917,7 +1916,7 @@ inline bool SearchBuffer::isBadMatch(const UChar* match, size_t matchLength) con
return !checkOnlyKanaLettersInStrings(m_normalizedTarget.begin(), m_normalizedTarget.size(), m_normalizedMatch.begin(), m_normalizedMatch.size());
}
-inline bool SearchBuffer::isWordStartMatch(size_t start, size_t length) const
+inline bool SearchBuffer::isWordStartMatch(std::size_t start, std::size_t length) const
{
ASSERT(m_options & AtWordStarts);
@@ -1966,15 +1965,15 @@ inline bool SearchBuffer::isWordStartMatch(size_t start, size_t length) const
if (Character::isCJKIdeographOrSymbol(firstCharacter))
return true;
- size_t wordBreakSearchStart = start + length;
+ std::size_t wordBreakSearchStart = start + length;
while (wordBreakSearchStart > start)
wordBreakSearchStart = findNextWordFromIndex(m_buffer.data(), m_buffer.size(), wordBreakSearchStart, false /* backwards */);
return wordBreakSearchStart == start;
}
-inline size_t SearchBuffer::search(size_t& start)
+inline std::size_t SearchBuffer::search(std::size_t& start)
{
- size_t size = m_buffer.size();
+ std::size_t size = m_buffer.size();
if (m_atBreak) {
if (!size)
return 0;
@@ -1996,7 +1995,7 @@ inline size_t SearchBuffer::search(size_t& start)
ASSERT(status == U_ZERO_ERROR);
nextMatch:
- if (!(matchStart >= 0 && static_cast<size_t>(matchStart) < size)) {
+ if (!(matchStart >= 0 && static_cast<std::size_t>(matchStart) < size)) {
ASSERT(matchStart == USEARCH_DONE);
return 0;
}
@@ -2004,23 +2003,23 @@ nextMatch:
// Matches that start in the overlap area are only tentative.
// The same match may appear later, matching more characters,
// possibly including a combining character that's not yet in the buffer.
- if (!m_atBreak && static_cast<size_t>(matchStart) >= size - m_overlap) {
- size_t overlap = m_overlap;
+ if (!m_atBreak && static_cast<std::size_t>(matchStart) >= size - m_overlap) {
+ std::size_t overlap = m_overlap;
if (m_options & AtWordStarts) {
// Ensure that there is sufficient context before matchStart the next time around for
// determining if it is at a word boundary.
int wordBoundaryContextStart = matchStart;
U16_BACK_1(m_buffer.data(), 0, wordBoundaryContextStart);
wordBoundaryContextStart = startOfLastWordBoundaryContext(m_buffer.data(), wordBoundaryContextStart);
- overlap = min(size - 1, max(overlap, size - wordBoundaryContextStart));
+ overlap = std::min(size - 1, std::max(overlap, size - wordBoundaryContextStart));
}
memcpy(m_buffer.data(), m_buffer.data() + size - overlap, overlap * sizeof(UChar));
- m_prefixLength -= min(m_prefixLength, size - overlap);
+ m_prefixLength -= std::min(m_prefixLength, size - overlap);
m_buffer.shrink(overlap);
return 0;
}
- size_t matchedLength = usearch_getMatchedLength(searcher);
+ std::size_t matchedLength = usearch_getMatchedLength(searcher);
ASSERT_WITH_SECURITY_IMPLICATION(matchStart + matchedLength <= size);
// If this match is "bad", move on to the next match.
@@ -2030,9 +2029,9 @@ nextMatch:
goto nextMatch;
}
- size_t newSize = size - (matchStart + 1);
+ std::size_t newSize = size - (matchStart + 1);
memmove(m_buffer.data(), m_buffer.data() + matchStart + 1, newSize * sizeof(UChar));
- m_prefixLength -= min<size_t>(m_prefixLength, matchStart + 1);
+ m_prefixLength -= std::min<std::size_t>(m_prefixLength, matchStart + 1);
m_buffer.shrink(newSize);
start = size - matchStart;
@@ -2095,8 +2094,8 @@ static bool isValidUTF16(const String& s)
if (s.is8Bit())
return true;
const UChar* ustr = s.characters16();
- size_t length = s.length();
- size_t position = 0;
+ std::size_t length = s.length();
+ std::size_t position = 0;
while (position < length) {
UChar32 character;
U16_NEXT(ustr, position, length, character);
@@ -2106,10 +2105,10 @@ static bool isValidUTF16(const String& s)
return true;
}
-static size_t findPlainTextInternal(CharacterIterator& it, const String& target, FindOptions options, size_t& matchStart)
+static std::size_t findPlainTextInternal(CharacterIterator& it, const String& target, FindOptions options, std::size_t& matchStart)
{
matchStart = 0;
- size_t matchLength = 0;
+ std::size_t matchLength = 0;
if (!isValidUTF16(target))
return 0;
@@ -2133,10 +2132,10 @@ static size_t findPlainTextInternal(CharacterIterator& it, const String& target,
it.appendTextTo(buffer);
it.advance(buffer.numberOfCharactersJustAppended());
tryAgain:
- size_t matchStartOffset;
- if (size_t newMatchLength = buffer.search(matchStartOffset)) {
+ std::size_t matchStartOffset;
+ if (std::size_t newMatchLength = buffer.search(matchStartOffset)) {
// Note that we found a match, and where we found it.
- size_t lastCharacterInBufferOffset = it.characterOffset();
+ std::size_t lastCharacterInBufferOffset = it.characterOffset();
ASSERT(lastCharacterInBufferOffset >= matchStartOffset);
matchStart = lastCharacterInBufferOffset - matchStartOffset;
matchLength = newMatchLength;
@@ -2163,8 +2162,8 @@ PassRefPtrWillBeRawPtr<Range> findPlainText(const Range* range, const String& ta
range->ownerDocument().updateLayout();
// First, find the text.
- size_t matchStart;
- size_t matchLength;
+ std::size_t matchStart;
+ std::size_t matchLength;
{
CharacterIterator findIterator(range, iteratorFlagsForFindPlainText);
matchLength = findPlainTextInternal(findIterator, target, options, matchStart);
@@ -2191,8 +2190,8 @@ void findPlainText(const Position& inputStart, const Position& inputEnd, const S
inputStart.document()->updateLayout();
// FIXME: Reduce the code duplication with above (but how?).
- size_t matchStart;
- size_t matchLength;
+ std::size_t matchStart;
+ std::size_t matchLength;
{
CharacterIterator findIterator(inputStart, inputEnd, iteratorFlagsForFindPlainText);
matchLength = findPlainTextInternal(findIterator, target, options, matchStart);

Powered by Google App Engine
This is Rietveld 408576698