Commit c79eaef4 authored by eric@webkit.org's avatar eric@webkit.org

Reviewed by Sam and Darin.

        Fire a warning shot in DeprecatedChar's direction.

        Remove DeprecatedChar::isSpace() usage, in preparation for removing DeprecatedChar
        Remove a needless String -> DeprecatedString -> String conversion for <script> tags

        * css/MediaQueryEvaluator.cpp:
        (WebCore::parseAspectRatio):
        * css/SVGCSSParser.cpp:
        * dom/Position.cpp:
        (WebCore::Position::leadingWhitespacePosition):
        (WebCore::Position::trailingWhitespacePosition):
        * editing/TextIterator.cpp:
        (WebCore::WordAwareIterator::advance):
        * html/HTMLFontElement.cpp:
        (WebCore::parseFontSizeNumber):
        * html/HTMLTokenizer.cpp:
        (WebCore::HTMLTokenizer::scriptHandler):
        (WebCore::HTMLTokenizer::scriptExecution):
        (WebCore::HTMLTokenizer::notifyFinished):
        * html/HTMLTokenizer.h:
        * loader/CachedCSSStyleSheet.cpp:
        * loader/TextResourceDecoder.cpp:
        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        * platform/mac/ClipboardMac.mm:
        (WebCore::ClipboardMac::getData):
        * platform/network/HTTPParsers.cpp:
        (WebCore::extractMIMETypeFromMediaType):
        * platform/text/PlatformString.h:
        * platform/text/StringImpl.cpp:
        (WebCore::parseLength):
        (WebCore::StringImpl::stripWhiteSpace):
        (WebCore::StringImpl::simplifyWhiteSpace):
        (WebCore::StringImpl::toInt):
        (WebCore::StringImpl::toInt64):
        (WebCore::StringImpl::toUInt64):
        * platform/text/StringImpl.h:
        (WebCore::isSpaceOrNewline):
        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::placeBoxesHorizontally):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::updateFirstLetter):
        * rendering/bidi.cpp:
        (WebCore::RenderBlock::computeHorizontalPositionsForLine):
        * svg/SVGFontFaceElement.cpp:
        (WebCore::mapAttributeToCSSProperty):
        * svg/SVGLength.cpp:
        * svg/SVGStyledElement.cpp:
        (WebCore::mapAttributeToCSSProperty):
        * xml/XPathParser.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29805 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 29d6711a
