WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
23708
Would like to have a callback when an HTML element is first added to the DOM
https://bugs.webkit.org/show_bug.cgi?id=23708
Summary
Would like to have a callback when an HTML element is first added to the DOM
Aaron Boodman
Reported
2009-02-03 11:34:20 PST
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.
Attachments
Adds htmlElementAvailable() callback to FrameLoaderClient
(5.17 KB, patch)
2009-02-03 11:37 PST
,
Aaron Boodman
hyatt
: review-
Details
Formatted Diff
Diff
Fixes per review feedback
(12.56 KB, patch)
2009-02-03 17:03 PST
,
Aaron Boodman
no flags
Details
Formatted Diff
Diff
Fix whitespace issues in previous patch
(12.60 KB, patch)
2009-02-03 17:10 PST
,
Aaron Boodman
hyatt
: review-
Details
Formatted Diff
Diff
More fixes
(13.40 KB, patch)
2009-02-04 23:56 PST
,
Aaron Boodman
no flags
Details
Formatted Diff
Diff
Add description and link to bug to ChangeLog files
(14.15 KB, patch)
2009-02-05 00:10 PST
,
Aaron Boodman
hyatt
: review+
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Aaron Boodman
Comment 1
2009-02-03 11:37:47 PST
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.
Dave Hyatt
Comment 2
2009-02-03 11:52:19 PST
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.
Mark Rowe (bdash)
Comment 3
2009-02-03 15:34:06 PST
You'd also need to implement the new method for all platforms rather than just Mac, otherwise the build will break.
Aaron Boodman
Comment 4
2009-02-03 17:03:45 PST
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.
Aaron Boodman
Comment 5
2009-02-03 17:10:06 PST
Created
attachment 27301
[details]
Fix whitespace issues in previous patch
Dave Hyatt
Comment 6
2009-02-04 17:51:02 PST
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.
Aaron Boodman
Comment 7
2009-02-04 23:56:04 PST
Created
attachment 27343
[details]
More fixes Updated ChangeLog, made changes as suggested in HTMLParser, and added an implementation to XMLTokenizerQt.cpp.
Darin Fisher (:fishd, Google)
Comment 8
2009-02-05 00:04:11 PST
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.
Aaron Boodman
Comment 9
2009-02-05 00:10:06 PST
Created
attachment 27344
[details]
Add description and link to bug to ChangeLog files Whoops, you are right. Fixed now.
Dave Hyatt
Comment 10
2009-02-05 14:52:54 PST
Comment on
attachment 27344
[details]
Add description and link to bug to ChangeLog files r=me
Dimitri Glazkov (Google)
Comment 11
2009-02-05 16:01:08 PST
Landed as
http://trac.webkit.org/changeset/40694
.
Simon Fraser (smfr)
Comment 12
2009-02-05 23:41:47 PST
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()'
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug