Bug 3534 - CSSMutableStyleDeclarationImpl::item is unimplemented
Summary: CSSMutableStyleDeclarationImpl::item is unimplemented
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Darin Adler
Depends on:
Reported: 2005-06-14 13:47 PDT by Dan Wood
Modified: 2005-07-08 21:20 PDT (History)
0 users

See Also:

Test case (1.05 KB, text/html)
2005-06-17 06:47 PDT, Anders Carlsson
no flags Details
Return the correct property string (4.53 KB, patch)
2005-06-17 07:38 PDT, Anders Carlsson
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Wood 2005-06-14 13:47:10 PDT
CSSMutableStyleDeclarationImpl::item (in css_valueimpl.cpp) is not defined.  This is called by 
[DOMCSSStyleDeclaration item:] in WebKit (DOM-CSS.mm).
Comment 1 Joost de Valk (AlthA) 2005-06-14 23:35:41 PDT
Could you please point out to why this is a problem and what it breaks? Maybe even attach a testcase? :)
Comment 2 Dan Wood 2005-06-15 10:04:03 PDT
The webkit method -[DOMCSSStyleDeclaration item:] calls CSSStyleDeclarationImpl::item...

- (DOMStyleSheet *)item:(unsigned long)index
    return [DOMStyleSheet _DOMStyleSheetWithImpl:[self _styleSheetListImpl]->item(index)];

This is the implementation of CSSStyleDeclarationImpl::item; notice that the index is unused and that 
an empty string is returned.

DOMString CSSStyleDeclarationImpl::item( unsigned long /*index*/ )
    // ###
    //return m_lstValues->at(index);
    return DOMString();

So for instance, if you were trying to process a DOMElement's style attribute (say, to make some 
modifications or output the style), by looping though each item (simplified snippet below), you'd find 
that the "item" method returns an empty string, so you couldn't process the style item.

				DOMCSSStyleDeclaration *style = [self style];
				NSLog(@"style = %@", style);
				int length = [style length];
				id item = [style item:0];

Comment 3 Joost de Valk (AlthA) 2005-06-16 00:16:47 PDT
we're getting there, if you'd please make a testcase out of your small example which behaves incorrect 
and for example works in firefox, then we have a case here :)
Comment 4 Joost de Valk (AlthA) 2005-06-16 14:04:39 PDT
hyatt	   AlthA: he's pointed out the function does not contain an impl
hyatt	   AlthA: thats enough to confirm it's a bug
hyatt   AlthA: even without a testcase

Comment 5 Anders Carlsson 2005-06-17 06:47:31 PDT
Created attachment 2430 [details]
Test case

Here's a test case that shows that item returns an empty string
Comment 6 Anders Carlsson 2005-06-17 07:38:41 PDT
Created attachment 2437 [details]
Return the correct property string

Here's a patch that makes ::item return the correct property string. 

I do know that m_values[i] is O(n), but I don't really think that it matters
much here because the number of style rules is usually rather small and I'd
guess that ::item is seldomly used.
Comment 7 Darin Adler 2005-06-17 16:06:46 PDT
Comment on attachment 2437 [details]
Return the correct property string

Looks fine. If it was me I would have formatted the
CSSMutableStyleDeclarationImpl::item function a little tighter, more like
CSSComputedStyleDeclarationImpl::item, but that's such a nit. Lets land this
Comment 8 Joost de Valk (AlthA) 2005-06-19 23:14:20 PDT
Reporter, i'll let you do the honors of verifying this one, since you know how well embedded i am in the 
code *ugh*.
Comment 9 Joost de Valk (AlthA) 2005-07-03 08:05:44 PDT
Dan, please verify this one if it has been fixed for you.
Comment 10 Dan Wood 2005-07-07 11:12:00 PDT
(In reply to comment #9)
> Dan, please verify this one if it has been fixed for you.

Well, something is definitely implemented, but I don't know if what is implemented is correct.  

I wrote a little test code that gets a computed style, and then outputs the items in the 

	DOMCSSStyleDeclaration *style = [[self DOMDocument] getComputedStyle:(DOMElement *)
node :@""];

	NSMutableString *string = [NSMutableString string];
	int i;
	for (i = 0 ; i < [style length] ; i++ )
		[string appendString:[style item:i]];
		[string appendString:@" "];
	NSLog(@"items (%d) = %@", [style length], string);

What results is this:

2005-07-07 10:59:21.369 Sandvox[21119] items (99) = rgba(0, 0, 0, 0) none repeat scroll 0 0 auto 
auto separate 0px 0px 0px 0px rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) none 
none none none 0px 0px 0px 0px auto stretch normal 0 1 single 1 horizontal start top none rgb(0, 0, 
0) auto dashboard-region( ltr inline show none Futura 40.128px normal normal normal 0px auto 
normal after-white-space -1% normal none outside disc 0px 0px 0px 0px auto 6px infinite scroll -1px 
-1px 0px 0px space 1 2 none visible auto auto auto auto auto auto auto static auto auto center none 
none 0px rgb(255, 255, 255) 0px 1px 1px uppercase auto normal read-write baseline visible normal 2 
0px 0px break-word normal 

Wow, this doesn't look right.  Or maybe it is.  It's hard to tell because the "cssText" method is not 
implemented either (new bug #3893), so I don't have anything to compare it to.  But it seems like it's 
only the "value" of a property.  I can't find any documentation on what this is *supposed* to return, but 
it doesn't look like it's anything useful.

So I'd like it if somebody who is more famiiar with what this is supposed to do can verify the bug, 
Comment 11 Anders Carlsson 2005-07-08 21:20:56 PDT
The problem is that CSSComputedStyleDeclarationImpl::item() isn't implemented. I've uploaded a patch for 
bug 3983 that implements it, so I'll just close this bug.