It would be useful to have a callback (perhaps on FrameLoaderClient) for when the HTML element is first added to the DOM. This would b fired around the same time as the existing windowObjectCleared() callback, but the difference would be that clients would be guaranteed there is a root HTML element available that they can start using. The specific use case I have in mind in user scripts in Chromium. In Firefox, developers frequently asked for a way to run their user scripts before any HTML or script had been run on the page. A typical reason would be so that they could add CSS to the page before rendering started, or to setup event handlers. In order to add CSS, we need a callback after there is an HTML element to append new style elements to, and windowObjectCleared() happens before this point currently.
Created attachment 27282 [details] Adds htmlElementAvailable() callback to FrameLoaderClient This is a first cut of what I'm talking about. It works for HTML and XHTML documents, but not SVG. SVG is not critical for my use case, and it looks like parsing works much differently in SVG. Also, please let me know what the right way is to add testing for something like this.
Comment on attachment 27282 [details] Adds htmlElementAvailable() callback to FrameLoaderClient I think this callback should just be documentElementAvailable rather than being specific to <html>. You did not patch XHTML, but only patched the HTML parser.
You'd also need to implement the new method for all platforms rather than just Mac, otherwise the build will break.
Created attachment 27300 [details] Fixes per review feedback Changed callback name to documentElementAvailable(), implemented for XML documents (which should cover SVG, XHTML, and WML I believe), and added empty implementations of callback for other platforms.
Created attachment 27301 [details] Fix whitespace issues in previous patch
Comment on attachment 27301 [details] Fix whitespace issues in previous patch Nearly there... Looks like your Changelog needs to be regenerated? The change to HTMLParser.cpp could just be a single if statement. if (localName == htmlTag && document->frame()) I don't know if Qt wants this or not but for completeness you would need to patch their XMLTokenizer as well.
Created attachment 27343 [details] More fixes Updated ChangeLog, made changes as suggested in HTMLParser, and added an implementation to XMLTokenizerQt.cpp.
Comment on attachment 27343 [details] More fixes >Index: WebCore/ChangeLog ... >+2009-02-04 Aaron Boodman <set EMAIL_ADDRESS environment variable> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ WARNING: NO TEST CASES ADDED OR CHANGED >+ Usually, this is where people add a link to the bug and a description of the change.
Created attachment 27344 [details] Add description and link to bug to ChangeLog files Whoops, you are right. Fixed now.
Comment on attachment 27344 [details] Add description and link to bug to ChangeLog files r=me
Landed as http://trac.webkit.org/changeset/40694.
This broke the gtk build: http://build.webkit.org/builders/trunk-qt-linux-release/builds/13432/steps/compile-release_2/logs/stdio /home/zrusin/WebKit-BuildSlave/trunk-qt-linux-release/build/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `non-virtual thunk to WebCore::FrameLoaderClientQt::documentElementAvailable()' /home/zrusin/WebKit-BuildSlave/trunk-qt-linux-release/build/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::FrameLoaderClientQt::documentElementAvailable()'