diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/platform/text')
9 files changed, 134 insertions, 106 deletions
diff --git a/src/3rdparty/webkit/WebCore/platform/text/BidiResolver.h b/src/3rdparty/webkit/WebCore/platform/text/BidiResolver.h index b6c2e88..286cdcd 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/BidiResolver.h +++ b/src/3rdparty/webkit/WebCore/platform/text/BidiResolver.h @@ -29,6 +29,28 @@ namespace WebCore { +template <class Iterator> struct MidpointState { + MidpointState() + { + reset(); + } + + void reset() + { + numMidpoints = 0; + currentMidpoint = 0; + betweenMidpoints = false; + } + + // The goal is to reuse the line state across multiple + // lines so we just keep an array around for midpoints and never clear it across multiple + // lines. We track the number of items and position using the two other variables. + Vector<Iterator> midpoints; + unsigned numMidpoints; + unsigned currentMidpoint; + bool betweenMidpoints; +}; + // The BidiStatus at a given position (typically the end of a line) can // be cached and then used to restart bidi resolution at that position. struct BidiStatus { @@ -135,6 +157,8 @@ public : const BidiStatus& status() const { return m_status; } void setStatus(const BidiStatus s) { m_status = s; } + MidpointState<Iterator>& midpointState() { return m_midpointState; } + void embed(WTF::Unicode::Direction); void commitExplicitEmbedding(); @@ -172,6 +196,7 @@ protected: Run* m_lastRun; Run* m_logicallyLastRun; unsigned m_runCount; + MidpointState<Iterator> m_midpointState; private: void raiseExplicitEmbeddingLevel(WTF::Unicode::Direction from, WTF::Unicode::Direction to); diff --git a/src/3rdparty/webkit/WebCore/platform/text/PlatformString.h b/src/3rdparty/webkit/WebCore/platform/text/PlatformString.h index 1cc60b2..ee2c8ce 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/PlatformString.h +++ b/src/3rdparty/webkit/WebCore/platform/text/PlatformString.h @@ -49,6 +49,7 @@ typedef const struct __CFString * CFStringRef; QT_BEGIN_NAMESPACE class QString; QT_END_NAMESPACE +#include <QDataStream> #endif #if PLATFORM(WX) @@ -176,11 +177,13 @@ public: unsigned toUIntStrict(bool* ok = 0, int base = 10) const; int64_t toInt64Strict(bool* ok = 0, int base = 10) const; uint64_t toUInt64Strict(bool* ok = 0, int base = 10) const; + intptr_t toIntPtrStrict(bool* ok = 0, int base = 10) const; int toInt(bool* ok = 0) const; unsigned toUInt(bool* ok = 0) const; int64_t toInt64(bool* ok = 0) const; uint64_t toUInt64(bool* ok = 0) const; + intptr_t toIntPtr(bool* ok = 0) const; double toDouble(bool* ok = 0) const; float toFloat(bool* ok = 0) const; @@ -246,6 +249,11 @@ private: RefPtr<StringImpl> m_impl; }; +#if PLATFORM(QT) +QDataStream& operator<<(QDataStream& stream, const String& str); +QDataStream& operator>>(QDataStream& stream, String& str); +#endif + String operator+(const String&, const String&); String operator+(const String&, const char*); String operator+(const char*, const String&); @@ -276,11 +284,13 @@ int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10); unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10); int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10); uint64_t charactersToUInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10); +intptr_t charactersToIntPtrStrict(const UChar*, size_t, bool* ok = 0, int base = 10); int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage unsigned charactersToUInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage +intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage double charactersToDouble(const UChar*, size_t, bool* ok = 0); float charactersToFloat(const UChar*, size_t, bool* ok = 0); diff --git a/src/3rdparty/webkit/WebCore/platform/text/String.cpp b/src/3rdparty/webkit/WebCore/platform/text/String.cpp index cd87e2c..97e2d4d 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/String.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/String.cpp @@ -484,6 +484,17 @@ uint64_t String::toUInt64Strict(bool* ok, int base) const return m_impl->toUInt64Strict(ok, base); } +intptr_t String::toIntPtrStrict(bool* ok, int base) const +{ + if (!m_impl) { + if (ok) + *ok = false; + return 0; + } + return m_impl->toIntPtrStrict(ok, base); +} + + int String::toInt(bool* ok) const { if (!m_impl) { @@ -524,6 +535,16 @@ uint64_t String::toUInt64(bool* ok) const return m_impl->toUInt64(ok); } +intptr_t String::toIntPtr(bool* ok) const +{ + if (!m_impl) { + if (ok) + *ok = false; + return 0; + } + return m_impl->toIntPtr(ok); +} + double String::toDouble(bool* ok) const { if (!m_impl) { @@ -804,6 +825,11 @@ uint64_t charactersToUInt64Strict(const UChar* data, size_t length, bool* ok, in return toIntegralType<uint64_t>(data, length, ok, base); } +intptr_t charactersToIntPtrStrict(const UChar* data, size_t length, bool* ok, int base) +{ + return toIntegralType<intptr_t>(data, length, ok, base); +} + int charactersToInt(const UChar* data, size_t length, bool* ok) { return toIntegralType<int>(data, lengthOfCharactersAsInteger(data, length), ok, 10); @@ -824,6 +850,11 @@ uint64_t charactersToUInt64(const UChar* data, size_t length, bool* ok) return toIntegralType<uint64_t>(data, lengthOfCharactersAsInteger(data, length), ok, 10); } +intptr_t charactersToIntPtr(const UChar* data, size_t length, bool* ok) +{ + return toIntegralType<intptr_t>(data, lengthOfCharactersAsInteger(data, length), ok, 10); +} + double charactersToDouble(const UChar* data, size_t length, bool* ok) { if (!length) { diff --git a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp index 8bc4dde..cd8fdbd 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.cpp @@ -486,6 +486,11 @@ uint64_t StringImpl::toUInt64Strict(bool* ok, int base) return charactersToUInt64Strict(m_data, m_length, ok, base); } +intptr_t StringImpl::toIntPtrStrict(bool* ok, int base) +{ + return charactersToIntPtrStrict(m_data, m_length, ok, base); +} + int StringImpl::toInt(bool* ok) { return charactersToInt(m_data, m_length, ok); @@ -506,6 +511,11 @@ uint64_t StringImpl::toUInt64(bool* ok) return charactersToUInt64(m_data, m_length, ok); } +intptr_t StringImpl::toIntPtr(bool* ok) +{ + return charactersToIntPtr(m_data, m_length, ok); +} + double StringImpl::toDouble(bool* ok) { return charactersToDouble(m_data, m_length, ok); @@ -1026,7 +1036,7 @@ PassRefPtr<StringImpl> StringImpl::create(const char* string) #if USE(JSC) PassRefPtr<StringImpl> StringImpl::create(const JSC::UString& str) { - SharedUChar* sharedBuffer = const_cast<JSC::UString*>(&str)->rep()->baseString()->sharedBuffer(); + SharedUChar* sharedBuffer = const_cast<JSC::UString*>(&str)->rep()->sharedBuffer(); if (sharedBuffer) { PassRefPtr<StringImpl> impl = adoptRef(new StringImpl(const_cast<UChar*>(str.data()), str.size(), AdoptBuffer())); sharedBuffer->ref(); @@ -1038,7 +1048,7 @@ PassRefPtr<StringImpl> StringImpl::create(const JSC::UString& str) JSC::UString StringImpl::ustring() { - SharedUChar* sharedBuffer = StringImpl::sharedBuffer(); + SharedUChar* sharedBuffer = this->sharedBuffer(); if (sharedBuffer) return JSC::UString::Rep::create(const_cast<UChar*>(m_data), m_length, sharedBuffer); @@ -1053,7 +1063,8 @@ PassRefPtr<StringImpl> StringImpl::createWithTerminatingNullCharacter(const Stri PassRefPtr<StringImpl> StringImpl::copy() { - return create(m_data, m_length); + // Using the constructor directly to make sure that per-thread empty string instance isn't returned. + return adoptRef(new StringImpl(m_data, m_length)); } StringImpl::SharedUChar* StringImpl::sharedBuffer() diff --git a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h index f591800..38439ed 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h +++ b/src/3rdparty/webkit/WebCore/platform/text/StringImpl.h @@ -135,11 +135,13 @@ public: unsigned toUIntStrict(bool* ok = 0, int base = 10); int64_t toInt64Strict(bool* ok = 0, int base = 10); uint64_t toUInt64Strict(bool* ok = 0, int base = 10); + intptr_t toIntPtrStrict(bool* ok = 0, int base = 10); int toInt(bool* ok = 0); // ignores trailing garbage unsigned toUInt(bool* ok = 0); // ignores trailing garbage int64_t toInt64(bool* ok = 0); // ignores trailing garbage uint64_t toUInt64(bool* ok = 0); // ignores trailing garbage + intptr_t toIntPtr(bool* ok = 0); // ignores trailing garbage double toDouble(bool* ok = 0); float toFloat(bool* ok = 0); diff --git a/src/3rdparty/webkit/WebCore/platform/text/android/TextBreakIteratorInternalICU.cpp b/src/3rdparty/webkit/WebCore/platform/text/android/TextBreakIteratorInternalICU.cpp new file mode 100644 index 0000000..9bebe74 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/text/android/TextBreakIteratorInternalICU.cpp @@ -0,0 +1,36 @@ +/* + * Copyright 2007, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "TextBreakIteratorInternalICU.h" + +namespace WebCore { + +const char* currentTextBreakLocaleID() +{ + return "en_us"; +} + +} diff --git a/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp b/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp index de9f527..97bbf40 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/text/qt/StringQt.cpp @@ -51,6 +51,22 @@ String::operator QString() const return QString(reinterpret_cast<const QChar*>(characters()), length()); } +QDataStream& operator<<(QDataStream& stream, const String& str) +{ + // could be faster + stream << QString(str); + return stream; +} + +QDataStream& operator>>(QDataStream& stream, String& str) +{ + // mabe not the fastest way, but really easy + QString tmp; + stream >> tmp; + str = tmp; + return stream; +} + } // vim: ts=4 sw=4 et diff --git a/src/3rdparty/webkit/WebCore/platform/text/symbian/StringImplSymbian.cpp b/src/3rdparty/webkit/WebCore/platform/text/symbian/StringImplSymbian.cpp deleted file mode 100644 index 3a1245f..0000000 --- a/src/3rdparty/webkit/WebCore/platform/text/symbian/StringImplSymbian.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -* ============================================================================== -* Copyright (c) 2006, Nokia Corporation -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* * Neither the name of the Nokia Corporation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -* -* ============================================================================== -*/ - -#include "config.h" -#include "StringImpl.h" -#include <e32std.h> - -namespace WebCore { - -StringImpl::StringImpl(const TDesC& des) -{ - init(des.Ptr(), des.Length()); -} - -TPtrC StringImpl::des() const -{ - TPtrC tstr((const TUint16 *)m_data, m_length); - return tstr; -} - -} diff --git a/src/3rdparty/webkit/WebCore/platform/text/symbian/StringSymbian.cpp b/src/3rdparty/webkit/WebCore/platform/text/symbian/StringSymbian.cpp deleted file mode 100644 index 27b6a13..0000000 --- a/src/3rdparty/webkit/WebCore/platform/text/symbian/StringSymbian.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -* ============================================================================== -* Copyright (c) 2006, Nokia Corporation -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* * Neither the name of the Nokia Corporation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -* -* ============================================================================== -*/ - -#include "config.h" -#include "PlatformString.h" -#include <e32std.h> - -namespace WebCore { - -String::String(const TDesC& des) -{ - if (!des.Length()) - m_impl = StringImpl::empty(); - else - m_impl = new StringImpl(des); -} - -}
\ No newline at end of file |