Open Bug 256773 Opened 16 years ago Updated 6 years ago

Gecko should support highlighting of multiple ranges that are not the selection (multiple styleable selections)

Categories

(Core :: DOM: Selection, enhancement)

enhancement
Not set

Tracking

()

People

(Reporter: dbaron, Unassigned)

References

(Depends on 1 open bug)

Details

Gecko should support highlighting of multiple DOM ranges that are not the
selection.  This is needed for things that want to highlight terms without
manipulating the page's DOM, e.g., the Find toolbar in Firefox (currently branch
only, ugh!) or the Google toolbar extension.

I'm not exactly sure about the details here, but we may want some sort of API
for associating style with ranges.

Note that this bug is different from bug 73373, which is about having multiple
selections.  However, both may depend on common infrastructure work.
Priority: -- → P1
If we fixed this, then selection could use it and a lot of special-purpose
selection drawing code could go away.

One obvious approach would be to have a new CSS selector :-moz-range(blah) and
be able to give a range the name "blah"; anything in the range matches the
selector. One problem with that is that *:-moz-range(blah) doesn't match text
nodes, and in fact our code assumes in various places that text nodes are not
individually stylable. We'd have to be very careful about performance impact if
we tried to relax that assumption. But I think we could pull it off if we had an
extension to CSS syntax that matched text nodes and didn't violate any standards.

I think the basic code changes with that approach would have to be:
-- changes to the bounds of named ranges would have to trigger reframes of the
content over which the bounds changed
-- constructing frames for text nodes would have to split frames at named range
boundaries
-- frame construction would have to very efficiently identify the named ranges
applying to content and hand them to the style system at style resolution time
-- we'd have to make sure we resolve style for text nodes when named ranges apply

That'd be a pretty big project.
::-moz-range(blah) could work like ::-moz-selection, presumably.
QA Contact: ian
Blocks: 256990
Blocks: 260131
I intend to fix bug 263683 by doing something like this bug but simpler: add a new selection type, much like how inline spellchecking is done.  This doesn't require any of the crazy style system wizardry in comment #1.  I suppose one could provide an API for this if needed.
A lot of what I wrote in comment #1 was bogus. We already support many selection types; making that indefinitely extensible shouldn't be hard.

pkasting: for your needs, feel free to go ahead and add one more selection type. When that's done, you might have some ideas for how to make it truly extensible :-).
QA Contact: ian
Blocks: 263683
Depends on: 443431
Any status update for this bug?
Priority: P1 → --
It seems to me this is "-- an API for extensible selection types" in list of the items to work on post-1.9.1, that was discussed in the layout meeting at the summit: http://groups.google.com/group/mozilla.dev.tech.layout/browse_thread/thread/3421bf91696f4b08#
Blocks: 451833
No longer blocks: 240432
No longer blocks: 256990, 260131
Summary: Gecko should support highlighting of multiple ranges that are not the selection → Gecko should support highlighting of multiple ranges that are not the selection (multiple styleable selections)
Assignee: selection → nobody
QA Contact: selection
No longer blocks: 451833
Blocks: 683811
You need to log in before you can comment on or make changes to this bug.