Changeset 21720 in webkit
- Timestamp:
- May 24, 2007 11:26:21 AM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r21719 r21720 1 2007-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 1 20 2007-05-24 Mitz Pettel <mitz@webkit.org> 2 21 -
trunk/WebCore/html/HTMLParser.cpp
r21706 r21720 493 493 handled = true; // ...and start a new one 494 494 } else { 495 bool possiblyMoveStrayContent = true;496 495 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); 510 513 Node* parent = node->parentNode(); 511 // A script may have removed the current node's parent from the DOM512 // http://bugs.webkit.org/show_bug.cgi?id=7137513 // FIXME: we should do real recovery here and re-parent with the correct node.514 514 if (!parent) 515 515 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, ¤tTagName); 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, ¤tTagName); 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; 541 526 } 527 return true; 542 528 } 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); 559 542 } 543 544 insertNode(e); 545 handled = true; 560 546 } 561 547 } … … 578 564 } 579 565 } else if (h->hasLocalName(colgroupTag)) { 580 if (!n->isTextNode()) { 581 popBlock(currentTagName); 582 handled = true; 583 } 566 popBlock(currentTagName); 567 handled = true; 584 568 } else if (!h->hasLocalName(bodyTag)) { 585 569 if (isInline(current)) { -
trunk/WebCore/html/HTMLTableColElement.cpp
r21615 r21720 31 31 #include "RenderTableCol.h" 32 32 #include "HTMLTableElement.h" 33 #include "Text.h" 33 34 34 35 namespace WebCore { … … 54 55 bool HTMLTableColElement::checkDTD(const Node* newChild) 55 56 { 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); 57 63 } 58 64 -
trunk/WebCore/html/HTMLTableElement.cpp
r21614 r21720 38 38 #include "HTMLTableSectionElement.h" 39 39 #include "RenderTable.h" 40 #include "Text.h" 40 41 41 42 namespace WebCore { … … 65 66 bool HTMLTableElement::checkDTD(const Node* newChild) 66 67 { 67 return newChild->isTextNode() || newChild->hasTagName(captionTag) || 68 if (newChild->isTextNode()) 69 return static_cast<const Text*>(newChild)->containsOnlyWhitespace(); 70 return newChild->hasTagName(captionTag) || 68 71 newChild->hasTagName(colTag) || newChild->hasTagName(colgroupTag) || 69 72 newChild->hasTagName(theadTag) || newChild->hasTagName(tfootTag) || -
trunk/WebCore/html/HTMLTableRowElement.cpp
r21698 r21720 34 34 #include "HTMLTableSectionElement.h" 35 35 #include "NodeList.h" 36 #include "Text.h" 36 37 37 38 namespace WebCore { … … 46 47 bool HTMLTableRowElement::checkDTD(const Node* newChild) 47 48 { 49 if (newChild->isTextNode()) 50 return static_cast<const Text*>(newChild)->containsOnlyWhitespace(); 48 51 return newChild->hasTagName(tdTag) || newChild->hasTagName(thTag) || 49 52 newChild->hasTagName(formTag) || newChild->hasTagName(scriptTag); -
trunk/WebCore/html/HTMLTableSectionElement.cpp
r21698 r21720 33 33 #include "HTMLTableElement.h" 34 34 #include "NodeList.h" 35 #include "Text.h" 35 36 36 37 namespace WebCore { … … 45 46 bool HTMLTableSectionElement::checkDTD(const Node* newChild) 46 47 { 48 if (newChild->isTextNode()) 49 return static_cast<const Text*>(newChild)->containsOnlyWhitespace(); 47 50 return newChild->hasTagName(trTag) || newChild->hasTagName(formTag) || 48 51 newChild->hasTagName(scriptTag);
Note: See TracChangeset
for help on using the changeset viewer.