An HTML reader to load an HTML document with an HTML
element structure. This is a set of callbacks from
the parser, implemented to create a set of elements
tagged with attributes. The parse builds up tokens
(ElementSpec) that describe the element subtree desired,
and burst it into the document under the protection of
a write lock using the insert method on the document
outer class.

The reader can be configured by registering actions
(of type HTMLDocument.HTMLReader.TagAction)
that describe how to handle the action. The idea behind
the actions provided is that the most natural text editing
operations can be provided if the element structure boils
down to paragraphs with runs of some kind of style
in them. Some things are more naturally specified
structurally, so arbitrary structure should be allowed
above the paragraphs, but will need to be edited with structural
actions. The implication of this is that some of the
HTML elements specified in the stream being parsed will
be collapsed into attributes, and in some cases paragraphs
will be synthesized. When HTML elements have been
converted to attributes, the attribute key will be of
type HTML.Tag, and the value will be of type AttributeSet
so that no information is lost. This enables many of the
existing actions to work so that the user can type input,
hit the return key, backspace, delete, etc and have a
reasonable result. Selections can be created, and attributes
applied or removed, etc. With this in mind, the work done
by the reader can be categorized into the following kinds
of tasks:

Block

Build the structure like it's specified in the stream.
This produces elements that contain other elements.

Paragraph

Like block except that it's expected that the element
will be used with a paragraph view so a paragraph element
won't need to be synthesized.

Character

Contribute the element as an attribute that will start
and stop at arbitrary text locations. This will ultimately
be mixed into a run of text, with all of the currently
flattened HTML character elements.

Special

Produce an embedded graphical element.

Form

Produce an element that is like the embedded graphical
element, except that it also has a component model associated
with it.

Hidden

Create an element that is hidden from view when the
document is being viewed read-only, and visible when the
document is being edited. This is useful to keep the
model from losing information, and used to store things
like comments and unrecognized tags.

HTMLDocument.HTMLReader

Method Detail

flush

The last method called on the reader. It allows
any pending changes to be flushed into the document.
Since this is currently loading synchronously, the entire
set of changes are pushed in at this point.

registerTag

Registers a handler for the given tag. By default
all of the well-known tags will have been registered.
This can be used to change the handling of a particular
tag or to add support for custom tags.

pushCharacterStyle

protected void pushCharacterStyle()

Pushes the current character style on a stack in preparation
for forming a new nested character style.

popCharacterStyle

protected void popCharacterStyle()

Pops a previously pushed character style off the stack
to return to a previous style.

textAreaContent

protected void textAreaContent(char[] data)

Adds the given content to the textarea document.
This method gets called when we are in a textarea
context. Therefore all text that is seen belongs
to the text area and is hence added to the
TextAreaDocument associated with the text area.

preContent

protected void preContent(char[] data)

Adds the given content that was encountered in a
PRE element. This synthesizes lines to hold the
runs of text, and makes calls to addContent to
actually add the text.