Commit d851e378 authored by mjs's avatar mjs

Reviewed by Richard.

	<rdar://problem/3504049>: XMLSerializer object and serializeToString method needed for XMLHttpRequest testing

	Also fixed some lasst-minute mistakes in the DOM serialization
	code that was already there.

        * WebCore.pbproj/project.pbxproj:
        * khtml/dom/dom_doc.h:
        * khtml/ecma/Makefile.am:
        * khtml/ecma/kjs_window.cpp:
        (Window::get):
        * khtml/ecma/kjs_window.h:
        (KJS::Window::):
        * khtml/ecma/kjs_window.lut.h:
        (KJS::):
        * khtml/ecma/xmlserializer.cpp: Added.
        (KJS::XMLSerializerConstructorImp::XMLSerializerConstructorImp):
        (KJS::XMLSerializerConstructorImp::implementsConstruct):
        (KJS::XMLSerializerConstructorImp::construct):
        (KJS::):
        (KJS::XMLSerializer::XMLSerializer):
        (KJS::XMLSerializerProtoFunc::tryCall):
        * khtml/ecma/xmlserializer.h: Added.
        (KJS::XMLSerializer::toBoolean):
        (KJS::XMLSerializer::classInfo):
        (KJS::XMLSerializer::):
        * khtml/ecma/xmlserializer.lut.h: Added.
        (KJS::):
        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::toString):
        (DocumentFragmentImpl::toString):
        * khtml/xml/dom_elementimpl.cpp:
        (AttrImpl::toString):
        (ElementImpl::toString):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5740 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 400db120
