Commit 4c545303 authored by hyatt's avatar hyatt

Improve <form> error reporting to catch <form>s inside table parts.

        Tweak the wording of some of the error messages to be a bit better.

        Reviewed by olliej

        * html/HTMLParser.cpp:
        (WebCore::HTMLParser::insertNode):
        (WebCore::HTMLParser::processCloseTag):
        (WebCore::HTMLParser::popBlock):
        * html/HTMLParserErrorCodes.cpp:
        (WebCore::htmlParserErrorMessageTemplate):
        * html/HTMLParserErrorCodes.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c4262c9c
2007-05-24 David Hyatt <hyatt@apple.com>
Improve <form> error reporting to catch <form>s inside table parts.
Tweak the wording of some of the error messages to be a bit better.
Reviewed by olliej
* html/HTMLParser.cpp:
(WebCore::HTMLParser::insertNode):
(WebCore::HTMLParser::processCloseTag):
(WebCore::HTMLParser::popBlock):
* html/HTMLParserErrorCodes.cpp:
(WebCore::htmlParserErrorMessageTemplate):
* html/HTMLParserErrorCodes.h:
2007-05-24 Rob Buis <buis@kde.org>
Reviewed by Hyatt.
......@@ -310,14 +310,16 @@ bool HTMLParser::insertNode(Node* n, bool flat)
// don't push elements without end tags (e.g., <img>) on the stack
bool parentAttached = current->attached();
if (tagPriority > 0 && !flat) {
pushBlock(localName, tagPriority);
if (newNode == current)
popBlock(localName);
else {
if (newNode == current) {
// This case should only be hit when a demoted <form> is placed inside a table.
ASSERT(localName == formTag);
reportError(FormInsideTablePartError, &current->localName());
} else {
// The pushBlock function transfers ownership of current to the block stack
// so we're guaranteed that didRefCurrent is false. The code below is an
// optimized version of setCurrent that takes advantage of that fact and also
// assumes that newNode is neither 0 nor a pointer to the document.
pushBlock(localName, tagPriority);
ASSERT(!didRefCurrent);
newNode->ref();
current = newNode;
......@@ -829,13 +831,15 @@ void HTMLParser::processCloseTag(Token* t)
if (t->tagName == htmlTag || t->tagName == bodyTag || t->tagName == commentAtom)
return;
if (t->tagName == formTag)
bool checkForCloseTagErrors = true;
if (t->tagName == formTag && m_currentFormElement) {
m_currentFormElement = 0;
else if (t->tagName == mapTag)
checkForCloseTagErrors = false;
} else if (t->tagName == mapTag)
m_currentMapElement = 0;
HTMLStackElem* oldElem = blockStack;
popBlock(t->tagName, true);
popBlock(t->tagName, checkForCloseTagErrors);
if (oldElem == blockStack && t->tagName == pTag) {
// We encountered a stray </p>. Amazingly Gecko, WinIE, and MacIE all treat
// this as a valid break, i.e., <p></p>. So go ahead and make the empty
......@@ -1214,7 +1218,7 @@ void HTMLParser::popBlock(const AtomicString& tagName, bool reportErrors)
if (!elem) {
if (reportErrors)
reportError(StrayCloseTagError, &tagName);
reportError(StrayCloseTagError, &tagName, 0, true);
return;
}
......
......@@ -45,10 +45,11 @@ const char* htmlParserErrorMessageTemplate(HTMLParserErrorCode errorCode)
"%tag1 misplaced in <table>. Creating %tag2 and putting %tag1 inside it.",
"</br> encountered. Converting </br> into <br>.",
"XML self-closing tag syntax used on %tag1. The tag will not be closed.",
"Stray </p> encountered. Converting </p> into <p></p>.",
"Stray %tag1 encountered. Ignoring close tag.",
"Unmatched </p> encountered. Converting </p> into <p></p>.",
"Unmatched %tag1 encountered. Ignoring tag.",
"%tag1 misnested or not properly closed. Cloning %tag1 in order to preserve the styles applied by it.",
"XML self-closing tag syntax used on <script>. The tag will be closed by WebKit, but not all engines do this. Change to <script></script> instead for best cross-browser compatibility."
"<form> cannot act as a container inside %tag1 without disrupting the table. The children of the <form> will be placed inside the %tag1 instead.",
"XML self-closing tag syntax used on <script>. The tag will be closed by WebKit, but not all browsers do this. Change to <script></script> instead for best cross-browser compatibility."
};
if (errorCode >= MisplacedTablePartError && errorCode <= IncorrectXMLCloseScriptWarning)
......
......@@ -46,6 +46,7 @@ enum HTMLParserErrorCode {
StrayParagraphCloseError,
StrayCloseTagError,
ResidualStyleError,
FormInsideTablePartError,
IncorrectXMLCloseScriptWarning
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment