Closed Bug 234493 Opened 22 years ago Closed 10 years ago

Tracking editor hooks that we're missing

Categories

(Core Graveyard :: Tracking, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: bzbarsky, Assigned: chofmann)

References

(Blocks 1 open bug)

Details

This is for tracking and discussion of hooks into layout that editor wants but doesn't have. One idea that's been floated is that we provide hooks into places like the CSS parser and the HTML parser so that any time a content object (rule, content node, whatever) is created/processed/whatever editor can be notified about the new object and the corresponding character offsets in the original source. Then editor can keep out-of-band information about the original text corresponding to objects and the serializers can use this when serializing. The goal would be to have minimal impact on performance of gecko in non-editor mode and pretty much zero impact on footprint (codesize excepted :() of gecko in non-editor mode.
jst came up with a darn neat hack. When a document is parsed for editor we could store the string-representation of all elements in an attribute in resp. element. I.e. we would have a __moz_tag_string attribute that contains a string of what the tag looked like in the markup. Actually we might want to have both __moz_starttag_string and __moz_endtag_string so that casing and whitespace is preserved for both start and endtag. The serializer could then look for these attributes and use those rather then manually serializing the element when available. So all editor would have to do is to remove these attributes when modifying an element. Of course, the big problem of hooking into the html-parser to retrieve the stringrepresentation of a tag still remains. But the hook into the serializer gets to be very smooth. Would there be any security concerns with this? The fact that a webpage can control how it's serialized? This might affect how 'save page as' saved pages gets serialized. If so, we could have a flag in the serializer so that only when editor serializes a page we look for these attributes.
We could also have those two strings be just internal things, instead of putting them in the attribute map, and hide them from Web pages. As in, attribute DOMString __moz_start_tag; attribute DOMString __moz_end_tag; ...but only for internal users or something. I feel somewhat dubious about putting this into the attribute map as that would have the same problems as our __moz_unknown attribute or whatever it is called, which occasionally appears in the middle of nowhere for no apparent reason (as far as authors are concerned).
These attributes would only be set when the page was used in editor so it should never affect webpages. However I'm starting to have second throughts on that solution anyhow since it can only be used for elements and not textnodes or comments.
Maybe a better solution would be an internal API (think nsIContent) to these things and these things would be stored in a hash table, and only when loading for the editor. That way, there's nothing exposed to web pages, and there's no penalty for non-editor content, and it would work on all types of nodes (that implement nsIContent).
If we can make this things available from untrusted script without hurting security or performance, that would be good. I've been working with "remote" editor widgets, and you can do pretty much all composer functionality from remote script.
Before everyone gets too carried away here let me just say that the hard part of fixing this bug is not which API we use to expose this information. The hard part is adding code to the html and css parser that gathers the information. Especially doing that in such a way that it won't affect performance of normal webbrowsing. Once that is done storing and exposing the information through any API, weather its nsIContent, __moz_XXX attributes, or scriptable interfaces somewhere, will be pretty easy.
Marking all tracking bugs which haven't been updated since 2014 as INCOMPLETE. If this bug is still relevant, please reopen it and move it into a bugzilla component related to the work being tracked. The Core: Tracking component will no longer be used.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INCOMPLETE
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.