RESOLVED FIXED 125279
Change how the form element pointer affects parsing template elements, to reduce weirdness in templates
https://bugs.webkit.org/show_bug.cgi?id=125279
Summary Change how the form element pointer affects parsing template elements, to red...
Ryosuke Niwa
Reported 2013-12-04 21:09:45 PST
Make HTML5 parser changes to match the HTML5 specification change: http://html5.org/tools/web-apps-tracker?from=8330&to=8331 Change how the form element pointer affects parsing <template> elements, to reduce weirdness in templates (e.g. before you couldn't have a template that contained a form if it was itself inside a form).
Attachments
Work in progress (6.27 KB, patch)
2013-12-04 21:17 PST, Ryosuke Niwa
no flags
Updates the parser (12.39 KB, patch)
2013-12-04 22:40 PST, Ryosuke Niwa
koivisto: review+
Ryosuke Niwa
Comment 1 2013-12-04 21:17:50 PST
Created attachment 218487 [details] Work in progress
Ryosuke Niwa
Comment 2 2013-12-04 22:24:17 PST
Ryosuke Niwa
Comment 3 2013-12-04 22:40:05 PST
Created attachment 218489 [details] Updates the parser
Antti Koivisto
Comment 4 2013-12-05 11:30:00 PST
Comment on attachment 218489 [details] Updates the parser View in context: https://bugs.webkit.org/attachment.cgi?id=218489&action=review > Source/WebCore/html/parser/HTMLConstructionSite.cpp:416 > + if (!insideTemplateElement()) > + m_form = static_pointer_cast<HTMLFormElement>(element); > + static_pointer_cast<HTMLFormElement>(element)->setDemoted(isDemoted); Please do the cast only once and put it to a local > Source/WebCore/html/parser/HTMLConstructionSite.cpp:544 > +inline bool HTMLConstructionSite::insideTemplateElement() > +{ > + return !ownerDocumentForCurrentNode().frame(); > +} Maybe we should just have a boolean for this state? This is bit hard to understand. > Source/WebCore/html/parser/HTMLTreeBuilder.cpp:1869 > +#if ENABLE(TEMPLATE_ELEMENT) > + if (!isParsingTemplateContents()) { > +#endif Not a big fan of #ifs like this
Ryosuke Niwa
Comment 5 2013-12-05 11:42:11 PST
Comment on attachment 218489 [details] Updates the parser View in context: https://bugs.webkit.org/attachment.cgi?id=218489&action=review >> Source/WebCore/html/parser/HTMLConstructionSite.cpp:416 >> + static_pointer_cast<HTMLFormElement>(element)->setDemoted(isDemoted); > > Please do the cast only once and put it to a local Done. >> Source/WebCore/html/parser/HTMLConstructionSite.cpp:544 >> +} > > Maybe we should just have a boolean for this state? This is bit hard to understand. Yeah, I'd love to. Unfortunately, it's very tricky to do in one patch :( >> Source/WebCore/html/parser/HTMLTreeBuilder.cpp:1869 >> +#endif > > Not a big fan of #ifs like this Got rid of the if-def since the latter part doesn't use any template-specific code and "return false" is hard-coded in isParsingTemplateContents() so that the compiler can easily eliminate the code block.
Ryosuke Niwa
Comment 6 2013-12-05 11:42:18 PST
Thanks for the review!
Ryosuke Niwa
Comment 7 2013-12-05 11:42:33 PST
Note You need to log in before you can comment on or make changes to this bug.