2007-07-05 00:36:59 +02:00
|
|
|
require 'html5/html5parser/phase'
|
2007-05-30 17:45:52 +02:00
|
|
|
|
2007-07-05 00:36:59 +02:00
|
|
|
module HTML5
|
2007-05-30 17:45:52 +02:00
|
|
|
class RootElementPhase < Phase
|
|
|
|
|
|
|
|
def processEOF
|
|
|
|
insertHtmlElement
|
|
|
|
@parser.phase.processEOF
|
|
|
|
end
|
|
|
|
|
|
|
|
def processComment(data)
|
|
|
|
@tree.insertComment(data, @tree.document)
|
|
|
|
end
|
|
|
|
|
|
|
|
def processSpaceCharacters(data)
|
|
|
|
@tree.insertText(data, @tree.document)
|
|
|
|
end
|
|
|
|
|
|
|
|
def processCharacters(data)
|
|
|
|
insertHtmlElement
|
|
|
|
@parser.phase.processCharacters(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def processStartTag(name, attributes)
|
|
|
|
@parser.firstStartTag = true if name == 'html'
|
|
|
|
insertHtmlElement
|
|
|
|
@parser.phase.processStartTag(name, attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
def processEndTag(name)
|
|
|
|
insertHtmlElement
|
|
|
|
@parser.phase.processEndTag(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def insertHtmlElement
|
|
|
|
element = @tree.createElement('html', {})
|
|
|
|
@tree.openElements.push(element)
|
|
|
|
@tree.document.appendChild(element)
|
|
|
|
@parser.phase = @parser.phases[:beforeHead]
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|