Bug 90596

Summary: Move element/tag category query functions to a separate file
Product: WebKit Reporter: Kwang Yul Seo <skyul>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: abarth, dglazkov, eric, rakuco, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 90607    
Attachments:
Description Flags
Patch
none
Patch
none
Patch abarth: review-

Kwang Yul Seo
Reported 2012-07-05 02:51:57 PDT
Move element/tag category query functions such as isSpecialNode(Node*) to HTMLParserCategory.h/cpp. Currently, these functions are scattered in HTMLTokenizer.cpp and HTMLElementStack.cpp. After this patch, we can move HTMLTreeBuilder::furthestBlockForFormattingElement(Element*) method to HTMLElementStack class. This method naturally belongs to HTMLElementStack, but it is currently in HTMLTreeBuilder only because isSpecialNode(Element*) is defined in HTMLTreeBuilder.cpp file.
Attachments
Patch (23.58 KB, patch)
2012-07-05 02:56 PDT, Kwang Yul Seo
no flags
Patch (23.60 KB, patch)
2012-07-05 04:21 PDT, Kwang Yul Seo
no flags
Patch (26.77 KB, patch)
2012-07-05 05:23 PDT, Kwang Yul Seo
abarth: review-
Kwang Yul Seo
Comment 1 2012-07-05 02:56:29 PDT
Early Warning System Bot
Comment 2 2012-07-05 03:00:59 PDT
Early Warning System Bot
Comment 3 2012-07-05 03:01:26 PDT
Build Bot
Comment 4 2012-07-05 03:07:53 PDT
Kwang Yul Seo
Comment 5 2012-07-05 03:13:12 PDT
I will fix build errors soon.
WebKit Review Bot
Comment 6 2012-07-05 03:19:46 PDT
Comment on attachment 150906 [details] Patch Attachment 150906 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/13136987
Kwang Yul Seo
Comment 7 2012-07-05 04:21:44 PDT
Build Bot
Comment 8 2012-07-05 04:50:27 PDT
Kwang Yul Seo
Comment 9 2012-07-05 05:23:49 PDT
Kwang Yul Seo
Comment 10 2012-07-05 05:34:58 PDT
I don't like the name, HTMLParserCategory. Please suggest me a better name for this.
Kwang Yul Seo
Comment 11 2012-07-05 05:36:01 PDT
(In reply to comment #8) > (From update of attachment 150923 [details]) > Attachment 150923 [details] did not pass mac-ews (mac): > Output: http://queues.webkit.org/results/13143139 Wow. It is surprisingly hard to make all the build bots green. Modifying Xcode project file by hand is the worst experience!
Adam Barth
Comment 12 2012-07-05 07:06:55 PDT
Comment on attachment 150926 [details] Patch I don't see the benefit of this change. Currently, these functions are defined in the files that use them. Do we achieve any code sharing with this change?
Kwang Yul Seo
Comment 13 2012-07-05 07:45:33 PDT
(In reply to comment #12) > (From update of attachment 150926 [details]) > I don't see the benefit of this change. Currently, these functions are defined in the files that use them. Do we achieve any code sharing with this change? I wanted to move HTMLTreeBuilder::furthestBlockForFormattingElement(Element*) to HTMLElementStack. (Bug 90607). There is a FIXME comment: // FIXME: This probably belongs on HTMLElementStack. HTMLElementStack::ElementRecord* HTMLTreeBuilder::furthestBlockForFormattingElement(Element* formattingElement) This method internally uses isSpecialNode(Node*). After HTMLTreeBuilder::furthestBlockForFormattingElement(Element*) is moved to HTMLElementStack, both HTMLTreeBuilder and HTMLElementStack need to access isSpecialNode(Node*). So I moved isSpecialNode(Node*) to a separate file. Because isSpecialNode(Node*) depends on many other functions, I had to move them too. I named the file HTMLParserCategory.h/cpp since these functions happen to be tag category query functions. Then I moved a few related functions too. So this patch does not achieve much code sharing. The only code sharing it achieves is isSpecialNode(Node*). If you think it is better to leave HTMLTreeBuilder::furthestBlockForFormattingElement(Element*) where it is, I'm okay with r-. Thanks for you review.
Adam Barth
Comment 14 2012-07-08 18:30:29 PDT
I think it's probably not worth fixing. Perhaps we should remove the FIXME comment? Generally, FIXME comments are often questions we weren't sure about when we wrote the code originally. We don't necessarily want to fix all of them. They're mostly there to help folks working on this code in the future understand what we were thinking originally.
Kwang Yul Seo
Comment 15 2012-07-08 18:33:08 PDT
(In reply to comment #14) > I think it's probably not worth fixing. Perhaps we should remove the FIXME comment? Generally, FIXME comments are often questions we weren't sure about when we wrote the code originally. We don't necessarily want to fix all of them. They're mostly there to help folks working on this code in the future understand what we were thinking originally. Okay. I will close Bug 90607 as WONTFIX too.
Eric Seidel (no email)
Comment 16 2012-07-08 18:41:57 PDT
I probably wrote the fixme. I kinda like the change... but I suspect we would want to do these all in a header instead. But as Adam notes, this is probably not worth teh code churn.
Eric Seidel (no email)
Comment 17 2012-07-08 18:42:37 PDT
I really appreciate you looking through all these parser FIXMEs. As Adam points out, we wrote a whole bunch of FIXMEs while writing the parser. Not all of which we really should fix. It's nice that someone is looking through them!
Kwang Yul Seo
Comment 18 2012-07-08 19:01:48 PDT
(In reply to comment #17) > I really appreciate you looking through all these parser FIXMEs. As Adam points out, we wrote a whole bunch of FIXMEs while writing the parser. Not all of which we really should fix. It's nice that someone is looking through them! Thanks. One particular FIXME I really want to remove is in HTMLPreloadScanner::scan() // FIXME: We should save and re-use these tokens in HTMLDocumentParser if // the pending script doesn't end up calling document.write. while (m_tokenizer->nextToken(m_source, m_token)) { processToken(); m_token.clear(); } HTMLPreloadScanner is nice, but it fails to save and reuse the tokens because it just uses an approximation of how the tree builder would update the tokenizer's state. I want to teach HTMLDocumentParser to parse speculatively (in addition to preloading) while it is waiting for scripts. I will file a bug and share my initial design. Looking through all these parser FIXMEs is a good way to learn the parser code base. I really appreciate your review. Thanks Adam and Eric.
Adam Barth
Comment 19 2012-07-08 20:43:14 PDT
w.r.t. that FIXME, another path is to move the preload scanner to its own thread. For either change, we really need benchmarks to tell us whether we're making things faster or slower. Maybe we can both re-use tokens and move the scanner to its own thread?
Kwang Yul Seo
Comment 20 2012-07-08 22:37:40 PDT
(In reply to comment #19) > w.r.t. that FIXME, another path is to move the preload scanner to its own thread. For either change, we really need benchmarks to tell us whether we're making things faster or slower. Maybe we can both re-use tokens and move the scanner to its own thread? It was tried before in Bug 63531. The patch was rejected because the performance gain was very small. After we introduce speculative parsing, then maybe we can both re-use tokens and move HTML parsing (not just preload scanning) off the main thread. Firefox exactly doe this. https://developer.mozilla.org/en/Gecko/HTML_parser_threading https://bugzilla.mozilla.org/show_bug.cgi?id=483016 Now the discussion is off the topic. I filed Bug 90751 for further discussion.
Note You need to log in before you can comment on or make changes to this bug.