TextNodeRegistry.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Doug Terry, June 26, 1987 2:58:55 pm PDT
The rules regarding legal transformations are as follows:
— A node may transform into one or more sibling nodes,
— A node may not be deleted by a transformation,
— The transformation procedure is responsible for making any necessary changes in the document tree, i.e. reestablishing proper child and next links for new nodes; these changes must obey the previous two rules,
— An active node may transform into another active node, however, in this case, the new active node may been seen by clients; the transformation on it will not occur until the next time the node is requested.
~
BEGIN
Ref: TYPE ~ TextNode.Ref;
TransformProc:
TYPE ~
PROC [node: Ref, parent: Ref, wantFirst:
BOOLEAN, clientData:
REF
ANY]
RETURNS [new: Ref];
Performs a transformation on the given node and returns the resulting node. If the transformation results in more than one new node then the first new node is returned if wantFirst=TRUE, otherwise the last new node is returned.
SizeProc:
TYPE ~
PROC [node: Ref, clientData:
REF
ANY]
RETURNS [size:
INT];
Computes or estimates the size that the given node will be AFTER it is transformed.
ActivityProc:
TYPE ~
PROC [on:
BOOLEAN, clientData:
REF
ANY]
RETURNS [];
Informs clients whether or not the registered transformations should be currently applied.
ProcSet: TYPE = REF ProcSetRec;
ProcSetRec:
TYPE =
RECORD[
activityOn: BOOLEAN ← FALSE,
transformProc: TransformProc ← NIL,
transformProcData: REF ANY ← NIL,
sizeProc: SizeProc ← NIL,
sizeProcData: REF ANY ← NIL,
activityProc: ActivityProc ← NIL,
activityProcData: REF ANY ← NIL];
Register:
PROC [activity:
ATOM, procs: ProcSet]
RETURNS [];
The given TransformProc will hereafter be applied to all nodes having an active property with value=activity.
UnRegister:
PROC [activity:
ATOM]
RETURNS [];
Removes the procedures associated with the given activity.
GetProcs:
PROC[activity:
ATOM]
RETURNS [procs: ProcSet];
Return the procedures associated with the given activity.
ActivityOn:
PROC [activity:
ATOM, on:
BOOLEAN ←
TRUE]
RETURNS [wasOn:
BOOLEAN];
Determines whether or not the registered transformations should be currently applied; if activity=NIL then activity is turned on/off for all registered clients. Registered clients are informed via callbacks when this switch is toggled so they can take appropriate action.
DoTransform:
PROC [activity:
ATOM, node: Ref, parent: Ref ←
NIL, wantFirst:
BOOLEAN ←
TRUE]
RETURNS [new: Ref];
Force the TransformProc associated with the given activity to be applied to the node. (This is intended primarily for use by TextNodeImpl.)
GetSize:
PROC [activity:
ATOM, node: Ref]
RETURNS [size:
INT];
Computes or estimates the size that the given node will be AFTER it is transformed by the specified activity. (This is intended primarily for use by TextNodeImpl.)