[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
hamaji at chromium.org
hamaji at chromium.org
Wed Mar 17 18:43:28 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 2b7e5316c9cacc5772fc2a63ba92c32ec8d56481
Author: hamaji at chromium.org <hamaji at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Mar 16 07:39:28 2010 +0000
2010-03-16 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by Darin Adler.
RenderText::m_text should be a String, not RefPtr<StringImpl>
https://bugs.webkit.org/show_bug.cgi?id=36010
Refactoring only, so no new tests.
* platform/text/PlatformString.h:
(WebCore::String::makeLower):
(WebCore::String::makeUpper):
(WebCore::String::makeSecure):
(WebCore::String::makeCapitalized):
(WebCore::String::containsOnlyASCII):
* rendering/RenderText.cpp:
(WebCore::RenderText::RenderText):
(WebCore::RenderText::widthFromCache):
(WebCore::RenderText::trimmedPrefWidths):
(WebCore::RenderText::containsOnlyWhitespace):
(WebCore::RenderText::setTextInternal):
(WebCore::RenderText::setText):
(WebCore::RenderText::previousOffset):
(WebCore::RenderText::previousOffsetForBackwardDeletion):
(WebCore::RenderText::nextOffset):
* rendering/RenderText.h:
(WebCore::RenderText::text):
(WebCore::RenderText::characters):
(WebCore::RenderText::textLength):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@56047 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 47aab46..3ab2d3a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-03-16 Shinichiro Hamaji <hamaji at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ RenderText::m_text should be a String, not RefPtr<StringImpl>
+ https://bugs.webkit.org/show_bug.cgi?id=36010
+
+ Refactoring only, so no new tests.
+
+ * platform/text/PlatformString.h:
+ (WebCore::String::makeLower):
+ (WebCore::String::makeUpper):
+ (WebCore::String::makeSecure):
+ (WebCore::String::makeCapitalized):
+ (WebCore::String::containsOnlyASCII):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::RenderText):
+ (WebCore::RenderText::widthFromCache):
+ (WebCore::RenderText::trimmedPrefWidths):
+ (WebCore::RenderText::containsOnlyWhitespace):
+ (WebCore::RenderText::setTextInternal):
+ (WebCore::RenderText::setText):
+ (WebCore::RenderText::previousOffset):
+ (WebCore::RenderText::previousOffsetForBackwardDeletion):
+ (WebCore::RenderText::nextOffset):
+ * rendering/RenderText.h:
+ (WebCore::RenderText::text):
+ (WebCore::RenderText::characters):
+ (WebCore::RenderText::textLength):
+
2010-03-16 Adam Barth <abarth at webkit.org>
Reviewed by Darin Adler.
diff --git a/WebCore/platform/text/PlatformString.h b/WebCore/platform/text/PlatformString.h
index 8a379be..c8946e2 100644
--- a/WebCore/platform/text/PlatformString.h
+++ b/WebCore/platform/text/PlatformString.h
@@ -63,6 +63,27 @@ class CString;
class SharedBuffer;
struct StringHash;
+// Declarations of string operations
+
+bool charactersAreAllASCII(const UChar*, size_t);
+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);
+
+int find(const UChar*, size_t, UChar, int startPosition = 0);
+int reverseFind(const UChar*, size_t, UChar, int startPosition = -1);
+
class String {
public:
String() { } // gives null string, distinguishable from an empty string
@@ -133,6 +154,11 @@ public:
String& replace(const String& a, const String& b) { if (m_impl) m_impl = m_impl->replace(a.impl(), b.impl()); return *this; }
String& replace(unsigned index, unsigned len, const String& b) { if (m_impl) m_impl = m_impl->replace(index, len, b.impl()); return *this; }
+ void makeLower() { if (m_impl) m_impl = m_impl->lower(); }
+ void makeUpper() { if (m_impl) m_impl = m_impl->upper(); }
+ void makeSecure(UChar aChar) { if (m_impl) m_impl = m_impl->secure(aChar); }
+ void makeCapitalized(UChar previousCharacter) { if (m_impl) m_impl = m_impl->capitalize(previousCharacter); }
+
void truncate(unsigned len);
void remove(unsigned pos, int len = 1);
@@ -256,6 +282,8 @@ public:
// the specified grapheme cluster length.
unsigned numCharactersInGraphemeClusters(unsigned) const;
+ bool containsOnlyASCII() const { return charactersAreAllASCII(characters(), length()); }
+
private:
RefPtr<StringImpl> m_impl;
};
@@ -294,27 +322,7 @@ inline bool operator!(const String& str) { return str.isNull(); }
inline void swap(String& a, String& b) { a.swap(b); }
-// String Operations
-
-bool charactersAreAllASCII(const UChar*, size_t);
-
-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);
-
-int find(const UChar*, size_t, UChar, int startPosition = 0);
-int reverseFind(const UChar*, size_t, UChar, int startPosition = -1);
+// Definitions of string operations
#ifdef __OBJC__
// This is for situations in WebKit where the long standing behavior has been
diff --git a/WebCore/rendering/RenderText.cpp b/WebCore/rendering/RenderText.cpp
index 111d510..aa919e0 100644
--- a/WebCore/rendering/RenderText.cpp
+++ b/WebCore/rendering/RenderText.cpp
@@ -48,12 +48,6 @@ using namespace Unicode;
namespace WebCore {
-// FIXME: Move to StringImpl.h eventually.
-static inline bool charactersAreAllASCII(StringImpl* text)
-{
- return charactersAreAllASCII(text->characters(), text->length());
-}
-
RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str)
: RenderObject(node)
, m_minWidth(-1)
@@ -66,7 +60,7 @@ RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str)
, m_hasTab(false)
, m_linesDirty(false)
, m_containsReversedText(false)
- , m_isAllASCII(charactersAreAllASCII(m_text.get()))
+ , m_isAllASCII(m_text.containsOnlyASCII())
, m_knownNotToUseFallbackFonts(false)
{
ASSERT(m_text);
@@ -442,8 +436,10 @@ ALWAYS_INLINE int RenderText::widthFromCache(const Font& f, int start, int len,
int w = 0;
bool isSpace;
bool previousCharWasSpace = true; // FIXME: Preserves historical behavior, but seems wrong for start > 0.
+ ASSERT(m_text);
+ StringImpl& text = *m_text.impl();
for (int i = start; i < start + len; i++) {
- char c = (*m_text)[i];
+ char c = text[i];
if (c <= ' ') {
if (c == ' ' || c == '\n') {
w += monospaceCharacterWidth;
@@ -486,7 +482,7 @@ void RenderText::trimmedPrefWidths(int leadWidth,
int len = textLength();
- if (!len || (stripFrontSpaces && m_text->containsOnlyWhitespace())) {
+ if (!len || (stripFrontSpaces && text()->containsOnlyWhitespace())) {
beginMinW = 0;
endMinW = 0;
beginMaxW = 0;
@@ -506,7 +502,9 @@ void RenderText::trimmedPrefWidths(int leadWidth,
hasBreakableChar = m_hasBreakableChar;
hasBreak = m_hasBreak;
- if ((*m_text)[0] == ' ' || ((*m_text)[0] == '\n' && !style()->preserveNewline()) || (*m_text)[0] == '\t') {
+ ASSERT(m_text);
+ StringImpl& text = *m_text.impl();
+ if (text[0] == ' ' || (text[0] == '\n' && !style()->preserveNewline()) || text[0] == '\t') {
const Font& f = style()->font(); // FIXME: This ignores first-line.
if (stripFrontSpaces) {
const UChar space = ' ';
@@ -529,7 +527,7 @@ void RenderText::trimmedPrefWidths(int leadWidth,
endMaxW = maxW;
for (int i = 0; i < len; i++) {
int linelen = 0;
- while (i + linelen < len && (*m_text)[i + linelen] != '\n')
+ while (i + linelen < len && text[i + linelen] != '\n')
linelen++;
if (linelen) {
@@ -777,9 +775,11 @@ bool RenderText::isAllCollapsibleWhitespace()
bool RenderText::containsOnlyWhitespace(unsigned from, unsigned len) const
{
+ ASSERT(m_text);
+ StringImpl& text = *m_text.impl();
unsigned currPos;
for (currPos = from;
- currPos < from + len && ((*m_text)[currPos] == '\n' || (*m_text)[currPos] == ' ' || (*m_text)[currPos] == '\t');
+ currPos < from + len && (text[currPos] == '\n' || text[currPos] == ' ' || text[currPos] == '\t');
currPos++) { }
return currPos >= (from + len);
}
@@ -952,7 +952,7 @@ void RenderText::setTextInternal(PassRefPtr<StringImpl> text)
// characters into space characters. Then, it will draw all space characters, including
// leading, trailing and multiple contiguous space characters.
- m_text = m_text->replace('\n', ' ');
+ m_text.replace('\n', ' ');
// If xml:space="preserve" is set, white-space is set to "pre", which
// preserves leading, trailing & contiguous space character for us.
@@ -963,13 +963,13 @@ void RenderText::setTextInternal(PassRefPtr<StringImpl> text)
// Then, it will strip off all leading and trailing space characters.
// Then, all contiguous space characters will be consolidated.
- m_text = m_text->replace('\n', StringImpl::empty());
+ m_text.replace('\n', StringImpl::empty());
// If xml:space="default" is set, white-space is set to "nowrap", which handles
// leading, trailing & contiguous space character removal for us.
}
- m_text = m_text->replace('\t', ' ');
+ m_text.replace('\t', ' ');
}
#endif
@@ -977,15 +977,14 @@ void RenderText::setTextInternal(PassRefPtr<StringImpl> text)
switch (style()->textTransform()) {
case TTNONE:
break;
- case CAPITALIZE: {
- m_text = m_text->capitalize(previousCharacter());
+ case CAPITALIZE:
+ m_text.makeCapitalized(previousCharacter());
break;
- }
case UPPERCASE:
- m_text = m_text->upper();
+ m_text.makeUpper();
break;
case LOWERCASE:
- m_text = m_text->lower();
+ m_text.makeLower();
break;
}
@@ -995,27 +994,27 @@ void RenderText::setTextInternal(PassRefPtr<StringImpl> text)
case TSNONE:
break;
case TSCIRCLE:
- m_text = m_text->secure(whiteBullet);
+ m_text.makeSecure(whiteBullet);
break;
case TSDISC:
- m_text = m_text->secure(bullet);
+ m_text.makeSecure(bullet);
break;
case TSSQUARE:
- m_text = m_text->secure(blackSquare);
+ m_text.makeSecure(blackSquare);
}
}
ASSERT(m_text);
- ASSERT(!isBR() || (textLength() == 1 && (*m_text)[0] == '\n'));
+ ASSERT(!isBR() || (textLength() == 1 && m_text[0] == '\n'));
- m_isAllASCII = charactersAreAllASCII(m_text.get());
+ m_isAllASCII = m_text.containsOnlyASCII();
}
void RenderText::setText(PassRefPtr<StringImpl> text, bool force)
{
ASSERT(text);
- if (!force && equal(m_text.get(), text.get()))
+ if (!force && equal(m_text.impl(), text.get()))
return;
setTextInternal(text);
@@ -1245,7 +1244,7 @@ unsigned RenderText::caretMaxRenderedOffset() const
int RenderText::previousOffset(int current) const
{
- StringImpl* si = m_text.get();
+ StringImpl* si = m_text.impl();
TextBreakIterator* iterator = cursorMovementIterator(si->characters(), si->length());
if (!iterator)
return current - 1;
@@ -1293,14 +1292,16 @@ inline bool isHangulLVT(UChar32 character)
int RenderText::previousOffsetForBackwardDeletion(int current) const
{
#if PLATFORM(MAC)
+ ASSERT(m_text);
+ StringImpl& text = *m_text.impl();
UChar32 character;
while (current > 0) {
- if (U16_IS_TRAIL((*m_text)[--current]))
+ if (U16_IS_TRAIL(text[--current]))
--current;
if (current < 0)
break;
- UChar32 character = m_text->characterStartingAt(current);
+ UChar32 character = text.characterStartingAt(current);
// We don't combine characters in Armenian ... Limbu range for backward deletion.
if ((character >= 0x0530) && (character < 0x1950))
@@ -1314,7 +1315,7 @@ int RenderText::previousOffsetForBackwardDeletion(int current) const
return current;
// Hangul
- character = m_text->characterStartingAt(current);
+ character = text.characterStartingAt(current);
if (((character >= HANGUL_CHOSEONG_START) && (character <= HANGUL_JONGSEONG_END)) || ((character >= HANGUL_SYLLABLE_START) && (character <= HANGUL_SYLLABLE_END))) {
HangulState state;
HangulState initialState;
@@ -1330,7 +1331,7 @@ int RenderText::previousOffsetForBackwardDeletion(int current) const
initialState = state;
- while (current > 0 && ((character = m_text->characterStartingAt(current - 1)) >= HANGUL_CHOSEONG_START) && (character <= HANGUL_SYLLABLE_END) && ((character <= HANGUL_JONGSEONG_END) || (character >= HANGUL_SYLLABLE_START))) {
+ while (current > 0 && ((character = text.characterStartingAt(current - 1)) >= HANGUL_CHOSEONG_START) && (character <= HANGUL_SYLLABLE_END) && ((character <= HANGUL_JONGSEONG_END) || (character >= HANGUL_SYLLABLE_START))) {
switch (state) {
case HangulStateV:
if (character <= HANGUL_CHOSEONG_END)
@@ -1368,7 +1369,7 @@ int RenderText::previousOffsetForBackwardDeletion(int current) const
int RenderText::nextOffset(int current) const
{
- StringImpl* si = m_text.get();
+ StringImpl* si = m_text.impl();
TextBreakIterator* iterator = cursorMovementIterator(si->characters(), si->length());
if (!iterator)
return current + 1;
diff --git a/WebCore/rendering/RenderText.h b/WebCore/rendering/RenderText.h
index d46bce9..e9ed147 100644
--- a/WebCore/rendering/RenderText.h
+++ b/WebCore/rendering/RenderText.h
@@ -50,7 +50,7 @@ public:
virtual void destroy();
- StringImpl* text() const { return m_text.get(); }
+ StringImpl* text() const { return m_text.impl(); }
InlineTextBox* createInlineTextBox();
void dirtyLineBoxes(bool fullLayout);
@@ -63,8 +63,8 @@ public:
virtual VisiblePosition positionForPoint(const IntPoint&);
- const UChar* characters() const { return m_text->characters(); }
- unsigned textLength() const { return m_text->length(); } // non virtual implementation of length()
+ const UChar* characters() const { return m_text.characters(); }
+ unsigned textLength() const { return m_text.length(); } // non virtual implementation of length()
void positionLineBox(InlineBox*);
virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos, HashSet<const SimpleFontData*>* fallbackFonts = 0) const;
@@ -151,7 +151,7 @@ private:
int m_minWidth; // here to minimize padding in 64-bit.
- RefPtr<StringImpl> m_text;
+ String m_text;
InlineTextBox* m_firstTextBox;
InlineTextBox* m_lastTextBox;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list