[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:16:17 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 31f0f17a114e8c94a4cf7663033e15f9aad816fc
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 4 19:45:42 2003 +0000

            Reviewed by John.
    
            - fixed 3498712: REGRESSION (100-115): Safari aborts at http://www11.dht.dk/~blangstrup_org/
    
            This was an uncaught exception thrown by DocumentImpl. But the design of KHTML DOM is that
            "impl" classes return exception codes; they don't throw exceptions.
    
            * khtml/dom/dom_doc.cpp:
            (DOM::Document::createElement): Throw exception if necessary. The impl function now returns
            an exception code.
            (DOM::Document::createElementNS): Ditto.
    
            * khtml/html/html_documentimpl.h: Add exception code parameter to createElement.
            * khtml/html/html_documentimpl.cpp: (HTMLDocumentImpl::createElement): Pass along the
            exception code from the lower level.
    
            * khtml/xml/dom_docimpl.h: Add exception code parameters to createElement, createElementNS,
            and createHTMLElement.
            * khtml/xml/dom_docimpl.cpp:
            (DOMImplementationImpl::createDocument): Handle exception code from createElementNS.
            (DocumentImpl::createElement): Add exception code parameter, not set since there is
            no exception.
            (DocumentImpl::importNode): Handle exception code from createElementNS.
            (DocumentImpl::createElementNS): Add exception code parameter. Propagate the exception
            codes that we get from createHTMLElement and setPrefix.
            (DocumentImpl::createHTMLElement): Add exception code parameter. Use an exception code
            rather than a C++ exception for INVALID_CHARACTER_ERR.
    
            * khtml/xml/dom_elementimpl.cpp: (ElementImpl::cloneNode): Pass exception code parameter to
            createElement.
    
            * khtml/xml/xml_tokenizer.cpp:
            (XMLHandler::startElement): Pass exception code parameter to createElementNS, and return false
            if it is not zero. This is where the bug happened. Before we would get an exception from
            createElementNS, but "impl" functions are not supposed to throw in KHTML's DOM.
            (XMLTokenizer::finish): Add various exception code parameters to compile, but we know we won't
            get any exceptions.
    
            * kwq/WebCoreDOMDocument.mm:
            (-[WebCoreDOMDocument createElement:]): Pass an (ignored) exception code parameter.
            (-[WebCoreDOMDocument createElementNS::]): Pass an (ignored) exception code parameter.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5694 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 33c02a7..ff6dc45 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,47 @@
+2003-12-04  Darin Adler  <darin at apple.com>
+
+        Reviewed by John.
+
+        - fixed 3498712: REGRESSION (100-115): Safari aborts at http://www11.dht.dk/~blangstrup_org/
+
+        This was an uncaught exception thrown by DocumentImpl. But the design of KHTML DOM is that
+        "impl" classes return exception codes; they don't throw exceptions.
+
+        * khtml/dom/dom_doc.cpp:
+        (DOM::Document::createElement): Throw exception if necessary. The impl function now returns
+        an exception code.
+        (DOM::Document::createElementNS): Ditto.
+
+        * khtml/html/html_documentimpl.h: Add exception code parameter to createElement.
+        * khtml/html/html_documentimpl.cpp: (HTMLDocumentImpl::createElement): Pass along the
+        exception code from the lower level.
+
+        * khtml/xml/dom_docimpl.h: Add exception code parameters to createElement, createElementNS,
+        and createHTMLElement.
+        * khtml/xml/dom_docimpl.cpp:
+        (DOMImplementationImpl::createDocument): Handle exception code from createElementNS.
+        (DocumentImpl::createElement): Add exception code parameter, not set since there is
+        no exception.
+        (DocumentImpl::importNode): Handle exception code from createElementNS.
+        (DocumentImpl::createElementNS): Add exception code parameter. Propagate the exception
+        codes that we get from createHTMLElement and setPrefix.
+        (DocumentImpl::createHTMLElement): Add exception code parameter. Use an exception code
+        rather than a C++ exception for INVALID_CHARACTER_ERR.
+
+        * khtml/xml/dom_elementimpl.cpp: (ElementImpl::cloneNode): Pass exception code parameter to
+        createElement.
+
+        * khtml/xml/xml_tokenizer.cpp:
+        (XMLHandler::startElement): Pass exception code parameter to createElementNS, and return false
+        if it is not zero. This is where the bug happened. Before we would get an exception from
+        createElementNS, but "impl" functions are not supposed to throw in KHTML's DOM.
+        (XMLTokenizer::finish): Add various exception code parameters to compile, but we know we won't
+        get any exceptions.
+
+        * kwq/WebCoreDOMDocument.mm:
+        (-[WebCoreDOMDocument createElement:]): Pass an (ignored) exception code parameter.
+        (-[WebCoreDOMDocument createElementNS::]): Pass an (ignored) exception code parameter.
+
 === Safari-116 ===
 
 2003-12-03  Richard Williamson   <rjw at apple.com>
diff --git a/WebCore/khtml/dom/dom_doc.cpp b/WebCore/khtml/dom/dom_doc.cpp
index 431377b..356c2cc 100644
--- a/WebCore/khtml/dom/dom_doc.cpp
+++ b/WebCore/khtml/dom/dom_doc.cpp
@@ -234,14 +234,24 @@ Element Document::documentElement() const
 
 Element Document::createElement( const DOMString &tagName )
 {
-    if (impl) return ((DocumentImpl *)impl)->createElement(tagName);
-    return 0;
+    if (!impl) return 0;
+    int exceptioncode = 0;
+    ElementImpl *e = ((DocumentImpl *)impl)->createElement(tagName, exceptioncode);
+    if (exceptioncode) {
+        throw DOMException(exceptioncode);
+    }
+    return e;
 }
 
 Element Document::createElementNS( const DOMString &namespaceURI, const DOMString &qualifiedName )
 {
-    if (impl) return ((DocumentImpl *)impl)->createElementNS(namespaceURI,qualifiedName);
-    return 0;
+    if (!impl) return 0;
+    int exceptioncode = 0;
+    ElementImpl *e = ((DocumentImpl *)impl)->createElementNS(namespaceURI, qualifiedName, exceptioncode);
+    if (exceptioncode) {
+        throw DOMException(exceptioncode);
+    }
+    return e;
 }
 
 DocumentFragment Document::createDocumentFragment(  )
diff --git a/WebCore/khtml/html/html_documentimpl.cpp b/WebCore/khtml/html/html_documentimpl.cpp
index 5e74191..7347a93 100644
--- a/WebCore/khtml/html/html_documentimpl.cpp
+++ b/WebCore/khtml/html/html_documentimpl.cpp
@@ -273,9 +273,9 @@ bool HTMLDocumentImpl::childAllowed( NodeImpl *newChild )
     return (newChild->id() == ID_HTML || newChild->id() == ID_COMMENT);
 }
 