2008-01-25 Eric Seidel <eric@webkit.org>
Reviewed by Sam and Darin.
Fire a warning shot in DeprecatedChar's direction.
Remove DeprecatedChar::isSpace() usage, in preparation for removing DeprecatedChar
Remove a needless String -> DeprecatedString -> String conversion for <script> tags
* css/MediaQueryEvaluator.cpp:
(WebCore::parseAspectRatio):
* css/SVGCSSParser.cpp:
* dom/Position.cpp:
(WebCore::Position::leadingWhitespacePosition):
(WebCore::Position::trailingWhitespacePosition):
* editing/TextIterator.cpp:
(WebCore::WordAwareIterator::advance):
* html/HTMLFontElement.cpp:
(WebCore::parseFontSizeNumber):
* html/HTMLTokenizer.cpp:
(WebCore::HTMLTokenizer::scriptHandler):
(WebCore::HTMLTokenizer::scriptExecution):
(WebCore::HTMLTokenizer::notifyFinished):
* html/HTMLTokenizer.h:
* loader/CachedCSSStyleSheet.cpp:
* loader/TextResourceDecoder.cpp:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
* platform/mac/ClipboardMac.mm:
(WebCore::ClipboardMac::getData):
* platform/network/HTTPParsers.cpp:
(WebCore::extractMIMETypeFromMediaType):
* platform/text/PlatformString.h:
* platform/text/StringImpl.cpp:
(WebCore::parseLength):
(WebCore::StringImpl::stripWhiteSpace):
(WebCore::StringImpl::simplifyWhiteSpace):
(WebCore::StringImpl::toInt):
(WebCore::StringImpl::toInt64):
(WebCore::StringImpl::toUInt64):
* platform/text/StringImpl.h:
(WebCore::isSpaceOrNewline):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::placeBoxesHorizontally):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateFirstLetter):
* rendering/bidi.cpp:
(WebCore::RenderBlock::computeHorizontalPositionsForLine):
* svg/SVGFontFaceElement.cpp:
(WebCore::mapAttributeToCSSProperty):
* svg/SVGLength.cpp:
* svg/SVGStyledElement.cpp:
(WebCore::mapAttributeToCSSProperty):
* xml/XPathParser.cpp:
2008-01-25 Stephanie Lewis <slewis@apple.com>
Reviewed by Tim.
......@@ -31,7 +31,6 @@
#include "Chrome.h"
#include "CSSPrimitiveValue.h"
#include "CSSValueList.h"
#include "DeprecatedString.h"
#include "FloatRect.h"
#include "Frame.h"
#include "FrameView.h"
......@@ -166,7 +165,7 @@ static bool parseAspectRatio(CSSValue* value, int& h, int& v)
&& i1->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(i1)->primitiveType() == CSSPrimitiveValue::CSS_STRING
&& i2->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(i2)->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
String str = static_cast<CSSPrimitiveValue*>(i1)->getStringValue();
if (!str.isNull() && str.length() == 1 && str[0] == DeprecatedChar('/')) {
if (!str.isNull() && str.length() == 1 && str[0] == '/') {
h = static_cast<CSSPrimitiveValue*>(i0)->getIntValue(CSSPrimitiveValue::CSS_NUMBER);
v = static_cast<CSSPrimitiveValue*>(i2)->getIntValue(CSSPrimitiveValue::CSS_NUMBER);
return true;
......
......@@ -33,7 +33,6 @@
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "SVGPaint.h"
#include "DeprecatedString.h"
using namespace std;
......
......@@ -635,7 +635,7 @@ Position Position::leadingWhitespacePosition(EAffinity affinity, bool considerNo
if (prev != *this && prev.node()->inSameContainingBlockFlowElement(node()) && prev.node()->isTextNode()) {
String string = static_cast<Text *>(prev.node())->data();
UChar c = string[prev.offset()];
if (considerNonCollapsibleWhitespace ? (DeprecatedChar(c).isSpace() || c == noBreakSpace) : isCollapsibleWhitespace(c))
if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : isCollapsibleWhitespace(c))
if (isEditablePosition(prev))
return prev;
}
......@@ -654,7 +654,7 @@ Position Position::trailingWhitespacePosition(EAffinity affinity, bool considerN
UChar c = v.characterAfter();
// The space must not be in another paragraph and it must be editable.
if (!isEndOfParagraph(v) && v.next(true).isNotNull())
if (considerNonCollapsibleWhitespace ? (DeprecatedChar(c).isSpace() || c == noBreakSpace) : isCollapsibleWhitespace(c))
if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : isCollapsibleWhitespace(c))
return *this;
return Position();
......
......@@ -1020,7 +1020,7 @@ void WordAwareIterator::advance()
while (1) {
// If this chunk ends in whitespace we can just use it as our chunk.
if (DeprecatedChar(m_textIterator.characters()[m_textIterator.length() - 1]).isSpace())
if (isSpaceOrNewline(m_textIterator.characters()[m_textIterator.length() - 1]))
return;
// If this is the first chunk that failed, save it in previousText before look ahead
......@@ -1031,7 +1031,7 @@ void WordAwareIterator::advance()
// Look ahead to next chunk. If it is whitespace or a break, we can use the previous stuff
m_textIterator.advance();
if (m_textIterator.atEnd() || m_textIterator.length() == 0 || DeprecatedChar(m_textIterator.characters()[0]).isSpace()) {
if (m_textIterator.atEnd() || m_textIterator.length() == 0 || isSpaceOrNewline(m_textIterator.characters()[0])) {
m_didLookAhead = true;
return;
}
......
......@@ -52,7 +52,7 @@ static bool parseFontSizeNumber(const String& s, int& size)
unsigned pos = 0;
// Skip leading spaces.
while (DeprecatedChar(s[pos]).isSpace())
while (isSpaceOrNewline(s[pos]))
++pos;
// Skip a plus or minus.
......
......@@ -425,7 +425,7 @@ HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state)
}
state = processListing(SegmentedString(scriptCode, scriptCodeSize), state);
DeprecatedString exScript(reinterpret_cast<DeprecatedChar*>(buffer), dest - buffer);
String scriptCode(buffer, dest - buffer);
processToken();
currToken.tagName = scriptTag.localName();
currToken.beginTag = false;
......@@ -467,7 +467,7 @@ HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state)
else
prependingSrc = src;
setSrc(SegmentedString());
state = scriptExecution(exScript, state, DeprecatedString::null, scriptStartLineno);
state = scriptExecution(scriptCode, state, String(), scriptStartLineno);
}
}
......@@ -500,12 +500,12 @@ HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state)
return state;
}
HTMLTokenizer::State HTMLTokenizer::scriptExecution(const DeprecatedString& str, State state, DeprecatedString scriptURL, int baseLine)
HTMLTokenizer::State HTMLTokenizer::scriptExecution(const String& str, State state, const String& scriptURL, int baseLine)
{
if (m_fragment || !m_doc->frame())
return state;
m_executingScript++;
DeprecatedString url = scriptURL.isNull() ? m_doc->frame()->document()->url() : scriptURL;
DeprecatedString url = scriptURL.isNull() ? m_doc->frame()->document()->url() : scriptURL.deprecatedString();
SegmentedString *savedPrependingSrc = currentPrependingSrc;
SegmentedString prependingSrc;
......@@ -1725,7 +1725,7 @@ void HTMLTokenizer::notifyFinished(CachedResource*)
// make sure we forget about the script before we execute the new one
// infinite recursion might happen otherwise
DeprecatedString cachedScriptUrl( cs->url().deprecatedString() );
String cachedScriptUrl(cs->url());
bool errorOccurred = cs->errorOccurred();
cs->deref(this);
RefPtr<Node> n = scriptNode.release();
......@@ -1739,7 +1739,7 @@ void HTMLTokenizer::notifyFinished(CachedResource*)
EventTargetNodeCast(n.get())->dispatchHTMLEvent(errorEvent, true, false);
else {
if (static_cast<HTMLScriptElement*>(n.get())->shouldExecuteAsJavaScript())
m_state = scriptExecution(scriptSource.deprecatedString(), m_state, cachedScriptUrl);
m_state = scriptExecution(scriptSource, m_state, cachedScriptUrl);
EventTargetNodeCast(n.get())->dispatchHTMLEvent(loadEvent, false, false);
}
......@@ -1761,8 +1761,7 @@ void HTMLTokenizer::notifyFinished(CachedResource*)
SegmentedString rest = pendingSrc;
pendingSrc.clear();
write(rest, false);
// we might be deleted at this point, do not
// access any members.
// we might be deleted at this point, do not access any members.
}
}
}
......
......@@ -129,7 +129,7 @@ private:
State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& _cBufferPos, bool start, bool parsingTag);
State parseProcessingInstruction(SegmentedString&, State);
State scriptHandler(State);
State scriptExecution(const DeprecatedString& script, State, DeprecatedString scriptURL, int baseLine = 0);
State scriptExecution(const String& script, State, const String& scriptURL, int baseLine = 0);
void setSrc(const SegmentedString&);
// check if we have enough space in the buffer.
......
......@@ -31,7 +31,6 @@
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "TextResourceDecoder.h"
#include "DeprecatedString.h"
#include "loader.h"
#include <wtf/Vector.h>
......
......@@ -26,7 +26,6 @@
#include "CString.h"
#include "DOMImplementation.h"
#include "DeprecatedCString.h"
#include "DeprecatedString.h"
#include "HTMLNames.h"
#include "TextCodec.h"
#include <wtf/ASCIICType.h>
......
......@@ -30,7 +30,6 @@
#import "MediaPlayerPrivateQTKit.h"
#import "BlockExceptions.h"
#import "DeprecatedString.h"
#import "GraphicsContext.h"
#import "KURL.h"
#import "ScrollView.h"
......
......@@ -200,7 +200,7 @@ String ClipboardMac::getData(const String& type, bool& success) const
// sure it doesn't change between our testing the change count and accessing the data.
if (cocoaValue && m_changeCount == [m_pasteboard.get() changeCount]) {
success = true;
return String(DeprecatedString::fromNSString(cocoaValue));
return cocoaValue;
}
return String();
......
......@@ -30,7 +30,6 @@
#include "config.h"
#include "HTTPParsers.h"
#include "DeprecatedString.h"
#include "PlatformString.h"
namespace WebCore {
......@@ -137,7 +136,7 @@ String extractMIMETypeFromMediaType(const String& mediaType)
UChar c = mediaType[offset];
if (c == ';')
break;
else if (DeprecatedChar(c).isSpace()) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045. bug 8644
else if (isSpaceOrNewline(c)) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045. bug 8644
continue;
// FIXME: This is a very slow way to build a string, given WebCore::String's implementation.
mimeType += String(&c, 1);
......
......@@ -43,6 +43,7 @@ class wxString;
namespace WebCore {
class CString;
class DeprecatedString;
struct StringHash;
class String {
......
......@@ -26,9 +26,9 @@
#include "StringImpl.h"
#include "AtomicString.h"
#include "DeprecatedString.h"
#include "CString.h"
#include "CharacterNames.h"
#include "DeprecatedString.h"
#include "FloatConversion.h"
#include "Length.h"
#include "StringBuffer.h"
......@@ -48,13 +48,6 @@ using KJS::UString;
namespace WebCore {
static inline bool isSpace(UChar c)
{
// Use isASCIISpace() for basic Latin-1.
// This will include newlines, which aren't included in Unicode DirWS.
return c <= 0x7F ? isASCIISpace(c) : direction(c) == WhiteSpaceNeutral;
}
static inline UChar* newUCharVector(unsigned n)
{
return static_cast<UChar*>(fastMalloc(sizeof(UChar) * n));
......@@ -224,7 +217,7 @@ static Length parseLength(const UChar* data, unsigned length)
return Length(1, Relative);
unsigned i = 0;
while (i < length && isSpace(data[i]))
while (i < length && isSpaceOrNewline(data[i]))
++i;
if (i < length && (data[i] == '+' || data[i] == '-'))
++i;
......@@ -239,7 +232,7 @@ static Length parseLength(const UChar* data, unsigned length)
++i;
/* IE Quirk: Skip any whitespace (20 % => 20%) */
while (i < length && isSpace(data[i]))
while (i < length && isSpaceOrNewline(data[i]))
++i;
if (ok) {
......@@ -447,7 +440,7 @@ PassRefPtr<StringImpl> StringImpl::stripWhiteSpace()
unsigned end = m_length - 1;
// skip white space from start
while (start <= end && isSpace(m_data[start]))
while (start <= end && isSpaceOrNewline(m_data[start]))
start++;
// only white space
......@@ -455,7 +448,7 @@ PassRefPtr<StringImpl> StringImpl::stripWhiteSpace()
return empty();
// skip white space from end
while (end && isSpace(m_data[end]))
while (end && isSpaceOrNewline(m_data[end]))
end--;
return create(m_data + start, end + 1 - start);
......@@ -472,9 +465,9 @@ PassRefPtr<StringImpl> StringImpl::simplifyWhiteSpace()
UChar* to = data.characters();
while (true) {
while (from != fromend && isSpace(*from))
while (from != fromend && isSpaceOrNewline(*from))
from++;
while (from != fromend && !isSpace(*from))
while (from != fromend && !isSpaceOrNewline(*from))
to[outc++] = *from++;
if (from != fromend)
to[outc++] = ' ';
......@@ -526,7 +519,7 @@ int StringImpl::toInt(bool* ok)
// Allow leading spaces.
for (; i != m_length; ++i)
if (!isSpace(m_data[i]))
if (!isSpaceOrNewline(m_data[i]))
break;
// Allow sign.
......@@ -547,7 +540,7 @@ int64_t StringImpl::toInt64(bool* ok)
// Allow leading spaces.
for (; i != m_length; ++i)
if (!isSpace(m_data[i]))
if (!isSpaceOrNewline(m_data[i]))
break;
// Allow sign.
......@@ -568,7 +561,7 @@ uint64_t StringImpl::toUInt64(bool* ok)
// Allow leading spaces.
for (; i != m_length; ++i)
if (!isSpace(m_data[i]))
if (!isSpaceOrNewline(m_data[i]))
break;
// Allow digits.
......
......@@ -22,12 +22,13 @@
#ifndef StringImpl_h
#define StringImpl_h
#include <wtf/RefCounted.h>
#include <wtf/unicode/Unicode.h>
#include <kjs/identifier.h>
#include <limits.h>
#include <wtf/ASCIICType.h>
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <limits.h>
#include <wtf/unicode/Unicode.h>
#if PLATFORM(CF)
typedef const struct __CFString * CFStringRef;
......@@ -40,7 +41,6 @@ typedef const struct __CFString * CFStringRef;
namespace WebCore {
class AtomicString;
class DeprecatedString;
class StringBuffer;
struct CStringTranslator;
......@@ -250,6 +250,13 @@ inline unsigned StringImpl::computeHash(const char* data)
return hash;
}
static inline bool isSpaceOrNewline(UChar c)
{
// Use isASCIISpace() for basic Latin-1.
// This will include newlines, which aren't included in Unicode DirWS.
return c <= 0x7F ? WTF::isASCIISpace(c) : WTF::Unicode::direction(c) == WTF::Unicode::WhiteSpaceNeutral;
}
}
namespace WTF {
......
......@@ -291,9 +291,9 @@ int InlineFlowBox::placeBoxesHorizontally(int x, int& leftPosition, int& rightPo
InlineTextBox* text = static_cast<InlineTextBox*>(curr);
RenderText* rt = static_cast<RenderText*>(text->object());
if (rt->textLength()) {
if (needsWordSpacing && DeprecatedChar(rt->characters()[text->start()]).isSpace())
if (needsWordSpacing && isSpaceOrNewline(rt->characters()[text->start()]))
x += rt->style(m_firstLine)->font().wordSpacing();
needsWordSpacing = !DeprecatedChar(rt->characters()[text->end()]).isSpace();
needsWordSpacing = !isSpaceOrNewline(rt->characters()[text->end()]);
}
text->setXPos(x);
......
......@@ -4131,7 +4131,7 @@ void RenderBlock::updateFirstLetter()
unsigned int length = 0;
// account for leading spaces and punctuation
while (length < oldText->length() && (DeprecatedChar((*oldText)[length]).isSpace() || Unicode::isPunct((*oldText)[length])))
while (length < oldText->length() && (isSpaceOrNewline((*oldText)[length]) || Unicode::isPunct((*oldText)[length])))
length++;
// account for first letter
......
......@@ -647,9 +647,9 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
int textWidth = rt->width(r->m_start, r->m_stop - r->m_start, totWidth, m_firstLine);
int rtLength = rt->textLength();
if (rtLength != 0) {
if (!r->compact && !r->m_start && needsWordSpacing && DeprecatedChar(rt->characters()[r->m_start]).isSpace())
if (!r->compact && !r->m_start && needsWordSpacing && isSpaceOrNewline(rt->characters()[r->m_start]))
totWidth += rt->style(m_firstLine)->font().wordSpacing();
needsWordSpacing = !DeprecatedChar(rt->characters()[r->m_stop - 1]).isSpace() && r->m_stop == rtLength;
needsWordSpacing = !isSpaceOrNewline(rt->characters()[r->m_stop - 1]) && r->m_stop == rtLength;
}
r->box->setWidth(textWidth);
} else if (!r->obj->isInlineFlow()) {
......
......@@ -67,8 +67,8 @@ static inline void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* pr
if (cssPropertyName)
propertyId = getPropertyID(cssPropertyName, strlen(cssPropertyName));
else {
DeprecatedString propertyName = attrName.localName().deprecatedString();
propertyId = getPropertyID(propertyName.ascii(), propertyName.length());
CString propertyName = attrName.localName().domString().utf8();
propertyId = getPropertyID(propertyName.data(), propertyName.length());
}
if (propertyId < 1)
fprintf(stderr, "Failed to find property: %s\n", attrName.localName().deprecatedString().ascii());
......
......@@ -27,7 +27,6 @@
#include "SVGLength.h"
#include "CSSHelper.h"
#include "DeprecatedString.h"
#include "FloatConversion.h"
#include "FrameView.h"
#include "RenderObject.h"
......
......@@ -27,6 +27,7 @@
#include "Attr.h"
#include "CSSStyleSelector.h"
#include "CString.h"
#include "Document.h"
#include "HTMLNames.h"
#include "PlatformString.h"
......@@ -74,8 +75,8 @@ static inline void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* pr
if (cssPropertyName)
propertyId = getPropertyID(cssPropertyName, strlen(cssPropertyName));
else {
DeprecatedString propertyName = attrName.localName().deprecatedString();
propertyId = getPropertyID(propertyName.ascii(), propertyName.length());
CString propertyName = attrName.localName().domString().utf8();
propertyId = getPropertyID(propertyName.data(), propertyName.length());
}
ASSERT(propertyId > 0);
propertyNameToIdMap->set(attrName.localName().impl(), propertyId);
......
......@@ -143,7 +143,7 @@ bool Parser::isOperatorContext() const
void Parser::skipWS()
{
while (m_nextPos < m_data.length() && DeprecatedChar(m_data[m_nextPos]).isSpace())
while (m_nextPos < m_data.length() && isSpaceOrNewline(m_data[m_nextPos]))
++m_nextPos;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment