Open Bug 1743749 Opened 2 years ago Updated 1 year ago

Clean up use of atoms for cache keys

Categories

(Core :: Disability Access APIs, task)

task

Tracking

()

People

(Reporter: Jamie, Unassigned)

References

(Blocks 1 open bug)

Details

We use AccAttributes for the CTW cache and AccAttributes is keyed by nsAtom. This has some advantages as compared to an enum: we don't need separate data structures for object/text attributes and the CTW cache and we get readable logging for the keys for free. However, a major disadvantage is that because we try to avoid polluting the nsGkAtoms namespace, we end up with some unclear/unintuitive keys; e.g. nsGkAtoms::line for text line start boundaries, nsGkAtoms::style for text attributes, etc.

We need to find a way to make this more obvious and readable. We can either alias the atoms in our own namespace or switch to using an enum after all.

I looked into various approaches of aliasing. We can't use an enum because enums have to be convertable to int. We can't use a using declaration because they only work for types, not values. What does work is this:

class CacheKey {
 public:
  static constexpr nsStaticAtom* TextLineStarts = nsGkAtoms::line;
};
You need to log in before you can comment on or make changes to this bug.