[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
kocienda
kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:51:09 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 43b0e396d2c6f79b59dba4b01ac2e81a81dfefb9
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Oct 25 23:01:46 2001 +0000
This is a fairly bit set of changes that improves rendering.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/khtml/css/csshelper.cpp b/WebCore/khtml/css/csshelper.cpp
index 472a425..515fcfa 100644
--- a/WebCore/khtml/css/csshelper.cpp
+++ b/WebCore/khtml/css/csshelper.cpp
@@ -54,8 +54,10 @@ float khtml::computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *st
float dpiY = 72.; // fallback
if ( devMetrics )
dpiY = devMetrics->logicalDpiY();
- if ( !khtml::printpainter && dpiY < 96 )
- dpiY = 96.;
+
+ // FIXME: SCREEN_RESOLUTION hack good enough to keep?
+ if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
+ dpiY = SCREEN_RESOLUTION;
float factor = 1.;
switch(type)
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index d711ea9..24b33ca 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -73,7 +73,6 @@ static int usedDynamicStates;
static int selectorDynamicState;
static CSSStyleSelector::Encodedurl *encodedurl;
-
CSSStyleSelector::CSSStyleSelector(DocumentImpl * doc)
{
strictParsing = doc->parseMode() == DocumentImpl::Strict;
@@ -1945,8 +1944,9 @@ void khtml::applyRule(khtml::RenderStyle *style, DOM::CSSProperty *prop, DOM::El
float toPix = 1.; // fallback
if ( !khtml::printpainter )
toPix = paintDeviceMetrics->logicalDpiY()/72.;
- if ( !khtml::printpainter && toPix < 96./72. )
- toPix = 96./72.;
+ // FIXME: SCREEN_RESOLUTION hack good enough to keep?
+ if ( !khtml::printpainter && toPix < SCREEN_RESOLUTION/72 )
+ toPix = SCREEN_RESOLUTION/72;
QValueList<int> standardSizes = e->ownerDocument()->view()->part()->fontSizes();
if(e->parentNode()) {
diff --git a/WebCore/khtml/khtmlview.cpp b/WebCore/khtml/khtmlview.cpp
index 2fca10a..41c20b2 100644
--- a/WebCore/khtml/khtmlview.cpp
+++ b/WebCore/khtml/khtmlview.cpp
@@ -309,15 +309,21 @@ static void printRenderTree(RenderObject *node, int level)
void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
{
+ // FIXME: make the height work correctly with the scroll view
+ eh = 780;
+
+
if(!m_part->xmlDocImpl()) {
p->fillRect(ex, ey, ew, eh, palette().normal().brush(QColorGroup::Base));
return;
}
- kdDebug( 6000 ) << "drawContents x=" << ex << ",y=" << ey << ",w=" << ew << ",h=" << eh << endl;
+ //kdDebug( 6000 ) << "drawContents x=" << ex << ",y=" << ey << ",w=" << ew << ",h=" << eh << endl;
if ( d->paintBuffer->width() < visibleWidth() )
- d->paintBuffer->resize(visibleWidth(),PAINT_BUFFER_HEIGHT);
+ // FIXME: make the height work correctly with the scroll view
+ //d->paintBuffer->resize(visibleWidth(),PAINT_BUFFER_HEIGHT);
+ d->paintBuffer->resize(visibleWidth(),780);
int py=0;
while (py < eh) {
@@ -334,7 +340,9 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
if (doc){
ro = doc->renderer();
if (ro){
+#ifdef RENDER_TREE_DEBUG
printRenderTree (ro, 0);
+#endif
ro->print(d->tp, ex, ey+py, ew, ph, 0, 0);
}
}
@@ -347,7 +355,9 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
#endif
d->tp->end();
- p->drawPixmap(ex, ey+py, *d->paintBuffer, 0, 0, ew, ph);
+ // FIXME: make the height work correctly with the scroll view
+ //p->drawPixmap(ex, ey+py, *d->paintBuffer, 0, 0, ew, ph);
+ p->drawPixmap(ex, ey+py, *d->paintBuffer, ex, ey+py, ew, ph);
py += PAINT_BUFFER_HEIGHT;
}
diff --git a/WebCore/khtml/misc/helper.cpp b/WebCore/khtml/misc/helper.cpp
index ea1826e..dca84ae 100644
--- a/WebCore/khtml/misc/helper.cpp
+++ b/WebCore/khtml/misc/helper.cpp
@@ -153,12 +153,16 @@ using namespace khtml;
static HTMLColors *htmlColors = 0L;
-static KStaticDeleter<HTMLColors> hcsd;
+// FIXME: do we really need static delete support here?
+//static KStaticDeleter<HTMLColors> hcsd;
void khtml::setNamedColor(QColor &color, const QString &_name)
{
- if( !htmlColors )
- htmlColors = hcsd.setObject( new HTMLColors );
+ if( !htmlColors ) {
+ // FIXME: do we really need static delete support here?
+ // htmlColors = hcsd.setObject( new HTMLColors );
+ htmlColors = new HTMLColors();
+ }
int pos;
QString name = _name;
@@ -176,26 +180,16 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
// also recognize "color=ffffff"
if (len == 6)
{
- bool ok;
- int val = name.toInt(&ok, 16);
- if(ok)
- {
- color.setRgb((0xff << 24) | val);
- return;
- }
- // recognize #12345 (duplicate the last character)
+ // recognize #12345 (append a '0')
if(name[0] == '#') {
- bool ok;
- int val = name.right(5).toInt(&ok, 16);
- if(ok) {
- color.setRgb((0xff << 24) | (val * 16 + ( val&0xf )));
- return;
- }
+ name += '0';
}
- if ( !name[0].isLetter() ) {
- color = QColor();
- return;
- }
+ else if ((!name[0].isLetter() && !name[0].isDigit())) {
+ color = QColor();
+ return;
+ }
+
+ color.setNamedColor(name);
}
// #fffffff as found on msdn.microsoft.com
@@ -232,13 +226,14 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
}
else
{
- //QColor tc = htmlColors->map[name];
- QColor tc = QColor (0,0,0);
- if ( !tc.isValid() )
+ QColor tc = htmlColors->map[name];
+
+ if (!tc.isValid()) {
tc = htmlColors->map[name.lower()];
-
- if (tc.isValid())
+ }
+ if (tc.isValid()) {
color = tc;
+ }
else {
color.setNamedColor(name);
if ( !color.isValid() ) color.setNamedColor( name.lower() );
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index b921ada..d30f046 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -78,6 +78,7 @@
using namespace DOM;
using namespace khtml;
+
//template class QStack<DOM::NodeImpl>; // needed ?
@@ -585,8 +586,11 @@ void DocumentImpl::recalcStyle()
float dpiY = 72.; // fallback
if ( !khtml::printpainter )
dpiY = paintDeviceMetrics()->logicalDpiY();
- if ( !khtml::printpainter && dpiY < 96 )
- dpiY = 96.;
+ // FIXME: Is SCREEN_RESOLUTION hack good enough?
+ //if ( !khtml::printpainter && dpiY < 96 )
+ // dpiY = 96.;
+ if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
+ dpiY = SCREEN_RESOLUTION;
float size = fs[3] * dpiY / 72.;
if(size < settings->minFontSize())
size = settings->minFontSize();
diff --git a/WebCore/kwq/KWQColor.h b/WebCore/kwq/KWQColor.h
index 830391a..4f1882f 100644
--- a/WebCore/kwq/KWQColor.h
+++ b/WebCore/kwq/KWQColor.h
@@ -63,6 +63,7 @@ public:
QColor();
QColor(int,int,int);
+ QColor(const QString &);
QColor(const char *);
QColor(const QColor &);
diff --git a/WebCore/kwq/KWQColor.mm b/WebCore/kwq/KWQColor.mm
index 9989981..ca550ef 100644
--- a/WebCore/kwq/KWQColor.mm
+++ b/WebCore/kwq/KWQColor.mm
@@ -55,6 +55,11 @@ QColor::QColor(int r, int g, int b)
_initialize (r, g, b);
}
+QColor::QColor(const QString &name)
+{
+ color = nil;
+ setNamedColor(name);
+}
QColor::QColor(const char *name)
{
@@ -90,14 +95,14 @@ QColor::QColor(const QColor ©From)
color = nil;
}
-
QString QColor::name() const
{
- NSLog (@"WARNING %s:%s:%d (NOT YET IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
- // FIXME! Must map onto named colors.
- return "white";
-}
+ NSString *name;
+ name = [NSString stringWithFormat:@"#%02x%02x%02x", red(), green(), blue()];
+
+ return NSSTRING_TO_QSTRING(name);
+}
static int hex2int( QChar hexchar )
{
@@ -116,39 +121,46 @@ static int hex2int( QChar hexchar )
void QColor::setNamedColor(const QString&name)
{
+
if ( name.isEmpty() ) {
setRgb( 0 );
- } else if ( name[0] == '#' ) {
- const QChar *p = name.unicode()+1;
- int len = name.length()-1;
- int r, g, b;
- if ( len == 12 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- g = (hex2int(p[4]) << 4) + hex2int(p[5]);
- b = (hex2int(p[8]) << 4) + hex2int(p[9]);
- } else if ( len == 9 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- g = (hex2int(p[3]) << 4) + hex2int(p[4]);
- b = (hex2int(p[6]) << 4) + hex2int(p[7]);
- } else if ( len == 6 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- g = (hex2int(p[2]) << 4) + hex2int(p[3]);
- b = (hex2int(p[4]) << 4) + hex2int(p[5]);
- } else if ( len == 3 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[0]);
- g = (hex2int(p[1]) << 4) + hex2int(p[1]);
- b = (hex2int(p[2]) << 4) + hex2int(p[2]);
- } else {
- r = g = b = 0;
+ }
+ else if ( name[0] == '#' || name.length() == 6) {
+ int offset = 0;
+ if (name[0] == '#') {
+ offset = 1;
+ }
+ const QChar *p = name.unicode() + offset;
+ int len = name.length();
+ int r, g, b;
+ if ( len == 12 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ g = (hex2int(p[4]) << 4) + hex2int(p[5]);
+ b = (hex2int(p[8]) << 4) + hex2int(p[9]);
+ } else if ( len == 9 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ g = (hex2int(p[3]) << 4) + hex2int(p[4]);
+ b = (hex2int(p[6]) << 4) + hex2int(p[7]);
+ } else if ( len == 6 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ g = (hex2int(p[2]) << 4) + hex2int(p[3]);
+ b = (hex2int(p[4]) << 4) + hex2int(p[5]);
+ } else if ( len == 3 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[0]);
+ g = (hex2int(p[1]) << 4) + hex2int(p[1]);
+ b = (hex2int(p[2]) << 4) + hex2int(p[2]);
+ } else {
+ r = g = b = 0;
}
setRgb( r, g, b );
+
} else {
if (color != nil)
[color release];
color = [NSColor colorWithCatalogName: @"Apple" colorName: QSTRING_TO_NSSTRING(name)];
if (color == nil) {
NSLog (@"WARNING %s:%d %s couldn't create color using name %s\n", __FILE__, __LINE__, __FUNCTION__, name.ascii());
- color = [NSColor blackColor];
+ color = [NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:1];
}
}
}
@@ -156,7 +168,15 @@ void QColor::setNamedColor(const QString&name)
bool QColor::isValid() const
{
- return TRUE;
+ bool result;
+
+ result = TRUE;
+
+ if (color == nil) {
+ result = FALSE;
+ }
+
+ return result;
}
diff --git a/WebCore/kwq/KWQFont.mm b/WebCore/kwq/KWQFont.mm
index a8e150b..4ea26e4 100644
--- a/WebCore/kwq/KWQFont.mm
+++ b/WebCore/kwq/KWQFont.mm
@@ -61,7 +61,8 @@ void QFont::_initializeWithFont (const QFont *withFont)
QFont::QFont(const QFont ©From)
{
_initializeWithFont(©From);
- _free();
+ // FIXME: why were we freeing here?
+ //_free();
}
diff --git a/WebCore/kwq/KWQKHTMLSettings.h b/WebCore/kwq/KWQKHTMLSettings.h
index 977b7de..fc6a9a0 100644
--- a/WebCore/kwq/KWQKHTMLSettings.h
+++ b/WebCore/kwq/KWQKHTMLSettings.h
@@ -35,6 +35,9 @@
#include <qfont.h>
#include <qmap.h>
+// FIXME: I am resetting the default screen resolution to 72
+#define SCREEN_RESOLUTION 72.0f
+
class KHTMLSettings
{
public:
diff --git a/WebCore/kwq/KWQPaintDeviceMetrics.mm b/WebCore/kwq/KWQPaintDeviceMetrics.mm
index 822c4da..6ef92bf 100644
--- a/WebCore/kwq/KWQPaintDeviceMetrics.mm
+++ b/WebCore/kwq/KWQPaintDeviceMetrics.mm
@@ -34,7 +34,7 @@ QPaintDeviceMetrics::QPaintDeviceMetrics(const QPaintDevice *)
int QPaintDeviceMetrics::logicalDpiY() const
{
- _logPartiallyImplemented();
+ //_logPartiallyImplemented();
return 72;
}
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index 543ec4a..6c308aa 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -44,6 +44,7 @@
class QFont;
class QPixmap;
class QWidget;
+class QPainterPrivate;
// class QWMatrix ==============================================================
@@ -186,20 +187,8 @@ private:
void _initialize(QWidget *widget);
void _drawPoints (const QPointArray &_points, bool winding, int index, int _npoints, bool fill);
- struct KWQPainterData { // QPainter data.
- QWidget *widget; // Has a reference to a KWQView.
- QFont qfont;
- QBrush qbrush;
- QPen qpen;
- uint isFocusLocked:1;
- void *ps_stack;
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSCompositingOperation compositingOperation;
-#else
- uint compositingOperation;
-#endif
- const QPaintDevice *bufferDevice;
- } *data;
+ QPainterPrivate *data;
+
#endif
}; // end class QPainter
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 094d1fb..ee78790 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -34,6 +34,36 @@
#import <Cocoa/Cocoa.h>
+struct QPainterPrivate {
+friend class QPainter;
+public:
+
+ QPainterPrivate(QWidget *widget) :
+ widget(widget),
+ qfont(),
+ qbrush(),
+ qpen(),
+ isFocusLocked(0),
+ ps_stack(0L),
+ compositingOperation(NSCompositeCopy),
+ bufferDevice(0L)
+ {
+ }
+
+ ~QPainterPrivate() {}
+
+private:
+ QWidget *widget; // Has a reference to a KWQView.
+ QFont qfont;
+ QBrush qbrush;
+ QPen qpen;
+ uint isFocusLocked:1;
+ void *ps_stack;
+ NSCompositingOperation compositingOperation;
+ const QPaintDevice *bufferDevice;
+};
+
+
struct QPState { // painter state
QFont font;
QPen pen;
@@ -64,20 +94,14 @@ QPainter::QPainter(QWidget *widget)
void QPainter::_initialize(QWidget *widget)
{
- data = (struct KWQPainterData *)calloc (1, sizeof (struct KWQPainterData));
- data->widget = widget;
- data->qpen = QPen (Qt::black);
- data->isFocusLocked = 0;
- data->compositingOperation = NSCompositeCopy;
- data->bufferDevice = 0L;
+ data = new QPainterPrivate(widget);
}
QPainter::~QPainter()
{
- free (data);
+ delete data;
}
-
const QFont &QPainter::font() const
{
@@ -108,9 +132,11 @@ void QPainter::setPen(const QPen &pen)
}
-void QPainter::setPen(PenStyle)
+void QPainter::setPen(PenStyle ps)
{
- _logNotYetImplemented();
+ data->qpen.setStyle(ps);
+ data->qpen.setColor(Qt::black);
+ data->qpen.setWidth(0);
}
@@ -175,7 +201,6 @@ void QPainter::restore()
// Draws a filled rectangle with a stroked border.
void QPainter::drawRect(int x, int y, int w, int h)
{
- /*
_lockFocus();
if (data->qbrush.qbrushstyle == SolidPattern){
//_setColorFromBrush();
@@ -184,7 +209,6 @@ void QPainter::drawRect(int x, int y, int w, int h)
_setColorFromPen();
[NSBezierPath strokeRect:NSMakeRect(x, y, w, h)];
_unlockFocus();
- */
}
@@ -196,7 +220,7 @@ void QPainter::_setColorFromBrush()
void QPainter::_setColorFromPen()
{
- [data->qpen.qcolor.color set];
+ [data->qpen.color().color set];
}
@@ -406,7 +430,7 @@ void QPainter::drawText(int x, int y, const QString &qstring, int len)
//font = data->qfont.data->font;
font = data->qfont.font;
-
+
if (len == -1)
string = QSTRING_TO_NSSTRING(qstring);
else
@@ -415,7 +439,8 @@ void QPainter::drawText(int x, int y, const QString &qstring, int len)
// This will draw the text from the top of the bounding box down.
// Qt expects to draw from the baseline.
y = y - (int)([font defaultLineHeightForFont] + [font descender]);
- [string drawAtPoint:NSMakePoint(x, y) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.qcolor.color, NSForegroundColorAttributeName, nil]];
+
+ [string drawAtPoint:NSMakePoint(x, y) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.color().color, NSForegroundColorAttributeName, nil]];
_unlockFocus();
}
@@ -433,7 +458,7 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString&qst
//font = data->qfont.data->font;
font = data->qfont.font;
-
+
if (len == -1)
string = QSTRING_TO_NSSTRING(qstring);
else
@@ -454,7 +479,7 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString&qst
[style setAlignment: NSLeftTextAlignment];
}
- [string drawInRect:NSMakeRect(x, y, w, h) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.qcolor.color, NSForegroundColorAttributeName, style, NSParagraphStyleAttributeName, nil]];
+ [string drawInRect:NSMakeRect(x, y, w, h) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.color().color, NSForegroundColorAttributeName, style, NSParagraphStyleAttributeName, nil]];
_unlockFocus();
}
@@ -463,14 +488,12 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString&qst
void QPainter::fillRect(int x, int y, int w, int h, const QBrush &brush)
{
- /*
_lockFocus();
if (brush.qbrushstyle == SolidPattern){
- //[brush.qcolor.color set];
- //[NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
+ [brush.qcolor.color set];
+ [NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
}
_unlockFocus();
- */
}
@@ -488,8 +511,8 @@ void QPainter::setClipRegion(const QRegion &)
const QRegion &QPainter::clipRegion() const
{
- _logNotYetImplemented();
- return QRegion();
+ _logPartiallyImplemented();
+ return QRegion::null;
}
diff --git a/WebCore/kwq/KWQPen.h b/WebCore/kwq/KWQPen.h
index 014622b..4942dad 100644
--- a/WebCore/kwq/KWQPen.h
+++ b/WebCore/kwq/KWQPen.h
@@ -30,8 +30,10 @@
#include <config.h>
#endif
-#include "qnamespace.h"
-#include "qcolor.h"
+#include <qnamespace.h>
+#include <qcolor.h>
+
+class QPenPrivate;
// class QPen ==================================================================
@@ -46,13 +48,19 @@ public:
// constructors, copy constructors, and destructors ------------------------
QPen();
- QPen(const QColor &color, uint width=0, PenStyle style=SolidLine);
- QPen(const QPen &);
+ QPen(const QColor &c, uint w=0, PenStyle ps=SolidLine);
+ QPen(const QPen &pen);
~QPen();
// member functions --------------------------------------------------------
const QColor &color() const;
+ uint width() const;
+ PenStyle style() const;
+
+ void setColor(const QColor &);
+ void setWidth(uint);
+ void setStyle(PenStyle);
// operators ---------------------------------------------------------------
@@ -63,7 +71,8 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
- QColor qcolor;
+private:
+ QPenPrivate *d;
}; // class QPen ===============================================================
diff --git a/WebCore/kwq/KWQPen.mm b/WebCore/kwq/KWQPen.mm
index 50735fe..fc3d666 100644
--- a/WebCore/kwq/KWQPen.mm
+++ b/WebCore/kwq/KWQPen.mm
@@ -25,44 +25,92 @@
#include <qpen.h>
+class QPenPrivate
+{
+friend class QPen;
+public:
+
+ QPenPrivate(const QColor &c, uint w, QPen::PenStyle ps) :
+ qcolor(c), width(w), penStyle(ps)
+ {
+ }
+
+ ~QPenPrivate() {}
+
+private:
+ QColor qcolor;
+ uint width;
+ QPen::PenStyle penStyle;
+};
+
+
QPen::QPen()
{
- qcolor = Qt::black;
+ d = new QPenPrivate(Qt::black, 3, SolidLine);
}
-QPen::QPen(const QColor &color, uint width, PenStyle style)
+QPen::QPen(const QColor &c, uint w, PenStyle ps)
{
- qcolor = color;
+ d = new QPenPrivate(c, w, ps);
}
QPen::QPen(const QPen ©From)
{
- qcolor = copyFrom.qcolor;
+ d->qcolor = copyFrom.d->qcolor;
}
QPen::~QPen()
{
+ delete d;
}
const QColor &QPen::color() const
{
- return qcolor;
+ return d->qcolor;
+}
+
+uint QPen::width() const
+{
+ return d->width;
+}
+
+QPen::PenStyle QPen::style() const
+{
+ return d->penStyle;
+}
+
+void QPen::setColor(const QColor &c)
+{
+ d->qcolor = c;
}
+void QPen::setWidth(uint w)
+{
+ d->width = w;
+}
+
+void QPen::setStyle(PenStyle ps)
+{
+ d->penStyle = ps;
+}
QPen &QPen::operator=(const QPen &assignFrom)
{
- qcolor = assignFrom.qcolor;
+ d->qcolor = assignFrom.d->qcolor;
+ d->width = assignFrom.d->width;
+ d->penStyle = assignFrom.d->penStyle;
return *this;
}
bool QPen::operator==(const QPen &compareTo) const
{
- return qcolor == compareTo.qcolor;
+ return (d->width == compareTo.d->width) &&
+ (d->penStyle == compareTo.d->penStyle) &&
+ (d->qcolor == compareTo.d->qcolor);
}
diff --git a/WebCore/kwq/KWQRegion.h b/WebCore/kwq/KWQRegion.h
index b087a40..a12b17a 100644
--- a/WebCore/kwq/KWQRegion.h
+++ b/WebCore/kwq/KWQRegion.h
@@ -67,6 +67,9 @@ public:
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
+
+ static const QRegion null;
+
// static member functions -------------------------------------------------
// constructors, copy constructors, and destructors ------------------------
diff --git a/WebCore/kwq/KWQRegion.mm b/WebCore/kwq/KWQRegion.mm
index 8c9c3eb..8fa00ff 100644
--- a/WebCore/kwq/KWQRegion.mm
+++ b/WebCore/kwq/KWQRegion.mm
@@ -27,6 +27,8 @@
#include <kwqdebug.h>
+const QRegion QRegion::null;
+
void QRegion::_initialize() {
data = calloc(1, sizeof(struct KWQRegionData));
data->type = Rectangle;
diff --git a/WebCore/kwq/KWQString.h b/WebCore/kwq/KWQString.h
index 4c02532..cb2ddfc 100644
--- a/WebCore/kwq/KWQString.h
+++ b/WebCore/kwq/KWQString.h
@@ -230,10 +230,7 @@ public:
bool isNull() const;
bool isEmpty() const;
- // NOTE: at is useful to keep as implementation of operator[]
-//#ifdef USING_BORROWED_KURL
QChar at(uint) const;
-//#endif
int compare(const QString &) const;
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index bef09ac..422d449 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -637,10 +637,14 @@ double QString::toDouble(bool *ok) const
if (ok) {
// NOTE: since CFStringGetDoubleValue returns 0.0 on error there is no
// way to know if "n" is valid in that case
- if (n == 0.0) {
+ //
+ // EXTRA NOTE: We can't assume 0.0 is bad, since it totally breaks
+ // html like border="0". So, only trigger breakage if the char
+ // at index 0 is neither a '0' nor a '.' nor a '-'.
+ UniChar uc = CFStringGetCharacterAtIndex(s,0);
+ *ok = TRUE;
+ if (n == 0.0 && uc != '0' && uc != '.' && uc != '-') {
*ok = FALSE;
- } else {
- *ok = TRUE;
}
}
return n;
@@ -1261,24 +1265,24 @@ ulong QString::convertToNumber(bool *ok, int base, bool *neg) const
uc = CFStringGetCharacterFromInlineBuffer(&buf, i);
// NOTE: ignore anything other than base 10 and base 16
if ((uc >= '0') && (uc <= '9')) {
- if (n > (max / 10)) {
+ if (n > (max / base)) {
valid = FALSE;
break;
}
- n = (n * 10) + (uc - '0');
+ n = (n * base) + (uc - '0');
} else if (base == 16) {
if ((uc >= 'A') && (uc <= 'F')) {
- if (n > (max / 16)) {
+ if (n > (max / base)) {
valid = FALSE;
break;
}
- n = (n * 16) + (10 + (uc - 'A'));
+ n = (n * base) + (10 + (uc - 'A'));
} else if ((uc >= 'a') && (uc <= 'f')) {
- if (n > (max / 16)) {
+ if (n > (max / base)) {
valid = FALSE;
break;
}
- n = (n * 16) + (10 + (uc - 'a'));
+ n = (n * base) + (10 + (uc - 'a'));
} else {
break;
}
diff --git a/WebCore/kwq/KWQVariant.mm b/WebCore/kwq/KWQVariant.mm
index 0779ef7..6e81d8b 100644
--- a/WebCore/kwq/KWQVariant.mm
+++ b/WebCore/kwq/KWQVariant.mm
@@ -25,53 +25,68 @@
#include <qvariant.h>
+#include <kwqdebug.h>
QVariant::QVariant()
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(bool, int)
+QVariant::QVariant(bool b, int i)
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(double)
+QVariant::QVariant(double d)
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(const QString &)
+QVariant::QVariant(const QString &s)
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(const QVariant &)
+QVariant::QVariant(const QVariant &other)
{
+ _logNotYetImplemented();
}
QVariant::~QVariant()
{
+ _logNotYetImplemented();
}
QVariant::Type QVariant::type() const
{
+ _logNotYetImplemented();
+ return UInt;
}
bool QVariant::toBool() const
{
+ _logNotYetImplemented();
+ return 0;
}
uint QVariant::toUInt() const
{
+ _logNotYetImplemented();
+ return 0;
}
-QVariant &QVariant::operator=(const QVariant &)
+QVariant &QVariant::operator=(const QVariant &other)
{
+ _logNotYetImplemented();
+ return *this;
}
diff --git a/WebCore/kwq/khtml/khtml_settings.h b/WebCore/kwq/khtml/khtml_settings.h
index 977b7de..fc6a9a0 100644
--- a/WebCore/kwq/khtml/khtml_settings.h
+++ b/WebCore/kwq/khtml/khtml_settings.h
@@ -35,6 +35,9 @@
#include <qfont.h>
#include <qmap.h>
+// FIXME: I am resetting the default screen resolution to 72
+#define SCREEN_RESOLUTION 72.0f
+
class KHTMLSettings
{
public:
diff --git a/WebCore/kwq/qt/qcolor.h b/WebCore/kwq/qt/qcolor.h
index 830391a..4f1882f 100644
--- a/WebCore/kwq/qt/qcolor.h
+++ b/WebCore/kwq/qt/qcolor.h
@@ -63,6 +63,7 @@ public:
QColor();
QColor(int,int,int);
+ QColor(const QString &);
QColor(const char *);
QColor(const QColor &);
diff --git a/WebCore/kwq/qt/qpainter.h b/WebCore/kwq/qt/qpainter.h
index 543ec4a..6c308aa 100644
--- a/WebCore/kwq/qt/qpainter.h
+++ b/WebCore/kwq/qt/qpainter.h
@@ -44,6 +44,7 @@
class QFont;
class QPixmap;
class QWidget;
+class QPainterPrivate;
// class QWMatrix ==============================================================
@@ -186,20 +187,8 @@ private:
void _initialize(QWidget *widget);
void _drawPoints (const QPointArray &_points, bool winding, int index, int _npoints, bool fill);
- struct KWQPainterData { // QPainter data.
- QWidget *widget; // Has a reference to a KWQView.
- QFont qfont;
- QBrush qbrush;
- QPen qpen;
- uint isFocusLocked:1;
- void *ps_stack;
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSCompositingOperation compositingOperation;
-#else
- uint compositingOperation;
-#endif
- const QPaintDevice *bufferDevice;
- } *data;
+ QPainterPrivate *data;
+
#endif
}; // end class QPainter
diff --git a/WebCore/kwq/qt/qpen.h b/WebCore/kwq/qt/qpen.h
index 014622b..4942dad 100644
--- a/WebCore/kwq/qt/qpen.h
+++ b/WebCore/kwq/qt/qpen.h
@@ -30,8 +30,10 @@
#include <config.h>
#endif
-#include "qnamespace.h"
-#include "qcolor.h"
+#include <qnamespace.h>
+#include <qcolor.h>
+
+class QPenPrivate;
// class QPen ==================================================================
@@ -46,13 +48,19 @@ public:
// constructors, copy constructors, and destructors ------------------------
QPen();
- QPen(const QColor &color, uint width=0, PenStyle style=SolidLine);
- QPen(const QPen &);
+ QPen(const QColor &c, uint w=0, PenStyle ps=SolidLine);
+ QPen(const QPen &pen);
~QPen();
// member functions --------------------------------------------------------
const QColor &color() const;
+ uint width() const;
+ PenStyle style() const;
+
+ void setColor(const QColor &);
+ void setWidth(uint);
+ void setStyle(PenStyle);
// operators ---------------------------------------------------------------
@@ -63,7 +71,8 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
- QColor qcolor;
+private:
+ QPenPrivate *d;
}; // class QPen ===============================================================
diff --git a/WebCore/kwq/qt/qregion.h b/WebCore/kwq/qt/qregion.h
index b087a40..a12b17a 100644
--- a/WebCore/kwq/qt/qregion.h
+++ b/WebCore/kwq/qt/qregion.h
@@ -67,6 +67,9 @@ public:
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
+
+ static const QRegion null;
+
// static member functions -------------------------------------------------
// constructors, copy constructors, and destructors ------------------------
diff --git a/WebCore/kwq/qt/qstring.h b/WebCore/kwq/qt/qstring.h
index 4c02532..cb2ddfc 100644
--- a/WebCore/kwq/qt/qstring.h
+++ b/WebCore/kwq/qt/qstring.h
@@ -230,10 +230,7 @@ public:
bool isNull() const;
bool isEmpty() const;
- // NOTE: at is useful to keep as implementation of operator[]
-//#ifdef USING_BORROWED_KURL
QChar at(uint) const;
-//#endif
int compare(const QString &) const;
diff --git a/WebCore/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj b/WebCore/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj
index 00756c5..1e521e1 100644
--- a/WebCore/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj
+++ b/WebCore/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj
@@ -240,7 +240,7 @@
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = ../../../../../lib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H -DQT_NO_DATASTREAM -D_KWQ_ -I../../../qt -I../../.. -I../../../../..";
- OTHER_LDFLAGS = "-lwebcore";
+ OTHER_LDFLAGS = "-lwebcore -framework Webkit";
PRODUCT_NAME = drawApp;
SECTORDER_FLAGS = "";
WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
diff --git a/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib b/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib
index ba73594..0c7ae75 100644
--- a/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib
+++ b/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib
@@ -5,7 +5,7 @@
<key>IBFramework Version</key>
<string>219.0</string>
<key>IBMainMenuLocation</key>
- <string>69 252 318 44 0 0 1600 1002 </string>
+ <string>69 298 318 44 0 0 1600 1178 </string>
<key>IBSystem Version</key>
<string>5G64</string>
<key>IBUserGuides</key>
diff --git a/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib b/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib
index 08667d4..4e0c928 100644
Binary files a/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib and b/WebCore/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib differ
diff --git a/WebCore/src/kdelibs/khtml/css/csshelper.cpp b/WebCore/src/kdelibs/khtml/css/csshelper.cpp
index 472a425..515fcfa 100644
--- a/WebCore/src/kdelibs/khtml/css/csshelper.cpp
+++ b/WebCore/src/kdelibs/khtml/css/csshelper.cpp
@@ -54,8 +54,10 @@ float khtml::computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *st
float dpiY = 72.; // fallback
if ( devMetrics )
dpiY = devMetrics->logicalDpiY();
- if ( !khtml::printpainter && dpiY < 96 )
- dpiY = 96.;
+
+ // FIXME: SCREEN_RESOLUTION hack good enough to keep?
+ if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
+ dpiY = SCREEN_RESOLUTION;
float factor = 1.;
switch(type)
diff --git a/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp b/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp
index d711ea9..24b33ca 100644
--- a/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp
+++ b/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp
@@ -73,7 +73,6 @@ static int usedDynamicStates;
static int selectorDynamicState;
static CSSStyleSelector::Encodedurl *encodedurl;
-
CSSStyleSelector::CSSStyleSelector(DocumentImpl * doc)
{
strictParsing = doc->parseMode() == DocumentImpl::Strict;
@@ -1945,8 +1944,9 @@ void khtml::applyRule(khtml::RenderStyle *style, DOM::CSSProperty *prop, DOM::El
float toPix = 1.; // fallback
if ( !khtml::printpainter )
toPix = paintDeviceMetrics->logicalDpiY()/72.;
- if ( !khtml::printpainter && toPix < 96./72. )
- toPix = 96./72.;
+ // FIXME: SCREEN_RESOLUTION hack good enough to keep?
+ if ( !khtml::printpainter && toPix < SCREEN_RESOLUTION/72 )
+ toPix = SCREEN_RESOLUTION/72;
QValueList<int> standardSizes = e->ownerDocument()->view()->part()->fontSizes();
if(e->parentNode()) {
diff --git a/WebCore/src/kdelibs/khtml/khtmlview.cpp b/WebCore/src/kdelibs/khtml/khtmlview.cpp
index 2fca10a..41c20b2 100644
--- a/WebCore/src/kdelibs/khtml/khtmlview.cpp
+++ b/WebCore/src/kdelibs/khtml/khtmlview.cpp
@@ -309,15 +309,21 @@ static void printRenderTree(RenderObject *node, int level)
void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
{
+ // FIXME: make the height work correctly with the scroll view
+ eh = 780;
+
+
if(!m_part->xmlDocImpl()) {
p->fillRect(ex, ey, ew, eh, palette().normal().brush(QColorGroup::Base));
return;
}
- kdDebug( 6000 ) << "drawContents x=" << ex << ",y=" << ey << ",w=" << ew << ",h=" << eh << endl;
+ //kdDebug( 6000 ) << "drawContents x=" << ex << ",y=" << ey << ",w=" << ew << ",h=" << eh << endl;
if ( d->paintBuffer->width() < visibleWidth() )
- d->paintBuffer->resize(visibleWidth(),PAINT_BUFFER_HEIGHT);
+ // FIXME: make the height work correctly with the scroll view
+ //d->paintBuffer->resize(visibleWidth(),PAINT_BUFFER_HEIGHT);
+ d->paintBuffer->resize(visibleWidth(),780);
int py=0;
while (py < eh) {
@@ -334,7 +340,9 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
if (doc){
ro = doc->renderer();
if (ro){
+#ifdef RENDER_TREE_DEBUG
printRenderTree (ro, 0);
+#endif
ro->print(d->tp, ex, ey+py, ew, ph, 0, 0);
}
}
@@ -347,7 +355,9 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
#endif
d->tp->end();
- p->drawPixmap(ex, ey+py, *d->paintBuffer, 0, 0, ew, ph);
+ // FIXME: make the height work correctly with the scroll view
+ //p->drawPixmap(ex, ey+py, *d->paintBuffer, 0, 0, ew, ph);
+ p->drawPixmap(ex, ey+py, *d->paintBuffer, ex, ey+py, ew, ph);
py += PAINT_BUFFER_HEIGHT;
}
diff --git a/WebCore/src/kdelibs/khtml/misc/helper.cpp b/WebCore/src/kdelibs/khtml/misc/helper.cpp
index ea1826e..dca84ae 100644
--- a/WebCore/src/kdelibs/khtml/misc/helper.cpp
+++ b/WebCore/src/kdelibs/khtml/misc/helper.cpp
@@ -153,12 +153,16 @@ using namespace khtml;
static HTMLColors *htmlColors = 0L;
-static KStaticDeleter<HTMLColors> hcsd;
+// FIXME: do we really need static delete support here?
+//static KStaticDeleter<HTMLColors> hcsd;
void khtml::setNamedColor(QColor &color, const QString &_name)
{
- if( !htmlColors )
- htmlColors = hcsd.setObject( new HTMLColors );
+ if( !htmlColors ) {
+ // FIXME: do we really need static delete support here?
+ // htmlColors = hcsd.setObject( new HTMLColors );
+ htmlColors = new HTMLColors();
+ }
int pos;
QString name = _name;
@@ -176,26 +180,16 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
// also recognize "color=ffffff"
if (len == 6)
{
- bool ok;
- int val = name.toInt(&ok, 16);
- if(ok)
- {
- color.setRgb((0xff << 24) | val);
- return;
- }
- // recognize #12345 (duplicate the last character)
+ // recognize #12345 (append a '0')
if(name[0] == '#') {
- bool ok;
- int val = name.right(5).toInt(&ok, 16);
- if(ok) {
- color.setRgb((0xff << 24) | (val * 16 + ( val&0xf )));
- return;
- }
+ name += '0';
}
- if ( !name[0].isLetter() ) {
- color = QColor();
- return;
- }
+ else if ((!name[0].isLetter() && !name[0].isDigit())) {
+ color = QColor();
+ return;
+ }
+
+ color.setNamedColor(name);
}
// #fffffff as found on msdn.microsoft.com
@@ -232,13 +226,14 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
}
else
{
- //QColor tc = htmlColors->map[name];
- QColor tc = QColor (0,0,0);
- if ( !tc.isValid() )
+ QColor tc = htmlColors->map[name];
+
+ if (!tc.isValid()) {
tc = htmlColors->map[name.lower()];
-
- if (tc.isValid())
+ }
+ if (tc.isValid()) {
color = tc;
+ }
else {
color.setNamedColor(name);
if ( !color.isValid() ) color.setNamedColor( name.lower() );
diff --git a/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp b/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp
index b921ada..d30f046 100644
--- a/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp
@@ -78,6 +78,7 @@
using namespace DOM;
using namespace khtml;
+
//template class QStack<DOM::NodeImpl>; // needed ?
@@ -585,8 +586,11 @@ void DocumentImpl::recalcStyle()
float dpiY = 72.; // fallback
if ( !khtml::printpainter )
dpiY = paintDeviceMetrics()->logicalDpiY();
- if ( !khtml::printpainter && dpiY < 96 )
- dpiY = 96.;
+ // FIXME: Is SCREEN_RESOLUTION hack good enough?
+ //if ( !khtml::printpainter && dpiY < 96 )
+ // dpiY = 96.;
+ if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
+ dpiY = SCREEN_RESOLUTION;
float size = fs[3] * dpiY / 72.;
if(size < settings->minFontSize())
size = settings->minFontSize();
diff --git a/WebCore/src/kwq/KWQColor.mm b/WebCore/src/kwq/KWQColor.mm
index 9989981..ca550ef 100644
--- a/WebCore/src/kwq/KWQColor.mm
+++ b/WebCore/src/kwq/KWQColor.mm
@@ -55,6 +55,11 @@ QColor::QColor(int r, int g, int b)
_initialize (r, g, b);
}
+QColor::QColor(const QString &name)
+{
+ color = nil;
+ setNamedColor(name);
+}
QColor::QColor(const char *name)
{
@@ -90,14 +95,14 @@ QColor::QColor(const QColor ©From)
color = nil;
}
-
QString QColor::name() const
{
- NSLog (@"WARNING %s:%s:%d (NOT YET IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
- // FIXME! Must map onto named colors.
- return "white";
-}
+ NSString *name;
+ name = [NSString stringWithFormat:@"#%02x%02x%02x", red(), green(), blue()];
+
+ return NSSTRING_TO_QSTRING(name);
+}
static int hex2int( QChar hexchar )
{
@@ -116,39 +121,46 @@ static int hex2int( QChar hexchar )
void QColor::setNamedColor(const QString&name)
{
+
if ( name.isEmpty() ) {
setRgb( 0 );
- } else if ( name[0] == '#' ) {
- const QChar *p = name.unicode()+1;
- int len = name.length()-1;
- int r, g, b;
- if ( len == 12 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- g = (hex2int(p[4]) << 4) + hex2int(p[5]);
- b = (hex2int(p[8]) << 4) + hex2int(p[9]);
- } else if ( len == 9 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- g = (hex2int(p[3]) << 4) + hex2int(p[4]);
- b = (hex2int(p[6]) << 4) + hex2int(p[7]);
- } else if ( len == 6 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- g = (hex2int(p[2]) << 4) + hex2int(p[3]);
- b = (hex2int(p[4]) << 4) + hex2int(p[5]);
- } else if ( len == 3 ) {
- r = (hex2int(p[0]) << 4) + hex2int(p[0]);
- g = (hex2int(p[1]) << 4) + hex2int(p[1]);
- b = (hex2int(p[2]) << 4) + hex2int(p[2]);
- } else {
- r = g = b = 0;
+ }
+ else if ( name[0] == '#' || name.length() == 6) {
+ int offset = 0;
+ if (name[0] == '#') {
+ offset = 1;
+ }
+ const QChar *p = name.unicode() + offset;
+ int len = name.length();
+ int r, g, b;
+ if ( len == 12 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ g = (hex2int(p[4]) << 4) + hex2int(p[5]);
+ b = (hex2int(p[8]) << 4) + hex2int(p[9]);
+ } else if ( len == 9 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ g = (hex2int(p[3]) << 4) + hex2int(p[4]);
+ b = (hex2int(p[6]) << 4) + hex2int(p[7]);
+ } else if ( len == 6 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ g = (hex2int(p[2]) << 4) + hex2int(p[3]);
+ b = (hex2int(p[4]) << 4) + hex2int(p[5]);
+ } else if ( len == 3 ) {
+ r = (hex2int(p[0]) << 4) + hex2int(p[0]);
+ g = (hex2int(p[1]) << 4) + hex2int(p[1]);
+ b = (hex2int(p[2]) << 4) + hex2int(p[2]);
+ } else {
+ r = g = b = 0;
}
setRgb( r, g, b );
+
} else {
if (color != nil)
[color release];
color = [NSColor colorWithCatalogName: @"Apple" colorName: QSTRING_TO_NSSTRING(name)];
if (color == nil) {
NSLog (@"WARNING %s:%d %s couldn't create color using name %s\n", __FILE__, __LINE__, __FUNCTION__, name.ascii());
- color = [NSColor blackColor];
+ color = [NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:1];
}
}
}
@@ -156,7 +168,15 @@ void QColor::setNamedColor(const QString&name)
bool QColor::isValid() const
{
- return TRUE;
+ bool result;
+
+ result = TRUE;
+
+ if (color == nil) {
+ result = FALSE;
+ }
+
+ return result;
}
diff --git a/WebCore/src/kwq/KWQFont.mm b/WebCore/src/kwq/KWQFont.mm
index a8e150b..4ea26e4 100644
--- a/WebCore/src/kwq/KWQFont.mm
+++ b/WebCore/src/kwq/KWQFont.mm
@@ -61,7 +61,8 @@ void QFont::_initializeWithFont (const QFont *withFont)
QFont::QFont(const QFont ©From)
{
_initializeWithFont(©From);
- _free();
+ // FIXME: why were we freeing here?
+ //_free();
}
diff --git a/WebCore/src/kwq/KWQPaintDeviceMetrics.mm b/WebCore/src/kwq/KWQPaintDeviceMetrics.mm
index 822c4da..6ef92bf 100644
--- a/WebCore/src/kwq/KWQPaintDeviceMetrics.mm
+++ b/WebCore/src/kwq/KWQPaintDeviceMetrics.mm
@@ -34,7 +34,7 @@ QPaintDeviceMetrics::QPaintDeviceMetrics(const QPaintDevice *)
int QPaintDeviceMetrics::logicalDpiY() const
{
- _logPartiallyImplemented();
+ //_logPartiallyImplemented();
return 72;
}
diff --git a/WebCore/src/kwq/KWQPainter.mm b/WebCore/src/kwq/KWQPainter.mm
index 094d1fb..ee78790 100644
--- a/WebCore/src/kwq/KWQPainter.mm
+++ b/WebCore/src/kwq/KWQPainter.mm
@@ -34,6 +34,36 @@
#import <Cocoa/Cocoa.h>
+struct QPainterPrivate {
+friend class QPainter;
+public:
+
+ QPainterPrivate(QWidget *widget) :
+ widget(widget),
+ qfont(),
+ qbrush(),
+ qpen(),
+ isFocusLocked(0),
+ ps_stack(0L),
+ compositingOperation(NSCompositeCopy),
+ bufferDevice(0L)
+ {
+ }
+
+ ~QPainterPrivate() {}
+
+private:
+ QWidget *widget; // Has a reference to a KWQView.
+ QFont qfont;
+ QBrush qbrush;
+ QPen qpen;
+ uint isFocusLocked:1;
+ void *ps_stack;
+ NSCompositingOperation compositingOperation;
+ const QPaintDevice *bufferDevice;
+};
+
+
struct QPState { // painter state
QFont font;
QPen pen;
@@ -64,20 +94,14 @@ QPainter::QPainter(QWidget *widget)
void QPainter::_initialize(QWidget *widget)
{
- data = (struct KWQPainterData *)calloc (1, sizeof (struct KWQPainterData));
- data->widget = widget;
- data->qpen = QPen (Qt::black);
- data->isFocusLocked = 0;
- data->compositingOperation = NSCompositeCopy;
- data->bufferDevice = 0L;
+ data = new QPainterPrivate(widget);
}
QPainter::~QPainter()
{
- free (data);
+ delete data;
}
-
const QFont &QPainter::font() const
{
@@ -108,9 +132,11 @@ void QPainter::setPen(const QPen &pen)
}
-void QPainter::setPen(PenStyle)
+void QPainter::setPen(PenStyle ps)
{
- _logNotYetImplemented();
+ data->qpen.setStyle(ps);
+ data->qpen.setColor(Qt::black);
+ data->qpen.setWidth(0);
}
@@ -175,7 +201,6 @@ void QPainter::restore()
// Draws a filled rectangle with a stroked border.
void QPainter::drawRect(int x, int y, int w, int h)
{
- /*
_lockFocus();
if (data->qbrush.qbrushstyle == SolidPattern){
//_setColorFromBrush();
@@ -184,7 +209,6 @@ void QPainter::drawRect(int x, int y, int w, int h)
_setColorFromPen();
[NSBezierPath strokeRect:NSMakeRect(x, y, w, h)];
_unlockFocus();
- */
}
@@ -196,7 +220,7 @@ void QPainter::_setColorFromBrush()
void QPainter::_setColorFromPen()
{
- [data->qpen.qcolor.color set];
+ [data->qpen.color().color set];
}
@@ -406,7 +430,7 @@ void QPainter::drawText(int x, int y, const QString &qstring, int len)
//font = data->qfont.data->font;
font = data->qfont.font;
-
+
if (len == -1)
string = QSTRING_TO_NSSTRING(qstring);
else
@@ -415,7 +439,8 @@ void QPainter::drawText(int x, int y, const QString &qstring, int len)
// This will draw the text from the top of the bounding box down.
// Qt expects to draw from the baseline.
y = y - (int)([font defaultLineHeightForFont] + [font descender]);
- [string drawAtPoint:NSMakePoint(x, y) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.qcolor.color, NSForegroundColorAttributeName, nil]];
+
+ [string drawAtPoint:NSMakePoint(x, y) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.color().color, NSForegroundColorAttributeName, nil]];
_unlockFocus();
}
@@ -433,7 +458,7 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString&qst
//font = data->qfont.data->font;
font = data->qfont.font;
-
+
if (len == -1)
string = QSTRING_TO_NSSTRING(qstring);
else
@@ -454,7 +479,7 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString&qst
[style setAlignment: NSLeftTextAlignment];
}
- [string drawInRect:NSMakeRect(x, y, w, h) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.qcolor.color, NSForegroundColorAttributeName, style, NSParagraphStyleAttributeName, nil]];
+ [string drawInRect:NSMakeRect(x, y, w, h) withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, data->qpen.color().color, NSForegroundColorAttributeName, style, NSParagraphStyleAttributeName, nil]];
_unlockFocus();
}
@@ -463,14 +488,12 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString&qst
void QPainter::fillRect(int x, int y, int w, int h, const QBrush &brush)
{
- /*
_lockFocus();
if (brush.qbrushstyle == SolidPattern){
- //[brush.qcolor.color set];
- //[NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
+ [brush.qcolor.color set];
+ [NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
}
_unlockFocus();
- */
}
@@ -488,8 +511,8 @@ void QPainter::setClipRegion(const QRegion &)
const QRegion &QPainter::clipRegion() const
{
- _logNotYetImplemented();
- return QRegion();
+ _logPartiallyImplemented();
+ return QRegion::null;
}
diff --git a/WebCore/src/kwq/KWQPen.mm b/WebCore/src/kwq/KWQPen.mm
index 50735fe..fc3d666 100644
--- a/WebCore/src/kwq/KWQPen.mm
+++ b/WebCore/src/kwq/KWQPen.mm
@@ -25,44 +25,92 @@
#include <qpen.h>
+class QPenPrivate
+{
+friend class QPen;
+public:
+
+ QPenPrivate(const QColor &c, uint w, QPen::PenStyle ps) :
+ qcolor(c), width(w), penStyle(ps)
+ {
+ }
+
+ ~QPenPrivate() {}
+
+private:
+ QColor qcolor;
+ uint width;
+ QPen::PenStyle penStyle;
+};
+
+
QPen::QPen()
{
- qcolor = Qt::black;
+ d = new QPenPrivate(Qt::black, 3, SolidLine);
}
-QPen::QPen(const QColor &color, uint width, PenStyle style)
+QPen::QPen(const QColor &c, uint w, PenStyle ps)
{
- qcolor = color;
+ d = new QPenPrivate(c, w, ps);
}
QPen::QPen(const QPen ©From)
{
- qcolor = copyFrom.qcolor;
+ d->qcolor = copyFrom.d->qcolor;
}
QPen::~QPen()
{
+ delete d;
}
const QColor &QPen::color() const
{
- return qcolor;
+ return d->qcolor;
+}
+
+uint QPen::width() const
+{
+ return d->width;
+}
+
+QPen::PenStyle QPen::style() const
+{
+ return d->penStyle;
+}
+
+void QPen::setColor(const QColor &c)
+{
+ d->qcolor = c;
}
+void QPen::setWidth(uint w)
+{
+ d->width = w;
+}
+
+void QPen::setStyle(PenStyle ps)
+{
+ d->penStyle = ps;
+}
QPen &QPen::operator=(const QPen &assignFrom)
{
- qcolor = assignFrom.qcolor;
+ d->qcolor = assignFrom.d->qcolor;
+ d->width = assignFrom.d->width;
+ d->penStyle = assignFrom.d->penStyle;
return *this;
}
bool QPen::operator==(const QPen &compareTo) const
{
- return qcolor == compareTo.qcolor;
+ return (d->width == compareTo.d->width) &&
+ (d->penStyle == compareTo.d->penStyle) &&
+ (d->qcolor == compareTo.d->qcolor);
}
diff --git a/WebCore/src/kwq/KWQRegion.mm b/WebCore/src/kwq/KWQRegion.mm
index 8c9c3eb..8fa00ff 100644
--- a/WebCore/src/kwq/KWQRegion.mm
+++ b/WebCore/src/kwq/KWQRegion.mm
@@ -27,6 +27,8 @@
#include <kwqdebug.h>
+const QRegion QRegion::null;
+
void QRegion::_initialize() {
data = calloc(1, sizeof(struct KWQRegionData));
data->type = Rectangle;
diff --git a/WebCore/src/kwq/KWQString.mm b/WebCore/src/kwq/KWQString.mm
index bef09ac..422d449 100644
--- a/WebCore/src/kwq/KWQString.mm
+++ b/WebCore/src/kwq/KWQString.mm
@@ -637,10 +637,14 @@ double QString::toDouble(bool *ok) const
if (ok) {
// NOTE: since CFStringGetDoubleValue returns 0.0 on error there is no
// way to know if "n" is valid in that case
- if (n == 0.0) {
+ //
+ // EXTRA NOTE: We can't assume 0.0 is bad, since it totally breaks
+ // html like border="0". So, only trigger breakage if the char
+ // at index 0 is neither a '0' nor a '.' nor a '-'.
+ UniChar uc = CFStringGetCharacterAtIndex(s,0);
+ *ok = TRUE;
+ if (n == 0.0 && uc != '0' && uc != '.' && uc != '-') {
*ok = FALSE;
- } else {
- *ok = TRUE;
}
}
return n;
@@ -1261,24 +1265,24 @@ ulong QString::convertToNumber(bool *ok, int base, bool *neg) const
uc = CFStringGetCharacterFromInlineBuffer(&buf, i);
// NOTE: ignore anything other than base 10 and base 16
if ((uc >= '0') && (uc <= '9')) {
- if (n > (max / 10)) {
+ if (n > (max / base)) {
valid = FALSE;
break;
}
- n = (n * 10) + (uc - '0');
+ n = (n * base) + (uc - '0');
} else if (base == 16) {
if ((uc >= 'A') && (uc <= 'F')) {
- if (n > (max / 16)) {
+ if (n > (max / base)) {
valid = FALSE;
break;
}
- n = (n * 16) + (10 + (uc - 'A'));
+ n = (n * base) + (10 + (uc - 'A'));
} else if ((uc >= 'a') && (uc <= 'f')) {
- if (n > (max / 16)) {
+ if (n > (max / base)) {
valid = FALSE;
break;
}
- n = (n * 16) + (10 + (uc - 'a'));
+ n = (n * base) + (10 + (uc - 'a'));
} else {
break;
}
diff --git a/WebCore/src/kwq/KWQVariant.mm b/WebCore/src/kwq/KWQVariant.mm
index 0779ef7..6e81d8b 100644
--- a/WebCore/src/kwq/KWQVariant.mm
+++ b/WebCore/src/kwq/KWQVariant.mm
@@ -25,53 +25,68 @@
#include <qvariant.h>
+#include <kwqdebug.h>
QVariant::QVariant()
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(bool, int)
+QVariant::QVariant(bool b, int i)
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(double)
+QVariant::QVariant(double d)
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(const QString &)
+QVariant::QVariant(const QString &s)
{
+ _logNotYetImplemented();
}
-QVariant::QVariant(const QVariant &)
+QVariant::QVariant(const QVariant &other)
{
+ _logNotYetImplemented();
}
QVariant::~QVariant()
{
+ _logNotYetImplemented();
}
QVariant::Type QVariant::type() const
{
+ _logNotYetImplemented();
+ return UInt;
}
bool QVariant::toBool() const
{
+ _logNotYetImplemented();
+ return 0;
}
uint QVariant::toUInt() const
{
+ _logNotYetImplemented();
+ return 0;
}
-QVariant &QVariant::operator=(const QVariant &)
+QVariant &QVariant::operator=(const QVariant &other)
{
+ _logNotYetImplemented();
+ return *this;
}
diff --git a/WebCore/src/kwq/khtml/khtml_settings.h b/WebCore/src/kwq/khtml/khtml_settings.h
index 977b7de..fc6a9a0 100644
--- a/WebCore/src/kwq/khtml/khtml_settings.h
+++ b/WebCore/src/kwq/khtml/khtml_settings.h
@@ -35,6 +35,9 @@
#include <qfont.h>
#include <qmap.h>
+// FIXME: I am resetting the default screen resolution to 72
+#define SCREEN_RESOLUTION 72.0f
+
class KHTMLSettings
{
public:
diff --git a/WebCore/src/kwq/qt/qcolor.h b/WebCore/src/kwq/qt/qcolor.h
index 830391a..4f1882f 100644
--- a/WebCore/src/kwq/qt/qcolor.h
+++ b/WebCore/src/kwq/qt/qcolor.h
@@ -63,6 +63,7 @@ public:
QColor();
QColor(int,int,int);
+ QColor(const QString &);
QColor(const char *);
QColor(const QColor &);
diff --git a/WebCore/src/kwq/qt/qpainter.h b/WebCore/src/kwq/qt/qpainter.h
index 543ec4a..6c308aa 100644
--- a/WebCore/src/kwq/qt/qpainter.h
+++ b/WebCore/src/kwq/qt/qpainter.h
@@ -44,6 +44,7 @@
class QFont;
class QPixmap;
class QWidget;
+class QPainterPrivate;
// class QWMatrix ==============================================================
@@ -186,20 +187,8 @@ private:
void _initialize(QWidget *widget);
void _drawPoints (const QPointArray &_points, bool winding, int index, int _npoints, bool fill);
- struct KWQPainterData { // QPainter data.
- QWidget *widget; // Has a reference to a KWQView.
- QFont qfont;
- QBrush qbrush;
- QPen qpen;
- uint isFocusLocked:1;
- void *ps_stack;
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSCompositingOperation compositingOperation;
-#else
- uint compositingOperation;
-#endif
- const QPaintDevice *bufferDevice;
- } *data;
+ QPainterPrivate *data;
+
#endif
}; // end class QPainter
diff --git a/WebCore/src/kwq/qt/qpen.h b/WebCore/src/kwq/qt/qpen.h
index 014622b..4942dad 100644
--- a/WebCore/src/kwq/qt/qpen.h
+++ b/WebCore/src/kwq/qt/qpen.h
@@ -30,8 +30,10 @@
#include <config.h>
#endif
-#include "qnamespace.h"
-#include "qcolor.h"
+#include <qnamespace.h>
+#include <qcolor.h>
+
+class QPenPrivate;
// class QPen ==================================================================
@@ -46,13 +48,19 @@ public:
// constructors, copy constructors, and destructors ------------------------
QPen();
- QPen(const QColor &color, uint width=0, PenStyle style=SolidLine);
- QPen(const QPen &);
+ QPen(const QColor &c, uint w=0, PenStyle ps=SolidLine);
+ QPen(const QPen &pen);
~QPen();
// member functions --------------------------------------------------------
const QColor &color() const;
+ uint width() const;
+ PenStyle style() const;
+
+ void setColor(const QColor &);
+ void setWidth(uint);
+ void setStyle(PenStyle);
// operators ---------------------------------------------------------------
@@ -63,7 +71,8 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
- QColor qcolor;
+private:
+ QPenPrivate *d;
}; // class QPen ===============================================================
diff --git a/WebCore/src/kwq/qt/qregion.h b/WebCore/src/kwq/qt/qregion.h
index b087a40..a12b17a 100644
--- a/WebCore/src/kwq/qt/qregion.h
+++ b/WebCore/src/kwq/qt/qregion.h
@@ -67,6 +67,9 @@ public:
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
+
+ static const QRegion null;
+
// static member functions -------------------------------------------------
// constructors, copy constructors, and destructors ------------------------
diff --git a/WebCore/src/kwq/qt/qstring.h b/WebCore/src/kwq/qt/qstring.h
index 4c02532..cb2ddfc 100644
--- a/WebCore/src/kwq/qt/qstring.h
+++ b/WebCore/src/kwq/qt/qstring.h
@@ -230,10 +230,7 @@ public:
bool isNull() const;
bool isEmpty() const;
- // NOTE: at is useful to keep as implementation of operator[]
-//#ifdef USING_BORROWED_KURL
QChar at(uint) const;
-//#endif
int compare(const QString &) const;
diff --git a/WebCore/src/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj b/WebCore/src/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj
index 00756c5..1e521e1 100644
--- a/WebCore/src/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj
+++ b/WebCore/src/kwq/tests/draw/drawApp/drawApp.pbproj/project.pbxproj
@@ -240,7 +240,7 @@
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = ../../../../../lib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H -DQT_NO_DATASTREAM -D_KWQ_ -I../../../qt -I../../.. -I../../../../..";
- OTHER_LDFLAGS = "-lwebcore";
+ OTHER_LDFLAGS = "-lwebcore -framework Webkit";
PRODUCT_NAME = drawApp;
SECTORDER_FLAGS = "";
WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
diff --git a/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib b/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib
index ba73594..0c7ae75 100644
--- a/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib
+++ b/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/info.nib
@@ -5,7 +5,7 @@
<key>IBFramework Version</key>
<string>219.0</string>
<key>IBMainMenuLocation</key>
- <string>69 252 318 44 0 0 1600 1002 </string>
+ <string>69 298 318 44 0 0 1600 1178 </string>
<key>IBSystem Version</key>
<string>5G64</string>
<key>IBUserGuides</key>
diff --git a/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib b/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib
index 08667d4..4e0c928 100644
Binary files a/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib and b/WebCore/src/kwq/tests/khtmlview/WebViewTest/English.lproj/MainMenu.nib/objects.nib differ
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list