+2002-06-10 Darin Adler <darin@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@apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
+2002-06-10 Darin Adler <darin@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@apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
+2002-06-10 Darin Adler <darin@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@apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
}
// 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
// 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++;
}
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
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);
{ 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] },
"abcdefghijklmnopqrstuvwxyz"
"0123456789@*_+-./";
- if (id == Eval) { // eval()
+ switch (id) {
+ case Eval: { // eval()
Value x = args[0];
if (x.type() != StringType)
return x;
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)
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++) {
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) {
s += UString(c, 1);
}
res = String(s);
+ break;
+ }
}
return res;
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);
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".
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;
}
// 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);
*
*/
+#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;
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
#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;
RegExp::~RegExp()
{
#ifdef HAVE_PCREPOSIX
- pcre_free(pcregex);
-
+ if (pcregex)
+ pcre_free(pcregex);
#else
/* TODO: is this really okay after an error ? */
regfree(&preg);
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
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());
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;
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;
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) {
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
}
}
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
*/
#include <stdio.h>
-#if !APPLE_CHANGES
-#include <iostream.h>
-#endif
#include "value.h"
#include "object.h"
// empty string ?
if (*c == '\0')
- return 0.0;
+ return tolerant ? NaN : 0.0;
// hex number ?
if (*c == '0' && (*(c+1) == 'x' || *(c+1) == 'X')) {
ValueImp::~ValueImp()
{
//fprintf(stderr,"ValueImp::~ValueImp %p\n",(void*)this);
+ _flags |= VI_DESTRUCTED;
}
void ValueImp::mark()
enum {
VI_MARKED = 1,
VI_GCALLOWED = 2,
- VI_CREATED = 4
+ VI_CREATED = 4,
+ VI_DESTRUCTED = 8
}; // VI means VALUEIMPL
ValueImpPrivate *_vd;
+2002-06-10 Darin Adler <darin@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@apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
+2002-06-10 Darin Adler <darin@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@apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
+2002-06-10 Darin Adler <darin@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@apple.com>
* Makefile.am: Use new shared "embed.am" file so we don't need four copies of
__ZN19KWQListIteratorImplmmEv
__ZN19KWQListIteratorImplppEv
__ZN20KWQValueListNodeImplC2Ev
-__ZN20KWQValueListNodeImplD2Ev
__ZN22KWQPtrDictIteratorImpl7toFirstEv
__ZN22KWQPtrDictIteratorImplC1ERK14KWQPtrDictImpl
__ZN22KWQPtrDictIteratorImplC2ERK14KWQPtrDictImpl
__ZN22KWQPtrDictIteratorImplD2Ev
__ZN22KWQPtrDictIteratorImplppEv
__ZN24KWQValueListIteratorImpl4nodeEv
-__ZN24KWQValueListIteratorImplC1ERKS_
__ZN24KWQValueListIteratorImplC1Ev
-__ZN24KWQValueListIteratorImplD1Ev
-__ZN24KWQValueListIteratorImplaSERKS_
__ZN24KWQValueListIteratorImpleqERKS_
__ZN24KWQValueListIteratorImplmmEv
__ZN24KWQValueListIteratorImplneERKS_
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
{
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();
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 {
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,
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 )
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();
}
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()
#include "dom/css_rule.h"
#include "css/cssparser.h"
#include "misc/loader_client.h"
+#include "misc/shared.h"
namespace khtml {
class CachedCSSStyleSheet;
};
-class CSSRuleListImpl : public DomShared
+class CSSRuleListImpl : public khtml::Shared<CSSRuleListImpl>
{
public:
CSSRuleListImpl();
}
}
-bool StyleSheetImpl::deleteMe()
-{
- if(!m_parent && _ref <= 0) return true;
- return false;
-}
-
bool StyleSheetImpl::disabled() const
{
return m_disabled;
virtual bool isStyleSheet() const { return true; }
- virtual bool deleteMe();
-
virtual DOM::DOMString type() const { return DOMString(); }
bool disabled() const;
// ----------------------------------------------------------------------------
-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;
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;
}
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;
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;
}
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();
}
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*/ )
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
#include "dom/dom_string.h"
#include "css/cssparser.h"
#include "misc/loader_client.h"
+#include "misc/shared.h"
#include <qintdict.h>
} m_value;
};
-class CounterImpl : public DomShared {
+class CounterImpl : public khtml::Shared<CounterImpl> {
public:
CounterImpl() { }
DOMString identifier() const { return m_identifier; }
DOMString m_separator;
};
-class RectImpl : public DomShared {
+class RectImpl : public khtml::Shared<RectImpl> {
public:
RectImpl();
~RectImpl();
// ------------------------------------------------------------------------------------------------------
-bool StyleBaseImpl::deleteMe()
-{
- if(!m_parent && _ref <= 0) return true;
- return false;
-}
-
void StyleBaseImpl::checkLoaded()
{
if(m_parent) m_parent->checkLoaded();
// 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();
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 == '{') {
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 ) {
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 )
{
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
} 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 );
if ( !matchFontFamily(ffamily) )
return FALSE;
return true;
- }
-};
+}
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 {
// 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;
{
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;
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;
}
if ( nonCSSHint )
return 0;
- int s = 0;
- if(tag != -1) s = 1;
+ int s = (tag != -1);
switch(match)
{
case Exact:
#include "dom/dom_string.h"
#include "dom/dom_misc.h"
+#include "misc/shared.h"
#include <qdatetime.h>
#include <qptrlist.h>
};
// 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; }
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
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)
#include <assert.h>
#include <qpaintdevicemetrics.h>
#include <qintcache.h>
+#include <stdlib.h>
#ifdef APPLE_CHANGES
namespace khtml {
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();
element = 0;
settings = 0;
paintDeviceMetrics = 0;
+ propsToApply = (CSSOrderedProperty **)malloc(128*sizeof(CSSOrderedProperty *));
+ pseudoProps = (CSSOrderedProperty **)malloc(128*sizeof(CSSOrderedProperty *));
+ propsToApplySize = 128;
+ pseudoPropsSize = 128;
}
CSSStyleSelector::~CSSStyleSelector()
delete authorStyle;
delete userStyle;
delete userSheet;
+ free(propsToApply);
+ free(pseudoProps);
}
void CSSStyleSelector::addSheet( CSSStyleSheetImpl *sheet )
#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
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
//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;
}
}
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 );
// 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 )
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
}
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 ) {
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++)
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;
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;
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;
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:
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) );
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)
{
// 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;
}
// 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;
}
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:
default:
return;
}
+ }
if(width < 0) return;
switch(prop->m_id)
{
case CSS_PROP_LETTER_SPACING:
case CSS_PROP_WORD_SPACING:
{
+ int width = 0;
if(value->cssValueType() == CSSValue::CSS_INHERIT)
{
if(!parentNode) return;
{
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:
break;
// ### needs the definitions in renderstyle
case CSS_PROP_MARKER_OFFSET:
- default:
- return;
+ default: break;
}
+ return;
}
// length, percent
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:
{
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;
}
style->setMarginLeft(l); break;
case CSS_PROP_TEXT_INDENT:
style->setTextIndent(l); break;
- default:
- return;
+ default: break;
}
+ return;
}
case CSS_PROP_MAX_HEIGHT:
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;
}
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;
}
// 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
fontDirty = true;
}
return;
+#ifdef APPLE_CHANGES
+ } // make prepare-ChangeLog happy
+#else
}
+#endif
}
break;
}
style->setPaddingRight(parentStyle->paddingRight());
return;
-
// case CSS_PROP_CUE:
case CSS_PROP_FONT:
case CSS_PROP_LIST_STYLE:
{
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,
*/
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; }
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;
CSSOrderedProperty **properties;
QMemArray<CSSOrderedProperty> inlineProps;
QString m_medium;
+ CSSOrderedProperty **propsToApply;
+ CSSOrderedProperty **pseudoProps;
+ unsigned int propsToApplySize;
+ unsigned int pseudoPropsSize;
int dynamicState;
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;
INPUT[type="password"],
TEXTAREA {
font-family: monospace;
- cursor: text;
}
INPUT[type="hidden"] {
CSSRule &CSSRule::operator = (const CSSRule &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
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 );
+}
// ----------------------------------------------------------
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
CSSRuleList &CSSRuleList::operator = (const CSSRuleList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
protected:
CSSRuleImpl *impl;
+
+ void assignOther( const CSSRule &other, RuleType thisType );
};
class CSSCharsetRuleImpl;
StyleSheet &StyleSheet::operator = (const StyleSheet &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
{
if(impl) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
StyleSheet::operator = (other);
+ }
return *this;
}
StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
MediaList &MediaList::operator = (const MediaList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
LinkStyle & LinkStyle::operator = (const LinkStyle &other)
{
+ if ( node != other.node ) {
if(node) node->deref();
node = other.node;
if(node) node->ref();
+ }
return *this;
}
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;
}
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
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;
}
#include <dom/dom_string.h>
#include <dom/dom_node.h>
+#include <dom/dom_misc.h>
+
namespace DOM {
CSSStyleDeclaration &CSSStyleDeclaration::operator = (const CSSStyleDeclaration &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
CSSValue &CSSValue::operator = (const CSSValue &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
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;
}
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)
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;
}
Counter &Counter::operator = (const Counter &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
+ }
return *this;
}
Rect &Rect::operator = (const Rect &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
+ }
return *this;
}
Event &Event::operator = (const Event &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
-
+ }
return *this;
}
// -----------------------------------------------------------------------------
+#ifndef SAVE_SPACE
+
EventException::EventException(unsigned short _code)
{
code = _code;
return *this;
}
+#endif
+
// -----------------------------------------------------------------------------
UIEvent::UIEvent() : Event()
{
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;
}
{
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;
}
{
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;
}
Range &Range::operator = (const Range &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
-
+ }
return *this;
}
#define _dom2_range_h_
#include <dom/dom_doc.h>
+#include <dom/dom_misc.h>
namespace DOM {
AbstractView &AbstractView::operator = (const AbstractView &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
-
+ }
return *this;
}
DOMImplementation &DOMImplementation::operator = (const DOMImplementation &other)
{
+ if ( impl != other.impl ) {
if (impl) impl->deref();
impl = other.impl;
if (impl) impl->ref();
-
+ }
return *this;
}
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;
}
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;
}
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;
}
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;
}
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;
}
#ifndef _DOM_DOMException_h_
#define _DOM_DOMException_h_
+#include <dom/dom_misc.h>
+
namespace DOM {
NamedNodeMap &NamedNodeMap::operator = (const NamedNodeMap &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
-
+ }
return *this;
}
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;
}
NodeList &NodeList::operator = (const NodeList &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
DOMString &DOMString::operator =(const DOMString &other)
{
+ if ( impl != other.impl ) {
if(impl) impl->deref();
impl = other.impl;
if(impl) impl->ref();
+ }
return *this;
}
QString DOMString::string() const
{
- if(!impl) return QConstString(0, 0).string();
+ if(!impl) return QString::null;
return QConstString(impl->s, impl->l).string();
}
bool DOMString::isEmpty() const
{
- if (impl == 0) return true;
- return (impl->l == 0);
+ return (!impl || impl->l == 0);
}
//-----------------------------------------------------------------------------
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
HTMLBodyElement &HTMLBodyElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BODY)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BODY );
return *this;
}
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 )
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 )
HTMLFrameElement &HTMLFrameElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FRAME)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FRAME );
return *this;
}
HTMLIFrameElement &HTMLIFrameElement::operator = (const Node &other)
{
- if(other.elementId() != ID_IFRAME)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_IFRAME );
return *this;
}
HTMLFrameSetElement &HTMLFrameSetElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FRAMESET)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FRAMESET );
return *this;
}
HTMLHeadElement &HTMLHeadElement::operator = (const Node &other)
{
- if(other.elementId() != ID_HEAD)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_HEAD );
return *this;
}
HTMLHtmlElement &HTMLHtmlElement::operator = (const Node &other)
{
- if(other.elementId() != ID_HTML)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_HTML );
return *this;
}
HTMLBlockquoteElement &HTMLBlockquoteElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BLOCKQUOTE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BLOCKQUOTE );
return *this;
}
HTMLDivElement &HTMLDivElement::operator = (const Node &other)
{
- if(other.elementId() != ID_DIV)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_DIV );
return *this;
}
HTMLHRElement &HTMLHRElement::operator = (const Node &other)
{
- if(other.elementId() != ID_HR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_HR );
return *this;
}
other.elementId() != ID_H5 ||
other.elementId() != ID_H6 )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
HTMLParagraphElement &HTMLParagraphElement::operator = (const Node &other)
{
- if(other.elementId() != ID_P)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_P );
return *this;
}
HTMLPreElement &HTMLPreElement::operator = (const Node &other)
{
- if(other.elementId() != ID_PRE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_PRE );
return *this;
}
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;
}
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
+}
*/
void addCSSProperty( const DOMString &property, const DOMString &value );
+protected:
+ /*
+ * @internal
+ */
+ void assignOther( const Node &other, int elementId );
};
}; //namespace
HTMLButtonElement &HTMLButtonElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BUTTON)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BUTTON );
return *this;
}
HTMLFieldSetElement &HTMLFieldSetElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FIELDSET)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FIELDSET );
return *this;
}
HTMLFormElement &HTMLFormElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FORM)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FORM );
return *this;
}
HTMLInputElement &HTMLInputElement::operator = (const Node &other)
{
- if(other.elementId() != ID_INPUT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_INPUT );
return *this;
}
HTMLLabelElement &HTMLLabelElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LABEL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LABEL );
return *this;
}
HTMLLegendElement &HTMLLegendElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LEGEND)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LEGEND );
return *this;
}
HTMLOptGroupElement &HTMLOptGroupElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OPTGROUP)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OPTGROUP );
return *this;
}
HTMLSelectElement &HTMLSelectElement::operator = (const Node &other)
{
- if(other.elementId() != ID_SELECT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_SELECT );
return *this;
}
HTMLTextAreaElement &HTMLTextAreaElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TEXTAREA)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TEXTAREA );
return *this;
}
HTMLOptionElement &HTMLOptionElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OPTION)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OPTION );
return *this;
}
HTMLIsIndexElement &HTMLIsIndexElement::operator = (const Node &other)
{
- if(other.elementId() != ID_ISINDEX)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_ISINDEX );
return *this;
}
HTMLBaseElement &HTMLBaseElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BASE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BASE );
return *this;
}
HTMLLinkElement &HTMLLinkElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LINK)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LINK );
return *this;
}
HTMLMetaElement &HTMLMetaElement::operator = (const Node &other)
{
- if(other.elementId() != ID_META)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_META );
return *this;
}
HTMLScriptElement &HTMLScriptElement::operator = (const Node &other)
{
- if(other.elementId() != ID_SCRIPT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_SCRIPT );
return *this;
}
HTMLStyleElement &HTMLStyleElement::operator = (const Node &other)
{
- if(other.elementId() != ID_STYLE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_STYLE );
return *this;
}
HTMLTitleElement &HTMLTitleElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TITLE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TITLE );
return *this;
}
HTMLAreaElement &HTMLAreaElement::operator = (const Node &other)
{
- if(other.elementId() != ID_AREA)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_AREA );
return *this;
}
HTMLImageElement &HTMLImageElement::operator = (const Node &other)
{
- if(other.elementId() != ID_IMG)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_IMG );
return *this;
}
HTMLMapElement &HTMLMapElement::operator = (const Node &other)
{
- if(other.elementId() != ID_MAP)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_MAP );
return *this;
}
HTMLAnchorElement &HTMLAnchorElement::operator = (const Node &other)
{
- if(other.elementId() != ID_A)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_A );
return *this;
}
HTMLBRElement &HTMLBRElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BR );
return *this;
}
HTMLFontElement &HTMLFontElement::operator = (const Node &other)
{
- if(other.elementId() != ID_FONT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_FONT );
return *this;
}
impl = _impl;
else
impl = 0;
+ if ( impl ) impl->ref();
}
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;
}
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;
}
HTMLDListElement &HTMLDListElement::operator = (const Node &other)
{
- if(other.elementId() != ID_DL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_DL );
return *this;
}
HTMLDirectoryElement &HTMLDirectoryElement::operator = (const Node &other)
{
- if(other.elementId() != ID_DIR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_DIR );
return *this;
}
HTMLLIElement &HTMLLIElement::operator = (const Node &other)
{
- if(other.elementId() != ID_LI)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_LI );
return *this;
}
HTMLMenuElement &HTMLMenuElement::operator = (const Node &other)
{
- if(other.elementId() != ID_MENU)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_MENU );
return *this;
}
HTMLOListElement &HTMLOListElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OL );
return *this;
}
HTMLUListElement &HTMLUListElement::operator = (const Node &other)
{
- if(other.elementId() != ID_UL)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_UL );
return *this;
}
HTMLBaseFontElement &HTMLBaseFontElement::operator = (const Node &other)
{
- if(other.elementId() != ID_BASEFONT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_BASEFONT );
return *this;
}
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;
}
HTMLAppletElement &HTMLAppletElement::operator = (const Node &other)
{
- if(other.elementId() != ID_APPLET)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_APPLET );
return *this;
}
HTMLObjectElement &HTMLObjectElement::operator = (const Node &other)
{
- if(other.elementId() != ID_OBJECT)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_OBJECT );
return *this;
}
HTMLParamElement &HTMLParamElement::operator = (const Node &other)
{
- if(other.elementId() != ID_PARAM)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_PARAM );
return *this;
}
HTMLTableCaptionElement &HTMLTableCaptionElement::operator = (const Node &other)
{
- if(other.elementId() != ID_CAPTION)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_CAPTION );
return *this;
}
if( other.elementId() != ID_TD &&
other.elementId() != ID_TH )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
if( other.elementId() != ID_COL &&
other.elementId() != ID_COLGROUP )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
HTMLTableElement &HTMLTableElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TABLE)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TABLE );
return *this;
}
HTMLTableRowElement &HTMLTableRowElement::operator = (const Node &other)
{
- if(other.elementId() != ID_TR)
- {
- impl = 0;
- return *this;
- }
- Node::operator = (other);
+ assignOther( other, ID_TR );
return *this;
}
other.elementId() != ID_THEAD &&
other.elementId() != ID_TFOOT )
{
+ if ( impl ) impl->deref();
impl = 0;
- return *this;
- }
+ } else {
Node::operator = (other);
+ }
return *this;
}
case Referrer:
return getString(doc.referrer());
case Domain:
- return getString(doc.domain());
+ return String(doc.domain());
case URL:
return getString(doc.URL());
case Body:
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;
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());
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;
#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;
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();
}
// -------------------------------------------------------------------------
-JSNodeFilter::JSNodeFilter(Object & _filter) : DOM::CustomNodeFilter()
+JSNodeFilter::JSNodeFilter(Object & _filter) : DOM::CustomNodeFilter(), filter( _filter )
{
- filter = _filter;
}
JSNodeFilter::~JSNodeFilter()
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; }
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;
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;
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)
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;
}
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:
//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;
}
{
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";
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
{
// 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
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
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));
// 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());
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() );
}
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()))
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());
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
{
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;
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();
}
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;
}
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;
#define HTML_MISCIMPL_H
#include "html_elementimpl.h"
+#include "misc/shared.h"
namespace DOM {
// -------------------------------------------------------------------------
-class HTMLCollectionImpl : public DomShared
+class HTMLCollectionImpl : public khtml::Shared<HTMLCollectionImpl>
{
friend class DOM::HTMLCollection;
public:
#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;
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)
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));
#include "html_elementimpl.h"
#include "xml/dom_stringimpl.h"
+#include "java/kjavaappletcontext.h"
#include <qstringlist.h>
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;
};
reset();
current = i;
inBody = true;
- inSelect = false;
}
KHTMLParser::~KHTMLParser()
memset(forbiddenTag, 0, (ID_CLOSE_TAG+1)*sizeof(ushort));
inBody = false;
- noRealBody = true;
haveFrameSet = false;
+ haveContent = false;
inSelect = false;
_inline = false;
#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>
}
// 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);
}
if ( changed )
doc()->recalcStyle( NodeImpl::Inherit );
- noRealBody = false;
}
return false;
}
}
if ( changed )
doc()->recalcStyle( NodeImpl::Inherit );
- noRealBody = false;
} else if ( current->isDocumentNode() )
break;
return false;
popBlock(ID_HEAD);
n = new HTMLBodyElementImpl(document);
startBody();
- noRealBody = false;
break;
// head elements
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
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:
*/
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; }
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
*/
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 ))
comment = false;
server = false;
textarea = false;
+ title = false;
startTag = false;
tquote = NoQuote;
searchCount = 0;
pending = SpacePending;
else
pending = TabPending;
+
++list;
}
else
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;
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;
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);
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 );
}
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;
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;
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;
}
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 )
{
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;
}
}
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)
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);
}
#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();
}
}
-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();
{
if (onHold == _onHold) return;
onHold = _onHold;
- if (!onHold)
- write( _src, true );
+ if (onHold)
+ setSrc(QString(src.current(), src.length())); // ### deep copy
}
-#include "htmltokenizer.moc"
class HTMLTokenizer : public Tokenizer, public khtml::CachedObjectClient
{
- Q_OBJECT
public:
HTMLTokenizer(DOM::DocumentPtr *, KHTMLView * = 0);
HTMLTokenizer(DOM::DocumentPtr *, DOM::DocumentFragmentImpl *frag);
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.
// 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;
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* ) ) );
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();
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")) )
{
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());
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 )
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() )
{
#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&)),
void KHTMLPart::clear()
{
- kdDebug( 6090 ) << "KHTMLPart::clear() this = " << this << endl;
if ( d->m_bCleared )
return;
d->m_bCleared = true;
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 )
// 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
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;
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();
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();
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 );
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
}
closeURL();
KURL url = m_url;
m_url = 0;
+ d->m_restored = true;
openURL(url);
+ d->m_restored = false;
}
#endif
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)
// 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:
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:
case ID_H4:
case ID_H5:
case ID_H6:
- text += "\n\n";
+ if (!hasNewLine)
+ text += "\n";
+ text += "\n";
+ hasNewLine = true;
break;
}
}
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
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)
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",
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;
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,
*/
// 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."
}
}
+ 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
//
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 {
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
}
if (tokenizer)
- tokenizer->setOnHold(false);
+ tokenizer->setOnHold(false);
return (response==KMessageBox::Continue);
}
return true;
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;
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;
borderY = 30;
clickX = -1;
clickY = -1;
- prevMouseX = -1;
- prevMouseY = -1;
+ prevMouseX = -1;
+ prevMouseY = -1;
clickCount = 0;
isDoubleClick = false;
scrollingSelf = false;
//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())
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)
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);
//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);
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();
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 )
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){
me->deref();
}
- if (oldUnder)
- oldUnder->deref();
- }
+ if (oldUnder)
+ oldUnder->deref();
+ }
}
bool swallowEvent = false;
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;
/*
* %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; }
return value;
case Percent:
return maxWidth*value/100;
- case Undefined:
case Variable:
return maxWidth;
default:
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); }
#include "khtml_factory.h"
#include "khtml_part.h"
+#include "html/html_documentimpl.h"
#include "css/css_stylesheetimpl.h"
#include "xml/dom_docimpl.h"
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;
#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)
// -------------------------------------------------------------------------------------------
-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.
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;
m_sheet = DOMString(stylesheet_data);
}
-#endif
-
-
CachedCSSStyleSheet::~CachedCSSStyleSheet()
{
}
void CachedCSSStyleSheet::deref(CachedObjectClient *c)
{
+ Cache::flush();
m_clients.remove(c);
if ( canDelete() && m_free )
delete this;
// -------------------------------------------------------------------------------------------
-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.
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;
m_script = DOMString(script_data);
}
-#endif
-
CachedScript::~CachedScript()
{
}
void CachedScript::deref(CachedObjectClient *c)
{
+ Cache::flush();
m_clients.remove(c);
if ( canDelete() && m_free )
delete this;
}
-/*!
- This Class defines the DataSource for incremental loading of images.
-*/
ImageSource::ImageSource(QByteArray buf)
{
buffer = 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())
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);
}
}
-/**
- * Sets the EOF state.
- */
void ImageSource::setEOF( bool state )
{
eof = state;
ready();
}
-
void ImageSource::cleanBuffer()
{
// if we need to be able to rewind, buffer is needed
}
}
-#endif // APPLE_CHANGES
-
static QString buildAcceptHeader()
{
QString result = KImageIO::mimeTypes( KImageIO::Reading ).join(", ");
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;
m_status = Unknown;
m_size = 0;
imgSource = 0;
+#ifndef APPLE_CHANGES
setAccept( acceptHeader );
+#endif
m_showAnimations = dl->showAnimations();
}
if( m ) {
m->unpause();
- if( m->finished() )
+ if( m->finished() || m_clients.count() == 1 )
m->restart();
}
#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;
}
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);
{
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
}
- 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 );
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());
}
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& ) ) );
DocLoader::DocLoader(KHTMLPart* part, DocumentImpl* doc)
{
- m_reloading = false;
+ m_cachePolicy = KIO::CC_Verify;
m_expireDate = 0;
m_bautoloadImages = true;
m_showAnimations = KHTMLSettings::KAnimationEnabled;
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 )
}
}
-void DocLoader::setReloading( bool enable )
+void DocLoader::setCachePolicy( KIO::CacheControl cachePolicy )
{
- m_reloading = enable;
+ m_cachePolicy = cachePolicy;
}
void DocLoader::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
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 ) {
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 * ) ) );
{
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
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)
#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)
#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)
{
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)
#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);
#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)
{
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)
#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);
#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))
{
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)
init();
#ifdef CACHE_DEBUG
- //statistics();
+ statistics();
kdDebug( 6060 ) << "Cache: flush()" << endl;
#endif
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()
flushAll();
}
-void Cache::preloadScript(const QString &, const QString &)
-{
-}
-
-void Cache::preloadStyleSheet(const QString &, const QString &)
-{
-}
-
#endif // APPLE_CHANGES
-
-#include "loader.moc"
#include <config.h>
#endif
+#include <time.h>
+
#include "loader_client.h"
#ifdef HAVE_LIBJPEG
#include "loader_jpeg.h"
#include <qtextcodec.h>
#include <kurl.h>
-
+#include <kio/global.h>
#include <khtml_settings.h>
#include <dom/dom_string.h>
}; // 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
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();