css inspector$Id$
The primary requirements for the css inspector are these:
It seems beneficial to integrate with the DOM inspector in order not to duplicate code. CSS rules should therefore be exposed via DOM properties or DOM functions, which have special meaning on the client side. This also serves to keep most of the CSS inspector code to the server side.
The precondition for this description is that the CSS inspector only shows the values directly specified on an element. Inherited values for an element is found by inspecting the parent elements in the DOM.
Currently, when we have loaded the CSS declarations for the elements in the document tree, we don't know which rule or stylesheet they came from. This is required for a CSS inspector.
The place where it's natural to add this information, is in the result from CSSCollection::GetProperties (available through HLDocProfile::GetCSS_Properties). This methods calls CSS::GetProperties for each stylesheet and stores an array of pointers to declaration objects. Each entry in the array corresponds to a CSS property. The resulting array contains declarations from different rulesets and different stylesheets. We can easily add an array of ruleset pointers, and an array of stylesheet pointers to keep more detailed information about the rule origin. This should not add much complexity or create performance/memory problems.
When we have the set of declarations, rulesets and stylesheets for an element, we can easily use the existing APIs in dom_css.h (CSS_DOMStyleDeclaration, CSS_DOMRule, and CSS_DOMStyleSheet) to get textual representations for display. Furthermore, they can be used to instantiate Ecmascript bindings for the DOM objects. This requires FEATURE_DOM2_STYLE.