-ElementImpl *HTMLDocumentImpl::createElement( const DOMString &name )
+ElementImpl *HTMLDocumentImpl::createElement( const DOMString &name, int &exceptioncode )
 {
-    return createHTMLElement(name);
+    return createHTMLElement(name, exceptioncode);
 }
 
 void HTMLDocumentImpl::slotHistoryChanged()
diff --git a/WebCore/khtml/html/html_documentimpl.h b/WebCore/khtml/html/html_documentimpl.h
index cf696d1..e8317a4 100644
--- a/WebCore/khtml/html/html_documentimpl.h
+++ b/WebCore/khtml/html/html_documentimpl.h
@@ -73,7 +73,7 @@ public:
 
     virtual bool childAllowed( NodeImpl *newChild );
 
-    virtual ElementImpl *createElement ( const DOMString &tagName );
+    virtual ElementImpl *createElement ( const DOMString &tagName, int &exceptioncode );
 
     HTMLMapElementImpl* getMap(const DOMString& url_);
 
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 17b821d..e4f2fa4 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -185,8 +185,9 @@ DocumentImpl *DOMImplementationImpl::createDocument( const DOMString &namespaceU
     if (doc->doctype() && dtype)
         doc->doctype()->copyFrom(*dtype);
 
-    ElementImpl *element = doc->createElementNS(namespaceURI,qualifiedName);
-    doc->appendChild(element,exceptioncode);
+    ElementImpl *element = doc->createElementNS(namespaceURI,qualifiedName,exceptioncode);
+    if (element)
+        doc->appendChild(element,exceptioncode);
     if (exceptioncode) {
         delete element;
         delete doc;
@@ -396,7 +397,7 @@ ElementImpl *DocumentImpl::documentElement() const
     return static_cast<ElementImpl*>(n);
 }
 
-ElementImpl *DocumentImpl::createElement( const DOMString &name )
+ElementImpl *DocumentImpl::createElement( const DOMString &name, int &exceptioncode )
 {
     return new XMLElementImpl( document, name.implementation() );
 }
@@ -442,7 +443,9 @@ NodeImpl *DocumentImpl::importNode(NodeImpl *importedNode, bool deep, int &excep
 
 	if(importedNode->nodeType() == Node::ELEMENT_NODE)
 	{
-		ElementImpl *tempElementImpl = createElementNS(getDocument()->namespaceURI(id()), importedNode->nodeName());
+		ElementImpl *tempElementImpl = createElementNS(getDocument()->namespaceURI(id()), importedNode->nodeName(), exceptioncode);
+                if (exceptioncode)
+                    return 0;
 		result = tempElementImpl;
 
 		if(static_cast<ElementImpl *>(importedNode)->attributes(true) && static_cast<ElementImpl *>(importedNode)->attributes(true)->length())
@@ -504,7 +507,7 @@ NodeImpl *DocumentImpl::importNode(NodeImpl *importedNode, bool deep, int &excep
 	return result;
 }
 
-ElementImpl *DocumentImpl::createElementNS( const DOMString &_namespaceURI, const DOMString &_qualifiedName )
+ElementImpl *DocumentImpl::createElementNS( const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode)
 {
     ElementImpl *e = 0;
     QString qName = _qualifiedName.string();
@@ -514,10 +517,16 @@ ElementImpl *DocumentImpl::createElementNS( const DOMString &_namespaceURI, cons
         _namespaceURI == XHTML_NAMESPACE) {
         // User requested an element in the XHTML namespace - this means we create a HTML element
         // (elements not in this namespace are treated as normal XML elements)
-        e = createHTMLElement(qName.mid(colonPos+1));
-        int exceptioncode = 0;
-        if (e && colonPos >= 0)
-            e->setPrefix(qName.left(colonPos),  exceptioncode);
+        e = createHTMLElement(qName.mid(colonPos+1), exceptioncode);
+        if (exceptioncode)
+            return 0;
+        if (e && colonPos >= 0) {
+            e->setPrefix(qName.left(colonPos), exceptioncode);
+            if (exceptioncode) {
+                delete e;
+                return 0;
+            }
+        }
     }
     if (!e)
         e = new XMLElementImpl( document, _qualifiedName.implementation(), _namespaceURI.implementation() );
@@ -621,9 +630,12 @@ unsigned short DocumentImpl::nodeType() const
     return Node::DOCUMENT_NODE;
 }
 
-ElementImpl *DocumentImpl::createHTMLElement( const DOMString &name )
+ElementImpl *DocumentImpl::createHTMLElement( const DOMString &name, int &exceptioncode )
 {
-    if (!isValidName(name)) throw DOMException(DOMException::INVALID_CHARACTER_ERR);
+    if (!isValidName(name)) {
+        exceptioncode = DOMException::INVALID_CHARACTER_ERR;
+        return 0;
+    }
 
     uint id = khtml::getTagID( name.string().lower().latin1(), name.string().length() );
 
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 56ac02b..d270f2c 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -147,7 +147,7 @@ public:
 
     DOMImplementationImpl *implementation() const;
     ElementImpl *documentElement() const;
-    virtual ElementImpl *createElement ( const DOMString &tagName );
+    virtual ElementImpl *createElement ( const DOMString &tagName, int &exceptioncode );
     DocumentFragmentImpl *createDocumentFragment ();
     TextImpl *createTextNode ( const DOMString &data );
     CommentImpl *createComment ( const DOMString &data );
@@ -156,7 +156,7 @@ public:
     Attr createAttribute(NodeImpl::Id id);
     EntityReferenceImpl *createEntityReference ( const DOMString &name );
     NodeImpl *importNode( NodeImpl *importedNode, bool deep, int &exceptioncode );
-    virtual ElementImpl *createElementNS ( const DOMString &_namespaceURI, const DOMString &_qualifiedName );
+    virtual ElementImpl *createElementNS ( const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode );
     ElementImpl *getElementById ( const DOMString &elementId ) const;
 
     // Actually part of HTMLDocument, but used for giving XML documents a window title as well
@@ -172,7 +172,7 @@ public:
     virtual bool isDocumentNode() const { return true; }
     virtual bool isHTMLDocument() const { return false; }
 
-    virtual ElementImpl *createHTMLElement ( const DOMString &tagName );
+    virtual ElementImpl *createHTMLElement ( const DOMString &tagName, int &exceptioncode );
 
     khtml::CSSStyleSelector *styleSelector() { return m_styleSelector; }
 
diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp
index 67f6ef2..2118834 100644
--- a/WebCore/khtml/xml/dom_elementimpl.cpp
+++ b/WebCore/khtml/xml/dom_elementimpl.cpp
@@ -294,7 +294,8 @@ void ElementImpl::setAttributeMap( NamedAttrMapImpl* list )
 NodeImpl *ElementImpl::cloneNode(bool deep)
 {
     // ### we loose the namespace here ... FIXME
-    ElementImpl *clone = getDocument()->createElement(tagName());
+    int exceptioncode;
+    ElementImpl *clone = getDocument()->createElement(tagName(), exceptioncode);
     if (!clone) return 0;
 
     // clone attributes
diff --git a/WebCore/khtml/xml/xml_tokenizer.cpp b/WebCore/khtml/xml/xml_tokenizer.cpp
index 727b89b..7abc4ec 100644
--- a/WebCore/khtml/xml/xml_tokenizer.cpp
+++ b/WebCore/khtml/xml/xml_tokenizer.cpp
@@ -77,12 +77,13 @@ bool XMLHandler::startElement( const QString& namespaceURI, const QString& /*loc
     if (m_currentNode->nodeType() == Node::TEXT_NODE)
         exitText();
 
-    ElementImpl *newElement;
-    newElement = m_doc->document()->createElementNS(namespaceURI,qName);
+    int exceptioncode = 0;
+    ElementImpl *newElement = m_doc->document()->createElementNS(namespaceURI,qName,exceptioncode);
+    if (!newElement)
+        return false;
 
     int i;
     for (i = 0; i < atts.length(); i++) {
-        int exceptioncode = 0;
         DOMString uri(atts.uri(i));
         DOMString ln(atts.localName(i));
         DOMString val(atts.value(i));
@@ -376,9 +377,9 @@ void XMLTokenizer::finish()
 
         // Create elements for display
         DocumentImpl *doc = m_doc->document();
-        NodeImpl *html = doc->createElementNS(XHTML_NAMESPACE,"html");
-        NodeImpl   *body = doc->createElementNS(XHTML_NAMESPACE,"body");
-        NodeImpl     *h1 = doc->createElementNS(XHTML_NAMESPACE,"h1");
+        NodeImpl *html = doc->createElementNS(XHTML_NAMESPACE,"html",exceptioncode);
+        NodeImpl   *body = doc->createElementNS(XHTML_NAMESPACE,"body",exceptioncode);
+        NodeImpl     *h1 = doc->createElementNS(XHTML_NAMESPACE,"h1",exceptioncode);
 #if APPLE_CHANGES
         // FIXME: Is there some alternative to having this text hardcoded here?
         NodeImpl       *headingText = doc->createTextNode("XML parsing error");
@@ -391,8 +392,8 @@ void XMLTokenizer::finish()
         NodeImpl       *lineText = 0;
         NodeImpl       *errorLocText = 0;
         if (!line.isNull()) {
-                      hr = doc->createElementNS(XHTML_NAMESPACE,"hr");
-                      pre = doc->createElementNS(XHTML_NAMESPACE,"pre");
+                      hr = doc->createElementNS(XHTML_NAMESPACE,"hr",exceptioncode);
+                      pre = doc->createElementNS(XHTML_NAMESPACE,"pre",exceptioncode);
                         lineText = doc->createTextNode(line+"\n");
                         errorLocText = doc->createTextNode(errorLocPtr);
         }
diff --git a/WebCore/kwq/WebCoreDOMDocument.mm b/WebCore/kwq/WebCoreDOMDocument.mm
index 3366675..d626ad5 100644
--- a/WebCore/kwq/WebCoreDOMDocument.mm
+++ b/WebCore/kwq/WebCoreDOMDocument.mm
@@ -188,12 +188,14 @@ DOM::DOMString NSStringToDOMString(NSString *aString)
 
 - (id<WebDOMElement>)createElement:(NSString *)tagName
 {
-    return [WebCoreDOMElement elementWithImpl: [self documentImpl]->createElement(NSStringToDOMString(tagName))];
+    int exceptionCode;
+    return [WebCoreDOMElement elementWithImpl: [self documentImpl]->createElement(NSStringToDOMString(tagName), exceptionCode)];
 }
 
 - (id<WebDOMElement>)createElementNS:(NSString *)namespaceURI :(NSString *)qualifiedName
 {
-    return [WebCoreDOMElement elementWithImpl: [self documentImpl]->createElementNS(NSStringToDOMString(namespaceURI),NSStringToDOMString(qualifiedName))];
+    int exceptionCode;
+    return [WebCoreDOMElement elementWithImpl: [self documentImpl]->createElementNS(NSStringToDOMString(namespaceURI), NSStringToDOMString(qualifiedName), exceptionCode)];
 }
 
 - (id<WebDOMDocumentFragment>)createDocumentFragment

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list