Bug 6680

Summary: DOMCSSStyleSheet not implemented but still reported as supported?
Product: WebKit Reporter: Todd Ditchendorf <todd>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ap, ian
Priority: P2    
Version: 417.x   
Hardware: Mac   
OS: OS X 10.4   
URL: http://www.ditchnet.org/wp/2006/01/20/applebugfriday-domcssstylesheet-not-properly-implemented-in-webkit/
Attachments:
Description Flags
Xcode project test case none

Todd Ditchendorf
Reported 2006-01-19 22:26:26 PST
I'm not really sure if this totally qualifies as a bug... I suspect it's just a matter of these features not yet being implemented just yet. Then again, WebKit's ObjC DOM implementation will <a href="http:// www.ditchnet.org/wp/2006/01/19/webkit-dom-conformance/">report that it fully supports "CSS","2.0"</a>. However, it appears to not even come close yet. Therefore, it's a bug worth reducing and reporting. Seems a bit odd that WebKit reports supporting this module although it doesn't. Okay... here's my reduction in a nutshell. I have a very simple XHTML document: <div><pre><code> &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;> &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;> &lt;head> &lt;title>Untitled&lt;/title> &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;stylesheet.css&quot; /> &lt;style type=&quot;text/css&quot;> html { border:1px solid lime; } &lt;/style> &lt;/head> &lt;body> &lt;h1>dude&lt;/h1> &lt;/body> &lt;/html> </code></pre></div> And a very simple CSS stylesheet: <div><pre><code> body { border:1px solid orange; } </code></pre></div> As you can see, my XHTML document has two associated stylesheets. One linked via a <code>link</ code> tag and one embedded via a <code>style</code> tag. Here's what I'd like to do. I'd like to get a reference to the <code>DOMDocument</code> object representing my XHTML document. From this document object, I'd like to get references to its two <code>DOMStyleSheet</ code> objects. However, these two stylesheets (by virtue of the fact that they both contain <code>type="text/css"</code> attributes) should actually be instances of the more derived <code>DOMCSSStyleSheet</code> type. I should be able to cast these two <code>DOMStyleSheet</ code> instances down to the more specific <code>DOMCSSStyleSheet</code> interface. Again, this is due to my declaration that these two stylesheets are of type <code>"text/css"</code> <a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS- CSSStyleSheet">according to the DOM Level 2 CSS spec</a>. Unfortunately, if my tests are correct it doesn't look like WebKit DOM supports this basic type (<code>DOMCSSStyleSheet</code>) of the CSS Level 2 Module. This type is the most central interface of that Module, and claiming support without that type is pretty silly. Here's the code from my reduction that fails: <div><code><pre> DOMDocument *doc = [[webView mainFrame] DOMDocument]; DOMStyleSheetList *styleSheets = [doc styleSheets]; NSLog(@&quot;num : %i&quot;,[styleSheets length]); // get reference to first stylesheet. should be a CSS stylesheet, but its not DOMStyleSheet *styleSheet1 = [styleSheets item:0]; DOMCSSStyleSheet *cssStyleSheet1 = (DOMCSSStyleSheet *)styleSheet1; // get reference to second stylesheet. should be a CSS stylesheet, but its not DOMStyleSheet *styleSheet2 = [styleSheets item:1]; DOMCSSStyleSheet *cssStyleSheet2 = (DOMCSSStyleSheet *)styleSheet2; // check the type of first stylesheet, both should return YES NSLog(@&quot;styleSheet1 is DOMStyleSheet ? %i&quot;, [cssStyleSheet1 isKindOfClass:[DOMStyleSheet class]]); NSLog(@&quot;styleSheet1 is DOMCSSStyleSheet ? %i&quot;, [cssStyleSheet1 isKindOfClass:[DOMCSSStyleSheet class]]); // check the type of second stylesheet, both should return YES NSLog(@&quot;styleSheet2 is DOMStyleSheet ? %i&quot;, [cssStyleSheet2 isKindOfClass:[DOMStyleSheet class]]); NSLog(@&quot;styleSheet2 is DOMCSSStyleSheet ? %i&quot;, [cssStyleSheet2 isKindOfClass:[DOMCSSStyleSheet class]]); // these methods should exist, but will raise error DOMCSSRuleList *ruleList1 = [cssStyleSheet1 cssRules]; DOMCSSRuleList *ruleList2 = [cssStyleSheet2 cssRules]; </code></pre></div> And here is the output: <div><code><pre> 36 -0600.] num : 2 [styleSheet isKindOfClass:[DOMStyleSheet class]] ? 1 [styleSheet isKindOfClass:[DOMCSSStyleSheet class]] ? 0 *** -[DOMStyleSheet cssRules]: selector not recognized [self = 0x3a4580] *** -[DOMStyleSheet cssRules]: selector not recognized [self = 0x3a4580] </code></pre></div> If my code is correct, appears that the stylesheets are not returned as specifically being CSS stylesheets as the DOM spec mandates. Apple really should report that DOM Level 2 CSS is not supported until this is implemented. <a href="http://ditchnet.org/csstest/CSSTest.zip">Download Xcode project reduction</a>.
Attachments
Xcode project test case (35.02 KB, application/octet-stream)
2006-01-20 06:42 PST, Todd Ditchendorf
no flags
Joost de Valk (AlthA)
Comment 1 2006-01-20 01:14:26 PST
Hi Todd, although your bugreport looks interesting, it also looks a bit cluttered :) could you add the testcase as an attachment to this bug? Thx!
Todd Ditchendorf
Comment 2 2006-01-20 06:42:52 PST
Created attachment 5799 [details] Xcode project test case Xcode project that demonstrates the problem in as few lines as possible.
Todd Ditchendorf
Comment 3 2006-01-20 06:45:16 PST
Hi Joost... sorry was attempting to be thorough, but it turned out a big mess! I've added an attachment for the Xcode project test case and a URL to my blog where the text of the desc can be read with much better formating.
Alexey Proskuryakov
Comment 4 2006-07-28 05:16:16 PDT
I have verified that the test works correctly now: 2006-07-28 16:12:19.852 CSSTest[24125] num : 2 2006-07-28 16:12:19.852 CSSTest[24125] styleSheet1 is DOMStyleSheet ? 1 2006-07-28 16:12:19.852 CSSTest[24125] styleSheet1 is DOMCSSStyleSheet ? 1 2006-07-28 16:12:19.853 CSSTest[24125] styleSheet2 is DOMStyleSheet ? 1 2006-07-28 16:12:19.853 CSSTest[24125] styleSheet2 is DOMCSSStyleSheet ? 1 *** This bug has been marked as a duplicate of 4309 ***
Note You need to log in before you can comment on or make changes to this bug.