[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:17:52 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit f028f81b86159057e99cfff4070ac6e240f77e23
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jun 10 20:08:04 2002 +0000
JavaScriptCore:
Merged in changes from KDE 3.0.1.
* kjs/collector.cpp:
* kjs/date_object.cpp:
* kjs/function.cpp:
* kjs/internal.cpp:
* kjs/lookup.h:
* kjs/object.cpp:
* kjs/operations.cpp:
* kjs/regexp.cpp:
* kjs/regexp_object.cpp:
* kjs/regexp_object.h:
* kjs/string_object.cpp:
* kjs/testkjs.cpp:
* kjs/ustring.cpp:
* kjs/value.cpp:
* kjs/value.h:
Do the merge, and add APPLE_CHANGES as needed to make things compile.
* kjs/date_object.lut.h: Re-generated.
WebCore:
Merged in changes from KDE 3.0.1.
* kwq/kdecore/kurl.h:
* kwq/KWQKURL.mm: (operator==): New, needed by some 3.0.1 code.
* kwq/qt/qpalette.h: Add QPalette::NColorGroups and QColorGroup::NColorRoles.
* kwq/KWQPalette.mm: Simplify by getting rid of "private" indirection.
(QPalette::color): New, needed by some 3.0.1 code.
* kwq/KWQColorGroup.mm: Simplify by getting rid of "private" indirection.
* kwq/qt/qstring.h:
* kwq/KWQString.mm: (QConstString::QConstString): Change parameter to const QChar *
to match Qt so we compile.
* kwq/qt/qtextedit.h:
* kwq/KWQTextEdit.mm: (QTextEdit::setTabStopWidth): Add unimplemented placeholder,
needed by some 3.0.1 code.
* kwq/qt/qvaluelist.h:
* kwq/KWQValueListImpl.h:
* kwq/KWQValueListImpl.mm: Simplify implementation.
* WebCore-tests.exp: Update for changes in QValueList implementation.
* kwq/kdecore/klibloader.h: Add include of <kio/global.h> to make something compile.
* kwq/khtml/java/kjavaappletcontext.h: Add JType and constructor that takes DCOPObject*.
* kwq/kio/global.h: Add KIO::CacheControl.
* khtml/css/css_ruleimpl.cpp:
* khtml/css/css_ruleimpl.h:
* khtml/css/css_stylesheetimpl.cpp:
* khtml/css/css_stylesheetimpl.h:
* khtml/css/css_valueimpl.cpp:
* khtml/css/css_valueimpl.h:
* khtml/css/cssparser.cpp:
* khtml/css/cssparser.h:
* khtml/css/cssstyleselector.cpp:
* khtml/css/cssstyleselector.h:
* khtml/css/html4.css:
* khtml/dom/css_rule.cpp:
* khtml/dom/css_rule.h:
* khtml/dom/css_stylesheet.cpp:
* khtml/dom/css_stylesheet.h:
* khtml/dom/css_value.cpp:
* khtml/dom/dom2_events.cpp:
* khtml/dom/dom2_range.cpp:
* khtml/dom/dom2_range.h:
* khtml/dom/dom2_views.cpp:
* khtml/dom/dom_doc.cpp:
* khtml/dom/dom_element.cpp:
* khtml/dom/dom_exception.h:
* khtml/dom/dom_node.cpp:
* khtml/dom/dom_string.cpp:
* khtml/dom/dom_text.cpp:
* khtml/dom/dom_xml.cpp:
* khtml/dom/html_base.cpp:
* khtml/dom/html_block.cpp:
* khtml/dom/html_document.cpp:
* khtml/dom/html_element.cpp:
* khtml/dom/html_element.h:
* khtml/dom/html_form.cpp:
* khtml/dom/html_head.cpp:
* khtml/dom/html_image.cpp:
* khtml/dom/html_inline.cpp:
* khtml/dom/html_list.cpp:
* khtml/dom/html_misc.cpp:
* khtml/dom/html_object.cpp:
* khtml/dom/html_table.cpp:
* khtml/ecma/kjs_html.cpp:
* khtml/ecma/kjs_proxy.cpp:
* khtml/ecma/kjs_traversal.cpp:
* khtml/ecma/kjs_window.cpp:
* khtml/html/html_baseimpl.cpp:
* khtml/html/html_formimpl.cpp:
* khtml/html/html_miscimpl.h:
* khtml/html/html_objectimpl.cpp:
* khtml/html/html_objectimpl.h:
* khtml/html/htmlparser.cpp:
* khtml/html/htmlparser.h:
* khtml/html/htmltokenizer.cpp:
* khtml/html/htmltokenizer.h:
* khtml/khtml_part.cpp:
* khtml/khtmlpart_p.h:
* khtml/khtmlview.cpp:
* khtml/misc/helper.cpp:
* khtml/misc/khtmllayout.h:
* khtml/misc/loader.cpp:
* khtml/misc/loader.h:
* khtml/misc/loader_client.h:
* khtml/misc/shared.h: Added.
* khtml/rendering/bidi.cpp:
* khtml/rendering/break_lines.cpp:
* khtml/rendering/font.cpp:
* khtml/rendering/render_applet.cpp:
* khtml/rendering/render_applet.h:
* khtml/rendering/render_container.cpp:
* khtml/rendering/render_form.cpp:
* khtml/rendering/render_form.h:
* khtml/rendering/render_frames.cpp:
* khtml/rendering/render_image.cpp:
* khtml/rendering/render_object.cpp:
* khtml/rendering/render_object.h:
* khtml/rendering/render_replaced.cpp:
* khtml/rendering/render_replaced.h:
* khtml/rendering/render_root.cpp:
* khtml/rendering/render_style.cpp:
* khtml/rendering/render_style.h:
* khtml/rendering/render_table.cpp:
* khtml/rendering/render_table.h:
* khtml/rendering/render_text.cpp:
* khtml/rendering/render_text.h:
* khtml/xml/dom2_eventsimpl.h:
* khtml/xml/dom2_rangeimpl.h:
* khtml/xml/dom2_traversalimpl.cpp:
* khtml/xml/dom2_traversalimpl.h:
* khtml/xml/dom2_viewsimpl.h:
* khtml/xml/dom_docimpl.cpp:
* khtml/xml/dom_docimpl.h:
* khtml/xml/dom_elementimpl.h:
* khtml/xml/dom_nodeimpl.cpp:
* khtml/xml/dom_nodeimpl.h:
* khtml/xml/dom_stringimpl.cpp:
* khtml/xml/dom_stringimpl.h:
* khtml/xml/xml_tokenizer.h:
Merge in 3.0.1 changes and add APPLE_CHANGES as necessary to get it to compile.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index c4a84d9..ae2fc65 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,26 @@
+2002-06-10 Darin Adler <darin at apple.com>
+
+ Merged in changes from KDE 3.0.1.
+
+ * kjs/collector.cpp:
+ * kjs/date_object.cpp:
+ * kjs/function.cpp:
+ * kjs/internal.cpp:
+ * kjs/lookup.h:
+ * kjs/object.cpp:
+ * kjs/operations.cpp:
+ * kjs/regexp.cpp:
+ * kjs/regexp_object.cpp:
+ * kjs/regexp_object.h:
+ * kjs/string_object.cpp:
+ * kjs/testkjs.cpp:
+ * kjs/ustring.cpp:
+ * kjs/value.cpp:
+ * kjs/value.h:
+ Do the merge, and add APPLE_CHANGES as needed to make things compile.
+
+ * kjs/date_object.lut.h: Re-generated.
+
2002-06-07 Darin Adler <darin at apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index c4a84d9..ae2fc65 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,3 +1,26 @@
+2002-06-10 Darin Adler <darin at apple.com>
+
+ Merged in changes from KDE 3.0.1.
+
+ * kjs/collector.cpp:
+ * kjs/date_object.cpp:
+ * kjs/function.cpp:
+ * kjs/internal.cpp:
+ * kjs/lookup.h:
+ * kjs/object.cpp:
+ * kjs/operations.cpp:
+ * kjs/regexp.cpp:
+ * kjs/regexp_object.cpp:
+ * kjs/regexp_object.h:
+ * kjs/string_object.cpp:
+ * kjs/testkjs.cpp:
+ * kjs/ustring.cpp:
+ * kjs/value.cpp:
+ * kjs/value.h:
+ Do the merge, and add APPLE_CHANGES as needed to make things compile.
+
+ * kjs/date_object.lut.h: Re-generated.
+
2002-06-07 Darin Adler <darin at apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index c4a84d9..ae2fc65 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,26 @@
+2002-06-10 Darin Adler <darin at apple.com>
+
+ Merged in changes from KDE 3.0.1.
+
+ * kjs/collector.cpp:
+ * kjs/date_object.cpp:
+ * kjs/function.cpp:
+ * kjs/internal.cpp:
+ * kjs/lookup.h:
+ * kjs/object.cpp:
+ * kjs/operations.cpp:
+ * kjs/regexp.cpp:
+ * kjs/regexp_object.cpp:
+ * kjs/regexp_object.h:
+ * kjs/string_object.cpp:
+ * kjs/testkjs.cpp:
+ * kjs/ustring.cpp:
+ * kjs/value.cpp:
+ * kjs/value.h:
+ Do the merge, and add APPLE_CHANGES as needed to make things compile.
+
+ * kjs/date_object.lut.h: Re-generated.
+
2002-06-07 Darin Adler <darin at apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index e561fd6..59becdc 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -225,10 +225,10 @@ bool Collector::collect()
}
// SWEEP: delete everything with a zero refcount (garbage)
+ // 1st step: destruct all objects
block = root;
while (block) {
ValueImp **r = (ValueImp**)block->mem;
- int del = 0;
for (int i = 0; i < block->size; i++, r++) {
ValueImp *imp = (*r);
// Can delete if refcount==0, created==true, gcAllowed==true, and marked==false
@@ -238,7 +238,20 @@ bool Collector::collect()
// emulate destructing part of 'operator delete()'
//fprintf( stderr, "Collector::deleting ValueImp %p (%s)\n", (void*)imp, typeid(*imp).name());
imp->~ValueImp();
- free(imp);
+ }
+ }
+ block = block->next;
+ }
+
+ // 2nd step: free memory
+ block = root;
+ while (block) {
+ ValueImp **r = (ValueImp**)block->mem;
+ int del = 0;
+ for (int i = 0; i < block->size; i++, r++) {
+ ValueImp *imp = (*r);
+ if (imp && (imp->_flags & ValueImp::VI_DESTRUCTED) != 0) {
+ free(imp);
*r = 0L;
del++;
}
diff --git a/JavaScriptCore/kjs/date_object.cpp b/JavaScriptCore/kjs/date_object.cpp
index 3715736..427eccb 100644
--- a/JavaScriptCore/kjs/date_object.cpp
+++ b/JavaScriptCore/kjs/date_object.cpp
@@ -76,7 +76,7 @@ const ClassInfo DatePrototypeImp::info = {"Date", 0, &dateTable, 0};
We use a negative ID to denote the "UTC" variant.
@begin dateTable 61
toString DateProtoFuncImp::ToString DontEnum|Function 0
- toUTCString -DateProtoFuncImp::ToString DontEnum|Function 0
+ toUTCString DateProtoFuncImp::ToUTCString DontEnum|Function 0
toDateString DateProtoFuncImp::ToDateString DontEnum|Function 0
toTimeString DateProtoFuncImp::ToTimeString DontEnum|Function 0
toLocaleString DateProtoFuncImp::ToLocaleString DontEnum|Function 0
@@ -195,14 +195,15 @@ Value DateProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
case ToDateString:
case ToTimeString:
case ToGMTString:
+ case ToUTCString:
setlocale(LC_TIME,"C");
if (id == DateProtoFuncImp::ToDateString) {
strftime(timebuffer, bufsize, "%x",t);
} else if (id == DateProtoFuncImp::ToTimeString) {
strftime(timebuffer, bufsize, "%X",t);
- } else {
+ } else { // toGMTString & toUTCString
t = gmtime(&tv);
- strftime(timebuffer, bufsize, "%a, %d-%b-%y %H:%M:%S %Z", t);
+ strftime(timebuffer, bufsize, "%a, %d %b %Y %H:%M:%S %Z", t);
}
setlocale(LC_TIME,oldlocale.c_str());
result = String(timebuffer);
diff --git a/JavaScriptCore/kjs/date_object.lut.h b/JavaScriptCore/kjs/date_object.lut.h
index c76862e..9f14cdc 100644
--- a/JavaScriptCore/kjs/date_object.lut.h
+++ b/JavaScriptCore/kjs/date_object.lut.h
@@ -62,7 +62,7 @@ const struct HashEntry dateTableEntries[] = {
{ 0, 0, 0, 0, 0 },
{ "getUTCSeconds", -DateProtoFuncImp::GetSeconds, DontEnum|Function, 0, 0 },
{ "getHours", DateProtoFuncImp::GetHours, DontEnum|Function, 0, 0 },
- { "toUTCString", -DateProtoFuncImp::ToString, DontEnum|Function, 0, &dateTableEntries[62] },
+ { "toUTCString", DateProtoFuncImp::ToUTCString, DontEnum|Function, 0, &dateTableEntries[62] },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ "setTime", DateProtoFuncImp::SetTime, DontEnum|Function, 1, &dateTableEntries[67] },
diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp
index d918d7a..c99d580 100644
--- a/JavaScriptCore/kjs/function.cpp
+++ b/JavaScriptCore/kjs/function.cpp
@@ -369,7 +369,8 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
"abcdefghijklmnopqrstuvwxyz"
"0123456789@*_+-./";
- if (id == Eval) { // eval()
+ switch (id) {
+ case Eval: { // eval()
Value x = args[0];
if (x.type() != StringType)
return x;
@@ -422,10 +423,13 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
return c.value();
else
return Undefined();
- } else
+ } else {
return c;
+ }
}
- } else if (id == ParseInt) {
+ break;
+ }
+ case ParseInt: {
String str = args[0].toString(exec);
int radix = args[1].toInt32(exec);
if (radix == 0)
@@ -441,15 +445,22 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
res = Number(NaN);
else
res = Number(static_cast<long>(value)); // remove floating-point part
- } else if (id == ParseFloat) {
+ break;
+ }
+ case ParseFloat: {
String str = args[0].toString(exec);
res = Number(str.value().toDouble( true /*tolerant*/ ));
- } else if (id == IsNaN) {
+ break;
+ }
+ case IsNaN:
res = Boolean(isNaN(args[0].toNumber(exec)));
- } else if (id == IsFinite) {
+ break;
+ case IsFinite: {
Number n = args[0].toNumber(exec);
res = Boolean(!n.isNaN() && !n.isInf());
- } else if (id == Escape) {
+ break;
+ }
+ case Escape: {
UString r = "", s, str = args[0].toString(exec);
const UChar *c = str.data();
for (int k = 0; k < str.size(); k++, c++) {
@@ -468,7 +479,9 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
r += s;
}
res = String(r);
- } else if (id == UnEscape) {
+ break;
+ }
+ case UnEscape: {
UString s, str = args[0].toString(exec);
int k = 0, len = str.size();
while (k < len) {
@@ -488,6 +501,8 @@ Value GlobalFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args
s += UString(c, 1);
}
res = String(s);
+ break;
+ }
}
return res;
diff --git a/JavaScriptCore/kjs/internal.cpp b/JavaScriptCore/kjs/internal.cpp
index 9ee98b7..4258f07 100644
--- a/JavaScriptCore/kjs/internal.cpp
+++ b/JavaScriptCore/kjs/internal.cpp
@@ -917,9 +917,9 @@ void InterpreterImp::initGlobalObject()
b_uriErrorPrototype.put(globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly);
// built-in values
- global.put(globExec,"NaN", Number(NaN), DontEnum);
- global.put(globExec,"Infinity", Number(Inf), DontEnum);
- global.put(globExec,"undefined", Undefined(), DontEnum);
+ global.put(globExec, "NaN", Number(NaN), DontEnum|DontDelete);
+ global.put(globExec, "Infinity", Number(Inf), DontEnum|DontDelete);
+ global.put(globExec, "undefined", Undefined(), DontEnum|DontDelete);
// built-in functions
global.put(globExec,"eval", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::Eval, 1)), DontEnum);
diff --git a/JavaScriptCore/kjs/lookup.h b/JavaScriptCore/kjs/lookup.h
index f8ce100..88819a2 100644
--- a/JavaScriptCore/kjs/lookup.h
+++ b/JavaScriptCore/kjs/lookup.h
@@ -194,7 +194,7 @@ namespace KJS {
fprintf(stderr, "Function bit not set! Shouldn't happen in lookupGetFunction!\n" );
return Undefined();
- };
+ }
/**
* Simplified version of lookupGet in case there are no functions, only "values".
diff --git a/JavaScriptCore/kjs/object.cpp b/JavaScriptCore/kjs/object.cpp
index 3b24acb..a43755a 100644
--- a/JavaScriptCore/kjs/object.cpp
+++ b/JavaScriptCore/kjs/object.cpp
@@ -200,15 +200,12 @@ ObjectImp::ObjectImp()
ObjectImp::~ObjectImp()
{
//fprintf(stderr,"ObjectImp::~ObjectImp %p\n",(void*)this);
-#if 0 // Those could be already deleted. The collector ensures no order
- // ### Check if this leads to memory leaks....
if (_proto)
_proto->setGcAllowed();
if (_internalValue)
_internalValue->setGcAllowed();
if (_scope)
_scope->setGcAllowed();
-#endif
delete _prop;
}
diff --git a/JavaScriptCore/kjs/operations.cpp b/JavaScriptCore/kjs/operations.cpp
index f47e2b9..670f721 100644
--- a/JavaScriptCore/kjs/operations.cpp
+++ b/JavaScriptCore/kjs/operations.cpp
@@ -220,8 +220,10 @@ int KJS::minInt(int d1, int d2)
// ECMA 11.6
Value KJS::add(ExecState *exec, const Value &v1, const Value &v2, char oper)
{
- Value p1 = v1.toPrimitive(exec);
- Value p2 = v2.toPrimitive(exec);
+ // exception for the Date exception in defaultValue()
+ Type preferred = oper == '+' ? UnspecifiedType : NumberType;
+ Value p1 = v1.toPrimitive(exec, preferred);
+ Value p2 = v2.toPrimitive(exec, preferred);
if ((p1.type() == StringType || p2.type() == StringType) && oper == '+') {
UString s1 = p1.toString(exec);
diff --git a/JavaScriptCore/kjs/regexp.cpp b/JavaScriptCore/kjs/regexp.cpp
index 88b8233..496b05d 100644
--- a/JavaScriptCore/kjs/regexp.cpp
+++ b/JavaScriptCore/kjs/regexp.cpp
@@ -19,18 +19,17 @@
*
*/
+#include "regexp.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "regexp.h"
-
using namespace KJS;
RegExp::RegExp(const UString &p, int f)
: pattern(p), flags(f)
{
-
#ifdef HAVE_PCREPOSIX
int pcreflags = 0;
const char *perrormsg;
@@ -44,6 +43,10 @@ RegExp::RegExp(const UString &p, int f)
pcregex = pcre_compile(p.ascii(), pcreflags,
&perrormsg, &errorOffset, NULL);
+#ifndef NDEBUG
+ if (!pcregex)
+ fprintf(stderr, "KJS: pcre_compile() failed with '%s'\n", perrormsg);
+#endif
#ifdef PCRE_INFO_CAPTURECOUNT
// Get number of subpatterns that will be returned
@@ -54,7 +57,7 @@ RegExp::RegExp(const UString &p, int f)
#else /* HAVE_PCREPOSIX */
- nrSubPatterns = 0; // not implemented with POSIX regex.
+ nrSubPatterns = 0; // determined in match() with POSIX regex.
int regflags = 0;
#ifdef REG_EXTENDED
regflags |= REG_EXTENDED;
@@ -78,8 +81,8 @@ RegExp::RegExp(const UString &p, int f)
RegExp::~RegExp()
{
#ifdef HAVE_PCREPOSIX
- pcre_free(pcregex);
-
+ if (pcregex)
+ pcre_free(pcregex);
#else
/* TODO: is this really okay after an error ? */
regfree(&preg);
@@ -88,50 +91,76 @@ RegExp::~RegExp()
UString RegExp::match(const UString &s, int i, int *pos, int **ovector)
{
+ if (i < 0)
+ i = 0;
+ if (ovector)
+ *ovector = 0L;
+ int dummyPos;
+ if (!pos)
+ pos = &dummyPos;
+ *pos = -1;
+ if (i > s.size() || s.isNull())
+ return UString::null;
#ifdef HAVE_PCREPOSIX
CString buffer(s.cstring());
int ovecsize = (nrSubPatterns+1)*3; // see pcre docu
if (ovector) *ovector = new int[ovecsize];
- if (i < 0)
- i = 0;
-
- if (i > s.size() || s.isNull() ||
- pcre_exec(pcregex, NULL, buffer.c_str(), buffer.size(), i,
- 0, ovector ? *ovector : 0L, ovecsize) == PCRE_ERROR_NOMATCH) {
-
- if (pos)
- *pos = -1;
+ if (!pcregex || pcre_exec(pcregex, NULL, buffer.c_str(), buffer.size(), i,
+ 0, ovector ? *ovector : 0L, ovecsize) == PCRE_ERROR_NOMATCH)
return UString::null;
- }
if (!ovector)
return UString::null; // don't rely on the return value if you pass ovector==0
- if (pos)
- *pos = (*ovector)[0];
- return s.substr((*ovector)[0], (*ovector)[1] - (*ovector)[0]);
-
#else
- regmatch_t rmatch[10];
-
- if (i < 0)
- i = 0;
+#ifdef APPLE_CHANGES
+ const uint maxMatch = 10;
+#else
+ const int maxMatch = 10;
+#endif
+ regmatch_t rmatch[maxMatch];
- char *str = strdup(s.ascii());
- if (i > s.size() || s.isNull() ||
- regexec(&preg, str + i, 10, rmatch, 0)) {
- if (pos)
- *pos = -1;
+ char *str = strdup(s.ascii()); // TODO: why ???
+ if (regexec(&preg, str + i, maxMatch, rmatch, 0)) {
+ free(str);
return UString::null;
}
free(str);
- if (pos)
- *pos = rmatch[0].rm_so + i;
- // TODO copy from rmatch to ovector
- return s.substr(rmatch[0].rm_so + i, rmatch[0].rm_eo - rmatch[0].rm_so);
+ if (!ovector) {
+ *pos = rmatch[0].rm_so + i;
+ return s.substr(rmatch[0].rm_so + i, rmatch[0].rm_eo - rmatch[0].rm_so);
+ }
+
+ // map rmatch array to ovector used in PCRE case
+ nrSubPatterns = 0;
+#ifdef APPLE_CHANGES
+ for(uint j = 1; j < maxMatch && rmatch[j].rm_so >= 0 ; j++)
+#else
+ for(int j = 1; j < maxMatch && rmatch[j].rm_so >= 0 ; j++)
#endif
+ nrSubPatterns++;
+ int ovecsize = (nrSubPatterns+1)*3; // see above
+ *ovector = new int[ovecsize];
+#ifdef APPLE_CHANGES
+ for (uint j = 0; j < nrSubPatterns + 1; j++) {
+#else
+ for (int j = 0; j < nrSubPatterns + 1; j++) {
+#endif
+ if (j>maxMatch)
+ break;
+ (*ovector)[2*j] = rmatch[j].rm_so + i;
+ (*ovector)[2*j+1] = rmatch[j].rm_eo + i;
+#ifdef APPLE_CHANGES
+ } // balance extra { so we don't confuse prepare-ChangeLog
+#else
+ }
+#endif
+#endif
+
+ *pos = (*ovector)[0];
+ return s.substr((*ovector)[0], (*ovector)[1] - (*ovector)[0]);
}
#if 0 // unused
diff --git a/JavaScriptCore/kjs/regexp_object.cpp b/JavaScriptCore/kjs/regexp_object.cpp
index 2ea69b7..603cefb 100644
--- a/JavaScriptCore/kjs/regexp_object.cpp
+++ b/JavaScriptCore/kjs/regexp_object.cpp
@@ -92,12 +92,16 @@ Value RegExpProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &arg
i = 0;
if (i < 0 || i > length) {
thisObj.put(exec,"lastIndex", Number(0), DontDelete | DontEnum);
- return Null();
+ if (id == Test)
+ return Boolean(false);
+ else
+ Null();
}
RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp());
int **ovector = regExpObj->registerRegexp( re, s.value() );
str = re->match(s.value(), i, 0L, ovector);
+ regExpObj->setSubPatterns(re->subPatterns());
if (id == Test)
return Boolean(!str.isNull());
@@ -159,15 +163,13 @@ RegExpObjectImp::RegExpObjectImp(ExecState *exec,
RegExpObjectImp::~RegExpObjectImp()
{
- if (lastOvector)
- delete [] lastOvector;
+ delete [] lastOvector;
}
int **RegExpObjectImp::registerRegexp( const RegExp* re, const UString& s )
{
lastString = s;
- if (lastOvector)
- delete [] lastOvector;
+ delete [] lastOvector;
lastOvector = 0;
lastNrSubPatterns = re->subPatterns();
return &lastOvector;
diff --git a/JavaScriptCore/kjs/regexp_object.h b/JavaScriptCore/kjs/regexp_object.h
index fc31ef8..e775fea 100644
--- a/JavaScriptCore/kjs/regexp_object.h
+++ b/JavaScriptCore/kjs/regexp_object.h
@@ -74,6 +74,7 @@ namespace KJS {
Value get(ExecState *exec, const UString &p) const;
int ** registerRegexp( const RegExp* re, const UString& s );
+ void setSubPatterns(int num) { lastNrSubPatterns = num; }
Value arrayOfMatches(ExecState *exec, const UString &result) const;
private:
UString lastString;
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index c7c9cf1..7092df0 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -213,6 +213,7 @@ Value StringProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &arg
RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp());
int **ovector = regExpObj->registerRegexp( reg, u );
UString mstr = reg->match(u, -1, &pos, ovector);
+ regExpObj->setSubPatterns(reg->subPatterns());
if (a0.isA(StringType))
delete reg;
if (id == Search) {
@@ -242,7 +243,16 @@ Value StringProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &arg
do {
int **ovector = regExpObj->registerRegexp( reg, u );
UString mstr = reg->match(u, lastIndex, &pos, ovector);
+ regExpObj->setSubPatterns(reg->subPatterns());
+ if (pos == -1)
+ break;
len = mstr.size();
+ // special case of empty match
+ if (len == 0 && lastIndex > 0) {
+ pos = lastIndex + 1;
+ if (pos > u.size())
+ break;
+ }
UString rstr(u3);
bool ok;
// check if u3 matches $1 or $2 etc
@@ -262,10 +272,9 @@ Value StringProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &arg
}
}
lastIndex = pos + rstr.size();
- if ( pos != -1 )
- u = u.substr(0, pos) + rstr + u.substr(pos + len);
+ u = u.substr(0, pos) + rstr + u.substr(pos + len);
//fprintf(stderr,"pos=%d,len=%d,lastIndex=%d,u=%s\n",pos,len,lastIndex,u.ascii());
- } while ( global && pos != -1 );
+ } while (global);
result = String(u);
} else { // First arg is a string
diff --git a/JavaScriptCore/kjs/testkjs.cpp b/JavaScriptCore/kjs/testkjs.cpp
index fbe7f5b..05453a4 100644
--- a/JavaScriptCore/kjs/testkjs.cpp
+++ b/JavaScriptCore/kjs/testkjs.cpp
@@ -21,9 +21,6 @@
*/
#include <stdio.h>
-#if !APPLE_CHANGES
-#include <iostream.h>
-#endif
#include "value.h"
#include "object.h"
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index e0fa10e..13be9c8 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -423,7 +423,7 @@ double UString::toDouble( bool tolerant ) const
// empty string ?
if (*c == '\0')
- return 0.0;
+ return tolerant ? NaN : 0.0;
// hex number ?
if (*c == '0' && (*(c+1) == 'x' || *(c+1) == 'X')) {
diff --git a/JavaScriptCore/kjs/value.cpp b/JavaScriptCore/kjs/value.cpp
index caf4d3a..0d5a241 100644
--- a/JavaScriptCore/kjs/value.cpp
+++ b/JavaScriptCore/kjs/value.cpp
@@ -64,6 +64,7 @@ ValueImp::ValueImp() :
ValueImp::~ValueImp()
{
//fprintf(stderr,"ValueImp::~ValueImp %p\n",(void*)this);
+ _flags |= VI_DESTRUCTED;
}
void ValueImp::mark()
diff --git a/JavaScriptCore/kjs/value.h b/JavaScriptCore/kjs/value.h
index 000c554..df3aebd 100644
--- a/JavaScriptCore/kjs/value.h
+++ b/JavaScriptCore/kjs/value.h
@@ -160,7 +160,8 @@ namespace KJS {
enum {
VI_MARKED = 1,
VI_GCALLOWED = 2,
- VI_CREATED = 4
+ VI_CREATED = 4,
+ VI_DESTRUCTED = 8
}; // VI means VALUEIMPL
ValueImpPrivate *_vd;
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index f61f992..30f04b8 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,133 @@
+2002-06-10 Darin Adler <darin at apple.com>
+
+ Merged in changes from KDE 3.0.1.
+
+ * kwq/kdecore/kurl.h:
+ * kwq/KWQKURL.mm: (operator==): New, needed by some 3.0.1 code.
+
+ * kwq/qt/qpalette.h: Add QPalette::NColorGroups and QColorGroup::NColorRoles.
+ * kwq/KWQPalette.mm: Simplify by getting rid of "private" indirection.
+ (QPalette::color): New, needed by some 3.0.1 code.
+ * kwq/KWQColorGroup.mm: Simplify by getting rid of "private" indirection.
+
+ * kwq/qt/qstring.h:
+ * kwq/KWQString.mm: (QConstString::QConstString): Change parameter to const QChar *
+ to match Qt so we compile.
+
+ * kwq/qt/qtextedit.h:
+ * kwq/KWQTextEdit.mm: (QTextEdit::setTabStopWidth): Add unimplemented placeholder,
+ needed by some 3.0.1 code.
+
+ * kwq/qt/qvaluelist.h:
+ * kwq/KWQValueListImpl.h:
+ * kwq/KWQValueListImpl.mm: Simplify implementation.
+
+ * WebCore-tests.exp: Update for changes in QValueList implementation.
+
+ * kwq/kdecore/klibloader.h: Add include of <kio/global.h> to make something compile.
+
+ * kwq/khtml/java/kjavaappletcontext.h: Add JType and constructor that takes DCOPObject*.
+
+ * kwq/kio/global.h: Add KIO::CacheControl.
+
+ * khtml/css/css_ruleimpl.cpp:
+ * khtml/css/css_ruleimpl.h:
+ * khtml/css/css_stylesheetimpl.cpp:
+ * khtml/css/css_stylesheetimpl.h:
+ * khtml/css/css_valueimpl.cpp:
+ * khtml/css/css_valueimpl.h:
+ * khtml/css/cssparser.cpp:
+ * khtml/css/cssparser.h:
+ * khtml/css/cssstyleselector.cpp:
+ * khtml/css/cssstyleselector.h:
+ * khtml/css/html4.css:
+ * khtml/dom/css_rule.cpp:
+ * khtml/dom/css_rule.h:
+ * khtml/dom/css_stylesheet.cpp:
+ * khtml/dom/css_stylesheet.h:
+ * khtml/dom/css_value.cpp:
+ * khtml/dom/dom2_events.cpp:
+ * khtml/dom/dom2_range.cpp:
+ * khtml/dom/dom2_range.h:
+ * khtml/dom/dom2_views.cpp:
+ * khtml/dom/dom_doc.cpp:
+ * khtml/dom/dom_element.cpp:
+ * khtml/dom/dom_exception.h:
+ * khtml/dom/dom_node.cpp:
+ * khtml/dom/dom_string.cpp:
+ * khtml/dom/dom_text.cpp:
+ * khtml/dom/dom_xml.cpp:
+ * khtml/dom/html_base.cpp:
+ * khtml/dom/html_block.cpp:
+ * khtml/dom/html_document.cpp:
+ * khtml/dom/html_element.cpp:
+ * khtml/dom/html_element.h:
+ * khtml/dom/html_form.cpp:
+ * khtml/dom/html_head.cpp:
+ * khtml/dom/html_image.cpp:
+ * khtml/dom/html_inline.cpp:
+ * khtml/dom/html_list.cpp:
+ * khtml/dom/html_misc.cpp:
+ * khtml/dom/html_object.cpp:
+ * khtml/dom/html_table.cpp:
+ * khtml/ecma/kjs_html.cpp:
+ * khtml/ecma/kjs_proxy.cpp:
+ * khtml/ecma/kjs_traversal.cpp:
+ * khtml/ecma/kjs_window.cpp:
+ * khtml/html/html_baseimpl.cpp:
+ * khtml/html/html_formimpl.cpp:
+ * khtml/html/html_miscimpl.h:
+ * khtml/html/html_objectimpl.cpp:
+ * khtml/html/html_objectimpl.h:
+ * khtml/html/htmlparser.cpp:
+ * khtml/html/htmlparser.h:
+ * khtml/html/htmltokenizer.cpp:
+ * khtml/html/htmltokenizer.h:
+ * khtml/khtml_part.cpp:
+ * khtml/khtmlpart_p.h:
+ * khtml/khtmlview.cpp:
+ * khtml/misc/helper.cpp:
+ * khtml/misc/khtmllayout.h:
+ * khtml/misc/loader.cpp:
+ * khtml/misc/loader.h:
+ * khtml/misc/loader_client.h:
+ * khtml/misc/shared.h: Added.
+ * khtml/rendering/bidi.cpp:
+ * khtml/rendering/break_lines.cpp:
+ * khtml/rendering/font.cpp:
+ * khtml/rendering/render_applet.cpp:
+ * khtml/rendering/render_applet.h:
+ * khtml/rendering/render_container.cpp:
+ * khtml/rendering/render_form.cpp:
+ * khtml/rendering/render_form.h:
+ * khtml/rendering/render_frames.cpp:
+ * khtml/rendering/render_image.cpp:
+ * khtml/rendering/render_object.cpp:
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_replaced.cpp:
+ * khtml/rendering/render_replaced.h:
+ * khtml/rendering/render_root.cpp:
+ * khtml/rendering/render_style.cpp:
+ * khtml/rendering/render_style.h:
+ * khtml/rendering/render_table.cpp:
+ * khtml/rendering/render_table.h:
+ * khtml/rendering/render_text.cpp:
+ * khtml/rendering/render_text.h:
+ * khtml/xml/dom2_eventsimpl.h:
+ * khtml/xml/dom2_rangeimpl.h:
+ * khtml/xml/dom2_traversalimpl.cpp:
+ * khtml/xml/dom2_traversalimpl.h:
+ * khtml/xml/dom2_viewsimpl.h:
+ * khtml/xml/dom_docimpl.cpp:
+ * khtml/xml/dom_docimpl.h:
+ * khtml/xml/dom_elementimpl.h:
+ * khtml/xml/dom_nodeimpl.cpp:
+ * khtml/xml/dom_nodeimpl.h:
+ * khtml/xml/dom_stringimpl.cpp:
+ * khtml/xml/dom_stringimpl.h:
+ * khtml/xml/xml_tokenizer.h:
+ Merge in 3.0.1 changes and add APPLE_CHANGES as necessary to get it to compile.
+
2002-06-07 Darin Adler <darin at apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index f61f992..30f04b8 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,133 @@
+2002-06-10 Darin Adler <darin at apple.com>
+
+ Merged in changes from KDE 3.0.1.
+
+ * kwq/kdecore/kurl.h:
+ * kwq/KWQKURL.mm: (operator==): New, needed by some 3.0.1 code.
+
+ * kwq/qt/qpalette.h: Add QPalette::NColorGroups and QColorGroup::NColorRoles.
+ * kwq/KWQPalette.mm: Simplify by getting rid of "private" indirection.
+ (QPalette::color): New, needed by some 3.0.1 code.
+ * kwq/KWQColorGroup.mm: Simplify by getting rid of "private" indirection.
+
+ * kwq/qt/qstring.h:
+ * kwq/KWQString.mm: (QConstString::QConstString): Change parameter to const QChar *
+ to match Qt so we compile.
+
+ * kwq/qt/qtextedit.h:
+ * kwq/KWQTextEdit.mm: (QTextEdit::setTabStopWidth): Add unimplemented placeholder,
+ needed by some 3.0.1 code.
+
+ * kwq/qt/qvaluelist.h:
+ * kwq/KWQValueListImpl.h:
+ * kwq/KWQValueListImpl.mm: Simplify implementation.
+
+ * WebCore-tests.exp: Update for changes in QValueList implementation.
+
+ * kwq/kdecore/klibloader.h: Add include of <kio/global.h> to make something compile.
+
+ * kwq/khtml/java/kjavaappletcontext.h: Add JType and constructor that takes DCOPObject*.
+
+ * kwq/kio/global.h: Add KIO::CacheControl.
+
+ * khtml/css/css_ruleimpl.cpp:
+ * khtml/css/css_ruleimpl.h:
+ * khtml/css/css_stylesheetimpl.cpp:
+ * khtml/css/css_stylesheetimpl.h:
+ * khtml/css/css_valueimpl.cpp:
+ * khtml/css/css_valueimpl.h:
+ * khtml/css/cssparser.cpp:
+ * khtml/css/cssparser.h:
+ * khtml/css/cssstyleselector.cpp:
+ * khtml/css/cssstyleselector.h:
+ * khtml/css/html4.css:
+ * khtml/dom/css_rule.cpp:
+ * khtml/dom/css_rule.h:
+ * khtml/dom/css_stylesheet.cpp:
+ * khtml/dom/css_stylesheet.h:
+ * khtml/dom/css_value.cpp:
+ * khtml/dom/dom2_events.cpp:
+ * khtml/dom/dom2_range.cpp:
+ * khtml/dom/dom2_range.h:
+ * khtml/dom/dom2_views.cpp:
+ * khtml/dom/dom_doc.cpp:
+ * khtml/dom/dom_element.cpp:
+ * khtml/dom/dom_exception.h:
+ * khtml/dom/dom_node.cpp:
+ * khtml/dom/dom_string.cpp:
+ * khtml/dom/dom_text.cpp:
+ * khtml/dom/dom_xml.cpp:
+ * khtml/dom/html_base.cpp:
+ * khtml/dom/html_block.cpp:
+ * khtml/dom/html_document.cpp:
+ * khtml/dom/html_element.cpp:
+ * khtml/dom/html_element.h:
+ * khtml/dom/html_form.cpp:
+ * khtml/dom/html_head.cpp:
+ * khtml/dom/html_image.cpp:
+ * khtml/dom/html_inline.cpp:
+ * khtml/dom/html_list.cpp:
+ * khtml/dom/html_misc.cpp:
+ * khtml/dom/html_object.cpp:
+ * khtml/dom/html_table.cpp:
+ * khtml/ecma/kjs_html.cpp:
+ * khtml/ecma/kjs_proxy.cpp:
+ * khtml/ecma/kjs_traversal.cpp:
+ * khtml/ecma/kjs_window.cpp:
+ * khtml/html/html_baseimpl.cpp:
+ * khtml/html/html_formimpl.cpp:
+ * khtml/html/html_miscimpl.h:
+ * khtml/html/html_objectimpl.cpp:
+ * khtml/html/html_objectimpl.h:
+ * khtml/html/htmlparser.cpp:
+ * khtml/html/htmlparser.h:
+ * khtml/html/htmltokenizer.cpp:
+ * khtml/html/htmltokenizer.h:
+ * khtml/khtml_part.cpp:
+ * khtml/khtmlpart_p.h:
+ * khtml/khtmlview.cpp:
+ * khtml/misc/helper.cpp:
+ * khtml/misc/khtmllayout.h:
+ * khtml/misc/loader.cpp:
+ * khtml/misc/loader.h:
+ * khtml/misc/loader_client.h:
+ * khtml/misc/shared.h: Added.
+ * khtml/rendering/bidi.cpp:
+ * khtml/rendering/break_lines.cpp:
+ * khtml/rendering/font.cpp:
+ * khtml/rendering/render_applet.cpp:
+ * khtml/rendering/render_applet.h:
+ * khtml/rendering/render_container.cpp:
+ * khtml/rendering/render_form.cpp:
+ * khtml/rendering/render_form.h:
+ * khtml/rendering/render_frames.cpp:
+ * khtml/rendering/render_image.cpp:
+ * khtml/rendering/render_object.cpp:
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_replaced.cpp:
+ * khtml/rendering/render_replaced.h:
+ * khtml/rendering/render_root.cpp:
+ * khtml/rendering/render_style.cpp:
+ * khtml/rendering/render_style.h:
+ * khtml/rendering/render_table.cpp:
+ * khtml/rendering/render_table.h:
+ * khtml/rendering/render_text.cpp:
+ * khtml/rendering/render_text.h:
+ * khtml/xml/dom2_eventsimpl.h:
+ * khtml/xml/dom2_rangeimpl.h:
+ * khtml/xml/dom2_traversalimpl.cpp:
+ * khtml/xml/dom2_traversalimpl.h:
+ * khtml/xml/dom2_viewsimpl.h:
+ * khtml/xml/dom_docimpl.cpp:
+ * khtml/xml/dom_docimpl.h:
+ * khtml/xml/dom_elementimpl.h:
+ * khtml/xml/dom_nodeimpl.cpp:
+ * khtml/xml/dom_nodeimpl.h:
+ * khtml/xml/dom_stringimpl.cpp:
+ * khtml/xml/dom_stringimpl.h:
+ * khtml/xml/xml_tokenizer.h:
+ Merge in 3.0.1 changes and add APPLE_CHANGES as necessary to get it to compile.
+
2002-06-07 Darin Adler <darin at apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index f61f992..30f04b8 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,133 @@
+2002-06-10 Darin Adler <darin at apple.com>
+
+ Merged in changes from KDE 3.0.1.
+
+ * kwq/kdecore/kurl.h:
+ * kwq/KWQKURL.mm: (operator==): New, needed by some 3.0.1 code.
+
+ * kwq/qt/qpalette.h: Add QPalette::NColorGroups and QColorGroup::NColorRoles.
+ * kwq/KWQPalette.mm: Simplify by getting rid of "private" indirection.
+ (QPalette::color): New, needed by some 3.0.1 code.
+ * kwq/KWQColorGroup.mm: Simplify by getting rid of "private" indirection.
+
+ * kwq/qt/qstring.h:
+ * kwq/KWQString.mm: (QConstString::QConstString): Change parameter to const QChar *
+ to match Qt so we compile.
+
+ * kwq/qt/qtextedit.h:
+ * kwq/KWQTextEdit.mm: (QTextEdit::setTabStopWidth): Add unimplemented placeholder,
+ needed by some 3.0.1 code.
+
+ * kwq/qt/qvaluelist.h:
+ * kwq/KWQValueListImpl.h:
+ * kwq/KWQValueListImpl.mm: Simplify implementation.
+
+ * WebCore-tests.exp: Update for changes in QValueList implementation.
+
+ * kwq/kdecore/klibloader.h: Add include of <kio/global.h> to make something compile.
+
+ * kwq/khtml/java/kjavaappletcontext.h: Add JType and constructor that takes DCOPObject*.
+
+ * kwq/kio/global.h: Add KIO::CacheControl.
+
+ * khtml/css/css_ruleimpl.cpp:
+ * khtml/css/css_ruleimpl.h:
+ * khtml/css/css_stylesheetimpl.cpp:
+ * khtml/css/css_stylesheetimpl.h:
+ * khtml/css/css_valueimpl.cpp:
+ * khtml/css/css_valueimpl.h:
+ * khtml/css/cssparser.cpp:
+ * khtml/css/cssparser.h:
+ * khtml/css/cssstyleselector.cpp:
+ * khtml/css/cssstyleselector.h:
+ * khtml/css/html4.css:
+ * khtml/dom/css_rule.cpp:
+ * khtml/dom/css_rule.h:
+ * khtml/dom/css_stylesheet.cpp:
+ * khtml/dom/css_stylesheet.h:
+ * khtml/dom/css_value.cpp:
+ * khtml/dom/dom2_events.cpp:
+ * khtml/dom/dom2_range.cpp:
+ * khtml/dom/dom2_range.h:
+ * khtml/dom/dom2_views.cpp:
+ * khtml/dom/dom_doc.cpp:
+ * khtml/dom/dom_element.cpp:
+ * khtml/dom/dom_exception.h:
+ * khtml/dom/dom_node.cpp:
+ * khtml/dom/dom_string.cpp:
+ * khtml/dom/dom_text.cpp:
+ * khtml/dom/dom_xml.cpp:
+ * khtml/dom/html_base.cpp:
+ * khtml/dom/html_block.cpp:
+ * khtml/dom/html_document.cpp:
+ * khtml/dom/html_element.cpp:
+ * khtml/dom/html_element.h:
+ * khtml/dom/html_form.cpp:
+ * khtml/dom/html_head.cpp:
+ * khtml/dom/html_image.cpp:
+ * khtml/dom/html_inline.cpp:
+ * khtml/dom/html_list.cpp:
+ * khtml/dom/html_misc.cpp:
+ * khtml/dom/html_object.cpp:
+ * khtml/dom/html_table.cpp:
+ * khtml/ecma/kjs_html.cpp:
+ * khtml/ecma/kjs_proxy.cpp:
+ * khtml/ecma/kjs_traversal.cpp:
+ * khtml/ecma/kjs_window.cpp:
+ * khtml/html/html_baseimpl.cpp:
+ * khtml/html/html_formimpl.cpp:
+ * khtml/html/html_miscimpl.h:
+ * khtml/html/html_objectimpl.cpp:
+ * khtml/html/html_objectimpl.h:
+ * khtml/html/htmlparser.cpp:
+ * khtml/html/htmlparser.h:
+ * khtml/html/htmltokenizer.cpp:
+ * khtml/html/htmltokenizer.h:
+ * khtml/khtml_part.cpp:
+ * khtml/khtmlpart_p.h:
+ * khtml/khtmlview.cpp:
+ * khtml/misc/helper.cpp:
+ * khtml/misc/khtmllayout.h:
+ * khtml/misc/loader.cpp:
+ * khtml/misc/loader.h:
+ * khtml/misc/loader_client.h:
+ * khtml/misc/shared.h: Added.
+ * khtml/rendering/bidi.cpp:
+ * khtml/rendering/break_lines.cpp:
+ * khtml/rendering/font.cpp:
+ * khtml/rendering/render_applet.cpp:
+ * khtml/rendering/render_applet.h:
+ * khtml/rendering/render_container.cpp:
+ * khtml/rendering/render_form.cpp:
+ * khtml/rendering/render_form.h:
+ * khtml/rendering/render_frames.cpp:
+ * khtml/rendering/render_image.cpp:
+ * khtml/rendering/render_object.cpp:
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_replaced.cpp:
+ * khtml/rendering/render_replaced.h:
+ * khtml/rendering/render_root.cpp:
+ * khtml/rendering/render_style.cpp:
+ * khtml/rendering/render_style.h:
+ * khtml/rendering/render_table.cpp:
+ * khtml/rendering/render_table.h:
+ * khtml/rendering/render_text.cpp:
+ * khtml/rendering/render_text.h:
+ * khtml/xml/dom2_eventsimpl.h:
+ * khtml/xml/dom2_rangeimpl.h:
+ * khtml/xml/dom2_traversalimpl.cpp:
+ * khtml/xml/dom2_traversalimpl.h:
+ * khtml/xml/dom2_viewsimpl.h:
+ * khtml/xml/dom_docimpl.cpp:
+ * khtml/xml/dom_docimpl.h:
+ * khtml/xml/dom_elementimpl.h:
+ * khtml/xml/dom_nodeimpl.cpp:
+ * khtml/xml/dom_nodeimpl.h:
+ * khtml/xml/dom_stringimpl.cpp:
+ * khtml/xml/dom_stringimpl.h:
+ * khtml/xml/xml_tokenizer.h:
+ Merge in 3.0.1 changes and add APPLE_CHANGES as necessary to get it to compile.
+
2002-06-07 Darin Adler <darin at apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
diff --git a/WebCore/WebCore-tests.exp b/WebCore/WebCore-tests.exp
index c626b57..753ac1b 100644
--- a/WebCore/WebCore-tests.exp
+++ b/WebCore/WebCore-tests.exp
@@ -86,7 +86,6 @@ __ZN19KWQListIteratorImplaSERKS_
__ZN19KWQListIteratorImplmmEv
__ZN19KWQListIteratorImplppEv
__ZN20KWQValueListNodeImplC2Ev
-__ZN20KWQValueListNodeImplD2Ev
__ZN22KWQPtrDictIteratorImpl7toFirstEv
__ZN22KWQPtrDictIteratorImplC1ERK14KWQPtrDictImpl
__ZN22KWQPtrDictIteratorImplC2ERK14KWQPtrDictImpl
@@ -94,10 +93,7 @@ __ZN22KWQPtrDictIteratorImplD1Ev
__ZN22KWQPtrDictIteratorImplD2Ev
__ZN22KWQPtrDictIteratorImplppEv
__ZN24KWQValueListIteratorImpl4nodeEv
-__ZN24KWQValueListIteratorImplC1ERKS_
__ZN24KWQValueListIteratorImplC1Ev
-__ZN24KWQValueListIteratorImplD1Ev
-__ZN24KWQValueListIteratorImplaSERKS_
__ZN24KWQValueListIteratorImpleqERKS_
__ZN24KWQValueListIteratorImplmmEv
__ZN24KWQValueListIteratorImplneERKS_
diff --git a/WebCore/khtml/css/css_ruleimpl.cpp b/WebCore/khtml/css/css_ruleimpl.cpp
index 145be85..ccba597 100644
--- a/WebCore/khtml/css/css_ruleimpl.cpp
+++ b/WebCore/khtml/css/css_ruleimpl.cpp
@@ -54,16 +54,14 @@ unsigned short CSSRuleImpl::type() const
CSSStyleSheetImpl *CSSRuleImpl::parentStyleSheet() const
{
- if( !m_parent ) return 0;
- if( m_parent->isCSSStyleSheet() ) return static_cast<CSSStyleSheetImpl *>(m_parent);
- return 0;
+ return ( m_parent && m_parent->isCSSStyleSheet() ) ?
+ static_cast<CSSStyleSheetImpl *>(m_parent) : 0;
}
CSSRuleImpl *CSSRuleImpl::parentRule() const
{
- if( !m_parent ) return 0;
- if( m_parent->isRule() ) return static_cast<CSSRuleImpl *>(m_parent);
- return 0;
+ return ( m_parent && m_parent->isRule() ) ?
+ static_cast<CSSRuleImpl *>(m_parent) : 0;
}
DOM::DOMString CSSRuleImpl::cssText() const
@@ -154,9 +152,12 @@ void CSSImportRuleImpl::setStyleSheet(const DOM::DOMString &url, const DOM::DOMS
{
kdDebug( 6080 ) << "CSSImportRule::setStyleSheet()" << endl;
+ if ( m_styleSheet ) m_styleSheet->deref();
m_styleSheet = new CSSStyleSheetImpl(this, url);
m_styleSheet->ref();
- m_styleSheet->parseString( sheet, parentStyleSheet() ? parentStyleSheet()->useStrictParsing() : true );
+
+ CSSStyleSheetImpl *parent = parentStyleSheet();
+ m_styleSheet->parseString( sheet, parent ? parent->useStrictParsing() : true );
m_loading = false;
checkLoaded();
@@ -164,24 +165,24 @@ void CSSImportRuleImpl::setStyleSheet(const DOM::DOMString &url, const DOM::DOMS
bool CSSImportRuleImpl::isLoading()
{
- if(m_loading) return true;
- if(m_styleSheet->isLoading()) return true;
- return false;
+ return ( m_loading || (m_styleSheet && m_styleSheet->isLoading()) );
}
void CSSImportRuleImpl::init()
{
khtml::DocLoader *docLoader = 0;
StyleBaseImpl *root = this;
- while (root->parent())
- root = root->parent();
+ StyleBaseImpl *parent;
+ while ( ( parent = root->parent()) )
+ root = parent;
if (root->isCSSStyleSheet())
docLoader = static_cast<CSSStyleSheetImpl*>(root)->docLoader();
DOMString absHref = m_strHref;
- if (!parentStyleSheet()->href().isNull()) {
+ CSSStyleSheetImpl *parentSheet = parentStyleSheet();
+ if (!parentSheet->href().isNull()) {
// use parent styleheet's URL as the base URL
- absHref = KURL(parentStyleSheet()->href().string(),m_strHref.string()).url();
+ absHref = KURL(parentSheet->href().string(),m_strHref.string()).url();
}
/*
else {
@@ -263,10 +264,7 @@ CSSRuleListImpl *CSSMediaRuleImpl::cssRules()
unsigned long CSSMediaRuleImpl::appendRule( CSSRuleImpl *rule )
{
- if( rule )
- return m_lstCSSRules->insertRule( rule, m_lstCSSRules->length() );
- else
- return 0;
+ return rule ? m_lstCSSRules->insertRule( rule, m_lstCSSRules->length() ) : 0;
}
unsigned long CSSMediaRuleImpl::insertRule( const DOMString &rule,
@@ -275,10 +273,7 @@ unsigned long CSSMediaRuleImpl::insertRule( const DOMString &rule,
const QChar *curP = rule.unicode();
CSSRuleImpl *newRule = parseRule( curP, curP + rule.length() );
- if( newRule )
- return m_lstCSSRules->insertRule( newRule, index );
-
- return 0;
+ return newRule ? m_lstCSSRules->insertRule( newRule, index ) : 0;
}
void CSSMediaRuleImpl::deleteRule( unsigned long index )
@@ -352,9 +347,8 @@ DOM::DOMString CSSStyleRuleImpl::selectorText() const
if ( m_selector && m_selector->first() ) {
// ### m_selector will be a single selector hopefully. so ->first() will disappear
CSSSelector* cs = m_selector->first();
- cs->print(); // debug
- DOMString str = cs->selectorText();
- return str;
+ //cs->print(); // debug
+ return cs->selectorText();
}
return DOMString();
}
@@ -377,9 +371,11 @@ void CSSStyleRuleImpl::setSelector( QPtrList<CSSSelector> *selector)
void CSSStyleRuleImpl::setDeclaration( CSSStyleDeclarationImpl *style)
{
+ if ( m_style != style ) {
if(m_style) m_style->deref();
m_style = style;
if(m_style) m_style->ref();
+ }
}
void CSSStyleRuleImpl::setNonCSSHints()
diff --git a/WebCore/khtml/css/css_ruleimpl.h b/WebCore/khtml/css/css_ruleimpl.h
index e5485e2..cecb47a 100644
--- a/WebCore/khtml/css/css_ruleimpl.h
+++ b/WebCore/khtml/css/css_ruleimpl.h
@@ -26,6 +26,7 @@
#include "dom/css_rule.h"
#include "css/cssparser.h"
#include "misc/loader_client.h"
+#include "misc/shared.h"
namespace khtml {
class CachedCSSStyleSheet;
@@ -211,7 +212,7 @@ public:
};
-class CSSRuleListImpl : public DomShared
+class CSSRuleListImpl : public khtml::Shared<CSSRuleListImpl>
{
public:
CSSRuleListImpl();
diff --git a/WebCore/khtml/css/css_stylesheetimpl.cpp b/WebCore/khtml/css/css_stylesheetimpl.cpp
index 21780e1..0054f6e 100644
--- a/WebCore/khtml/css/css_stylesheetimpl.cpp
+++ b/WebCore/khtml/css/css_stylesheetimpl.cpp
@@ -78,12 +78,6 @@ StyleSheetImpl::~StyleSheetImpl()
}
}
-bool StyleSheetImpl::deleteMe()
-{
- if(!m_parent && _ref <= 0) return true;
- return false;
-}
-
bool StyleSheetImpl::disabled() const
{
return m_disabled;
diff --git a/WebCore/khtml/css/css_stylesheetimpl.h b/WebCore/khtml/css/css_stylesheetimpl.h
index b455484..199a7c1 100644
--- a/WebCore/khtml/css/css_stylesheetimpl.h
+++ b/WebCore/khtml/css/css_stylesheetimpl.h
@@ -58,8 +58,6 @@ public:
virtual bool isStyleSheet() const { return true; }
- virtual bool deleteMe();
-
virtual DOM::DOMString type() const { return DOMString(); }
bool disabled() const;
@@ -117,11 +115,11 @@ protected:
// ----------------------------------------------------------------------------
-class StyleSheetListImpl : public DomShared
+class StyleSheetListImpl : public khtml::Shared<StyleSheetListImpl>
{
public:
StyleSheetListImpl();
- virtual ~StyleSheetListImpl();
+ ~StyleSheetListImpl();
// the following two ignore implicit stylesheets
unsigned long length() const;
diff --git a/WebCore/khtml/css/css_valueimpl.cpp b/WebCore/khtml/css/css_valueimpl.cpp
index 0056cde..08c2998 100644
--- a/WebCore/khtml/css/css_valueimpl.cpp
+++ b/WebCore/khtml/css/css_valueimpl.cpp
@@ -88,9 +88,10 @@ CSSValueImpl *CSSStyleDeclarationImpl::getPropertyCSSValue( int propertyID )
if(!m_lstValues) return 0;
QPtrListIterator<CSSProperty> lstValuesIt(*m_lstValues);
- for (lstValuesIt.toLast(); lstValuesIt.current(); --lstValuesIt)
- if (lstValuesIt.current()->m_id == propertyID && !lstValuesIt.current()->nonCSSHint)
- return lstValuesIt.current()->value();
+ CSSProperty *current;
+ for ( lstValuesIt.toLast(); (current = lstValuesIt.current()); --lstValuesIt )
+ if (current->m_id == propertyID && !current->nonCSSHint)
+ return current->value();
return 0;
}
@@ -100,13 +101,13 @@ DOMString CSSStyleDeclarationImpl::removeProperty( int propertyID, bool NonCSSHi
DOMString value;
QPtrListIterator<CSSProperty> lstValuesIt(*m_lstValues);
- for (lstValuesIt.toLast(); lstValuesIt.current(); --lstValuesIt)
- if (lstValuesIt.current()->m_id == propertyID && NonCSSHint == lstValuesIt.current()->nonCSSHint) {
- value = lstValuesIt.current()->value()->cssText();
- m_lstValues->removeRef(lstValuesIt.current());
+ CSSProperty *current;
+ for ( lstValuesIt.toLast(); (current = lstValuesIt.current()); --lstValuesIt )
+ if (current->m_id == propertyID && NonCSSHint == current->nonCSSHint) {
+ value = current->value()->cssText();
+ m_lstValues->removeRef(current);
setChanged();
-
- return value;
+ break;
}
return value;
@@ -129,13 +130,13 @@ void CSSStyleDeclarationImpl::setChanged()
bool CSSStyleDeclarationImpl::getPropertyPriority( int propertyID )
{
- if(!m_lstValues) return false;
-
- unsigned int i = 0;
- while(i < m_lstValues->count())
- {
- if(propertyID == m_lstValues->at(i)->m_id ) return m_lstValues->at(i)->m_bImportant;
- i++;
+ if ( m_lstValues) {
+ QPtrListIterator<CSSProperty> lstValuesIt(*m_lstValues);
+ CSSProperty *current;
+ for ( lstValuesIt.toFirst(); (current = lstValuesIt.current()); ++lstValuesIt ) {
+ if( propertyID == current->m_id )
+ return current->m_bImportant;
+ }
}
return false;
}
@@ -184,20 +185,18 @@ void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString)
props->setAutoDelete(false);
-#ifndef APPLE_CHANGES
- unsigned int i = 0;
-#endif
if(!m_lstValues) {
m_lstValues = new QPtrList<CSSProperty>;
m_lstValues->setAutoDelete( true );
}
- for (unsigned int i = 0; i < props->count(); ++i) {
- //kdDebug( 6080 ) << "setting property" << endl;
- CSSProperty *prop = props->at(i);
+ CSSProperty *prop = props->first();
+ while( prop ) {
removeProperty(prop->m_id, false);
m_lstValues->append(prop);
+ prop = props->next();
}
+
delete props;
setChanged();
}
@@ -212,8 +211,7 @@ void CSSStyleDeclarationImpl::setLengthProperty(int id, const DOM::DOMString &va
unsigned long CSSStyleDeclarationImpl::length() const
{
- if(!m_lstValues) return 0;
- return m_lstValues->count();
+ return m_lstValues ? m_lstValues->count() : 0;
}
DOMString CSSStyleDeclarationImpl::item( unsigned long /*index*/ )
@@ -225,9 +223,8 @@ DOMString CSSStyleDeclarationImpl::item( unsigned long /*index*/ )
CSSRuleImpl *CSSStyleDeclarationImpl::parentRule() const
{
- if( !m_parent ) return 0;
- if( m_parent->isRule() ) return static_cast<CSSRuleImpl *>(m_parent);
- return 0;
+ return (m_parent && m_parent->isRule() ) ?
+ static_cast<CSSRuleImpl *>(m_parent) : 0;
}
DOM::DOMString CSSStyleDeclarationImpl::cssText() const
diff --git a/WebCore/khtml/css/css_valueimpl.h b/WebCore/khtml/css/css_valueimpl.h
index 51812b1..a080ba1 100644
--- a/WebCore/khtml/css/css_valueimpl.h
+++ b/WebCore/khtml/css/css_valueimpl.h
@@ -26,6 +26,7 @@
#include "dom/dom_string.h"
#include "css/cssparser.h"
#include "misc/loader_client.h"
+#include "misc/shared.h"
#include <qintdict.h>
@@ -221,7 +222,7 @@ protected:
} m_value;
};
-class CounterImpl : public DomShared {
+class CounterImpl : public khtml::Shared<CounterImpl> {
public:
CounterImpl() { }
DOMString identifier() const { return m_identifier; }
@@ -233,7 +234,7 @@ public:
DOMString m_separator;
};
-class RectImpl : public DomShared {
+class RectImpl : public khtml::Shared<RectImpl> {
public:
RectImpl();
~RectImpl();
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 8dab36b..955f9b9 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -83,12 +83,6 @@ int DOM::getPropertyID(const char *tagStr, int len)
// ------------------------------------------------------------------------------------------------------
-bool StyleBaseImpl::deleteMe()
-{
- if(!m_parent && _ref <= 0) return true;
- return false;
-}
-
void StyleBaseImpl::checkLoaded()
{
if(m_parent) m_parent->checkLoaded();
@@ -101,7 +95,7 @@ DOMString StyleBaseImpl::baseURL()
// try to find out about their url
StyleBaseImpl *b = this;
while(b && !b->isStyleSheet())
- b = b->parent();
+ b = b->m_parent;
if(!b) return DOMString();
@@ -191,7 +185,7 @@ StyleBaseImpl::parseToChar(const QChar *curP, const QChar *endP, QChar c, bool c
sq = !sq;
else if (!sq && !dq && *curP == c)
return(curP);
- else if (!sq && !dq && chkws && curP->isSpace()) //isspace(*curP))
+ else if (!sq && !dq && chkws && curP->isSpace())
return(curP);
else if(!sq && !dq ) {
if (*curP == '{') {
@@ -854,8 +848,8 @@ public:
int m_yyTok;
bool strictParsing;
- int getChar() {
- return ( m_yyPos == m_yyIn.length() ) ? QChar('\0') : QChar(m_yyIn[m_yyPos++]);
+ QChar getChar() {
+ return ( m_yyPos == m_yyIn.length() ) ? QChar('\0') : m_yyIn.unicode()[m_yyPos++];
}
void startTokenizer( const QString& str, bool _strictParsing ) {
@@ -869,45 +863,7 @@ public:
m_yyTok = TOK_NONE;
}
- int getToken()
- {
- m_yyStr = QString::null;
-
- if ( m_yyChar == '\0' )
- return TOK_EOI;
- if ( m_yyChar == QChar(' ') )
- m_yyChar = getChar();
-
- if ( m_yyChar == QChar('/') ) {
- m_yyChar = getChar();
- return TOK_SLASH;
- } else if ( m_yyChar == QChar(',') ) {
- m_yyChar = getChar();
- return TOK_COMMA;
- } else if ( m_yyChar == QChar('"') ) {
- m_yyChar = getChar();
- while ( m_yyChar != QChar('"') && m_yyChar != '\0' ) {
- m_yyStr += m_yyChar;
- m_yyChar = getChar();
- }
- m_yyChar = getChar();
- return TOK_STRING;
- } else if ( m_yyChar == QChar('\'') ) {
- m_yyChar = getChar();
- while ( m_yyChar != QChar('\'') && m_yyChar != '\0' ) {
- m_yyStr += m_yyChar;
- m_yyChar = getChar();
- }
- m_yyChar = getChar();
- return TOK_STRING;
- } else {
- while ( m_yyChar != '/' && m_yyChar != ',' && m_yyChar != '\0' && m_yyChar != ' ') {
- m_yyStr += m_yyChar;
- m_yyChar = getChar();
- }
- return TOK_SYMBOL;
- }
- }
+ int getToken();
bool match( int tok )
{
@@ -1026,8 +982,54 @@ public:
return TRUE;
}
- bool matchFontFamily ( QStringList *ffamily )
- {
+ bool matchFontFamily ( QStringList *ffamily );
+ bool matchRealFont( QString *fstyle, QString *fvariant, QString *fweight,
+ QString *fsize, QString *lheight, QString *ffamily );
+};
+
+int FontParser::getToken()
+{
+ m_yyStr = QString::null;
+
+ if ( m_yyChar == '\0' )
+ return TOK_EOI;
+ if ( m_yyChar == ' ' )
+ m_yyChar = getChar();
+
+ if ( m_yyChar == '/' ) {
+ m_yyChar = getChar();
+ return TOK_SLASH;
+ } else if ( m_yyChar == ',' ) {
+ m_yyChar = getChar();
+ return TOK_COMMA;
+ } else if ( m_yyChar == '"' ) {
+ m_yyChar = getChar();
+ while ( m_yyChar != '"' && m_yyChar != '\0' ) {
+ m_yyStr += m_yyChar;
+ m_yyChar = getChar();
+ }
+ m_yyChar = getChar();
+ return TOK_STRING;
+ } else if ( m_yyChar == '\'' ) {
+ m_yyChar = getChar();
+ while ( m_yyChar != '\'' && m_yyChar != '\0' ) {
+ m_yyStr += m_yyChar;
+ m_yyChar = getChar();
+ }
+ m_yyChar = getChar();
+ return TOK_STRING;
+ } else {
+ while ( m_yyChar != '/' && m_yyChar != ',' && m_yyChar != '\0' && m_yyChar != ' ') {
+ m_yyStr += m_yyChar;
+ m_yyChar = getChar();
+ }
+ return TOK_SYMBOL;
+ }
+}
+
+
+bool FontParser::matchFontFamily ( QStringList *ffamily )
+{
if ( m_yyTok == TOK_NONE )
m_yyTok = getToken();
#if 0
@@ -1047,11 +1049,11 @@ public:
} while ( match(TOK_COMMA) );
return true;
- }
+}
- bool matchRealFont( QString *fstyle, QString *fvariant, QString *fweight,
+bool FontParser::matchRealFont( QString *fstyle, QString *fvariant, QString *fweight,
QString *fsize, QString *lheight, QString *ffamily )
- {
+{
bool metFstyle = matchFontStyle( fstyle );
bool metFvariant = matchFontVariant( fvariant );
matchFontWeight( fweight );
@@ -1071,8 +1073,7 @@ public:
if ( !matchFontFamily(ffamily) )
return FALSE;
return true;
- }
-};
+}
bool StyleBaseImpl::parseFont(const QChar *curP, const QChar *endP)
{
@@ -1113,7 +1114,7 @@ bool StyleBaseImpl::parseFont(const QChar *curP, const QChar *endP)
} else {
fweight = "normal";
}
- fsize.sprintf("%dpx", sysFont.pixelSize());
+ fsize = QString::number( sysFont.pixelSize() ) + "px";
ffamily = sysFont.family();
} else {
@@ -1226,7 +1227,14 @@ bool StyleBaseImpl::parseValue( const QChar *curP, const QChar *endP, int propId
// only shape in CSS2 is rect( top right bottom left )
QString str = QConstString( const_cast<QChar*>( curP ), endP - curP ).string();
// the CSS specs are not really clear if there should be commas in here or not. We accept both spaces and commas.
- str.replace( QRegExp( "," ), " " );
+ QChar *uc = (QChar *)str.unicode();
+ int len = str.length();
+ while( len ) {
+ if ( *uc == ',' )
+ *uc = ' ';
+ uc++;
+ len--;
+ }
str = str.simplifyWhiteSpace();
if ( str.find( "rect", 0, false ) != 0 )
break;
@@ -2330,106 +2338,95 @@ CSSValueImpl* StyleBaseImpl::parseContent(const QChar *curP, const QChar *endP)
{
CSSValueListImpl* values = new CSSValueListImpl();
- QPtrList<QChar> list = splitContent(curP, endP);
- for(uint n=0; n<list.count(); n+=2)
- {
- QString str(list.at(n), list.at(n+1)-list.at(n));
- CSSValueImpl* parsedValue=0;
- if (str.left(4) == "url(")
+ while (curP < endP) {
+ const QChar *nextP = curP;
+ bool esc = false;
+ bool sq = false;
+ bool dq = false;
+ while ( nextP < endP ) {
+ if (esc)
+ esc = false;
+ else if (*nextP == '\\')
+ esc = true;
+ else if (!sq && (*nextP == '"')) {
+ if (dq) break;
+ dq = true;
+ }
+ else if (!dq && (*nextP == '\'')) {
+ if (sq) break;
+ sq = true;
+ }
+ else if (!sq && !dq && nextP->isSpace())
+ break;
+ nextP++;
+ }
+ QString str = QConstString(curP, nextP-curP).string();
+ CSSValueImpl* parsedValue=0;
+ if (str.startsWith("url("))
{
// url
DOMString value(curP, endP - curP);
value = khtml::parseURL(value);
parsedValue = new CSSImageValueImpl(
- DOMString(KURL(baseURL().string(), value.string()).url()), this);
- #ifdef CSS_DEBUG
+ DOMString(KURL(baseURL().string(), value.string()).url()), this);
+#ifdef CSS_DEBUG
kdDebug( 6080 ) << "content, url=" << value.string() << " base=" << baseURL().string() << endl;
- #endif
+#endif
}
- else if (str.left(5) == "attr(")
+ else if (str.startsWith("attr("))
{
// attr
}
- else if (str.left(8) == "counter(")
+ else if (str.startsWith("counter("))
{
// counter
}
- else if (str == "open-quote")
+ else if (str.startsWith("open-quote"))
{
// open-quote
}
- else if (str == "close-quote")
+ else if (str.startsWith("close-quote"))
{
// open-quote
}
- else if (str == "no-open-quote")
+ else if (str.startsWith("no-open-quote"))
{
// no-open-quote
}
- else if (str == "no-close-quote")
+ else if (str.startsWith("no-close-quote"))
{
// no-close-quote
}
- else
+ else if (str.length() && (str[0] == '\'' || str[0] == '"'))
{
// string
- QString str = QConstString( list.at(n), list.at(n+1)-list.at(n)).string();
- str = str.replace(QRegExp("\\\\a"),"\n");
- parsedValue = new CSSPrimitiveValueImpl(DOMString(str), CSSPrimitiveValue::CSS_STRING);
+ int l = str.length();
+ QString strstr;
+ for (int i = 0; i < l; ++i) {
+ if (i < l - 1 && str[i] == '\\') {
+ if (str[i+1] == 'a')
+ strstr += '\n';
+ else
+ strstr += str[i+1];
+ ++i;
+ continue;
+ }
+ strstr += str[i];
+ }
+ parsedValue = new CSSPrimitiveValueImpl(DOMString(strstr), CSSPrimitiveValue::CSS_STRING);
}
if (parsedValue)
values->append(parsedValue);
+ // skip over whitespace
+ for (curP = ++nextP ; curP < endP && curP->isSpace(); ++curP)
+ ;
}
return values;
}
-
-QPtrList<QChar> StyleBaseImpl::splitContent(const QChar *curP, const QChar *endP)
-{
- bool last = false;
-
- QPtrList<QChar> list;
- while(!last) {
- const QChar *nextP = curP;
- bool q = false;
- bool dq = false;
- if(*nextP=='\'')
- q=true;
- else if (*nextP=='\"')
- dq=true;
- while(!(nextP->isSpace()) || q || dq) {
- nextP++;
- if(nextP >= endP){
- last = true;
- break;
- }
- if((q&&*nextP=='\'') || (dq&&*nextP=='\"')){
- nextP++;
- if(nextP >= endP) last= true;
- break;
- }
- }
-
- list.append(curP+((q||dq)?1:0));
- list.append(nextP-((q||dq)?1:0));
-
- if ( last ) break;
- while(nextP->isSpace()) { // skip over WS between tokens
- nextP++;
- curP = nextP;
- if(curP >= endP) {
- last = true;
- break;
- }
- }
- }
- return list;
-}
-
-
QPtrList<QChar> StyleBaseImpl::splitShorthandProperties(const QChar *curP, const QChar *endP)
{
bool last = false;
@@ -2939,7 +2936,7 @@ StyleListImpl::~StyleListImpl()
for( n = m_lstChildren->first(); n != 0; n = m_lstChildren->next() )
{
n->setParent(0);
- if(n->deleteMe()) delete n;
+ if( !n->refCount() ) delete n;
}
delete m_lstChildren;
}
@@ -2958,8 +2955,7 @@ unsigned int CSSSelector::specificity()
if ( nonCSSHint )
return 0;
- int s = 0;
- if(tag != -1) s = 1;
+ int s = (tag != -1);
switch(match)
{
case Exact:
diff --git a/WebCore/khtml/css/cssparser.h b/WebCore/khtml/css/cssparser.h
index 84377c6..9bda69b 100644
--- a/WebCore/khtml/css/cssparser.h
+++ b/WebCore/khtml/css/cssparser.h
@@ -25,6 +25,7 @@
#include "dom/dom_string.h"
#include "dom/dom_misc.h"
+#include "misc/shared.h"
#include <qdatetime.h>
#include <qptrlist.h>
@@ -111,21 +112,17 @@ public:
};
// a style class which has a parent (almost all have)
- class StyleBaseImpl : public DomShared
+ class StyleBaseImpl : public khtml::TreeShared<StyleBaseImpl>
{
public:
- StyleBaseImpl() : DOM::DomShared() { m_parent = 0; hasInlinedDecl = false; strictParsing = true; }
- StyleBaseImpl(StyleBaseImpl *p) : DOM::DomShared() { m_parent = p; hasInlinedDecl = false; strictParsing = true; }
+ StyleBaseImpl() { m_parent = 0; hasInlinedDecl = false; strictParsing = true; }
+ StyleBaseImpl(StyleBaseImpl *p) { m_parent = p; hasInlinedDecl = false; strictParsing = true; }
virtual ~StyleBaseImpl() {}
- virtual bool deleteMe();
-
// returns the url of the style sheet this object belongs to
DOMString baseURL();
- StyleBaseImpl *parent() { return m_parent; }
-
virtual bool isStyleSheet() const { return false; }
virtual bool isCSSStyleSheet() const { return false; }
virtual bool isStyleSheetList() const { return false; }
@@ -177,7 +174,6 @@ public:
bool parseAuralValue(const QChar *curP, const QChar *endP, int propId);
CSSValueImpl* parseContent(const QChar *curP, const QChar *endP);
- QPtrList<QChar> splitContent(const QChar *curP, const QChar *endP);
// defines units allowed for a certain property, used in parseUnit
enum Units
@@ -210,12 +206,8 @@ public:
bool useStrictParsing() const { return strictParsing; }
protected:
- StyleBaseImpl *m_parent;
bool hasInlinedDecl : 1;
bool strictParsing : 1;
- private:
-// bool m_bImportant : 1;
-// bool m_bnonCSSHint : 1;
};
// a style class which has a list of children (StyleSheets for example)
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index d98a759..26ab2c0 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -63,6 +63,7 @@ using namespace DOM;
#include <assert.h>
#include <qpaintdevicemetrics.h>
#include <qintcache.h>
+#include <stdlib.h>
#ifdef APPLE_CHANGES
namespace khtml {
@@ -106,12 +107,12 @@ CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, S
userStyle = 0;
userSheet = 0;
paintDeviceMetrics = doc->paintDeviceMetrics();
-
+
if(paintDeviceMetrics) // this may be null, not everyone uses khtmlview (Niko)
computeFontSizes(paintDeviceMetrics, view ? view->part()->zoomFactor() : 100);
if ( !userStyleSheet.isEmpty() ) {
- userSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl *)0);
+ userSheet = new DOM::CSSStyleSheetImpl(doc);
userSheet->parseString( DOMString( userStyleSheet ) );
userStyle = new CSSStyleSelectorList();
@@ -168,6 +169,10 @@ void CSSStyleSelector::init()
element = 0;
settings = 0;
paintDeviceMetrics = 0;
+ propsToApply = (CSSOrderedProperty **)malloc(128*sizeof(CSSOrderedProperty *));
+ pseudoProps = (CSSOrderedProperty **)malloc(128*sizeof(CSSOrderedProperty *));
+ propsToApplySize = 128;
+ pseudoPropsSize = 128;
}
CSSStyleSelector::~CSSStyleSelector()
@@ -176,6 +181,8 @@ CSSStyleSelector::~CSSStyleSelector()
delete authorStyle;
delete userStyle;
delete userSheet;
+ free(propsToApply);
+ free(pseudoProps);
}
void CSSStyleSelector::addSheet( CSSStyleSheetImpl *sheet )
@@ -255,6 +262,27 @@ void CSSStyleSelector::computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics,
#undef MAXFONTSIZES
+static inline void bubbleSort( CSSOrderedProperty **b, CSSOrderedProperty **e )
+{
+ while( b < e ) {
+ bool swapped = FALSE;
+ CSSOrderedProperty **y = e+1;
+ CSSOrderedProperty **x = e;
+ CSSOrderedProperty **swappedPos;
+ do {
+ if ( !((**(--x)) < (**(--y))) ) {
+ swapped = TRUE;
+ swappedPos = x;
+ CSSOrderedProperty *tmp = *y;
+ *y = *x;
+ *x = tmp;
+ }
+ } while( x != b );
+ if ( !swapped ) break;
+ b = swappedPos + 1;
+ }
+}
+
RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
{
// set some variables we will need
@@ -271,8 +299,8 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
settings = part->settings();
paintDeviceMetrics = element->getDocument()->paintDeviceMetrics();
- CSSOrderedPropertyList *propsToApply = new CSSOrderedPropertyList;
- CSSOrderedPropertyList *pseudoProps = new CSSOrderedPropertyList;
+ unsigned int numPropsToApply = 0;
+ unsigned int numPseudoProps = 0;
// try to sort out most style rules as early as possible.
// ### implement CSS3 namespace support
@@ -292,12 +320,21 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
//qDebug("adding property" );
for ( unsigned int p = 0; p < selectorCache[i].props_size; p += 2 )
- for ( unsigned int j = 0; j < (unsigned int )selectorCache[i].props[p+1]; ++j )
- static_cast<QPtrList<CSSOrderedProperty>*>(propsToApply)->append( properties[selectorCache[i].props[p]+j] );
+ for ( unsigned int j = 0; j < (unsigned int )selectorCache[i].props[p+1]; ++j ) {
+ if (numPropsToApply >= propsToApplySize ) {
+ propsToApplySize *= 2;
+ propsToApply = (CSSOrderedProperty **)realloc( propsToApply, propsToApplySize*sizeof( CSSOrderedProperty * ) );
+ }
+ propsToApply[numPropsToApply++] = properties[selectorCache[i].props[p]+j];
+ }
} else if ( selectorCache[i].state == AppliesPseudo ) {
for ( unsigned int p = 0; p < selectorCache[i].props_size; p += 2 )
for ( unsigned int j = 0; j < (unsigned int) selectorCache[i].props[p+1]; ++j ) {
- static_cast<QPtrList<CSSOrderedProperty>*>(pseudoProps)->append( properties[selectorCache[i].props[p]+j] );
+ if (numPseudoProps >= pseudoPropsSize ) {
+ pseudoPropsSize *= 2;
+ pseudoProps = (CSSOrderedProperty **)realloc( pseudoProps, pseudoPropsSize*sizeof( CSSOrderedProperty * ) );
+ }
+ pseudoProps[numPseudoProps++] = properties[selectorCache[i].props[p]+j];
properties[selectorCache[i].props[p]+j]->pseudoId = (RenderStyle::PseudoId) selectors[i]->pseudoId;
}
}
@@ -306,6 +343,7 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
selectorCache[i].state = Invalid;
}
+
//qDebug( "styleForElement( %s )", e->tagName().string().latin1() );
//qDebug( "%d selectors, %d checked, %d match, %d properties ( of %d )",
//selectors_size, schecked, smatch, propsToApply->count(), properties_size );
@@ -313,10 +351,10 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
// inline style declarations, after all others. non css hints
// count as author rules, and come before all other style sheets, see hack in append()
if(e->m_styleDecls)
- addInlineDeclarations( e->m_styleDecls, propsToApply );
+ numPropsToApply = addInlineDeclarations( e->m_styleDecls, numPropsToApply );
- propsToApply->sort();
- pseudoProps->sort();
+ bubbleSort( propsToApply, propsToApply+numPropsToApply-1 );
+ bubbleSort( pseudoProps, pseudoProps+numPseudoProps-1 );
RenderStyle *style = new RenderStyle();
if( parentStyle )
@@ -331,29 +369,26 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
if ( part ) {
fontDirty = false;
- if (propsToApply->count()) {
+ if (numPropsToApply ) {
CSSStyleSelector::style = style;
- for (CSSOrderedProperty *ordprop = propsToApply->first();
- ordprop;
- ordprop = propsToApply->next()) {
- if ( fontDirty && ordprop->priority >= (1 << 30) ) {
+ for (unsigned int i = 0; i < numPropsToApply; ++i) {
+ if ( fontDirty && propsToApply[i]->priority >= (1 << 30) ) {
// we are past the font properties, time to update to the
// correct font
CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
fontDirty = false;
}
- applyRule( ordprop->prop );
+ applyRule( propsToApply[i]->prop );
}
if ( fontDirty )
CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
}
- if ( pseudoProps->count() != 0 ) {
+ if ( numPseudoProps ) {
fontDirty = false;
//qDebug("%d applying %d pseudo props", e->cssTagId(), pseudoProps->count() );
- CSSOrderedProperty *ordprop = pseudoProps->first();
- while( ordprop ) {
- if ( fontDirty && ordprop->priority >= (1 << 30) ) {
+ for (unsigned int i = 0; i < numPseudoProps; ++i) {
+ if ( fontDirty && pseudoProps[i]->priority >= (1 << 30) ) {
// we are past the font properties, time to update to the
// correct font
//We have to do this for all pseudo styles
@@ -366,21 +401,19 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
}
RenderStyle *pseudoStyle;
- pseudoStyle = style->getPseudoStyle(ordprop->pseudoId);
+ pseudoStyle = style->getPseudoStyle(pseudoProps[i]->pseudoId);
if (!pseudoStyle)
{
- pseudoStyle = style->addPseudoStyle(ordprop->pseudoId);
+ pseudoStyle = style->addPseudoStyle(pseudoProps[i]->pseudoId);
if (pseudoStyle)
pseudoStyle->inheritFrom( style );
}
CSSStyleSelector::style = pseudoStyle;
if ( pseudoStyle )
- applyRule( ordprop->prop );
-
-
- ordprop = pseudoProps->next();
+ applyRule( pseudoProps[i]->prop );
}
+
if ( fontDirty ) {
RenderStyle *pseudoStyle = style->pseudoStyle;
while ( pseudoStyle ) {
@@ -396,21 +429,22 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
if ( usedDynamicStates & StyleSelector::Active )
style->setHasActive();
- delete propsToApply;
- delete pseudoProps;
-
return style;
}
-void CSSStyleSelector::addInlineDeclarations(DOM::CSSStyleDeclarationImpl *decl,
- CSSOrderedPropertyList *list )
+unsigned int CSSStyleSelector::addInlineDeclarations(DOM::CSSStyleDeclarationImpl *decl,
+ unsigned int numProps )
{
QPtrList<CSSProperty> *values = decl->values();
- if(!values) return;
+ if(!values) return numProps;
int len = values->count();
if ( inlineProps.size() < (uint)len )
inlineProps.resize( len+1 );
+ if (numProps + len >= propsToApplySize ) {
+ propsToApplySize += propsToApplySize;
+ propsToApply = (CSSOrderedProperty **)realloc( propsToApply, propsToApplySize*sizeof( CSSOrderedProperty * ) );
+ }
CSSOrderedProperty *array = (CSSOrderedProperty *)inlineProps.data();
for(int i = 0; i < len; i++)
@@ -432,6 +466,7 @@ void CSSStyleSelector::addInlineDeclarations(DOM::CSSStyleDeclarationImpl *decl,
case CSS_PROP_FONT:
case CSS_PROP_COLOR:
case CSS_PROP_BACKGROUND_IMAGE:
+ case CSS_PROP_DISPLAY:
// these have to be applied first, because other properties use the computed
// values of these porperties.
first = true;
@@ -446,9 +481,9 @@ void CSSStyleSelector::addInlineDeclarations(DOM::CSSStyleDeclarationImpl *decl,
array->selector = 0;
array->position = i;
array->priority = (!first << 30) | (source << 24);
- static_cast<QPtrList<CSSOrderedProperty>*>(list)->append( array );
- array++;
+ propsToApply[numProps++] = array++;
}
+ return numProps;
}
static bool subject;
@@ -1043,6 +1078,7 @@ void CSSOrderedPropertyList::append(DOM::CSSStyleDeclarationImpl *decl, uint sel
case CSS_PROP_FONT:
case CSS_PROP_COLOR:
case CSS_PROP_BACKGROUND_IMAGE:
+ case CSS_PROP_DISPLAY:
// these have to be applied first, because other properties use the computed
// values of these porperties.
first = true;
@@ -1173,31 +1209,34 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
case CSS_PROP_BORDER_LEFT_STYLE:
case CSS_PROP_OUTLINE_STYLE:
{
+ EBorderStyle s;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
switch(prop->m_id)
{
case CSS_PROP_BORDER_TOP_STYLE:
- style->setBorderTopStyle(parentStyle->borderTopStyle());
- return;
+ s = parentStyle->borderTopStyle();
+ break;
case CSS_PROP_BORDER_RIGHT_STYLE:
- style->setBorderRightStyle(parentStyle->borderRightStyle());
- return;
+ s = parentStyle->borderRightStyle();
+ break;
case CSS_PROP_BORDER_BOTTOM_STYLE:
- style->setBorderBottomStyle(parentStyle->borderBottomStyle());
- return;
+ s = parentStyle->borderBottomStyle();
+ break;
case CSS_PROP_BORDER_LEFT_STYLE:
- style->setBorderLeftStyle(parentStyle->borderLeftStyle());
- return;
+ s = parentStyle->borderLeftStyle();
+ break;
case CSS_PROP_OUTLINE_STYLE:
- style->setOutlineStyle(parentStyle->outlineStyle());
+ s = parentStyle->outlineStyle();
+ break;
+ default:
return;
- }
}
- if(!primitiveValue) return;
- EBorderStyle s = (EBorderStyle) (primitiveValue->getIdent() - CSS_VAL_NONE);
-
+ } else {
+ if(!primitiveValue) return;
+ s = (EBorderStyle) (primitiveValue->getIdent() - CSS_VAL_NONE);
+ }
switch(prop->m_id)
{
case CSS_PROP_BORDER_TOP_STYLE:
@@ -1668,11 +1707,12 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
if(value->cssValueType() == CSSValue::CSS_INHERIT) {
if(!parentNode) return;
style->setCursor(parentStyle->cursor());
+ style->setCursorImage(parentStyle->cursorImage());
return;
} else if(primitiveValue) {
if(primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) {
CSSImageValueImpl *image = static_cast<CSSImageValueImpl *>(primitiveValue);
- kdDebug( 6080 ) << "setting cursor image to " << image->cssText().string() << endl;
+ //kdDebug( 6080 ) << "setting cursor image to " << image->cssText().string() << endl;
style->setCursorImage(image->image());
} else {
style->setCursor( (ECursor) (primitiveValue->getIdent() - CSS_VAL_AUTO) );
@@ -1711,30 +1751,29 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
switch(prop->m_id)
{
case CSS_PROP_BACKGROUND_COLOR:
- style->setBackgroundColor(parentStyle->backgroundColor()); break;
+ col = parentStyle->backgroundColor(); break;
case CSS_PROP_BORDER_TOP_COLOR:
- style->setBorderTopColor(parentStyle->borderTopColor()); break;
+ col = parentStyle->borderTopColor(); break;
case CSS_PROP_BORDER_RIGHT_COLOR:
- style->setBorderRightColor(parentStyle->borderRightColor()); break;
+ col = parentStyle->borderRightColor(); break;
case CSS_PROP_BORDER_BOTTOM_COLOR:
- style->setBorderBottomColor(parentStyle->borderBottomColor()); break;
+ col = parentStyle->borderBottomColor(); break;
case CSS_PROP_BORDER_LEFT_COLOR:
- style->setBorderLeftColor(parentStyle->borderLeftColor()); break;
+ col = parentStyle->borderLeftColor(); break;
case CSS_PROP_COLOR:
- style->setColor(parentStyle->color()); break;
+ col = parentStyle->color(); break;
case CSS_PROP_OUTLINE_COLOR:
- style->setOutlineColor(parentStyle->outlineColor()); break;
+ col = parentStyle->outlineColor(); break;
default:
- // ###
- break;
- }
return;
}
+ } else {
if(!primitiveValue) return;
if(primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR)
col = primitiveValue->getRGBColorValue()->color();
else
return;
+ }
//kdDebug( 6080 ) << "applying color " << col.isValid() << endl;
switch(prop->m_id)
{
@@ -1793,15 +1832,16 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
// uri || inherit
case CSS_PROP_BACKGROUND_IMAGE:
{
+ khtml::CachedImage *image = 0;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
- style->setBackgroundImage(parentStyle->backgroundImage());
- break;
- }
+ image = parentStyle->backgroundImage();
+ } else {
if(!primitiveValue) return;
- CSSImageValueImpl *image = static_cast<CSSImageValueImpl *>(primitiveValue);
- style->setBackgroundImage(image->image());
+ image = static_cast<CSSImageValueImpl *>(primitiveValue)->image();
+ }
+ style->setBackgroundImage(image);
//kdDebug( 6080 ) << "setting image in style to " << image->image() << endl;
break;
}
@@ -1810,16 +1850,17 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
// break;
case CSS_PROP_LIST_STYLE_IMAGE:
{
+ khtml::CachedImage *image = 0;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
- style->setListStyleImage(parentStyle->listStyleImage());
- break;
- }
+ image = parentStyle->listStyleImage();
+ } else {
if(!primitiveValue) return;
- CSSImageValueImpl *image = static_cast<CSSImageValueImpl *>(primitiveValue);
- style->setListStyleImage(image->image());
- kdDebug( 6080 ) << "setting image in list to " << image->image() << endl;
+ image = static_cast<CSSImageValueImpl *>(primitiveValue)->image();
+ }
+ style->setListStyleImage(image);
+ //kdDebug( 6080 ) << "setting image in list to " << image->image() << endl;
break;
}
@@ -1830,28 +1871,27 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
case CSS_PROP_BORDER_LEFT_WIDTH:
case CSS_PROP_OUTLINE_WIDTH:
{
+ short width = 3;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
switch(prop->m_id)
{
case CSS_PROP_BORDER_TOP_WIDTH:
- style->setBorderTopWidth(parentStyle->borderTopWidth()); break;
+ width = parentStyle->borderTopWidth(); break;
case CSS_PROP_BORDER_RIGHT_WIDTH:
- style->setBorderRightWidth(parentStyle->borderRightWidth()); break;
+ width = parentStyle->borderRightWidth(); break;
case CSS_PROP_BORDER_BOTTOM_WIDTH:
- style->setBorderBottomWidth(parentStyle->borderBottomWidth()); break;
+ width = parentStyle->borderBottomWidth(); break;
case CSS_PROP_BORDER_LEFT_WIDTH:
- style->setBorderLeftWidth(parentStyle->borderLeftWidth()); break;
+ width = parentStyle->borderLeftWidth(); break;
case CSS_PROP_OUTLINE_WIDTH:
- style->setOutlineWidth(parentStyle->outlineWidth()); break;
+ width = parentStyle->outlineWidth(); break;
default:
- // ###
- break;
- }
return;
}
+ return;
+ } else {
if(!primitiveValue) break;
- short width = 3; // medium is default value
switch(primitiveValue->getIdent())
{
case CSS_VAL_THIN:
@@ -1869,6 +1909,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
default:
return;
}
+ }
if(width < 0) return;
switch(prop->m_id)
{
@@ -1897,6 +1938,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
case CSS_PROP_LETTER_SPACING:
case CSS_PROP_WORD_SPACING:
{
+ int width = 0;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
@@ -1904,21 +1946,18 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
{
case CSS_PROP_MARKER_OFFSET:
// ###
- break;
+ return;
case CSS_PROP_LETTER_SPACING:
- style->setLetterSpacing(parentStyle->letterSpacing()); break;
+ width = parentStyle->letterSpacing(); break;
case CSS_PROP_WORD_SPACING:
- style->setWordSpacing(parentStyle->wordSpacing()); break;
+ width = parentStyle->wordSpacing(); break;
default:
- // ###
- break;
+ return;
}
- return;
- }
- if(!primitiveValue) return;
- int width = primitiveValue->computeLength(style, paintDeviceMetrics);
-// reason : letter or word spacing may be negative.
-// if( width < 0 ) return;
+ } else {
+ if(!primitiveValue) return;
+ width = primitiveValue->computeLength(style, paintDeviceMetrics);
+ }
switch(prop->m_id)
{
case CSS_PROP_LETTER_SPACING:
@@ -1929,9 +1968,9 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
break;
// ### needs the definitions in renderstyle
case CSS_PROP_MARKER_OFFSET:
- default:
- return;
+ default: break;
}
+ return;
}
// length, percent
@@ -1948,7 +1987,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
primitiveValue->getIdent() == CSS_VAL_STATIC_POSITION)
{
//kdDebug( 6080 ) << "found value=static-position" << endl;
- l = Length ( 0, Static);
+ l = Length ( 0, Static );
apply = true;
}
case CSS_PROP_BOTTOM:
@@ -1974,40 +2013,41 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
{
if(value->cssValueType() == CSSValue::CSS_INHERIT) {
if(!parentNode) return;
+ apply = true;
switch(prop->m_id)
{
case CSS_PROP_MAX_WIDTH:
- style->setMaxWidth(parentStyle->maxWidth()); break;
+ l = parentStyle->maxWidth(); break;
case CSS_PROP_BOTTOM:
- style->setBottom(parentStyle->bottom()); break;
+ l = parentStyle->bottom(); break;
case CSS_PROP_TOP:
- style->setTop(parentStyle->top()); break;
+ l = parentStyle->top(); break;
case CSS_PROP_LEFT:
- style->setLeft(parentStyle->left()); break;
+ l = parentStyle->left(); break;
case CSS_PROP_RIGHT:
- style->setRight(parentStyle->right()); break;
+ l = parentStyle->right(); break;
case CSS_PROP_WIDTH:
- style->setWidth(parentStyle->width()); break;
+ l = parentStyle->width(); break;
case CSS_PROP_MIN_WIDTH:
- style->setMinWidth(parentStyle->minWidth()); break;
+ l = parentStyle->minWidth(); break;
case CSS_PROP_PADDING_TOP:
- style->setPaddingTop(parentStyle->paddingTop()); break;
+ l = parentStyle->paddingTop(); break;
case CSS_PROP_PADDING_RIGHT:
- style->setPaddingRight(parentStyle->paddingRight()); break;
+ l = parentStyle->paddingRight(); break;
case CSS_PROP_PADDING_BOTTOM:
- style->setPaddingBottom(parentStyle->paddingBottom()); break;
+ l = parentStyle->paddingBottom(); break;
case CSS_PROP_PADDING_LEFT:
- style->setPaddingLeft(parentStyle->paddingLeft()); break;
+ l = parentStyle->paddingLeft(); break;
case CSS_PROP_MARGIN_TOP:
- style->setMarginTop(parentStyle->marginTop()); break;
+ l = parentStyle->marginTop(); break;
case CSS_PROP_MARGIN_RIGHT:
- style->setMarginRight(parentStyle->marginRight()); break;
+ l = parentStyle->marginRight(); break;
case CSS_PROP_MARGIN_BOTTOM:
- style->setMarginBottom(parentStyle->marginBottom()); break;
+ l = parentStyle->marginBottom(); break;
case CSS_PROP_MARGIN_LEFT:
- style->setMarginLeft(parentStyle->marginLeft()); break;
+ l = parentStyle->marginLeft(); break;
case CSS_PROP_TEXT_INDENT:
- style->setTextIndent(parentStyle->textIndent()); break;
+ l = parentStyle->textIndent(); break;
default:
return;
}
@@ -2056,9 +2096,9 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
style->setMarginLeft(l); break;
case CSS_PROP_TEXT_INDENT:
style->setTextIndent(l); break;
- default:
- return;
+ default: break;
}
+ return;
}
case CSS_PROP_MAX_HEIGHT:
@@ -2074,14 +2114,15 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
+ apply = true;
switch(prop->m_id)
{
case CSS_PROP_MAX_HEIGHT:
- style->setMaxHeight(parentStyle->maxHeight()); break;
+ l = parentStyle->maxHeight(); break;
case CSS_PROP_HEIGHT:
- style->setHeight(parentStyle->height()); break;
+ l = parentStyle->height(); break;
case CSS_PROP_MIN_HEIGHT:
- style->setMinHeight(parentStyle->minHeight()); break;
+ l = parentStyle->minHeight(); break;
default:
return;
}
@@ -2249,41 +2290,43 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
break;
case CSS_PROP_Z_INDEX:
{
+ int z_index = 0;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
+ {
if(!parentNode) return;
- style->setZIndex(parentStyle->zIndex());
- return;
- }
- if(!primitiveValue ||
- primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
- return;
- style->setZIndex((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
+ z_index = parentStyle->zIndex();
+ } else {
+ if(!primitiveValue ||
+ primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
+ return;
+ z_index = (int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+ }
+ style->setZIndex( z_index );
return;
}
// length, percent, number
case CSS_PROP_LINE_HEIGHT:
{
+ Length lineHeight;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
- style->setLineHeight(parentStyle->lineHeight());
- return;
- }
- Length lineHeight;
- if(!primitiveValue) return;
- int type = primitiveValue->primitiveType();
- if(primitiveValue->getIdent() == CSS_VAL_NORMAL)
- lineHeight = Length( -100, Percent );
- else if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
- lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
- else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
- lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
- else if(type == CSSPrimitiveValue::CSS_NUMBER)
- lineHeight = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
- else
- return;
+ lineHeight = parentStyle->lineHeight();
+ } else {
+ if(!primitiveValue) return;
+ int type = primitiveValue->primitiveType();
+ if(primitiveValue->getIdent() == CSS_VAL_NORMAL)
+ lineHeight = Length( -100, Percent );
+ else if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+ lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
+ else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+ lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
+ else if(type == CSSPrimitiveValue::CSS_NUMBER)
+ lineHeight = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
+ else
+ return;
+ }
style->setLineHeight(lineHeight);
return;
}
@@ -2341,11 +2384,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
// qDebug("setting clip right to %d", right.value );
// qDebug("setting clip bottom to %d", bottom.value );
// qDebug("setting clip left to %d", left.value );
- style->setClipTop( top );
- style->setClipRight( right );
- style->setClipBottom( bottom );
- style->setClipLeft( left );
-
+ style->setClip( top, right, bottom, left );
style->setJsClipMode( (!strictParsing && prop->m_id == CSS_PROP__KONQ_JS_CLIP) ? true : false );
// rect, ident
@@ -2430,7 +2469,11 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
fontDirty = true;
}
return;
+#ifdef APPLE_CHANGES
+ } // make prepare-ChangeLog happy
+#else
}
+#endif
}
break;
}
@@ -2586,7 +2629,6 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
style->setPaddingRight(parentStyle->paddingRight());
return;
-
// case CSS_PROP_CUE:
case CSS_PROP_FONT:
case CSS_PROP_LIST_STYLE:
diff --git a/WebCore/khtml/css/cssstyleselector.h b/WebCore/khtml/css/cssstyleselector.h
index fc8918a..e62c306 100644
--- a/WebCore/khtml/css/cssstyleselector.h
+++ b/WebCore/khtml/css/cssstyleselector.h
@@ -79,9 +79,12 @@ namespace khtml
{
public:
StyleSelector() {};
- virtual ~StyleSelector() {};
- virtual RenderStyle *styleForElement(DOM::ElementImpl *e, int = None) = 0;
+ /* as noone has implemented a second style selector up to now comment out
+ the virtual methods until then, so the class has no vptr.
+ */
+// virtual ~StyleSelector() {};
+// virtual RenderStyle *styleForElement(DOM::ElementImpl *e, int = None) = 0;
enum State {
None = 0x00,
@@ -113,14 +116,14 @@ namespace khtml
*/
CSSStyleSelector( DOM::CSSStyleSheetImpl *sheet );
- virtual ~CSSStyleSelector();
+ ~CSSStyleSelector();
void addSheet( DOM::CSSStyleSheetImpl *sheet );
static void loadDefaultStyle(const KHTMLSettings *s = 0);
static void clear();
- virtual RenderStyle *styleForElement(DOM::ElementImpl *e, int state = None );
+ RenderStyle *styleForElement(DOM::ElementImpl *e, int state = None );
QValueList<int> fontSizes() const { return m_fontSizes; }
@@ -144,8 +147,8 @@ namespace khtml
void buildLists();
void clearLists();
- void addInlineDeclarations(DOM::CSSStyleDeclarationImpl *decl,
- CSSOrderedPropertyList *list );
+ unsigned int addInlineDeclarations(DOM::CSSStyleDeclarationImpl *decl,
+ unsigned int numProps );
static DOM::CSSStyleSheetImpl *defaultSheet;
static CSSStyleSelectorList *defaultStyle;
@@ -191,6 +194,10 @@ namespace khtml
CSSOrderedProperty **properties;
QMemArray<CSSOrderedProperty> inlineProps;
QString m_medium;
+ CSSOrderedProperty **propsToApply;
+ CSSOrderedProperty **pseudoProps;
+ unsigned int propsToApplySize;
+ unsigned int pseudoPropsSize;
int dynamicState;
@@ -233,6 +240,13 @@ namespace khtml
priority = (!first << 30) | (source << 24) | specificity;
}
+ bool operator < ( const CSSOrderedProperty &other ) const {
+ if (priority < other.priority) return true;
+ if (priority > other.priority) return false;
+ if (position < other.position) return true;
+ return false;
+ }
+
DOM::CSSProperty *prop;
RenderStyle::PseudoId pseudoId;
unsigned int selector;
diff --git a/WebCore/khtml/css/html4.css b/WebCore/khtml/css/html4.css
index 914ff5b..ef94145 100644
--- a/WebCore/khtml/css/html4.css
+++ b/WebCore/khtml/css/html4.css
@@ -391,7 +391,6 @@ INPUT[type="text"],
INPUT[type="password"],
TEXTAREA {
font-family: monospace;
- cursor: text;
}
INPUT[type="hidden"] {
diff --git a/WebCore/khtml/dom/css_rule.cpp b/WebCore/khtml/dom/css_rule.cpp
index dbe02fc..367730a 100644
--- a/WebCore/khtml/dom/css_rule.cpp
+++ b/WebCore/khtml/dom/css_rule.cpp
@@ -43,9 +43,11 @@ CSSRule::CSSRule(CSSRuleImpl *i)
CSSRule &CSSRule::operator = (const CSSRule &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -94,6 +96,14 @@ bool CSSRule::isNull() const
return (impl == 0);
}
+void CSSRule::assignOther( const CSSRule &other, RuleType thisType )
+{
+ if (other.type() != thisType ) {
+ if ( impl ) impl->deref();
+ impl = 0;
+ } else
+ CSSRule::operator = ( other );
+}
// ----------------------------------------------------------
@@ -125,13 +135,7 @@ CSSCharsetRule &CSSCharsetRule::operator = (const CSSCharsetRule &other)
CSSCharsetRule &CSSCharsetRule::operator = (const CSSRule &other)
{
- if (impl) impl->deref();
- if (other.type() != CSSRule::CHARSET_RULE) {
- impl = 0;
- return *this;
- }
- impl = other.handle();
- if (impl) impl->ref();
+ assignOther( other, CSSRule::CHARSET_RULE);
return *this;
}
@@ -180,13 +184,7 @@ CSSFontFaceRule &CSSFontFaceRule::operator = (const CSSFontFaceRule &other)
CSSFontFaceRule &CSSFontFaceRule::operator = (const CSSRule &other)
{
- if (impl) impl->deref();
- if (other.type() != CSSRule::FONT_FACE_RULE) {
- impl = 0;
- return *this;
- }
- impl = other.handle();
- if (impl) impl->ref();
+ assignOther( other, CSSRule::FONT_FACE_RULE );
return *this;
}
@@ -230,13 +228,7 @@ CSSImportRule &CSSImportRule::operator = (const CSSImportRule &other)
CSSImportRule &CSSImportRule::operator = (const CSSRule &other)
{
- if (impl) impl->deref();
- if (other.type() != CSSRule::IMPORT_RULE) {
- impl = 0;
- return *this;
- }
- impl = other.handle();
- if (impl) impl->ref();
+ assignOther( other, CSSRule::IMPORT_RULE );
return *this;
}
@@ -292,13 +284,7 @@ CSSMediaRule &CSSMediaRule::operator = (const CSSMediaRule &other)
CSSMediaRule &CSSMediaRule::operator = (const CSSRule &other)
{
- if (impl) impl->deref();
- if (other.type() != CSSRule::MEDIA_RULE) {
- impl = 0;
- return *this;
- }
- impl = other.handle();
- if (impl) impl->ref();
+ assignOther( other, CSSRule::MEDIA_RULE );
return *this;
}
@@ -360,13 +346,7 @@ CSSPageRule &CSSPageRule::operator = (const CSSPageRule &other)
CSSPageRule &CSSPageRule::operator = (const CSSRule &other)
{
- if (impl) impl->deref();
- if (other.type() != CSSRule::PAGE_RULE) {
- impl = 0;
- return *this;
- }
- impl = other.handle();
- if (impl) impl->ref();
+ assignOther( other, CSSRule::PAGE_RULE );
return *this;
}
@@ -423,13 +403,7 @@ CSSStyleRule &CSSStyleRule::operator = (const CSSStyleRule &other)
CSSStyleRule &CSSStyleRule::operator = (const CSSRule &other)
{
- if (impl) impl->deref();
- if (other.type() != CSSRule::STYLE_RULE) {
- impl = 0;
- return *this;
- }
- impl = other.handle();
- if (impl) impl->ref();
+ assignOther( other, CSSRule::STYLE_RULE );
return *this;
}
@@ -486,13 +460,7 @@ CSSUnknownRule &CSSUnknownRule::operator = (const CSSUnknownRule &other)
CSSUnknownRule &CSSUnknownRule::operator = (const CSSRule &other)
{
- if (impl) impl->deref();
- if (other.type() != CSSRule::UNKNOWN_RULE) {
- impl = 0;
- return *this;
- }
- impl = other.handle();
- if (impl) impl->ref();
+ assignOther( other, CSSRule::UNKNOWN_RULE );
return *this;
}
@@ -537,9 +505,11 @@ CSSRuleList::CSSRuleList(StyleListImpl *lst)
CSSRuleList &CSSRuleList::operator = (const CSSRuleList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/css_rule.h b/WebCore/khtml/dom/css_rule.h
index f35fb3f..d550240 100644
--- a/WebCore/khtml/dom/css_rule.h
+++ b/WebCore/khtml/dom/css_rule.h
@@ -133,6 +133,8 @@ public:
protected:
CSSRuleImpl *impl;
+
+ void assignOther( const CSSRule &other, RuleType thisType );
};
class CSSCharsetRuleImpl;
diff --git a/WebCore/khtml/dom/css_stylesheet.cpp b/WebCore/khtml/dom/css_stylesheet.cpp
index a5c636b..48d7a9b 100644
--- a/WebCore/khtml/dom/css_stylesheet.cpp
+++ b/WebCore/khtml/dom/css_stylesheet.cpp
@@ -53,9 +53,11 @@ StyleSheet::StyleSheet(StyleSheetImpl *i)
StyleSheet &StyleSheet::operator = (const StyleSheet &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -157,9 +159,9 @@ CSSStyleSheet &CSSStyleSheet::operator = (const StyleSheet &other)
{
if(impl) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
StyleSheet::operator = (other);
+ }
return *this;
}
@@ -223,9 +225,11 @@ StyleSheetList::StyleSheetList(StyleSheetListImpl *i)
StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -277,9 +281,11 @@ MediaList::MediaList(MediaListImpl *i)
MediaList &MediaList::operator = (const MediaList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -349,9 +355,11 @@ LinkStyle::LinkStyle(const LinkStyle &other)
LinkStyle & LinkStyle::operator = (const LinkStyle &other)
{
+ if ( node != other.node ) {
if(node) node->deref();
node = other.node;
if(node) node->ref();
+ }
return *this;
}
@@ -361,15 +369,13 @@ LinkStyle & LinkStyle::operator = (const Node &other)
node = 0;
// ### add processing instructions
NodeImpl *n = other.handle();
- if(!n || !n->isElementNode()) return *this;
// ### check link is really linking a style sheet
- if(n->id() != ID_STYLE || n->id() != ID_LINK)
- return *this;
-
+ if( n && n->isElementNode() &&
+ (n->id() == ID_STYLE || n->id() == ID_LINK) ) {
node = n;
if(node) node->ref();
-
+ }
return *this;
}
@@ -380,14 +386,14 @@ LinkStyle::~LinkStyle()
StyleSheet LinkStyle::sheet()
{
- if(!node) return StyleSheet();
-
- if(node->id() == ID_STYLE)
- return static_cast<HTMLStyleElementImpl *>(node)->sheet();
- else if(node->id() == ID_LINK)
- return static_cast<HTMLLinkElementImpl *>(node)->sheet();
+ int id = node ? node->id() : 0;
// ### add PI
- return StyleSheet();
+ return
+ ( id == ID_STYLE) ?
+ static_cast<HTMLStyleElementImpl *>(node)->sheet()
+ : ( (id == ID_LINK) ?
+ static_cast<HTMLLinkElementImpl *>(node)->sheet()
+ : StyleSheet() );
}
bool LinkStyle::isNull() const
@@ -411,17 +417,22 @@ DocumentStyle::DocumentStyle(const DocumentStyle &other)
DocumentStyle & DocumentStyle::operator = (const DocumentStyle &other)
{
+ if ( doc != other.doc ) {
if(doc) doc->deref();
doc = other.doc;
if(doc) doc->ref();
+ }
return *this;
}
DocumentStyle & DocumentStyle::operator = (const Document &other)
{
+ DocumentImpl *odoc = static_cast<DocumentImpl *>(other.handle());
+ if ( doc != odoc ) {
if(doc) doc->deref();
- doc = static_cast<DocumentImpl *>(other.handle());
+ doc = odoc;
if(doc) doc->ref();
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/css_stylesheet.h b/WebCore/khtml/dom/css_stylesheet.h
index f314a4e..25f731c 100644
--- a/WebCore/khtml/dom/css_stylesheet.h
+++ b/WebCore/khtml/dom/css_stylesheet.h
@@ -29,6 +29,8 @@
#include <dom/dom_string.h>
#include <dom/dom_node.h>
+#include <dom/dom_misc.h>
+
namespace DOM {
diff --git a/WebCore/khtml/dom/css_value.cpp b/WebCore/khtml/dom/css_value.cpp
index fa6e79f..d8d0085 100644
--- a/WebCore/khtml/dom/css_value.cpp
+++ b/WebCore/khtml/dom/css_value.cpp
@@ -49,9 +49,11 @@ CSSStyleDeclaration::CSSStyleDeclaration(CSSStyleDeclarationImpl *i)
CSSStyleDeclaration &CSSStyleDeclaration::operator = (const CSSStyleDeclaration &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -165,9 +167,11 @@ CSSValue::CSSValue(CSSValueImpl *i)
CSSValue &CSSValue::operator = (const CSSValue &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -238,21 +242,26 @@ CSSValueList::CSSValueList(CSSValueListImpl *impl) : CSSValue(impl)
CSSValueList &CSSValueList::operator = (const CSSValueList &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.handle();
if (impl) impl->ref();
+ }
return *this;
}
CSSValueList &CSSValueList::operator = (const CSSValue &other)
{
+ CSSValueImpl *ohandle = other.handle() ;
+ if ( impl != ohandle ) {
if (impl) impl->deref();
if (!other.isNull() && !other.isCSSValueList()) {
impl = 0;
- return *this;
- }
- impl = other.handle();
+ } else {
+ impl = ohandle;
if (impl) impl->ref();
+ }
+ }
return *this;
}
@@ -280,9 +289,6 @@ CSSPrimitiveValue::CSSPrimitiveValue() : CSSValue()
CSSPrimitiveValue::CSSPrimitiveValue(const CSSPrimitiveValue &other) : CSSValue(other)
{
- if (impl) impl->deref();
- impl = other.handle();
- if (impl) impl->ref();
}
CSSPrimitiveValue::CSSPrimitiveValue(const CSSValue &other) : CSSValue(other)
@@ -297,21 +303,26 @@ CSSPrimitiveValue::CSSPrimitiveValue(CSSPrimitiveValueImpl *impl) : CSSValue(imp
CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSPrimitiveValue &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.handle();
if (impl) impl->ref();
+ }
return *this;
}
CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSValue &other)
{
+ CSSValueImpl *ohandle = other.handle();
+ if ( impl != ohandle ) {
if (impl) impl->deref();
if (!other.isNull() && !other.isCSSPrimitiveValue()) {
impl = 0;
- return *this;
- }
- impl = other.handle();
+ } else {
+ impl = ohandle;
if (impl) impl->ref();
+ }
+ }
return *this;
}
@@ -396,9 +407,11 @@ Counter::Counter(const Counter &/*other*/)
Counter &Counter::operator = (const Counter &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
+ }
return *this;
}
@@ -504,9 +517,11 @@ Rect::Rect(RectImpl *i)
Rect &Rect::operator = (const Rect &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/dom2_events.cpp b/WebCore/khtml/dom/dom2_events.cpp
index f56b003..5c71fa8 100644
--- a/WebCore/khtml/dom/dom2_events.cpp
+++ b/WebCore/khtml/dom/dom2_events.cpp
@@ -70,10 +70,11 @@ Event::~Event()
Event &Event::operator = (const Event &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
-
+ }
return *this;
}
@@ -177,6 +178,8 @@ DOMString Event::eventModuleName()
// -----------------------------------------------------------------------------
+#ifndef SAVE_SPACE
+
EventException::EventException(unsigned short _code)
{
code = _code;
@@ -193,6 +196,8 @@ EventException & EventException::operator = (const EventException &other)
return *this;
}
+#endif
+
// -----------------------------------------------------------------------------
UIEvent::UIEvent() : Event()
@@ -222,9 +227,10 @@ UIEvent &UIEvent::operator = (const Event &other)
{
Event e;
e = other;
- if (!e.isNull() && !e.handle()->isUIEvent())
+ if (!e.isNull() && !e.handle()->isUIEvent()) {
+ if ( impl ) impl->deref();
impl = 0;
- else
+ } else
Event::operator = (other);
return *this;
}
@@ -291,9 +297,10 @@ MouseEvent &MouseEvent::operator = (const Event &other)
{
Event e;
e = other;
- if (!e.isNull() && !e.handle()->isMouseEvent())
+ if (!e.isNull() && !e.handle()->isMouseEvent()) {
+ if ( impl ) impl->deref();
impl = 0;
- else
+ } else
UIEvent::operator = (other);
return *this;
}
@@ -438,9 +445,10 @@ MutationEvent &MutationEvent::operator = (const Event &other)
{
Event e;
e = other;
- if (!e.isNull() && !e.handle()->isMutationEvent())
+ if (!e.isNull() && !e.handle()->isMutationEvent()) {
+ if ( impl ) impl->deref();
impl = 0;
- else
+ } else
Event::operator = (other);
return *this;
}
diff --git a/WebCore/khtml/dom/dom2_range.cpp b/WebCore/khtml/dom/dom2_range.cpp
index b7a2a67..50b7979 100644
--- a/WebCore/khtml/dom/dom2_range.cpp
+++ b/WebCore/khtml/dom/dom2_range.cpp
@@ -74,10 +74,11 @@ Range::Range(RangeImpl *i)
Range &Range::operator = (const Range &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
-
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/dom2_range.h b/WebCore/khtml/dom/dom2_range.h
index b263241..ef4c13f 100644
--- a/WebCore/khtml/dom/dom2_range.h
+++ b/WebCore/khtml/dom/dom2_range.h
@@ -31,6 +31,7 @@
#define _dom2_range_h_
#include <dom/dom_doc.h>
+#include <dom/dom_misc.h>
namespace DOM {
diff --git a/WebCore/khtml/dom/dom2_views.cpp b/WebCore/khtml/dom/dom2_views.cpp
index 2a8b77a..19f4cce 100644
--- a/WebCore/khtml/dom/dom2_views.cpp
+++ b/WebCore/khtml/dom/dom2_views.cpp
@@ -56,10 +56,11 @@ AbstractView::~AbstractView()
AbstractView &AbstractView::operator = (const AbstractView &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
-
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/dom_doc.cpp b/WebCore/khtml/dom/dom_doc.cpp
index 25aebc9..d9e265d 100644
--- a/WebCore/khtml/dom/dom_doc.cpp
+++ b/WebCore/khtml/dom/dom_doc.cpp
@@ -58,10 +58,11 @@ DOMImplementation::DOMImplementation(DOMImplementationImpl *i)
DOMImplementation &DOMImplementation::operator = (const DOMImplementation &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
-
+ }
return *this;
}
@@ -187,11 +188,14 @@ Document::Document(DocumentImpl *i) : Node(i)
Document &Document::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != DOCUMENT_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -434,11 +438,14 @@ DocumentFragment::DocumentFragment(const DocumentFragment &other) : Node(other)
DocumentFragment &DocumentFragment::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != DOCUMENT_FRAGMENT_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -475,12 +482,14 @@ DocumentType::DocumentType(DocumentTypeImpl *impl) : Node(impl)
DocumentType &DocumentType::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != DOCUMENT_TYPE_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
-
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/dom_element.cpp b/WebCore/khtml/dom/dom_element.cpp
index dfc18e9..2c1eef0 100644
--- a/WebCore/khtml/dom/dom_element.cpp
+++ b/WebCore/khtml/dom/dom_element.cpp
@@ -43,11 +43,13 @@ Attr::Attr( AttrImpl *_impl )
Attr &Attr::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || !ohandle->isAttributeNode()) {
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -115,11 +117,13 @@ Element::Element(ElementImpl *impl) : Node(impl)
Element &Element::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || !ohandle->isElementNode()) {
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/dom_exception.h b/WebCore/khtml/dom/dom_exception.h
index cd2d0b5..f86e576 100644
--- a/WebCore/khtml/dom/dom_exception.h
+++ b/WebCore/khtml/dom/dom_exception.h
@@ -29,6 +29,8 @@
#ifndef _DOM_DOMException_h_
#define _DOM_DOMException_h_
+#include <dom/dom_misc.h>
+
namespace DOM {
diff --git a/WebCore/khtml/dom/dom_node.cpp b/WebCore/khtml/dom/dom_node.cpp
index 0af53c4..9451db4 100644
--- a/WebCore/khtml/dom/dom_node.cpp
+++ b/WebCore/khtml/dom/dom_node.cpp
@@ -50,10 +50,11 @@ NamedNodeMap::NamedNodeMap(NamedNodeMapImpl *i)
NamedNodeMap &NamedNodeMap::operator = (const NamedNodeMap &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
-
+ }
return *this;
}
@@ -146,10 +147,11 @@ Node::Node( NodeImpl *i )
Node &Node::operator = (const Node &other)
{
- if(impl == other.impl) return *this;
+ if(impl != other.impl) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -448,9 +450,11 @@ NodeList::NodeList(const NodeListImpl *i)
NodeList &NodeList::operator = (const NodeList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/dom_string.cpp b/WebCore/khtml/dom/dom_string.cpp
index 7512035..6c542fb 100644
--- a/WebCore/khtml/dom/dom_string.cpp
+++ b/WebCore/khtml/dom/dom_string.cpp
@@ -78,9 +78,11 @@ DOMString::~DOMString()
DOMString &DOMString::operator =(const DOMString &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
@@ -203,7 +205,7 @@ QChar *DOMString::unicode() const
QString DOMString::string() const
{
- if(!impl) return QConstString(0, 0).string();
+ if(!impl) return QString::null;
return QConstString(impl->s, impl->l).string();
}
@@ -256,8 +258,7 @@ bool DOM::strcasecmp( const DOMString &as, const char* bs )
bool DOMString::isEmpty() const
{
- if (impl == 0) return true;
- return (impl->l == 0);
+ return (!impl || impl->l == 0);
}
//-----------------------------------------------------------------------------
diff --git a/WebCore/khtml/dom/dom_text.cpp b/WebCore/khtml/dom/dom_text.cpp
index d5354fc..28f3358 100644
--- a/WebCore/khtml/dom/dom_text.cpp
+++ b/WebCore/khtml/dom/dom_text.cpp
@@ -40,14 +40,17 @@ CharacterData::CharacterData(const CharacterData &other) : Node(other)
CharacterData &CharacterData::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle ||
( ohandle->nodeType() != CDATA_SECTION_NODE &&
ohandle->nodeType() != TEXT_NODE &&
ohandle->nodeType() != COMMENT_NODE )) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -159,11 +162,14 @@ Comment::Comment(const Comment &other) : CharacterData(other)
Comment &Comment::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != COMMENT_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -194,13 +200,16 @@ Text::Text(const Text &other) : CharacterData(other)
Text &Text::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle ||
(ohandle->nodeType() != TEXT_NODE &&
ohandle->nodeType() != CDATA_SECTION_NODE)) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/dom_xml.cpp b/WebCore/khtml/dom/dom_xml.cpp
index 3dde5e0..05d4d56 100644
--- a/WebCore/khtml/dom/dom_xml.cpp
+++ b/WebCore/khtml/dom/dom_xml.cpp
@@ -39,11 +39,14 @@ CDATASection::CDATASection(const CDATASection &) : Text()
CDATASection &CDATASection::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != CDATA_SECTION_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -73,11 +76,14 @@ Entity::Entity(const Entity &) : Node()
Entity &Entity::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != ENTITY_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -132,11 +138,14 @@ EntityReference::EntityReference(const EntityReference &) : Node()
EntityReference &EntityReference::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != ENTITY_REFERENCE_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -167,11 +176,14 @@ Notation::Notation(const Notation &) : Node()
Notation &Notation::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != NOTATION_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
@@ -220,11 +232,14 @@ ProcessingInstruction::ProcessingInstruction(const ProcessingInstruction &)
ProcessingInstruction &ProcessingInstruction::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
+ if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != PROCESSING_INSTRUCTION_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/html_base.cpp b/WebCore/khtml/dom/html_base.cpp
index e8edc52..9a4b127 100644
--- a/WebCore/khtml/dom/html_base.cpp
+++ b/WebCore/khtml/dom/html_base.cpp
@@ -41,12 +41,7 @@ HTMLBodyElement::HTMLBodyElement(HTMLBodyElementImpl *impl) : HTMLElement(impl)
HTMLBodyElement &HTMLBodyElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BODY)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BODY );
return *this;
}
@@ -62,8 +57,7 @@ HTMLBodyElement::~HTMLBodyElement()
DOMString HTMLBodyElement::aLink() const
{
- if(!impl) return DOMString();
- return ((ElementImpl *)impl)->getAttribute(ATTR_ALINK);
+ return impl ? ((ElementImpl *)impl)->getAttribute(ATTR_ALINK) : DOMString();
}
void HTMLBodyElement::setALink( const DOMString &value )
@@ -73,8 +67,7 @@ void HTMLBodyElement::setALink( const DOMString &value )
DOMString HTMLBodyElement::background() const
{
- if(!impl) return DOMString();
- return ((ElementImpl *)impl)->getAttribute(ATTR_BACKGROUND);
+ return impl ? ((ElementImpl *)impl)->getAttribute(ATTR_BACKGROUND) : DOMString();
}
void HTMLBodyElement::setBackground( const DOMString &value )
@@ -142,12 +135,7 @@ HTMLFrameElement::HTMLFrameElement(HTMLFrameElementImpl *impl) : HTMLElement(imp
HTMLFrameElement &HTMLFrameElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FRAME)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FRAME );
return *this;
}
@@ -277,12 +265,7 @@ HTMLIFrameElement::HTMLIFrameElement(HTMLIFrameElementImpl *impl) : HTMLElement(
HTMLIFrameElement &HTMLIFrameElement::operator = (const Node &other)
{
- if(other.elementId() != ID_IFRAME)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_IFRAME );
return *this;
}
@@ -428,12 +411,7 @@ HTMLFrameSetElement::HTMLFrameSetElement(HTMLFrameSetElementImpl *impl) : HTMLEl
HTMLFrameSetElement &HTMLFrameSetElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FRAMESET)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FRAMESET );
return *this;
}
@@ -485,12 +463,7 @@ HTMLHeadElement::HTMLHeadElement(HTMLHeadElementImpl *impl) : HTMLElement(impl)
HTMLHeadElement &HTMLHeadElement::operator = (const Node &other)
{
- if(other.elementId() != ID_HEAD)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_HEAD );
return *this;
}
@@ -531,12 +504,7 @@ HTMLHtmlElement::HTMLHtmlElement(HTMLHtmlElementImpl *impl) : HTMLElement(impl)
HTMLHtmlElement &HTMLHtmlElement::operator = (const Node &other)
{
- if(other.elementId() != ID_HTML)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_HTML );
return *this;
}
diff --git a/WebCore/khtml/dom/html_block.cpp b/WebCore/khtml/dom/html_block.cpp
index 4410168..30b60f0 100644
--- a/WebCore/khtml/dom/html_block.cpp
+++ b/WebCore/khtml/dom/html_block.cpp
@@ -43,12 +43,7 @@ HTMLBlockquoteElement::HTMLBlockquoteElement(HTMLBlockquoteElementImpl *impl) :
HTMLBlockquoteElement &HTMLBlockquoteElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BLOCKQUOTE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BLOCKQUOTE );
return *this;
}
@@ -89,12 +84,7 @@ HTMLDivElement::HTMLDivElement(HTMLDivElementImpl *impl) : HTMLElement(impl)
HTMLDivElement &HTMLDivElement::operator = (const Node &other)
{
- if(other.elementId() != ID_DIV)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_DIV );
return *this;
}
@@ -135,12 +125,7 @@ HTMLHRElement::HTMLHRElement(HTMLHRElementImpl *impl) : HTMLElement(impl)
HTMLHRElement &HTMLHRElement::operator = (const Node &other)
{
- if(other.elementId() != ID_HR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_HR );
return *this;
}
@@ -227,10 +212,11 @@ HTMLHeadingElement &HTMLHeadingElement::operator = (const Node &other)
other.elementId() != ID_H5 ||
other.elementId() != ID_H6 )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
@@ -271,12 +257,7 @@ HTMLParagraphElement::HTMLParagraphElement(HTMLParagraphElementImpl *impl) : HTM
HTMLParagraphElement &HTMLParagraphElement::operator = (const Node &other)
{
- if(other.elementId() != ID_P)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_P );
return *this;
}
@@ -317,12 +298,7 @@ HTMLPreElement::HTMLPreElement(HTMLPreElementImpl *impl) : HTMLElement(impl)
HTMLPreElement &HTMLPreElement::operator = (const Node &other)
{
- if(other.elementId() != ID_PRE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_PRE );
return *this;
}
diff --git a/WebCore/khtml/dom/html_document.cpp b/WebCore/khtml/dom/html_document.cpp
index 2eee0c5..ebe38ec 100644
--- a/WebCore/khtml/dom/html_document.cpp
+++ b/WebCore/khtml/dom/html_document.cpp
@@ -55,16 +55,18 @@ HTMLDocument::HTMLDocument(HTMLDocumentImpl *impl) : Document(impl)
HTMLDocument &HTMLDocument::operator = (const Node &other)
{
- if(other.nodeType() != DOCUMENT_NODE)
- {
+ if(other.nodeType() != DOCUMENT_NODE) {
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
- Document d(other);
- if(!d.isHTMLDocument())
+ } else {
+ DocumentImpl *d = static_cast<DocumentImpl *>(other.handle());
+ if(!d->isHTMLDocument()) {
+ if ( impl ) impl->deref();
impl = 0;
- else
+ } else {
Node::operator =(other);
+ }
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/html_element.cpp b/WebCore/khtml/dom/html_element.cpp
index 354e98c..43619ff 100644
--- a/WebCore/khtml/dom/html_element.cpp
+++ b/WebCore/khtml/dom/html_element.cpp
@@ -165,3 +165,21 @@ HTMLCollection HTMLElement::children() const
if(!impl) return HTMLCollection();
return HTMLCollection(impl, HTMLCollectionImpl::NODE_CHILDREN);
}
+
+void HTMLElement::assignOther( const Node &other, int elementId )
+{
+#ifdef APPLE_CHANGES
+ if((int)other.elementId() != elementId) {
+#else
+ if(other.elementId() != elementId) {
+#endif
+ if ( impl ) impl->deref();
+ impl = 0;
+ } else {
+ Node::operator = (other);
+#ifdef APPLE_CHANGES
+ } // keep prepare-ChangeLog happy
+#else
+ }
+#endif
+}
diff --git a/WebCore/khtml/dom/html_element.h b/WebCore/khtml/dom/html_element.h
index 9ffe23d..dadbefa 100644
--- a/WebCore/khtml/dom/html_element.h
+++ b/WebCore/khtml/dom/html_element.h
@@ -200,6 +200,11 @@ public:
*/
void addCSSProperty( const DOMString &property, const DOMString &value );
+protected:
+ /*
+ * @internal
+ */
+ void assignOther( const Node &other, int elementId );
};
}; //namespace
diff --git a/WebCore/khtml/dom/html_form.cpp b/WebCore/khtml/dom/html_form.cpp
index 97f07a3..a0d0158 100644
--- a/WebCore/khtml/dom/html_form.cpp
+++ b/WebCore/khtml/dom/html_form.cpp
@@ -47,12 +47,7 @@ HTMLButtonElement::HTMLButtonElement(HTMLButtonElementImpl *impl) : HTMLElement(
HTMLButtonElement &HTMLButtonElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BUTTON)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BUTTON );
return *this;
}
@@ -150,12 +145,7 @@ HTMLFieldSetElement::HTMLFieldSetElement(HTMLFieldSetElementImpl *impl) : HTMLEl
HTMLFieldSetElement &HTMLFieldSetElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FIELDSET)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FIELDSET );
return *this;
}
@@ -191,12 +181,7 @@ HTMLFormElement::HTMLFormElement(HTMLFormElementImpl *impl) : HTMLElement(impl)
HTMLFormElement &HTMLFormElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FORM)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FORM );
return *this;
}
@@ -314,12 +299,7 @@ HTMLInputElement::HTMLInputElement(HTMLInputElementImpl *impl) : HTMLElement(imp
HTMLInputElement &HTMLInputElement::operator = (const Node &other)
{
- if(other.elementId() != ID_INPUT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_INPUT );
return *this;
}
@@ -584,12 +564,7 @@ HTMLLabelElement::HTMLLabelElement(HTMLLabelElementImpl *impl) : HTMLElement(imp
HTMLLabelElement &HTMLLabelElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LABEL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LABEL );
return *this;
}
@@ -651,12 +626,7 @@ HTMLLegendElement::HTMLLegendElement(HTMLLegendElementImpl *impl) : HTMLElement(
HTMLLegendElement &HTMLLegendElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LEGEND)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LEGEND );
return *this;
}
@@ -714,12 +684,7 @@ HTMLOptGroupElement::HTMLOptGroupElement(HTMLOptGroupElementImpl *impl) : HTMLEl
HTMLOptGroupElement &HTMLOptGroupElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OPTGROUP)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OPTGROUP );
return *this;
}
@@ -772,12 +737,7 @@ HTMLSelectElement::HTMLSelectElement(HTMLSelectElementImpl *impl) : HTMLElement(
HTMLSelectElement &HTMLSelectElement::operator = (const Node &other)
{
- if(other.elementId() != ID_SELECT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_SELECT );
return *this;
}
@@ -938,12 +898,7 @@ HTMLTextAreaElement::HTMLTextAreaElement(HTMLTextAreaElementImpl *impl) : HTMLEl
HTMLTextAreaElement &HTMLTextAreaElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TEXTAREA)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TEXTAREA );
return *this;
}
@@ -1111,12 +1066,7 @@ HTMLOptionElement::HTMLOptionElement(HTMLOptionElementImpl *impl) : HTMLElement(
HTMLOptionElement &HTMLOptionElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OPTION)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OPTION );
return *this;
}
@@ -1224,12 +1174,7 @@ HTMLIsIndexElement::HTMLIsIndexElement(HTMLIsIndexElementImpl *impl) : HTMLEleme
HTMLIsIndexElement &HTMLIsIndexElement::operator = (const Node &other)
{
- if(other.elementId() != ID_ISINDEX)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_ISINDEX );
return *this;
}
diff --git a/WebCore/khtml/dom/html_head.cpp b/WebCore/khtml/dom/html_head.cpp
index 0060206..07e3ca5 100644
--- a/WebCore/khtml/dom/html_head.cpp
+++ b/WebCore/khtml/dom/html_head.cpp
@@ -41,12 +41,7 @@ HTMLBaseElement::HTMLBaseElement(HTMLBaseElementImpl *impl) : HTMLElement(impl)
HTMLBaseElement &HTMLBaseElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BASE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BASE );
return *this;
}
@@ -98,12 +93,7 @@ HTMLLinkElement::HTMLLinkElement(HTMLLinkElementImpl *impl) : HTMLElement(impl)
HTMLLinkElement &HTMLLinkElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LINK)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LINK );
return *this;
}
@@ -239,12 +229,7 @@ HTMLMetaElement::HTMLMetaElement(HTMLMetaElementImpl *impl) : HTMLElement(impl)
HTMLMetaElement &HTMLMetaElement::operator = (const Node &other)
{
- if(other.elementId() != ID_META)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_META );
return *this;
}
@@ -318,12 +303,7 @@ HTMLScriptElement::HTMLScriptElement(HTMLScriptElementImpl *impl) : HTMLElement(
HTMLScriptElement &HTMLScriptElement::operator = (const Node &other)
{
- if(other.elementId() != ID_SCRIPT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_SCRIPT );
return *this;
}
@@ -432,12 +412,7 @@ HTMLStyleElement::HTMLStyleElement(HTMLStyleElementImpl *impl) : HTMLElement(imp
HTMLStyleElement &HTMLStyleElement::operator = (const Node &other)
{
- if(other.elementId() != ID_STYLE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_STYLE );
return *this;
}
@@ -509,12 +484,7 @@ HTMLTitleElement::HTMLTitleElement(HTMLTitleElementImpl *impl) : HTMLElement(imp
HTMLTitleElement &HTMLTitleElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TITLE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TITLE );
return *this;
}
diff --git a/WebCore/khtml/dom/html_image.cpp b/WebCore/khtml/dom/html_image.cpp
index f9309a9..3771e31 100644
--- a/WebCore/khtml/dom/html_image.cpp
+++ b/WebCore/khtml/dom/html_image.cpp
@@ -45,12 +45,7 @@ HTMLAreaElement::HTMLAreaElement(HTMLAreaElementImpl *impl) : HTMLElement(impl)
HTMLAreaElement &HTMLAreaElement::operator = (const Node &other)
{
- if(other.elementId() != ID_AREA)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_AREA );
return *this;
}
@@ -177,12 +172,7 @@ HTMLImageElement::HTMLImageElement(HTMLImageElementImpl *impl) : HTMLElement(imp
HTMLImageElement &HTMLImageElement::operator = (const Node &other)
{
- if(other.elementId() != ID_IMG)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_IMG );
return *this;
}
@@ -357,12 +347,7 @@ HTMLMapElement::HTMLMapElement(HTMLMapElementImpl *impl) : HTMLElement(impl)
HTMLMapElement &HTMLMapElement::operator = (const Node &other)
{
- if(other.elementId() != ID_MAP)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_MAP );
return *this;
}
diff --git a/WebCore/khtml/dom/html_inline.cpp b/WebCore/khtml/dom/html_inline.cpp
index 5f865d6..134d1c7 100644
--- a/WebCore/khtml/dom/html_inline.cpp
+++ b/WebCore/khtml/dom/html_inline.cpp
@@ -45,12 +45,7 @@ HTMLAnchorElement::HTMLAnchorElement(HTMLAnchorElementImpl *impl) : HTMLElement(
HTMLAnchorElement &HTMLAnchorElement::operator = (const Node &other)
{
- if(other.elementId() != ID_A)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_A );
return *this;
}
@@ -227,12 +222,7 @@ HTMLBRElement::HTMLBRElement(HTMLBRElementImpl *impl) : HTMLElement(impl)
HTMLBRElement &HTMLBRElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BR );
return *this;
}
@@ -273,12 +263,7 @@ HTMLFontElement::HTMLFontElement(HTMLFontElementImpl *impl) : HTMLElement(impl)
HTMLFontElement &HTMLFontElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FONT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FONT );
return *this;
}
@@ -343,6 +328,7 @@ HTMLModElement::HTMLModElement(HTMLElementImpl *_impl)
impl = _impl;
else
impl = 0;
+ if ( impl ) impl->ref();
}
HTMLModElement &HTMLModElement::operator = (const Node &other)
@@ -350,10 +336,11 @@ HTMLModElement &HTMLModElement::operator = (const Node &other)
if( other.elementId() != ID_INS &&
other.elementId() != ID_DEL )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
@@ -406,16 +393,12 @@ HTMLQuoteElement::HTMLQuoteElement(HTMLGenericElementImpl *_impl)
impl = _impl;
else
impl = 0;
+ if ( impl ) impl->ref();
}
HTMLQuoteElement &HTMLQuoteElement::operator = (const Node &other)
{
- if(other.elementId() != ID_Q)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_Q );
return *this;
}
diff --git a/WebCore/khtml/dom/html_list.cpp b/WebCore/khtml/dom/html_list.cpp
index 5afdfc6..c21e755 100644
--- a/WebCore/khtml/dom/html_list.cpp
+++ b/WebCore/khtml/dom/html_list.cpp
@@ -41,12 +41,7 @@ HTMLDListElement::HTMLDListElement(HTMLDListElementImpl *impl) : HTMLElement(imp
HTMLDListElement &HTMLDListElement::operator = (const Node &other)
{
- if(other.elementId() != ID_DL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_DL );
return *this;
}
@@ -93,12 +88,7 @@ HTMLDirectoryElement::HTMLDirectoryElement(HTMLDirectoryElementImpl *impl) : HTM
HTMLDirectoryElement &HTMLDirectoryElement::operator = (const Node &other)
{
- if(other.elementId() != ID_DIR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_DIR );
return *this;
}
@@ -145,12 +135,7 @@ HTMLLIElement::HTMLLIElement(HTMLLIElementImpl *impl) : HTMLElement(impl)
HTMLLIElement &HTMLLIElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LI)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LI );
return *this;
}
@@ -205,12 +190,7 @@ HTMLMenuElement::HTMLMenuElement(HTMLMenuElementImpl *impl) : HTMLElement(impl)
HTMLMenuElement &HTMLMenuElement::operator = (const Node &other)
{
- if(other.elementId() != ID_MENU)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_MENU );
return *this;
}
@@ -257,12 +237,7 @@ HTMLOListElement::HTMLOListElement(HTMLOListElementImpl *impl) : HTMLElement(imp
HTMLOListElement &HTMLOListElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OL );
return *this;
}
@@ -335,12 +310,7 @@ HTMLUListElement::HTMLUListElement(HTMLUListElementImpl *impl) : HTMLElement(imp
HTMLUListElement &HTMLUListElement::operator = (const Node &other)
{
- if(other.elementId() != ID_UL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_UL );
return *this;
}
diff --git a/WebCore/khtml/dom/html_misc.cpp b/WebCore/khtml/dom/html_misc.cpp
index 99149cb..1e67647 100644
--- a/WebCore/khtml/dom/html_misc.cpp
+++ b/WebCore/khtml/dom/html_misc.cpp
@@ -41,12 +41,7 @@ HTMLBaseFontElement::HTMLBaseFontElement(HTMLBaseFontElementImpl *impl) : HTMLEl
HTMLBaseFontElement &HTMLBaseFontElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BASEFONT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BASEFONT );
return *this;
}
@@ -114,10 +109,11 @@ HTMLCollection::HTMLCollection(NodeImpl *base, int type)
HTMLCollection &HTMLCollection::operator = (const HTMLCollection &other)
{
- if(impl == other.impl) return *this;
+ if(impl != other.impl) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
diff --git a/WebCore/khtml/dom/html_object.cpp b/WebCore/khtml/dom/html_object.cpp
index 0825d16..3db75f1 100644
--- a/WebCore/khtml/dom/html_object.cpp
+++ b/WebCore/khtml/dom/html_object.cpp
@@ -41,12 +41,7 @@ HTMLAppletElement::HTMLAppletElement(HTMLAppletElementImpl *impl)
HTMLAppletElement &HTMLAppletElement::operator = (const Node &other)
{
- if(other.elementId() != ID_APPLET)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_APPLET );
return *this;
}
@@ -197,12 +192,7 @@ HTMLObjectElement::HTMLObjectElement(HTMLObjectElementImpl *impl) : HTMLElement(
HTMLObjectElement &HTMLObjectElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OBJECT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OBJECT );
return *this;
}
@@ -440,12 +430,7 @@ HTMLParamElement::HTMLParamElement(HTMLParamElementImpl *impl) : HTMLElement(imp
HTMLParamElement &HTMLParamElement::operator = (const Node &other)
{
- if(other.elementId() != ID_PARAM)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_PARAM );
return *this;
}
diff --git a/WebCore/khtml/dom/html_table.cpp b/WebCore/khtml/dom/html_table.cpp
index 3c18d4c..746fd2a 100644
--- a/WebCore/khtml/dom/html_table.cpp
+++ b/WebCore/khtml/dom/html_table.cpp
@@ -45,12 +45,7 @@ HTMLTableCaptionElement::HTMLTableCaptionElement(HTMLTableCaptionElementImpl *im
HTMLTableCaptionElement &HTMLTableCaptionElement::operator = (const Node &other)
{
- if(other.elementId() != ID_CAPTION)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_CAPTION );
return *this;
}
@@ -94,10 +89,11 @@ HTMLTableCellElement &HTMLTableCellElement::operator = (const Node &other)
if( other.elementId() != ID_TD &&
other.elementId() != ID_TH )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
@@ -302,10 +298,11 @@ HTMLTableColElement &HTMLTableColElement::operator = (const Node &other)
if( other.elementId() != ID_COL &&
other.elementId() != ID_COLGROUP )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
@@ -404,12 +401,7 @@ HTMLTableElement::HTMLTableElement(HTMLTableElementImpl *impl) : HTMLElement(imp
HTMLTableElement &HTMLTableElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TABLE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TABLE );
return *this;
}
@@ -639,12 +631,7 @@ HTMLTableRowElement::HTMLTableRowElement(HTMLTableRowElementImpl *impl) : HTMLEl
HTMLTableRowElement &HTMLTableRowElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TR );
return *this;
}
@@ -778,10 +765,11 @@ HTMLTableSectionElement &HTMLTableSectionElement::operator = (const Node &other)
other.elementId() != ID_THEAD &&
other.elementId() != ID_TFOOT )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
diff --git a/WebCore/khtml/ecma/kjs_html.cpp b/WebCore/khtml/ecma/kjs_html.cpp
index 7da51af..a740717 100644
--- a/WebCore/khtml/ecma/kjs_html.cpp
+++ b/WebCore/khtml/ecma/kjs_html.cpp
@@ -172,7 +172,7 @@ Value KJS::HTMLDocument::tryGet(ExecState *exec, const UString &propertyName) co
case Referrer:
return getString(doc.referrer());
case Domain:
- return getString(doc.domain());
+ return String(doc.domain());
case URL:
return getString(doc.URL());
case Body:
@@ -1114,7 +1114,7 @@ Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
case FormAction: return getString(form.action());
case FormEncType: return getString(form.enctype());
case FormMethod: return getString(form.method());
- case FormTarget: return getString(form.target());
+ case FormTarget: return String(form.target());
}
}
break;
@@ -1415,7 +1415,7 @@ Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
case ImageHspace: return Number(image.hspace());
case ImageIsMap: return Boolean(image.isMap());
case ImageLongDesc: return getString(image.longDesc());
- case ImageSrc: return getString(image.src());
+ case ImageSrc: return String(image.src());
case ImageUseMap: return getString(image.useMap());
case ImageVspace: return Number(image.vspace());
case ImageWidth: return Number(image.width());
@@ -1630,7 +1630,8 @@ Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
case FrameName: return getString(frameElement.name());
case FrameNoResize: return Boolean(frameElement.noResize());
case FrameScrolling: return getString(frameElement.scrolling());
- case FrameSrc: return getString(frameElement.src());
+ case FrameSrc:
+ case FrameLocation: return getString(frameElement.src());
}
}
break;
@@ -2829,8 +2830,12 @@ void KJS::HTMLSelectCollection::tryPut(ExecState *exec, const UString &propertyN
#ifdef KJS_VERBOSE
kdDebug(6070) << "KJS::HTMLSelectCollection::tryPut " << propertyName.qstring() << endl;
#endif
+ if ( propertyName == "selectedIndex" ) {
+ element.setSelectedIndex( value.toInteger( exec ) );
+ return;
+ }
// resize ?
- if (propertyName == "length") {
+ else if (propertyName == "length") {
long newLen = value.toInteger(exec);
long diff = element.length() - newLen;
diff --git a/WebCore/khtml/ecma/kjs_proxy.cpp b/WebCore/khtml/ecma/kjs_proxy.cpp
index bb5e5dc..5daea73 100644
--- a/WebCore/khtml/ecma/kjs_proxy.cpp
+++ b/WebCore/khtml/ecma/kjs_proxy.cpp
@@ -129,7 +129,7 @@ QVariant KJSProxyImpl::evaluate(QString filename, int baseLine,
if ( comp.complType() == Throw )
{
UString msg = comp.value().toString(m_script->globalExec());
- kdWarning(6070) << "Script throwed exception: " << msg.qstring() << endl;
+ kdWarning(6070) << "Script threw exception: " << msg.qstring() << endl;
}
return QVariant();
}
diff --git a/WebCore/khtml/ecma/kjs_traversal.cpp b/WebCore/khtml/ecma/kjs_traversal.cpp
index ee3cee3..5d60b91 100644
--- a/WebCore/khtml/ecma/kjs_traversal.cpp
+++ b/WebCore/khtml/ecma/kjs_traversal.cpp
@@ -297,9 +297,8 @@ DOM::NodeFilter KJS::toNodeFilter(const Value& val)
// -------------------------------------------------------------------------
-JSNodeFilter::JSNodeFilter(Object & _filter) : DOM::CustomNodeFilter()
+JSNodeFilter::JSNodeFilter(Object & _filter) : DOM::CustomNodeFilter(), filter( _filter )
{
- filter = _filter;
}
JSNodeFilter::~JSNodeFilter()
diff --git a/WebCore/khtml/ecma/kjs_window.cpp b/WebCore/khtml/ecma/kjs_window.cpp
index 678b32c..bb2c6e9 100644
--- a/WebCore/khtml/ecma/kjs_window.cpp
+++ b/WebCore/khtml/ecma/kjs_window.cpp
@@ -58,7 +58,8 @@ namespace KJS {
class History : public ObjectImp {
friend class HistoryFunc;
public:
- History(KHTMLPart *p) : part(p) { }
+ History(ExecState *exec, KHTMLPart *p)
+ : ObjectImp(exec->interpreter()->builtinObjectPrototype()), part(p) { }
virtual Value get(ExecState *exec, const UString &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
@@ -70,7 +71,8 @@ namespace KJS {
class FrameArray : public ObjectImp {
public:
- FrameArray(KHTMLPart *p) : part(p) { }
+ FrameArray(ExecState *exec, KHTMLPart *p)
+ : ObjectImp(exec->interpreter()->builtinObjectPrototype()), part(p) { }
virtual Value get(ExecState *exec, const UString &propertyName) const;
private:
QGuardedPtr<KHTMLPart> part;
@@ -254,7 +256,7 @@ const ClassInfo Window::info = { "Window", 0, &WindowTable, 0 };
IMPLEMENT_PROTOFUNC(WindowFunc)
Window::Window(KHTMLPart *p)
- : m_part(p), screen(0), history(0), frames(0), loc(0), m_evt(0)
+ : ObjectImp(/*no proto*/), m_part(p), screen(0), history(0), frames(0), loc(0), m_evt(0)
{
winq = new WindowQObject(this);
//kdDebug(6070) << "Window::Window this=" << this << " part=" << m_part << " " << m_part->name() << endl;
@@ -406,10 +408,10 @@ Value Window::get(ExecState *exec, const UString &p) const
return getEventConstructor(exec);
case Frames:
return Value(frames ? frames :
- (const_cast<Window*>(this)->frames = new FrameArray(m_part)));
+ (const_cast<Window*>(this)->frames = new FrameArray(exec,m_part)));
case _History:
return Value(history ? history :
- (const_cast<Window*>(this)->history = new History(m_part)));
+ (const_cast<Window*>(this)->history = new History(exec,m_part)));
case Event:
if (m_evt)
@@ -654,7 +656,7 @@ Value Window::get(ExecState *exec, const UString &p) const
Value ret = parentObject.get(exec,p);
if (ret.type() != UndefinedType ) {
#ifdef KJS_VERBOSE
- kdDebug() << "Window::get property " << p.qstring() << " found in parent part" << endl;
+ kdDebug(6070) << "Window::get property " << p.qstring() << " found in parent part" << endl;
#endif
return ret;
}
@@ -699,10 +701,14 @@ void Window::put(ExecState* exec, const UString &propertyName, const Value &valu
return;
}
case _Location: {
- QString str = value.toString(exec).qstring();
KHTMLPart* p = Window::retrieveActive(exec)->m_part;
- if ( p )
- m_part->scheduleRedirection(0, p->htmlDocument().completeURL(str).string());
+ if (p) {
+ QString dstUrl = p->htmlDocument().completeURL(value.toString(exec).string()).string();
+ if (dstUrl.find("javascript:", 0, false) || isSafeScript(exec))
+ m_part->scheduleRedirection(0,
+ dstUrl,
+ false /*don't lock history*/);
+ }
return;
}
case Onabort:
@@ -862,6 +868,7 @@ bool Window::isSafeScript(ExecState *exec) const
//kdDebug(6070) << "current domain:" << actDomain.string() << ", frame domain:" << thisDomain.string() << endl;
if ( actDomain == thisDomain )
return true;
+
kdWarning(6070) << "Javascript: access denied for current frame '" << actDomain.string() << "' to frame '" << thisDomain.string() << "'" << endl;
return false;
}
@@ -1082,14 +1089,14 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
while ( part->parentPart() )
part = part->parentPart();
- part->scheduleRedirection(0, url.url());
+ part->scheduleRedirection(0, url.url(), false/*don't lock history*/);
return Window::retrieve(part);
}
if ( uargs.frameName == "_parent" )
{
if ( part->parentPart() )
part = part->parentPart();
- part->scheduleRedirection(0, url.url());
+ part->scheduleRedirection(0, url.url(), false/*don't lock history*/);
return Window::retrieve(part);
}
uargs.serviceType = "text/html";
@@ -1217,12 +1224,13 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
else
return Undefined();
case Window::SetInterval:
- if (args.size() == 2 && v.isA(StringType)) {
+ if (args.size() >= 2 && v.isA(StringType)) {
int i = args[1].toInt32(exec);
int r = (const_cast<Window*>(window))->installTimeout(s, i, false);
return Number(r);
}
- else if (args.size() >= 2 && Object::dynamicCast(v).implementsCall()) {
+ else if (args.size() >= 2 && !Object::dynamicCast(v).isNull() &&
+ Object::dynamicCast(v).implementsCall()) {
Value func = args[0];
int i = args[1].toInt32(exec);
#if 0
@@ -1262,9 +1270,9 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
// To conform to the SPEC, we only ask if the window
// has more than one entry in the history (NS does that too).
- History history(part);
+ History history(exec,part);
if ( history.get( exec, "length" ).toInt32(exec) <= 1 ||
- KMessageBox::questionYesNo( window->part()->widget(), i18n("Close window ?"), i18n("Confirmation required") ) == KMessageBox::Yes )
+ KMessageBox::questionYesNo( window->part()->widget(), i18n("Close window?"), i18n("Confirmation Required") ) == KMessageBox::Yes )
(const_cast<Window*>(window))->scheduleClose();
}
else
@@ -1612,7 +1620,7 @@ void Location::put(ExecState *exec, const UString &p, const Value &v, int attr)
return;
}
- m_part->scheduleRedirection(0, url.url());
+ m_part->scheduleRedirection(0, url.url(), false /*don't lock history*/);
}
Value Location::toPrimitive(ExecState *exec, Type) const
@@ -1644,11 +1652,11 @@ Value LocationFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
QString str = args[0].toString(exec).qstring();
KHTMLPart* p = Window::retrieveActive(exec)->part();
if ( p )
- part->scheduleRedirection(0, p->htmlDocument().completeURL(str).string());
+ part->scheduleRedirection(0, p->htmlDocument().completeURL(str).string(), true /*lock history*/);
break;
}
case Location::Reload:
- part->scheduleRedirection(0, part->url().url());
+ part->scheduleRedirection(0, part->url().url(), true/*lock history*/);
break;
case Location::ToString:
return String(location->toString(exec));
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index 986e889..1bae529 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -296,13 +296,17 @@ void HTMLFrameElementImpl::attach()
// ignore display: none for this element!
KHTMLView* w = getDocument()->view();
- // limit to how deep we can nest frames
- KHTMLPart *part = w->part();
- int depth = 0;
- while ((part = part->parentPart()))
- depth++;
+ // avoid endless recursion
+ KURL u;
+ if (!url.isEmpty()) u = getDocument()->completeURL( url.string() );
+ bool selfreference = false;
+ for (KHTMLPart* part = w->part(); part; part = part->parentPart())
+ if (part->url() == u) {
+ selfreference = true;
+ break;
+ }
- if (depth < 5) {
+ if (!selfreference) {
m_render = new RenderFrame(this);
m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
parentNode()->renderer()->addChild(m_render, nextRenderer());
@@ -318,7 +322,7 @@ void HTMLFrameElementImpl::attach()
name = DOMString(w->part()->requestFrameName());
// load the frame contents
- if (!url.isEmpty())
+ if ( !url.isEmpty() && !(w->part()->onlyLocalReferences() && u.protocol() != "file"))
w->part()->requestFrame( static_cast<RenderFrame*>(m_render), url.string(), name.string() );
}
@@ -596,7 +600,16 @@ void HTMLIFrameElementImpl::attach()
assert(parentNode());
KHTMLView* w = getDocument()->view();
- // limit to how deep we can nest frames
+ // avoid endless recursion
+ KURL u;
+ if (!url.isEmpty()) u = getDocument()->completeURL( url.string() );
+ bool selfreference = false;
+ for (KHTMLPart* part = w->part(); part; part = part->parentPart())
+ if (part->url() == u) {
+ selfreference = true;
+ break;
+ }
+
KHTMLPart *part = w->part();
int depth = 0;
while ((part = part->parentPart()))
@@ -604,7 +617,8 @@ void HTMLIFrameElementImpl::attach()
RenderStyle* _style = getDocument()->styleSelector()->styleForElement(this);
_style->ref();
- if (depth < 7 && parentNode()->renderer() && _style->display() != NONE) {
+ if (!selfreference && !(w->part()->onlyLocalReferences() && u.protocol() != "file") &&
+ parentNode()->renderer() && _style->display() != NONE) {
m_render = new RenderPartObject(this);
m_render->setStyle(_style);
parentNode()->renderer()->addChild(m_render, nextRenderer());
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index cc1bc7c..d319668 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -323,6 +323,10 @@ void HTMLFormElementImpl::setEnctype( const DOMString& type )
m_enctype = "multipart/form-data";
m_multipart = true;
m_post = true;
+ } else if (type.string().find("text", 0, false) != -1 || type.string().find("plain", 0, false) != -1)
+ {
+ m_enctype = "text/plain";
+ m_multipart = false;
}
else
{
@@ -942,6 +946,7 @@ void HTMLInputElementImpl::parseAttribute(AttributeImpl *attr)
break;
case ATTR_MAXLENGTH:
m_maxLen = attr->val() ? attr->val()->toInt() : -1;
+ setChanged();
break;
case ATTR_SIZE:
m_size = attr->val() ? attr->val()->toInt() : 20;
@@ -1275,13 +1280,6 @@ void HTMLInputElementImpl::defaultEventHandler(EventImpl *evt)
xPos = me->clientX()-offsetX;
yPos = me->clientY()-offsetY;
- // since we are not called from a RenderFormElement, the DOMActivate event will not get
- // sent so we have to do it here
- if (me->detail() % 2 == 0) // double click
- dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT,2);
- else
- dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT,1);
-
me->setDefaultHandled();
}
@@ -1402,13 +1400,17 @@ DOMString HTMLSelectElementImpl::type() const
long HTMLSelectElementImpl::selectedIndex() const
{
- uint i;
+ // return the number of the first option selected
+ uint o = 0;
QMemArray<HTMLGenericFormElementImpl*> items = listItems();
- for (i = 0; i < items.size(); i++) {
- if (items[i]->id() == ID_OPTION
- && static_cast<HTMLOptionElementImpl*>(items[i])->selected())
- return listToOptionIndex(int(i)); // selectedIndex is the *first* selected item; there may be others
+ for (unsigned int i = 0; i < items.size(); i++) {
+ if (items[i]->id() == ID_OPTION) {
+ if (static_cast<HTMLOptionElementImpl*>(items[i])->selected())
+ return o;
+ o++;
+ }
}
+ Q_ASSERT(m_multiple);
return -1;
}
@@ -1718,31 +1720,32 @@ int HTMLSelectElementImpl::listToOptionIndex(int listIndex) const
void HTMLSelectElementImpl::recalcListItems()
{
NodeImpl* current = firstChild();
- bool inOptGroup = false;
m_listItems.resize(0);
- bool foundSelected = false;
+ HTMLOptionElementImpl* foundSelected = 0;
while(current) {
- if (!inOptGroup && current->id() == ID_OPTGROUP && current->firstChild()) {
+ if (current->id() == ID_OPTGROUP && current->firstChild()) {
// ### what if optgroup contains just comments? don't want one of no options in it...
m_listItems.resize(m_listItems.size()+1);
m_listItems[m_listItems.size()-1] = static_cast<HTMLGenericFormElementImpl*>(current);
current = current->firstChild();
- inOptGroup = true;
}
if (current->id() == ID_OPTION) {
m_listItems.resize(m_listItems.size()+1);
m_listItems[m_listItems.size()-1] = static_cast<HTMLGenericFormElementImpl*>(current);
- if (foundSelected && !m_multiple && static_cast<HTMLOptionElementImpl*>(current)->selected())
- static_cast<HTMLOptionElementImpl*>(current)->setSelected(false);
- foundSelected = static_cast<HTMLOptionElementImpl*>(current)->selected();
+ if (!foundSelected && !m_multiple) {
+ foundSelected = static_cast<HTMLOptionElementImpl*>(current);
+ foundSelected->m_selected = true;
+ }
+ else if (foundSelected && !m_multiple && static_cast<HTMLOptionElementImpl*>(current)->selected()) {
+ foundSelected->m_selected = false;
+ foundSelected = static_cast<HTMLOptionElementImpl*>(current);
+ }
}
NodeImpl *parent = current->parentNode();
current = current->nextSibling();
if (!current) {
- if (inOptGroup) {
+ if (parent != this)
current = parent->nextSibling();
- inOptGroup = false;
- }
}
}
m_recalcListItems = false;
diff --git a/WebCore/khtml/html/html_miscimpl.h b/WebCore/khtml/html/html_miscimpl.h
index b653675..ba87923 100644
--- a/WebCore/khtml/html/html_miscimpl.h
+++ b/WebCore/khtml/html/html_miscimpl.h
@@ -24,6 +24,7 @@
#define HTML_MISCIMPL_H
#include "html_elementimpl.h"
+#include "misc/shared.h"
namespace DOM {
@@ -43,7 +44,7 @@ public:
// -------------------------------------------------------------------------
-class HTMLCollectionImpl : public DomShared
+class HTMLCollectionImpl : public khtml::Shared<HTMLCollectionImpl>
{
friend class DOM::HTMLCollection;
public:
diff --git a/WebCore/khtml/html/html_objectimpl.cpp b/WebCore/khtml/html/html_objectimpl.cpp
index b05138c..720931f 100644
--- a/WebCore/khtml/html/html_objectimpl.cpp
+++ b/WebCore/khtml/html/html_objectimpl.cpp
@@ -39,6 +39,11 @@
#include "rendering/render_frames.h"
#include "xml/dom2_eventsimpl.h"
+#ifndef Q_WS_QWS // We don't have Java in Qt Embedded
+#include "java/kjavaappletwidget.h"
+#include "java/kjavaappletcontext.h"
+#endif
+
using namespace DOM;
using namespace khtml;
@@ -127,6 +132,35 @@ void HTMLAppletElementImpl::attach()
NodeBaseImpl::attach();
}
+bool HTMLAppletElementImpl::getMember(const QString & name, JType & type, QString & val) {
+#ifdef APPLE_CHANGES
+ return false;
+#else
+#ifndef Q_WS_QWS // We don't have Java in Qt Embedded
+ if ( !m_render || !m_render->isApplet() )
+ return false;
+ KJavaAppletWidget *w = static_cast<KJavaAppletWidget*>(static_cast<RenderApplet*>(m_render)->widget());
+ return (w && w->applet() && w->applet()->getMember(name, type, val));
+#else
+ return false;
+#endif
+#endif
+}
+
+bool HTMLAppletElementImpl::callMember(const QString & name, const QStringList & args, JType & type, QString & val) {
+#ifdef APPLE_CHANGES
+ return false;
+#else
+#ifndef Q_WS_QWS // We don't have Java in Qt Embedded
+ if ( !m_render || !m_render->isApplet() )
+ return false;
+ KJavaAppletWidget *w = static_cast<KJavaAppletWidget*>(static_cast<RenderApplet*>(m_render)->widget());
+ return (w && w->applet() && w->applet()->callMember(name, args, type, val));
+#else
+ return false;
+#endif
+#endif
+}
// -------------------------------------------------------------------------
HTMLEmbedElementImpl::HTMLEmbedElementImpl(DocumentPtr *doc)
@@ -299,7 +333,15 @@ void HTMLObjectElementImpl::attach()
assert(!m_render);
KHTMLView* w = getDocument()->view();
- if (w->part()->pluginsEnabled() && parentNode()->renderer()) {
+ bool loadplugin = w->part()->pluginsEnabled();
+ KURL u = getDocument()->completeURL(url);
+ for (KHTMLPart* part = w->part(); part; part = part->parentPart())
+ if (part->url() == u) {
+ loadplugin = false;
+ break;
+ }
+
+ if (loadplugin && parentNode()->renderer()) {
needWidgetUpdate = false;
m_render = new RenderPartObject(this);
m_render->setStyle(getDocument()->styleSelector()->styleForElement(this));
diff --git a/WebCore/khtml/html/html_objectimpl.h b/WebCore/khtml/html/html_objectimpl.h
index bbe0faf..ae542bf 100644
--- a/WebCore/khtml/html/html_objectimpl.h
+++ b/WebCore/khtml/html/html_objectimpl.h
@@ -25,6 +25,7 @@
#include "html_elementimpl.h"
#include "xml/dom_stringimpl.h"
+#include "java/kjavaappletcontext.h"
#include <qstringlist.h>
@@ -48,6 +49,8 @@ public:
virtual void parseAttribute(AttributeImpl *token);
virtual void attach();
+ bool getMember(const QString &, JType &, QString &);
+ bool callMember(const QString &, const QStringList &, JType &, QString &);
protected:
khtml::VAlign valign;
};
diff --git a/WebCore/khtml/html/htmlparser.cpp b/WebCore/khtml/html/htmlparser.cpp
index eb929dd..0789fde 100644
--- a/WebCore/khtml/html/htmlparser.cpp
+++ b/WebCore/khtml/html/htmlparser.cpp
@@ -140,7 +140,6 @@ KHTMLParser::KHTMLParser( DOM::DocumentFragmentImpl *i, DocumentPtr *doc )
reset();
current = i;
inBody = true;
- inSelect = false;
}
KHTMLParser::~KHTMLParser()
@@ -167,8 +166,8 @@ void KHTMLParser::reset()
memset(forbiddenTag, 0, (ID_CLOSE_TAG+1)*sizeof(ushort));
inBody = false;
- noRealBody = true;
haveFrameSet = false;
+ haveContent = false;
inSelect = false;
_inline = false;
@@ -202,7 +201,7 @@ void KHTMLParser::parseToken(Token *t)
#ifdef PARSER_DEBUG
kdDebug( 6035 ) << "\n\n==> parser: processing token " << getTagName(t->id).string() << "(" << t->id << ")"
<< " current = " << getTagName(current->id()).string() << "(" << current->id() << ")" << endl;
- kdDebug(6035) << "inline=" << _inline << " inBody=" << inBody << " noRealBody=" << noRealBody << " haveFrameSet=" << haveFrameSet << endl;
+ kdDebug(6035) << "inline=" << _inline << " inBody=" << inBody << " haveFrameSet=" << haveFrameSet << endl;
#endif
// holy shit. apparently some sites use </br> instead of <br>
@@ -219,13 +218,11 @@ void KHTMLParser::parseToken(Token *t)
}
// ignore spaces, if we're not inside a paragraph or other inline code
- if( t->id == ID_TEXT ) {
+ if( t->id == ID_TEXT && t->text ) {
+ if(inBody && !skipMode() && t->text->l > 2) haveContent = true;
#ifdef PARSER_DEBUG
- if(t->text)
- kdDebug(6035) << "length="<< t->text->l << " text='" << QConstString(t->text->s, t->text->l).string() << "'" << endl;
+ kdDebug(6035) << "length="<< t->text->l << " text='" << QConstString(t->text->s, t->text->l).string() << "'" << endl;
#endif
-
- if ( inBody ) noRealBody = false;
}
NodeImpl *n = getElement(t);
@@ -390,7 +387,6 @@ bool KHTMLParser::insertNode(NodeImpl *n)
}
if ( changed )
doc()->recalcStyle( NodeImpl::Inherit );
- noRealBody = false;
}
return false;
}
@@ -440,7 +436,6 @@ bool KHTMLParser::insertNode(NodeImpl *n)
}
if ( changed )
doc()->recalcStyle( NodeImpl::Inherit );
- noRealBody = false;
} else if ( current->isDocumentNode() )
break;
return false;
@@ -757,7 +752,6 @@ NodeImpl *KHTMLParser::getElement(Token* t)
popBlock(ID_HEAD);
n = new HTMLBodyElementImpl(document);
startBody();
- noRealBody = false;
break;
// head elements
@@ -783,7 +777,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
break;
case ID_FRAMESET:
popBlock(ID_HEAD);
- if ( inBody && !haveFrameSet) {
+ if ( inBody && !haveFrameSet && !haveContent) {
popBlock( ID_BODY );
// ### actually for IE document.body returns the now hidden "body" element
// we can't implement that behaviour now because it could cause too many
@@ -793,14 +787,12 @@ NodeImpl *KHTMLParser::getElement(Token* t)
static_cast<HTMLDocumentImpl*>(document->document())->body()
->addCSSProperty(CSS_PROP_DISPLAY, "none");
inBody = false;
- noRealBody = true;
}
- if ( haveFrameSet && current->id() == ID_HTML )
+ if ( (haveContent || haveFrameSet) && current->id() == ID_HTML)
break;
n = new HTMLFrameSetElementImpl(document);
haveFrameSet = true;
startBody();
- noRealBody = false;
break;
// a bit a special case, since the frame is inlined...
case ID_IFRAME:
diff --git a/WebCore/khtml/html/htmlparser.h b/WebCore/khtml/html/htmlparser.h
index c2df0ce..124c787 100644
--- a/WebCore/khtml/html/htmlparser.h
+++ b/WebCore/khtml/html/htmlparser.h
@@ -82,8 +82,6 @@ public:
*/
void reset();
- bool parsingBody() const { return inBody; }
-
bool skipMode() const { return (discard_until != 0); }
bool noSpaces() const { return (!_inline || !inBody); }
bool selectMode() const { return inSelect; }
@@ -152,16 +150,14 @@ protected:
void startBody();
bool inBody;
- // in case we haven't found an explicit body element up to now, this is true.
- // needed for broken HTML as: <center><frameset>... as the center element creates an implicit body
- bool noRealBody;
+ bool haveContent;
bool haveFrameSet;
bool _inline;
bool end;
bool flat;
bool haveKonqBlock;
bool inSelect;
-
+
/*
* tells the parser to discard all tags, until it reaches the one specified
*/
diff --git a/WebCore/khtml/html/htmltokenizer.cpp b/WebCore/khtml/html/htmltokenizer.cpp
index 136f0d9..0e7df42 100644
--- a/WebCore/khtml/html/htmltokenizer.cpp
+++ b/WebCore/khtml/html/htmltokenizer.cpp
@@ -66,6 +66,7 @@ static const char scriptEnd [] = "</script";
static const char xmpEnd [] = "</xmp";
static const char styleEnd [] = "</style";
static const char textareaEnd [] = "</textarea";
+static const char titleEnd [] = "</title";
#define KHTML_ALLOC_QCHAR_VEC( N ) (QChar*) malloc( sizeof(QChar)*( N ) )
#define KHTML_REALLOC_QCHAR_VEC(P, N ) (QChar*) P = realloc(p, sizeof(QChar)*( N ))
@@ -217,6 +218,7 @@ void HTMLTokenizer::begin()
comment = false;
server = false;
textarea = false;
+ title = false;
startTag = false;
tquote = NoQuote;
searchCount = 0;
@@ -284,6 +286,7 @@ void HTMLTokenizer::processListing(DOMStringIt list)
pending = SpacePending;
else
pending = TabPending;
+
++list;
}
else
@@ -308,27 +311,20 @@ void HTMLTokenizer::processListing(DOMStringIt list)
pre = old_pre;
}
-void HTMLTokenizer::parseSpecial(DOMStringIt &src, bool begin)
+void HTMLTokenizer::parseSpecial(DOMStringIt &src)
{
- assert( textarea || !Entity );
+ assert( textarea || title || !Entity );
assert( !tag );
- assert( xmp+textarea+style+script == 1 );
+ assert( xmp+textarea+title+style+script == 1 );
if (script)
scriptStartLineno = lineno+src.lineCount();
- if ( begin ) {
- if ( script ) { searchStopper = scriptEnd; }
- else if ( style ) { searchStopper = styleEnd; }
- else if ( textarea ) { searchStopper = textareaEnd; }
- else if ( xmp ) { searchStopper = xmpEnd; }
- searchStopperLen = strlen( searchStopper );
- }
if ( comment ) parseComment( src );
while ( src.length() ) {
checkScriptBuffer();
unsigned char ch = src->latin1();
- if ( !scriptCodeResync && !brokenComments && !textarea && !xmp && ch == '-' && scriptCodeSize >= 3 && !src.escaped() && QConstString( scriptCode+scriptCodeSize-3, 3 ).string() == "<!-" ) {
+ if ( !scriptCodeResync && !brokenComments && !textarea && !xmp && !title && ch == '-' && scriptCodeSize >= 3 && !src.escaped() && QConstString( scriptCode+scriptCodeSize-3, 3 ).string() == "<!-" ) {
comment = true;
parseComment( src );
continue;
@@ -345,9 +341,11 @@ void HTMLTokenizer::parseSpecial(DOMStringIt &src, bool begin)
processToken();
if ( style ) { currToken.id = ID_STYLE + ID_CLOSE_TAG; }
else if ( textarea ) { currToken.id = ID_TEXTAREA + ID_CLOSE_TAG; }
+ else if ( title ) { currToken.id = ID_TITLE + ID_CLOSE_TAG; }
else if ( xmp ) { currToken.id = ID_XMP + ID_CLOSE_TAG; }
processToken();
- style = script = style = textarea = xmp = false;
+ style = script = style = textarea = title = xmp = false;
+ tquote = NoQuote;
scriptCodeSize = scriptCodeResync = 0;
}
return;
@@ -369,7 +367,7 @@ void HTMLTokenizer::parseSpecial(DOMStringIt &src, bool begin)
tquote = NoQuote;
}
escaped = ( !escaped && ch == '\\' );
- if (!scriptCodeResync && textarea && !src.escaped() && ch == '&') {
+ if (!scriptCodeResync && (textarea||title) && !src.escaped() && ch == '&') {
QChar *scriptCodeDest = scriptCode+scriptCodeSize;
++src;
parseEntity(src,scriptCodeDest,true);
@@ -443,8 +441,13 @@ void HTMLTokenizer::scriptHandler()
scriptCodeSize = scriptCodeResync = 0;
if ( !parser->skipMode() ) {
- if ( !m_executingScript && !loadingExtScript )
- addPendingSource();
+ if ( !m_executingScript && !loadingExtScript ) {
+ // kdDebug( 6036 ) << "adding pending Output to parsed string" << endl;
+ QString newStr = QString(src.current(), src.length());
+ newStr += pendingSrc;
+ setSrc(newStr);
+ pendingSrc = "";
+ }
else if ( !prependingSrc.isEmpty() )
write( prependingSrc, false );
}
@@ -482,7 +485,7 @@ void HTMLTokenizer::parseComment(DOMStringIt &src)
QConstString((QChar*)src.current(), QMIN(16, src.length())).string().latin1());
#endif
if (src->unicode() == '>' &&
- ( ( brokenComments && !( script || style || textarea || xmp ) ) ||
+ ( ( brokenComments && !( script || style ) ) ||
( scriptCodeSize > 2 && scriptCode[scriptCodeSize-3] == '-' &&
scriptCode[scriptCodeSize-2] == '-' ) ) ) {
++src;
@@ -1075,13 +1078,12 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
return;
uint tagID = currToken.id;
- bool flat = currToken.flat;
#if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 0
kdDebug( 6036 ) << "appending Tag: " << tagID << endl;
#endif
- bool beginTag = tagID < ID_CLOSE_TAG;
+ bool beginTag = !currToken.flat && (tagID < ID_CLOSE_TAG);
- if(!beginTag)
+ if(tagID >= ID_CLOSE_TAG)
tagID -= ID_CLOSE_TAG;
else if ( beginTag && tagID == ID_SCRIPT ) {
AttributeImpl* a = 0;
@@ -1125,21 +1127,45 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
prePos = 0;
pre = beginTag;
break;
- case ID_TEXTAREA:
- if(beginTag && !flat)
- parseSpecial(src, textarea = true );
- break;
case ID_SCRIPT:
- if (beginTag && !flat)
- parseSpecial(src, script = true);
+ if (beginTag) {
+ searchStopper = scriptEnd;
+ searchStopperLen = 8;
+ script = true;
+ parseSpecial(src);
+ }
break;
case ID_STYLE:
- if (beginTag && !flat)
- parseSpecial(src, style = true);
+ if (beginTag) {
+ searchStopper = styleEnd;
+ searchStopperLen = 7;
+ style = true;
+ parseSpecial(src);
+ }
+ break;
+ case ID_TEXTAREA:
+ if(beginTag) {
+ searchStopper = textareaEnd;
+ searchStopperLen = 10;
+ textarea = true;
+ parseSpecial(src);
+ }
+ break;
+ case ID_TITLE:
+ if (beginTag) {
+ searchStopper = titleEnd;
+ searchStopperLen = 7;
+ title = true;
+ parseSpecial(src);
+ }
break;
case ID_XMP:
- if (beginTag && !flat)
- parseSpecial(src, xmp = true);
+ if (beginTag) {
+ searchStopper = xmpEnd;
+ searchStopperLen = 5;
+ xmp = true;
+ parseSpecial(src);
+ }
break;
case ID_SELECT:
select = beginTag;
@@ -1163,10 +1189,13 @@ void HTMLTokenizer::addPending()
}
else if ( textarea )
{
- if (pending == LFPending)
- *dest++ = '\n';
- else
- *dest++ = ' ';
+ switch(pending) {
+ case LFPending: *dest++ = '\n'; prePos = 0; break;
+ case SpacePending: *dest++ = ' '; ++prePos; break;
+ case TabPending: *dest++ = '\t'; prePos += TAB_SIZE - (prePos % TAB_SIZE); break;
+ case NonePending:
+ assert(0);
+ }
}
else if ( pre )
{
@@ -1188,18 +1217,17 @@ void HTMLTokenizer::addPending()
case TabPending:
p = TAB_SIZE - ( prePos % TAB_SIZE );
+#ifdef TOKEN_DEBUG
+ qDebug("tab pending, prePos: %d, toadd: %d", prePos, p);
+#endif
+
for ( int x = 0; x < p; x++ )
- {
- *dest = QChar(' ');
- dest++;
- }
+ *dest++ = QChar(' ');
prePos += p;
break;
- default:
-#if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
- kdDebug( 6036 ) << "Assertion failed: pending = " << (int) pending << endl;
-#endif
+ case NonePending:
+ assert(0);
break;
}
}
@@ -1258,13 +1286,15 @@ void HTMLTokenizer::write( const QString &str, bool appendData )
else if ( plaintext )
parseText( src );
else if (script)
- parseSpecial(src, false);
+ parseSpecial(src);
else if (style)
- parseSpecial(src, false);
+ parseSpecial(src);
else if (xmp)
- parseSpecial(src, false);
+ parseSpecial(src);
else if (textarea)
- parseSpecial(src, false);
+ parseSpecial(src);
+ else if (title)
+ parseSpecial(src);
else if (comment)
parseComment(src);
else if (server)
@@ -1530,7 +1560,7 @@ void HTMLTokenizer::processToken()
if ( dest > buffer )
{
#ifdef TOKEN_DEBUG
- if(currToken.id && currToken.id != ID_COMMENT) {
+ if(currToken.id) {
qDebug( "unexpected token id: %d, str: *%s*", currToken.id,QConstString( buffer,dest-buffer ).string().latin1() );
assert(0);
}
@@ -1538,8 +1568,7 @@ void HTMLTokenizer::processToken()
#endif
currToken.text = new DOMStringImpl( buffer, dest - buffer );
currToken.text->ref();
- if (currToken.id != ID_COMMENT)
- currToken.id = ID_TEXT;
+ currToken.id = ID_TEXT;
}
else if(!currToken.id) {
currToken.reset();
@@ -1642,15 +1671,6 @@ void HTMLTokenizer::notifyFinished(CachedObject */*finishedObj*/)
}
}
-void HTMLTokenizer::addPendingSource()
-{
-// kdDebug( 6036 ) << "adding pending Output to parsed string" << endl;
- QString newStr = QString(src.current(), src.length());
- newStr += pendingSrc;
- setSrc(newStr);
- pendingSrc = "";
-}
-
void HTMLTokenizer::setSrc(QString source)
{
lineno += src.lineCount();
@@ -1662,8 +1682,7 @@ void HTMLTokenizer::setOnHold(bool _onHold)
{
if (onHold == _onHold) return;
onHold = _onHold;
- if (!onHold)
- write( _src, true );
+ if (onHold)
+ setSrc(QString(src.current(), src.length())); // ### deep copy
}
-#include "htmltokenizer.moc"
diff --git a/WebCore/khtml/html/htmltokenizer.h b/WebCore/khtml/html/htmltokenizer.h
index c3ea931..2e3019b 100644
--- a/WebCore/khtml/html/htmltokenizer.h
+++ b/WebCore/khtml/html/htmltokenizer.h
@@ -126,7 +126,6 @@ namespace khtml {
class HTMLTokenizer : public Tokenizer, public khtml::CachedObjectClient
{
- Q_OBJECT
public:
HTMLTokenizer(DOM::DocumentPtr *, KHTMLView * = 0);
HTMLTokenizer(DOM::DocumentPtr *, DOM::DocumentFragmentImpl *frag);
@@ -148,14 +147,13 @@ protected:
void parseServer(khtml::DOMStringIt &str);
void parseText(khtml::DOMStringIt &str);
void parseListing(khtml::DOMStringIt &str);
- void parseSpecial(khtml::DOMStringIt &str, bool begin);
+ void parseSpecial(khtml::DOMStringIt &str);
void parseTag(khtml::DOMStringIt &str);
void parseEntity(khtml::DOMStringIt &str, QChar *&dest, bool start = false);
void parseProcessingInstruction(khtml::DOMStringIt &str);
void scriptHandler();
void scriptExecution(const QString& script, QString scriptURL = QString(),
int baseLine = 0);
- void addPendingSource();
void setSrc(QString source);
// check if we have enough space in the buffer.
@@ -266,6 +264,9 @@ protected:
// Are we in a <xmp> ... </xmp> block
bool xmp;
+ // Are we in a <title> ... </title> block
+ bool title;
+
// Are we in plain textmode ?
bool plaintext;
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index fd4efe9..b054bf3 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -285,8 +285,8 @@ KHTMLPart::~KHTMLPart()
if ( d->m_job )
d->m_job->kill();
- if ( d->m_doc && d->m_doc->docLoader() )
- khtml::Cache::loader()->cancelRequests( d->m_doc->docLoader() );
+ if (!d->m_bComplete)
+ closeURL();
disconnect( khtml::Cache::loader(), SIGNAL( requestStarted( khtml::DocLoader*, khtml::CachedObject* ) ),
this, SLOT( slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* ) ) );
@@ -334,8 +334,6 @@ bool KHTMLPart::restoreURL( const KURL &url )
d->m_bLoadEventEmitted = false;
d->m_workingURL = url;
- d->m_restored = true;
-
// set the java(script) flags according to the current host.
d->m_bJScriptEnabled = KHTMLFactory::defaultHTMLSettings()->isJavaScriptEnabled(url.host());
d->m_bJScriptDebugEnabled = KHTMLFactory::defaultHTMLSettings()->isJavaScriptDebugEnabled();
@@ -423,13 +421,21 @@ bool KHTMLPart::openURL( const KURL &url )
return true;
}
- kdDebug( 6050 ) << "closing old URL" << endl;
- closeURL();
+ if (!d->m_restored)
+ {
+ kdDebug( 6050 ) << "closing old URL" << endl;
+ closeURL();
+ }
args.metaData().insert("main_frame_request", parentPart() == 0 ? "TRUE" : "FALSE" );
args.metaData().insert("ssl_was_in_use", d->m_ssl_in_use ? "TRUE" : "FALSE" );
args.metaData().insert("ssl_activate_warnings", "TRUE" );
- d->m_bReloading = args.reload;
+ if (d->m_restored)
+ d->m_cachePolicy = KIO::CC_Cache;
+ else if (args.reload)
+ d->m_cachePolicy = KIO::CC_Refresh;
+ else
+ d->m_cachePolicy = KIO::CC_Verify;
if ( args.doPost() && (url.protocol().startsWith("http")) )
{
@@ -437,7 +443,10 @@ bool KHTMLPart::openURL( const KURL &url )
d->m_job->addMetaData("content-type", args.contentType() );
}
else
- d->m_job = KIO::get( url, args.reload, false );
+ {
+ d->m_job = KIO::get( url, false, false );
+ d->m_job->addMetaData("cache", KIO::getCacheControlString(d->m_cachePolicy));
+ }
d->m_job->addMetaData(args.metaData());
@@ -451,7 +460,6 @@ bool KHTMLPart::openURL( const KURL &url )
d->m_bComplete = false;
d->m_bLoadEventEmitted = false;
- d->m_restored = false;
// delete old status bar msg's from kjs (if it _was_ activated on last URL)
if( d->m_bJScriptEnabled )
@@ -514,7 +522,7 @@ bool KHTMLPart::closeURL()
d->m_bComplete = true; // to avoid emitting completed() in slotFinishedParsing() (David)
d->m_bLoadEventEmitted = true; // don't want that one either
- d->m_bReloading = false;
+ d->m_cachePolicy = KIO::CC_Verify; // Why here?
KHTMLPageCache::self()->cancelFetch(this);
if ( d->m_doc && d->m_doc->parsing() )
@@ -739,7 +747,7 @@ KJavaAppletContext *KHTMLPart::createJavaContext()
{
#ifndef Q_WS_QWS
if ( !d->m_javaContext ) {
- d->m_javaContext = new KJavaAppletContext();
+ d->m_javaContext = new KJavaAppletContext(d->m_dcopobject);
connect( d->m_javaContext, SIGNAL(showStatus(const QString&)),
this, SIGNAL(setStatusBarText(const QString&)) );
connect( d->m_javaContext, SIGNAL(showDocument(const QString&, const QString&)),
@@ -878,7 +886,6 @@ bool KHTMLPart::autoloadImages() const
void KHTMLPart::clear()
{
- kdDebug( 6090 ) << "KHTMLPart::clear() this = " << this << endl;
if ( d->m_bCleared )
return;
d->m_bCleared = true;
@@ -916,10 +923,7 @@ void KHTMLPart::clear()
if ( d->m_doc )
- {
- kdDebug( 6090 ) << "KHTMLPart::clear(): detaching the document " << d->m_doc << endl;
d->m_doc->detach();
- }
// Moving past doc so that onUnload works.
if ( d->m_jscript )
@@ -931,14 +935,10 @@ void KHTMLPart::clear()
// do not dereference the document before the jscript and view are cleared, as some destructors
// might still try to access the document.
if ( d->m_doc )
- {
- kdDebug( 6090 ) << "KHTMLPart::clear(): dereferencing the document " << d->m_doc << endl;
d->m_doc->deref();
- }
d->m_doc = 0;
delete d->m_decoder;
-
d->m_decoder = 0;
#ifndef APPLE_CHANGES
@@ -966,6 +966,7 @@ void KHTMLPart::clear()
d->m_delayRedirect = 0;
d->m_redirectURL = QString::null;
+ d->m_redirectLockHistory = true;
d->m_bHTTPRefresh = false;
d->m_bClearing = false;
d->m_frameNameId = 1;
@@ -1028,7 +1029,8 @@ void KHTMLPart::slotData( KIO::Job* kio_job, const QByteArray &data )
begin( d->m_workingURL, d->m_extension->urlArgs().xOffset, d->m_extension->urlArgs().yOffset );
- d->m_doc->docLoader()->setReloading(d->m_bReloading);
+
+ d->m_doc->docLoader()->setCachePolicy(d->m_cachePolicy);
d->m_workingURL = KURL();
d->m_cacheId = KHTMLPageCache::self()->createCacheEntry();
@@ -1178,15 +1180,21 @@ void KHTMLPart::htmlError( int errorCode, const QString& text, const KURL& reqUr
d->m_bJScriptOverride = true;
begin();
QString errText = QString::fromLatin1( "<HTML><HEAD><TITLE>" );
- errText += i18n( "Error while loading %1" ).arg( reqUrl.prettyURL() );
+ errText += i18n( "Error while loading %1" ).arg( reqUrl.htmlURL() );
errText += QString::fromLatin1( "</TITLE></HEAD><BODY><P>" );
- errText += i18n( "An error occured while loading <B>%1</B>:" ).arg( reqUrl.prettyURL() );
+ errText += i18n( "An error occured while loading <B>%1</B>:" ).arg( reqUrl.htmlURL() );
errText += QString::fromLatin1( "</P><P>" );
QString kioErrString = KIO::buildErrorString( errorCode, text );
+
+ kioErrString.replace(QRegExp("&"), QString("&"));
+ kioErrString.replace(QRegExp("<"), QString("<"));
+ kioErrString.replace(QRegExp(">"), QString(">"));
+
// In case the error string has '\n' in it, replace with <BR/>
kioErrString.replace( QRegExp("\n"), "<BR/>" );
+
errText += kioErrString;
- errText += QString::fromLatin1( "</PRE></P></BODY></HTML>" );
+ errText += QString::fromLatin1( "</P></BODY></HTML>" );
write(errText);
end();
@@ -1700,18 +1708,17 @@ KURL KHTMLPart::completeURL( const QString &url )
return KURL( d->m_doc->completeURL( url ) );
}
-// ### implement lockhistory being optional (sometimes javascript wants
-// to do redirection that end up in the history!)
-void KHTMLPart::scheduleRedirection( int delay, const QString &url, bool /* doLockHistory*/ )
+void KHTMLPart::scheduleRedirection( int delay, const QString &url, bool doLockHistory )
{
#ifdef APPLE_CHANGES
impl->scheduleRedirection(delay, url);
#else
- //kdDebug(6050) << "KHTMLPart::scheduleRedirection delay=" << delay << " url=" << url << endl;
+ kdDebug(6050) << "KHTMLPart::scheduleRedirection delay=" << delay << " url=" << url << endl;
if( d->m_redirectURL.isEmpty() || delay < d->m_delayRedirect )
{
d->m_delayRedirect = delay;
d->m_redirectURL = url;
+ d->m_redirectLockHistory = doLockHistory;
if ( d->m_bComplete ) {
d->m_redirectionTimer.stop();
d->m_redirectionTimer.start( 1000 * d->m_delayRedirect, true );
@@ -1744,7 +1751,7 @@ void KHTMLPart::slotRedirect()
if ( urlcmp( u, m_url.url(), true, true ) )
args.reload = true;
- args.setLockHistory( true );
+ args.setLockHistory( d->m_redirectLockHistory );
urlSelected( u, 0, 0, QString::null, args );
#endif
}
@@ -1768,7 +1775,9 @@ bool KHTMLPart::setEncoding( const QString &name, bool override )
closeURL();
KURL url = m_url;
m_url = 0;
+ d->m_restored = true;
openURL(url);
+ d->m_restored = false;
}
#endif
@@ -1965,11 +1974,13 @@ bool KHTMLPart::findTextNext( const QString &str, bool forward, bool caseSensiti
QString KHTMLPart::selectedText() const
{
+ bool hasNewLine = true;
QString text;
DOM::Node n = d->m_selectionStart;
while(!n.isNull()) {
if(n.nodeType() == DOM::Node::TEXT_NODE) {
QString str = n.nodeValue().string();
+ hasNewLine = false;
if(n == d->m_selectionStart && n == d->m_selectionEnd)
text = str.mid(d->m_startOffset, d->m_endOffset - d->m_startOffset);
else if(n == d->m_selectionStart)
@@ -1983,9 +1994,13 @@ QString KHTMLPart::selectedText() const
// This is our simple HTML -> ASCII transformation:
unsigned short id = n.elementId();
switch(id) {
+ case ID_BR:
+ text += "\n";
+ hasNewLine = true;
+ break;
+
case ID_TD:
case ID_TH:
- case ID_BR:
case ID_HR:
case ID_OL:
case ID_UL:
@@ -1995,7 +2010,10 @@ QString KHTMLPart::selectedText() const
case ID_DT:
case ID_PRE:
case ID_BLOCKQUOTE:
- text += "\n";
+ case ID_DIV:
+ if (!hasNewLine)
+ text += "\n";
+ hasNewLine = true;
break;
case ID_P:
case ID_TR:
@@ -2005,7 +2023,10 @@ QString KHTMLPart::selectedText() const
case ID_H4:
case ID_H5:
case ID_H6:
- text += "\n\n";
+ if (!hasNewLine)
+ text += "\n";
+ text += "\n";
+ hasNewLine = true;
break;
}
}
@@ -2015,11 +2036,54 @@ QString KHTMLPart::selectedText() const
while( next.isNull() && !n.parentNode().isNull() ) {
n = n.parentNode();
next = n.nextSibling();
+ unsigned short id = n.elementId();
+ switch(id) {
+ case ID_TD:
+ case ID_TH:
+ case ID_HR:
+ case ID_OL:
+ case ID_UL:
+ case ID_LI:
+ case ID_DD:
+ case ID_DL:
+ case ID_DT:
+ case ID_PRE:
+ case ID_BLOCKQUOTE:
+ case ID_DIV:
+ if (!hasNewLine)
+ text += "\n";
+ hasNewLine = true;
+ break;
+ case ID_P:
+ case ID_TR:
+ case ID_H1:
+ case ID_H2:
+ case ID_H3:
+ case ID_H4:
+ case ID_H5:
+ case ID_H6:
+ if (!hasNewLine)
+ text += "\n";
+ text += "\n";
+ hasNewLine = true;
+ break;
+ }
}
n = next;
}
- return text;
+ int start = 0;
+ int end = text.length();
+
+ // Strip leading LFs
+ while ((start < end) && (text[start] == '\n'))
+ start++;
+
+ // Strip excessive trailing LFs
+ while ((start < (end-1)) && (text[end-1] == '\n') && (text[end-2] == '\n'))
+ end--;
+
+ return text.mid(start, end-start);
}
bool KHTMLPart::hasSelection() const
@@ -2188,7 +2252,7 @@ void KHTMLPart::overURL( const QString &url, const QString &target, bool shiftPr
mailtoMsg += i18n(" - CC: ") + KURL::decode_string((*it).mid(3));
else if ((*it).startsWith(QString::fromLatin1("bcc=")))
mailtoMsg += i18n(" - BCC: ") + KURL::decode_string((*it).mid(4));
- emit setStatusBarText(mailtoMsg);
+ emit setStatusBarText(mailtoMsg.replace(QRegExp("([\n\r\t]|[ ]{10})"), ""));
return;
}
// Is this check neccessary at all? (Frerich)
@@ -2265,15 +2329,10 @@ void KHTMLPart::urlSelected( const QString &url, int button, int state, const QS
args.frameName = target;
- // For http-refresh, force the io-slave to re-get the page
- // as needed instead of loading from cache. NOTE: I would
- // have done a "verify" instead, but I am not sure that servers
- // will include the correct response (specfically "Refresh:") on
- // a "HEAD" request which is what a "verify" setting results in.(DA)
if ( d->m_bHTTPRefresh )
{
d->m_bHTTPRefresh = false;
- args.metaData()["cache"]="reload"; //"verify";
+ args.metaData()["cache"] = "refresh";
}
args.metaData().insert("main_frame_request",
@@ -2620,7 +2679,7 @@ bool KHTMLPart::requestObject( khtml::ChildFrame *child, const KURL &url, const
args.serviceType = child->m_serviceType;
child->m_args = args;
- child->m_args.reload = d->m_bReloading;
+ child->m_args.reload = (d->m_cachePolicy == KIO::CC_Reload) || (d->m_cachePolicy == KIO::CC_Refresh);
child->m_serviceName = QString::null;
if (!d->m_referrer.isEmpty() && !child->m_args.metaData().contains( "referrer" ))
child->m_args.metaData()["referrer"] = d->m_referrer;
@@ -2766,7 +2825,7 @@ bool KHTMLPart::processObjectRequest( khtml::ChildFrame *child, const KURL &_url
return true;
}
- child->m_args.reload = d->m_bReloading;
+ child->m_args.reload = (d->m_cachePolicy == KIO::CC_Reload) || (d->m_cachePolicy == KIO::CC_Refresh);
// make sure the part has a way to find out about the mimetype.
// we actually set it in child->m_args in requestObject already,
@@ -2895,7 +2954,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
*/
// This causes crashes... needs to be fixed.
- if (u.protocol() != "https") {
+ if (u.protocol() != "https" && u.protocol() != "mailto") {
if (d->m_ssl_in_use) { // Going from SSL -> nonSSL
int rc = KMessageBox::warningContinueCancel(NULL, i18n("Warning: This is a secure form but it is attempting to send your data back unencrypted."
"\nA third party may be able to intercept and view this information."
@@ -2929,6 +2988,18 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
}
}
+ if (u.protocol() == "mailto") {
+ int rc = KMessageBox::warningContinueCancel(NULL,
+ i18n("This site is attempting to submit form data via email."),
+ i18n("KDE"),
+ QString::null,
+ "WarnTriedEmailSubmit");
+
+ if (rc == KMessageBox::Cancel) {
+ return;
+ }
+ }
+
// End form security checks
//
@@ -2956,8 +3027,53 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
args.metaData().insert("ssl_activate_warnings", "TRUE");
args.frameName = _target.isEmpty() ? d->m_doc->baseTarget() : _target ;
+ // Handle mailto: forms
+ if (u.protocol() == "mailto") {
+ // 1) Check for attach= and strip it
+ QString q = u.query().mid(1);
+ QStringList nvps = QStringList::split("&", q);
+ bool triedToAttach = false;
+
+ for (QStringList::Iterator nvp = nvps.begin(); nvp != nvps.end(); ++nvp) {
+ QStringList pair = QStringList::split("=", *nvp);
+ if (pair.count() >= 2) {
+ if (pair.first().lower() == "attach") {
+ nvp = nvps.remove(nvp);
+ triedToAttach = true;
+ }
+ }
+ }
+
+ if (triedToAttach)
+ KMessageBox::information(NULL, i18n("This site attempted to attach a file from your computer in the form submission. The attachment was removed for your protection."), i18n("KDE"), "WarnTriedAttach");
+
+ // 2) Append body=
+ QString bodyEnc;
+ if (contentType.lower() == "multipart/form-data") {
+ // FIXME: is this correct? I suspect not
+ bodyEnc = KURL::encode_string(QString::fromLatin1(formData.data(),
+ formData.size()));
+ } else if (contentType.lower() == "text/plain") {
+ // Convention seems to be to decode, and s/&/\n/
+ QString tmpbody = QString::fromLatin1(formData.data(),
+ formData.size());
+ tmpbody.replace(QRegExp("[&]"), "\n");
+ tmpbody.replace(QRegExp("[+]"), " ");
+ tmpbody = KURL::decode_string(tmpbody); // Decode the rest of it
+ bodyEnc = KURL::encode_string(tmpbody); // Recode for the URL
+ } else {
+ bodyEnc = KURL::encode_string(QString::fromLatin1(formData.data(),
+ formData.size()));
+ }
+
+ nvps.append(QString("body=%1").arg(bodyEnc));
+ q = nvps.join("&");
+ u.setQuery(q);
+ }
+
if ( strcmp( action, "get" ) == 0 ) {
- u.setQuery( QString::fromLatin1( formData.data(), formData.size() ) );
+ if (u.protocol() != "mailto")
+ u.setQuery( QString::fromLatin1( formData.data(), formData.size() ) );
args.setDoPost( false );
}
else {
@@ -3506,15 +3622,18 @@ void KHTMLPart::restoreState( QDataStream &stream )
args.yOffset = yOffset;
args.docState = docState;
d->m_extension->setURLArgs( args );
-// kdDebug( 6050 ) << "in restoreState : calling openURL for " << u.url() << endl;
if (!KHTMLPageCache::self()->isValid(d->m_cacheId))
+ {
+ d->m_restored = true;
openURL( u );
+ d->m_restored = false;
+ }
else
+ {
restoreURL( u );
+ }
}
- d->m_restored = true;
-
}
#endif
@@ -4343,7 +4462,7 @@ bool KHTMLPart::checkLinkSecurity(const KURL &linkURL,const QString &message, co
}
if (tokenizer)
- tokenizer->setOnHold(false);
+ tokenizer->setOnHold(false);
return (response==KMessageBox::Continue);
}
return true;
diff --git a/WebCore/khtml/khtmlpart_p.h b/WebCore/khtml/khtmlpart_p.h
index 5e4d026..480c3f0 100644
--- a/WebCore/khtml/khtmlpart_p.h
+++ b/WebCore/khtml/khtmlpart_p.h
@@ -105,7 +105,7 @@ public:
m_job = 0L;
m_bComplete = true;
m_bLoadEventEmitted = true;
- m_bReloading = false;
+ m_cachePolicy = KIO::CC_Verify;
m_manager = 0L;
m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
m_bClearing = false;
@@ -254,13 +254,14 @@ public:
bool m_bComplete:1;
bool m_bLoadEventEmitted:1;
- bool m_bReloading:1;
bool m_haveEncoding:1;
bool m_bHTTPRefresh:1;
bool m_onlyLocalReferences :1;
+ bool m_redirectLockHistory:1;
KURL m_workingURL;
+ KIO::CacheControl m_cachePolicy;
QTimer m_redirectionTimer;
QTime m_parsetime;
int m_delayRedirect;
diff --git a/WebCore/khtml/khtmlview.cpp b/WebCore/khtml/khtmlview.cpp
index 1c741fe..229ba6c 100644
--- a/WebCore/khtml/khtmlview.cpp
+++ b/WebCore/khtml/khtmlview.cpp
@@ -131,8 +131,8 @@ public:
borderY = 30;
clickX = -1;
clickY = -1;
- prevMouseX = -1;
- prevMouseY = -1;
+ prevMouseX = -1;
+ prevMouseY = -1;
clickCount = 0;
isDoubleClick = false;
scrollingSelf = false;
@@ -465,20 +465,10 @@ void KHTMLView::viewportMousePressEvent( QMouseEvent *_mouse )
//kdDebug( 6000 ) << "\nmousePressEvent: x=" << xm << ", y=" << ym << endl;
-
- // Make this frame the active one
- // ### need some visual indication for the active frame.
- /* ### use PartManager (Simon)
- if ( _isFrame && !_isSelected )
- {
- kdDebug( 6000 ) << "activating frame!" << endl;
- topView()->setFrameSelected(this);
- }*/
-
d->isDoubleClick = false;
DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MousePress );
- m_part->xmlDocImpl()->prepareMouseEvent( xm, ym, &mev );
+ m_part->xmlDocImpl()->prepareMouseEvent( false, xm, ym, &mev );
if (d->clickCount > 0 &&
QPoint(d->clickX-xm,d->clickY-ym).manhattanLength() <= QApplication::startDragDistance())
@@ -514,7 +504,7 @@ void KHTMLView::viewportMouseDoubleClickEvent( QMouseEvent *_mouse )
d->isDoubleClick = true;
DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MouseDblClick );
- m_part->xmlDocImpl()->prepareMouseEvent( xm, ym, &mev );
+ m_part->xmlDocImpl()->prepareMouseEvent( false, xm, ym, &mev );
// We do the same thing as viewportMousePressEvent() here, since the DOM does not treat
// single and double-click events as separate (only the detail, i.e. number of clicks differs)
@@ -551,7 +541,7 @@ void KHTMLView::viewportMouseMoveEvent( QMouseEvent * _mouse )
viewportToContents(_mouse->x(), _mouse->y(), xm, ym);
DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MouseMove );
- m_part->xmlDocImpl()->prepareMouseEvent( xm, ym, &mev );
+ m_part->xmlDocImpl()->prepareMouseEvent( false, xm, ym, &mev );
bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEMOVE_EVENT,mev.innerNode.handle(),false,
0,_mouse,true,DOM::NodeImpl::MouseMove);
@@ -652,7 +642,7 @@ void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
//kdDebug( 6000 ) << "\nmouseReleaseEvent: x=" << xm << ", y=" << ym << endl;
DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MouseRelease );
- m_part->xmlDocImpl()->prepareMouseEvent( xm, ym, &mev );
+ m_part->xmlDocImpl()->prepareMouseEvent( false, xm, ym, &mev );
bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEUP_EVENT,mev.innerNode.handle(),true,
d->clickCount,_mouse,false,DOM::NodeImpl::MouseRelease);
@@ -788,6 +778,8 @@ void KHTMLView::keyReleaseEvent(QKeyEvent *_ke)
void KHTMLView::contentsContextMenuEvent ( QContextMenuEvent *_ce )
{
+// ### what kind of c*** is that ?
+#if 0
if (!m_part->xmlDocImpl()) return;
int xm = _ce->x();
int ym = _ce->y();
@@ -806,12 +798,11 @@ void KHTMLView::contentsContextMenuEvent ( QContextMenuEvent *_ce )
QWidget *w = static_cast<RenderWidget*>(targetNode->renderer())->widget();
#endif
QContextMenuEvent cme(_ce->reason(),pos,_ce->globalPos(),_ce->state());
-// ### what kind of c*** is that ?
-// setIgnoreEvents(true);
-// QApplication::sendEvent(w,&cme);
-// setIgnoreEvents(false);
+ setIgnoreEvents(true);
+ QApplication::sendEvent(w,&cme);
+ setIgnoreEvents(false);
}
-
+#endif
}
bool KHTMLView::focusNextPrevChild( bool next )
@@ -1288,18 +1279,19 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
bool ctrlKey = (_mouse->state() & ControlButton);
bool altKey = (_mouse->state() & AltButton);
bool shiftKey = (_mouse->state() & ShiftButton);
- bool metaKey = (_mouse->state() & MetaButton);
+ bool metaKey = (_mouse->state() & MetaButton);
// mouseout/mouseover
if (setUnder && (d->prevMouseX != clientX || d->prevMouseY != clientY)) {
- NodeImpl *oldUnder = 0;
+ // ### this code sucks. we should save the oldUnder instead of calculating
+ // it again. calculating is expensive! (Dirk)
+ NodeImpl *oldUnder = 0;
if (d->prevMouseX >= 0 && d->prevMouseY >= 0) {
NodeImpl::MouseEvent mev( _mouse->stateAfter(), static_cast<NodeImpl::MouseEventType>(mouseEventType));
- m_part->xmlDocImpl()->prepareMouseEvent( d->prevMouseX, d->prevMouseY, &mev );
+ m_part->xmlDocImpl()->prepareMouseEvent( true, d->prevMouseX, d->prevMouseY, &mev );
oldUnder = mev.innerNode.handle();
}
-
if (oldUnder != targetNode) {
// send mouseout event to the old node
if (oldUnder){
@@ -1327,9 +1319,9 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
me->deref();
}
- if (oldUnder)
- oldUnder->deref();
- }
+ if (oldUnder)
+ oldUnder->deref();
+ }
}
bool swallowEvent = false;
diff --git a/WebCore/khtml/misc/helper.cpp b/WebCore/khtml/misc/helper.cpp
index 59c9f8e..7caedd3 100644
--- a/WebCore/khtml/misc/helper.cpp
+++ b/WebCore/khtml/misc/helper.cpp
@@ -34,122 +34,164 @@
using namespace DOM;
using namespace khtml;
-// ### make it const if possible...
- struct HTMLColors {
+struct HTMLColors {
QMap<QString,QColor> map;
- HTMLColors()
- {
- map["black"] = "#000000";
- map["green"] = "#008000";
- map["silver"] = "#c0c0c0";
- map["lime"] = "#00ff00";
- map["gray"] = "#808080";
- map["olive"] = "#808000";
- map["white"] = "#ffffff";
- map["yellow"] = "#ffff00";
- map["maroon"] = "#800000";
- map["navy"] = "#000080";
- map["red"] = "#ff0000";
- map["blue"] = "#0000ff";
- map["purple"] = "#800080";
- map["teal"] = "#008080";
- map["fuchsia"] = "#ff00ff";
- map["aqua"] = "#00ffff";
- map["crimson"] = "#dc143c";
- map["indigo"] = "#4b0082";
- // ### react to style changes
- // see http://www.richinstyle.com for details
-
- /* Mapping system settings to CSS 2
- * Tried hard to get an appropriate mapping - schlpbch
- */
-
- KConfig *globalConfig = KGlobal::config();
- globalConfig->setGroup("WM");
-
- QColorGroup cg = kapp->palette().active();
+ HTMLColors();
+};
- // Active window border.
- map["activeborder"] = globalConfig->readColorEntry( "background", &cg.light());
- // Active window caption.
- map["activecaption"] = globalConfig->readColorEntry( "activeBackground", &cg.text());
- // Text in caption, size box, and scrollbar arrow box.
- map["captiontext"] = globalConfig->readColorEntry( "activeForeground", &cg.text());
+struct colorMap {
+ const char * name;
+ const char * value;
+};
- cg = kapp->palette().inactive();
+static const colorMap cmap[] = {
+ { "black", "#000000" },
+ { "green", "#008000" },
+ { "silver", "#c0c0c0" },
+ { "lime", "#00ff00" },
+ { "gray", "#808080" },
+ { "olive", "#808000" },
+ { "white", "#ffffff" },
+ { "yellow", "#ffff00" },
+ { "maroon", "#800000" },
+ { "navy", "#000080" },
+ { "red", "#ff0000" },
+ { "blue", "#0000ff" },
+ { "purple", "#800080" },
+ { "teal", "#008080" },
+ { "fuchsia", "#ff00ff" },
+ { "aqua", "#00ffff" },
+ { "crimson", "#dc143c" },
+ { "indigo", "#4b0082" },
+ { 0, 0 }
+};
- /* Don't know how to deal with buttons correctly */
+struct uiColors {
+#ifdef APPLE_CHANGES
+ const char * name;
+ const char * configGroup;
+ const char * configEntry;
+ QPalette::ColorGroup group;
+ QColorGroup::ColorRole role;
+#else
+ const char * const name;
+ const char * const configGroup;
+ const char * const configEntry;
+ const QPalette::ColorGroup group;
+ const QColorGroup::ColorRole role;
+#endif
+};
+
+const char * const wmgroup = "WM";
+const char * const generalgroup = "General";
+static const uiColors uimap[] = {
+ // Active window border.
+ { "activeborder", wmgroup, "background", QPalette::Active, QColorGroup::Light },
+ // Active window caption.
+ { "activecaption", wmgroup, "background", QPalette::Active, QColorGroup::Text },
+ // Text in caption, size box, and scrollbar arrow box.
+ { "captiontext", wmgroup, "activeForeground", QPalette::Active, QColorGroup::Text },
// Face color for three-dimensional display elements.
- map["buttonface"] = cg.button();
+ { "buttonface", wmgroup, 0, QPalette::Inactive, QColorGroup::Button },
// Dark shadow for three-dimensional display elements (for edges facing away from the light source).
- map["buttonhighlight"] = cg.light();
+ { "buttonhighlight", wmgroup, 0, QPalette::Inactive, QColorGroup::Light },
// Shadow color for three-dimensional display elements.
- map["buttonshadow"] = cg.shadow();
+ { "buttonshadow", wmgroup, 0, QPalette::Inactive, QColorGroup::Shadow },
// Text on push buttons.
- map["buttontext"] = globalConfig->readColorEntry( "buttonForeground", &cg.buttonText());
-
+ { "buttontext", wmgroup, "buttonForeground", QPalette::Inactive, QColorGroup::ButtonText },
// Dark shadow for three-dimensional display elements.
- map["threeddarkshadow"] = cg.dark();
+ { "threeddarkshadow", wmgroup, 0, QPalette::Inactive, QColorGroup::Dark },
// Face color for three-dimensional display elements.
- map["threedface"] = cg.button();
+ { "threedface", wmgroup, 0, QPalette::Inactive, QColorGroup::Button },
// Highlight color for three-dimensional display elements.
- map["threedhighlight"] = cg.light();
+ { "threedhighlight", wmgroup, 0, QPalette::Inactive, QColorGroup::Light },
// Light color for three-dimensional display elements (for edges facing the light source).
- map["threedlightshadow"] = cg.midlight();
+ { "threedlightshadow", wmgroup, 0, QPalette::Inactive, QColorGroup::Midlight },
// Dark shadow for three-dimensional display elements.
- map["threedshadow"] = cg.shadow();
+ { "threedshadow", wmgroup, 0, QPalette::Inactive, QColorGroup::Shadow },
- // InfoBackground
-#ifndef QT_NO_TOOLTIP
- map["infobackground"] = QToolTip::palette().inactive().background();
- // InfoText
- map["infotext"] = QToolTip::palette().inactive().foreground();
-#endif
+ // Inactive window border.
+ { "inactiveborder", wmgroup, "background", QPalette::Disabled, QColorGroup::Background },
+ // Inactive window caption.
+ { "inactivecaption", wmgroup, "inactiveBackground", QPalette::Disabled, QColorGroup::Background },
+ // Color of text in an inactive caption.
+ { "inactivecaptiontext", wmgroup, "inactiveForeground", QPalette::Disabled, QColorGroup::Text },
+ { "graytext", wmgroup, 0, QPalette::Disabled, QColorGroup::Text },
- globalConfig->setGroup("General");
// Menu background
- map["menu"] = globalConfig->readColorEntry( "background", &cg.background());
+ { "menu", generalgroup, "background", QPalette::Inactive, QColorGroup::Background },
// Text in menus
- map["menutext"] = globalConfig->readColorEntry( "foreground", &cg.background());
+ { "menutext", generalgroup, "foreground", QPalette::Inactive, QColorGroup::Background },
- // Item(s) selected in a control.
- map["highlight"] = globalConfig->readColorEntry( "selectBackground", &cg.highlight());
// Text of item(s) selected in a control.
- map["highlighttext"] = globalConfig->readColorEntry( "selectForeground", &cg.highlightedText());
+ { "highlight", generalgroup, "selectBackground", QPalette::Inactive, QColorGroup::Background },
+
+ // Text of item(s) selected in a control.
+ { "highlighttext", generalgroup, "selectForeground", QPalette::Inactive, QColorGroup::Background },
// Background color of multiple document interface.
- map["appworkspace"] = globalConfig->readColorEntry( "background", &cg.text());
+ { "appworkspace", generalgroup, "background", QPalette::Inactive, QColorGroup::Text },
// Scroll bar gray area.
- map["scrollbar"] = globalConfig->readColorEntry( "background", &cg.background());
+ { "scrollbar", generalgroup, "background", QPalette::Inactive, QColorGroup::Background },
// Window background.
- map["window"] = globalConfig->readColorEntry( "windowBackground", &cg.background());
+ { "window", generalgroup, "windowBackground", QPalette::Inactive, QColorGroup::Background },
// Window frame.
- map["windowframe"] = globalConfig->readColorEntry( "windowBackground",&cg.background());
+ { "windowframe", generalgroup, "windowBackground", QPalette::Inactive, QColorGroup::Background },
// WindowText
- map["windowtext"] = globalConfig->readColorEntry( "windowForeground", &cg.text());
- map["text"] = cg.text();
-
- cg = kapp->palette().disabled();
- globalConfig->setGroup("WM");
- // Inactive window border.
- map["inactiveborder"] = globalConfig->readColorEntry( "background", &cg.background());
- // Inactive window caption.
- map["inactivecaption"] = globalConfig->readColorEntry( "inactiveBackground", &cg.background());
- // Color of text in an inactive caption.
- map["inactivecaptiontext"] = globalConfig->readColorEntry( "inactiveForeground", &cg.text());
- map["graytext"] = cg.text();
-
- KConfig *bckgrConfig = new KConfig("kdesktoprc", true, false); // No multi-screen support
- bckgrConfig->setGroup("Desktop0");
+ { "windowtext", generalgroup, "windowForeground", QPalette::Inactive, QColorGroup::Text },
+ { "text", generalgroup, 0, QPalette::Inactive, QColorGroup::Text },
+ { 0, 0, 0, QPalette::NColorGroups, QColorGroup::NColorRoles }
+};
+
+HTMLColors::HTMLColors()
+{
+ const colorMap *color = cmap;
+ while ( color->name ) {
+ map[color->name] = color->value;
+ ++color;
+ }
+ // ### react to style changes
+ // see http://www.richinstyle.com for details
+
+ /* Mapping system settings to CSS 2
+ * Tried hard to get an appropriate mapping - schlpbch
+ */
+
+ KConfig *globalConfig = KGlobal::config();
+ const QPalette &pal = kapp->palette();
+
+ const uiColors *uicol = uimap;
+ const char *lastConfigGroup = 0;
+ while( uicol->name ) {
+ if ( lastConfigGroup != uicol->configGroup ) {
+ lastConfigGroup = uicol->configGroup;
+ globalConfig->setGroup( lastConfigGroup );
+ }
+ QColor c = pal.color( uicol->group, uicol->role );
+ if ( uicol->configEntry )
+ c = globalConfig->readColorEntry( uicol->configEntry, &c );
+ map[uicol->name] = c;
+ ++uicol;
+ }
+
+#ifndef QT_NO_TOOLTIP
+ // InfoBackground
+ map["infobackground"] = QToolTip::palette().inactive().background();
+ // InfoText
+ map["infotext"] = QToolTip::palette().inactive().foreground();
+#endif
+
+ KConfig bckgrConfig("kdesktoprc", true, false); // No multi-screen support
+ bckgrConfig.setGroup("Desktop0");
// Desktop background.
- map["background"] = bckgrConfig->readColorEntry("Color1", &cg.background());
- delete bckgrConfig;
- };
+ map["background"] = bckgrConfig.readColorEntry("Color1", &pal.disabled().background());
};
+
+
static HTMLColors *htmlColors = 0L;
static KStaticDeleter<HTMLColors> hcsd;
diff --git a/WebCore/khtml/misc/khtmllayout.h b/WebCore/khtml/misc/khtmllayout.h
index c5bf001..abe8c7a 100644
--- a/WebCore/khtml/misc/khtmllayout.h
+++ b/WebCore/khtml/misc/khtmllayout.h
@@ -41,13 +41,14 @@ namespace khtml
/*
* %multiLength and %Length
*/
- enum LengthType { Undefined = 0, Variable = 1, Relative, Percent, Fixed, Static };
+ enum LengthType { Variable = 0, Relative, Percent, Fixed, Static };
struct Length
{
- Length() : value(0), type(Variable) {}
- Length(LengthType t) : value(0), type(t) {}
+ Length() { *((Q_UINT32 *)this) = 0; }
+ Length(LengthType t) { type = t; value = 0; }
Length(int v, LengthType t) : value(v), type(t) {}
- Length(const Length &l) : value(l.value), type(l.type) {}
+ Length(const Length &o)
+ { *((Q_UINT32 *)this) = *((Q_UINT32 *)&o); }
Length& operator=(const Length& o)
{ *((Q_UINT32 *)this) = *((Q_UINT32 *)&o); return *this; }
@@ -68,7 +69,6 @@ namespace khtml
return value;
case Percent:
return maxWidth*value/100;
- case Undefined:
case Variable:
return maxWidth;
default:
@@ -86,13 +86,11 @@ namespace khtml
return value;
case Percent:
return maxWidth*value/100;
- case Undefined:
case Variable:
default:
return 0;
}
}
- bool isUndefined() const { return (type == Undefined); }
bool isVariable() const { return (type == Variable); }
bool isRelative() const { return (type == Relative); }
bool isPercent() const { return (type == Percent); }
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index 9fb3b73..882b143 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -52,6 +52,7 @@
#include "khtml_factory.h"
#include "khtml_part.h"
+#include "html/html_documentimpl.h"
#include "css/css_stylesheetimpl.h"
#include "xml/dom_docimpl.h"
@@ -69,15 +70,13 @@ static bool cacheDisabled;
void CachedObject::finish()
{
if( m_size > MAXCACHEABLE )
- {
m_status = Uncacheable;
- //Cache::flush(true); // Force flush.
- }
else
m_status = Cached;
KURL url(m_url.string());
- if (m_expireDate && url.protocol().startsWith("http"))
+ if (m_expireDateChanged && url.protocol().startsWith("http"))
{
+ m_expireDateChanged = false;
KIO::http_update_cache(url, false, m_expireDate);
#ifdef CACHE_DEBUG
kdDebug(6060) << " Setting expire date for image "<<m_url.string()<<" to " << m_expireDate << endl;
@@ -88,14 +87,25 @@ void CachedObject::finish()
#endif
}
-void CachedObject::setExpireDate(int _expireDate)
+void CachedObject::setExpireDate(time_t _expireDate, bool changeHttpCache)
{
- // assert(_expireDate);
- if ( _expireDate != m_expireDate && (m_status == Uncacheable || m_status == Cached))
+ if ( _expireDate == m_expireDate)
+ return;
+
+ if (m_status == Uncacheable || m_status == Cached)
{
finish();
}
m_expireDate = _expireDate;
+ if (changeHttpCache && m_expireDate)
+ m_expireDateChanged = true;
+}
+
+bool CachedObject::isExpired() const
+{
+ if (!m_expireDate) return false;
+ time_t now = time(0);
+ return (difftime(now, m_expireDate) >= 0);
}
void CachedObject::setRequest(Request *_request)
@@ -109,11 +119,11 @@ void CachedObject::setRequest(Request *_request)
// -------------------------------------------------------------------------------------------
-CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
+CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate, const QString& charset)
#ifdef APPLE_CHANGES
- : CachedObject(dl, url, CSSStyleSheet, reload, _expireDate)
+ : CachedObject(dl, url, CSSStyleSheet, _cachePolicy, _expireDate)
#else
- : CachedObject(url, CSSStyleSheet, reload, _expireDate)
+ : CachedObject(url, CSSStyleSheet, _cachePolicy, _expireDate)
#endif
{
// It's css we want.
@@ -128,10 +138,12 @@ CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, bo
m_codec = QTextCodec::codecForMib(4); // latin-1
}
-#ifndef APPLE_CHANGES
-
CachedCSSStyleSheet::CachedCSSStyleSheet(const DOMString &url, const QString &stylesheet_data)
- : CachedObject(url, CSSStyleSheet, false, 0)
+#ifdef APPLE_CHANGES
+ : CachedObject(0, url, CSSStyleSheet, KIO::CC_Verify, 0)
+#else
+ : CachedObject(url, CSSStyleSheet, KIO::CC_Verify, 0)
+#endif
{
m_loading = false;
m_status = Persistent;
@@ -140,9 +152,6 @@ CachedCSSStyleSheet::CachedCSSStyleSheet(const DOMString &url, const QString &st
m_sheet = DOMString(stylesheet_data);
}
-#endif
-
-
CachedCSSStyleSheet::~CachedCSSStyleSheet()
{
}
@@ -158,6 +167,7 @@ void CachedCSSStyleSheet::ref(CachedObjectClient *c)
void CachedCSSStyleSheet::deref(CachedObjectClient *c)
{
+ Cache::flush();
m_clients.remove(c);
if ( canDelete() && m_free )
delete this;
@@ -197,11 +207,11 @@ void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ )
// -------------------------------------------------------------------------------------------
-CachedScript::CachedScript(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
+CachedScript::CachedScript(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate, const QString& charset)
#ifdef APPLE_CHANGES
- : CachedObject(dl, url, Script, reload, _expireDate)
+ : CachedObject(dl, url, Script, _cachePolicy, _expireDate)
#else
- : CachedObject(url, Script, reload, _expireDate)
+ : CachedObject(url, Script, _cachePolicy, _expireDate)
#endif
{
// It's javascript we want.
@@ -218,10 +228,12 @@ CachedScript::CachedScript(DocLoader* dl, const DOMString &url, bool reload, int
m_codec = QTextCodec::codecForMib(4); // latin-1
}
-#ifndef APPLE_CHANGES
-
CachedScript::CachedScript(const DOMString &url, const QString &script_data)
- : CachedObject(url, Script, false, 0)
+#ifdef APPLE_CHANGES
+ : CachedObject(0, url, Script, KIO::CC_Verify, 0)
+#else
+ : CachedObject(url, Script, KIO::CC_Verify, 0)
+#endif
{
m_loading = false;
m_status = Persistent;
@@ -230,8 +242,6 @@ CachedScript::CachedScript(const DOMString &url, const QString &script_data)
m_script = DOMString(script_data);
}
-#endif
-
CachedScript::~CachedScript()
{
}
@@ -247,6 +257,7 @@ void CachedScript::ref(CachedObjectClient *c)
void CachedScript::deref(CachedObjectClient *c)
{
+ Cache::flush();
m_clients.remove(c);
if ( canDelete() && m_free )
delete this;
@@ -338,9 +349,6 @@ namespace khtml
}
-/*!
- This Class defines the DataSource for incremental loading of images.
-*/
ImageSource::ImageSource(QByteArray buf)
{
buffer = buf;
@@ -350,10 +358,6 @@ ImageSource::ImageSource(QByteArray buf)
rewable = true;
}
-/**
- * Overload QDataSource::readyToSend() and returns the number
- * of bytes ready to send if not eof instead of returning -1.
-*/
int ImageSource::readyToSend()
{
if(eof && pos == buffer.size())
@@ -362,9 +366,6 @@ int ImageSource::readyToSend()
return buffer.size() - pos;
}
-/*!
- Reads and sends a block of data.
-*/
void ImageSource::sendTo(QDataSink* sink, int n)
{
sink->receive((const uchar*)&buffer.at(pos), n);
@@ -379,9 +380,6 @@ void ImageSource::sendTo(QDataSink* sink, int n)
}
}
-/**
- * Sets the EOF state.
- */
void ImageSource::setEOF( bool state )
{
eof = state;
@@ -409,7 +407,6 @@ void ImageSource::rewind()
ready();
}
-
void ImageSource::cleanBuffer()
{
// if we need to be able to rewind, buffer is needed
@@ -426,8 +423,6 @@ void ImageSource::cleanBuffer()
}
}
-#endif // APPLE_CHANGES
-
static QString buildAcceptHeader()
{
QString result = KImageIO::mimeTypes( KImageIO::Reading ).join(", ");
@@ -436,16 +431,44 @@ static QString buildAcceptHeader()
return result;
}
+static bool crossDomain(const QString &a, const QString &b)
+{
+ if (a == b) return false;
+
+ QStringList l1 = QStringList::split('.', a);
+ QStringList l2 = QStringList::split('.', b);
+
+ while(l1.count() > l2.count())
+ l1.pop_front();
+
+ while(l2.count() > l1.count())
+ l2.pop_front();
+
+ while(l2.count() >= 2)
+ {
+ if (l1 == l2)
+ return false;
+
+ l1.pop_front();
+ l2.pop_front();
+ }
+ return true;
+}
+
+#endif // APPLE_CHANGES
+
// -------------------------------------------------------------------------------------
-CachedImage::CachedImage(DocLoader* dl, const DOMString &url, bool reload, int _expireDate)
+CachedImage::CachedImage(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate)
#ifdef APPLE_CHANGES
- : CachedObject(dl, url, Image, reload, _expireDate)
+ : CachedObject(dl, url, Image, _cachePolicy, _expireDate)
#else
- : QObject(), CachedObject(url, Image, reload, _expireDate)
+ : QObject(), CachedObject(url, Image, _cachePolicy, _expireDate)
#endif
{
+#ifndef APPLE_CHANGES
static const QString &acceptHeader = KGlobal::staticQString( buildAcceptHeader() );
+#endif
m = 0;
p = 0;
@@ -462,7 +485,9 @@ CachedImage::CachedImage(DocLoader* dl, const DOMString &url, bool reload, int _
m_status = Unknown;
m_size = 0;
imgSource = 0;
+#ifndef APPLE_CHANGES
setAccept( acceptHeader );
+#endif
m_showAnimations = dl->showAnimations();
}
@@ -483,7 +508,7 @@ void CachedImage::ref( CachedObjectClient *c )
if( m ) {
m->unpause();
- if( m->finished() )
+ if( m->finished() || m_clients.count() == 1 )
m->restart();
}
@@ -497,10 +522,10 @@ void CachedImage::deref( CachedObjectClient *c )
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << this << " CachedImage::deref(" << c << ") " << endl;
#endif
+ Cache::flush();
m_clients.remove( c );
if(m && m_clients.isEmpty() && m->running())
m->pause();
-
if ( canDelete() && m_free )
delete this;
}
@@ -536,10 +561,10 @@ const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
if ( r.height() < BGMINHEIGHT )
h = ((BGMINHEIGHT / s.height())+1) * s.height();
}
- if ( (w != r.width()) || (h != r.height()) )
+ if ( (w != r.width()) || (h != r.height()) || (isvalid && r.mask()))
{
QPixmap pix = r;
- if ( w != r.width() )
+ if ( w != r.width() || (isvalid && pix.mask()))
{
bg = new QPixmap(w, r.height());
QPainter p(bg);
@@ -638,12 +663,8 @@ void CachedImage::do_notify(const QPixmap& p, const QRect& r)
{
CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() ) {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "found a client to update: " << c << endl;
-#endif
+ for ( c = m_clients.first(); c != 0; c = m_clients.next() )
c->setPixmap( p, r, this);
- }
}
#ifndef APPLE_CHANGES
@@ -697,21 +718,12 @@ void CachedImage::movieStatus(int status)
}
- if((status == QMovie::EndOfMovie) ||
+ if((status == QMovie::EndOfMovie && (!m || m->frameNumber() <= 1)) ||
((status == QMovie::EndOfLoop) && (m_showAnimations == KHTMLSettings::KAnimationLoopOnce)) ||
((status == QMovie::EndOfFrame) && (m_showAnimations == KHTMLSettings::KAnimationDisabled))
)
{
-#if 0
- // the movie has ended and it doesn't loop nor is it an animation,
- // so there is no need to keep the buffer in memory
- if(imgSource && (m->frameNumber() == 1))
-#else
- // WABA: Throw away the movie when it gets to the end.
- // We might want to do a pause instead in some cases if there is
- // a chance that we want to play the movie again.
if(imgSource)
-#endif
{
setShowAnimations( KHTMLSettings::KAnimationDisabled );
@@ -737,9 +749,9 @@ void CachedImage::movieStatus(int status)
if((status == QMovie::EndOfFrame) || (status == QMovie::EndOfMovie))
{
#ifdef CACHE_DEBUG
-// QRect r(valid_rect());
-// qDebug("movie Status frame update %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
-// pixmap().size().width(), pixmap().size().height());
+ QRect r(valid_rect());
+ qDebug("movie Status frame update %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
+ pixmap().size().width(), pixmap().size().height());
#endif
do_notify(pixmap(), valid_rect());
}
@@ -760,6 +772,7 @@ void CachedImage::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimati
imgSource->cleanBuffer();
delete p;
p = new QPixmap(m->framePixmap());
+
m->disconnectUpdate( this, SLOT( movieUpdated( const QRect &) ));
m->disconnectStatus( this, SLOT( movieStatus( int ) ));
m->disconnectResize( this, SLOT( movieResize( const QSize& ) ) );
@@ -930,7 +943,7 @@ Request::~Request()
DocLoader::DocLoader(KHTMLPart* part, DocumentImpl* doc)
{
- m_reloading = false;
+ m_cachePolicy = KIO::CC_Verify;
m_expireDate = 0;
m_bautoloadImages = true;
m_showAnimations = KHTMLSettings::KAnimationEnabled;
@@ -948,68 +961,71 @@ DocLoader::~DocLoader()
Cache::docloader->remove( this );
}
-void DocLoader::setExpireDate(int _expireDate)
+void DocLoader::setExpireDate(time_t _expireDate)
{
m_expireDate = _expireDate;
}
+bool DocLoader::needReload(const KURL &fullURL)
+{
+ bool reload = false;
+ if (m_cachePolicy == KIO::CC_Verify)
+ {
+ if (!m_reloadedURLs.contains(fullURL.url()))
+ {
+ CachedObject *existing = Cache::cache->find(fullURL.url());
+ if (existing && existing->isExpired())
+ {
+ Cache::removeCacheEntry(existing);
+ m_reloadedURLs.append(fullURL.url());
+ reload = true;
+ }
+ }
+ }
+ else if ((m_cachePolicy == KIO::CC_Reload) || (m_cachePolicy == KIO::CC_Refresh))
+ {
+ if (!m_reloadedURLs.contains(fullURL.url()))
+ {
+ CachedObject *existing = Cache::cache->find(fullURL.url());
+ if (existing)
+ {
+ Cache::removeCacheEntry(existing);
+ }
+ m_reloadedURLs.append(fullURL.url());
+ reload = true;
+ }
+ }
+ return reload;
+}
+
CachedImage *DocLoader::requestImage( const DOM::DOMString &url)
{
KURL fullURL = m_doc->completeURL( url.string() );
if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestImage(this, url, true, m_expireDate);
- }
- }
+ bool reload = needReload(fullURL);
- CachedImage* ci = Cache::requestImage(this, url, false, m_expireDate);
-
- return ci;
+ return Cache::requestImage(this, url, reload, m_expireDate);
}
CachedCSSStyleSheet *DocLoader::requestStyleSheet( const DOM::DOMString &url, const QString& charset)
{
-// KURL fullURL = url.string();
KURL fullURL = m_doc->completeURL( url.string() );
-
if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestStyleSheet(this, url, true,m_expireDate, charset);
- }
- }
+ bool reload = needReload(fullURL);
- return Cache::requestStyleSheet(this, url, false,m_expireDate, charset);
+ return Cache::requestStyleSheet(this, url, reload, m_expireDate, charset);
}
CachedScript *DocLoader::requestScript( const DOM::DOMString &url, const QString& charset)
{
KURL fullURL = m_doc->completeURL( url.string() );
-// KURL fullURL = url.string();
if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestScript(this, url, true,m_expireDate, charset);
- }
- }
+ bool reload = needReload(fullURL);
- return Cache::requestScript(this, url, false,m_expireDate, charset);
+ return Cache::requestScript(this, url, reload, m_expireDate, charset);
}
void DocLoader::setAutoloadImages( bool enable )
@@ -1034,9 +1050,9 @@ void DocLoader::setAutoloadImages( bool enable )
}
}
-void DocLoader::setReloading( bool enable )
+void DocLoader::setCachePolicy( KIO::CacheControl cachePolicy )
{
- m_reloading = enable;
+ m_cachePolicy = cachePolicy;
}
void DocLoader::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
@@ -1104,11 +1120,13 @@ void Loader::servePendingRequests()
kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
#endif
- KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
+ KURL u(req->object->url().string());
+ KIO::TransferJob* job = KIO::get( u, false, false /*no GUI*/);
#ifdef APPLE_CHANGES
d->serveRequest(req, job);
#else
+ job->addMetaData("cache", getCacheControlString(req->object->cachePolicy()));
if (!req->object->accept().isEmpty())
job->addMetaData("accept", req->object->accept());
if ( req->m_docLoader ) {
@@ -1117,13 +1135,11 @@ void Loader::servePendingRequests()
r.setPath( "/" );
job->addMetaData("referrer", r.url());
-
- if (req->m_docLoader->part()->restored())
- {
-// kdDebug() << "USING NON-VALIDATING CACHE!"<< endl;
- job->addMetaData("cache","Cache");
- }
-
+ QString domain = r.host();
+ if (req->m_docLoader->doc()->isHTMLDocument())
+ domain = static_cast<HTMLDocumentImpl*>(req->m_docLoader->doc())->domain().string();
+ if (crossDomain(u.host(), domain))
+ job->addMetaData("cross-domain", "true");
}
connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinished( KIO::Job * ) ) );
@@ -1155,6 +1171,11 @@ void Loader::slotFinished( KIO::Job* job )
{
r->object->data(r->m_buffer, true);
emit requestDone( r->m_docLoader, r->object );
+ time_t expireDate = j->queryMetaData("expire-date").toLong();
+#ifndef APPLE_CHANGES
+kdDebug(6060) << "Loader::slotFinished, url = " << j->url().url() << " expires " << ctime(&expireDate) << endl;
+#endif
+ r->object->setExpireDate(expireDate, false);
}
#ifdef APPLE_CHANGES
@@ -1321,14 +1342,29 @@ void Cache::clear()
delete docloader; docloader = 0;
}
-CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool reload, int _expireDate )
+CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool reload, time_t _expireDate )
{
// this brings the _url to a standard form...
KURL kurl;
+ KIO::CacheControl cachePolicy;
if ( dl )
+ {
kurl = dl->m_doc->completeURL( url.string() );
+ cachePolicy = dl->cachePolicy();
+ }
else
+ {
kurl = url.string();
+ cachePolicy = KIO::CC_Verify;
+ }
+
+ if( kurl.isMalformed() )
+ {
+#ifdef CACHE_DEBUG
+ kdDebug( 6060 ) << "Cache: Malformed url: " << kurl.url() << endl;
+#endif
+ return 0;
+ }
CachedObject *o = 0;
if (!reload)
@@ -1338,7 +1374,7 @@ CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool rel
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
#endif
- CachedImage *im = new CachedImage(dl, kurl.url(), reload, _expireDate);
+ CachedImage *im = new CachedImage(dl, kurl.url(), cachePolicy, _expireDate);
if ( dl && dl->autoloadImages() ) Cache::loader()->load(dl, im, true);
#ifdef APPLE_CHANGES
if (cacheDisabled)
@@ -1347,14 +1383,13 @@ CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool rel
#endif
cache->insert( kurl.url(), im );
lru->prepend( kurl.url() );
- flush();
#ifdef APPLE_CHANGES
}
#endif
o = im;
}
- o->setExpireDate(_expireDate);
+ o->setExpireDate(_expireDate, true);
if(!o->type() == CachedObject::Image)
{
@@ -1382,14 +1417,27 @@ CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool rel
return static_cast<CachedImage *>(o);
}
-CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString & url, bool reload, int _expireDate, const QString& charset)
+CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString & url, bool reload, time_t _expireDate, const QString& charset)
{
// this brings the _url to a standard form...
KURL kurl;
+ KIO::CacheControl cachePolicy;
if ( dl )
+ {
kurl = dl->m_doc->completeURL( url.string() );
+ cachePolicy = dl->cachePolicy();
+ }
else
+ {
kurl = url.string();
+ cachePolicy = KIO::CC_Verify;
+ }
+
+ if( kurl.isMalformed() )
+ {
+ kdDebug( 6060 ) << "Cache: Malformed url: " << kurl.url() << endl;
+ return 0;
+ }
CachedObject *o = cache->find(kurl.url());
if(!o)
@@ -1397,7 +1445,7 @@ CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString &
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
#endif
- CachedCSSStyleSheet *sheet = new CachedCSSStyleSheet(dl, kurl.url(), reload, _expireDate, charset);
+ CachedCSSStyleSheet *sheet = new CachedCSSStyleSheet(dl, kurl.url(), cachePolicy, _expireDate, charset);
#ifdef APPLE_CHANGES
if (cacheDisabled)
sheet->setFree(true);
@@ -1405,14 +1453,13 @@ CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString &
#endif
cache->insert( kurl.url(), sheet );
lru->prepend( kurl.url() );
- flush();
#ifdef APPLE_CHANGES
}
#endif
o = sheet;
}
- o->setExpireDate(_expireDate);
+ o->setExpireDate(_expireDate, true);
if(!o->type() == CachedObject::CSSStyleSheet)
{
@@ -1440,14 +1487,37 @@ CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString &
return static_cast<CachedCSSStyleSheet *>(o);
}
-CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bool reload, int _expireDate, const QString& charset)
+void Cache::preloadStyleSheet( const QString &url, const QString &stylesheet_data)
+{
+ CachedObject *o = cache->find(url);
+ if(o)
+ removeCacheEntry(o);
+
+ CachedCSSStyleSheet *stylesheet = new CachedCSSStyleSheet(url, stylesheet_data);
+ cache->insert( url, stylesheet );
+}
+
+CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bool reload, time_t _expireDate, const QString& charset)
{
// this brings the _url to a standard form...
KURL kurl;
+ KIO::CacheControl cachePolicy;
if ( dl )
+ {
kurl = dl->m_doc->completeURL( url.string() );
+ cachePolicy = dl->cachePolicy();
+ }
else
+ {
kurl = url.string();
+ cachePolicy = KIO::CC_Verify;
+ }
+
+ if( kurl.isMalformed() )
+ {
+ kdDebug( 6060 ) << "Cache: Malformed url: " << kurl.url() << endl;
+ return 0;
+ }
CachedObject *o = cache->find(kurl.url());
if(!o)
@@ -1455,7 +1525,7 @@ CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bo
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
#endif
- CachedScript *script = new CachedScript(dl, kurl.url(), reload, _expireDate, charset);
+ CachedScript *script = new CachedScript(dl, kurl.url(), cachePolicy, _expireDate, charset);
#ifdef APPLE_CHANGES
if (cacheDisabled)
script->setFree(true);
@@ -1463,14 +1533,13 @@ CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bo
#endif
cache->insert( kurl.url(), script );
lru->prepend( kurl.url() );
- flush();
#ifdef APPLE_CHANGES
}
#endif
o = script;
}
- o->setExpireDate(_expireDate);
+ o->setExpireDate(_expireDate, true);
if(!(o->type() == CachedObject::Script))
{
@@ -1498,6 +1567,16 @@ CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bo
return static_cast<CachedScript *>(o);
}
+void Cache::preloadScript( const QString &url, const QString &script_data)
+{
+ CachedObject *o = cache->find(url);
+ if(o)
+ removeCacheEntry(o);
+
+ CachedScript *script = new CachedScript(url, script_data);
+ cache->insert( url, script );
+}
+
void Cache::flush(bool force)
{
if (force)
@@ -1509,7 +1588,7 @@ void Cache::flush(bool force)
init();
#ifdef CACHE_DEBUG
- //statistics();
+ statistics();
kdDebug( 6060 ) << "Cache: flush()" << endl;
#endif
@@ -1620,6 +1699,17 @@ void Cache::removeCacheEntry( CachedObject *object )
delete object;
}
+
+// --------------------------------------
+
+void CachedObjectClient::setPixmap(const QPixmap &, const QRect&, CachedImage *) {}
+void CachedObjectClient::setStyleSheet(const DOM::DOMString &/*url*/, const DOM::DOMString &/*sheet*/) {}
+void CachedObjectClient::notifyFinished(CachedObject * /*finishedObj*/) {}
+
+
+#include "loader.moc"
+
+
#ifdef APPLE_CHANGES
Cache::Statistics Cache::getStatistics()
@@ -1684,14 +1774,4 @@ void Cache::setCacheDisabled(bool disabled)
flushAll();
}
-void Cache::preloadScript(const QString &, const QString &)
-{
-}
-
-void Cache::preloadStyleSheet(const QString &, const QString &)
-{
-}
-
#endif // APPLE_CHANGES
-
-#include "loader.moc"
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index 85a926c..cf328cb 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -29,6 +29,8 @@
#include <config.h>
#endif
+#include <time.h>
+
#include "loader_client.h"
#ifdef HAVE_LIBJPEG
#include "loader_jpeg.h"
@@ -45,7 +47,7 @@
#include <qtextcodec.h>
#include <kurl.h>
-
+#include <kio/global.h>
#include <khtml_settings.h>
#include <dom/dom_string.h>
@@ -102,9 +104,9 @@ namespace khtml
}; // will be destroyed as soon as possible
#ifdef APPLE_CHANGES
- CachedObject(const DocLoader *loader, const DOM::DOMString &url, Type type, bool _reload, int _expireDate)
+ CachedObject(const DocLoader *loader, const DOM::DOMString &url, Type type, KIO::CacheControl _cachePolicy, time_t _expireDate)
#else
- CachedObject(const DOM::DOMString &url, Type type, bool _reload, int _expireDate)
+ CachedObject(const DOM::DOMString &url, Type type, KIO::CacheControl _cachePolicy, time_t _expireDate)
#endif
{
#ifdef APPLE_CHANGES
@@ -115,10 +117,11 @@ namespace khtml
m_status = Pending;
m_size = 0;
m_free = false;
- m_reload = _reload;
+ m_cachePolicy = _cachePolicy;
m_request = 0;
m_expireDate = _expireDate;
m_deleted = false;
+ m_expireDateChanged = false;
}
virtual ~CachedObject() {
if(m_deleted) abort();
@@ -155,13 +158,15 @@ namespace khtml
*/
void setFree( bool b ) { m_free = b; }
- bool reload() const { return m_reload; }
+ KIO::CacheControl cachePolicy() const { return m_cachePolicy; }
void setRequest(Request *_request);
bool canDelete() const { return (m_clients.count() == 0 && !m_request); }
- void setExpireDate(int _expireDate);
+ void setExpireDate(time_t _expireDate, bool changeHttpCache);
+
+ bool isExpired() const;
virtual bool schedule() const { return false; }
@@ -187,11 +192,12 @@ namespace khtml
Type m_type;
Status m_status;
int m_size;
- int m_expireDate;
+ time_t m_expireDate;
+ KIO::CacheControl m_cachePolicy;
bool m_free : 1;
- bool m_reload : 1;
bool m_deleted : 1;
bool m_loading : 1;
+ bool m_expireDateChanged : 1;
};
@@ -201,7 +207,7 @@ namespace khtml
class CachedCSSStyleSheet : public CachedObject
{
public:
- CachedCSSStyleSheet(DocLoader* dl, const DOM::DOMString &url, bool reload, int _expireDate, const QString& charset);
+ CachedCSSStyleSheet(DocLoader* dl, const DOM::DOMString &url, KIO::CacheControl cachePolicy, time_t _expireDate, const QString& charset);
CachedCSSStyleSheet(const DOM::DOMString &url, const QString &stylesheet_data);
virtual ~CachedCSSStyleSheet();
@@ -228,7 +234,7 @@ namespace khtml
class CachedScript : public CachedObject
{
public:
- CachedScript(DocLoader* dl, const DOM::DOMString &url, bool reload, int _expireDate, const QString& charset);
+ CachedScript(DocLoader* dl, const DOM::DOMString &url, KIO::CacheControl cachePolicy, time_t _expireDate, const QString& charset);
CachedScript(const DOM::DOMString &url, const QString &script_data);
virtual ~CachedScript();
@@ -260,7 +266,7 @@ namespace khtml
{
Q_OBJECT
public:
- CachedImage(DocLoader* dl, const DOM::DOMString &url, bool reload, int _expireDate);
+ CachedImage(DocLoader* dl, const DOM::DOMString &url, KIO::CacheControl cachePolicy, time_t _expireDate);
virtual ~CachedImage();
const QPixmap &pixmap() const;
@@ -335,26 +341,28 @@ namespace khtml
CachedScript *requestScript( const DOM::DOMString &url, const QString& charset);
bool autoloadImages() const { return m_bautoloadImages; }
- bool reloading() const { return m_reloading; }
+ KIO::CacheControl cachePolicy() const { return m_cachePolicy; }
KHTMLSettings::KAnimationAdvice showAnimations() const { return m_showAnimations; }
- int expireDate() const { return m_expireDate; }
+ time_t expireDate() const { return m_expireDate; }
KHTMLPart* part() const { return m_part; }
DOM::DocumentImpl* doc() const { return m_doc; }
- void setExpireDate( int );
+ void setExpireDate( time_t );
void setAutoloadImages( bool );
- void setReloading( bool );
+ void setCachePolicy( KIO::CacheControl cachePolicy );
void setShowAnimations( KHTMLSettings::KAnimationAdvice );
void removeCachedObject( CachedObject*) const;
private:
+ bool needReload(const KURL &fullUrl);
+
friend class Cache;
friend class DOM::DocumentImpl;
QStringList m_reloadedURLs;
mutable QPtrList<CachedObject> m_docObjects;
- int m_expireDate;
- bool m_reloading : 1;
+ time_t m_expireDate;
+ KIO::CacheControl m_cachePolicy;
bool m_bautoloadImages : 1;
KHTMLSettings::KAnimationAdvice m_showAnimations : 2;
KHTMLPart* m_part;
@@ -447,13 +455,13 @@ namespace khtml
* if the DocLoader is zero, the url must be full-qualified.
* Otherwise, it is automatically base-url expanded
*/
- static CachedImage *requestImage( DocLoader* l, const DOM::DOMString &url, bool reload=false, int _expireDate=0);
+ static CachedImage *requestImage( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0);
/**
* Ask the cache for some url. Will return a cachedObject, and
* load the requested data in case it's not cached
*/
- static CachedCSSStyleSheet *requestStyleSheet( DocLoader* l, const DOM::DOMString &url, bool reload=false, int _expireDate=0, const QString& charset = QString::null);
+ static CachedCSSStyleSheet *requestStyleSheet( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0, const QString& charset = QString::null);
/**
* Pre-loads a stylesheet into the cache.
@@ -464,7 +472,7 @@ namespace khtml
* Ask the cache for some url. Will return a cachedObject, and
* load the requested data in case it's not cahced
*/
- static CachedScript *requestScript( DocLoader* l, const DOM::DOMString &url, bool reload=false, int _expireDate=0, const QString& charset=QString::null);
+ static CachedScript *requestScript( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0, const QString& charset=QString::null);
/**
* Pre-loads a script into the cache.
diff --git a/WebCore/khtml/misc/loader_client.h b/WebCore/khtml/misc/loader_client.h
index b63fccb..261af98 100644
--- a/WebCore/khtml/misc/loader_client.h
+++ b/WebCore/khtml/misc/loader_client.h
@@ -24,9 +24,9 @@ namespace khtml {
// rectangle of the part that has been loaded very recently
// pointer to us
// return whether we need manual update
- virtual void setPixmap(const QPixmap &, const QRect&, CachedImage *) {}
- virtual void setStyleSheet(const DOM::DOMString &/*url*/, const DOM::DOMString &/*sheet*/) {}
- virtual void notifyFinished(CachedObject * /*finishedObj*/) {}
+ virtual void setPixmap(const QPixmap &, const QRect&, CachedImage *);
+ virtual void setStyleSheet(const DOM::DOMString &/*url*/, const DOM::DOMString &/*sheet*/);
+ virtual void notifyFinished(CachedObject * /*finishedObj*/);
};
};
diff --git a/WebCore/khtml/misc/shared.h b/WebCore/khtml/misc/shared.h
new file mode 100644
index 0000000..09994d3
--- /dev/null
+++ b/WebCore/khtml/misc/shared.h
@@ -0,0 +1,57 @@
+#ifndef SHARED_H
+#define SHARED_H
+
+namespace khtml {
+
+template<class type> class Shared
+{
+public:
+ Shared() { _ref=0; /*counter++;*/ }
+ ~Shared() { /*counter--;*/ }
+
+ void ref() { _ref++; }
+ void deref() {
+ if(_ref) _ref--;
+ if(!_ref)
+ delete static_cast<type *>(this);
+ }
+ bool hasOneRef() { //kdDebug(300) << "ref=" << _ref << endl;
+ return _ref==1; }
+
+ int refCount() const { return _ref; }
+// static int counter;
+protected:
+ unsigned int _ref;
+};
+
+template<class type> class TreeShared
+{
+public:
+ TreeShared() { _ref = 0; m_parent = 0; /*counter++;*/ }
+ TreeShared( type *parent ) { _ref=0; m_parent = parent; /*counter++;*/ }
+ ~TreeShared() { /*counter--;*/ }
+
+ void ref() { _ref++; }
+ void deref() {
+ if(_ref) _ref--;
+ if(!_ref && !m_parent) {
+ delete static_cast<type *>(this);
+ }
+ }
+ bool hasOneRef() { //kdDebug(300) << "ref=" << _ref << endl;
+ return _ref==1; }
+
+ int refCount() const { return _ref; }
+// static int counter;
+
+ void setParent(type *parent) { m_parent = parent; }
+ type *parent() const { return m_parent; }
+private:
+ unsigned int _ref;
+protected:
+ type *m_parent;
+};
+
+};
+
+#endif
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index 4cb10f1..8fc8655 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -91,7 +91,7 @@ inline bool operator==( const BidiIterator &it1, const BidiIterator &it2 )
return true;
}
-inline bool operator!=( const BidiIterator &it1, const BidiIterator &it2 )
+inline bool operator!=( const BidiIterator &it1, const BidiIterator &it2 )
{
if(it1.pos != it2.pos) return true;
if(it1.obj != it2.obj) return true;
@@ -188,7 +188,7 @@ inline void BidiIterator::operator ++ ()
if(!obj) return;
if(obj->isText()) {
pos++;
- if(pos >= obj->length()) {
+ if(pos >= static_cast<RenderText *>(obj)->stringLength()) {
obj = Bidinext( par, obj );
pos = 0;
}
@@ -204,18 +204,20 @@ inline bool BidiIterator::atEnd() const
return false;
}
-const QChar &BidiIterator::current() const
+static const QChar nbsp = QChar(0xA0);
+
+inline const QChar &BidiIterator::current() const
{
- static const QChar nbsp = QChar(0xA0);
if( !obj || !obj->isText()) return nbsp; // non breaking space
return static_cast<RenderText *>(obj)->text()[pos];
}
-QChar::Direction BidiIterator::direction() const
+inline QChar::Direction BidiIterator::direction() const
{
- if(!obj || !obj->isText() || obj->length() <= 0) return QChar::DirON;
+ if(!obj || !obj->isText() ) return QChar::DirON;
+
RenderText *renderTxt = static_cast<RenderText *>( obj );
- if ( pos >= renderTxt->length() )
+ if ( pos >= renderTxt->stringLength() )
return QChar::DirON;
return renderTxt->text()[pos].direction();
}
@@ -228,7 +230,7 @@ static void appendRun()
#if BIDI_DEBUG > 1
kdDebug(6041) << "appendRun: dir="<<(int)dir<<endl;
#endif
-
+
bool b = adjustEmbeddding;
adjustEmbeddding = false;
@@ -256,9 +258,9 @@ static void appendRun()
static void embed( QChar::Direction d )
{
-#if BIDI_DEBUG > 1
+#if BIDI_DEBUG > 1
qDebug("*** embed dir=%d emptyrun=%d", d, emptyRun );
-#endif
+#endif
bool b = adjustEmbeddding ;
adjustEmbeddding = false;
if ( d == QChar::DirPDF ) {
@@ -335,10 +337,10 @@ void RenderFlow::bidiReorderLine(const BidiIterator &start, const BidiIterator &
}
return;
}
-#if BIDI_DEBUG > 1
+#if BIDI_DEBUG > 1
kdDebug(6041) << "reordering Line from " << start.obj << "/" << start.pos << " to " << end.obj << "/" << end.pos << endl;
#endif
-
+
QPtrList<BidiRun> runs;
runs.setAutoDelete(true);
sruns = &runs;
@@ -347,7 +349,7 @@ void RenderFlow::bidiReorderLine(const BidiIterator &start, const BidiIterator &
dir = QChar::DirON;
emptyRun = true;
-
+
numSpaces = 0;
current = start;
@@ -366,7 +368,7 @@ void RenderFlow::bidiReorderLine(const BidiIterator &start, const BidiIterator &
} else {
dirCurrent = current.direction();
}
-
+
#ifndef QT_NO_UNICODETABLES
#if BIDI_DEBUG > 1
@@ -397,7 +399,7 @@ void RenderFlow::bidiReorderLine(const BidiIterator &start, const BidiIterator &
case QChar::DirAL:
case QChar::DirEN:
case QChar::DirAN:
- appendRun();
+ appendRun();
break;
case QChar::DirES:
case QChar::DirET:
@@ -685,7 +687,7 @@ void RenderFlow::bidiReorderLine(const BidiIterator &start, const BidiIterator &
}
#if BIDI_DEBUG > 0
- kdDebug(6041) << "reached end of line current=" << current.obj << "/" << current.pos
+ kdDebug(6041) << "reached end of line current=" << current.obj << "/" << current.pos
<< ", eor=" << eor.obj << "/" << eor.pos << endl;
#endif
if ( !emptyRun && sor != current ) {
@@ -926,7 +928,7 @@ void RenderFlow::layoutInlineChildren()
#endif
#if BIDI_DEBUG > 1 || defined( DEBUG_LINEBREAKS )
kdDebug(6041) << " ------- bidi start " << this << " -------" << endl;
-#endif
+#endif
int toAdd = style()->borderBottomWidth();
m_height = style()->borderTopWidth();
@@ -973,7 +975,7 @@ void RenderFlow::layoutInlineChildren()
firstLine = true;
while( !end.atEnd() ) {
start = end;
-
+
end = findNextLineBreak(start);
if( start.atEnd() ) break;
bidiReorderLine(start, end);
@@ -1001,7 +1003,7 @@ void RenderFlow::layoutInlineChildren()
#if BIDI_DEBUG > 1
kdDebug(6041) << " ------- bidi end " << this << " -------" << endl;
-#endif
+#endif
//kdDebug() << "RenderFlow::layoutInlineChildren time used " << qt.elapsed() << endl;
//kdDebug(6040) << "height = " << m_height <<endl;
}
@@ -1092,7 +1094,7 @@ BidiIterator RenderFlow::findNextLineBreak(BidiIterator &start)
tmpW += o->width()+o->marginLeft()+o->marginRight();
} else if ( o->isText() ) {
RenderText *t = static_cast<RenderText *>(o);
- int strlen = t->length();
+ int strlen = t->stringLength();
int len = strlen - pos;
QChar *str = t->text();
#if 0
diff --git a/WebCore/khtml/rendering/break_lines.cpp b/WebCore/khtml/rendering/break_lines.cpp
index 57cf61e..6635778 100644
--- a/WebCore/khtml/rendering/break_lines.cpp
+++ b/WebCore/khtml/rendering/break_lines.cpp
@@ -31,8 +31,8 @@ bool isBreakable( const QChar *s, int pos, int )
#endif
{
const QChar *c = s+pos;
- char ch = c->latin1();
- if ( !ch ) {
+ unsigned short ch = c->unicode();
+ if ( ch > 0xff ) {
// not latin1, need to do more sophisticated checks for asian fonts
unsigned char row = c->row();
if ( row == 0x0e ) {
@@ -65,12 +65,12 @@ bool isBreakable( const QChar *s, int pos, int )
} else
return false;
}
- if ( row < 0x11 ) // no asian font
- return false;
if ( row > 0x2d && row < 0xfb || row == 0x11 )
// asian line breaking. Everywhere allowed except directly
// in front of a punctuation character.
return true;
+ else // no asian font
+ return c->isSpace();
} else {
if ( ch == ' ' || ch == '\n' )
return true;
diff --git a/WebCore/khtml/rendering/font.cpp b/WebCore/khtml/rendering/font.cpp
index 46f3599..8895efa 100644
--- a/WebCore/khtml/rendering/font.cpp
+++ b/WebCore/khtml/rendering/font.cpp
@@ -49,10 +49,10 @@ void Font::drawText( QPainter *p, int x, int y, QChar *str, int slen, int pos, i
qstr.setLength( slen );
QChar *uc = (QChar *)qstr.unicode();
for( int i = 0; i < slen; i++ )
- if ( uc->unicode() == 0xa0 )
- *uc = ' ';
+ if ( (uc+i)->unicode() == 0xa0 )
+ *(uc+i) = ' ';
}
-
+
// ### fixme for RTL
if ( !letterSpacing && !wordSpacing && !toAdd && from==-1 ) {
// simply draw it
@@ -101,33 +101,32 @@ void Font::drawText( QPainter *p, int x, int y, QChar *str, int slen, int pos, i
int Font::width( QChar *chs, int slen, int pos, int len ) const
{
#ifdef APPLE_CHANGES
- return fm.width(chs + pos, kMin(len, slen - pos));
+ return fm.width(chs + pos, len);
#else
- QString qstr = QConstString(chs+pos, slen-pos).string();
-
+ QString qstr = QConstString(chs+pos, len).string();
// hack for fonts that don't have a welldefined nbsp
if ( !fontDef.hasNbsp ) {
// str.setLength() always does a deep copy, so the replacement code below is safe.
- qstr.setLength( slen );
+ qstr.setLength( len );
QChar *uc = (QChar *)qstr.unicode();
- for( int i = 0; i < slen; i++ )
- if ( uc->unicode() == 0xa0 )
- *uc = ' ';
+ for( int i = 0; i < len; i++ )
+ if ( (uc+i)->unicode() == 0xa0 )
+ *(uc+i) = ' ';
}
// ### might be a little inaccurate
- int w = fm.width( qstr, len );
+ int w = fm.width( qstr );
if ( letterSpacing )
w += len*letterSpacing;
- if ( wordSpacing ) {
+ if ( wordSpacing )
// add amount
for( int i = 0; i < len; i++ ) {
if( chs[i+pos].isSpace() )
w += wordSpacing;
}
- }
+
return w;
#endif
}
diff --git a/WebCore/khtml/rendering/render_applet.cpp b/WebCore/khtml/rendering/render_applet.cpp
index 25aa213..924b512 100644
--- a/WebCore/khtml/rendering/render_applet.cpp
+++ b/WebCore/khtml/rendering/render_applet.cpp
@@ -41,7 +41,7 @@
using namespace khtml;
using namespace DOM;
-RenderApplet::RenderApplet(HTMLElementImpl *applet, QMap<QString, QString> args )
+RenderApplet::RenderApplet(HTMLElementImpl *applet, const QMap<QString, QString> &args )
: RenderWidget(applet)
{
// init RenderObject attributes
@@ -49,10 +49,11 @@ RenderApplet::RenderApplet(HTMLElementImpl *applet, QMap<QString, QString> args
#ifdef APPLE_CHANGES
// FIXME: Can we find a way to do this in layout below instead of here?
+ QMap<QString, QString> argsToPassToWidget(args);
for (NodeImpl *child = element()->firstChild(); child; child = child->nextSibling()) {
if (child->id() == ID_PARAM) {
HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>(child);
- args.insert(p->name(), p->value());
+ argsToPassToWidget.insert(p->name(), p->value());
}
}
#endif // APPLE_CHANGES
@@ -66,7 +67,7 @@ RenderApplet::RenderApplet(HTMLElementImpl *applet, QMap<QString, QString> args
if ( context ) {
//kdDebug(6100) << "RenderApplet::RenderApplet, setting QWidget" << endl;
#ifdef APPLE_CHANGES
- setQWidget( new KJavaAppletWidget(args) );
+ setQWidget( new KJavaAppletWidget(argsToPassToWidget) );
#else
setQWidget( new KJavaAppletWidget(context, _view->viewport()) );
processArguments(args);
@@ -134,7 +135,7 @@ void RenderApplet::layout()
#ifndef APPLE_CHANGES
-void RenderApplet::processArguments(QMap<QString, QString> args)
+void RenderApplet::processArguments(const QMap<QString, QString> &args)
{
KJavaAppletWidget *w = static_cast<KJavaAppletWidget*>(m_widget);
KJavaApplet* applet = w ? w->applet() : 0;
@@ -143,15 +144,18 @@ void RenderApplet::processArguments(QMap<QString, QString> args)
applet->setBaseURL( args[QString::fromLatin1("baseURL") ] );
applet->setAppletClass( args[QString::fromLatin1("code") ] );
- if( !args[QString::fromLatin1("codeBase") ].isEmpty() )
- applet->setCodeBase( args[QString::fromLatin1("codeBase") ] );
+ QString str = args[QString::fromLatin1("codeBase") ];
+ if( !str.isEmpty() )
+ applet->setCodeBase( str );
- if( !args[QString::fromLatin1("name") ].isNull() )
- applet->setAppletName( args[QString::fromLatin1("name") ] );
+ str = args[QString::fromLatin1("name") ];
+ if( !str.isNull() )
+ applet->setAppletName( str );
else
applet->setAppletName( args[QString::fromLatin1("code") ] );
- if( !args[QString::fromLatin1("archive") ].isEmpty() )
+ str = args[QString::fromLatin1("archive") ];
+ if( !str.isEmpty() )
applet->setArchives( args[QString::fromLatin1("archive") ] );
}
}
diff --git a/WebCore/khtml/rendering/render_applet.h b/WebCore/khtml/rendering/render_applet.h
index a9382c3..63863cd 100644
--- a/WebCore/khtml/rendering/render_applet.h
+++ b/WebCore/khtml/rendering/render_applet.h
@@ -39,7 +39,7 @@ namespace khtml {
class RenderApplet : public RenderWidget
{
public:
- RenderApplet(DOM::HTMLElementImpl* node, QMap<QString, QString> args);
+ RenderApplet(DOM::HTMLElementImpl* node, const QMap<QString, QString> &args);
virtual ~RenderApplet();
virtual const char *renderName() const { return "RenderApplet"; }
@@ -47,12 +47,13 @@ public:
virtual void layout();
virtual short intrinsicWidth() const;
virtual int intrinsicHeight() const;
+ virtual bool isApplet() const { return true; }
DOM::HTMLElementImpl *element() const
{ return static_cast<DOM::HTMLElementImpl*>(RenderObject::element()); }
private:
- void processArguments( QMap<QString, QString> args );
+ void processArguments( const QMap<QString, QString> &args );
};
class RenderEmptyApplet : public RenderWidget
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index 1d1588d..b0d3374 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -196,7 +196,7 @@ void RenderContainer::insertPseudoChild(RenderStyle::PseudoId type, RenderObject
if (pseudo)
{
- if (pseudo->contentType()==RenderStyle::CONTENT_TEXT)
+ if (pseudo->contentType()==CONTENT_TEXT)
{
RenderObject* po = new RenderFlow(0 /* anonymous box */);
po->setStyle(pseudo);
@@ -213,7 +213,7 @@ void RenderContainer::insertPseudoChild(RenderStyle::PseudoId type, RenderObject
t->close();
po->close();
}
- else if (pseudo->contentType()==RenderStyle::CONTENT_OBJECT)
+ else if (pseudo->contentType()==CONTENT_OBJECT)
{
RenderObject* po = new RenderImage(0);
po->setStyle(pseudo);
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index e25da11..0343a37 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -40,7 +40,7 @@
#include "khtmlview.h"
#include "khtml_ext.h"
-#include "xml/dom_docimpl.h" // ### remove dependency
+#include "xml/dom_docimpl.h"
#include <kdebug.h>
@@ -70,9 +70,9 @@ RenderFormElement::~RenderFormElement()
short RenderFormElement::baselinePosition( bool f ) const
{
#ifdef APPLE_CHANGES
- return RenderWidget::baselinePosition( f ) - 6 - QFontMetrics( style()->font() ).descent();
+ return RenderWidget::baselinePosition( f ) - 6 - style()->fontMetrics().descent();
#else
- return RenderWidget::baselinePosition( f ) - 2 - QFontMetrics( style()->font() ).descent();
+ return RenderWidget::baselinePosition( f ) - 2 - style()->fontMetrics().descent();
#endif
}
@@ -109,36 +109,36 @@ void RenderFormElement::updateFromElement()
int lowlightVal = 100 + (2*contrast_+4)*10;
if (backgroundColor.isValid()) {
- pal.setColor(QPalette::Active,QColorGroup::Background,backgroundColor);
- pal.setColor(QPalette::Active,QColorGroup::Light,backgroundColor.light(highlightVal));
- pal.setColor(QPalette::Active,QColorGroup::Dark,backgroundColor.dark(lowlightVal));
- pal.setColor(QPalette::Active,QColorGroup::Mid,backgroundColor.dark(120));
- pal.setColor(QPalette::Active,QColorGroup::Midlight, backgroundColor.light(110));
- pal.setColor(QPalette::Active,QColorGroup::Button,backgroundColor);
- pal.setColor(QPalette::Active,QColorGroup::Base,backgroundColor);
- pal.setColor(QPalette::Inactive,QColorGroup::Background,backgroundColor);
- pal.setColor(QPalette::Inactive,QColorGroup::Light,backgroundColor.light(highlightVal));
- pal.setColor(QPalette::Inactive,QColorGroup::Dark,backgroundColor.dark(lowlightVal));
- pal.setColor(QPalette::Inactive,QColorGroup::Mid,backgroundColor.dark(120));
- pal.setColor(QPalette::Inactive,QColorGroup::Midlight, backgroundColor.light(110));
- pal.setColor(QPalette::Inactive,QColorGroup::Button,backgroundColor);
- pal.setColor(QPalette::Inactive,QColorGroup::Base,backgroundColor);
- pal.setColor(QPalette::Disabled,QColorGroup::Background,backgroundColor);
- pal.setColor(QPalette::Disabled,QColorGroup::Light,backgroundColor.light(highlightVal));
- pal.setColor(QPalette::Disabled,QColorGroup::Dark,backgroundColor.dark(lowlightVal));
- pal.setColor(QPalette::Disabled,QColorGroup::Mid,backgroundColor.dark(120));
- pal.setColor(QPalette::Disabled,QColorGroup::Text,backgroundColor.dark(120));
- pal.setColor(QPalette::Disabled,QColorGroup::Midlight, backgroundColor.light(110));
- pal.setColor(QPalette::Disabled,QColorGroup::Button, backgroundColor);
- pal.setColor(QPalette::Disabled,QColorGroup::Base,backgroundColor);
+ for ( int i = 0; i < QPalette::NColorGroups; i++ ) {
+ pal.setColor( (QPalette::ColorGroup)i, QColorGroup::Background, backgroundColor );
+ pal.setColor( (QPalette::ColorGroup)i, QColorGroup::Light, backgroundColor.light(highlightVal) );
+ pal.setColor( (QPalette::ColorGroup)i, QColorGroup::Dark, backgroundColor.dark(lowlightVal) );
+ pal.setColor( (QPalette::ColorGroup)i, QColorGroup::Mid, backgroundColor.dark(120) );
+ pal.setColor( (QPalette::ColorGroup)i, QColorGroup::Midlight, backgroundColor.light(110) );
+ pal.setColor( (QPalette::ColorGroup)i, QColorGroup::Button, backgroundColor );
+ pal.setColor( (QPalette::ColorGroup)i, QColorGroup::Base, backgroundColor );
+ }
}
if ( color.isValid() ) {
- pal.setColor(QPalette::Active,QColorGroup::Foreground,color);
- pal.setColor(QPalette::Active,QColorGroup::ButtonText,color);
- pal.setColor(QPalette::Active,QColorGroup::Text,color);
- pal.setColor(QPalette::Inactive,QColorGroup::Foreground,color);
- pal.setColor(QPalette::Inactive,QColorGroup::ButtonText,color);
- pal.setColor(QPalette::Inactive,QColorGroup::Text,color);
+ struct ColorSet {
+ QPalette::ColorGroup cg;
+ QColorGroup::ColorRole cr;
+ };
+ const struct ColorSet toSet [] = {
+ { QPalette::Active, QColorGroup::Foreground },
+ { QPalette::Active, QColorGroup::ButtonText },
+ { QPalette::Active, QColorGroup::Text },
+ { QPalette::Inactive, QColorGroup::Foreground },
+ { QPalette::Inactive, QColorGroup::ButtonText },
+ { QPalette::Inactive, QColorGroup::Text },
+ { QPalette::Disabled,QColorGroup::ButtonText },
+ { QPalette::NColorGroups, QColorGroup::NColorRoles },
+ };
+ const ColorSet *set = toSet;
+ while( set->cg != QPalette::NColorGroups ) {
+ pal.setColor( set->cg, set->cr, color );
+ ++set;
+ }
QColor disfg = color;
int h, s, v;
@@ -146,14 +146,13 @@ void RenderFormElement::updateFromElement()
if (v > 128)
// dark bg, light fg - need a darker disabled fg
disfg = disfg.dark(lowlightVal);
- else if (disfg != black)
+ else if (disfg != Qt::black)
// light bg, dark fg - need a lighter disabled fg - but only if !black
disfg = disfg.light(highlightVal);
else
// black fg - use darkgrey disabled fg
disfg = Qt::darkGray;
pal.setColor(QPalette::Disabled,QColorGroup::Foreground,disfg);
- pal.setColor(QPalette::Disabled,QColorGroup::ButtonText, color);
}
m_widget->setPalette(pal);
@@ -194,14 +193,12 @@ void RenderFormElement::performAction(QObject::Actions action)
void RenderFormElement::slotClicked()
{
- if(isRenderButton()) {
- ref();
- QMouseEvent e2( QEvent::MouseButtonRelease, m_mousePos, m_button, m_state);
+ ref();
+ QMouseEvent e2( QEvent::MouseButtonRelease, m_mousePos, m_button, m_state);
- element()->dispatchMouseEvent(&e2, m_isDoubleClick ? EventImpl::KHTML_DBLCLICK_EVENT : EventImpl::KHTML_CLICK_EVENT, m_clickCount);
- m_isDoubleClick = false;
- deref();
- }
+ element()->dispatchMouseEvent(&e2, m_isDoubleClick ? EventImpl::KHTML_DBLCLICK_EVENT : EventImpl::KHTML_CLICK_EVENT, m_clickCount);
+ m_isDoubleClick = false;
+ deref();
}
// -------------------------------------------------------------------------
@@ -288,7 +285,7 @@ void RenderRadioButton::updateFromElement()
void RenderRadioButton::slotClicked()
{
- element()->setChecked(widget()->isChecked());
+ element()->setChecked(true);
// emit mouseClick event etc
RenderButton::slotClicked();
@@ -558,16 +555,17 @@ void RenderLineEdit::calcMinMaxWidth()
void RenderLineEdit::updateFromElement()
{
+ int ml = element()->maxLength();
+ if ( ml < 0 || ml > 1024 )
+ ml = 1024;
+ if ( widget()->maxLength() != ml )
+ widget()->setMaxLength( ml );
+
if (element()->value().string() != widget()->text()) {
widget()->blockSignals(true);
int pos = widget()->cursorPosition();
widget()->setText(element()->value().string());
- int ml = element()->maxLength();
- if ( ml < 0 || ml > 1024 )
- ml = 1024;
- if ( widget()->maxLength() != ml )
- widget()->setMaxLength( ml );
widget()->setEdited( false );
widget()->setCursorPosition(pos);
@@ -1068,6 +1066,7 @@ KListBox* RenderSelect::createListBox()
// ### looks broken
//lb->setAutoMask(true);
connect( lb, SIGNAL( selectionChanged() ), this, SLOT( slotSelectionChanged() ) );
+ connect( lb, SIGNAL( clicked( QListBoxItem * ) ), this, SLOT( slotClicked() ) );
m_ignoreSelectEvents = false;
lb->setMouseTracking(true);
@@ -1094,19 +1093,20 @@ void RenderSelect::updateSelection()
}
else {
bool found = false;
- for (i = 0; i < int(listItems.size()); i++)
- if (listItems[i]->id() == ID_OPTION && static_cast<HTMLOptionElementImpl*>(listItems[i])->selected()) {
- static_cast<KComboBox*>(m_widget)->setCurrentItem(i);
- found = true;
- break;
- }
- // ok, nothing was selected, select the first one..
- for (i = 0; !found && i < int(listItems.size()); i++)
- if ( listItems[i]->id() == ID_OPTION ) {
-// static_cast<HTMLOptionElementImpl*>( listItems[i] )->m_selected = true;
- static_cast<KComboBox*>( m_widget )->setCurrentItem( i );
- break;
+ int firstOption = listItems.size();
+ i = listItems.size();
+ while (i--)
+ if (listItems[i]->id() == ID_OPTION) {
+ if (found)
+ static_cast<HTMLOptionElementImpl*>(listItems[i])->m_selected = false;
+ else if (static_cast<HTMLOptionElementImpl*>(listItems[i])->selected()) {
+ static_cast<KComboBox*>( m_widget )->setCurrentItem(i);
+ found = true;
+ }
+ firstOption = i;
}
+
+ Q_ASSERT(firstOption == listItems.size() || found);
}
m_selectionChanged = false;
@@ -1128,7 +1128,7 @@ TextAreaWidget::TextAreaWidget(int wrap, QWidget* parent)
setHScrollBarMode( Auto );
setVScrollBarMode( Auto );
}
- KCursor::setAutoHideCursor(this, true);
+ KCursor::setAutoHideCursor(viewport(), true);
setTextFormat(QTextEdit::PlainText);
setAutoMask(true);
setMouseTracking(true);
@@ -1190,6 +1190,7 @@ void RenderTextArea::calcMinMaxWidth()
TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
const QFontMetrics &m = style()->fontMetrics();
+ w->setTabStopWidth(8 * m.width(" "));
#ifdef APPLE_CHANGES
QSize size( QMAX(element()->cols(), 1)*m.width('x') + w->frameWidth() +
w->verticalScrollBarWidth(),
diff --git a/WebCore/khtml/rendering/render_form.h b/WebCore/khtml/rendering/render_form.h
index 3ce2b67..757df0f 100644
--- a/WebCore/khtml/rendering/render_form.h
+++ b/WebCore/khtml/rendering/render_form.h
@@ -398,10 +398,6 @@ class TextAreaWidget : public QTextEdit
public:
TextAreaWidget(int wrap, QWidget* parent);
-// using QMultiLineEdit::verticalScrollBar;
-// using QMultiLineEdit::horizontalScrollBar;
-// using QMultiLineEdit::hasMarkedText;
-
protected:
virtual bool event (QEvent *e );
};
diff --git a/WebCore/khtml/rendering/render_frames.cpp b/WebCore/khtml/rendering/render_frames.cpp
index 45d49f7..5dba103 100644
--- a/WebCore/khtml/rendering/render_frames.cpp
+++ b/WebCore/khtml/rendering/render_frames.cpp
@@ -27,6 +27,7 @@
#include "rendering/render_root.h"
#include "html/html_baseimpl.h"
#include "html/html_objectimpl.h"
+#include "html/htmltokenizer.h"
#include "misc/htmlattrs.h"
#include "xml/dom2_eventsimpl.h"
#include "xml/dom_docimpl.h"
@@ -771,13 +772,10 @@ bool RenderPartObject::partLoadingErrorNotify( khtml::ChildFrame *childFrame, co
// Dissociate ourselves from the current event loop (to prevent crashes
// due to the message box staying up)
QTimer::singleShot( 0, this, SLOT( slotPartLoadingErrorNotify() ) );
- /*
- // The proper fix, but this doesn't work well yet (msg box keeps appearing)
Tokenizer *tokenizer = static_cast<DOM::DocumentImpl *>(part->document().handle())->tokenizer();
if (tokenizer) tokenizer->setOnHold( true );
slotPartLoadingErrorNotify();
if (tokenizer) tokenizer->setOnHold( false );
- */
return false;
}
@@ -855,14 +853,15 @@ void RenderPartObject::layout( )
KHTMLAssert( !layouted() );
KHTMLAssert( minMaxKnown() );
+#ifndef APPLE_CHANGES
short m_oldwidth = m_width;
int m_oldheight = m_height;
+#endif
calcWidth();
calcHeight();
- if (m_width != m_oldwidth || m_height != m_oldheight)
- RenderPart::layout();
+ RenderPart::layout();
setLayouted();
}
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index ed3e85e..697817a 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -71,11 +71,11 @@ void RenderImage::setStyle(RenderStyle* _style)
setOverhangingContents(style()->height().isPercent());
setSpecialObjects(true);
- if (style()->contentObject())
- {
+ CachedObject* co = style()->contentObject();
+ if (co && image != co ) {
if (image) image->deref(this);
image = static_cast<CachedImage*>(style()->contentObject());
- image->ref(this);
+ if (image) image->ref(this);
}
}
@@ -93,7 +93,7 @@ void RenderImage::setPixmap( const QPixmap &p, const QRect& r, CachedImage *o)
int ih = p.height() + 8;
// we have an alt and the user meant it (its not a text we invented)
- if ( !alt.isEmpty() && !element()->getAttribute( ATTR_ALT ).isNull()) {
+ if ( element() && !alt.isEmpty() && !element()->getAttribute( ATTR_ALT ).isNull()) {
const QFontMetrics &fm = style()->fontMetrics();
QRect br = fm.boundingRect ( 0, 0, 1024, 256, Qt::AlignAuto|Qt::WordBreak, alt.string() );
if ( br.width() > iw )
@@ -317,7 +317,7 @@ void RenderImage::layout()
void RenderImage::notifyFinished(CachedObject *finishedObj)
{
- if (image == finishedObj && !loadEventSent) {
+ if (image == finishedObj && !loadEventSent && element()) {
loadEventSent = true;
element()->dispatchHTMLEvent(EventImpl::LOAD_EVENT,false,false);
}
@@ -347,7 +347,6 @@ bool RenderImage::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
void RenderImage::updateFromElement()
{
- assert(element());
#ifdef APPLE_CHANGES
// Treat a lack of src or empty string for src as no image at all, not the page itself
// loaded as an image.
@@ -362,7 +361,7 @@ void RenderImage::updateFromElement()
requestImage(khtml::parseURL(element()->getAttribute(ATTR_SRC)));
#endif
- if(new_image && new_image != image) {
+ if(new_image && new_image != image && (!style() || !style()->contentObject())) {
loadEventSent = false;
if(image) image->deref(this);
image = new_image;
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 580e484..b91651e 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -841,7 +841,7 @@ bool RenderObject::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
bool inner = !info.innerNode();
// ### table should have its own, more performant method
- if (isInline() || isRoot() || isTableRow() || isTableSection() || inside || mouseInside() ) {
+ if (isPositioned() || isInline() || isRoot() || isTableRow() || isTableSection() || inside || mouseInside() ) {
for (RenderObject* child = lastChild(); child; child = child->previousSibling())
if (!child->isPositioned() && child->nodeAtPoint(info, _x, _y, _tx+xPos(), _ty+yPos()))
inside = true;
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 0355c1c..f5c45b6 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -129,6 +129,7 @@ public:
virtual bool isBody() const { return false; }
virtual bool isFormElement() const { return false; }
virtual bool isFrameSet() const { return false; }
+ virtual bool isApplet() const { return false; }
bool isAnonymousBox() const { return m_isAnonymous; }
void setIsAnonymousBox(bool b) { m_isAnonymous = b; }
diff --git a/WebCore/khtml/rendering/render_replaced.cpp b/WebCore/khtml/rendering/render_replaced.cpp
index d7742df..118789f 100644
--- a/WebCore/khtml/rendering/render_replaced.cpp
+++ b/WebCore/khtml/rendering/render_replaced.cpp
@@ -19,7 +19,6 @@
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id$
*/
#include "render_replaced.h"
#include "render_root.h"
@@ -157,12 +156,19 @@ RenderWidget::~RenderWidget()
delete m_widget;
}
-static void resizeWidget( QWidget *widget, int w, int h )
+void RenderWidget::resizeWidget( QWidget *widget, int w, int h )
{
- // ugly hack to limit the maximum size of the widget (as X11 has problems if it's bigger)
+ // ugly hack to limit the maximum size of the widget (as X11 has problems i
h = QMIN( h, 3072 );
w = QMIN( w, 2000 );
- widget->resize( w, h );
+
+ if (widget->width() != w || widget->height() != h) {
+ ref();
+ element()->ref();
+ widget->resize( w, h );
+ element()->deref();
+ deref();
+ }
}
void RenderWidget::setQWidget(QWidget *widget)
diff --git a/WebCore/khtml/rendering/render_replaced.h b/WebCore/khtml/rendering/render_replaced.h
index f6e0ade..356adc8 100644
--- a/WebCore/khtml/rendering/render_replaced.h
+++ b/WebCore/khtml/rendering/render_replaced.h
@@ -23,7 +23,6 @@
#define render_replaced_h
#include "render_box.h"
-
#include <qobject.h>
class KHTMLView;
class QWidget;
@@ -34,7 +33,6 @@ class RenderReplaced : public RenderBox
{
public:
RenderReplaced(DOM::NodeImpl* node);
- virtual ~RenderReplaced() {}
virtual const char *renderName() const { return "RenderReplaced"; }
@@ -63,7 +61,7 @@ private:
};
-class RenderWidget : public QObject, public RenderReplaced, public DOM::DomShared
+class RenderWidget : public QObject, public RenderReplaced, public khtml::Shared<RenderWidget>
{
Q_OBJECT
public:
@@ -89,6 +87,8 @@ public slots:
protected:
bool eventFilter(QObject* /*o*/, QEvent* e);
void setQWidget(QWidget *widget);
+ void resizeWidget( QWidget *widget, int w, int h );
+
QWidget *m_widget;
KHTMLView* m_view;
};
diff --git a/WebCore/khtml/rendering/render_root.cpp b/WebCore/khtml/rendering/render_root.cpp
index 050a749..f80c3d8 100644
--- a/WebCore/khtml/rendering/render_root.cpp
+++ b/WebCore/khtml/rendering/render_root.cpp
@@ -228,7 +228,9 @@ void RenderRoot::repaintRectangle(int x, int y, int w, int h, bool f)
void RenderRoot::repaint()
{
- if (m_view && !m_printingMode) m_view->scheduleRepaint(0, 0, docWidth(), docHeight());
+ if (m_view && !m_printingMode)
+ m_view->scheduleRepaint(m_view->contentsX(), m_view->contentsY(),
+ m_view->visibleWidth(), m_view->visibleHeight());
}
void RenderRoot::close()
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index 267a4dd..ee3eff6 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -29,24 +29,15 @@
using namespace khtml;
StyleSurroundData::StyleSurroundData()
+ : margin( Fixed ), padding( Fixed )
{
- margin.left = Length(0,Fixed);
- margin.right = Length(0,Fixed);
- margin.top = Length(0,Fixed);
- margin.bottom = Length(0,Fixed);
- padding.left = Length(0,Fixed);
- padding.right = Length(0,Fixed);
- padding.top = Length(0,Fixed);
- padding.bottom = Length(0,Fixed);
}
StyleSurroundData::StyleSurroundData(const StyleSurroundData& o )
- : SharedData()
+ : Shared<StyleSurroundData>(),
+ offset( o.offset ), margin( o.margin ), padding( o.padding ),
+ border( o.border )
{
- offset = o.offset;
- margin = o.margin;
- padding = o.padding;
- border = o.border;
}
bool StyleSurroundData::operator==(const StyleSurroundData& o) const
@@ -56,19 +47,17 @@ bool StyleSurroundData::operator==(const StyleSurroundData& o) const
}
StyleBoxData::StyleBoxData()
+ : z_index( ZAUTO )
{
}
StyleBoxData::StyleBoxData(const StyleBoxData& o )
- : SharedData()
+ : Shared<StyleBoxData>(),
+ width( o.width ), height( o.height ),
+ min_width( o.min_width ), max_width( o.max_width ),
+ min_height ( o.min_height ), max_height( o.max_height ),
+ z_index( o.z_index )
{
- width = o.width;
- height = o.height;
- min_width = o.min_width;
- max_width = o.max_width;
- min_height = o.min_height;
- max_height = o.max_height;
- z_index = o.z_index;
}
bool StyleBoxData::operator==(const StyleBoxData& o) const
@@ -84,64 +73,83 @@ bool StyleBoxData::operator==(const StyleBoxData& o) const
}
StyleVisualData::StyleVisualData()
+ : colspan( 1 ), counter_increment( 0 ), counter_reset( 0 ),
+ palette( QApplication::palette() )
{
- colspan = 1;
- palette = QApplication::palette();
- counter_increment = counter_reset = 0;
}
StyleVisualData::~StyleVisualData() {
}
-StyleVisualData::StyleVisualData(const StyleVisualData& o ) : SharedData()
+StyleVisualData::StyleVisualData(const StyleVisualData& o )
+ : Shared<StyleVisualData>(),
+ clip( o.clip ), colspan( o.colspan ),
+ counter_increment( o.counter_increment ), counter_reset( o.counter_reset ),
+ palette( o.palette )
{
- clip = o.clip;
- colspan = o.colspan;
- counter_increment = o.counter_increment;
- counter_reset = o.counter_reset;
- palette = o.palette;
}
-void
-RenderStyle::setBitDefaults()
+
+StyleBackgroundData::StyleBackgroundData()
+ : image( 0 )
+{
+}
+
+StyleBackgroundData::StyleBackgroundData(const StyleBackgroundData& o )
+ : Shared<StyleBackgroundData>(),
+ color( o.color ), image( o.image ),
+ x_position( o.x_position ), y_position( o.y_position ),
+ outline( o.outline )
{
- inherited_flags._border_collapse = true;
- inherited_flags._empty_cells = SHOW;
- inherited_flags._caption_side = CAPTOP;
- inherited_flags._list_style_type = DISC;
- inherited_flags._list_style_position = OUTSIDE;
- inherited_flags._visibility = VISIBLE;
- inherited_flags._text_align = TAAUTO;
- inherited_flags._text_transform = TTNONE;
- inherited_flags._direction = LTR;
- inherited_flags._white_space = NORMAL;
- inherited_flags._text_decoration = TDNONE;
- inherited_flags._cursor_style = CURSOR_AUTO;
- inherited_flags._font_variant = FVNORMAL;
- inherited_flags._visuallyOrdered = false;
- inherited_flags._htmlHacks=false;
- inherited_flags._unused = 0;
+}
+
+bool StyleBackgroundData::operator==(const StyleBackgroundData& o) const
+{
+ return
+ color == o.color &&
+ image == o.image &&
+ x_position == o.x_position &&
+ y_position == o.y_position &&
+ outline == o.outline;
+}
+
+
- noninherited_flags._display = INLINE;
+StyleInheritedData::StyleInheritedData()
+ : indent( Fixed ), line_height( -100, Percent ), style_image( 0 ),
+ cursor_image( 0 ), font(), color( Qt::black ), decoration_color( Qt::black ), border_spacing( 0 )
+{
+}
- noninherited_flags._overflow = OVISIBLE;
- noninherited_flags._vertical_align = BASELINE;
- noninherited_flags._clear = CNONE;
- noninherited_flags._table_layout = TAUTO;
- noninherited_flags._bg_repeat = REPEAT;
- noninherited_flags._bg_attachment = SCROLL;
- noninherited_flags._position = STATIC;
- noninherited_flags._floating = FNONE;
- noninherited_flags._flowAroundFloats=false;
- noninherited_flags._styleType = NOPSEUDO;
- noninherited_flags._hasHover = false;
- noninherited_flags._hasActive = false;
- noninherited_flags._jsClipMode = false;
- noninherited_flags._unicodeBidi = UBNormal;
+StyleInheritedData::~StyleInheritedData()
+{
}
+StyleInheritedData::StyleInheritedData(const StyleInheritedData& o )
+ : Shared<StyleInheritedData>(),
+ indent( o.indent ), line_height( o.line_height ), style_image( o.style_image ),
+ cursor_image( o.cursor_image ), font( o.font ),
+ color( o.color ), decoration_color( o.decoration_color ),
+ border_spacing( o.border_spacing )
+{
+}
+bool StyleInheritedData::operator==(const StyleInheritedData& o) const
+{
+ return
+ indent == o.indent &&
+ line_height == o.line_height &&
+ border_spacing == o.border_spacing &&
+ style_image == o.style_image &&
+ cursor_image == o.cursor_image &&
+ font == o.font &&
+ color == o.color &&
+ decoration_color == o.decoration_color;
+
+ // doesn't work because structs are not packed
+ //return memcmp(this, &o, sizeof(*this))==0;
+}
RenderStyle::RenderStyle()
{
@@ -159,7 +167,7 @@ RenderStyle::RenderStyle()
setBitDefaults();
pseudoStyle = 0;
-
+ content = 0;
}
RenderStyle::RenderStyle(bool)
@@ -167,32 +175,22 @@ RenderStyle::RenderStyle(bool)
setBitDefaults();
box.init();
- box.access()->setDefaultValues();
visual.init();
background.init();
surround.init();
inherited.init();
- inherited.access()->setDefaultValues();
pseudoStyle = 0;
+ content = 0;
}
-RenderStyle::RenderStyle(const RenderStyle& other)
- : DOM::DomShared()
+RenderStyle::RenderStyle(const RenderStyle& o)
+ : Shared<RenderStyle>(),
+ inherited_flags( o.inherited_flags ), noninherited_flags( o.noninherited_flags ),
+ box( o.box ), visual( o.visual ), background( o.background ), surround( o.surround ),
+ inherited( o.inherited ), pseudoStyle( 0 ), content( o.content )
{
-
- inherited_flags = other.inherited_flags;
- noninherited_flags = other.noninherited_flags;
-
- box = other.box;
- visual = other.visual;
- background = other.background;
- surround = other.surround;
-
- inherited = other.inherited;
-
- pseudoStyle=0;
}
void RenderStyle::inheritFrom(const RenderStyle* inheritParent)
@@ -215,6 +213,8 @@ RenderStyle::~RenderStyle()
prev->pseudoStyle = 0;
prev->deref();
}
+ if ( content )
+ delete content;
}
bool RenderStyle::operator==(const RenderStyle& o) const
@@ -222,29 +222,26 @@ bool RenderStyle::operator==(const RenderStyle& o) const
// compare everything except the pseudoStyle pointer
return (inherited_flags == o.inherited_flags &&
noninherited_flags == o.noninherited_flags &&
- *box.get() == *o.box.get() &&
- *visual.get() == *o.visual.get() &&
- *background.get() == *o.background.get() &&
- *surround.get() == *o.surround.get() &&
- *inherited.get() == *o.inherited.get());
+ box == o.box &&
+ visual == o.visual &&
+ background == o.background &&
+ surround == o.surround &&
+ inherited == o.inherited);
}
RenderStyle* RenderStyle::getPseudoStyle(PseudoId pid)
{
-
- if (!(noninherited_flags._styleType==NOPSEUDO))
- return 0;
-
- RenderStyle *ps = pseudoStyle;
-
+ RenderStyle *ps = 0;
+ if (noninherited_flags._styleType==NOPSEUDO) {
+ ps = pseudoStyle;
while (ps) {
if (ps->noninherited_flags._styleType==pid)
- return ps;
+ break;
ps = ps->pseudoStyle;
}
-
- return 0;
+ }
+ return ps;
}
RenderStyle* RenderStyle::addPseudoStyle(PseudoId pid)
@@ -253,9 +250,6 @@ RenderStyle* RenderStyle::addPseudoStyle(PseudoId pid)
if (!ps)
{
- if (pid==BEFORE || pid==AFTER)
- ps = new RenderPseudoElementStyle();
- else
ps = new RenderStyle(*this); // use the real copy constructor to get an identical copy
ps->ref();
ps->noninherited_flags._styleType = pid;
@@ -289,7 +283,7 @@ bool RenderStyle::inheritedNotEqual( RenderStyle *other ) const
return
(
inherited_flags != other->inherited_flags ||
- *inherited.get() != *other->inherited.get()
+ inherited != other->inherited
);
}
@@ -437,57 +431,50 @@ void RenderStyle::cleanup()
// SharedData::counter = 0;
}
-RenderPseudoElementStyle::RenderPseudoElementStyle() : RenderStyle()
-{
- _contentType = CONTENT_NONE;
-}
-
-RenderPseudoElementStyle::RenderPseudoElementStyle(bool b) : RenderStyle(b)
-{
- _contentType = CONTENT_NONE;
-}
-RenderPseudoElementStyle::RenderPseudoElementStyle(const RenderStyle& r) : RenderStyle(r)
+void RenderStyle::setContent(CachedObject* o)
{
- _contentType = CONTENT_NONE;
+ if ( !content )
+ content = new ContentData;
+ else
+ content->clearContent();
+// o->ref();
+ content->_content.object = o;
+ content->_contentType = CONTENT_OBJECT;
}
-RenderPseudoElementStyle::~RenderPseudoElementStyle() { clearContent(); }
-
-void RenderPseudoElementStyle::setContent(CachedObject* o)
+void RenderStyle::setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c)
{
- clearContent();
-// o->ref();
- _content.object = o;
- _contentType = CONTENT_OBJECT;
+ visual.access()->palette.setColor(g,r,c);
}
-void RenderPseudoElementStyle::setContent(DOM::DOMStringImpl* s)
+void RenderStyle::setClip( Length top, Length right, Length bottom, Length left )
{
- clearContent();
- _content.text = s;
- _content.text->ref();
- _contentType = CONTENT_TEXT;
+ StyleVisualData *data = visual.access();
+ data->clip.top = top;
+ data->clip.right = right;
+ data->clip.bottom = bottom;
+ data->clip.left = left;
}
-DOM::DOMStringImpl* RenderPseudoElementStyle::contentText()
+void RenderStyle::setContent(DOM::DOMStringImpl* s)
{
- if (_contentType==CONTENT_TEXT)
- return _content.text;
+ if ( !content )
+ content = new ContentData;
else
- return 0;
+ content->clearContent();
+
+ content->_content.text = s;
+ content->_content.text->ref();
+ content->_contentType = CONTENT_TEXT;
}
-CachedObject* RenderPseudoElementStyle::contentObject()
+ContentData::~ContentData()
{
- if (_contentType==CONTENT_OBJECT)
- return _content.object;
- else
- return 0;
+ clearContent();
}
-
-void RenderPseudoElementStyle::clearContent()
+void ContentData::clearContent()
{
switch (_contentType)
{
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 121ce30..ca5f571 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -1,7 +1,9 @@
/*
* This file is part of the DOM implementation for KDE.
*
- * Copyright (C) 1999 Antti Koivisto (koivisto at kde.org)
+ * Copyright (C) 2000 Lars Knoll (knoll at kde.org)
+ * (C) 2000 Antti Koivisto (koivisto at kde.org)
+ * (C) 2000 Dirk Mueller (mueller at kde.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -40,6 +42,7 @@
#include "dom/dom_misc.h"
#include "misc/khtmllayout.h"
+#include "misc/shared.h"
#include "rendering/font.h"
#include <assert.h>
@@ -66,8 +69,13 @@ public:
{
data=0;
}
+ DataRef( const DataRef<DATA> &d )
+ {
+ data = d.data;
+ data->ref();
+ }
- virtual ~DataRef()
+ ~DataRef()
{
if(data) data->deref();
}
@@ -96,8 +104,6 @@ public:
void init()
{
- if (data)
- data->deref();
data = new DATA;
data->ref();
}
@@ -115,28 +121,18 @@ public:
return *this;
}
+ bool operator == ( const DataRef<DATA> &o ) const {
+ return (*data == *(o.data) );
+ }
+ bool operator != ( const DataRef<DATA> &o ) const {
+ return (*data != *(o.data) );
+ }
+
private:
DATA* data;
};
-class SharedData
-{
-public:
- SharedData() { _ref=0; /*counter++;*/ }
- virtual ~SharedData() { /*counter--;*/ }
-
- void ref() { _ref++; }
- void deref() { if(_ref) _ref--; if(_ref<=0) delete this; }
- bool hasOneRef() { //kdDebug(300) << "ref=" << _ref << endl;
- return _ref==1; }
-
-// static int counter;
-protected:
- unsigned int _ref;
-};
-
-
//------------------------------------------------
//------------------------------------------------
@@ -147,6 +143,8 @@ struct LengthBox
LengthBox()
{
}
+ LengthBox( LengthType t )
+ : left( t ), right ( t ), top( t ), bottom( t ) {}
Length left;
Length right;
@@ -216,7 +214,7 @@ public:
};
-class BorderData : public SharedData
+class BorderData : public Shared<BorderData>
{
public:
BorderValue left;
@@ -236,7 +234,7 @@ public:
};
-class StyleSurroundData : public SharedData
+class StyleSurroundData : public Shared<StyleSurroundData>
{
public:
StyleSurroundData();
@@ -260,7 +258,7 @@ public:
const int ZAUTO=0;
-class StyleBoxData : public SharedData
+class StyleBoxData : public Shared<StyleBoxData>
{
public:
StyleBoxData();
@@ -272,11 +270,6 @@ public:
// StyleBoxData(const StyleBoxData &other);
// const StyleBoxData &operator = (const StyleBoxData &other);
- void setDefaultValues()
- {
- z_index = ZAUTO;
- }
-
bool operator==(const StyleBoxData& o) const;
bool operator!=(const StyleBoxData& o) const {
return !(*this == o);
@@ -320,12 +313,12 @@ enum EUnicodeBidi {
UBNormal, Embed, Override
};
-class StyleVisualData : public SharedData
+class StyleVisualData : public Shared<StyleVisualData>
{
public:
StyleVisualData();
- virtual ~StyleVisualData();
+ ~StyleVisualData();
StyleVisualData(const StyleVisualData& o );
@@ -358,40 +351,16 @@ enum EBackgroundRepeat {
-class StyleBackgroundData : public SharedData
+class StyleBackgroundData : public Shared<StyleBackgroundData>
{
public:
- StyleBackgroundData()
- {
- image = 0;
- }
-
- virtual ~StyleBackgroundData()
- {
- }
+ StyleBackgroundData();
+ ~StyleBackgroundData() {}
+ StyleBackgroundData(const StyleBackgroundData& o );
- StyleBackgroundData(const StyleBackgroundData& o ) : SharedData()
- {
- color = o.color;
- image = o.image;
- x_position = o.x_position;
- y_position = o.y_position;
- outline = o.outline;
- }
-
- bool operator==(const StyleBackgroundData& o) const
- {
- return
- color == o.color &&
- image == o.image &&
- x_position == o.x_position &&
- y_position == o.y_position &&
- outline == o.outline;
- }
-
- bool operator!=(const StyleBackgroundData &o) const
- {
- return !(operator==(o));
+ bool operator==(const StyleBackgroundData& o) const;
+ bool operator!=(const StyleBackgroundData &o) const {
+ return !(*this == o);
}
QColor color;
@@ -432,48 +401,16 @@ enum ETextDecoration {
TDNONE = 0x0 , UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH= 0x4, BLINK = 0x8
};
-class StyleInheritedData : public SharedData
+class StyleInheritedData : public Shared<StyleInheritedData>
{
public:
- void setDefaultValues()
- {
- line_height = Length( -100, Percent );
- indent = Length(0, Fixed);
- border_spacing = 0;
- style_image = 0;
- cursor_image = 0;
- }
+ StyleInheritedData();
+ ~StyleInheritedData();
+ StyleInheritedData(const StyleInheritedData& o );
- StyleInheritedData() : SharedData(), font() { setDefaultValues(); }
- virtual ~StyleInheritedData() { }
-
- StyleInheritedData(const StyleInheritedData& o )
- : SharedData(), font( o.font ), color( o.color ), decoration_color( o.decoration_color )
- {
- indent = o.indent;
- line_height = o.line_height;
- border_spacing = o.border_spacing;
- style_image = o.style_image;
- cursor_image = o.cursor_image;
- }
-
- bool operator==(const StyleInheritedData& o) const
- {
- return indent == o.indent &&
- line_height == o.line_height &&
- border_spacing == o.border_spacing &&
- style_image == o.style_image &&
- cursor_image == o.cursor_image &&
- font == o.font &&
- color == o.color &&
- decoration_color == o.decoration_color;
-
- // doesn't work because structs are not packed
- //return memcmp(this, &o, sizeof(*this))==0;
- }
- bool operator != ( const StyleInheritedData &o ) const
- {
- return !(operator==( o ) );
+ bool operator==(const StyleInheritedData& o) const;
+ bool operator != ( const StyleInheritedData &o ) const {
+ return !(*this == o);
}
Length indent;
@@ -524,6 +461,23 @@ enum EFontVariant {
FVNORMAL, SMALL_CAPS
};
+enum ContentType {
+ CONTENT_NONE, CONTENT_OBJECT, CONTENT_TEXT, CONTENT_COUNTER
+};
+
+struct ContentData {
+ ~ContentData();
+ void clearContent();
+
+ ContentType _contentType;
+
+ union {
+ CachedObject* object;
+ DOM::DOMStringImpl* text;
+ // counters...
+ } _content ;
+};
+
//------------------------------------------------
enum EDisplay {
@@ -534,7 +488,7 @@ enum EDisplay {
TABLE_CAPTION, NONE
};
-class RenderStyle : public DOM::DomShared
+class RenderStyle : public Shared<RenderStyle>
{
friend class CSSStyleSelector;
public:
@@ -544,7 +498,6 @@ public:
enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER };
protected:
- void setBitDefaults();
// !START SYNC!: Keep this in sync with the copy constructor in render_style.cpp
@@ -558,7 +511,6 @@ protected:
return *((Q_UINT32 *)this) != *((Q_UINT32 *)&other);
}
- bool _border_collapse : 1 ;
EEmptyCell _empty_cells : 1 ;
ECaptionSide _caption_side : 2;
EListStyleType _list_style_type : 5 ;
@@ -566,10 +518,11 @@ protected:
EVisibility _visibility : 2;
ETextAlign _text_align : 3;
ETextTransform _text_transform : 2;
- EDirection _direction : 1;
- EWhiteSpace _white_space : 2;
int _text_decoration : 4;
ECursor _cursor_style : 4;
+ EDirection _direction : 1;
+ bool _border_collapse : 1 ;
+ EWhiteSpace _white_space : 2;
EFontVariant _font_variant : 1;
// non CSS2 inherited
bool _visuallyOrdered : 1;
@@ -588,14 +541,14 @@ protected:
}
EDisplay _display : 5;
+ EBackgroundRepeat _bg_repeat : 2;
+ bool _bg_attachment : 1;
EOverflow _overflow : 4 ;
EVerticalAlign _vertical_align : 4;
EClear _clear : 2;
- ETableLayout _table_layout : 1;
- EBackgroundRepeat _bg_repeat : 2;
- bool _bg_attachment : 1;
EPosition _position : 2;
EFloat _floating : 2;
+ ETableLayout _table_layout : 1;
bool _flowAroundFloats :1;
PseudoId _styleType : 3;
@@ -617,6 +570,9 @@ protected:
// list of associated pseudo styles
RenderStyle* pseudoStyle;
+ // added this here, so we can get rid of the vptr in this class.
+ // makes up for the same size.
+ ContentData *content;
// !END SYNC!
// static default style
@@ -625,6 +581,43 @@ protected:
private:
RenderStyle(const RenderStyle*) {}
+protected:
+ void setBitDefaults()
+ {
+ inherited_flags._empty_cells = SHOW;
+ inherited_flags._caption_side = CAPTOP;
+ inherited_flags._list_style_type = DISC;
+ inherited_flags._list_style_position = OUTSIDE;
+ inherited_flags._visibility = VISIBLE;
+ inherited_flags._text_align = TAAUTO;
+ inherited_flags._text_transform = TTNONE;
+ inherited_flags._text_decoration = TDNONE;
+ inherited_flags._cursor_style = CURSOR_AUTO;
+ inherited_flags._direction = LTR;
+ inherited_flags._border_collapse = true;
+ inherited_flags._white_space = NORMAL;
+ inherited_flags._font_variant = FVNORMAL;
+ inherited_flags._visuallyOrdered = false;
+ inherited_flags._htmlHacks=false;
+ inherited_flags._unused = 0;
+
+ noninherited_flags._display = INLINE;
+ noninherited_flags._bg_repeat = REPEAT;
+ noninherited_flags._bg_attachment = SCROLL;
+ noninherited_flags._overflow = OVISIBLE;
+ noninherited_flags._vertical_align = BASELINE;
+ noninherited_flags._clear = CNONE;
+ noninherited_flags._position = STATIC;
+ noninherited_flags._floating = FNONE;
+ noninherited_flags._table_layout = TAUTO;
+ noninherited_flags._flowAroundFloats=false;
+ noninherited_flags._styleType = NOPSEUDO;
+ noninherited_flags._hasHover = false;
+ noninherited_flags._hasActive = false;
+ noninherited_flags._jsClipMode = false;
+ noninherited_flags._unicodeBidi = UBNormal;
+ }
+
public:
RenderStyle();
@@ -632,7 +625,7 @@ public:
RenderStyle(bool);
RenderStyle(const RenderStyle&);
- virtual ~RenderStyle();
+ ~RenderStyle();
void inheritFrom(const RenderStyle* inheritParent);
@@ -818,6 +811,7 @@ public:
void setClipRight(Length v) { SET_VAR(visual,clip.right,v) }
void setClipTop(Length v) { SET_VAR(visual,clip.top,v) }
void setClipBottom(Length v) { SET_VAR(visual,clip.bottom,v) }
+ void setClip( Length top, Length right, Length bottom, Length left );
void setJsClipMode( bool b ) { noninherited_flags._jsClipMode = b; }
void setUnicodeBidi( EUnicodeBidi b ) { noninherited_flags._unicodeBidi = b; }
@@ -893,28 +887,33 @@ public:
void setZIndex(int v) { SET_VAR(box,z_index,v) }
QPalette palette() const { return visual->palette; }
- void setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c)
- {
- visual.access()->palette.setColor(g,r,c);
- }
+ void setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c);
void resetPalette() // Called when the desktop color scheme changes.
{
const_cast<StyleVisualData *>(visual.get())->palette = QApplication::palette();
}
- enum ContentType
- {
- CONTENT_NONE, CONTENT_OBJECT, CONTENT_TEXT, CONTENT_COUNTER
- };
+ ContentType contentType() { return content ? content->_contentType : CONTENT_NONE; }
- virtual ContentType contentType() { return CONTENT_NONE; }
+ DOM::DOMStringImpl* contentText()
+ {
+ if (content && content->_contentType==CONTENT_TEXT)
+ return content->_content.text;
+ else
+ return 0;
+ }
- virtual void setContent(DOM::DOMStringImpl* /*s*/) { assert(false); }
- virtual void setContent(CachedObject* /*o*/) { assert(false); }
+ CachedObject* contentObject()
+ {
+ if (content && content->_contentType==CONTENT_OBJECT)
+ return content->_content.object;
+ else
+ return 0;
+ }
- virtual DOM::DOMStringImpl* contentText() { return 0; }
- virtual CachedObject* contentObject() { return 0; }
+ void setContent(DOM::DOMStringImpl* s);
+ void setContent(CachedObject* o);
bool inheritedNotEqual( RenderStyle *other ) const;
@@ -923,40 +922,6 @@ public:
};
-class RenderPseudoElementStyle : public RenderStyle
-{
-public:
-
- RenderPseudoElementStyle();
- RenderPseudoElementStyle(bool b);
- RenderPseudoElementStyle(const RenderStyle& r);
-
- virtual ~RenderPseudoElementStyle();
-
- ContentType contentType() { return _contentType; }
-
- void setContent(DOM::DOMStringImpl* s);
- void setContent(CachedObject* o);
-
- DOM::DOMStringImpl* contentText();
- CachedObject* contentObject();
-
-
-private:
-
- void clearContent();
-
- ContentType _contentType;
-
- union {
- CachedObject* object;
- DOM::DOMStringImpl* text;
- // counters...
- } _content ;
-
-};
-
-
} // namespace
#endif
diff --git a/WebCore/khtml/rendering/render_table.cpp b/WebCore/khtml/rendering/render_table.cpp
index 707840d..bb6de21 100644
--- a/WebCore/khtml/rendering/render_table.cpp
+++ b/WebCore/khtml/rendering/render_table.cpp
@@ -203,7 +203,7 @@ void RenderTable::addChild(RenderObject *child, RenderObject *beforeChild)
o = beforeChild;
else {
RenderObject *lastBox = beforeChild;
- while ( lastBox && lastBox->parent()->isAnonymousBox() &&
+ while ( lastBox && lastBox->parent()->isAnonymousBox() &&
!lastBox->isTableSection() && lastBox->style()->display() != TABLE_CAPTION )
lastBox = lastBox->parent();
if ( lastBox && lastBox->isAnonymousBox() ) {
@@ -419,7 +419,7 @@ void RenderTable::addColInfo(RenderTableCol *colel)
int span = colel->span();
int _minSize=0;
int _maxSize=0;
- Length _width = colel->width();
+ Length _width = colel->style()->width();
if (_width.type==Fixed) {
_maxSize=_width.value;
_minSize=_width.value;
@@ -580,60 +580,22 @@ void RenderTable::spreadSpanMinMax(int col, int span, int distmin,
}
}
- if (hasUsableCols)
- {
+ if (hasUsableCols) {
// spread span maxWidth
- LengthType tt = Undefined;
- bool out=false;
- while (tt<=type && !out && tmax)
- {
- tmax = distributeMaxWidth(tmax,type,tt,col,span);
- switch (tt)
- {
- case Undefined: tt=Variable; break;
- case Variable: tt=Relative; break;
- case Relative: tt=Percent; break;
- case Percent: tt=Fixed; break;
- default: out=true; break;
- }
- }
+ for (int i = LengthType(Variable); i <= int(Fixed) && i <= type && tmax; ++i)
+ tmax = distributeMaxWidth(tmax,type,LengthType(i),col,span);
// spread span minWidth
- tt = Undefined;
- out=false;
- while (tt<=type && !out && tmin)
- {
- tmin = distributeMinWidth(tmin,type,tt,col,span,true);
- switch (tt)
- {
- case Undefined: tt=Variable; break;
- case Variable: tt=Relative; break;
- case Relative: tt=Percent; break;
- case Percent: tt=Fixed; break;
- default: out=true; break;
- }
- }
+ for (int i = LengthType(Variable); i <= int(Fixed) && i <= type && tmin; ++i)
+ tmin = distributeMinWidth(tmin,type,LengthType(i),col,span,true);
// force spread rest of the minWidth
- tt = Undefined;
- out=false;
- while (!out && tmin)
- {
- tmin = distributeMinWidth(tmin,type,tt,col,span,false);
- switch (tt)
- {
- case Undefined: tt=Variable; break;
- case Variable: tt=Relative; break;
- case Relative: tt=Percent; break;
- case Percent: tt=Fixed; break;
- default: out=true; break;
- }
- }
+ for (int i = LengthType(Variable); i <= int(Fixed) && tmin; ++i)
+ tmin = distributeMinWidth(tmin,type,LengthType(i),col,span,false);
for (int c=col; c < col+span ; ++c)
colMaxWidth[c]=KMAX(colMinWidth[c],colMaxWidth[c]);
-
}
}
@@ -924,8 +886,8 @@ void RenderTable::calcColMinMax()
hasPercent=false;
bool hasRel=false;
bool hasVar=false;
-
- int maxPercentColumn=0;
+
+ int maxPercentColumn=0;
int maxTentativePercentWidth=0;
m_minWidth = spacing;
@@ -944,13 +906,13 @@ void RenderTable::calcColMinMax()
minPercent=maxPercent=spacing;
}
totalPercent += colValue[i];
-
+
maxPercentColumn = KMAX(colValue[i],maxPercentColumn);
-
+
minPercent += colMinWidth[i] + spacing;
maxPercent += colMaxWidth[i] + spacing;
-
- maxTentativePercentWidth = KMAX(colValue[i]==0?0:colMaxWidth[i]*100/colValue[i],
+
+ maxTentativePercentWidth = KMAX(colValue[i]==0?0:colMaxWidth[i]*100/colValue[i],
maxTentativePercentWidth);
break;
case Relative:
@@ -962,7 +924,6 @@ void RenderTable::calcColMinMax()
minRel += colMinWidth[i] + spacing;
maxRel += colMaxWidth[i] + spacing;
break;
- case Undefined:
case Variable:
case Fixed:
default:
@@ -988,8 +949,8 @@ void RenderTable::calcColMinMax()
int tot = KMIN(100u, totalPercent );
if (tot>0)
- m_maxWidth = maxPercent*100/tot;
-
+ m_maxWidth = maxPercent*100/tot;
+
if (tot<100)
m_maxWidth = KMAX( short((maxVar+maxRel)*100/(100-tot)), m_maxWidth );
else if (hasRel || hasVar || ((int)totalPercent>maxPercentColumn && maxPercentColumn>=100))
@@ -1051,7 +1012,7 @@ void RenderTable::calcWidth()
// restrict width to what we really have in case we flow around floats
if ( style()->flowAroundFloats() && cb->isFlow() )
m_width = QMIN( static_cast<RenderFlow *>(cb)->lineWidth( m_y ) - borderWidth, m_width );
-
+
m_width = KMAX (m_width, m_minWidth);
m_marginRight=0;
@@ -1141,7 +1102,6 @@ void RenderTable::calcColWidth(void)
maxRel += colMaxWidth[i];
numRel++;
break;
- case Undefined:
case Variable:
default:
minVar += colMinWidth[i];
@@ -2281,16 +2241,6 @@ void RenderTableCol::addChild(RenderObject *child, RenderObject *beforeChild)
}
}
-Length RenderTableCol::width()
-{
- if (style()->width().type == Undefined
- && parent() &&
- parent()->style()->display()==TABLE_COLUMN_GROUP)
- return static_cast<RenderTableCol*>(parent())->width();
- else
- return style()->width();
-}
-
#ifndef NDEBUG
void RenderTableCol::dump(QTextStream *stream, QString ind) const
{
diff --git a/WebCore/khtml/rendering/render_table.h b/WebCore/khtml/rendering/render_table.h
index cd7e606..01bde1f 100644
--- a/WebCore/khtml/rendering/render_table.h
+++ b/WebCore/khtml/rendering/render_table.h
@@ -103,7 +103,7 @@ public:
RenderTableCell* _cell, bool recalc = true);
void recalcColInfos();
-
+
// overrides
virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
virtual void print( QPainter *, int x, int y, int w, int h,
@@ -159,7 +159,7 @@ public:
start = 0;
min=0;
max=0;
- type=khtml::Undefined;
+ type=khtml::Variable;
value=0;
minCell=0;
maxCell=0;
@@ -444,7 +444,6 @@ public:
long span() const { return _span; }
void setSpan( long s ) { _span = s; }
- khtml::Length width();
virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 88dfc56..332f841 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -265,7 +265,7 @@ void RenderText::setStyle(RenderStyle *_style)
RenderObject::setStyle( _style );
m_lineHeight = RenderObject::lineHeight(false);
- if (changedText && element())
+ if (changedText && element() && element()->string())
setText(element()->string(), changedText);
}
}
@@ -332,16 +332,10 @@ bool RenderText::nodeAtPoint(NodeInfo& /*info*/, int _x, int _y, int _tx, int _t
break;
}
- s = si < (int)m_lines.count()-1 ? m_lines[++si] : 0;
+ s = si < (int) m_lines.count()-1 ? m_lines[++si] : 0;
}
-#ifndef APPLE_CHANGES
- bool oldinside = mouseInside();
-#endif
setMouseInside(inside);
-// don't need this, no DOM Element associated with us
-// if (mouseInside() != oldinside && element())
-// element()->setChanged();
return inside;
}
@@ -723,7 +717,7 @@ void RenderText::setText(DOMStringImpl *text, bool force)
if(str) str->deref();
str = text;
- if ( style() ) {
+ if ( str && style() ) {
if ( style()->fontVariant() == SMALL_CAPS )
str = str->upper();
else
@@ -734,8 +728,8 @@ void RenderText::setText(DOMStringImpl *text, bool force)
case NONE:
default:;
}
+ str->ref();
}
- if(str) str->ref();
// ### what should happen if we change the text of a
// RenderBR object ?
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index 160328d..d334034 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -137,6 +137,7 @@ public:
unsigned int length() const { return str->l; }
QChar *text() const { return str->s; }
+ unsigned int stringLength() const { return str->l; } // non virtual implementation of length()
virtual void position(int x, int y, int from, int len, int width, bool reverse, bool firstLine, int spaceAdd);
virtual unsigned int width(unsigned int from, unsigned int len, const Font *f) const;
diff --git a/WebCore/khtml/xml/dom2_eventsimpl.h b/WebCore/khtml/xml/dom2_eventsimpl.h
index f1b59ff..a1585d3 100644
--- a/WebCore/khtml/xml/dom2_eventsimpl.h
+++ b/WebCore/khtml/xml/dom2_eventsimpl.h
@@ -25,6 +25,7 @@
#define _DOM_EventsImpl_h_
#include "dom/dom2_events.h"
+#include "misc/shared.h"
#include "xml/dom2_viewsimpl.h"
#include <qdatetime.h>
#include <qevent.h>
@@ -39,7 +40,7 @@ class NodeImpl;
// ### support user-defined events
-class EventImpl : public DomShared
+class EventImpl : public khtml::Shared<EventImpl>
{
public:
enum EventId {
diff --git a/WebCore/khtml/xml/dom2_rangeimpl.h b/WebCore/khtml/xml/dom2_rangeimpl.h
index ce06b35..a29b9d5 100644
--- a/WebCore/khtml/xml/dom2_rangeimpl.h
+++ b/WebCore/khtml/xml/dom2_rangeimpl.h
@@ -27,10 +27,11 @@
#define _DOM2_RangeImpl_h_
#include "dom/dom2_range.h"
+#include "misc/shared.h"
namespace DOM {
-class RangeImpl : public DomShared
+class RangeImpl : public khtml::Shared<RangeImpl>
{
friend class DocumentImpl;
public:
diff --git a/WebCore/khtml/xml/dom2_traversalimpl.cpp b/WebCore/khtml/xml/dom2_traversalimpl.cpp
index 303d265..49c518c 100644
--- a/WebCore/khtml/xml/dom2_traversalimpl.cpp
+++ b/WebCore/khtml/xml/dom2_traversalimpl.cpp
@@ -305,7 +305,8 @@ TreeWalkerImpl::TreeWalkerImpl()
m_expandEntityReferences = true;
}
-TreeWalkerImpl::TreeWalkerImpl(const TreeWalkerImpl &other) : DomShared()
+TreeWalkerImpl::TreeWalkerImpl(const TreeWalkerImpl &other)
+ : khtml::Shared<TreeWalkerImpl>()
{
m_expandEntityReferences = other.m_expandEntityReferences;
m_filter = other.m_filter;
diff --git a/WebCore/khtml/xml/dom2_traversalimpl.h b/WebCore/khtml/xml/dom2_traversalimpl.h
index f54d990..1a218d0 100644
--- a/WebCore/khtml/xml/dom2_traversalimpl.h
+++ b/WebCore/khtml/xml/dom2_traversalimpl.h
@@ -27,6 +27,7 @@
#include "dom/dom_node.h"
#include "dom/dom_misc.h"
+#include "misc/shared.h"
#include "dom/dom2_traversal.h"
namespace DOM {
@@ -34,7 +35,7 @@ namespace DOM {
class NodeImpl;
class DocumentImpl;
-class NodeIteratorImpl : public DomShared
+class NodeIteratorImpl : public khtml::Shared<NodeIteratorImpl>
{
public:
NodeIteratorImpl(NodeImpl *_root, unsigned long _whatToShow, NodeFilter _filter, bool _entityReferenceExpansion);
@@ -75,13 +76,13 @@ protected:
DocumentImpl *m_doc;
};
-class NodeFilterImpl : public DomShared
+class NodeFilterImpl : public khtml::Shared<NodeFilterImpl>
{
public:
NodeFilterImpl();
~NodeFilterImpl();
- virtual short acceptNode(const Node &n);
+ short acceptNode(const Node &n);
void setCustomNodeFilter(CustomNodeFilter *custom);
CustomNodeFilter *customNodeFilter();
@@ -90,7 +91,7 @@ protected:
};
-class TreeWalkerImpl : public DomShared
+class TreeWalkerImpl : public khtml::Shared<TreeWalkerImpl>
{
public:
TreeWalkerImpl();
diff --git a/WebCore/khtml/xml/dom2_viewsimpl.h b/WebCore/khtml/xml/dom2_viewsimpl.h
index d49d58b..20e547c 100644
--- a/WebCore/khtml/xml/dom2_viewsimpl.h
+++ b/WebCore/khtml/xml/dom2_viewsimpl.h
@@ -25,6 +25,7 @@
#include "dom/dom_misc.h"
#include "css/css_valueimpl.h"
+#include "misc/shared.h"
namespace DOM {
@@ -34,7 +35,7 @@ class ElementImpl;
class DOMStringImpl;
// Introduced in DOM Level 2:
-class AbstractViewImpl : public DomShared
+class AbstractViewImpl : public khtml::Shared<AbstractViewImpl>
{
public:
AbstractViewImpl(DocumentImpl *_document);
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 03d276d..447f50d 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -384,11 +384,13 @@ NodeImpl *DocumentImpl::importNode( NodeImpl */*importedNode*/, bool /*deep*/,
ElementImpl *DocumentImpl::createElementNS( const DOMString &_namespaceURI, const DOMString &_qualifiedName )
{
ElementImpl *e = 0;
- if (_namespaceURI == XHTML_NAMESPACE) {
+ QString qName = _qualifiedName.string();
+ int colonPos = qName.find(':',0);
+
+ if ((_namespaceURI.isNull() && colonPos < 0) ||
+ _namespaceURI == XHTML_NAMESPACE) {
// User requested an element in the XHTML namespace - this means we create a HTML element
// (elements not in this namespace are treated as normal XML elements)
- QString qName = _qualifiedName.string();
- int colonPos = qName.find(':',0);
e = createHTMLElement(qName.mid(colonPos+1));
int exceptioncode = 0;
if (colonPos >= 0)
@@ -447,6 +449,9 @@ void DocumentImpl::setTitle(DOMString _title)
view()->part()->setTitle(_title);
#else
QString titleStr = m_title.string();
+ for (int i = 0; i < titleStr.length(); ++i)
+ if (titleStr[i] < ' ')
+ titleStr[i] = ' ';
titleStr.compose();
if ( !view()->part()->parentPart() ) {
if (titleStr.isNull() || titleStr.isEmpty()) {
@@ -1375,11 +1380,11 @@ void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &con
}
}
-bool DocumentImpl::prepareMouseEvent( int _x, int _y, MouseEvent *ev )
+bool DocumentImpl::prepareMouseEvent( bool readonly, int _x, int _y, MouseEvent *ev )
{
if ( m_render ) {
assert(m_render->isRoot());
- RenderObject::NodeInfo renderInfo(false, ev->type == MousePress);
+ RenderObject::NodeInfo renderInfo(readonly, ev->type == MousePress);
bool isInside = m_render->nodeAtPoint(renderInfo, _x, _y, 0, 0);
ev->innerNode = renderInfo.innerNode();
@@ -1398,7 +1403,8 @@ bool DocumentImpl::prepareMouseEvent( int _x, int _y, MouseEvent *ev )
// qDebug("url: *%s*", ev->url.string().latin1());
}
- updateRendering();
+ if (!readonly)
+ updateRendering();
return isInside;
}
@@ -1808,17 +1814,17 @@ void DocumentImpl::setFocusNode(NodeImpl *newFocusNode)
if (m_focusNode) {
m_focusNode->ref();
m_focusNode->dispatchHTMLEvent(EventImpl::FOCUS_EVENT,false,false);
+ if (m_focusNode != newFocusNode) return;
m_focusNode->dispatchUIEvent(EventImpl::DOMFOCUSIN_EVENT);
- if (m_focusNode == newFocusNode) {
- m_focusNode->setFocus();
- // eww, I suck. set the qt focus correctly
- // ### find a better place in the code for this
- if (getDocument()->view()) {
- if (!m_focusNode->renderer() || !m_focusNode->renderer()->isWidget())
- getDocument()->view()->setFocus();
- else if (static_cast<RenderWidget*>(m_focusNode->renderer())->widget())
- static_cast<RenderWidget*>(m_focusNode->renderer())->widget()->setFocus();
- }
+ if (m_focusNode != newFocusNode) return;
+ m_focusNode->setFocus();
+ // eww, I suck. set the qt focus correctly
+ // ### find a better place in the code for this
+ if (getDocument()->view()) {
+ if (!m_focusNode->renderer() || !m_focusNode->renderer()->isWidget())
+ getDocument()->view()->setFocus();
+ else if (static_cast<RenderWidget*>(m_focusNode->renderer())->widget())
+ static_cast<RenderWidget*>(m_focusNode->renderer())->widget()->setFocus();
}
}
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 474c502..14cb91c 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -26,6 +26,7 @@
#include "xml/dom_elementimpl.h"
#include "xml/dom2_traversalimpl.h"
+#include "misc/shared.h"
#include <qstringlist.h>
#include <qptrlist.h>
@@ -76,7 +77,7 @@ namespace DOM {
class TextImpl;
class TreeWalkerImpl;
-class DOMImplementationImpl : public DomShared
+class DOMImplementationImpl : public khtml::Shared<DOMImplementationImpl>
{
public:
DOMImplementationImpl();
@@ -265,7 +266,7 @@ public:
// internal
NodeImpl *findElement( Id id );
- bool prepareMouseEvent( int x, int y, MouseEvent *ev );
+ bool prepareMouseEvent( bool readonly, int x, int y, MouseEvent *ev );
virtual bool childAllowed( NodeImpl *newChild );
virtual bool childTypeAllowed( unsigned short nodeType );
diff --git a/WebCore/khtml/xml/dom_elementimpl.h b/WebCore/khtml/xml/dom_elementimpl.h
index 83b3f87..032f316 100644
--- a/WebCore/khtml/xml/dom_elementimpl.h
+++ b/WebCore/khtml/xml/dom_elementimpl.h
@@ -28,6 +28,7 @@
#include "dom_nodeimpl.h"
#include "dom/dom_element.h"
#include "xml/dom_stringimpl.h"
+#include "misc/shared.h"
#ifdef APPLE_CHANGES
#ifdef __OBJC__
@@ -50,7 +51,7 @@ class NamedAttrMapImpl;
// the actual Attr (AttrImpl) with its value as textchild
// is only allocated on demand by the DOM bindings.
// Any use of AttrImpl inside khtml should be avoided.
-class AttributeImpl : public DOM::DomShared
+class AttributeImpl : public khtml::Shared<AttributeImpl>
{
friend class NamedAttrMapImpl;
friend class ElementImpl;
@@ -59,8 +60,7 @@ class AttributeImpl : public DOM::DomShared
public:
// null value is forbidden !
AttributeImpl(NodeImpl::Id id, DOMStringImpl* value)
- : DomShared(),
- m_id(id), _prefix(0), _value(value), _impl(0)
+ : m_id(id), _prefix(0), _value(value), _impl(0)
{ _value->ref(); };
~AttributeImpl() {
if (_prefix) _prefix->deref();
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index bbc2bac..54b9e93 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -49,7 +49,6 @@ const Q_UINT32 NodeImpl::IdLocalMask = 0x0000ffff;
NodeImpl::NodeImpl(DocumentPtr *doc)
: document(doc),
- m_parent(0),
m_previous(0),
m_next(0),
m_render(0),
@@ -916,11 +915,6 @@ void NodeImpl::dump(QTextStream *stream, QString ind) const
}
#endif
-bool NodeImpl::deleteMe()
-{
- return !m_parent && !_ref;
-}
-
void NodeImpl::init()
{
}
@@ -1014,8 +1008,7 @@ NodeBaseImpl::~NodeBaseImpl()
n->setPreviousSibling(0);
n->setNextSibling(0);
n->setParent(0);
-
- if(n->deleteMe())
+ if ( !n->refCount() )
delete n;
}
}
@@ -1246,7 +1239,7 @@ void NodeBaseImpl::removeChildren()
n->setPreviousSibling(0);
n->setNextSibling(0);
n->setParent(0);
- if(n->deleteMe())
+ if( !n->refCount() )
delete n;
}
_first = _last = 0;
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index cabcde4..f8149e8 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -28,6 +28,7 @@
#include "dom/dom_string.h"
#include "dom/dom_node.h"
#include "misc/helper.h"
+#include "misc/shared.h"
// The namespace used for XHTML elements
#define XHTML_NAMESPACE "http://www.w3.org/1999/xhtml"
@@ -54,13 +55,12 @@ class CSSStyleDeclarationImpl;
class RegisteredEventListener;
class EventImpl;
-class DocumentPtr : public DomShared
+class DocumentPtr : public khtml::Shared<DocumentPtr>
{
public:
DocumentImpl *document() const { return doc; }
private:
DocumentPtr() { doc = 0; }
- void resetDocument() { doc = 0; }
friend class DocumentImpl;
friend class DOMImplementationImpl;
@@ -68,7 +68,7 @@ private:
};
// this class implements nodes, which can have a parent but no children:
-class NodeImpl : public DomShared
+class NodeImpl : public khtml::TreeShared<NodeImpl>
{
friend class DocumentImpl;
public:
@@ -107,10 +107,8 @@ public:
// helper functions not being part of the DOM
// Attention: they assume that the caller did the consistency checking!
- void setParent(NodeImpl *parent) { m_parent = parent; }
void setPreviousSibling(NodeImpl *previous) { m_previous = previous; }
void setNextSibling(NodeImpl *next) { m_next = next; }
- virtual bool deleteMe();
virtual void setFirstChild(NodeImpl *child);
virtual void setLastChild(NodeImpl *child);
@@ -361,7 +359,6 @@ public:
private: // members
DocumentPtr *document;
- NodeImpl *m_parent;
NodeImpl *m_previous;
NodeImpl *m_next;
protected:
@@ -452,9 +449,10 @@ protected:
class Node;
class NodeImpl;
-class NodeListImpl : public DomShared
+class NodeListImpl : public khtml::Shared<NodeListImpl>
{
public:
+ virtual ~NodeListImpl() {}
// DOM methods & attributes for NodeList
virtual unsigned long length() const;
@@ -539,7 +537,7 @@ protected:
// Generic NamedNodeMap interface
// Other classes implement this for more specific situations e.g. attributes
// of an element
-class NamedNodeMapImpl : public DomShared
+class NamedNodeMapImpl : public khtml::Shared<NamedNodeMapImpl>
{
public:
NamedNodeMapImpl();
diff --git a/WebCore/khtml/xml/dom_stringimpl.cpp b/WebCore/khtml/xml/dom_stringimpl.cpp
index d385730..78d607c 100644
--- a/WebCore/khtml/xml/dom_stringimpl.cpp
+++ b/WebCore/khtml/xml/dom_stringimpl.cpp
@@ -36,28 +36,9 @@ namespace DOM {
using khtml::Fixed;
#endif
-#define QT_ALLOC_QCHAR_VEC( N ) (QChar*) new char[ sizeof(QChar)*( N ) ]
-#define QT_DELETE_QCHAR_VEC( P ) delete[] ((char*)( P ))
-
-DOMStringImpl::DOMStringImpl(const QChar *str, uint len)
-{
- if(str && len)
- {
- s = QT_ALLOC_QCHAR_VEC( len );
- memcpy( s, str, len * sizeof(QChar) );
- l = len;
- }
- else
- {
- s = QT_ALLOC_QCHAR_VEC( 1 ); // crash protection
- s[0] = QChar::null;
- l = 0;
- }
-}
-
DOMStringImpl::DOMStringImpl(const char *str)
{
- if(str)
+ if(str && *str)
{
l = strlen(str);
s = QT_ALLOC_QCHAR_VEC( l );
@@ -69,23 +50,11 @@ DOMStringImpl::DOMStringImpl(const char *str)
else
{
s = QT_ALLOC_QCHAR_VEC( 1 ); // crash protection
- s[0] = QChar::null;
+ s[0] = 0x0; // == QChar::null;
l = 0;
}
}
-DOMStringImpl::DOMStringImpl(const QChar &ch)
-{
- s = QT_ALLOC_QCHAR_VEC( 1 );
- s[0] = ch;
- l = 1;
-}
-
-DOMStringImpl::~DOMStringImpl()
-{
- if(s) QT_DELETE_QCHAR_VEC(s);
-}
-
void DOMStringImpl::append(DOMStringImpl *str)
{
if(str && str->l != 0)
@@ -200,10 +169,7 @@ static Length parseLength(QChar *s, unsigned int l)
if(ok) {
return Length(v, Fixed);
}
- if(l == 4 && QConstString(s, l).string().contains("auto", false))
- return Length(0, Variable);
-
- return Length(0, Undefined);
+ return Length(0, Variable);
}
Length DOMStringImpl::toLength() const
diff --git a/WebCore/khtml/xml/dom_stringimpl.h b/WebCore/khtml/xml/dom_stringimpl.h
index 54e5b00..903208e 100644
--- a/WebCore/khtml/xml/dom_stringimpl.h
+++ b/WebCore/khtml/xml/dom_stringimpl.h
@@ -26,20 +26,40 @@
#include "dom/dom_misc.h"
#include "misc/khtmllayout.h"
+#include "misc/shared.h"
-class QChar;
+#define QT_ALLOC_QCHAR_VEC( N ) (QChar*) new char[ sizeof(QChar)*( N ) ]
+#define QT_DELETE_QCHAR_VEC( P ) delete[] ((char*)( P ))
namespace DOM {
-class DOMStringImpl : public DomShared
+class DOMStringImpl : public khtml::Shared<DOMStringImpl>
{
protected:
DOMStringImpl() { s = 0, l = 0; }
public:
- DOMStringImpl(const QChar *str, unsigned int len);
+ DOMStringImpl(const QChar *str, unsigned int len) {
+ bool havestr = str && len;
+ s = QT_ALLOC_QCHAR_VEC( havestr ? len : 1 );
+ if(str && len) {
+ memcpy( s, str, len * sizeof(QChar) );
+ l = len;
+ } else {
+ // crash protection
+ s[0] = 0x0;
+ l = 0;
+ }
+ }
+
DOMStringImpl(const char *str);
- DOMStringImpl(const QChar &ch);
- virtual ~DOMStringImpl();
+ DOMStringImpl(const QChar &ch) {
+ s = QT_ALLOC_QCHAR_VEC( 1 );
+ s[0] = ch;
+ l = 1;
+ }
+ ~DOMStringImpl() {
+ if(s) QT_DELETE_QCHAR_VEC(s);
+ }
void append(DOMStringImpl *str);
void insert(DOMStringImpl *str, unsigned int pos);
diff --git a/WebCore/khtml/xml/xml_tokenizer.h b/WebCore/khtml/xml/xml_tokenizer.h
index 21e9c5f..bf8e3f6 100644
--- a/WebCore/khtml/xml/xml_tokenizer.h
+++ b/WebCore/khtml/xml/xml_tokenizer.h
@@ -120,7 +120,6 @@ signals:
class XMLTokenizer : public Tokenizer, public khtml::CachedObjectClient
{
- Q_OBJECT
public:
XMLTokenizer(DOM::DocumentPtr *, KHTMLView * = 0);
virtual ~XMLTokenizer();
diff --git a/WebCore/kwq/KWQColorGroup.mm b/WebCore/kwq/KWQColorGroup.mm
index 4dcb189..e2eaa6d 100644
--- a/WebCore/kwq/KWQColorGroup.mm
+++ b/WebCore/kwq/KWQColorGroup.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -22,168 +22,105 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
#include <qpalette.h>
-#include <qcolor.h>
-
-#define QCOLOR_GROUP_SIZE (QColorGroup::HighlightedText + 1)
-
-class QColorGroupPrivate
-{
-friend class QColorGroup;
-public:
- QColorGroupPrivate() {
- brushes = new QBrush[QCOLOR_GROUP_SIZE];
- brushes[QColorGroup::Foreground] = QColor(255,255,255);
- brushes[QColorGroup::Shadow] = QColor(255,255,255);
- brushes[QColorGroup::Light] = QColor(224,224,224);
- brushes[QColorGroup::Midlight] = QColor(192,192,192);
- brushes[QColorGroup::Mid] = QColor(128,128,128);
- brushes[QColorGroup::Dark] = QColor(64,64,64);
- brushes[QColorGroup::Base] = QColor(255,255,255);
- brushes[QColorGroup::ButtonText] = QColor(0,0,0);
- brushes[QColorGroup::Button] = QColor(192,192,192);
- brushes[QColorGroup::Background] = QColor(255,255,255);
- brushes[QColorGroup::Text] = QColor(0,0,0);
- brushes[QColorGroup::Highlight] = QColor(64,64,64);
- brushes[QColorGroup::HighlightedText] = QColor(0,0,0);
- }
-
- QColorGroupPrivate(const QColorGroupPrivate *other) {
- brushes = new QBrush[QCOLOR_GROUP_SIZE];
- for (int i = 0; i < QCOLOR_GROUP_SIZE; i++) {
- brushes[i] = other->brushes[i];
- }
- }
-
- ~QColorGroupPrivate() {
- delete [] brushes;
- }
-
-private:
- QBrush *brushes;
-};
QColorGroup::QColorGroup()
{
- d = new QColorGroupPrivate();
+ brushes[Foreground] = QColor(255,255,255);
+ brushes[Shadow] = QColor(255,255,255);
+ brushes[Light] = QColor(224,224,224);
+ brushes[Midlight] = QColor(192,192,192);
+ brushes[Mid] = QColor(128,128,128);
+ brushes[Dark] = QColor(64,64,64);
+ brushes[Base] = QColor(255,255,255);
+ brushes[ButtonText] = QColor(0,0,0);
+ brushes[Button] = QColor(192,192,192);
+ brushes[Background] = QColor(255,255,255);
+ brushes[Text] = QColor(0,0,0);
+ brushes[Highlight] = QColor(64,64,64);
+ brushes[HighlightedText] = QColor(0,0,0);
}
-
-QColorGroup::QColorGroup(const QColorGroup &other)
+const QBrush &QColorGroup::brush(ColorRole cr) const
{
- d = new QColorGroupPrivate(other.d);
+ return brushes[cr];
}
-
-QColorGroup::~QColorGroup()
+const QColor &QColorGroup::color(ColorRole cr) const
{
- delete d;
+ return brushes[cr].color();
}
-
-const QBrush &QColorGroup::brush(QColorGroup::ColorRole cr) const
-{
- return d->brushes[cr];
-}
-
-const QColor &QColorGroup::color(QColorGroup::ColorRole cr) const
-{
- return d->brushes[cr].color();
-}
-
-
void QColorGroup::setColor(QColorGroup::ColorRole cr, const QColor &color)
{
- d->brushes[cr].setColor(color);
+ brushes[cr].setColor(color);
}
-
const QColor &QColorGroup::foreground() const
{
- return d->brushes[Foreground].color();
+ return brushes[Foreground].color();
}
-
const QColor &QColorGroup::shadow() const
{
- return d->brushes[Shadow].color();
+ return brushes[Shadow].color();
}
-
const QColor &QColorGroup::light() const
{
- return d->brushes[Light].color();
+ return brushes[Light].color();
}
-
const QColor &QColorGroup::midlight() const
{
- return d->brushes[Midlight].color();
+ return brushes[Midlight].color();
}
-
const QColor &QColorGroup::dark() const
{
- return d->brushes[Dark].color();
+ return brushes[Dark].color();
}
-
const QColor &QColorGroup::base() const
{
- return d->brushes[Base].color();
+ return brushes[Base].color();
}
-
const QColor &QColorGroup::buttonText() const
{
- return d->brushes[ButtonText].color();
+ return brushes[ButtonText].color();
}
-
const QColor &QColorGroup::button() const
{
- return d->brushes[Button].color();
+ return brushes[Button].color();
}
-
const QColor &QColorGroup::text() const
{
- return d->brushes[Text].color();
+ return brushes[Text].color();
}
-
const QColor &QColorGroup::background() const
{
- return d->brushes[Background].color();
+ return brushes[Background].color();
}
const QColor &QColorGroup::highlight() const
{
- return d->brushes[Highlight].color();
+ return brushes[Highlight].color();
}
-
const QColor &QColorGroup::highlightedText() const
{
- return d->brushes[HighlightedText].color();
-}
-
-
-QColorGroup &QColorGroup::operator=(const QColorGroup &other)
-{
- for (int i = 0; i < QCOLOR_GROUP_SIZE; i++) {
- d->brushes[i] = other.d->brushes[i];
- }
- return *this;
+ return brushes[HighlightedText].color();
}
-
-bool QColorGroup::operator==(const QColorGroup &other)
+bool QColorGroup::operator==(const QColorGroup &other) const
{
- for (int i = 0; i < QCOLOR_GROUP_SIZE; i++) {
- if (d->brushes[i] != other.d->brushes[i]) {
+ for (int i = 0; i < NColorRoles; i++) {
+ if (brushes[i] != other.brushes[i]) {
return false;
}
}
diff --git a/WebCore/kwq/KWQKIOGlobal.h b/WebCore/kwq/KWQKIOGlobal.h
index 839f421..af372da 100644
--- a/WebCore/kwq/KWQKIOGlobal.h
+++ b/WebCore/kwq/KWQKIOGlobal.h
@@ -31,6 +31,14 @@
#include <qmap.h>
namespace KIO {
+ enum CacheControl
+ {
+ CC_Cache,
+ CC_Verify,
+ CC_Refresh,
+ CC_Reload
+ };
+
const QMap<QString, QString> MetaData();
}
diff --git a/WebCore/kwq/KWQKJavaAppletContext.h b/WebCore/kwq/KWQKJavaAppletContext.h
index 47addd8..b8f7511 100644
--- a/WebCore/kwq/KWQKJavaAppletContext.h
+++ b/WebCore/kwq/KWQKJavaAppletContext.h
@@ -23,8 +23,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef KJAVAAPPLETCONTEXT_H
+#define KJAVAAPPLETCONTEXT_H
+
#include <qobject.h>
+class DCOPObject;
+
+typedef enum { } JType;
+
class KJavaAppletContext : public QObject
{
+public:
+ KJavaAppletContext(DCOPObject* = 0) { }
};
+
+#endif
diff --git a/WebCore/kwq/KWQKLibrary.h b/WebCore/kwq/KWQKLibrary.h
index e697dbd..5751177 100644
--- a/WebCore/kwq/KWQKLibrary.h
+++ b/WebCore/kwq/KWQKLibrary.h
@@ -23,6 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <kio/global.h>
+
class KLibrary
{
public:
diff --git a/WebCore/kwq/KWQKURL.h b/WebCore/kwq/KWQKURL.h
index 73dd2b3..9c1d869 100644
--- a/WebCore/kwq/KWQKURL.h
+++ b/WebCore/kwq/KWQKURL.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,31 +36,17 @@
typedef void NSURL;
#endif
-// class KURL ==================================================================
-
class KURL {
public:
-
- // structs -----------------------------------------------------------------
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- static QString decode_string(const QString &urlString);
- static void clearCaches();
-
- // constructors, copy constructors, and destructors ------------------------
-
KURL();
KURL(const char *, int encoding_hint=0);
KURL(const KURL &, const QString &);
KURL(const QString &, int encoding_hint=0);
- KURL(const KURL &);
- ~KURL();
+ KURL(const KURL &);
- // member functions --------------------------------------------------------
+ ~KURL();
+ KURL &operator=(const KURL &);
bool isEmpty() const;
bool isMalformed() const;
@@ -89,12 +75,10 @@ public:
NSURL *getNSURL() const;
- // operators ---------------------------------------------------------------
-
- KURL &operator=(const KURL &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ static QString decode_string(const QString &urlString);
+ static void clearCaches();
+
+ friend bool operator==(const KURL &, const KURL &);
private:
void swap(KURL &other);
@@ -108,6 +92,6 @@ private:
mutable KWQRefPtr<KWQKURLPrivate> d;
QString urlString;
-}; // class KURL ===============================================================
+};
#endif
diff --git a/WebCore/kwq/KWQKURL.mm b/WebCore/kwq/KWQKURL.mm
index 4e60439..219d50e 100644
--- a/WebCore/kwq/KWQKURL.mm
+++ b/WebCore/kwq/KWQKURL.mm
@@ -755,3 +755,8 @@ QString KURL::htmlRef() const
_logNotYetImplemented();
return 0;
}
+
+bool operator==(const KURL &a, const KURL &b)
+{
+ return [a.getNSURL() isEqual:b.getNSURL()];
+}
diff --git a/WebCore/kwq/KWQPalette.h b/WebCore/kwq/KWQPalette.h
index 848a210..737c9d5 100644
--- a/WebCore/kwq/KWQPalette.h
+++ b/WebCore/kwq/KWQPalette.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,49 +26,32 @@
#ifndef QPALETTE_H_
#define QPALETTE_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <qcolor.h>
#include <qbrush.h>
class QColorGroupPrivate;
class QPalettePrivate;
-// class QColorGroup ===========================================================
-
class QColorGroup {
public:
-
- // typedefs ----------------------------------------------------------------
-
enum ColorRole {
- Foreground = 0,
- Shadow = 1,
- Light = 2,
- Midlight = 3,
- Mid = 4,
- Dark = 5,
- Base = 6,
- ButtonText = 7,
- Button = 8,
- Background = 9,
- Text = 10,
- Highlight = 11,
- HighlightedText = 12
+ Foreground,
+ Shadow,
+ Light,
+ Midlight,
+ Mid,
+ Dark,
+ Base,
+ ButtonText,
+ Button,
+ Background,
+ Text,
+ Highlight,
+ HighlightedText,
+ NColorRoles
};
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
- // constructors, copy constructors, and destructors ------------------------
-
QColorGroup();
- QColorGroup(const QColorGroup &);
- ~QColorGroup();
-
- // member functions --------------------------------------------------------
const QBrush &brush(ColorRole) const;
@@ -88,65 +71,36 @@ public:
const QColor &highlight() const;
const QColor &highlightedText() const;
- // operators ---------------------------------------------------------------
-
- QColorGroup &operator=(const QColorGroup &);
+ bool operator==(const QColorGroup &) const;
- bool operator==(const QColorGroup &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
private:
- QColorGroupPrivate *d;
-
-}; // class QColorGroup ========================================================
+ QBrush brushes[NColorRoles];
+};
-// class QPalette ==============================================================
-
class QPalette {
public:
-
- // typedefs ----------------------------------------------------------------
-
- // enums -------------------------------------------------------------------
-
enum ColorGroup {
- Active = 0,
- Inactive = 1,
- Disabled = 2,
+ Active,
+ Inactive,
+ Disabled,
+ NColorGroups
};
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QPalette();
- QPalette(const QPalette &);
- ~QPalette();
-
- // member functions --------------------------------------------------------
+ const QColor &color(ColorGroup, QColorGroup::ColorRole) const;
+ void setColor(ColorGroup, QColorGroup::ColorRole, const QColor &);
- void setColor(ColorGroup, QColorGroup::ColorRole role, const QColor &color);
-
- const QColorGroup &active() const;
- const QColorGroup &inactive() const;
- const QColorGroup &disabled() const;
- const QColorGroup &normal() const;
-
- // operators ---------------------------------------------------------------
-
- QPalette &operator=(const QPalette &);
+ const QColorGroup &active() const { return m_active; }
+ const QColorGroup &inactive() const { return m_inactive; }
+ const QColorGroup &disabled() const { return m_disabled; }
+ const QColorGroup &normal() const { return m_active; }
bool operator==(const QPalette &) const;
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
private:
- QPalettePrivate *d;
-
-}; // class QPalette ===========================================================
+ QColorGroup m_active;
+ QColorGroup m_inactive;
+ QColorGroup m_disabled;
+};
#endif
diff --git a/WebCore/kwq/KWQPalette.mm b/WebCore/kwq/KWQPalette.mm
index 93cb23d..daf7f94 100644
--- a/WebCore/kwq/KWQPalette.mm
+++ b/WebCore/kwq/KWQPalette.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,97 +25,37 @@
#include <qpalette.h>
-
-class QPalettePrivate
+const QColor& QPalette::color(ColorGroup cg, QColorGroup::ColorRole role) const
{
-friend class QPalette;
-public:
- QPalettePrivate() : active(), inactive(), disabled()
- {
- }
-
- QPalettePrivate(const QPalettePrivate *other) :
- active(other->active),
- inactive(other->inactive),
- disabled(other->disabled)
- {
+ switch (cg) {
+ default: // keep GCC from complaining about NColorGroups
+ case Active:
+ return m_active.color(role);
+ case Inactive:
+ return m_inactive.color(role);
+ case Disabled:
+ return m_disabled.color(role);
}
-
-private:
- QColorGroup active;
- QColorGroup inactive;
- QColorGroup disabled;
-};
-
-#include <kwqdebug.h>
-
-QPalette::QPalette()
-{
- d = new QPalettePrivate();
}
-
-QPalette::QPalette(const QPalette &other)
-{
- d = new QPalettePrivate(other.d);
-}
-
-
-QPalette::~QPalette()
-{
- delete d;
-}
-
-
void QPalette::setColor(ColorGroup cg, QColorGroup::ColorRole role, const QColor &color)
{
switch (cg) {
- case Active:
- d->active.setColor(role, color);
- break;
- case Inactive:
- d->inactive.setColor(role, color);
- break;
- case Disabled:
- d->disabled.setColor(role, color);
- break;
+ case Active:
+ m_active.setColor(role, color);
+ break;
+ case Inactive:
+ m_inactive.setColor(role, color);
+ break;
+ case Disabled:
+ m_disabled.setColor(role, color);
+ break;
+ default: // keep GCC from complaining about NColorGroups
+ break;
}
}
-
-const QColorGroup &QPalette::active() const
-{
- return d->active;
-}
-
-
-const QColorGroup &QPalette::inactive() const
-{
- return d->inactive;
-}
-
-
-const QColorGroup &QPalette::disabled() const
-{
- return d->disabled;
-}
-
-
-const QColorGroup &QPalette::normal() const
-{
- return d->active;
-}
-
-
-QPalette &QPalette::operator=(const QPalette &other)
-{
- d->active = other.d->active;
- d->inactive = other.d->inactive;
- d->disabled = other.d->disabled;
- return *this;
-}
-
bool QPalette::operator==(QPalette const &other) const
{
- return d->active == other.d->active && d->inactive == other.d->inactive && d->disabled == other.d->disabled;
+ return m_active == other.m_active && m_inactive == other.m_inactive && m_disabled == other.m_disabled;
}
diff --git a/WebCore/kwq/KWQString.h b/WebCore/kwq/KWQString.h
index f52f7a0..b0cd378 100644
--- a/WebCore/kwq/KWQString.h
+++ b/WebCore/kwq/KWQString.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,7 +28,7 @@
#include <CoreFoundation/CoreFoundation.h>
-#include "qcstring.h"
+#include <qcstring.h>
// Make htmltokenizer.cpp happy
#define QT_VERSION 300
@@ -47,15 +47,8 @@ class QRegExp;
class NSString;
#endif
-// QChar class =================================================================
-
class QChar {
public:
-
- // typedefs ----------------------------------------------------------------
-
- // enums -------------------------------------------------------------------
-
enum Direction {
// NOTE: alphabetical order
//DirAL, DirAN, DirB, DirBN, DirCS, DirEN, DirES, DirET, DirL, DirLRE,
@@ -67,14 +60,8 @@ public:
DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN
};
- // constants ---------------------------------------------------------------
-
static const QChar null;
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QChar();
QChar(char);
QChar(uchar);
@@ -83,8 +70,6 @@ public:
QChar(int);
QChar(uint);
- // member functions --------------------------------------------------------
-
ushort unicode() const;
uchar cell() const;
uchar row() const;
@@ -103,8 +88,6 @@ public:
bool mirrored() const;
QChar mirroredChar() const;
- // operators ---------------------------------------------------------------
-
operator char() const;
friend bool operator==(QChar, QChar);
@@ -131,20 +114,13 @@ public:
friend bool operator<=(QChar, char);
friend bool operator<=(char, QChar);
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
private:
- // data members ------------------------------------------------------------
-
UniChar c;
- // friends -----------------------------------------------------------------
-
friend class QString;
friend class QConstString;
-}; // class QChar ==============================================================
+};
inline QChar::QChar() : c(0)
{
@@ -294,36 +270,10 @@ inline bool operator<(char ch, QChar qc)
return (uchar) ch < qc.c;
}
-// QString class ===============================================================
-
class QString {
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
-
static const QString null;
- // static member functions -------------------------------------------------
-
- static QString number(int /* NOTE: base NOT used */ );
- static QString number(uint /* NOTE: base NOT used */ );
- static QString number(long /* NOTE: base NOT used */ );
- static QString number(ulong /* NOTE: base NOT used */ );
- static QString number(double);
-
- static QString fromLatin1(const char * /* NOTE: len NOT used */ );
- static QString fromStringWithEncoding(const char *, int, CFStringEncoding);
- static QString fromCFMutableString(CFMutableStringRef);
- static QString fromCFString(CFStringRef);
- static QString fromNSString(NSString *);
-
- static QString gstring_toQString(CFMutableStringRef *ref, UniChar *uchars, int len);
- static CFMutableStringRef gstring_toCFString(CFMutableStringRef *ref, UniChar *uchars, int len);
-
- // constructors, copy constructors, and destructors ------------------------
-
QString();
QString(QChar);
QString(const QByteArray &);
@@ -335,7 +285,14 @@ public:
~QString();
- // assignment operators ----------------------------------------------------
+ static QString fromLatin1(const char * /* NOTE: len NOT used */ );
+ static QString fromStringWithEncoding(const char *, int, CFStringEncoding);
+ static QString fromCFMutableString(CFMutableStringRef);
+ static QString fromCFString(CFStringRef);
+ static QString fromNSString(NSString *);
+
+ static QString gstring_toQString(CFMutableStringRef *ref, UniChar *uchars, int len);
+ static CFMutableStringRef gstring_toCFString(CFMutableStringRef *ref, UniChar *uchars, int len);
QString &operator=(const QString &);
QString &operator=(const QCString &);
@@ -343,8 +300,6 @@ public:
QString &operator=(QChar);
QString &operator=(char);
- // member functions --------------------------------------------------------
-
uint length() const;
const QChar *unicode() const;
@@ -390,20 +345,25 @@ public:
float toFloat(bool *ok=NULL) const;
double toDouble(bool *ok=NULL) const;
+ static QString number(int);
+ static QString number(uint);
+ static QString number(long);
+ static QString number(ulong);
+ static QString number(double);
+
QString arg(const QString &, int width=0) const;
- QString arg(short, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(ushort, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(int, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(uint, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(long, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(ulong, int width=0 /* NOTE: base NOT used */ ) const;
+ QString arg(short, int width=0) const;
+ QString arg(ushort, int width=0) const;
+ QString arg(int, int width=0) const;
+ QString arg(uint, int width=0) const;
+ QString arg(long, int width=0) const;
+ QString arg(ulong, int width=0) const;
QString arg(double, int width=0) const;
QString left(uint) const;
QString right(uint) const;
QString mid(uint, uint len=0xffffffff) const;
- // NOTE: copy is simple enough to keep for completeness
QString copy() const;
QString lower() const;
@@ -413,12 +373,12 @@ public:
QString &setUnicode(const QChar *, uint);
QString &setLatin1(const char *);
- QString &setNum(short /* NOTE: base NOT used */ );
- QString &setNum(ushort /* NOTE: base NOT used */ );
- QString &setNum(int /* NOTE: base NOT used */ );
- QString &setNum(uint /* NOTE: base NOT used */ );
- QString &setNum(long /* NOTE: base NOT used */ );
- QString &setNum(ulong /* NOTE: base NOT used */ );
+ QString &setNum(short);
+ QString &setNum(ushort);
+ QString &setNum(int);
+ QString &setNum(uint);
+ QString &setNum(long);
+ QString &setNum(ulong);
QString &setNum(double);
QString &sprintf(const char *, ...);
@@ -440,8 +400,6 @@ public:
CFMutableStringRef getCFMutableString() const;
NSString *getNSString() const;
- // operators ---------------------------------------------------------------
-
bool operator!() const;
operator const char *() const;
@@ -452,30 +410,18 @@ public:
QString &operator+=(QChar);
QString &operator+=(char);
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
private:
-
- // private enums -----------------------------------------------------------
-
enum CacheType { CacheInvalid, CacheUnicode, CacheLatin1 };
- // private member functions ------------------------------------------------
-
void flushCache() const;
QCString convertToQCString(CFStringEncoding) const;
ulong convertToNumber(bool *ok, int base, bool *neg) const;
QString leftRight(uint width, bool left) const;
int compareToLatin1(const char *chs) const;
- // data members ------------------------------------------------------------
-
CFMutableStringRef s;
mutable void *cache;
- // friends -----------------------------------------------------------------
-
friend bool operator==(const QString &, const QString &);
friend bool operator==(const QString &, const char *);
friend bool operator==(const char *, const QString &);
@@ -505,10 +451,7 @@ private:
void _copyIfNeededInternalString();
-}; // class QString ============================================================
-
-
-// operators associated with QString ===========================================
+};
QString operator+(const QString &, const QString &);
QString operator+(const QString &, const char *);
@@ -663,14 +606,10 @@ inline bool operator>=(const char *chs, const QString &qs)
return qs.compareToLatin1(chs) <= 0;
}
-// class QConstString ==========================================================
-
class QConstString : private QString {
public:
-
- QConstString(QChar *, uint);
+ QConstString(const QChar *, uint);
const QString &string() const { return *this; }
-
-}; // class QConstString =======================================================
+};
#endif
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index f343b6a..dd70779 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -1331,7 +1331,7 @@ QString operator+(char ch, const QString &qs)
// constructors, copy constructors, and destructors ----------------------------
-QConstString::QConstString(QChar *qcs, uint len)
+QConstString::QConstString(const QChar *qcs, uint len)
{
if (qcs || len) {
// NOTE: use instead of CFStringCreateWithCharactersNoCopy function to
diff --git a/WebCore/kwq/KWQTextEdit.h b/WebCore/kwq/KWQTextEdit.h
index 04ebc8a..3d4fe8b 100644
--- a/WebCore/kwq/KWQTextEdit.h
+++ b/WebCore/kwq/KWQTextEdit.h
@@ -54,6 +54,7 @@ class QTextEdit : public QScrollView
WrapStyle wordWrap() const;
void setWordWrap(WrapStyle);
void setTextFormat(TextFormat);
+ void setTabStopWidth(int);
bool isReadOnly () const;
void setReadOnly (bool);
void getCursorPosition(int *, int *) const;
diff --git a/WebCore/kwq/KWQTextEdit.mm b/WebCore/kwq/KWQTextEdit.mm
index d599118..8b8aaa0 100644
--- a/WebCore/kwq/KWQTextEdit.mm
+++ b/WebCore/kwq/KWQTextEdit.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -22,14 +22,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
#include <qtextedit.h>
#import <KWQTextArea.h>
-
-// class QTextEdit
+#include <kwqdebug.h>
QTextEdit::QTextEdit(QWidget *parent)
{
@@ -118,6 +116,11 @@ void QTextEdit::setTextFormat(TextFormat f)
}
}
+void QTextEdit::setTabStopWidth(int)
+{
+ _logNotYetImplemented();
+}
+
bool QTextEdit::isReadOnly () const
{
KWQTextArea *textView = (KWQTextArea *)getView();
@@ -147,4 +150,3 @@ int QTextEdit::horizontalScrollBarHeight() const
KWQTextArea *textView = (KWQTextArea *)getView();
return (int) [[textView horizontalScroller] frame].size.height;
}
-
diff --git a/WebCore/kwq/KWQValueList.h b/WebCore/kwq/KWQValueList.h
index c38c130..3f910e5 100644
--- a/WebCore/kwq/KWQValueList.h
+++ b/WebCore/kwq/KWQValueList.h
@@ -117,9 +117,9 @@ public:
T& operator[] (uint index) { return ((QValueListNode<T> *)impl.nodeAt(index))->value; }
const T& operator[] (uint index) const { return ((const QValueListNode<T> *)impl.nodeAt(index))->value; }
- QValueList<T> &operator+=(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
- QValueList<T> &operator<<(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
-
+ QValueList &operator+=(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
+ QValueList &operator<<(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
+
private:
KWQValueListImpl impl;
diff --git a/WebCore/kwq/KWQValueListImpl.h b/WebCore/kwq/KWQValueListImpl.h
index 2d941b8..bf48a41 100644
--- a/WebCore/kwq/KWQValueListImpl.h
+++ b/WebCore/kwq/KWQValueListImpl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,10 +26,6 @@
#ifndef KWQVALUELIST_H_
#define KWQVALUELIST_H_
-#include <config.h>
-
-#ifndef USING_BORROWED_QVALUELIST
-
#include <KWQRefPtr.h>
#include <KWQDef.h>
@@ -39,12 +35,7 @@ class KWQValueListIteratorImpl
{
public:
KWQValueListIteratorImpl();
- KWQValueListIteratorImpl(const KWQValueListIteratorImpl &other);
-
- ~KWQValueListIteratorImpl();
- KWQValueListIteratorImpl &operator=(const KWQValueListIteratorImpl &other);
-
bool operator==(const KWQValueListIteratorImpl &other);
bool operator!=(const KWQValueListIteratorImpl &other);
@@ -58,7 +49,6 @@ public:
private:
KWQValueListIteratorImpl(const KWQValueListNodeImpl *n);
-
KWQValueListNodeImpl *nodeImpl;
friend class KWQValueListImpl;
@@ -69,9 +59,10 @@ class KWQValueListImpl
{
public:
KWQValueListImpl(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyNode)(KWQValueListNodeImpl *));
- KWQValueListImpl(const KWQValueListImpl &other);
-
~KWQValueListImpl();
+
+ KWQValueListImpl(const KWQValueListImpl&);
+ KWQValueListImpl& operator=(const KWQValueListImpl&);
void clear();
uint count() const;
@@ -99,9 +90,7 @@ public:
KWQValueListNodeImpl *nodeAt(uint index);
KWQValueListNodeImpl *nodeAt(uint index) const;
-
- KWQValueListImpl operator=(const KWQValueListImpl &other);
-
+
private:
void copyOnWrite();
@@ -116,7 +105,6 @@ class KWQValueListNodeImpl
{
protected:
KWQValueListNodeImpl();
- ~KWQValueListNodeImpl();
private:
KWQValueListNodeImpl *prev;
@@ -128,5 +116,3 @@ private:
};
#endif
-
-#endif
diff --git a/WebCore/kwq/KWQValueListImpl.mm b/WebCore/kwq/KWQValueListImpl.mm
index 66b77ac..d9ef97f 100644
--- a/WebCore/kwq/KWQValueListImpl.mm
+++ b/WebCore/kwq/KWQValueListImpl.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,30 +35,11 @@ KWQValueListNodeImpl::KWQValueListNodeImpl() :
{
}
-KWQValueListNodeImpl::~KWQValueListNodeImpl()
-{
-}
-
KWQValueListIteratorImpl::KWQValueListIteratorImpl() :
nodeImpl(NULL)
{
}
-KWQValueListIteratorImpl::KWQValueListIteratorImpl(const KWQValueListIteratorImpl &other) :
- nodeImpl(other.nodeImpl)
-{
-}
-
-KWQValueListIteratorImpl::~KWQValueListIteratorImpl()
-{
-}
-
-KWQValueListIteratorImpl &KWQValueListIteratorImpl::operator=(const KWQValueListIteratorImpl &other)
-{
- nodeImpl = other.nodeImpl;
- return *this;
-}
-
bool KWQValueListIteratorImpl::operator==(const KWQValueListIteratorImpl &other)
{
return nodeImpl == other.nodeImpl;
@@ -195,7 +176,7 @@ void KWQValueListImpl::KWQValueListPrivate::deleteList(KWQValueListNodeImpl *l)
KWQValueListImpl::KWQValueListImpl(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyFunc)(KWQValueListNodeImpl *)) :
- d(new KWQValueListImpl::KWQValueListPrivate(deleteFunc, copyFunc))
+ d(new KWQValueListPrivate(deleteFunc, copyFunc))
{
}
@@ -426,7 +407,7 @@ KWQValueListNodeImpl *KWQValueListImpl::nodeAt(uint index) const
return p;
}
-KWQValueListImpl KWQValueListImpl::operator=(const KWQValueListImpl &other)
+KWQValueListImpl& KWQValueListImpl::operator=(const KWQValueListImpl &other)
{
KWQValueListImpl tmp(other);
KWQRefPtr<KWQValueListImpl::KWQValueListPrivate> tmpD = tmp.d;
@@ -440,7 +421,7 @@ KWQValueListImpl KWQValueListImpl::operator=(const KWQValueListImpl &other)
void KWQValueListImpl::copyOnWrite()
{
if (d->refCount > 1) {
- d = KWQRefPtr<KWQValueListImpl::KWQValueListPrivate>(new KWQValueListImpl::KWQValueListPrivate(*d));
+ d = KWQRefPtr<KWQValueListImpl::KWQValueListPrivate>(new KWQValueListPrivate(*d));
}
}
diff --git a/WebCore/kwq/kdecore/klibloader.h b/WebCore/kwq/kdecore/klibloader.h
index e697dbd..5751177 100644
--- a/WebCore/kwq/kdecore/klibloader.h
+++ b/WebCore/kwq/kdecore/klibloader.h
@@ -23,6 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <kio/global.h>
+
class KLibrary
{
public:
diff --git a/WebCore/kwq/kdecore/kurl.h b/WebCore/kwq/kdecore/kurl.h
index 73dd2b3..9c1d869 100644
--- a/WebCore/kwq/kdecore/kurl.h
+++ b/WebCore/kwq/kdecore/kurl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,31 +36,17 @@
typedef void NSURL;
#endif
-// class KURL ==================================================================
-
class KURL {
public:
-
- // structs -----------------------------------------------------------------
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- static QString decode_string(const QString &urlString);
- static void clearCaches();
-
- // constructors, copy constructors, and destructors ------------------------
-
KURL();
KURL(const char *, int encoding_hint=0);
KURL(const KURL &, const QString &);
KURL(const QString &, int encoding_hint=0);
- KURL(const KURL &);
- ~KURL();
+ KURL(const KURL &);
- // member functions --------------------------------------------------------
+ ~KURL();
+ KURL &operator=(const KURL &);
bool isEmpty() const;
bool isMalformed() const;
@@ -89,12 +75,10 @@ public:
NSURL *getNSURL() const;
- // operators ---------------------------------------------------------------
-
- KURL &operator=(const KURL &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ static QString decode_string(const QString &urlString);
+ static void clearCaches();
+
+ friend bool operator==(const KURL &, const KURL &);
private:
void swap(KURL &other);
@@ -108,6 +92,6 @@ private:
mutable KWQRefPtr<KWQKURLPrivate> d;
QString urlString;
-}; // class KURL ===============================================================
+};
#endif
diff --git a/WebCore/kwq/khtml/java/kjavaappletcontext.h b/WebCore/kwq/khtml/java/kjavaappletcontext.h
index 47addd8..b8f7511 100644
--- a/WebCore/kwq/khtml/java/kjavaappletcontext.h
+++ b/WebCore/kwq/khtml/java/kjavaappletcontext.h
@@ -23,8 +23,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef KJAVAAPPLETCONTEXT_H
+#define KJAVAAPPLETCONTEXT_H
+
#include <qobject.h>
+class DCOPObject;
+
+typedef enum { } JType;
+
class KJavaAppletContext : public QObject
{
+public:
+ KJavaAppletContext(DCOPObject* = 0) { }
};
+
+#endif
diff --git a/WebCore/kwq/kio/global.h b/WebCore/kwq/kio/global.h
index 839f421..af372da 100644
--- a/WebCore/kwq/kio/global.h
+++ b/WebCore/kwq/kio/global.h
@@ -31,6 +31,14 @@
#include <qmap.h>
namespace KIO {
+ enum CacheControl
+ {
+ CC_Cache,
+ CC_Verify,
+ CC_Refresh,
+ CC_Reload
+ };
+
const QMap<QString, QString> MetaData();
}
diff --git a/WebCore/kwq/qt/qpalette.h b/WebCore/kwq/qt/qpalette.h
index 848a210..737c9d5 100644
--- a/WebCore/kwq/qt/qpalette.h
+++ b/WebCore/kwq/qt/qpalette.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,49 +26,32 @@
#ifndef QPALETTE_H_
#define QPALETTE_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <qcolor.h>
#include <qbrush.h>
class QColorGroupPrivate;
class QPalettePrivate;
-// class QColorGroup ===========================================================
-
class QColorGroup {
public:
-
- // typedefs ----------------------------------------------------------------
-
enum ColorRole {
- Foreground = 0,
- Shadow = 1,
- Light = 2,
- Midlight = 3,
- Mid = 4,
- Dark = 5,
- Base = 6,
- ButtonText = 7,
- Button = 8,
- Background = 9,
- Text = 10,
- Highlight = 11,
- HighlightedText = 12
+ Foreground,
+ Shadow,
+ Light,
+ Midlight,
+ Mid,
+ Dark,
+ Base,
+ ButtonText,
+ Button,
+ Background,
+ Text,
+ Highlight,
+ HighlightedText,
+ NColorRoles
};
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
- // constructors, copy constructors, and destructors ------------------------
-
QColorGroup();
- QColorGroup(const QColorGroup &);
- ~QColorGroup();
-
- // member functions --------------------------------------------------------
const QBrush &brush(ColorRole) const;
@@ -88,65 +71,36 @@ public:
const QColor &highlight() const;
const QColor &highlightedText() const;
- // operators ---------------------------------------------------------------
-
- QColorGroup &operator=(const QColorGroup &);
+ bool operator==(const QColorGroup &) const;
- bool operator==(const QColorGroup &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
private:
- QColorGroupPrivate *d;
-
-}; // class QColorGroup ========================================================
+ QBrush brushes[NColorRoles];
+};
-// class QPalette ==============================================================
-
class QPalette {
public:
-
- // typedefs ----------------------------------------------------------------
-
- // enums -------------------------------------------------------------------
-
enum ColorGroup {
- Active = 0,
- Inactive = 1,
- Disabled = 2,
+ Active,
+ Inactive,
+ Disabled,
+ NColorGroups
};
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QPalette();
- QPalette(const QPalette &);
- ~QPalette();
-
- // member functions --------------------------------------------------------
+ const QColor &color(ColorGroup, QColorGroup::ColorRole) const;
+ void setColor(ColorGroup, QColorGroup::ColorRole, const QColor &);
- void setColor(ColorGroup, QColorGroup::ColorRole role, const QColor &color);
-
- const QColorGroup &active() const;
- const QColorGroup &inactive() const;
- const QColorGroup &disabled() const;
- const QColorGroup &normal() const;
-
- // operators ---------------------------------------------------------------
-
- QPalette &operator=(const QPalette &);
+ const QColorGroup &active() const { return m_active; }
+ const QColorGroup &inactive() const { return m_inactive; }
+ const QColorGroup &disabled() const { return m_disabled; }
+ const QColorGroup &normal() const { return m_active; }
bool operator==(const QPalette &) const;
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
private:
- QPalettePrivate *d;
-
-}; // class QPalette ===========================================================
+ QColorGroup m_active;
+ QColorGroup m_inactive;
+ QColorGroup m_disabled;
+};
#endif
diff --git a/WebCore/kwq/qt/qstring.h b/WebCore/kwq/qt/qstring.h
index f52f7a0..b0cd378 100644
--- a/WebCore/kwq/qt/qstring.h
+++ b/WebCore/kwq/qt/qstring.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,7 +28,7 @@
#include <CoreFoundation/CoreFoundation.h>
-#include "qcstring.h"
+#include <qcstring.h>
// Make htmltokenizer.cpp happy
#define QT_VERSION 300
@@ -47,15 +47,8 @@ class QRegExp;
class NSString;
#endif
-// QChar class =================================================================
-
class QChar {
public:
-
- // typedefs ----------------------------------------------------------------
-
- // enums -------------------------------------------------------------------
-
enum Direction {
// NOTE: alphabetical order
//DirAL, DirAN, DirB, DirBN, DirCS, DirEN, DirES, DirET, DirL, DirLRE,
@@ -67,14 +60,8 @@ public:
DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN
};
- // constants ---------------------------------------------------------------
-
static const QChar null;
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QChar();
QChar(char);
QChar(uchar);
@@ -83,8 +70,6 @@ public:
QChar(int);
QChar(uint);
- // member functions --------------------------------------------------------
-
ushort unicode() const;
uchar cell() const;
uchar row() const;
@@ -103,8 +88,6 @@ public:
bool mirrored() const;
QChar mirroredChar() const;
- // operators ---------------------------------------------------------------
-
operator char() const;
friend bool operator==(QChar, QChar);
@@ -131,20 +114,13 @@ public:
friend bool operator<=(QChar, char);
friend bool operator<=(char, QChar);
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
private:
- // data members ------------------------------------------------------------
-
UniChar c;
- // friends -----------------------------------------------------------------
-
friend class QString;
friend class QConstString;
-}; // class QChar ==============================================================
+};
inline QChar::QChar() : c(0)
{
@@ -294,36 +270,10 @@ inline bool operator<(char ch, QChar qc)
return (uchar) ch < qc.c;
}
-// QString class ===============================================================
-
class QString {
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
-
static const QString null;
- // static member functions -------------------------------------------------
-
- static QString number(int /* NOTE: base NOT used */ );
- static QString number(uint /* NOTE: base NOT used */ );
- static QString number(long /* NOTE: base NOT used */ );
- static QString number(ulong /* NOTE: base NOT used */ );
- static QString number(double);
-
- static QString fromLatin1(const char * /* NOTE: len NOT used */ );
- static QString fromStringWithEncoding(const char *, int, CFStringEncoding);
- static QString fromCFMutableString(CFMutableStringRef);
- static QString fromCFString(CFStringRef);
- static QString fromNSString(NSString *);
-
- static QString gstring_toQString(CFMutableStringRef *ref, UniChar *uchars, int len);
- static CFMutableStringRef gstring_toCFString(CFMutableStringRef *ref, UniChar *uchars, int len);
-
- // constructors, copy constructors, and destructors ------------------------
-
QString();
QString(QChar);
QString(const QByteArray &);
@@ -335,7 +285,14 @@ public:
~QString();
- // assignment operators ----------------------------------------------------
+ static QString fromLatin1(const char * /* NOTE: len NOT used */ );
+ static QString fromStringWithEncoding(const char *, int, CFStringEncoding);
+ static QString fromCFMutableString(CFMutableStringRef);
+ static QString fromCFString(CFStringRef);
+ static QString fromNSString(NSString *);
+
+ static QString gstring_toQString(CFMutableStringRef *ref, UniChar *uchars, int len);
+ static CFMutableStringRef gstring_toCFString(CFMutableStringRef *ref, UniChar *uchars, int len);
QString &operator=(const QString &);
QString &operator=(const QCString &);
@@ -343,8 +300,6 @@ public:
QString &operator=(QChar);
QString &operator=(char);
- // member functions --------------------------------------------------------
-
uint length() const;
const QChar *unicode() const;
@@ -390,20 +345,25 @@ public:
float toFloat(bool *ok=NULL) const;
double toDouble(bool *ok=NULL) const;
+ static QString number(int);
+ static QString number(uint);
+ static QString number(long);
+ static QString number(ulong);
+ static QString number(double);
+
QString arg(const QString &, int width=0) const;
- QString arg(short, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(ushort, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(int, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(uint, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(long, int width=0 /* NOTE: base NOT used */ ) const;
- QString arg(ulong, int width=0 /* NOTE: base NOT used */ ) const;
+ QString arg(short, int width=0) const;
+ QString arg(ushort, int width=0) const;
+ QString arg(int, int width=0) const;
+ QString arg(uint, int width=0) const;
+ QString arg(long, int width=0) const;
+ QString arg(ulong, int width=0) const;
QString arg(double, int width=0) const;
QString left(uint) const;
QString right(uint) const;
QString mid(uint, uint len=0xffffffff) const;
- // NOTE: copy is simple enough to keep for completeness
QString copy() const;
QString lower() const;
@@ -413,12 +373,12 @@ public:
QString &setUnicode(const QChar *, uint);
QString &setLatin1(const char *);
- QString &setNum(short /* NOTE: base NOT used */ );
- QString &setNum(ushort /* NOTE: base NOT used */ );
- QString &setNum(int /* NOTE: base NOT used */ );
- QString &setNum(uint /* NOTE: base NOT used */ );
- QString &setNum(long /* NOTE: base NOT used */ );
- QString &setNum(ulong /* NOTE: base NOT used */ );
+ QString &setNum(short);
+ QString &setNum(ushort);
+ QString &setNum(int);
+ QString &setNum(uint);
+ QString &setNum(long);
+ QString &setNum(ulong);
QString &setNum(double);
QString &sprintf(const char *, ...);
@@ -440,8 +400,6 @@ public:
CFMutableStringRef getCFMutableString() const;
NSString *getNSString() const;
- // operators ---------------------------------------------------------------
-
bool operator!() const;
operator const char *() const;
@@ -452,30 +410,18 @@ public:
QString &operator+=(QChar);
QString &operator+=(char);
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
private:
-
- // private enums -----------------------------------------------------------
-
enum CacheType { CacheInvalid, CacheUnicode, CacheLatin1 };
- // private member functions ------------------------------------------------
-
void flushCache() const;
QCString convertToQCString(CFStringEncoding) const;
ulong convertToNumber(bool *ok, int base, bool *neg) const;
QString leftRight(uint width, bool left) const;
int compareToLatin1(const char *chs) const;
- // data members ------------------------------------------------------------
-
CFMutableStringRef s;
mutable void *cache;
- // friends -----------------------------------------------------------------
-
friend bool operator==(const QString &, const QString &);
friend bool operator==(const QString &, const char *);
friend bool operator==(const char *, const QString &);
@@ -505,10 +451,7 @@ private:
void _copyIfNeededInternalString();
-}; // class QString ============================================================
-
-
-// operators associated with QString ===========================================
+};
QString operator+(const QString &, const QString &);
QString operator+(const QString &, const char *);
@@ -663,14 +606,10 @@ inline bool operator>=(const char *chs, const QString &qs)
return qs.compareToLatin1(chs) <= 0;
}
-// class QConstString ==========================================================
-
class QConstString : private QString {
public:
-
- QConstString(QChar *, uint);
+ QConstString(const QChar *, uint);
const QString &string() const { return *this; }
-
-}; // class QConstString =======================================================
+};
#endif
diff --git a/WebCore/kwq/qt/qtextedit.h b/WebCore/kwq/qt/qtextedit.h
index 04ebc8a..3d4fe8b 100644
--- a/WebCore/kwq/qt/qtextedit.h
+++ b/WebCore/kwq/qt/qtextedit.h
@@ -54,6 +54,7 @@ class QTextEdit : public QScrollView
WrapStyle wordWrap() const;
void setWordWrap(WrapStyle);
void setTextFormat(TextFormat);
+ void setTabStopWidth(int);
bool isReadOnly () const;
void setReadOnly (bool);
void getCursorPosition(int *, int *) const;
diff --git a/WebCore/kwq/qt/qvaluelist.h b/WebCore/kwq/qt/qvaluelist.h
index c38c130..3f910e5 100644
--- a/WebCore/kwq/qt/qvaluelist.h
+++ b/WebCore/kwq/qt/qvaluelist.h
@@ -117,9 +117,9 @@ public:
T& operator[] (uint index) { return ((QValueListNode<T> *)impl.nodeAt(index))->value; }
const T& operator[] (uint index) const { return ((const QValueListNode<T> *)impl.nodeAt(index))->value; }
- QValueList<T> &operator+=(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
- QValueList<T> &operator<<(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
-
+ QValueList &operator+=(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
+ QValueList &operator<<(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
+
private:
KWQValueListImpl impl;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list