BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
RemexHtml\TreeBuilder\Dispatcher Class Reference
Inheritance diagram for RemexHtml\TreeBuilder\Dispatcher:
Collaboration diagram for RemexHtml\TreeBuilder\Dispatcher:

Public Member Functions

 __construct (TreeBuilder $builder)
 
 switchMode ($mode)
 
 switchAndSave ($mode)
 
 restoreMode ()
 
 getHandler ()
 
 isInTableMode ()
 
 reset ()
 
 startDocument (Tokenizer $tokenizer, $namespace, $name)
 
 endDocument ($pos)
 
 error ($text, $pos)
 
 characters ($text, $start, $length, $sourceStart, $sourceLength)
 
 startTag ($name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength)
 
 endTag ($name, $sourceStart, $sourceLength)
 
 doctype ($name, $public, $system, $quirks, $sourceStart, $sourceLength)
 
 comment ($text, $sourceStart, $sourceLength)
 

Public Attributes

const INITIAL = 1
 
const BEFORE_HTML = 2
 
const BEFORE_HEAD = 3
 
const IN_HEAD = 4
 
const IN_HEAD_NOSCRIPT = 5
 
const AFTER_HEAD = 6
 
const IN_BODY = 7
 
const TEXT = 8
 
const IN_TABLE = 9
 
const IN_TABLE_TEXT = 10
 
const IN_CAPTION = 11
 
const IN_COLUMN_GROUP = 12
 
const IN_TABLE_BODY = 13
 
const IN_ROW = 14
 
const IN_CELL = 15
 
const IN_SELECT = 16
 
const IN_SELECT_IN_TABLE = 17
 
const IN_TEMPLATE = 18
 
const AFTER_BODY = 19
 
const IN_FRAMESET = 20
 
const AFTER_FRAMESET = 21
 
const AFTER_AFTER_BODY = 22
 
const AFTER_AFTER_FRAMESET = 23
 
const IN_FOREIGN_CONTENT = 24
 
const IN_PRE = 25
 
const IN_TEXTAREA = 26
 
 $inHead
 
 $inBody
 
 $inTable
 
 $inSelect
 
 $inTemplate
 
 $inForeign
 
 $ack
 
 $templateModeStack
 

Protected Member Functions

 getAppropriateMode ()
 
 dispatcherCurrentNode ()
 

Protected Attributes

 $builder
 
 $handler
 
 $dispatchTable
 
 $mode
 
 $originalMode
 

Static Protected Attributes

static $handlerClasses
 

Detailed Description

This is the approximate equivalent of the "tree construction dispatcher" in the spec. It receives token events and distributes them to the appropriate insertion mode class. It also implements some things specific to the dispatcher state:

  • "Reset the insertion mode appropriately"
  • The stack of template insertion modes
  • The "original insertion mode"

Constructor & Destructor Documentation

RemexHtml\TreeBuilder\Dispatcher::__construct ( TreeBuilder  $builder)
Parameters
TreeBuilder$builder

Member Function Documentation

RemexHtml\TreeBuilder\Dispatcher::characters (   $text,
  $start,
  $length,
  $sourceStart,
  $sourceLength 
)

A merged sequence of character tokens. We use the SAX-like convention of requiring the handler to do the substring operation, i.e. the actual text is substr( $text, $start, $length ), since this allows us to avoid some copying, at least if ignoreCharRefs and ignoreNulls are enabled.

Parameters
string$textThe string which contains the emitted characters
integer$startThe start of the range within $text to use
integer$lengthThe length of the range within $text to use
integer$sourceStartThe input position
integer$sourceLengthThe input length

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::comment (   $text,
  $sourceStart,
  $sourceLength 
)

A comment.

Parameters
string$textThe inner text of the comment
integer$sourceStartThe input position
integer$sourceLengthThe input length

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::dispatcherCurrentNode ( )
protected

If the stack of open elements is empty, return null, otherwise return the adjusted current node.

RemexHtml\TreeBuilder\Dispatcher::doctype (   $name,
  $public,
  $system,
  $quirks,
  $sourceStart,
  $sourceLength 
)

A DOCTYPE declaration