2003-12-09 Maciej Stachowiak <mjs@apple.com>
Reviewed by Richard.
<rdar://problem/3504049>: XMLSerializer object and serializeToString method needed for XMLHttpRequest testing
Also fixed some lasst-minute mistakes in the DOM serialization
code that was already there.
* WebCore.pbproj/project.pbxproj:
* khtml/dom/dom_doc.h:
* khtml/ecma/Makefile.am:
* khtml/ecma/kjs_window.cpp:
(Window::get):
* khtml/ecma/kjs_window.h:
(KJS::Window::):
* khtml/ecma/kjs_window.lut.h:
(KJS::):
* khtml/ecma/xmlserializer.cpp: Added.
(KJS::XMLSerializerConstructorImp::XMLSerializerConstructorImp):
(KJS::XMLSerializerConstructorImp::implementsConstruct):
(KJS::XMLSerializerConstructorImp::construct):
(KJS::):
(KJS::XMLSerializer::XMLSerializer):
(KJS::XMLSerializerProtoFunc::tryCall):
* khtml/ecma/xmlserializer.h: Added.
(KJS::XMLSerializer::toBoolean):
(KJS::XMLSerializer::classInfo):
(KJS::XMLSerializer::):
* khtml/ecma/xmlserializer.lut.h: Added.
(KJS::):
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::toString):
(DocumentFragmentImpl::toString):
* khtml/xml/dom_elementimpl.cpp:
(AttrImpl::toString):
(ElementImpl::toString):
2003-12-09 David Hyatt <hyatt@apple.com>
Implement start() and stop() for marquees.
......
......@@ -521,6 +521,8 @@
654E7EE40569FD4600358BD2,
654E7EE50569FD4600358BD2,
84B2B1F9056BEF3A00D2B771,
65912B110586921000123A69,
65912B120586921000123A69,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -786,6 +788,7 @@
654E7EE30569FD4600358BD2,
84B2B1FA056BEF3A00D2B771,
84B2B250056BF15F00D2B771,
65912B100586921000123A69,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -1083,6 +1086,48 @@
settings = {
};
};
65912B0D0586921000123A69 = {
expectedFileType = sourcecode.cpp.cpp;
fileEncoding = 30;
isa = PBXFileReference;
path = xmlserializer.cpp;
refType = 4;
sourceTree = "<group>";
};
65912B0E0586921000123A69 = {
expectedFileType = sourcecode.c.h;
fileEncoding = 30;
isa = PBXFileReference;
path = xmlserializer.h;
refType = 4;
sourceTree = "<group>";
};
65912B0F0586921000123A69 = {
expectedFileType = sourcecode.c.h;
fileEncoding = 30;
isa = PBXFileReference;
path = xmlserializer.lut.h;
refType = 4;
sourceTree = "<group>";
};
65912B100586921000123A69 = {
fileRef = 65912B0D0586921000123A69;
isa = PBXBuildFile;
settings = {
};
};
65912B110586921000123A69 = {
fileRef = 65912B0E0586921000123A69;
isa = PBXBuildFile;
settings = {
};
};
65912B120586921000123A69 = {
fileRef = 65912B0F0586921000123A69;
isa = PBXBuildFile;
settings = {
};
};
65A640F00533BB1F0085E777 = {
expectedFileType = sourcecode.c.h;
fileEncoding = 30;
......@@ -4202,6 +4247,9 @@
654E7EE00569FD4600358BD2,
654E7EE10569FD4600358BD2,
654E7EE20569FD4600358BD2,
65912B0D0586921000123A69,
65912B0E0586921000123A69,
65912B0F0586921000123A69,
);
isa = PBXGroup;
path = ecma;
......
......@@ -790,9 +790,10 @@ public:
DOMString completeURL(const DOMString& url);
DOMString toString() const;
protected:
Document( DocumentImpl *i);
protected:
friend class Node;
};
......
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2003 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "xmlserializer.h"
#include "xmlserializer.lut.h"
#include "dom/dom_exception.h"
#include "dom/dom_doc.h"
#include "xml/dom_docimpl.h"
#include <kdebug.h>
using namespace KJS;
////////////////////// XMLSerializer Object ////////////////////////
/* Source for XMLSerializerProtoTable.
@begin XMLSerializerProtoTable 1
serializeToString XMLSerializer::SerializeToString DontDelete|Function 1
@end
*/
DEFINE_PROTOTYPE("XMLSerializer",XMLSerializerProto)
IMPLEMENT_PROTOFUNC(XMLSerializerProtoFunc)
IMPLEMENT_PROTOTYPE(XMLSerializerProto,XMLSerializerProtoFunc)
namespace KJS {
XMLSerializerConstructorImp::XMLSerializerConstructorImp(ExecState *)
: ObjectImp()
{
}
bool XMLSerializerConstructorImp::implementsConstruct() const
{
return true;
}
Object XMLSerializerConstructorImp::construct(ExecState *exec, const List &)
{
return Object(new XMLSerializer(exec));
}
const ClassInfo XMLSerializer::info = { "XMLSerializer", 0, &XMLSerializerTable, 0 };
/* Source for XMLSerializerTable.
@begin XMLSerializerTable 0
@end
*/
XMLSerializer::XMLSerializer(ExecState *exec)
: DOMObject(XMLSerializerProto::self(exec))
{
}
Value XMLSerializerProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
if (!thisObj.inherits(&XMLSerializer::info)) {
Object err = Error::create(exec,TypeError);
exec->setException(err);
return err;
}
switch (id) {
case XMLSerializer::SerializeToString:
{
if (args.size() != 1) {
return Undefined();
}
if (!args[0].toObject(exec).inherits(&DOMDocument::info)) {
return Undefined();
}
DOM::Node docNode = static_cast<KJS::DOMDocument *>(args[0].toObject(exec).imp())->toNode();
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(docNode.handle());
if (!doc) {
return Undefined();
}
QString body;
try {
body = doc->toString().string();
} catch(DOM::DOMException& e) {
Object err = Error::create(exec, GeneralError, "Exception serializing document");
exec->setException(err);
return err;
}
return getStringOrNull(body);
}
}
return Undefined();
}
}; // end namespace
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 2003 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _XMLSERIALIZER_H_
#define _XMLSERIALIZER_H_
#include "ecma/kjs_binding.h"
#include "ecma/kjs_dom.h"
#include "misc/decoder.h"
#include "kio/jobclasses.h"
namespace KJS {
class JSEventListener;
class XMLSerializerConstructorImp : public ObjectImp {
public:
XMLSerializerConstructorImp(ExecState *);
virtual bool implementsConstruct() const;
virtual Object construct(ExecState *exec, const List &args);
};
class XMLSerializer : public DOMObject {
public:
XMLSerializer(ExecState *);
virtual bool toBoolean(ExecState *) const { return true; }
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { SerializeToString };
private:
friend class XMLSerializerProtoFunc;
};
}; // namespace
#endif
/* Automatically generated from xmlserializer.cpp using ../../../JavaScriptCore/kjs/create_hash_table. DO NOT EDIT ! */
namespace KJS {
const struct HashEntry XMLSerializerProtoTableEntries[] = {
{ "serializeToString", XMLSerializer::SerializeToString, DontDelete|Function, 1, 0 }
};
const struct HashTable XMLSerializerProtoTable = { 2, 1, XMLSerializerProtoTableEntries, 1 };
} // namespace
namespace KJS {
const struct HashEntry XMLSerializerTableEntries[] = {
};
const struct HashTable XMLSerializerTable = { 2, 0, XMLSerializerTableEntries, 0 };
} // namespace
......@@ -2594,7 +2594,7 @@ DOMString DocumentImpl::toString() const
DOMString result;
for (NodeImpl *child = firstChild(); child != NULL; child = child->nextSibling()) {
child = child->nextSibling();
result += child->toString();
}
return result;
......@@ -2645,7 +2645,7 @@ DOMString DocumentFragmentImpl::toString() const
DOMString result;
for (NodeImpl *child = firstChild(); child != NULL; child = child->nextSibling()) {
child = child->nextSibling();
result += child->toString();
}
return result;
......
......@@ -168,7 +168,7 @@ DOMString AttrImpl::toString() const
result += "=\"";
for (NodeImpl *child = firstChild(); child != NULL; child = child->nextSibling()) {
child = child->nextSibling();
result += child->toString();
}
result += "\"";
......@@ -557,7 +557,7 @@ DOMString ElementImpl::toString() const
result += ">";
for (NodeImpl *child = firstChild(); child != NULL; child = child->nextSibling()) {
child = child->nextSibling();
result += child->toString();
}
result += "</";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment