[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:39:30 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit e391c78510e56e4292a06b9ea9dd0aed86908d24
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Sep 17 22:18:45 2002 +0000
WebCore:
- fixed 2936933 -- Pages that claim to be UTF-8 but contain invalid
sequences do not render at all
Misc. speed improvements. Total 2.6% speedup for cvs-base.
Improvements for signals.
* kwq/KWQChar.mm:
(QChar::isSpace): Add fast case for ASCII.
(QChar::lower): Add fast case for ASCII.
(QChar::upper): Add fast case for ASCII.
* kwq/qt/qcolor.h: Just store RGB values, not NSColor objects.
* kwq/KWQColor.mm:
(QColor::QColor): No need to set color to nil.
(QColor::name): Use QString::sprintf instead of NSString.
(QColor::setNamedColor): Use KWQInvalidColor instead of nil.
(QColor::getNSColor): Make an autoreleased NSColor.
* kwq/KWQKHTMLPartImpl.mm:
(moveWidgetsAside): Use isWidget() instead of dynamic_cast.
* kwq/KWQSignal.h: use a QValueList instead of a fixed-size array.
* kwq/KWQSignal.mm:
(KWQSignal::connect): Append to list.
(KWQSignal::disconnect): Remove from list.
(KWQSignal::call): Use the QValueList.
* kwq/KWQSlot.mm:
(KWQSlot::call): Use static_cast instead of dynamic_cast where possible.
* kwq/qt/qstring.h: Add return value to forceUnicode.
* kwq/KWQString.mm:
(QString::fromStringWithEncoding): Implemented using the Text Encoding
Converter instead of CFString.
(compareIgnoringCaseForASCIIOnly): New function. Faster find.
(QString::find): Separate case-sensitive from case-insensitive and speed
up both of them.
(QString::stripWhiteSpace): Use the new forceUnicode for simplicity.
(QString::simplifyWhiteSpace): Ditto.
(QString::insert): Ditto.
(QString::remove): Ditto.
(QString::forceUnicode): Return the unicode pointer.
(QString::fill): Use the new forceUnicode for simplicity.
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge mouseUp:]): Fix two bugs. First, don't treat a slow
click as a double click. Second, deliver a mouse release event even for
a double click, as Qt does.
WebBrowser:
Don't update the tool tip rectangles every time we update the
background image. This makes things a little faster.
* TextFieldWithControls.h: Boolean for whether tool tip rectangles
are up to date.
* TextFieldWithControls.m:
(-[TextFieldWithControls updateToolTips]): Do work only if flag is
NO. Set flag to YES when done.
(-[TextFieldWithControls backgroundImage]): Don't update the tool
tip rectangles here.
(-[TextFieldWithControls setFrameOrigin:]): Mark the tool tip rectangles
as out of date.
(-[TextFieldWithControls setFrameSize:]): Mark the tool tip rectangles
as out of date.
(-[TextFieldWithControls drawRect:]): Update the tool tips if needed.
(-[TextFieldWithControls showRightButton:]): Mark the tool tip rectangles
as out of date.
(-[TextFieldWithControls setLeftButtonImage:withOrigin:]): Ditto.
(-[TextFieldWithControls setRightButtonImage:withOrigin:]): Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2076 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index c8a37d5..b8e6ea1 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,55 @@
+2002-09-17 Darin Adler <darin at apple.com>
+
+ - fixed 2936933 -- Pages that claim to be UTF-8 but contain invalid
+ sequences do not render at all
+
+ Misc. speed improvements. Total 2.6% speedup for cvs-base.
+
+ Improvements for signals.
+
+ * kwq/KWQChar.mm:
+ (QChar::isSpace): Add fast case for ASCII.
+ (QChar::lower): Add fast case for ASCII.
+ (QChar::upper): Add fast case for ASCII.
+
+ * kwq/qt/qcolor.h: Just store RGB values, not NSColor objects.
+ * kwq/KWQColor.mm:
+ (QColor::QColor): No need to set color to nil.
+ (QColor::name): Use QString::sprintf instead of NSString.
+ (QColor::setNamedColor): Use KWQInvalidColor instead of nil.
+ (QColor::getNSColor): Make an autoreleased NSColor.
+
+ * kwq/KWQKHTMLPartImpl.mm:
+ (moveWidgetsAside): Use isWidget() instead of dynamic_cast.
+
+ * kwq/KWQSignal.h: use a QValueList instead of a fixed-size array.
+ * kwq/KWQSignal.mm:
+ (KWQSignal::connect): Append to list.
+ (KWQSignal::disconnect): Remove from list.
+ (KWQSignal::call): Use the QValueList.
+
+ * kwq/KWQSlot.mm:
+ (KWQSlot::call): Use static_cast instead of dynamic_cast where possible.
+
+ * kwq/qt/qstring.h: Add return value to forceUnicode.
+ * kwq/KWQString.mm:
+ (QString::fromStringWithEncoding): Implemented using the Text Encoding
+ Converter instead of CFString.
+ (compareIgnoringCaseForASCIIOnly): New function. Faster find.
+ (QString::find): Separate case-sensitive from case-insensitive and speed
+ up both of them.
+ (QString::stripWhiteSpace): Use the new forceUnicode for simplicity.
+ (QString::simplifyWhiteSpace): Ditto.
+ (QString::insert): Ditto.
+ (QString::remove): Ditto.
+ (QString::forceUnicode): Return the unicode pointer.
+ (QString::fill): Use the new forceUnicode for simplicity.
+
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge mouseUp:]): Fix two bugs. First, don't treat a slow
+ click as a double click. Second, deliver a mouse release event even for
+ a double click, as Qt does.
+
2002-09-17 Richard Williamson <rjw at apple.com>
* khtml/css/cssstyleselector.cpp:
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c8a37d5..b8e6ea1 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,55 @@
+2002-09-17 Darin Adler <darin at apple.com>
+
+ - fixed 2936933 -- Pages that claim to be UTF-8 but contain invalid
+ sequences do not render at all
+
+ Misc. speed improvements. Total 2.6% speedup for cvs-base.
+
+ Improvements for signals.
+
+ * kwq/KWQChar.mm:
+ (QChar::isSpace): Add fast case for ASCII.
+ (QChar::lower): Add fast case for ASCII.
+ (QChar::upper): Add fast case for ASCII.
+
+ * kwq/qt/qcolor.h: Just store RGB values, not NSColor objects.
+ * kwq/KWQColor.mm:
+ (QColor::QColor): No need to set color to nil.
+ (QColor::name): Use QString::sprintf instead of NSString.
+ (QColor::setNamedColor): Use KWQInvalidColor instead of nil.
+ (QColor::getNSColor): Make an autoreleased NSColor.
+
+ * kwq/KWQKHTMLPartImpl.mm:
+ (moveWidgetsAside): Use isWidget() instead of dynamic_cast.
+
+ * kwq/KWQSignal.h: use a QValueList instead of a fixed-size array.
+ * kwq/KWQSignal.mm:
+ (KWQSignal::connect): Append to list.
+ (KWQSignal::disconnect): Remove from list.
+ (KWQSignal::call): Use the QValueList.
+
+ * kwq/KWQSlot.mm:
+ (KWQSlot::call): Use static_cast instead of dynamic_cast where possible.
+
+ * kwq/qt/qstring.h: Add return value to forceUnicode.
+ * kwq/KWQString.mm:
+ (QString::fromStringWithEncoding): Implemented using the Text Encoding
+ Converter instead of CFString.
+ (compareIgnoringCaseForASCIIOnly): New function. Faster find.
+ (QString::find): Separate case-sensitive from case-insensitive and speed
+ up both of them.
+ (QString::stripWhiteSpace): Use the new forceUnicode for simplicity.
+ (QString::simplifyWhiteSpace): Ditto.
+ (QString::insert): Ditto.
+ (QString::remove): Ditto.
+ (QString::forceUnicode): Return the unicode pointer.
+ (QString::fill): Use the new forceUnicode for simplicity.
+
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge mouseUp:]): Fix two bugs. First, don't treat a slow
+ click as a double click. Second, deliver a mouse release event even for
+ a double click, as Qt does.
+
2002-09-17 Richard Williamson <rjw at apple.com>
* khtml/css/cssstyleselector.cpp:
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c8a37d5..b8e6ea1 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,55 @@
+2002-09-17 Darin Adler <darin at apple.com>
+
+ - fixed 2936933 -- Pages that claim to be UTF-8 but contain invalid
+ sequences do not render at all
+
+ Misc. speed improvements. Total 2.6% speedup for cvs-base.
+
+ Improvements for signals.
+
+ * kwq/KWQChar.mm:
+ (QChar::isSpace): Add fast case for ASCII.
+ (QChar::lower): Add fast case for ASCII.
+ (QChar::upper): Add fast case for ASCII.
+
+ * kwq/qt/qcolor.h: Just store RGB values, not NSColor objects.
+ * kwq/KWQColor.mm:
+ (QColor::QColor): No need to set color to nil.
+ (QColor::name): Use QString::sprintf instead of NSString.
+ (QColor::setNamedColor): Use KWQInvalidColor instead of nil.
+ (QColor::getNSColor): Make an autoreleased NSColor.
+
+ * kwq/KWQKHTMLPartImpl.mm:
+ (moveWidgetsAside): Use isWidget() instead of dynamic_cast.
+
+ * kwq/KWQSignal.h: use a QValueList instead of a fixed-size array.
+ * kwq/KWQSignal.mm:
+ (KWQSignal::connect): Append to list.
+ (KWQSignal::disconnect): Remove from list.
+ (KWQSignal::call): Use the QValueList.
+
+ * kwq/KWQSlot.mm:
+ (KWQSlot::call): Use static_cast instead of dynamic_cast where possible.
+
+ * kwq/qt/qstring.h: Add return value to forceUnicode.
+ * kwq/KWQString.mm:
+ (QString::fromStringWithEncoding): Implemented using the Text Encoding
+ Converter instead of CFString.
+ (compareIgnoringCaseForASCIIOnly): New function. Faster find.
+ (QString::find): Separate case-sensitive from case-insensitive and speed
+ up both of them.
+ (QString::stripWhiteSpace): Use the new forceUnicode for simplicity.
+ (QString::simplifyWhiteSpace): Ditto.
+ (QString::insert): Ditto.
+ (QString::remove): Ditto.
+ (QString::forceUnicode): Return the unicode pointer.
+ (QString::fill): Use the new forceUnicode for simplicity.
+
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge mouseUp:]): Fix two bugs. First, don't treat a slow
+ click as a double click. Second, deliver a mouse release event even for
+ a double click, as Qt does.
+
2002-09-17 Richard Williamson <rjw at apple.com>
* khtml/css/cssstyleselector.cpp:
diff --git a/WebCore/kwq/KWQChar.mm b/WebCore/kwq/KWQChar.mm
index 4629485..de6913c 100644
--- a/WebCore/kwq/KWQChar.mm
+++ b/WebCore/kwq/KWQChar.mm
@@ -41,6 +41,10 @@ const QChar QChar::null;
bool QChar::isSpace() const
{
+ // Without this first quick case, this function was showing up in profiles.
+ if (c <= 0x7F) {
+ return isspace(c);
+ }
static CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline);
return CFCharacterSetIsCharacterMember(set, c);
}
@@ -76,6 +80,10 @@ bool QChar::isPunct() const
QChar QChar::lower() const
{
+ // Without this first quick case, this function was showing up in profiles.
+ if (c <= 0x7F) {
+ return (char)tolower(c);
+ }
scratchUniChar = c;
CFStringLowercase(GetScratchUniCharString(), NULL);
return scratchUniChar;
@@ -83,6 +91,10 @@ QChar QChar::lower() const
QChar QChar::upper() const
{
+ // Without this first quick case, this function was showing up in profiles.
+ if (c <= 0x7F) {
+ return (char)toupper(c);
+ }
scratchUniChar = c;
CFStringUppercase(GetScratchUniCharString(), NULL);
return scratchUniChar;
diff --git a/WebCore/kwq/KWQColor.h b/WebCore/kwq/KWQColor.h
index 5ba0d15..8a73ca3 100644
--- a/WebCore/kwq/KWQColor.h
+++ b/WebCore/kwq/KWQColor.h
@@ -39,27 +39,26 @@ typedef unsigned int QRgb; // RGB triplet
QRgb qRgb(int r, int g, int b);
QRgb qRgba(int r, int g, int b, int a);
+const QRgb KWQInvalidColor = 0x40000000;
+
class QColor {
public:
- QColor();
- QColor(int,int,int);
+ QColor() : color(KWQInvalidColor) { }
+ QColor(int r, int g, int b) : color(qRgb(r, g, b)) { }
explicit QColor(const QString &);
QColor(const char *); // can't be explicit because of helper.cpp
- QColor(const QColor &);
-
- ~QColor();
QString name() const;
void setNamedColor(const QString&);
- bool isValid() const;
+ bool isValid() const { return color != KWQInvalidColor; }
- int red() const;
- int green() const;
- int blue() const;
- QRgb rgb() const;
- void setRgb(int,int,int);
- void setRgb(int);
+ int red() const { return (color >> 16) & 0xFF; }
+ int green() const { return (color >> 8) & 0xFF; }
+ int blue() const { return color & 0xFF; }
+ QRgb rgb() const { return color & 0xFFFFFF; }
+ void setRgb(int r, int g, int b) { color = qRgb(r, g, b); }
+ void setRgb(int rgb) { color = rgb; }
void hsv(int *, int *, int *) const;
void setHsv(int h, int s, int v);
@@ -67,14 +66,23 @@ public:
QColor light(int f = 150) const;
QColor dark(int f = 200) const;
- QColor &operator=(const QColor &);
- bool operator==(const QColor &x) const;
- bool operator!=(const QColor &x) const;
+ friend bool operator==(const QColor &a, const QColor &b);
+ friend bool operator!=(const QColor &a, const QColor &b);
NSColor *getNSColor() const;
private:
- NSColor *color;
+ QRgb color;
};
+inline bool operator==(const QColor &a, const QColor &b)
+{
+ return a.color == b.color;
+}
+
+inline bool operator!=(const QColor &a, const QColor &b)
+{
+ return a.color != b.color;
+}
+
#endif
diff --git a/WebCore/kwq/KWQColor.mm b/WebCore/kwq/KWQColor.mm
index b75cd37..b655d1e 100644
--- a/WebCore/kwq/KWQColor.mm
+++ b/WebCore/kwq/KWQColor.mm
@@ -29,17 +29,6 @@
#import <qstring.h>
#import <KWQAssertions.h>
-static void createStaticConstructorAutoreleasePool()
-{
- static bool created;
- if (created)
- return;
- created = true;
- [[NSAutoreleasePool alloc] init];
- // FIXME: It would be great if there was some way to release this
- // without help from the application.
-}
-
const QColor Qt::black (0x00, 0x00, 0x00);
const QColor Qt::white (0xFF, 0xFF, 0xFF);
const QColor Qt::darkGray (0x80, 0x80, 0x80);
@@ -217,45 +206,21 @@ QRgb qRgba(int r, int g, int b, int a)
return a << 24 | r << 16 | g << 8 | b;
}
-QColor::QColor()
-{
- color = nil;
-}
-
-QColor::QColor(int r, int g, int b)
-{
- // This function is used during static contructor time, and needs to set up an autorelease pool.
- createStaticConstructorAutoreleasePool();
-
- color = nil;
- setRgb(r, g, b);
-}
-
QColor::QColor(const QString &name)
{
- color = nil;
setNamedColor(name);
}
QColor::QColor(const char *name)
{
- color = nil;
setNamedColor(name);
}
-QColor::~QColor()
-{
- [color release];
-}
-
-QColor::QColor(const QColor ©From)
-{
- color = [copyFrom.color retain];
-}
-
QString QColor::name() const
{
- return QString::fromNSString([NSString stringWithFormat:@"#%02X%02X%02X", red(), green(), blue()]);
+ QString name;
+ name.sprintf("#%02X%02X%02X", red(), green(), blue());
+ return name;
}
static int hex2int(QChar hexchar)
@@ -332,8 +297,7 @@ void QColor::setNamedColor(const QString &name)
int r, g, b;
if (name.isEmpty()) {
- [color release];
- color = nil;
+ color = KWQInvalidColor;
}
else if (decodeColorFromHexColorString(name, &r, &g, &b)) {
setRgb(r, g, b);
@@ -348,62 +312,11 @@ void QColor::setNamedColor(const QString &name)
}
else {
ERROR("couldn't create color using name %s", name.ascii());
- [color release];
- color = nil;
+ color = KWQInvalidColor;
}
}
}
-bool QColor::isValid() const
-{
- return color != nil;
-}
-
-int QColor::red() const
-{
- if (color == nil)
- return 0;
- return (int)(rint([color redComponent] * 255));
-}
-
-int QColor::green() const
-{
- if (color == nil)
- return 0;
- return (int)(rint([color greenComponent] * 255));
-}
-
-int QColor::blue() const
-{
- if (color == nil)
- return 0;
- return (int)(rint([color blueComponent] * 255));
-}
-
-QRgb QColor::rgb() const
-{
- if (color == nil)
- return 0;
- return qRgb(red(),green(),blue());
-}
-
-void QColor::setRgb(int r, int g, int b)
-{
- [color release];
- if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
- color = nil;
- else
- color = [[NSColor colorWithCalibratedRed: r / 255.0
- green: g / 255.0
- blue: b / 255.0
- alpha: 1.0] retain];
-}
-
-void QColor::setRgb(int rgb)
-{
- setRgb((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF);
-}
-
void QColor::hsv(int *h, int *s, int *v) const
{
int r = red();
@@ -533,29 +446,10 @@ QColor QColor::dark(int factor) const
return result;
}
-QColor &QColor::operator=(const QColor &assignFrom)
-{
- [assignFrom.color retain];
- [color release];
- color = assignFrom.color;
- return *this;
-}
-
-bool QColor::operator==(const QColor &compareTo) const
-{
- if (color == compareTo.color)
- return true;
- if (color && compareTo.color)
- return [color isEqual:compareTo.color];
- return false;
-}
-
-bool QColor::operator!=(const QColor &compareTo) const
-{
- return !(*this == compareTo);
-}
-
NSColor *QColor::getNSColor() const
{
- return color ? color : [[NSColor blackColor] retain];
+ return [NSColor colorWithCalibratedRed:red() / 255.0
+ green:green() / 255.0
+ blue:blue() / 255.0
+ alpha:1.0];
}
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 9664d9b..76d0fb3 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -373,9 +373,9 @@ void KWQKHTMLPartImpl::redirectionTimerStartedOrStopped()
static void moveWidgetsAside(RenderObject *object)
{
- RenderWidget *renderWidget = dynamic_cast<RenderWidget *>(object);
- if (renderWidget) {
- QWidget *widget = renderWidget->widget();
+ // Would use dynamic_cast, but a virtual function call is faster.
+ if (object->isWidget()) {
+ QWidget *widget = static_cast<RenderWidget *>(object)->widget();
if (widget) {
widget->move(999999, 0);
}
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index 9664d9b..76d0fb3 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -373,9 +373,9 @@ void KWQKHTMLPartImpl::redirectionTimerStartedOrStopped()
static void moveWidgetsAside(RenderObject *object)
{
- RenderWidget *renderWidget = dynamic_cast<RenderWidget *>(object);
- if (renderWidget) {
- QWidget *widget = renderWidget->widget();
+ // Would use dynamic_cast, but a virtual function call is faster.
+ if (object->isWidget()) {
+ QWidget *widget = static_cast<RenderWidget *>(object)->widget();
if (widget) {
widget->move(999999, 0);
}
diff --git a/WebCore/kwq/KWQSignal.h b/WebCore/kwq/KWQSignal.h
index aa287ed..331b7f3 100644
--- a/WebCore/kwq/KWQSignal.h
+++ b/WebCore/kwq/KWQSignal.h
@@ -50,7 +50,7 @@ private:
QObject *m_object;
KWQSignal *m_next;
const char *m_name;
- KWQSlot m_slots[4];
+ QValueList<KWQSlot> m_slots;
friend class QObject;
};
diff --git a/WebCore/kwq/KWQSignal.mm b/WebCore/kwq/KWQSignal.mm
index c964a43..94ad8a1 100644
--- a/WebCore/kwq/KWQSignal.mm
+++ b/WebCore/kwq/KWQSignal.mm
@@ -51,39 +51,32 @@ KWQSignal::~KWQSignal()
void KWQSignal::connect(const KWQSlot &slot)
{
- const int numSlots = sizeof(m_slots) / sizeof(m_slots[0]);
- for (int i = 0; i != numSlots; ++i) {
- if (m_slots[i].isEmpty()) {
- m_slots[i] = slot;
- return;
- }
+#if !ERROR_DISABLED
+ if (m_slots.contains(slot)) {
+ ERROR("connecting the same slot to a signal twice, %s", m_name);
}
- ERROR("more than %d connections to the same signal not supported, %s", numSlots, m_name);
+#endif
+ m_slots.append(slot);
}
void KWQSignal::disconnect(const KWQSlot &slot)
{
- const int numSlots = sizeof(m_slots) / sizeof(m_slots[0]);
- for (int i = 0; i != numSlots; ++i) {
- if (m_slots[i] == slot) {
- m_slots[i].clear();
- return;
- }
+#if !ERROR_DISABLED
+ if (!m_slots.contains(slot)) {
+ ERROR("disconnecting a signal that wasn't connected, %s", m_name);
}
- ERROR("disconnecting a signal that wasn't connected, %s", m_name);
+#endif
+ m_slots.remove(slot);
}
void KWQSignal::call() const
{
if (!m_object->m_signalsBlocked) {
KWQObjectSenderScope senderScope(m_object);
- const int numSlots = sizeof(m_slots) / sizeof(m_slots[0]);
- KWQSlot copiedSlots[numSlots];
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i] = m_slots[i];
- }
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i].call();
+ QValueList<KWQSlot> copiedSlots(m_slots);
+ QValueListConstIterator<KWQSlot> end = copiedSlots.end();
+ for (QValueListConstIterator<KWQSlot> it = copiedSlots.begin(); it != end; ++it) {
+ (*it).call();
}
}
}
@@ -92,28 +85,22 @@ void KWQSignal::call(bool b) const
{
if (!m_object->m_signalsBlocked) {
KWQObjectSenderScope senderScope(m_object);
- const int numSlots = sizeof(m_slots) / sizeof(m_slots[0]);
- KWQSlot copiedSlots[numSlots];
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i] = m_slots[i];
- }
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i].call(b);
+ QValueList<KWQSlot> copiedSlots(m_slots);
+ QValueListConstIterator<KWQSlot> end = copiedSlots.end();
+ for (QValueListConstIterator<KWQSlot> it = copiedSlots.begin(); it != end; ++it) {
+ (*it).call(b);
}
}
}
-void KWQSignal::call(int j) const
+void KWQSignal::call(int i) const
{
if (!m_object->m_signalsBlocked) {
KWQObjectSenderScope senderScope(m_object);
- const int numSlots = sizeof(m_slots) / sizeof(m_slots[0]);
- KWQSlot copiedSlots[numSlots];
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i] = m_slots[i];
- }
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i].call(j);
+ QValueList<KWQSlot> copiedSlots(m_slots);
+ QValueListConstIterator<KWQSlot> end = copiedSlots.end();
+ for (QValueListConstIterator<KWQSlot> it = copiedSlots.begin(); it != end; ++it) {
+ (*it).call(i);
}
}
}
@@ -122,13 +109,10 @@ void KWQSignal::call(const QString &s) const
{
if (!m_object->m_signalsBlocked) {
KWQObjectSenderScope senderScope(m_object);
- const int numSlots = sizeof(m_slots) / sizeof(m_slots[0]);
- KWQSlot copiedSlots[numSlots];
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i] = m_slots[i];
- }
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i].call(s);
+ QValueList<KWQSlot> copiedSlots(m_slots);
+ QValueListConstIterator<KWQSlot> end = copiedSlots.end();
+ for (QValueListConstIterator<KWQSlot> it = copiedSlots.begin(); it != end; ++it) {
+ (*it).call(s);
}
}
}
@@ -137,13 +121,10 @@ void KWQSignal::call(Job *j) const
{
if (!m_object->m_signalsBlocked) {
KWQObjectSenderScope senderScope(m_object);
- const int numSlots = sizeof(m_slots) / sizeof(m_slots[0]);
- KWQSlot copiedSlots[numSlots];
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i] = m_slots[i];
- }
- for (int i = 0; i != numSlots; ++i) {
- copiedSlots[i].call(j);
+ QValueList<KWQSlot> copiedSlots(m_slots);
+ QValueListConstIterator<KWQSlot> end = copiedSlots.end();
+ for (QValueListConstIterator<KWQSlot> it = copiedSlots.begin(); it != end; ++it) {
+ (*it).call(j);
}
}
}
diff --git a/WebCore/kwq/KWQSlot.mm b/WebCore/kwq/KWQSlot.mm
index fd91765..ef573de 100644
--- a/WebCore/kwq/KWQSlot.mm
+++ b/WebCore/kwq/KWQSlot.mm
@@ -119,13 +119,9 @@ void KWQSlot::call() const
}
#define CASE(member, type, function) \
- case member: { \
- type *o = dynamic_cast<type *>(m_object.pointer()); \
- if (o) { \
- o->function(); \
- } \
- return; \
- }
+ case member: \
+ static_cast<type *>(m_object.pointer())->function(); \
+ return;
switch (m_function) {
CASE(signalFinishedParsing, DocumentImpl, m_finishedParsing.call)
@@ -145,7 +141,7 @@ void KWQSlot::call() const
}
RenderFileButton *button = dynamic_cast<RenderFileButton *>(m_object.pointer());
if (button) {
- edit->slotReturnPressed();
+ button->slotReturnPressed();
}
return;
}
@@ -161,13 +157,9 @@ void KWQSlot::call(bool b) const
}
#define CASE(member, type, function) \
- case member: { \
- type *o = dynamic_cast<type *>(m_object.pointer()); \
- if (o) { \
- o->function(b); \
- } \
- return; \
- }
+ case member: \
+ static_cast<type *>(m_object.pointer())->function(b); \
+ return;
switch (m_function) {
CASE(slotChildCompletedWithBool, KHTMLPart, slotChildCompleted)
@@ -185,20 +177,12 @@ void KWQSlot::call(int i) const
}
switch (m_function) {
- case slotStateChanged: {
- RenderCheckBox *checkBox = dynamic_cast<RenderCheckBox *>(m_object.pointer());
- if (checkBox) {
- checkBox->slotStateChanged(i);
- }
+ case slotStateChanged:
+ static_cast<RenderCheckBox *>(m_object.pointer())->slotStateChanged(i);
return;
- }
- case slotSelected: {
- RenderSelect *select = dynamic_cast<RenderSelect *>(m_object.pointer());
- if (select) {
- select->slotSelected(i);
- }
+ case slotSelected:
+ static_cast<RenderSelect *>(m_object.pointer())->slotSelected(i);
return;
- }
}
call();
@@ -218,7 +202,7 @@ void KWQSlot::call(const QString &string) const
}
RenderFileButton *button = dynamic_cast<RenderFileButton *>(m_object.pointer());
if (button) {
- edit->slotTextChanged(string);
+ button->slotTextChanged(string);
}
return;
}
@@ -234,13 +218,9 @@ void KWQSlot::call(Job *job) const
}
switch (m_function) {
- case slotChildStarted: {
- KHTMLPart *part = dynamic_cast<KHTMLPart *>(m_object.pointer());
- if (part) {
- part->slotChildStarted(job);
- }
+ case slotChildStarted:
+ static_cast<KHTMLPart *>(m_object.pointer())->slotChildStarted(job);
return;
- }
}
call();
diff --git a/WebCore/kwq/KWQString.h b/WebCore/kwq/KWQString.h
index 9a4a060..a7cf720 100644
--- a/WebCore/kwq/KWQString.h
+++ b/WebCore/kwq/KWQString.h
@@ -473,7 +473,7 @@ private:
void detach();
void detachInternal();
void deref();
- void forceUnicode();
+ QChar *forceUnicode();
void setLength(uint);
QStringData *data() const;
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index 6541318..f33306e 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -215,7 +215,6 @@ static void freeHandle(void *free);
#define IS_ASCII_QCHAR(c) ((c).unicode() > 0 && (c).unicode() <= 0xff)
static const int caseDelta = ('a' - 'A');
-#define ASCII_TO_LOWER (p) ((p >= 'A' && p <= 'Z') ? (p + caseDelta) : p)
QStringData *QString::shared_null = 0;
QStringData **QString::shared_null_handle = 0;
@@ -716,20 +715,85 @@ void QString::setBufferFromCFString(CFStringRef cfs)
}
}
-// This function is used by the decoder. It will be replaced with TEC eventually.
+// This function is used by the decoder.
QString QString::fromStringWithEncoding(const char *chs, int len, CFStringEncoding encoding)
{
- QString qs;
+ ASSERT_ARG(len, len >= 0);
+ ASSERT_ARG(encoding, encoding != kCFStringEncodingInvalidId);
- if (chs && len > 0) {
- CFStringRef s = CFStringCreateWithBytes(kCFAllocatorDefault, (const UInt8 *)chs, len, encoding, true);
- if (s) {
- qs.setBufferFromCFString(s);
- CFRelease(s);
+ if (len <= 0) {
+ return QString::null;
+ }
+
+ // Get a converter for the passed-in encoding.
+ static TECObjectRef converter;
+ static CFStringEncoding converterEncoding = kCFStringEncodingInvalidId;
+ OSStatus status;
+ if (encoding != converterEncoding) {
+ TECObjectRef newConverter;
+ status = TECCreateConverter(&newConverter, encoding,
+ CreateTextEncoding(kTextEncodingUnicodeDefault, kTextEncodingDefaultVariant, kUnicode16BitFormat));
+ if (status) {
+ ERROR("the Text Encoding Converter won't convert from text encoding 0x%X, error %d", encoding, status);
+ return QString::null;
+ }
+ if (converter) {
+ TECDisposeConverter(converter);
}
+ converter = newConverter;
+ } else {
+ TECClearConverterContextInfo(converter);
}
- return qs;
+ const UInt8 *sourcePointer = (UInt8 *)chs;
+ unsigned long sourceLength = len;
+
+ QString result;
+ int resultLength = 0;
+
+ for (;;) {
+ UniChar buffer[4096];
+ unsigned long bytesWritten = 0;
+ bool doingFlush = sourceLength == 0;
+ if (doingFlush) {
+ status = TECFlushText(converter,
+ (UInt8 *)buffer, sizeof(buffer), &bytesWritten);
+ } else {
+ unsigned long bytesRead = 0;
+ status = TECConvertText(converter, sourcePointer, sourceLength, &bytesRead,
+ (UInt8 *)buffer, sizeof(buffer), &bytesWritten);
+ sourcePointer += bytesRead;
+ sourceLength -= bytesRead;
+ }
+ if (bytesWritten) {
+ ASSERT(bytesWritten % sizeof(UniChar) == 0);
+ result.setLength(resultLength + bytesWritten / sizeof(UniChar));
+ memcpy(result.forceUnicode() + resultLength, buffer, bytesWritten);
+ resultLength += bytesWritten / sizeof(UniChar);
+ }
+ if (status == kTextMalformedInputErr || status == kTextUndefinedElementErr) {
+ // FIXME: Put in FFFD character here?
+ TECClearConverterContextInfo(converter);
+ if (sourceLength) {
+ sourcePointer += 1;
+ sourceLength -= 1;
+ }
+ status = noErr;
+ }
+ if (status == kTECOutputBufferFullStatus) {
+ continue;
+ }
+ if (status != noErr) {
+ ERROR("text decoding failed with error %d", status);
+ break;
+ }
+ if (doingFlush) {
+ // Done.
+ break;
+ }
+ }
+
+ return result;
}
QString QString::fromCFString(CFStringRef cfs)
@@ -1144,30 +1208,33 @@ int QString::find(const QString &str, int index, bool caseSensitive) const
}
-static inline bool compareToLatinCharacter (UniChar c1, UniChar c2, bool caseSensitive)
+static inline bool compareIgnoringCaseForASCIIOnly(char c1, char c2)
{
- if (!caseSensitive){
- if (c2 >= 'a' && c2 <= 'z'){
- if (c1 == c2 || c1 == c2 - caseDelta)
- return true;
- }
- else if (c2 >= 'A' && c2 <= 'Z'){
- if (c1 == c2 || c1 == c2 + caseDelta)
- return true;
- }
- else if (c1 == c2)
- return true;
+ if (c2 >= 'a' && c2 <= 'z') {
+ return c1 == c2 || c1 == c2 - caseDelta;
}
- else if (c1 == c2)
- return true;
- return false;
+ if (c2 >= 'A' && c2 <= 'Z') {
+ return c1 == c2 || c1 == c2 + caseDelta;
+ }
+ return c1 == c2;
+}
+
+static inline bool compareIgnoringCaseForASCIIOnly(QChar c1, char c2)
+{
+ if (c2 >= 'a' && c2 <= 'z') {
+ return c1 == c2 || c1.unicode() == c2 - caseDelta;
+ }
+ if (c2 >= 'A' && c2 <= 'Z') {
+ return c1 == c2 || c1.unicode() == c2 + caseDelta;
+ }
+ return c1 == c2;
}
// This function should be as fast as possible, every little bit helps.
// Our usage patterns are typically small strings. In time trials
// this simplistic algorithm is much faster than Boyer-Moore or hash
-// based alrogithms.
+// based algorithms.
int QString::find(const char *chs, int index, bool caseSensitive) const
{
if (dataHandle[0]->_isAsciiValid){
@@ -1179,29 +1246,40 @@ int QString::find(const char *chs, int index, bool caseSensitive) const
ptr += index;
if (len && (index >= 0) && (index < len)) {
- QChar firstC, c1, c2;
- const char *_chs;
- int remaining = len - index, found = -1;
+ int remaining = len - index;
int compareToLength = strlen(chs);
- _chs = chs + 1;
- firstC = (QChar)(*chs);
- while (remaining >= compareToLength){
- if (compareToLatinCharacter((UniChar)*ptr++,firstC,caseSensitive)){
- char *compareTo = ptr;
-
- found = len - remaining;
- while ( (c2 = (UniChar)(*_chs++)) ){
- c1 = (UniChar)(*compareTo++);
- if (compareToLatinCharacter(c1, c2,caseSensitive))
- continue;
- break;
+ char firstC = *chs;
+
+ if (caseSensitive) {
+ while (remaining >= compareToLength) {
+ if (*ptr++ == firstC) {
+ const char *_chs = chs + 1;
+ char *compareTo = ptr;
+ char c2;
+ while ((c2 = *_chs++))
+ if (*compareTo++ != c2)
+ break;
+ if (c2 == 0)
+ return len - remaining;
}
- if (c2 == (QChar)0)
- return found;
- _chs = chs + 1;
+ remaining--;
+ }
+ } else {
+ while (remaining >= compareToLength) {
+ if (compareIgnoringCaseForASCIIOnly(*ptr++, firstC)) {
+ const char *_chs = chs + 1;
+ char *compareTo = ptr;
+ char c2;
+ while ((c2 = *_chs++))
+ if (!compareIgnoringCaseForASCIIOnly(*compareTo++, c2))
+ break;
+ if (c2 == 0)
+ return len - remaining;
+ _chs = chs + 1;
+ }
+ remaining--;
}
- remaining--;
}
}
}
@@ -1214,29 +1292,39 @@ int QString::find(const char *chs, int index, bool caseSensitive) const
ptr += index;
if (len && (index >= 0) && (index < len)) {
- QChar firstC, c1, c2;
- const char *_chs;
- int remaining = len - index, found = -1;
+ int remaining = len - index;
int compareToLength = strlen(chs);
-
- _chs = chs + 1;
- firstC = (QChar)(*chs);
- while (remaining >= compareToLength){
- if (compareToLatinCharacter((UniChar)*ptr++,firstC,caseSensitive)){
- QChar *compareTo = ptr;
-
- found = len - remaining;
- while ( (c2 = (UniChar)(*_chs++)) ){
- c1 = (UniChar)(*compareTo++);
- if (compareToLatinCharacter(c1, c2,caseSensitive))
- continue;
- break;
+
+ if (caseSensitive) {
+ QChar firstC = *chs;
+ while (remaining >= compareToLength) {
+ if (*ptr++ == firstC) {
+ QChar *compareTo = ptr;
+ const char *_chs = chs + 1;
+ char c2;
+ while ((c2 = *_chs++))
+ if (*compareTo++ != c2)
+ break;
+ if (c2 == 0)
+ return len - remaining;
}
- if (c2 == (QChar)0)
- return found;
- _chs = chs + 1;
+ remaining--;
+ }
+ } else {
+ char firstC = *chs;
+ while (remaining >= compareToLength) {
+ if (compareIgnoringCaseForASCIIOnly(*ptr++, firstC)) {
+ QChar *compareTo = ptr;
+ const char *_chs = chs + 1;
+ char c2;
+ while ((c2 = *_chs++))
+ if (!compareIgnoringCaseForASCIIOnly(*compareTo++, c2))
+ break;
+ if (c2 == 0)
+ return len - remaining;
+ }
+ remaining--;
}
- remaining--;
}
}
}
@@ -1803,10 +1891,9 @@ QString QString::stripWhiteSpace() const
memcpy( (char *)result.data()->ascii(), &ascii()[start], l );
}
else if (dataHandle[0]->_isUnicodeValid){
- result.forceUnicode();
result.setLength( l );
if ( l )
- memcpy( (QChar *)result.data()->unicode(), &unicode()[start], sizeof(QChar)*l );
+ memcpy(result.forceUnicode(), &unicode()[start], sizeof(QChar)*l );
}
else
FATAL("invalid character cache");
@@ -1842,13 +1929,12 @@ QString QString::simplifyWhiteSpace() const
result.truncate( outc );
}
else if (dataHandle[0]->_isUnicodeValid){
- result.forceUnicode();
result.setLength( dataHandle[0]->_length );
const QChar *from = unicode();
const QChar *fromend = from + dataHandle[0]->_length;
int outc=0;
- QChar *to = (QChar *)result.unicode();
+ QChar *to = result.forceUnicode();
while ( TRUE ) {
while ( from!=fromend && from->isSpace() )
from++;
@@ -2090,8 +2176,7 @@ QString &QString::insert(uint index, const QString &qs)
// Ensure that we have enough space.
setLength (originalLength + insertLength);
- forceUnicode();
- targetChars = (QChar *)unicode();
+ targetChars = forceUnicode();
// Move tail to make space for inserted characters.
memmove (targetChars+(index+insertLength), targetChars+index, (originalLength-index)*sizeof(QChar));
@@ -2145,8 +2230,7 @@ QString &QString::insert(uint index, QChar qc)
// Ensure that we have enough space.
setLength (originalLength + 1);
- forceUnicode();
- targetChars = (QChar *)unicode();
+ targetChars = forceUnicode();
// Move tail to make space for inserted character.
memmove (targetChars+(index+1), targetChars+index, (originalLength-index)*sizeof(QChar));
@@ -2273,8 +2357,9 @@ QString &QString::remove(uint index, uint len)
detach();
#ifdef QSTRING_DEBUG_UNICODE
- forceUnicode();
+ forceUnicode();
#endif
+
if (dataHandle[0]->_isAsciiValid){
memmove( dataHandle[0]->ascii()+index, dataHandle[0]->ascii()+index+len,
sizeof(char)*(olen-index-len) );
@@ -2328,14 +2413,12 @@ QString &QString::replace(const QRegExp &qre, const QString &str)
}
-
-void QString::forceUnicode()
+QChar *QString::forceUnicode()
{
detach();
-
- unicode();
-
+ QChar *result = const_cast<QChar *>(unicode());
dataHandle[0]->_isAsciiValid = 0;
+ return result;
}
@@ -2413,9 +2496,8 @@ void QString::fill(QChar qc, int len)
dataHandle[0]->_isUnicodeValid = 0;
}
else {
- forceUnicode();
setLength(len);
- QChar *nd = (QChar *)unicode();
+ QChar *nd = forceUnicode();
while (len--)
*nd++ = qc;
}
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index f1f56b4..9fffebd 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -282,7 +282,7 @@ using khtml::RenderPart;
int nx, ny;
node->absolutePosition(nx,ny);
NSObject *copiedNode = [copier nodeWithName:name
- position:NSMakePoint(nx,ny)
+ position:NSMakePoint(nx,ny)
rect:NSMakeRect(node->xPos(), node->yPos(), node->width(), node->height())
view:view
children:children];
@@ -366,13 +366,15 @@ using khtml::RenderPart;
state |= [self stateForEvent:event];
if (part->impl->view()) {
- if ([event clickCount] % 2 == 0){
- QMouseEvent kEvent(QEvent::MouseButtonDblClick, QPoint((int)p.x, (int)p.y), button, state, [event clickCount]);
- part->impl->view()->viewportMouseDoubleClickEvent(&kEvent);
- }
- else {
- QMouseEvent kEvent(QEvent::MouseButtonRelease, QPoint((int)p.x, (int)p.y), button, state, [event clickCount]);
- part->impl->view()->viewportMouseReleaseEvent(&kEvent);
+ int clickCount = [event clickCount];
+
+ // Qt documentation says you always get a release event before a double-click event.
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(p), button, state, clickCount);
+ part->impl->view()->viewportMouseReleaseEvent(&releaseEvent);
+
+ if (clickCount > 0 && clickCount % 2 == 0) {
+ QMouseEvent doubleClickEvent(QEvent::MouseButtonDblClick, QPoint(p), button, state, clickCount);
+ part->impl->view()->viewportMouseDoubleClickEvent(&doubleClickEvent);
}
}
}
@@ -399,7 +401,7 @@ using khtml::RenderPart;
state |= [self stateForEvent:event];
if (part->impl->view()) {
- QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state, [event clickCount]);
+ QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint(p), button, state, [event clickCount]);
part->impl->view()->viewportMousePressEvent(&kEvent);
}
}
@@ -408,7 +410,7 @@ using khtml::RenderPart;
{
NSPoint p = [event locationInWindow];
- QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), 0, [self stateForEvent:event]);
+ QMouseEvent kEvent(QEvent::MouseMove, QPoint(p), 0, [self stateForEvent:event]);
if (part->impl->view()) {
part->impl->view()->viewportMouseMoveEvent(&kEvent);
}
@@ -418,7 +420,7 @@ using khtml::RenderPart;
{
NSPoint p = [event locationInWindow];
- QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), Qt::LeftButton, Qt::LeftButton);
+ QMouseEvent kEvent(QEvent::MouseMove, QPoint(p), Qt::LeftButton, Qt::LeftButton);
if (part->impl->view()) {
part->impl->view()->viewportMouseMoveEvent(&kEvent);
}
diff --git a/WebCore/kwq/qt/qcolor.h b/WebCore/kwq/qt/qcolor.h
index 5ba0d15..8a73ca3 100644
--- a/WebCore/kwq/qt/qcolor.h
+++ b/WebCore/kwq/qt/qcolor.h
@@ -39,27 +39,26 @@ typedef unsigned int QRgb; // RGB triplet
QRgb qRgb(int r, int g, int b);
QRgb qRgba(int r, int g, int b, int a);
+const QRgb KWQInvalidColor = 0x40000000;
+
class QColor {
public:
- QColor();
- QColor(int,int,int);
+ QColor() : color(KWQInvalidColor) { }
+ QColor(int r, int g, int b) : color(qRgb(r, g, b)) { }
explicit QColor(const QString &);
QColor(const char *); // can't be explicit because of helper.cpp
- QColor(const QColor &);
-
- ~QColor();
QString name() const;
void setNamedColor(const QString&);
- bool isValid() const;
+ bool isValid() const { return color != KWQInvalidColor; }
- int red() const;
- int green() const;
- int blue() const;
- QRgb rgb() const;
- void setRgb(int,int,int);
- void setRgb(int);
+ int red() const { return (color >> 16) & 0xFF; }
+ int green() const { return (color >> 8) & 0xFF; }
+ int blue() const { return color & 0xFF; }
+ QRgb rgb() const { return color & 0xFFFFFF; }
+ void setRgb(int r, int g, int b) { color = qRgb(r, g, b); }
+ void setRgb(int rgb) { color = rgb; }
void hsv(int *, int *, int *) const;
void setHsv(int h, int s, int v);
@@ -67,14 +66,23 @@ public:
QColor light(int f = 150) const;
QColor dark(int f = 200) const;
- QColor &operator=(const QColor &);
- bool operator==(const QColor &x) const;
- bool operator!=(const QColor &x) const;
+ friend bool operator==(const QColor &a, const QColor &b);
+ friend bool operator!=(const QColor &a, const QColor &b);
NSColor *getNSColor() const;
private:
- NSColor *color;
+ QRgb color;
};
+inline bool operator==(const QColor &a, const QColor &b)
+{
+ return a.color == b.color;
+}
+
+inline bool operator!=(const QColor &a, const QColor &b)
+{
+ return a.color != b.color;
+}
+
#endif
diff --git a/WebCore/kwq/qt/qstring.h b/WebCore/kwq/qt/qstring.h
index 9a4a060..a7cf720 100644
--- a/WebCore/kwq/qt/qstring.h
+++ b/WebCore/kwq/qt/qstring.h
@@ -473,7 +473,7 @@ private:
void detach();
void detachInternal();
void deref();
- void forceUnicode();
+ QChar *forceUnicode();
void setLength(uint);
QStringData *data() const;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list