[webkit-dev] Implementing <style scoped>

Antti Koivisto koivisto at iki.fi
Fri Sep 9 03:33:30 PDT 2011


On Fri, Sep 9, 2011 at 12:28 AM, Roland Steiner
<rolandsteiner at chromium.org>wrote:

>
> ad 3.) Implementation of scoped selector matching works as follows:
>
> .) scoped style sheet rules are contained in a separate map <scoping
> element address> -> RuleSet
> .) add a field to ParentStackFrame that identifies the
> closest ParentStackFrame that refers to a scoping element
> .) during matching only check RuleSets that are thusly identified in
> ParentStackFrame (plus a slow path that climbs the tree in case
> ParentStackFrame isn't applicable), plus global rules
> .) add a 'scope' parameter to the matching functions that identifies the
> scoping element that limits the matching.
>
> Note that with this implementation rules in scoped RuleSets that are not
> "in scope" aren't even looked at. Also note that the actual selector data is
> NOT modified for this. I.e., a selector in a scoped style sheet is not
> different from a global selector. This has several benefits:
>

Sounds good to me. We don't currently rely on ParentStackFrames to get any
semantics right, it is just for performance optimization. You will need to
take care that it is now functional (rebuild as needed) in all cases.

Inroducing root should be ok for fastCheckSelector path too, testing against
root element shouldn't be slower than testing against null.

I was anyway thinking of moving the parent stack to SelectorChecker. With
this it will actually be needed for querySelectorAll.


   antti


>
> .) no updating necessary if a <style> element is inserted or removed from
> the document, nor when the 'scoped' attribute is set/unset.
> .) paves the way for a trivial implementation of a similarly scoped
> querySelector[All].
> .) for components: several component instantiations can re-use the same
> template style sheet without the need to clone its rules.
>
>
> Please let me know your thoughts,
>
> - Roland
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20110909/a3ebefc9/attachment.html>


More information about the webkit-dev mailing list