Changeset 21720 in webkit


Ignore:
Timestamp:
May 24, 2007 11:26:21 AM (17 years ago)
Author:
hyatt
Message:

Fix for <rdar://problem/5208440> (13753)

REGRESSION: Raw text needs to be pulled outside of tables

Reviewed by aroben

  • html/HTMLParser.cpp: (WebCore::HTMLParser::handleError):
  • html/HTMLTableColElement.cpp: (WebCore::HTMLTableColElement::checkDTD):
  • html/HTMLTableElement.cpp: (WebCore::HTMLTableElement::checkDTD):
  • html/HTMLTableRowElement.cpp: (WebCore::HTMLTableRowElement::checkDTD):
  • html/HTMLTableSectionElement.cpp: (WebCore::HTMLTableSectionElement::checkDTD):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r21719 r21720  
     12007-05-24  David Hyatt  <hyatt@apple.com>
     2
     3        Fix for <rdar://problem/5208440> (13753)
     4
     5        REGRESSION: Raw text needs to be pulled outside of tables
     6
     7        Reviewed by aroben
     8
     9        * html/HTMLParser.cpp:
     10        (WebCore::HTMLParser::handleError):
     11        * html/HTMLTableColElement.cpp:
     12        (WebCore::HTMLTableColElement::checkDTD):
     13        * html/HTMLTableElement.cpp:
     14        (WebCore::HTMLTableElement::checkDTD):
     15        * html/HTMLTableRowElement.cpp:
     16        (WebCore::HTMLTableRowElement::checkDTD):
     17        * html/HTMLTableSectionElement.cpp:
     18        (WebCore::HTMLTableSectionElement::checkDTD):
     19
    1202007-05-24  Mitz Pettel  <mitz@webkit.org>
    221
  • trunk/WebCore/html/HTMLParser.cpp

    r21706 r21720  
    493493                handled = true;      // ...and start a new one
    494494            } else {
    495                 bool possiblyMoveStrayContent = true;
    496495                ExceptionCode ec = 0;
    497                 if (n->isTextNode()) {
    498                     Text* t = static_cast<Text*>(n);
    499                     if (t->containsOnlyWhitespace())
    500                         return false;
    501                     StringImpl* i = t->string();
    502                     unsigned int pos = 0;
    503                     while (pos < i->length() && ((*i)[pos] == ' ' || (*i)[pos] == noBreakSpace))
    504                         pos++;
    505                     if (pos == i->length())
    506                         possiblyMoveStrayContent = false;
    507                 }
    508                 if (possiblyMoveStrayContent) {
    509                     Node* node = current;
     496                Node* node = current;
     497                Node* parent = node->parentNode();
     498                // A script may have removed the current node's parent from the DOM
     499                // http://bugs.webkit.org/show_bug.cgi?id=7137
     500                // FIXME: we should do real recovery here and re-parent with the correct node.
     501                if (!parent)
     502                    return false;
     503                Node* grandparent = parent->parentNode();
     504
     505                if (n->isTextNode() ||
     506                    (h->hasLocalName(trTag) &&
     507                     isTableSection(parent) && grandparent->hasTagName(tableTag)) ||
     508                     ((!n->hasTagName(tdTag) && !n->hasTagName(thTag) &&
     509                       !n->hasTagName(formTag) && !n->hasTagName(scriptTag)) && isTableSection(node) &&
     510                     parent->hasTagName(tableTag))) {
     511                    node = (node->hasTagName(tableTag)) ? node :
     512                            ((node->hasTagName(trTag)) ? grandparent : parent);
    510513                    Node* parent = node->parentNode();
    511                     // A script may have removed the current node's parent from the DOM
    512                     // http://bugs.webkit.org/show_bug.cgi?id=7137
    513                     // FIXME: we should do real recovery here and re-parent with the correct node.
    514514                    if (!parent)
    515515                        return false;
    516                     Node* grandparent = parent->parentNode();
    517 
    518                     if (n->isTextNode() ||
    519                         (h->hasLocalName(trTag) &&
    520                          isTableSection(parent) && grandparent->hasTagName(tableTag)) ||
    521                          ((!n->hasTagName(tdTag) && !n->hasTagName(thTag) &&
    522                            !n->hasTagName(formTag) && !n->hasTagName(scriptTag)) && isTableSection(node) &&
    523                          parent->hasTagName(tableTag))) {
    524                         node = (node->hasTagName(tableTag)) ? node :
    525                                 ((node->hasTagName(trTag)) ? grandparent : parent);
    526                         Node* parent = node->parentNode();
    527                         if (!parent)
    528                             return false;
    529                         parent->insertBefore(n, node, ec);
    530                         if (!ec) {
    531                             reportError(StrayTableContentError, &localName, &currentTagName);
    532                             if (n->isHTMLElement() && tagPriority > 0 &&
    533                                 !flat && static_cast<HTMLElement*>(n)->endTagRequirement() != TagStatusForbidden)
    534                             {
    535                                 pushBlock(localName, tagPriority);
    536                                 setCurrent(n);
    537                                 inStrayTableContent++;
    538                                 blockStack->strayTableContent = true;
    539                             }
    540                             return true;
     516                    parent->insertBefore(n, node, ec);
     517                    if (!ec) {
     518                        reportError(StrayTableContentError, &localName, &currentTagName);
     519                        if (n->isHTMLElement() && tagPriority > 0 &&
     520                            !flat && static_cast<HTMLElement*>(n)->endTagRequirement() != TagStatusForbidden)
     521                        {
     522                            pushBlock(localName, tagPriority);
     523                            setCurrent(n);
     524                            inStrayTableContent++;
     525                            blockStack->strayTableContent = true;
    541526                        }
     527                        return true;
    542528                    }
    543 
    544                     if (!ec) {
    545                         if (current->hasTagName(trTag)) {
    546                             reportError(TablePartRequiredError, &localName, &tdTag.localName());
    547                             e = new HTMLTableCellElement(tdTag, document);
    548                         } else if (current->hasTagName(tableTag)) {
    549                             // Don't report an error in this case, since making a <tbody> happens all the time when you have <table><tr>,
    550                             // and it isn't really a parse error per se.
    551                             e = new HTMLTableSectionElement(tbodyTag, document);
    552                         } else {
    553                             reportError(TablePartRequiredError, &localName, &trTag.localName());
    554                             e = new HTMLTableRowElement(document);
    555                         }
    556 
    557                         insertNode(e);
    558                         handled = true;
     529                }
     530
     531                if (!ec) {
     532                    if (current->hasTagName(trTag)) {
     533                        reportError(TablePartRequiredError, &localName, &tdTag.localName());
     534                        e = new HTMLTableCellElement(tdTag, document);
     535                    } else if (current->hasTagName(tableTag)) {
     536                        // Don't report an error in this case, since making a <tbody> happens all the time when you have <table><tr>,
     537                        // and it isn't really a parse error per se.
     538                        e = new HTMLTableSectionElement(tbodyTag, document);
     539                    } else {
     540                        reportError(TablePartRequiredError, &localName, &trTag.localName());
     541                        e = new HTMLTableRowElement(document);
    559542                    }
     543
     544                    insertNode(e);
     545                    handled = true;
    560546                }
    561547            }
     
    578564            }
    579565        } else if (h->hasLocalName(colgroupTag)) {
    580             if (!n->isTextNode()) {
    581                 popBlock(currentTagName);
    582                 handled = true;
    583             }
     566            popBlock(currentTagName);
     567            handled = true;
    584568        } else if (!h->hasLocalName(bodyTag)) {
    585569            if (isInline(current)) {
  • trunk/WebCore/html/HTMLTableColElement.cpp

    r21615 r21720  
    3131#include "RenderTableCol.h"
    3232#include "HTMLTableElement.h"
     33#include "Text.h"
    3334
    3435namespace WebCore {
     
    5455bool HTMLTableColElement::checkDTD(const Node* newChild)
    5556{
    56     return hasLocalName(colgroupTag) && newChild->hasTagName(colTag);
     57    if (hasLocalName(colTag))
     58        return false;
     59   
     60    if (newChild->isTextNode())
     61        return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
     62    return newChild->hasTagName(colTag);
    5763}
    5864
  • trunk/WebCore/html/HTMLTableElement.cpp

    r21614 r21720  
    3838#include "HTMLTableSectionElement.h"
    3939#include "RenderTable.h"
     40#include "Text.h"
    4041
    4142namespace WebCore {
     
    6566bool HTMLTableElement::checkDTD(const Node* newChild)
    6667{
    67     return newChild->isTextNode() || newChild->hasTagName(captionTag) ||
     68    if (newChild->isTextNode())
     69        return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
     70    return newChild->hasTagName(captionTag) ||
    6871           newChild->hasTagName(colTag) || newChild->hasTagName(colgroupTag) ||
    6972           newChild->hasTagName(theadTag) || newChild->hasTagName(tfootTag) ||
  • trunk/WebCore/html/HTMLTableRowElement.cpp

    r21698 r21720  
    3434#include "HTMLTableSectionElement.h"
    3535#include "NodeList.h"
     36#include "Text.h"
    3637
    3738namespace WebCore {
     
    4647bool HTMLTableRowElement::checkDTD(const Node* newChild)
    4748{
     49    if (newChild->isTextNode())
     50        return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    4851    return newChild->hasTagName(tdTag) || newChild->hasTagName(thTag) ||
    4952           newChild->hasTagName(formTag) || newChild->hasTagName(scriptTag);
  • trunk/WebCore/html/HTMLTableSectionElement.cpp

    r21698 r21720  
    3333#include "HTMLTableElement.h"
    3434#include "NodeList.h"
     35#include "Text.h"
    3536
    3637namespace WebCore {
     
    4546bool HTMLTableSectionElement::checkDTD(const Node* newChild)
    4647{
     48    if (newChild->isTextNode())
     49        return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
    4750    return newChild->hasTagName(trTag) || newChild->hasTagName(formTag) ||
    4851           newChild->hasTagName(scriptTag);
Note: See TracChangeset for help on using the changeset viewer.