[webkit-changes] cvs commit: LayoutTests/dom/xhtml/level1/core
hc_documentgetdoctype-expected.txt
Darin
darin at opensource.apple.com
Tue Oct 25 23:10:12 PDT 2005
darin 05/10/25 23:10:12
Modified: . ChangeLog
khtml/html html_documentimpl.cpp
khtml/xml dom_docimpl.cpp dom_docimpl.h xml_tokenizer.cpp
. ChangeLog
dom/xhtml/level1/core hc_documentgetdoctype-expected.txt
Log:
LayoutTests:
* dom/xhtml/level1/core/hc_documentgetdoctype-expected.txt: Expect success.
WebCore:
Reviewed by Eric.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5315
need to set document type based on contents of <!DOCTYPE>
(fixes one layout test)
* khtml/html/html_documentimpl.cpp: (DOM::HTMLDocumentImpl::determineParseMode):
Use the new setDocType function instead of modifying m_doctype directly.
* khtml/xml/dom_docimpl.h: Changed to use SharedPtr more.
(DOM::DocumentImpl::realDocType): Add get() since we're using SharedPtr.
(DOM::DocumentImpl::setDocType): Added.
* khtml/xml/dom_docimpl.cpp:
(DOMImplementationImpl::createDocument): Use setDocType instead of using
realDocType()->copyFrom to set up the document type in the new document.
(DocumentImpl::DocumentImpl): Don't create an empty document type during constructor.
(DocumentImpl::~DocumentImpl): Remove explicit deref since we're using SharedPtr.
(DocumentImpl::doctype): Add get() since we're using SharedPtr.
(DocumentTypeImpl::DocumentTypeImpl): Streamlined implementation since we're using SharedPtr.
* khtml/xml/xml_tokenizer.cpp:
(khtml::XMLTokenizer::internalSubset): Added. Calls setDocType.
(khtml::internalSubsetHandler): Added. Calls xmlSAX2InternalSubset after calling our function.
(khtml::XMLTokenizer::finish): Changed to pass our internalSubsetHandler function pointer.
Revision Changes Path
1.292 +27 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.291
retrieving revision 1.292
diff -u -r1.291 -r1.292
--- ChangeLog 26 Oct 2005 06:08:00 -0000 1.291
+++ ChangeLog 26 Oct 2005 06:10:05 -0000 1.292
@@ -1,3 +1,30 @@
+2005-10-25 Darin Adler <darin at apple.com>
+
+ Reviewed by Eric.
+
+ - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5315
+ need to set document type based on contents of <!DOCTYPE>
+ (fixes one layout test)
+
+ * khtml/html/html_documentimpl.cpp: (DOM::HTMLDocumentImpl::determineParseMode):
+ Use the new setDocType function instead of modifying m_doctype directly.
+
+ * khtml/xml/dom_docimpl.h: Changed to use SharedPtr more.
+ (DOM::DocumentImpl::realDocType): Add get() since we're using SharedPtr.
+ (DOM::DocumentImpl::setDocType): Added.
+ * khtml/xml/dom_docimpl.cpp:
+ (DOMImplementationImpl::createDocument): Use setDocType instead of using
+ realDocType()->copyFrom to set up the document type in the new document.
+ (DocumentImpl::DocumentImpl): Don't create an empty document type during constructor.
+ (DocumentImpl::~DocumentImpl): Remove explicit deref since we're using SharedPtr.
+ (DocumentImpl::doctype): Add get() since we're using SharedPtr.
+ (DocumentTypeImpl::DocumentTypeImpl): Streamlined implementation since we're using SharedPtr.
+
+ * khtml/xml/xml_tokenizer.cpp:
+ (khtml::XMLTokenizer::internalSubset): Added. Calls setDocType.
+ (khtml::internalSubsetHandler): Added. Calls xmlSAX2InternalSubset after calling our function.
+ (khtml::XMLTokenizer::finish): Changed to pass our internalSubsetHandler function pointer.
+
2005-10-25 David Hyatt <hyatt at apple.com>
This patch makes a number of refinements to buttons to make
1.73 +2 -5 WebCore/khtml/html/html_documentimpl.cpp
Index: html_documentimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_documentimpl.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- html_documentimpl.cpp 13 Oct 2005 00:49:29 -0000 1.72
+++ html_documentimpl.cpp 26 Oct 2005 06:10:09 -0000 1.73
@@ -495,11 +495,8 @@
QString systemID, publicID;
int resultFlags = 0;
if (parseDocTypeDeclaration(str, &resultFlags, publicID, systemID)) {
- if (resultFlags & PARSEMODE_HAVE_DOCTYPE) {
- m_doctype->setName("HTML");
- m_doctype->setPublicId(publicID);
- m_doctype->setSystemId(systemID);
- }
+ if (resultFlags & PARSEMODE_HAVE_DOCTYPE)
+ setDocType(new DocumentTypeImpl(docPtr(), "HTML", publicID, systemID));
if (!(resultFlags & PARSEMODE_HAVE_DOCTYPE)) {
// No doctype found at all. Default to quirks mode and Html4.
pMode = Compat;
1.262 +16 -53 WebCore/khtml/xml/dom_docimpl.cpp
Index: dom_docimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -r1.261 -r1.262
--- dom_docimpl.cpp 24 Oct 2005 07:24:35 -0000 1.261
+++ dom_docimpl.cpp 26 Oct 2005 06:10:09 -0000 1.262
@@ -305,7 +305,7 @@
// now get the interesting parts of the doctype
if (doctype)
- doc->realDocType()->copyFrom(*doctype);
+ doc->setDocType(new DocumentTypeImpl(doc->docPtr(), *doctype));
return doc;
}
@@ -415,14 +415,6 @@
m_elemSheet = 0;
m_tokenizer = 0;
- // ### this should be created during parsing a <!DOCTYPE>
- // not during construction. Not sure who added that and why (Dirk)
- m_doctype = new DocumentTypeImpl(_implementation, document,
- DOMString() /* qualifiedName */,
- DOMString() /* publicId */,
- DOMString() /* systemId */);
- m_doctype->ref();
-
m_implementation = _implementation;
if (m_implementation)
m_implementation->ref();
@@ -492,8 +484,6 @@
delete m_styleSelector;
delete m_docLoader;
if (m_elemSheet ) m_elemSheet->deref();
- if (m_doctype)
- m_doctype->deref();
if (m_implementation)
m_implementation->deref();
delete m_paintDeviceMetrics;
@@ -571,7 +561,7 @@
DocumentTypeImpl *DocumentImpl::doctype() const
{
- return m_doctype;
+ return m_docType.get();
}
DOMImplementationImpl *DocumentImpl::impl() const
@@ -3310,49 +3300,29 @@
// ----------------------------------------------------------------------------
-DocumentTypeImpl::DocumentTypeImpl(DOMImplementationImpl *implementation, DocumentPtr *doc,
- const DOMString &qualifiedName, const DOMString &publicId,
- const DOMString &systemId)
- : NodeImpl(doc), m_implementation(implementation),
- m_qualifiedName(qualifiedName), m_publicId(publicId), m_systemId(systemId)
+DocumentTypeImpl::DocumentTypeImpl(DOMImplementationImpl *i, DocumentPtr *doc, const DOMString &n, const DOMString &p, const DOMString &s)
+ : NodeImpl(doc), m_implementation(i), m_name(n), m_publicId(p), m_systemId(s)
{
- if (m_implementation)
- m_implementation->ref();
-
- m_entities = 0;
- m_notations = 0;
-
- // if doc is 0, it is not attached to a document and / or
- // therefore does not provide entities or notations. (DOM Level 3)
}
-DocumentTypeImpl::~DocumentTypeImpl()
+DocumentTypeImpl::DocumentTypeImpl(DocumentPtr *doc, const DOMString &n, const DOMString &p, const DOMString &s)
+ : NodeImpl(doc), m_name(n), m_publicId(p), m_systemId(s)
{
- if (m_implementation)
- m_implementation->deref();
- if (m_entities)
- m_entities->deref();
- if (m_notations)
- m_notations->deref();
}
-void DocumentTypeImpl::copyFrom(const DocumentTypeImpl& other)
-{
- m_qualifiedName = other.m_qualifiedName;
- m_publicId = other.m_publicId;
- m_systemId = other.m_systemId;
- m_subset = other.m_subset;
+DocumentTypeImpl::DocumentTypeImpl(DocumentPtr *doc, const DocumentTypeImpl &t)
+ : NodeImpl(doc), m_implementation(t.m_implementation)
+ , m_name(t.m_name), m_publicId(t.m_publicId), m_systemId(t.m_systemId), m_subset(t.m_subset)
+{
}
DOMString DocumentTypeImpl::toString() const
{
- DOMString result;
- if (m_qualifiedName.isEmpty()) {
+ if (m_name.isEmpty())
return "";
- } else {
- result = "<!DOCTYPE ";
- result += m_qualifiedName;
- }
+
+ DOMString result = "<!DOCTYPE ";
+ result += m_name;
if (!m_publicId.isEmpty()) {
result += " PUBLIC \"";
result += m_publicId;
@@ -3383,16 +3353,9 @@
return Node::DOCUMENT_TYPE_NODE;
}
-// DOM Section 1.1.1
-bool DocumentTypeImpl::childTypeAllowed( unsigned short /*type*/ )
+NodeImpl *DocumentTypeImpl::cloneNode(bool /*deep*/)
{
- return false;
-}
-
-NodeImpl *DocumentTypeImpl::cloneNode ( bool /*deep*/ )
-{
- // Spec says cloning Document nodes is "implementation dependent"
- // so we do not support it...
+ // The DOM Level 2 specification says cloning DocumentType nodes is "implementation dependent" so for now we do not support it.
return 0;
}
1.132 +18 -25 WebCore/khtml/xml/dom_docimpl.h
Index: dom_docimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.h,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -r1.131 -r1.132
--- dom_docimpl.h 24 Oct 2005 07:24:35 -0000 1.131
+++ dom_docimpl.h 26 Oct 2005 06:10:09 -0000 1.132
@@ -175,7 +175,7 @@
// DOM methods & attributes for Document
virtual DocumentTypeImpl *doctype() const; // returns 0 for HTML documents
- DocumentTypeImpl *realDocType() const { return m_doctype; }
+ DocumentTypeImpl *realDocType() const { return m_docType.get(); }
DOMImplementationImpl *impl() const;
virtual ElementImpl *documentElement() const;
@@ -584,6 +584,8 @@
void incDOMTreeVersion() { ++m_domtree_version; }
unsigned int domTreeVersion() const { return m_domtree_version; }
+ void setDocType(DocumentTypeImpl *docType) { m_docType = docType; }
+
signals:
void finishedParsing();
@@ -598,7 +600,7 @@
QString m_baseURL;
QString m_baseTarget;
- DocumentTypeImpl *m_doctype;
+ SharedPtr<DocumentTypeImpl> m_docType;
DOMImplementationImpl *m_implementation;
StyleSheetImpl *m_sheet;
@@ -794,51 +796,42 @@
virtual DOMString toString() const;
};
-
class DocumentTypeImpl : public NodeImpl
{
public:
- DocumentTypeImpl(DOMImplementationImpl *_implementation, DocumentPtr *doc,
- const DOMString &qualifiedName, const DOMString &publicId,
- const DOMString &systemId);
- ~DocumentTypeImpl();
+ DocumentTypeImpl(DOMImplementationImpl *, DocumentPtr *, const DOMString &name, const DOMString &publicId, const DOMString &systemId);
+ DocumentTypeImpl(DocumentPtr *, const DOMString &name, const DOMString &publicId, const DOMString &systemId);
+ DocumentTypeImpl(DocumentPtr *, const DocumentTypeImpl &);
// DOM methods & attributes for DocumentType
- NamedNodeMapImpl *entities() const { return m_entities; }
- NamedNodeMapImpl *notations() const { return m_notations; }
+ NamedNodeMapImpl *entities() const { return m_entities.get(); }
+ NamedNodeMapImpl *notations() const { return m_notations.get(); }
- DOMString name() const { return m_qualifiedName; }
+ DOMString name() const { return m_name; }
DOMString publicId() const { return m_publicId; }
DOMString systemId() const { return m_systemId; }
DOMString internalSubset() const { return m_subset; }
- // DOM methods overridden from parent classes
+ // DOM methods overridden from parent classes
virtual DOMString nodeName() const;
virtual unsigned short nodeType() const;
- virtual bool childTypeAllowed( unsigned short type );
- virtual NodeImpl *cloneNode ( bool deep );
+ virtual NodeImpl *cloneNode(bool deep);
// Other methods (not part of DOM)
- void setName(const DOMString& n) { m_qualifiedName = n; }
- void setPublicId(const DOMString& publicId) { m_publicId = publicId; }
- void setSystemId(const DOMString& systemId) { m_systemId = systemId; }
- DOMImplementationImpl *impl() const { return m_implementation; }
- void copyFrom(const DocumentTypeImpl&);
-
+ DOMImplementationImpl *impl() const { return m_implementation.get(); }
virtual DOMString toString() const;
-protected:
- DOMImplementationImpl *m_implementation;
- NamedNodeMapImpl* m_entities;
- NamedNodeMapImpl* m_notations;
+private:
+ SharedPtr<DOMImplementationImpl> m_implementation;
+ SharedPtr<NamedNodeMapImpl> m_entities;
+ SharedPtr<NamedNodeMapImpl> m_notations;
- DOMString m_qualifiedName;
+ DOMString m_name;
DOMString m_publicId;
DOMString m_systemId;
DOMString m_subset;
};
-
} //namespace
#endif
1.48 +29 -26 WebCore/khtml/xml/xml_tokenizer.cpp
Index: xml_tokenizer.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/xml_tokenizer.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- xml_tokenizer.cpp 25 Oct 2005 22:32:55 -0000 1.47
+++ xml_tokenizer.cpp 26 Oct 2005 06:10:10 -0000 1.48
@@ -42,25 +42,8 @@
#include <qptrstack.h>
-using namespace DOM::HTMLNames;
-
-using DOM::AttributeImpl;
-using DOM::NamedAttrMapImpl;
-using DOM::DocumentFragmentImpl;
-using DOM::DocumentImpl;
-using DOM::DocumentPtr;
-using DOM::DOMString;
-using DOM::DOMStringImpl;
-using DOM::ElementImpl;
-using DOM::HTMLScriptElementImpl;
-using DOM::HTMLTableSectionElementImpl;
-using DOM::Node;
-using DOM::NodeImpl;
-using DOM::nullAtom;
-using DOM::ProcessingInstructionImpl;
-using DOM::QualifiedName;
-using DOM::TextImpl;
-using DOM::AtomicString;
+using namespace DOM;
+using namespace HTMLNames;
namespace khtml {
@@ -113,6 +96,7 @@
void processingInstruction(const xmlChar *target, const xmlChar *data);
void cdataBlock(const xmlChar *s, int len);
void comment(const xmlChar *s);
+ void internalSubset(const xmlChar *name, const xmlChar *externalID, const xmlChar *systemID);
private:
void end();
@@ -134,7 +118,7 @@
QString m_xmlCode;
xmlParserCtxtPtr m_context;
- DOM::NodeImpl *m_currentNode;
+ NodeImpl *m_currentNode;
bool m_sawError;
bool m_sawXSLTransform;
@@ -386,7 +370,7 @@
void XMLTokenizer::endElementNs()
{
- if (m_parserStopped)
+ if (m_parserStopped)
return;
if (m_currentNode->nodeType() == Node::TEXT_NODE)
@@ -401,7 +385,7 @@
void XMLTokenizer::characters(const xmlChar *s, int len)
{
- if (m_parserStopped)
+ if (m_parserStopped)
return;
if (m_currentNode->nodeType() == Node::TEXT_NODE ||
@@ -539,7 +523,7 @@
void XMLTokenizer::comment(const xmlChar *s)
{
- if (m_parserStopped)
+ if (m_parserStopped)
return;
if (m_currentNode->nodeType() == Node::TEXT_NODE)
@@ -548,6 +532,19 @@
m_currentNode->addChild(m_doc->document()->createComment(toQString(s)));
}
+void XMLTokenizer::internalSubset(const xmlChar *name, const xmlChar *externalID, const xmlChar *systemID)
+{
+ if (m_parserStopped)
+ return;
+
+ DocumentPtr *docPtr = m_doc;
+ DocumentImpl *doc = docPtr->document();
+ if (!doc)
+ return;
+
+ doc->setDocType(new DocumentTypeImpl(docPtr, toQString(name), toQString(externalID), toQString(systemID)));
+}
+
inline XMLTokenizer *getTokenizer(void *closure)
{
xmlParserCtxtPtr ctxt = static_cast<xmlParserCtxtPtr>(closure);
@@ -615,15 +612,21 @@
if(ent)
return ent;
- // Workaround a libxml SAX2 bug whereby charactersHandler is called twice
+ // Work around a libxml SAX2 bug that causes charactersHandler to be called twice.
bool inAttr = ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE;
ent = xmlGetDocEntity(ctxt->myDoc, name);
- if(ent)
+ if (ent)
ctxt->replaceEntities = inAttr || (ent->etype != XML_INTERNAL_GENERAL_ENTITY);
return ent;
}
+static void internalSubsetHandler(void *closure, const xmlChar *name, const xmlChar *externalID, const xmlChar *systemID)
+{
+ getTokenizer(closure)->internalSubset(name, externalID, systemID);
+ xmlSAX2InternalSubset(closure, name, externalID, systemID);
+}
+
void XMLTokenizer::finish()
{
xmlSAXHandler sax;
@@ -639,7 +642,7 @@
sax.endElementNs = endElementNsHandler;
sax.getEntity = getEntityHandler;
sax.startDocument = xmlSAX2StartDocument;
- sax.internalSubset = xmlSAX2InternalSubset;
+ sax.internalSubset = internalSubsetHandler;
sax.entityDecl = xmlSAX2EntityDecl;
sax.initialized = XML_SAX2_MAGIC;
1.58 +4 -0 LayoutTests/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/LayoutTests/ChangeLog,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- ChangeLog 26 Oct 2005 06:05:07 -0000 1.57
+++ ChangeLog 26 Oct 2005 06:10:11 -0000 1.58
@@ -1,3 +1,7 @@
+2005-10-25 Darin Adler <darin at apple.com>
+
+ * dom/xhtml/level1/core/hc_documentgetdoctype-expected.txt: Expect success.
+
2005-10-25 Maciej Stachowiak <mjs at apple.com>
Update isSameNode results back, now that the fix is landed.
1.2 +1 -2 LayoutTests/dom/xhtml/level1/core/hc_documentgetdoctype-expected.txt
Index: hc_documentgetdoctype-expected.txt
===================================================================
RCS file: /cvs/root/LayoutTests/dom/xhtml/level1/core/hc_documentgetdoctype-expected.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hc_documentgetdoctype-expected.txt 26 Sep 2005 22:33:40 -0000 1.1
+++ hc_documentgetdoctype-expected.txt 26 Oct 2005 06:10:11 -0000 1.2
@@ -1,3 +1,2 @@
Test http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetdoctype
-Status failure
-Message nodeName: assertEquals failed, actual null, expected html.
+Status Success
More information about the webkit-changes
mailing list