summaryrefslogtreecommitdiffstats
path: root/WebCore/editing/TextIterator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/editing/TextIterator.cpp')
-rw-r--r--WebCore/editing/TextIterator.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/WebCore/editing/TextIterator.cpp b/WebCore/editing/TextIterator.cpp
index d5a03ef..0612986 100644
--- a/WebCore/editing/TextIterator.cpp
+++ b/WebCore/editing/TextIterator.cpp
@@ -782,7 +782,7 @@ static bool shouldEmitExtraNewlineForNode(Node* node)
|| node->hasTagName(pTag)) {
RenderStyle* style = r->style();
if (style) {
- int bottomMargin = toRenderBox(r)->collapsedMarginBottom();
+ int bottomMargin = toRenderBox(r)->collapsedMarginAfter();
int fontSize = style->fontDescription().computedPixelSize();
if (bottomMargin * 2 >= fontSize)
return true;
@@ -1534,7 +1534,7 @@ const UChar* WordAwareIterator::characters() const
// --------
-static inline UChar foldQuoteMark(UChar c)
+static inline UChar foldQuoteMarkOrSoftHyphen(UChar c)
{
switch (c) {
case hebrewPunctuationGershayim:
@@ -1545,12 +1545,16 @@ static inline UChar foldQuoteMark(UChar c)
case leftSingleQuotationMark:
case rightSingleQuotationMark:
return '\'';
+ case softHyphen:
+ // Replace soft hyphen with an ignorable character so that their presence or absence will
+ // not affect string comparison.
+ return 0;
default:
return c;
}
}
-static inline void foldQuoteMarks(String& s)
+static inline void foldQuoteMarksAndSoftHyphens(String& s)
{
s.replace(hebrewPunctuationGeresh, '\'');
s.replace(hebrewPunctuationGershayim, '"');
@@ -1558,14 +1562,17 @@ static inline void foldQuoteMarks(String& s)
s.replace(leftSingleQuotationMark, '\'');
s.replace(rightDoubleQuotationMark, '"');
s.replace(rightSingleQuotationMark, '\'');
+ // Replace soft hyphen with an ignorable character so that their presence or absence will
+ // not affect string comparison.
+ s.replace(softHyphen, 0);
}
#if USE(ICU_UNICODE) && !UCONFIG_NO_COLLATION
-static inline void foldQuoteMarks(UChar* data, size_t length)
+static inline void foldQuoteMarksAndSoftHyphens(UChar* data, size_t length)
{
for (size_t i = 0; i < length; ++i)
- data[i] = foldQuoteMark(data[i]);
+ data[i] = foldQuoteMarkOrSoftHyphen(data[i]);
}
static const size_t minimumSearchBufferSize = 8192;
@@ -1819,7 +1826,7 @@ inline SearchBuffer::SearchBuffer(const String& target, bool isCaseSensitive)
// FIXME: We'd like to tailor the searcher to fold quote marks for us instead
// of doing it in a separate replacement pass here, but ICU doesn't offer a way
// to add tailoring on top of the locale-specific tailoring as of this writing.
- foldQuoteMarks(m_target);
+ foldQuoteMarksAndSoftHyphens(m_target);
size_t targetLength = m_target.length();
m_buffer.reserveInitialCapacity(max(targetLength * 8, minimumSearchBufferSize));
@@ -1869,7 +1876,7 @@ inline size_t SearchBuffer::append(const UChar* characters, size_t length)
size_t usableLength = min(m_buffer.capacity() - oldLength, length);
ASSERT(usableLength);
m_buffer.append(characters, usableLength);
- foldQuoteMarks(m_buffer.data() + oldLength, usableLength);
+ foldQuoteMarksAndSoftHyphens(m_buffer.data() + oldLength, usableLength);
return usableLength;
}
@@ -2008,7 +2015,7 @@ inline SearchBuffer::SearchBuffer(const String& target, bool isCaseSensitive)
{
ASSERT(!m_target.isEmpty());
m_target.replace(noBreakSpace, ' ');
- foldQuoteMarks(m_target);
+ foldQuoteMarksAndSoftHyphens(m_target);
}
inline SearchBuffer::~SearchBuffer()
@@ -2028,7 +2035,7 @@ inline bool SearchBuffer::atBreak() const
inline void SearchBuffer::append(UChar c, bool isStart)
{
- m_buffer[m_cursor] = c == noBreakSpace ? ' ' : foldQuoteMark(c);
+ m_buffer[m_cursor] = c == noBreakSpace ? ' ' : foldQuoteMarkOrSoftHyphen(c);
m_isCharacterStartBuffer[m_cursor] = isStart;
if (++m_cursor == m_target.length()) {
m_cursor = 0;