Parameters
string | null$nameThe DOCTYPE name, or null if none was found
string | null$publicThe public identifier, or null if none was found
string | null$systemThe system identifier, or null if none was found
bool$quirksWhat the spec calls the "force-quirks flag"
integer$sourceStartThe input position
integer$sourceLengthThe input length

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::endDocument (   $pos)

Called when the end of the input string is consumed

Parameters
integer$posThe input position (past the end)

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::endTag (   $name,
  $sourceStart,
  $sourceLength 
)

An end tag event.

Parameters
string$nameThe tag name
integer$sourceStartThe input position
integer$sourceLengthThe input length

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::error (   $text,
  $pos 
)

This is called for "parse errors" (as defined by the spec). The spec does not define names for error messages, so we just use some English text for now. The imagined audience is a developer reading validator output.

Parameters
string$textThe error message
integer$posThe input position

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::getAppropriateMode ( )
protected

Get the insertion mode index which is switched to when we reset the insertion mode appropriately.

Returns
integer
RemexHtml\TreeBuilder\Dispatcher::getHandler ( )

Get the handler for the current insertion mode in HTML content. This is used by the "in foreign" handler to execute the HTML insertion mode. It does not necessarily correspond to the handler currently being executed.

Returns
InsertionMode
RemexHtml\TreeBuilder\Dispatcher::isInTableMode ( )

True if we are in a table mode, for the purposes of switching to IN_SELECT_IN_TABLE as opposed to IN_SELECT.

Returns
bool
RemexHtml\TreeBuilder\Dispatcher::reset ( )

Reset the insertion mode appropriately, and return the new handler.

Returns
InsertionMode
RemexHtml\TreeBuilder\Dispatcher::restoreMode ( )

Switch the insertion mode to the original insertion mode and return the new handler.

Returns
InsertionMode
RemexHtml\TreeBuilder\Dispatcher::startDocument ( Tokenizer  $tokenizer,
  $fragmentNamespace,
  $fragmentName 
)

Called once at the start of the document (STATE_START)

Parameters
Tokenizer$tokenizerThe Tokenizer which generated the event
string | null$fragmentNamespaceThe fragment namespace, or null to run in document mode.
string | null$fragmentNameThe fragment tag name, or null to run in document mode.

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::startTag (   $name,
Attributes  $attrs,
  $selfClose,
  $sourceStart,
  $sourceLength 
)

A start tag event. We call it a tag rather than an element since the start/end events are not balanced, so the relationship between tags and elements is complex. Errors emitted by attribute parsing will be not be received until $attrs is accessed by the handler.

Parameters
string$nameThe tag name
Attributes$attrsThe tag attributes
bool$selfCloseWhether there is a self-closing slash
integer$sourceStartThe input position
integer$sourceLengthThe input length

Implements RemexHtml\Tokenizer\TokenHandler.

RemexHtml\TreeBuilder\Dispatcher::switchAndSave (   $mode)

Let the original insertion mode be the current insertion mode, and switch the insertion mode to some new value. Return the new handler.

Parameters
integer$mode
Returns
InsertionMode
RemexHtml\TreeBuilder\Dispatcher::switchMode (   $mode)

Switch the insertion mode, and return the new handler

Parameters
integer$mode
Returns
InsertionMode

Member Data Documentation

RemexHtml\TreeBuilder\Dispatcher::$ack

The insertion mode sets this to true to acknowledge the tag's self-closing flag.

RemexHtml\TreeBuilder\Dispatcher::$dispatchTable
protected

An array mapping insertion mode indexes to InsertionMode objects

RemexHtml\TreeBuilder\Dispatcher::$handler
protected

The InsertionMode object for the current insertion mode in HTML content

RemexHtml\TreeBuilder\Dispatcher::$handlerClasses
staticprotected
Initial value:
= [
self::INITIAL => Initial::class

The handler class for each insertion mode

RemexHtml\TreeBuilder\Dispatcher::$mode
protected

The insertion mode index

RemexHtml\TreeBuilder\Dispatcher::$originalMode
protected

The "original insertion mode" index

const RemexHtml\TreeBuilder\Dispatcher::INITIAL = 1

The insertion mode indexes


The documentation for this class was generated from the following file: