[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdewebdev/quanta
From:       Paulo Moura Guedes <moura () kdewebdev ! org>
Date:       2005-03-29 22:18:36
Message-ID: 20050329221836.8CADF484 () office ! kde ! org
[Download RAW message or body]

CVS commit by mojo: 

Don't insert KHTML DOM nodes from Quanta empty nodes, if DTD not allows it. 
Thanks to Leo for the tip and to Gour for sending me the output of the diff added to \
#99826.

Can #99826 people confirm me if this fixes the bug?

CCBUG: 99826
CCMAIL: Leo Savernik <l.savernik@aon.at>, quanta-devel@kde.org, carlo@gentoo.org


  M +10 -3     parsers/qtag.cpp   1.23
  M +1 -1      parsers/qtag.h   1.66
  M +18 -8     parts/kafka/wkafkapart.cpp   1.96


--- kdewebdev/quanta/parsers/qtag.cpp  #1.22:1.23
@@ -211,5 +211,5 @@ bool QTag::isChild(const QString& tag, b
 }
 
-bool QTag::isChild(Node *node, bool trueIfNoChildsDefined)
+bool QTag::isChild(Node *node, bool trueIfNoChildsDefined, bool \
treatEmptyNodesAsText)  {
   QString nodeName;
@@ -224,6 +224,13 @@ bool QTag::isChild(Node *node, bool true
       return(!childTags.isEmpty() && (childTags.contains("#text") || \
childTags.contains("#TEXT")));  }
-  else if(node->tag->type == Tag::Empty)
+  else if(node->tag->type == Tag::Empty && !treatEmptyNodesAsText)
     return true;
+  else if(node->tag->type == Tag::Empty && treatEmptyNodesAsText)
+  {
+      if(trueIfNoChildsDefined)
+          return(childTags.isEmpty() || childTags.contains("#text") || \
childTags.contains("#TEXT")); +      else
+          return(!childTags.isEmpty() && (childTags.contains("#text") || \
childTags.contains("#TEXT")));       +  }
   else if(node->tag->type == Tag::XmlTagEnd)
   {

--- kdewebdev/quanta/parsers/qtag.h  #1.65:1.66
@@ -236,5 +236,5 @@ public:
   bool isChild(const QString& tag, bool trueIfNoChildsDefined = true);
   //prefer using this variant, it handle Text, Empty, XmlTagEnd nodes!
-  bool isChild(Node *node, bool trueIfNoChildsDefined = true);
+  bool isChild(Node *node, bool trueIfNoChildsDefined = true, bool \
treatEmptyNodesAsText = false);  /*** Returns the list of parent of this tag. */
   QPtrList<QTag> parents();

--- kdewebdev/quanta/parts/kafka/wkafkapart.cpp  #1.95:1.96
@@ -349,4 +349,6 @@ kNodeAttrs* KafkaDocument::connectDomNod
                 name = domNode.nodeName().string().lower();
 
+    kdDebug(23100) << "KafkaDocument::connectDomNodeToQuantaNode() - domNode name: \
|" << name << "|" << endl; +
         props = new kNodeAttrs();
 
@@ -500,14 +502,22 @@ bool KafkaDocument::buildKafkaNodeFromNo
         int i;
 
-//     This is a hack to not created DOM::Nodes from quanta empty nodes if outside \
                body, because KHTML
-//     moves a node in that condition into the body and then the trees become \
                desynchronized.
-    bool isInsideBody = false;
+//     Don't create DOM::Nodes from Quanta empty nodes outside the body or inside \
other not allowed element, or KHTML +//     will give us problems.
+    bool canInsertEmptyNode = false;
+    if(node->tag->type == Tag::Empty)
+    {
     if(!m_currentDoc->defaultDTD()->name.contains("HTML", false))
-        isInsideBody = true;
+            canInsertEmptyNode = true;
     else
-        isInsideBody = kafkaCommon::hasParent(node, "body");
+            canInsertEmptyNode = kafkaCommon::hasParent(node, "body");
+        
+        Node* parent_node = node->parent;
+        QTag* parent_node_description_tag = QuantaCommon::tagFromDTD(parent_node);
+        if(parent_node_description_tag && \
!parent_node_description_tag->isChild(node, true, true)) +            \
canInsertEmptyNode = false; +    }
     
     if(node->tag->type == Tag::XmlTag || 
-       ((node->tag->type == Tag::Text || (node->tag->type == Tag::Empty && \
isInsideBody)) && !node->insideSpecial)) +       ((node->tag->type == Tag::Text || \
(node->tag->type == Tag::Empty && canInsertEmptyNode)) && !node->insideSpecial))  {
                 str = node->tag->name.lower();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic