summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/text
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-08-19 17:55:56 +0100
committerIain Merrick <husky@google.com>2010-08-23 11:05:40 +0100
commitf486d19d62f1bc33246748b14b14a9dfa617b57f (patch)
tree195485454c93125455a30e553a73981c3816144d /WebCore/platform/text
parent6ba0b43722d16bc295606bec39f396f596e4fef1 (diff)
downloadexternal_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.zip
external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.gz
external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.bz2
Merge WebKit at r65615 : Initial merge by git.
Change-Id: Ifbf384f4531e3b58475a662e38195c2d9152ae79
Diffstat (limited to 'WebCore/platform/text')
-rw-r--r--WebCore/platform/text/AtomicString.h27
-rw-r--r--WebCore/platform/text/AtomicStringHash.h64
-rw-r--r--WebCore/platform/text/AtomicStringImpl.h27
-rw-r--r--WebCore/platform/text/AtomicStringKeyedMRUCache.h2
-rw-r--r--WebCore/platform/text/SegmentedString.cpp15
-rw-r--r--WebCore/platform/text/SegmentedString.h32
-rw-r--r--WebCore/platform/text/StringBuilder.cpp2
-rw-r--r--WebCore/platform/text/StringHash.h28
-rw-r--r--WebCore/platform/text/StringImpl.h29
-rw-r--r--WebCore/platform/text/TextBoundaries.cpp2
-rw-r--r--WebCore/platform/text/TextCodecLatin1.cpp2
-rw-r--r--WebCore/platform/text/TextCodecUTF16.cpp2
-rw-r--r--WebCore/platform/text/TextCodecUserDefined.cpp2
-rw-r--r--WebCore/platform/text/cf/HyphenationCF.cpp1
-rw-r--r--WebCore/platform/text/cf/StringImplCF.cpp2
-rw-r--r--WebCore/platform/text/mac/HyphenationMac.mm1
-rw-r--r--WebCore/platform/text/mac/StringImplMac.mm2
-rw-r--r--WebCore/platform/text/transcoder/FontTranscoder.h2
-rw-r--r--WebCore/platform/text/wince/TextCodecWinCE.cpp2
19 files changed, 55 insertions, 189 deletions
diff --git a/WebCore/platform/text/AtomicString.h b/WebCore/platform/text/AtomicString.h
deleted file mode 100644
index 6ce63b5..0000000
--- a/WebCore/platform/text/AtomicString.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef WebCoreAtomicString_h
-#define WebCoreAtomicString_h
-
-// FIXME: remove this header, use the forward from wtf directly.
-#include <wtf/text/AtomicString.h>
-
-#endif // AtomicString_h
diff --git a/WebCore/platform/text/AtomicStringHash.h b/WebCore/platform/text/AtomicStringHash.h
deleted file mode 100644
index d13332b..0000000
--- a/WebCore/platform/text/AtomicStringHash.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
- */
-
-#ifndef AtomicStringHash_h
-#define AtomicStringHash_h
-
-#include "AtomicString.h"
-#include <wtf/HashTraits.h>
-
-namespace WebCore {
-
- struct AtomicStringHash {
- static unsigned hash(const AtomicString& key)
- {
- return key.impl()->existingHash();
- }
-
- static bool equal(const AtomicString& a, const AtomicString& b)
- {
- return a == b;
- }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
-}
-
-namespace WTF {
-
- // WebCore::AtomicStringHash is the default hash for AtomicString
- template<> struct HashTraits<WTF::AtomicString> : GenericHashTraits<WTF::AtomicString> {
- static const bool emptyValueIsZero = true;
- static void constructDeletedValue(WTF::AtomicString& slot) { new (&slot) WTF::AtomicString(HashTableDeletedValue); }
- static bool isDeletedValue(const WTF::AtomicString& slot) { return slot.isHashTableDeletedValue(); }
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/text/AtomicStringImpl.h b/WebCore/platform/text/AtomicStringImpl.h
deleted file mode 100644
index 64bce77..0000000
--- a/WebCore/platform/text/AtomicStringImpl.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef WebCoreAtomicStringImpl_h
-#define WebCoreAtomicStringImpl_h
-
-// FIXME: remove this header, use the forward from wtf directly.
-#include <wtf/text/AtomicStringImpl.h>
-
-#endif
diff --git a/WebCore/platform/text/AtomicStringKeyedMRUCache.h b/WebCore/platform/text/AtomicStringKeyedMRUCache.h
index a47585a..b3004f7 100644
--- a/WebCore/platform/text/AtomicStringKeyedMRUCache.h
+++ b/WebCore/platform/text/AtomicStringKeyedMRUCache.h
@@ -26,6 +26,8 @@
#ifndef AtomicStringKeyedMRUCache_h
#define AtomicStringKeyedMRUCache_h
+#include <wtf/text/AtomicString.h>
+
namespace WebCore {
template<typename T, size_t capacity = 4>
diff --git a/WebCore/platform/text/SegmentedString.cpp b/WebCore/platform/text/SegmentedString.cpp
index 04d6c77..b9ff503 100644
--- a/WebCore/platform/text/SegmentedString.cpp
+++ b/WebCore/platform/text/SegmentedString.cpp
@@ -52,6 +52,7 @@ const SegmentedString& SegmentedString::operator=(const SegmentedString &other)
else
m_currentChar = other.m_currentChar;
m_closed = other.m_closed;
+ m_numberOfCharactersConsumedPriorToCurrentString = other.m_numberOfCharactersConsumedPriorToCurrentString;
return *this;
}
@@ -99,6 +100,7 @@ void SegmentedString::append(const SegmentedSubstring &s)
ASSERT(!m_closed);
if (s.m_length) {
if (!m_currentString.m_length) {
+ m_numberOfCharactersConsumedPriorToCurrentString += m_currentString.numberOfCharactersConsumed();
m_currentString = s;
} else {
m_substrings.append(s);
@@ -110,7 +112,15 @@ void SegmentedString::append(const SegmentedSubstring &s)
void SegmentedString::prepend(const SegmentedSubstring &s)
{
ASSERT(!escaped());
+ ASSERT(!s.numberOfCharactersConsumed());
if (s.m_length) {
+ // FIXME: We're assuming that the prepend were originally consumed by
+ // this SegmentedString. We're also ASSERTing that s is a fresh
+ // SegmentedSubstring. These assumptions are sufficient for our
+ // current use, but we might need to handle the more elaborate
+ // cases in the future.
+ m_numberOfCharactersConsumedPriorToCurrentString += m_currentString.numberOfCharactersConsumed();
+ m_numberOfCharactersConsumedPriorToCurrentString -= s.m_length;
if (!m_currentString.m_length)
m_currentString = s;
else {
@@ -160,7 +170,12 @@ void SegmentedString::prepend(const SegmentedString &s)
void SegmentedString::advanceSubstring()
{
if (m_composite) {
+ m_numberOfCharactersConsumedPriorToCurrentString += m_currentString.numberOfCharactersConsumed();
m_currentString = m_substrings.takeFirst();
+ // If we've previously consumed some characters of the non-current
+ // string, we now account for those characters as part of the current
+ // string, not as part of "prior to current string."
+ m_numberOfCharactersConsumedPriorToCurrentString -= m_currentString.numberOfCharactersConsumed();
if (m_substrings.isEmpty())
m_composite = false;
} else {
diff --git a/WebCore/platform/text/SegmentedString.h b/WebCore/platform/text/SegmentedString.h
index 1d3098d..91c2cbe 100644
--- a/WebCore/platform/text/SegmentedString.h
+++ b/WebCore/platform/text/SegmentedString.h
@@ -45,6 +45,8 @@ public:
void setExcludeLineNumbers() { m_doNotExcludeLineNumbers = false; }
+ int numberOfCharactersConsumed() const { return m_string.length() - m_length; }
+
void appendTo(String& str) const
{
if (m_string.characters() == m_current) {
@@ -69,10 +71,26 @@ private:
class SegmentedString {
public:
SegmentedString()
- : m_pushedChar1(0), m_pushedChar2(0), m_currentChar(0), m_composite(false), m_closed(false) {}
+ : m_pushedChar1(0)
+ , m_pushedChar2(0)
+ , m_currentChar(0)
+ , m_numberOfCharactersConsumedPriorToCurrentString(0)
+ , m_composite(false)
+ , m_closed(false)
+ {
+ }
+
SegmentedString(const String& str)
- : m_pushedChar1(0), m_pushedChar2(0), m_currentString(str)
- , m_currentChar(m_currentString.m_current), m_composite(false), m_closed(false) {}
+ : m_pushedChar1(0)
+ , m_pushedChar2(0)
+ , m_currentString(str)
+ , m_currentChar(m_currentString.m_current)
+ , m_numberOfCharactersConsumedPriorToCurrentString(0)
+ , m_composite(false)
+ , m_closed(false)
+ {
+ }
+
SegmentedString(const SegmentedString&);
const SegmentedString& operator=(const SegmentedString&);
@@ -173,6 +191,13 @@ public:
bool escaped() const { return m_pushedChar1; }
+ int numberOfCharactersConsumed()
+ {
+ // We don't currently handle the case when there are pushed character.
+ ASSERT(!m_pushedChar1);
+ return m_numberOfCharactersConsumedPriorToCurrentString + m_currentString.numberOfCharactersConsumed();
+ }
+
String toString() const;
const UChar& operator*() const { return *current(); }
@@ -221,6 +246,7 @@ private:
UChar m_pushedChar2;
SegmentedSubstring m_currentString;
const UChar* m_currentChar;
+ int m_numberOfCharactersConsumedPriorToCurrentString;
Deque<SegmentedSubstring> m_substrings;
bool m_composite;
bool m_closed;
diff --git a/WebCore/platform/text/StringBuilder.cpp b/WebCore/platform/text/StringBuilder.cpp
index 213daab..1c47129 100644
--- a/WebCore/platform/text/StringBuilder.cpp
+++ b/WebCore/platform/text/StringBuilder.cpp
@@ -30,7 +30,7 @@
#include "config.h"
#include "StringBuilder.h"
-#include "StringBuffer.h"
+#include <wtf/text/StringBuffer.h>
namespace WebCore {
diff --git a/WebCore/platform/text/StringHash.h b/WebCore/platform/text/StringHash.h
deleted file mode 100644
index 35de30d..0000000
--- a/WebCore/platform/text/StringHash.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved
- * Copyright (C) Research In Motion Limited 2009. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef WebCoreStringHash_h
-#define WebCoreStringHash_h
-
-// FIXME: remove this header, use the forward from wtf directly.
-#include <wtf/text/StringHash.h>
-
-#endif
diff --git a/WebCore/platform/text/StringImpl.h b/WebCore/platform/text/StringImpl.h
deleted file mode 100644
index fa79b61..0000000
--- a/WebCore/platform/text/StringImpl.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef WebCoreStringImpl_h
-#define WebCoreStringImpl_h
-
-// FIXME: remove this header, use the forward from wtf directly.
-#include <wtf/text/StringImpl.h>
-
-#endif
diff --git a/WebCore/platform/text/TextBoundaries.cpp b/WebCore/platform/text/TextBoundaries.cpp
index 2455f6d..8eaffca 100644
--- a/WebCore/platform/text/TextBoundaries.cpp
+++ b/WebCore/platform/text/TextBoundaries.cpp
@@ -27,8 +27,8 @@
#include "config.h"
#include "TextBoundaries.h"
-#include "StringImpl.h"
#include "TextBreakIterator.h"
+#include <wtf/text/StringImpl.h>
#include <wtf/unicode/Unicode.h>
using namespace WTF;
diff --git a/WebCore/platform/text/TextCodecLatin1.cpp b/WebCore/platform/text/TextCodecLatin1.cpp
index 1e9385d..4f9cbe0 100644
--- a/WebCore/platform/text/TextCodecLatin1.cpp
+++ b/WebCore/platform/text/TextCodecLatin1.cpp
@@ -27,9 +27,9 @@
#include "TextCodecLatin1.h"
#include "PlatformString.h"
-#include "StringBuffer.h"
#include <stdio.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuffer.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
diff --git a/WebCore/platform/text/TextCodecUTF16.cpp b/WebCore/platform/text/TextCodecUTF16.cpp
index 16f8431..5c23732 100644
--- a/WebCore/platform/text/TextCodecUTF16.cpp
+++ b/WebCore/platform/text/TextCodecUTF16.cpp
@@ -27,8 +27,8 @@
#include "TextCodecUTF16.h"
#include "PlatformString.h"
-#include "StringBuffer.h"
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuffer.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
diff --git a/WebCore/platform/text/TextCodecUserDefined.cpp b/WebCore/platform/text/TextCodecUserDefined.cpp
index 851d693..70d8673 100644
--- a/WebCore/platform/text/TextCodecUserDefined.cpp
+++ b/WebCore/platform/text/TextCodecUserDefined.cpp
@@ -27,9 +27,9 @@
#include "TextCodecUserDefined.h"
#include "PlatformString.h"
-#include "StringBuffer.h"
#include <stdio.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuffer.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
diff --git a/WebCore/platform/text/cf/HyphenationCF.cpp b/WebCore/platform/text/cf/HyphenationCF.cpp
index b983979..8be537d 100644
--- a/WebCore/platform/text/cf/HyphenationCF.cpp
+++ b/WebCore/platform/text/cf/HyphenationCF.cpp
@@ -28,7 +28,6 @@
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
-#include "AtomicString.h"
#include "AtomicStringKeyedMRUCache.h"
#include "TextBreakIteratorInternalICU.h"
#include <wtf/ListHashSet.h>
diff --git a/WebCore/platform/text/cf/StringImplCF.cpp b/WebCore/platform/text/cf/StringImplCF.cpp
index 18e137f..0157918 100644
--- a/WebCore/platform/text/cf/StringImplCF.cpp
+++ b/WebCore/platform/text/cf/StringImplCF.cpp
@@ -19,7 +19,7 @@
*/
#include "config.h"
-#include "StringImpl.h"
+#include <wtf/text/StringImpl.h>
#if PLATFORM(CF)
diff --git a/WebCore/platform/text/mac/HyphenationMac.mm b/WebCore/platform/text/mac/HyphenationMac.mm
index 56122df..d5c9283 100644
--- a/WebCore/platform/text/mac/HyphenationMac.mm
+++ b/WebCore/platform/text/mac/HyphenationMac.mm
@@ -28,7 +28,6 @@
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
-#import "AtomicString.h"
#import "AtomicStringKeyedMRUCache.h"
#import "TextBreakIteratorInternalICU.h"
#import "WebCoreSystemInterface.h"
diff --git a/WebCore/platform/text/mac/StringImplMac.mm b/WebCore/platform/text/mac/StringImplMac.mm
index 843f396..6f5e953 100644
--- a/WebCore/platform/text/mac/StringImplMac.mm
+++ b/WebCore/platform/text/mac/StringImplMac.mm
@@ -19,7 +19,7 @@
*/
#include "config.h"
-#include "StringImpl.h"
+#include <wtf/text/StringImpl.h>
#include "FoundationExtras.h"
diff --git a/WebCore/platform/text/transcoder/FontTranscoder.h b/WebCore/platform/text/transcoder/FontTranscoder.h
index 1fdc936..67db977 100644
--- a/WebCore/platform/text/transcoder/FontTranscoder.h
+++ b/WebCore/platform/text/transcoder/FontTranscoder.h
@@ -31,9 +31,9 @@
#ifndef FontTranscoder_h
#define FontTranscoder_h
-#include "AtomicStringHash.h"
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
+#include <wtf/text/AtomicStringHash.h>
namespace WebCore {
diff --git a/WebCore/platform/text/wince/TextCodecWinCE.cpp b/WebCore/platform/text/wince/TextCodecWinCE.cpp
index 644b12f..578f789 100644
--- a/WebCore/platform/text/wince/TextCodecWinCE.cpp
+++ b/WebCore/platform/text/wince/TextCodecWinCE.cpp
@@ -27,13 +27,13 @@
#include "ce_textcodecs.h"
#include "FontCache.h"
#include "PlatformString.h"
-#include "StringHash.h"
#include <mlang.h>
#include <winbase.h>
#include <winnls.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
#include <wtf/unicode/UTF8.h>
namespace WebCore {