diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/platform/text')
8 files changed, 52 insertions, 42 deletions
diff --git a/src/3rdparty/webkit/WebCore/platform/text/CharacterNames.h b/src/3rdparty/webkit/WebCore/platform/text/CharacterNames.h index 5b1a33780..cd0944739 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/CharacterNames.h +++ b/src/3rdparty/webkit/WebCore/platform/text/CharacterNames.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -37,22 +37,26 @@ namespace WebCore { const UChar blackSquare = 0x25A0; const UChar bullet = 0x2022; + const UChar hebrewPunctuationGeresh = 0x05F3; const UChar hebrewPunctuationGershayim = 0x05F4; const UChar horizontalEllipsis = 0x2026; - const UChar ideographicSpace = 0x3000; const UChar ideographicComma = 0x3001; const UChar ideographicFullStop = 0x3002; - const UChar leftToRightMark = 0x200E; + const UChar ideographicSpace = 0x3000; + const UChar leftDoubleQuotationMark = 0x201C; + const UChar leftSingleQuotationMark = 0x2018; const UChar leftToRightEmbed = 0x202A; + const UChar leftToRightMark = 0x200E; const UChar leftToRightOverride = 0x202D; const UChar newlineCharacter = 0x000A; const UChar noBreakSpace = 0x00A0; const UChar objectReplacementCharacter = 0xFFFC; const UChar popDirectionalFormatting = 0x202C; const UChar replacementCharacter = 0xFFFD; + const UChar rightDoubleQuotationMark = 0x201D; const UChar rightSingleQuotationMark = 0x2019; - const UChar rightToLeftMark = 0x200F; const UChar rightToLeftEmbed = 0x202B; + const UChar rightToLeftMark = 0x200F; const UChar rightToLeftOverride = 0x202E; const UChar softHyphen = 0x00AD; const UChar whiteBullet = 0x25E6; diff --git a/src/3rdparty/webkit/WebCore/platform/text/StringBuffer.h b/src/3rdparty/webkit/WebCore/platform/text/StringBuffer.h index 28d4e897b..353a44a0c 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/StringBuffer.h +++ b/src/3rdparty/webkit/WebCore/platform/text/StringBuffer.h @@ -35,7 +35,7 @@ namespace WebCore { -class StringBuffer : Noncopyable { +class StringBuffer : public Noncopyable { public: explicit StringBuffer(unsigned length) : m_length(length) diff --git a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp index cd8fdbd00..8cbcc0d95 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp @@ -205,24 +205,26 @@ bool StringImpl::containsOnlyWhitespace() return true; } -PassRefPtr<StringImpl> StringImpl::substring(unsigned pos, unsigned len) +PassRefPtr<StringImpl> StringImpl::substring(unsigned start, unsigned length) { - if (pos >= m_length) + if (start >= m_length) return empty(); - if (len > m_length - pos) - len = m_length - pos; - return create(m_data + pos, len); + unsigned maxLength = m_length - start; + if (length >= maxLength) { + if (!start) + return this; + length = maxLength; + } + return create(m_data + start, length); } -PassRefPtr<StringImpl> StringImpl::substringCopy(unsigned pos, unsigned len) +PassRefPtr<StringImpl> StringImpl::substringCopy(unsigned start, unsigned length) { - if (pos >= m_length) - pos = m_length; - if (len > m_length - pos) - len = m_length - pos; - if (!len) + start = min(start, m_length); + length = min(length, m_length - start); + if (!length) return adoptRef(new StringImpl); - return substring(pos, len); + return create(m_data + start, length); } UChar32 StringImpl::characterStartingAt(unsigned i) diff --git a/src/3rdparty/webkit/WebCore/platform/text/TextBreakIteratorICU.cpp b/src/3rdparty/webkit/WebCore/platform/text/TextBreakIteratorICU.cpp index c4fc1b0ee..c922fbc84 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/TextBreakIteratorICU.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/TextBreakIteratorICU.cpp @@ -160,7 +160,7 @@ TextBreakIterator* cursorMovementIterator(const UChar* string, int length) "$LF = [\\p{Grapheme_Cluster_Break = LF}];" "$Control = [\\p{Grapheme_Cluster_Break = Control}];" "$VoiceMarks = [\\uFF9E\\uFF9F];" // Japanese half-width katakana voiced marks - "$Extend = [\\p{Grapheme_Cluster_Break = Extend} $VoiceMarks];" + "$Extend = [\\p{Grapheme_Cluster_Break = Extend} $VoiceMarks - [\\u0E30 \\u0E32 \\u0E45 \\u0EB0 \\u0EB2]];" "$SpacingMark = [[\\p{General_Category = Spacing Mark}] - $Extend];" "$L = [\\p{Grapheme_Cluster_Break = L}];" "$V = [\\p{Grapheme_Cluster_Break = V}];" diff --git a/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h b/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h index df4258294..3c74165d3 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h +++ b/src/3rdparty/webkit/WebCore/platform/text/TextCodec.h @@ -56,7 +56,7 @@ namespace WebCore { typedef char UnencodableReplacementArray[32]; - class TextCodec : Noncopyable { + class TextCodec : public Noncopyable { public: virtual ~TextCodec(); diff --git a/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp b/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp index 97bbf40b1..62aa9794e 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp @@ -41,7 +41,7 @@ String::String(const QString& qstr) String::String(const QStringRef& ref) { - if (!ref.string()) + if (!ref.string()) return; m_impl = StringImpl::create(reinterpret_cast<const UChar*>(ref.unicode()), ref.length()); } diff --git a/src/3rdparty/webkit/WebCore/platform/text/qt/TextBoundaries.cpp b/src/3rdparty/webkit/WebCore/platform/text/qt/TextBoundaries.cpp index bdc851b93..ffc4c44bd 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/qt/TextBoundaries.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/qt/TextBoundaries.cpp @@ -39,8 +39,7 @@ #if QT_VERSION >= 0x040400 #include <qtextboundaryfinder.h> -namespace WebCore -{ +namespace WebCore { int findNextWordFromIndex(UChar const* buffer, int len, int position, bool forward) { @@ -78,9 +77,8 @@ void findWordBoundary(UChar const* buffer, int len, int position, int* start, in } #else -namespace WebCore -{ - +namespace WebCore { + int findNextWordFromIndex(UChar const* buffer, int len, int position, bool forward) { QString str(reinterpret_cast<QChar const*>(buffer), len); diff --git a/src/3rdparty/webkit/WebCore/platform/text/qt/TextBreakIteratorQt.cpp b/src/3rdparty/webkit/WebCore/platform/text/qt/TextBreakIteratorQt.cpp index 06e8f3741..d80e270b7 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/qt/TextBreakIteratorQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/qt/TextBreakIteratorQt.cpp @@ -36,8 +36,7 @@ namespace WebCore { - class TextBreakIterator : public QTextBoundaryFinder - { + class TextBreakIterator : public QTextBoundaryFinder { }; static QTextBoundaryFinder* iterator = 0; static unsigned char buffer[1024]; @@ -138,17 +137,18 @@ namespace WebCore { namespace WebCore { - class TextBreakIterator - { + class TextBreakIterator { public: virtual int first() = 0; virtual int next() = 0; virtual int previous() = 0; - inline int following(int pos) { + inline int following(int pos) + { currentPos = pos; return next(); } - inline int preceding(int pos) { + inline int preceding(int pos) + { currentPos = pos; return previous(); } @@ -157,16 +157,14 @@ namespace WebCore { int length; }; - class WordBreakIteratorQt : public TextBreakIterator - { + class WordBreakIteratorQt : public TextBreakIterator { public: virtual int first(); virtual int next(); virtual int previous(); }; - class CharBreakIteratorQt : public TextBreakIterator - { + class CharBreakIteratorQt : public TextBreakIterator { public: virtual int first(); virtual int next(); @@ -174,12 +172,14 @@ namespace WebCore { QTextLayout layout; }; - int WordBreakIteratorQt::first() { + int WordBreakIteratorQt::first() + { currentPos = 0; return currentPos; } - int WordBreakIteratorQt::next() { + int WordBreakIteratorQt::next() + { if (currentPos >= length) { currentPos = -1; return currentPos; @@ -194,7 +194,9 @@ namespace WebCore { } return currentPos; } - int WordBreakIteratorQt::previous() { + + int WordBreakIteratorQt::previous() + { if (currentPos <= 0) { currentPos = -1; return currentPos; @@ -210,18 +212,22 @@ namespace WebCore { return currentPos; } - int CharBreakIteratorQt::first() { + int CharBreakIteratorQt::first() + { currentPos = 0; return currentPos; } - int CharBreakIteratorQt::next() { + int CharBreakIteratorQt::next() + { if (currentPos >= length) return -1; currentPos = layout.nextCursorPosition(currentPos); return currentPos; } - int CharBreakIteratorQt::previous() { + + int CharBreakIteratorQt::previous() + { if (currentPos <= 0) return -1; currentPos = layout.previousCursorPosition(currentPos); @@ -252,7 +258,7 @@ TextBreakIterator* characterBreakIterator(const UChar* string, int length) iterator->length = length; iterator->currentPos = 0; iterator->layout.setText(QString(reinterpret_cast<const QChar*>(string), length)); - + return iterator; } |