[webkit-changes] cvs commit: WebCore/layout-tests/fast/parser area-in-div-expected.txt area-in-div.html

Darin darin at opensource.apple.com
Sat Sep 10 14:03:45 PDT 2005


darin       05/09/10 14:03:45

  Modified:    .        ChangeLog
               khtml/html htmlparser.cpp htmlparser.h
  Added:       layout-tests/fast/parser area-in-div-expected.txt
                        area-in-div.html
  Log:
          Reviewed by Maciej.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4806
            REGRESSION <area> elements misnested inside <div> elements not working
  
          Test cases added:
          * layout-tests/fast/parser/area-in-div.html: Added.
          * layout-tests/fast/parser/area-in-div-expected.txt: Added.
  
          * khtml/html/htmlparser.h: Declared mapCreateErrorCheck.
          * khtml/html/htmlparser.cpp:
          (HTMLParser::handleError): Fix formatting and indentation.
          (HTMLParser::formCreateErrorCheck): Added code to create the form too, so we can
          squirrel the form pointer away. Return false to prevent the factory from creating it.
          (HTMLParser::mapCreateErrorCheck): Added. Same kind of thing here, but without the logic
          that prevents creating a form if there's already a form open.
          (HTMLParser::getNode): Added the code to put the map function into the table. Also
          removed the form special-case code here that accomplishes what is now done inside the
          formCreateErrorCheck above instead.
  
  Revision  Changes    Path
  1.112     +22 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- ChangeLog	10 Sep 2005 20:47:13 -0000	1.111
  +++ ChangeLog	10 Sep 2005 21:03:42 -0000	1.112
  @@ -2,6 +2,28 @@
   
           Reviewed by Maciej.
   
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4806
  +          REGRESSION <area> elements misnested inside <div> elements not working
  +
  +        Test cases added:
  +        * layout-tests/fast/parser/area-in-div.html: Added.
  +        * layout-tests/fast/parser/area-in-div-expected.txt: Added.
  +
  +        * khtml/html/htmlparser.h: Declared mapCreateErrorCheck.
  +        * khtml/html/htmlparser.cpp:
  +        (HTMLParser::handleError): Fix formatting and indentation.
  +        (HTMLParser::formCreateErrorCheck): Added code to create the form too, so we can
  +        squirrel the form pointer away. Return false to prevent the factory from creating it.
  +        (HTMLParser::mapCreateErrorCheck): Added. Same kind of thing here, but without the logic
  +        that prevents creating a form if there's already a form open.
  +        (HTMLParser::getNode): Added the code to put the map function into the table. Also
  +        removed the form special-case code here that accomplishes what is now done inside the
  +        formCreateErrorCheck above instead.
  +
  +2005-09-10  Darin Adler  <darin at apple.com>
  +
  +        Reviewed by Maciej.
  +
           - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4367
             Crash when executing setTimeout / Date / document.write Javascript (bugtraq)
   
  
  
  
  1.111     +29 -27    WebCore/khtml/html/htmlparser.cpp
  
  Index: htmlparser.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/htmlparser.cpp,v
  retrieving revision 1.110
  retrieving revision 1.111
  diff -u -r1.110 -r1.111
  --- htmlparser.cpp	1 Sep 2005 23:40:35 -0000	1.110
  +++ htmlparser.cpp	10 Sep 2005 21:03:44 -0000	1.111
  @@ -318,8 +318,7 @@
               return false;
       } else if (n->isHTMLElement()) {
           HTMLElementImpl* h = static_cast<HTMLElementImpl*>(n);
  -        if (h->hasLocalName(trTag) || h->hasLocalName(thTag) ||
  -            h->hasLocalName(tdTag)) {
  +        if (h->hasLocalName(trTag) || h->hasLocalName(thTag) || h->hasLocalName(tdTag)) {
               if (inStrayTableContent && !isTableRelated(current)) {
                   // pop out to the nearest enclosing table-related tag.
                   while (blockStack && !isTableRelated(current))
  @@ -416,10 +415,9 @@
                   if (!n->attached() && HTMLWidget)
                       n->attach();
                   handled = true;
  +                return true;
               }
  -            else
  -                return false;
  -            return true;
  +            return false;
           } else if (h->hasLocalName(captionTag)) {
               if (isTablePart(current)) {
                   NodeImpl* tsection = current;
  @@ -468,13 +466,13 @@
                       TextImpl *t = static_cast<TextImpl *>(n);
                       if (t->containsOnlyWhitespace())
                           return false;
  -				}
  -				if (!haveFrameSet) {
  -					e = new HTMLBodyElementImpl(document);
  -					startBody();
  -					insertNode(e);
  -					handled = true;
  -				}
  +                }
  +                if (!haveFrameSet) {
  +                    e = new HTMLBodyElementImpl(document);
  +                    startBody();
  +                    insertNode(e);
  +                    handled = true;
  +                }
               }
           } else if (h->hasLocalName(headTag)) {
               if (n->hasTagName(htmlTag))
  @@ -553,8 +551,7 @@
                       }
                   }
               }
  -        }
  -        else if (h->hasLocalName(objectTag)) {
  +        } else if (h->hasLocalName(objectTag)) {
               setSkipMode(objectTag);
               return false;
           } else if (h->hasLocalName(ulTag) || h->hasLocalName(olTag) ||
  @@ -577,8 +574,7 @@
               if (localName == optgroupTag) {
                   popBlock(currentTagName);
                   handled = true;
  -            }
  -            else if (localName == selectTag) {
  +            } else if (localName == selectTag) {
                   // IE treats a nested select as </select>. Let's do the same
                   popBlock(localName);
               }
  @@ -599,8 +595,7 @@
                   handled = true;
               }
           }
  -    }
  -    else if (current->isDocumentNode()) {
  +    } else if (current->isDocumentNode()) {
           if (current->firstChild() == 0) {
               e = new HTMLHtmlElementImpl(document);
               insertNode(e);
  @@ -676,7 +671,11 @@
   {
       // Only create a new form if we're not already inside one.
       // This is consistent with other browsers' behavior.
  -    return !form;
  +    if (!form) {
  +        form = new HTMLFormElementImpl(document);
  +        result = form;
  +    }
  +    return false;
   }
   
   bool HTMLParser::isindexCreateErrorCheck(Token* t, NodeImpl*& result)
  @@ -759,6 +758,13 @@
       return true;
   }
   
  +bool HTMLParser::mapCreateErrorCheck(Token* t, NodeImpl*& result)
  +{
  +    map = new HTMLMapElementImpl(document);
  +    result = map;
  +    return false;
  +}
  +
   NodeImpl *HTMLParser::getNode(Token* t)
   {
       // Init our error handling table.
  @@ -796,19 +802,15 @@
           gFunctionMap.insert(noembedTag.localName().impl(), &HTMLParser::noembedCreateErrorCheck);
           gFunctionMap.insert(noframesTag.localName().impl(), &HTMLParser::noframesCreateErrorCheck);
           gFunctionMap.insert(noscriptTag.localName().impl(), &HTMLParser::noscriptCreateErrorCheck);
  +        gFunctionMap.insert(mapTag.localName().impl(), &HTMLParser::mapCreateErrorCheck);
       }
   
       bool proceed = true;
  -    NodeImpl* result = 0;
  -    CreateErrorCheckFunc errorCheckFunc = gFunctionMap.get(t->tagName.impl());
  -    if (errorCheckFunc)
  +    NodeImpl *result = 0;
  +    if (CreateErrorCheckFunc errorCheckFunc = gFunctionMap.get(t->tagName.impl()))
           proceed = (this->*(errorCheckFunc))(t, result);
  -
  -    if (proceed) {
  +    if (proceed)
           result = HTMLElementFactory::createHTMLElement(t->tagName, doc(), form);
  -        if (t->tagName == formTag)
  -            form = static_cast<HTMLFormElementImpl*>(result);
  -    }
       return result;
   }
   
  
  
  
  1.29      +2 -3      WebCore/khtml/html/htmlparser.h
  
  Index: htmlparser.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/htmlparser.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- htmlparser.h	9 Jul 2005 20:19:11 -0000	1.28
  +++ htmlparser.h	10 Sep 2005 21:03:44 -0000	1.29
  @@ -29,8 +29,6 @@
   #ifndef HTMLPARSER_H
   #define HTMLPARSER_H
   
  -#include "dom/dom_string.h"
  -#include "xml/dom_nodeimpl.h"
   #include "html/html_documentimpl.h"
   
   class KHTMLView;
  @@ -49,7 +47,7 @@
   
   namespace khtml {
       class Token;
  -};
  +}
   
   /**
    * The parser for html. It receives a stream of tokens from the HTMLTokenizer, and
  @@ -114,6 +112,7 @@
       bool noscriptCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&);
       bool noframesCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&);
       bool nolayerCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&);
  +    bool mapCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&);
   
       void processCloseTag(khtml::Token *);
   
  
  
  
  1.1                  WebCore/layout-tests/fast/parser/area-in-div-expected.txt
  
  Index: area-in-div-expected.txt
  ===================================================================
  This tests that an <area> element can be created even if it's not properly nested just inside a <map> element.
  
  Test result: success
  
  
  
  
  
  1.1                  WebCore/layout-tests/fast/parser/area-in-div.html
  
  Index: area-in-div.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  <HTML><HEAD><TITLE>AREA inside DIV</TITLE></HEAD>
  <BODY>
  <!-- intentionally invalid -->
  <MAP name="m">
  <div>
  <AREA id="a" alt="">
  </div>
  </MAP>
  <p>This tests that an &lt;area&gt; element can be created even if it's not properly nested
  just inside a &lt;map&gt; element.</p>
  <p>Test result: 
  <SCRIPT type="text/javascript">
  if (window.layoutTestController)
      layoutTestController.dumpAsText();
  if (document.getElementById('a'))
      document.write("success");
  else
      document.write("failure");
  </SCRIPT>
  </p>
  </BODY></HTML>
  
  
  



More information about the webkit-changes mailing list