Each nsCSSStyleSheet has a pointer to a nsCSSStyleSheetInner. The
nsCSSStyleSheetInner is shared across multiple stylesheets, in
general. The nsCSSStyleSheetInner owns the rules and the child
stylesheets.
What this means is that a given rule object is effectively owned by
multiple sheets. However, cycles can only form through rule objects
that have been JS-wrapped, and if we're JS-wrapping a rule object that
means we have ensured that it's owned by only one stylesheet.
Therefore, we only traverse and unlink mInner if it's uniquely owned
by our sheet.
Similarly, if our child sheets or any of their rules have been
JS-wrapped, that means that we must have an mInner that we own
outright.
This creates a new method 'StartDecoding' which does a RequestDecode and some
decoding of the image.
--HG--
extra : rebase_source : 89c1c2f40e3dfb6e025939ebf3257f81ce429501
This patch enables sharing of an nsAttrValue's MiscContainer between nodes for style rules. MiscContainers of type eCSSStyleRule are now refcounted (with some clever struct packing to ensure that the amount of memory allocated for MiscContainer remains unchanged on 32 and 64 bit). This infrastructure can be used to share most MiscContainer types in the future if we find advantages to sharing other types than just eCSSStyleRuley. A cache mapping strings to MiscContainers has been added to nsHTMLCSSStyleSheet. MiscContainers can be shared between nsAttrValues when one nsAttrValue is SetTo another nsAttrValue or when there is a cache hit in this cache. This patch also adds the ability to tell a style rule that it belongs to an nsHTMLCSSStyleSheet, with appropriate accessor functions to separate that from the existing case of belonging to an nsCSSStyleSheet.
The primary use case is to reduce memory use for pages that have lots of inline style attributes with the same value. This can happen easily with large pages that are automatically generated. An (admittedly pathological) testcase in Bug 686975 sees over 250 MB of memory savings with this change. Reusing the same MiscContainer for multiple nodes saves the overhead of maintaining separate copies of the string containing the serialized value of the style attribute and of creating separate style rules for each node. Eliminating duplicate style rules enables further savings in layout through style context sharing. The testcase sees the amount of memory used by style contexts go from over 250 MB to 10 KB.
Because the cache is based on the text value of the style attribute, it will not handle attributes that have different text values but are parsed into identical style rules. We also do not attempt to share MiscContainers when the node's base URI differs from the document URI. The effect of these limitations is expected to be low.
gfxTextObjectPaint::GetFillPattern/GetStrokePattern should take the destination's CTM
as a parameter in order to set up the pattern matrix correctly, since the pattern matrix
is combined with the CTM by cairo/Thebes --- but we want the pattern rendering to be
independendt of the CTM, instead depending only on the TM set up when we initialized
the gfxTextObjectPaint.
We make SVGTextObjectPaint store matrices that map device space to pattern space.
This adds entries for property aliases as though they are shorthands.
This fits with the CSS working group's recent resolution to describe
aliases as shorthands, recorded in
http://lists.w3.org/Archives/Public/www-style/2012Aug/0770.html .
The property_database.js entries themselves are copied from the
non-alias entries for the properties, with these changes:
(1) The property name is changed to the prefixed form
(2) The domProp entry is changed to the prefixed form
(3) Adding alias_for entries for each property.
(4) When type is CSS_TYPE_LONGHAND in the target of the alias, type for
the alias is CSS_TYPE_SHORTHAND_AND_LONGHAND and a subproperties
entry is added with the target of the alias.
There are also some indentation fixes to the copied entries in
property_database.js (made before they were copied, and thus affecting
the original as well).
This currently only affects the testing of overflow, but it will also
affect -moz-transform (and any other aliases implemented the same way)
after the later patches in this bug.
This special-cases text-decoration because text-decoration: inherit causes
the color to inherit in a way that we can't serialize the result (since
it's no longer "foreground"). (This isn't great; we might want to
consider fixing it somehow.)
Separate out background layers into separate display-list items, so that
backgrounds that are a mix of fixed and non-fixed layers will be treated
individually.