Class: Gammo::Parser::InFrameset

Inherits:
InsertionMode show all
Defined in:
lib/gammo/parser/insertion_mode/in_frameset.rb

Overview

Section 12.2.6.4.20.

Instance Attribute Summary

Attributes inherited from InsertionMode

#parser

Instance Method Summary collapse

Methods inherited from InsertionMode

#initialize, #process

Constructor Details

This class inherits a constructor from Gammo::Parser::InsertionMode

Instance Method Details

#character_token(token) ⇒ Object



9
10
11
12
# File 'lib/gammo/parser/insertion_mode/in_frameset.rb', line 9

def character_token(token)
  text = token.data.each_char.with_object(String.new) { |c, s| s << c if c == ?\s }
  parser.add_text(text) if text != ''
end

#comment_token(token) ⇒ Object



5
6
7
# File 'lib/gammo/parser/insertion_mode/in_frameset.rb', line 5

def comment_token(token)
  parser.add_child Node::Comment.new(data: token.data)
end

#default(_) ⇒ Object



42
43
44
45
# File 'lib/gammo/parser/insertion_mode/in_frameset.rb', line 42

def default(_)
  # ignore the token
  halt true
end

#end_tag_token(token) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gammo/parser/insertion_mode/in_frameset.rb', line 29

def end_tag_token(token)
  case token.tag
  when Tags::Frameset
    if parser.open_elements.last.tag != Tags::Html
      parser.open_elements.pop
      if parser.open_elements.last.tag != Tags::Frameset
        parser.insertion_mode = AfterFrameset
        halt true
      end
    end
  end
end

#start_tag_token(token) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gammo/parser/insertion_mode/in_frameset.rb', line 14

def start_tag_token(token)
  case token.tag
  when Tags::Html
    halt InBody.new(parser).process
  when Tags::Frameset
    parser.add_element
  when Tags::Frame
    parser.add_element
    parser.open_elements.pop
    parser.acknowledge_self_closing_tag
  when Tags::Noframes
    halt InHead.new(parser).process
  end
end