[Bug 19276] [Shadow]: Consider simplifying addStyleSheet parameters

https://www.w3.org/Bugs/Public/show_bug.cgi?id=19276

--- Comment #2 from Takashi Sakamoto <tasak@google.com> ---
I'm sorry. I missed the way to obtain css text from <style>(and also URL from
<link>).

So, if <style> is not in DOM tree,
(1) obtain css text from <style> (in the same way as StyleElement class does).
(2) parse the obtained css text (in the same way as StyleElement class does).
(3) create CSSStyleSheet.

(2) and (3) are the same task as addStyleSheet(DOMString cssText) does.

I think, which is better to use Element or DOMString depends on Web
developers...
We have to ask developers about which their favorite way.

Best regards,
Takashi Sakamoto

(In reply to comment #1)
> (In reply to comment #0)
> > Both HTMLLinkElement and HTMLStyleElement are used here as the glorified
> > dictionaries, and that seems like abuse of their intended purpose.
> > 
> > We should do something simpler.
> > 
> > a) use actual dictionaries
> > b) use two calls, one to add a stylesheet by URL, one to add a stylesheet as
> > string.
> 
> Talking about b),  I'm not sure whether it is ok to create any hash key from
> css text or not...
> 
> If we cannot quickly check whether the given css text (string) is the same
> as the one which has been already parsed or not, we have to parse the same
> css text many and many times.
> 
> I mean, from the view of implementation, is it possible to do (1)->(2)->(3)
> in WebKit?
> 
> Suppose that we have some css text as WTF::String.
> (1) we generate some hash key from the css text.
> (2) we look up some hash table, mapping from some hash key (integer?) to an
> instance of class StyleSheet.
> (3) if some StyleSheet is found, we use the found one. Otherwise, we parse
> the css text by using CSSParser and create a new StyleSheet (and register it
> with the hash table).
> 
> If we run CSSParser every time we invoke addStyleSheet, it might cause
> performance problem...
> 
> Best regards,
> Takashi Sakamoto

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Monday, 15 October 2012 10:40:02 UTC