[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Withdrawn: 8320796: CssMetaData.combine()
From:       Andy Goryachev <angorya () openjdk ! org>
Date:       2023-11-29 21:53:29
Message-ID: XTXhjmHfzX4cabKSreT3pJvq3gz6cq5hwgpjGPxaNtk=.a480e24f-9e29-4653-947f-0c1a567272e5 () github ! com
[Download RAW message or body]

On Mon, 27 Nov 2023 18:30:27 GMT, Andy Goryachev <angorya@openjdk.org> wrote:

> Provide a public utility method for use by custom and core Nodes to simplify \
> boilerplate around styleable properties as well as to save some memory. 
> 
> /**
> * Utility method which combines {@code CssMetaData} items in one immutable list.
> * <p>
> * The intended usage is to combine the parent and the child CSS meta data for
> * the purposes of {@code getClassCssMetaData()} method, see for example {@link \
>                 Node#getClassCssMetaData()}.
> * <p>
> * Example:
> * <pre>
> * private static final List&lt;CssMetaData&lt;? extends Styleable, ?>> STYLEABLES = \
>                 CssMetaData.combine(
> *      &lt;Parent>.getClassCssMetaData(),
> *      STYLEABLE1,
> *      STYLEABLE2
> *  );
> * </pre>
> * This method returns an instance of {@link java.util.RandomAccess} interface.
> *
> * @param list the css metadata items, usually from the parent, must not be null
> * @param items the additional items
> * @return the immutable list containing all of the items
> *
> * @since 22
> */
> public static List<CssMetaData<? extends Styleable, ?>> combine(
> List<CssMetaData<? extends Styleable, ?>> list,
> CssMetaData<? extends Styleable, ?>... items)
> 
> 
> Problem(s):
> 
> - the same less-than-optimal implementation is duplicated throughout the javafx \
> code base which combines the parent and child styleable properties, using ArrayList \
>                 wrapped in a  Collections.unmodifiableList()
> - the capacity of underlying ArrayList might exceed the number of items, wasting \
>                 memory
> - a potential exists for the custom component developer to inadvertently create a \
> sub-standard implementation (i.e. return a List which does not implement \
> RandomAccess interface), or forget to include parent's styleables. 
> Non-Goals:
> 
> - not redesigning the lazy initialization of STYLEABLES list
> - not changing the way styleables are enumerated in Nodes and Controls
> - not adding any new methods to JDK (collections)
> 
> To Be Discussed:
> 
> - it is not clear whether the order of styleables returned by <N extends \
>                 Node>.getClassCssMetaData() is of any importance
> - the current spec for Node.getCssMetaData() specifies the return value as "The \
> CssMetaData associated with this node, which may include the CssMetaData of its \
> superclasses.", implying that it may or may not include.  It is unclear whether it \
> must include the parent's styleables (well, except the Node whose superclass is \
> Object and thus has no styleable properties).

This pull request has been closed without being integrated.

-------------

PR: https://git.openjdk.org/jfx/pull/1296


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic