Reviewed by Darin.
Add String::split which returns a Vector of Strings and use it instead of
DeprecatedStringList.
* bindings/js/kjs_events.cpp:
(KJS::Clipboard::getValueProperty):
* bindings/js/kjs_window.cpp:
(KJS::parseModalDialogFeatures):
* css/MediaList.cpp:
(WebCore::MediaList::setMediaText):
* dom/Clipboard.h:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::formData):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::tokenizeRelAttribute):
* platform/PlatformString.h:
* platform/String.cpp:
(WebCore::String::split):
* platform/StringImpl.cpp:
* platform/StringImpl.h:
* platform/mac/ClipboardMac.h:
* platform/mac/ClipboardMac.mm:
(WebCore::ClipboardMac::types):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16479
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-09-20 Anders Carlsson <acarlsson@apple.com>
+
+ Reviewed by Darin.
+
+ Add String::split which returns a Vector of Strings and use it instead of
+ DeprecatedStringList.
+
+ * bindings/js/kjs_events.cpp:
+ (KJS::Clipboard::getValueProperty):
+ * bindings/js/kjs_window.cpp:
+ (KJS::parseModalDialogFeatures):
+ * css/MediaList.cpp:
+ (WebCore::MediaList::setMediaText):
+ * dom/Clipboard.h:
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::formData):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::tokenizeRelAttribute):
+ * platform/PlatformString.h:
+ * platform/String.cpp:
+ (WebCore::String::split):
+ * platform/StringImpl.cpp:
+ * platform/StringImpl.h:
+ * platform/mac/ClipboardMac.h:
+ * platform/mac/ClipboardMac.mm:
+ (WebCore::ClipboardMac::types):
+
2006-09-20 Justin Garcia <justin.garcia@apple.com>
Reviewed by harrison
return jsStringOrUndefined(clipboard->effectAllowed());
case Types:
{
- DeprecatedStringList qTypes = clipboard->types();
- if (qTypes.isEmpty())
+ HashSet<String> types = clipboard->types();
+ if (types.isEmpty())
return jsNull();
else {
List list;
- for (DeprecatedStringList::Iterator it = qTypes.begin(); it != qTypes.end(); ++it) {
+ HashSet<String>::const_iterator end = types.end();
+ for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it)
list.append(jsString(UString(*it)));
- }
return exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
}
}
{
HashMap<String, String> map;
- DeprecatedStringList features = DeprecatedStringList::split(';', featuresArg->toString(exec));
- DeprecatedStringList::ConstIterator end = features.end();
- for (DeprecatedStringList::ConstIterator it = features.begin(); it != end; ++it) {
- DeprecatedString s = *it;
+ Vector<String> features = String(featuresArg->toString(exec)).split(';');
+ Vector<String>::const_iterator end = features.end();
+ for (Vector<String>::const_iterator it = features.begin(); it != end; ++it) {
+ String s = *it;
int pos = s.find('=');
int colonPos = s.find(':');
if (pos >= 0 && colonPos >= 0)
// null string for value means key without value
map.set(s.stripWhiteSpace().lower(), String());
} else {
- DeprecatedString key = s.left(pos).stripWhiteSpace().lower();
- DeprecatedString val = s.mid(pos + 1).stripWhiteSpace().lower();
+ String key = s.left(pos).stripWhiteSpace().lower();
+ String val = s.substring(pos + 1).stripWhiteSpace().lower();
int spacePos = val.find(' ');
if (spacePos != -1)
val = val.left(spacePos);
MediaList tempMediaList;
CSSParser p(true);
- DeprecatedStringList list = DeprecatedStringList::split(',', value.deprecatedString());
- for (DeprecatedStringList::Iterator it = list.begin(); it != list.end(); ++it) {
+ Vector<String> list = value.split(',');
+ Vector<String>::const_iterator end = list.end();
+ for (Vector<String>::const_iterator it = list.begin(); it != end; ++it) {
String medium = (*it).stripWhiteSpace();
if (!medium.isEmpty()) {
if (!p.parseMediaQuery(&tempMediaList, medium)) {
#ifndef Clipboard_h
#define Clipboard_h
+#include <wtf/HashSet.h>
#include "AtomicString.h"
#include "Node.h"
#include "Shared.h"
namespace WebCore {
class CachedImage;
- class DeprecatedStringList;
class IntPoint;
// State available during IE's events for drag and drop and copy/paste
virtual bool setData(const String& type, const String& data) = 0;
// extensions beyond IE's API
- virtual DeprecatedStringList types() const = 0;
+ virtual HashSet<String> types() const = 0;
virtual IntPoint dragLocation() const = 0;
virtual CachedImage* dragImage() const = 0;
{
DeprecatedCString enc_string = ""; // used for non-multipart data
- DeprecatedString str = m_acceptcharset.deprecatedString();
+ String str = m_acceptcharset;
str.replace(',', ' ');
- DeprecatedStringList charsets = DeprecatedStringList::split(' ', str);
+ Vector<String> charsets = str.split(' ');
TextEncoding encoding;
Frame* frame = document()->frame();
- for (DeprecatedStringList::Iterator it = charsets.begin(); it != charsets.end(); ++it)
+ Vector<String>::const_iterator end = charsets.end();
+ for (Vector<String>::const_iterator it = charsets.begin(); it != end; ++it)
if ((encoding = TextEncoding(*it)).isValid())
break;
if (!encoding.isValid()) {
void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& relStr)
{
m_isStyleSheet = m_isIcon = m_alternate = false;
- DeprecatedString rel = relStr.deprecatedString().lower();
+ String rel = relStr.domString().lower();
if (rel == "stylesheet")
m_isStyleSheet = true;
else if (rel == "icon" || rel == "shortcut icon")
else {
// Tokenize the rel attribute and set bits based on specific keywords that we find.
rel.replace('\n', ' ');
- DeprecatedStringList list = DeprecatedStringList::split(' ', rel);
- for (DeprecatedStringList::Iterator i = list.begin(); i != list.end(); ++i) {
- if (*i == "stylesheet")
+ Vector<String> list = rel.split(' ');
+ Vector<String>::const_iterator end = list.end();
+ for (Vector<String>::const_iterator it = list.begin(); it != end; ++it) {
+ if (*it == "stylesheet")
m_isStyleSheet = true;
- else if (*i == "alternate")
+ else if (*it == "alternate")
m_alternate = true;
- else if (*i == "icon")
+ else if (*it == "icon")
m_isIcon = true;
}
}
String left(unsigned len) const { return substring(0, len); }
String right(unsigned len) const { return substring(length() - len, len); }
- // Splits the string into two. The original string gets truncated to pos, and the rest is returned.
- String split(unsigned pos);
-
// Returns a lowercase/uppercase version of the string
String lower() const;
String upper() const;
#endif
;
+ Vector<String> split(const String& separator, bool allowEmptyEntries = false) const;
+ Vector<String> split(UChar separator, bool allowEmptyEntries = false) const;
+
int toInt(bool* ok = 0) const;
Length* toLengthArray(int& len) const;
Length* toCoordsArray(int& len) const;
return m_impl->substring(pos, len);
}
-String String::split(unsigned pos)
-{
- if (!m_impl)
- return String();
- return m_impl->split(pos);
-}
-
String String::lower() const
{
if (!m_impl)
return m_impl ? m_impl->toLengthArray(len) : 0;
}
+Vector<String> String::split(const String& separator, bool allowEmptyEntries) const
+{
+ Vector<String> result;
+
+ int startPos = 0;
+ int endPos;
+ while ((endPos = find(separator, startPos)) != -1) {
+ if (allowEmptyEntries || startPos != endPos)
+ result.append(substring(startPos, endPos - startPos));
+ startPos = endPos + separator.length();
+ }
+ if (allowEmptyEntries || startPos != (int)length())
+ result.append(substring(startPos));
+
+ return result;
+}
+
+Vector<String> String::split(UChar separator, bool allowEmptyEntries) const
+{
+ Vector<String> result;
+
+ return split(String(&separator, 1), allowEmptyEntries);
+}
+
#ifndef NDEBUG
Vector<char> String::ascii() const
{
m_hasTerminatingNullCharacter = false;
}
-StringImpl* StringImpl::split(unsigned pos)
-{
- assert(!m_inTable);
- if( pos >=m_length ) return new StringImpl();
-
- unsigned newLen = m_length-pos;
- UChar* c = newUCharVector(newLen);
- memcpy(c, m_data + pos, newLen * sizeof(UChar));
-
- StringImpl* str = new StringImpl(m_data + pos, newLen);
- truncate(pos);
- return str;
-}
-
bool StringImpl::containsOnlyWhitespace() const
{
return containsOnlyWhitespace(0, m_length);
void truncate(int len);
void remove(unsigned pos, int len = 1);
- StringImpl* split(unsigned pos);
StringImpl* copy() const { return new StringImpl(m_data, m_length); }
StringImpl* substring(unsigned pos, unsigned len = UINT_MAX);
namespace WebCore {
-class DeprecatedStringList;
class FrameMac;
class ClipboardMac : public Clipboard, public CachedResourceClient {
bool setData(const String &type, const String &data);
// extensions beyond IE's API
- virtual DeprecatedStringList types() const;
+ virtual HashSet<String> types() const;
IntPoint dragLocation() const; // same point as client passed us
CachedImage* dragImage() const;
return false;
}
-DeprecatedStringList ClipboardMac::types() const
+HashSet<String> ClipboardMac::types() const
{
if (m_policy != Readable && m_policy != TypesReadable)
- return DeprecatedStringList();
+ return HashSet<String>();
NSArray *types = [m_pasteboard types];
// Enforce changeCount ourselves for security. We check after reading instead of before to be
// sure it doesn't change between our testing the change count and accessing the data.
if (m_changeCount != [m_pasteboard changeCount])
- return DeprecatedStringList();
+ return HashSet<String>();
- DeprecatedStringList result;
+ HashSet<String> result;
if (types) {
unsigned count = [types count];
unsigned i;
if ([pbType isEqualToString:@"NeXT plain ascii pasteboard type"])
continue; // skip this ancient type that gets auto-supplied by some system conversion
- DeprecatedString qstr = MIMETypeFromCocoaType(pbType);
- if (!result.contains(qstr))
- result.append(qstr);
+ String str = MIMETypeFromCocoaType(pbType);
+ if (!result.contains(str))
+ result.add(str);
}
}
return result;