ChangeLog
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Sep 2004 00:57:52 +0000 (00:57 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Sep 2004 00:57:52 +0000 (00:57 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7701 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/khtml/html/htmlparser.cpp
WebCore/khtml/html/htmlparser.h

index 3f9cf85dc32206e47190686ded5a6302ae482d53..e0af105cd89e911e5d0f77ce2ab57ba903f91686 100644 (file)
@@ -253,6 +253,10 @@ void KHTMLParser::parseToken(Token *t)
         // take care of optional close tags
         if(endTag[e->id()] == DOM::OPTIONAL)
             popBlock(t->id);
+            
+        if (isHeaderTag(t->id))
+            // Do not allow two header tags to be nested if the intervening tags are inlines.
+            popNestedHeaderTag();
     }
 
     // if this tag is forbidden inside the current context, pop
@@ -1199,6 +1203,36 @@ void KHTMLParser::processCloseTag(Token *t)
 #endif
 }
 
+bool KHTMLParser::isHeaderTag(int _id)
+{
+    switch (_id) {
+        case ID_H1:
+        case ID_H2:
+        case ID_H3:
+        case ID_H4:
+        case ID_H5:
+        case ID_H6:
+            return true;
+        default:
+            return false;
+    }
+}
+
+void KHTMLParser::popNestedHeaderTag()
+{
+    // This function only cares about checking for nested headers that have only inlines in between them.
+    NodeImpl* currNode = current;
+    for (HTMLStackElem* curr = blockStack; curr; curr = curr->next) {
+        if (isHeaderTag(curr->id)) {
+            popBlock(curr->id);
+            return;
+        }
+        if (currNode && !currNode->isInline())
+            return;
+        currNode = curr->node;
+    }
+}
+
 bool KHTMLParser::isResidualStyleTag(int _id)
 {
     switch (_id) {
index 40ae3e4f7223afab0c287a5d60a16fd585d81d1c..31eb450bf6f37e15c45f66dfa8710d81077dcea8 100644 (file)
@@ -135,6 +135,9 @@ protected:
 
     bool allowNestedRedundantTag(int _id);
     
+    static bool isHeaderTag(int _id);
+    void popNestedHeaderTag();
+
     ushort *forbiddenTag;
     
     /*