Class: HTML5::InBodyPhase

Inherits:
Phase
  • Object
show all
Defined in:
lib/html5/html5parser/in_body_phase.rb

Instance Method Summary collapse

Methods inherited from Phase

#adjust_foreign_attributes, #adjust_mathml_attributes, #assert, end_tag_handlers, handle_end, handle_start, #in_scope?, #processComment, #processDoctype, #processEndTag, #processStartTag, #process_eof, #remove_open_elements_until, #startTagHtml, start_tag_handlers, tag_handlers

Constructor Details

#initialize(parser, tree) ⇒ InBodyPhase

Returns a new instance of InBodyPhase.



52
53
54
55
56
57
58
59
# File 'lib/html5/html5parser/in_body_phase.rb', line 52

def initialize(parser, tree)
  super(parser, tree)

  # for special handling of whitespace in <pre>
  class << self
    alias processSpaceCharactersNonPre processSpaceCharacters
  end
end

Instance Method Details

#endTagAppletButtonMarqueeObject(name) ⇒ Object



558
559
560
561
562
563
564
565
566
567
568
569
570
# File 'lib/html5/html5parser/in_body_phase.rb', line 558

def endTagAppletButtonMarqueeObject(name)
  @tree.generateImpliedEndTags if in_scope?(name)

  unless @tree.open_elements.last.name == name
    parse_error("end-tag-too-early", {"name" => name})
  end

  if in_scope?(name)
    remove_open_elements_until(name)

    @tree.clearActiveFormattingElements
  end
end

#endTagBlock(name) ⇒ Object



391
392
393
394
395
396
397
398
399
400
401
# File 'lib/html5/html5parser/in_body_phase.rb', line 391

def endTagBlock(name)
  @tree.generateImpliedEndTags if in_scope?(name)

  unless @tree.open_elements.last.name == name
    parse_error("end-tag-too-early", {"name" => name})
  end

  if in_scope?(name)
    remove_open_elements_until(name)
  end
end

#endTagBody(name) ⇒ Object



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/html5/html5parser/in_body_phase.rb', line 369

def endTagBody(name)
  # XXX Need to take open <p> tags into account here. We shouldn't imply
  # </p> but we should not throw a parse error either. Specification is
  # likely to be updated.
  unless @tree.open_elements[1] && @tree.open_elements[1].name == 'body'
    # inner_html case
    parse_error "unexpected-end-tag", {:name => 'body'}
    return
  end
  unless @tree.open_elements.last.name == 'body'
    parse_error("expected-one-end-tag-but-got-another",
            {"expectedName" => "body",
             "gotName" => @tree.open_elements.last.name})
  end
  @parser.phase = @parser.phases[:afterBody]
end

#endTagBr(name) ⇒ Object



577
578
579
580
581
582
583
# File 'lib/html5/html5parser/in_body_phase.rb', line 577

def endTagBr(name)
  parse_error("unexpected-end-tag-treated-as",
        {"originalName" => "br", "newName" => "br element"})
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, {})
  @tree.open_elements.pop()
end

#endTagCdataTextAreaXmp(name) ⇒ Object



590
591
592
593
594
595
596
# File 'lib/html5/html5parser/in_body_phase.rb', line 590

def endTagCdataTextAreaXmp(name)
  if @tree.open_elements.last.name == name
    @tree.open_elements.pop
  else
    parse_error("unexpected-end-tag", {"name" => name})
  end
end

#endTagForm(name) ⇒ Object



403
404
405
406
407
408
409
410
411
412
413
# File 'lib/html5/html5parser/in_body_phase.rb', line 403

def endTagForm(name)
  @tree.formPointer = nil
  if !in_scope?(name)
    # parse error
  else
    @tree.generateImpliedEndTags
    parse_error("end-tag-too-early-ignored", {"name" => "form"}) if @tree.open_elements.last.name != name
    until name == @tree.open_elements.pop.name
    end
  end
end

#endTagFormatting(name) ⇒ Object

The much-feared adoption agency algorithm



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/html5/html5parser/in_body_phase.rb', line 447

def endTagFormatting(name)
  # http://www.whatwg.org/specs/web-apps/current-work/#adoptionAgency
  # XXX Better parse_error messages appreciated.
  while true
    # Step 1 paragraph 1
    afeElement = @tree.elementInActiveFormattingElements(name)
    if !afeElement or (@tree.open_elements.include?(afeElement) && !in_scope?(afeElement.name))
      parse_error("adoption-agency-1.1", {"name" => name})
      return
    # Step 1 paragraph 2
    elsif not @tree.open_elements.include?(afeElement)
      parse_error("adoption-agency-1.2", {"name" => name})
      @tree.activeFormattingElements.delete(afeElement)
      return
    end

    # Step 1 paragraph 3
    if afeElement != @tree.open_elements.last
      parse_error("adoption-agency-1.3", {"name" => name})
    end

    # Step 2
    # Start of the adoption agency algorithm proper
    afeIndex = @tree.open_elements.index(afeElement)
    furthestBlock = nil
    @tree.open_elements[afeIndex..-1].each do |element|
      if (SPECIAL_ELEMENTS + SCOPING_ELEMENTS).include?(element.name)
        furthestBlock = element
        break
      end
    end

    # Step 3
    if furthestBlock.nil?
      element = remove_open_elements_until {|el| el == afeElement }
      @tree.activeFormattingElements.delete(element)
      return
    end
    commonAncestor = @tree.open_elements[afeIndex - 1]

    # Step 5
    furthestBlock.parent.removeChild(furthestBlock) if furthestBlock.parent

    # Step 6
    # The bookmark is supposed to help us identify where to reinsert
    # nodes in step 12. We have to ensure that we reinsert nodes after
    # the node before the active formatting element. Note the bookmark
    # can move in step 7.4
    bookmark = @tree.activeFormattingElements.index(afeElement)

    # Step 7
    lastNode = node = furthestBlock
    while true
      # AT replace this with a function and recursion?
      # Node is element before node in open elements
      node = @tree.open_elements[@tree.open_elements.index(node) - 1]
      until @tree.activeFormattingElements.include?(node)
        tmpNode = node
        node = @tree.open_elements[@tree.open_elements.index(node) - 1]
        @tree.open_elements.delete(tmpNode)
      end
      # Step 7.3
      break if node == afeElement
      # Step 7.4
      if lastNode == furthestBlock
        # XXX should this be index(node) or index(node)+1
        # Anne: I think +1 is ok. Given x = [2,3,4,5]
        # x.index(3) gives 1 and then x[1 +1] gives 4...
        bookmark = @tree.activeFormattingElements.index(node) + 1
      end
      # Step 7.5
      cite = node.parent
      if node.hasContent
        clone = node.cloneNode
        # Replace node with clone
        @tree.activeFormattingElements[@tree.activeFormattingElements.index(node)] = clone
        @tree.open_elements[@tree.open_elements.index(node)] = clone
        node = clone
      end
      # Step 7.6
      # Remove lastNode from its parents, if any
      lastNode.parent.removeChild(lastNode) if lastNode.parent
      node.appendChild(lastNode)
      # Step 7.7
      lastNode = node
      # End of inner loop
    end

    # Step 8
    lastNode.parent.removeChild(lastNode) if lastNode.parent
    commonAncestor.appendChild(lastNode)

    # Step 9
    clone = afeElement.cloneNode

    # Step 10
    furthestBlock.reparentChildren(clone)

    # Step 11
    furthestBlock.appendChild(clone)

    # Step 12
    @tree.activeFormattingElements.delete(afeElement)
    @tree.activeFormattingElements.insert([bookmark,@tree.activeFormattingElements.length].min, clone)

    # Step 13
    @tree.open_elements.delete(afeElement)
    @tree.open_elements.insert(@tree.open_elements.index(furthestBlock) + 1, clone)
  end
end

#endTagHeading(name) ⇒ Object



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/html5/html5parser/in_body_phase.rb', line 426

def endTagHeading(name)
  HEADING_ELEMENTS.each do |element|
    if in_scope?(element)
      @tree.generateImpliedEndTags
      break
    end
  end

  unless @tree.open_elements.last.name == name
    parse_error("end-tag-too-early", {"name" => name})
  end

  HEADING_ELEMENTS.each do |element|
    if in_scope?(element)
      remove_open_elements_until {|el| HEADING_ELEMENTS.include?(el.name)}
      break
    end
  end
end

#endTagHtml(name) ⇒ Object



386
387
388
389
# File 'lib/html5/html5parser/in_body_phase.rb', line 386

def endTagHtml(name)
  endTagBody(name)
  @parser.phase.processEndTag(name) unless @parser.inner_html
end

#endTagListItem(name) ⇒ Object



415
416
417
418
419
420
421
422
423
424
# File 'lib/html5/html5parser/in_body_phase.rb', line 415

def endTagListItem(name)
  # AT Could merge this with the Block case
  @tree.generateImpliedEndTags(name) if in_scope?(name)

  unless @tree.open_elements.last.name == name
    parse_error("end-tag-too-early", {"name" => name})
  end

  remove_open_elements_until(name) if in_scope?(name)
end

#endTagMisplaced(name) ⇒ Object



572
573
574
575
# File 'lib/html5/html5parser/in_body_phase.rb', line 572

def endTagMisplaced(name)
  # This handles elements with end tags in other insertion modes.
  parse_error("unexpected-end-tag", {"name" => name})
end

#endTagNew(name) ⇒ Object



598
599
600
601
602
603
604
# File 'lib/html5/html5parser/in_body_phase.rb', line 598

def endTagNew(name)
  # New HTML5 elements, "event-source", "section", "nav",
  # "article", "aside", "header", "footer", "datagrid", "command"
  # STDERR.puts "Warning: Undefined behaviour for end tag #{name}"
  endTagOther(name)
  #raise NotImplementedError
end

#endTagNone(name) ⇒ Object



585
586
587
588
# File 'lib/html5/html5parser/in_body_phase.rb', line 585

def endTagNone(name)
  # This handles elements with no end tag.
  parse_error("no-end-tag", {"name" => name})
end

#endTagOther(name) ⇒ Object



606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
# File 'lib/html5/html5parser/in_body_phase.rb', line 606

def endTagOther(name)
  # XXX This logic should be moved into the treebuilder
  @tree.open_elements.reverse.each do |node|
    if node.name == name
      @tree.generateImpliedEndTags

      unless @tree.open_elements.last.name == name
        parse_error("unexpected-end-tag", {"name" => name})
      end

      remove_open_elements_until {|element| element == node }

      break
    else
      if (SPECIAL_ELEMENTS + SCOPING_ELEMENTS).include?(node.name)
        parse_error("unexpected-end-tag", {"name" => name})
        break
      end
    end
  end
end

#endTagP(name) ⇒ Object



358
359
360
361
362
363
364
365
366
367
# File 'lib/html5/html5parser/in_body_phase.rb', line 358

def endTagP(name)
  @tree.generateImpliedEndTags('p') if in_scope?('p')
  parse_error("unexpected-end-tag", {"name" => "p"}) unless @tree.open_elements.last.name == 'p'
  if in_scope?('p')
    @tree.open_elements.pop while in_scope?('p')
  else
    startTagCloseP('p', {})
    endTagP('p')
  end
end

#processCharacters(data) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/html5/html5parser/in_body_phase.rb', line 85

def processCharacters(data)
  # XXX The specification says to do this for every character at the
  # moment, but apparently that doesn't match the real world so we don't
  # do it for space characters.
  @tree.reconstructActiveFormattingElements
  @tree.insertText(data)
end

#processSpaceCharacters(data) ⇒ Object



80
81
82
83
# File 'lib/html5/html5parser/in_body_phase.rb', line 80

def processSpaceCharacters(data)
  @tree.reconstructActiveFormattingElements()
  @tree.insertText(data)
end

#processSpaceCharactersDropNewline(data) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/html5/html5parser/in_body_phase.rb', line 61

def processSpaceCharactersDropNewline(data)
  # #Sometimes (start of <pre> blocks) we want to drop leading newlines

  class << self
    remove_method :processSpaceCharacters rescue nil
    alias processSpaceCharacters processSpaceCharactersNonPre
  end
  
  if (data.length > 0 and data[0] == ?\n && 
    %w[listing pre textarea].include?(@tree.open_elements.last.name) && !@tree.open_elements.last.hasContent)
    data = data[1..-1]
  end

  if data.length > 0
    @tree.reconstructActiveFormattingElements
    @tree.insertText(data)
  end
end

#startTagA(name, attributes) ⇒ Object



182
183
184
185
186
187
188
189
190
191
# File 'lib/html5/html5parser/in_body_phase.rb', line 182

def startTagA(name, attributes)
  if afeAElement = @tree.elementInActiveFormattingElements('a')
    parse_error("unexpected-start-tag-implies-end-tag", {"startName" => "a", "endName" => "a"})
    endTagFormatting('a')
    @tree.open_elements.delete(afeAElement) if @tree.open_elements.include?(afeAElement)
    @tree.activeFormattingElements.delete(afeAElement) if @tree.activeFormattingElements.include?(afeAElement)
  end
  @tree.reconstructActiveFormattingElements
  addFormattingElement(name, attributes)
end

#startTagAppletMarqueeObject(name, attributes) ⇒ Object



221
222
223
224
225
# File 'lib/html5/html5parser/in_body_phase.rb', line 221

def startTagAppletMarqueeObject(name, attributes)
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, attributes)
  @tree.activeFormattingElements.push(Marker)
end

#startTagBody(name, attributes) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/html5/html5parser/in_body_phase.rb', line 97

def startTagBody(name, attributes)
  parse_error("unexpected-start-tag", {"name" => "body"})

  if @tree.open_elements.length == 1 || @tree.open_elements[1].name != 'body'
    assert @parser.inner_html
  else
    attributes.each do |attr, value|
      unless @tree.open_elements[1].attributes.has_key?(attr)
        @tree.open_elements[1].attributes[attr] = value
      end
    end
  end
end

#startTagButton(name, attributes) ⇒ Object



209
210
211
212
213
214
215
216
217
218
219
# File 'lib/html5/html5parser/in_body_phase.rb', line 209

def startTagButton(name, attributes)
  if in_scope?('button')
    parse_error("unexpected-start-tag-implies-end-tag", {"startName" => "button", "endName" => "button"})
    processEndTag('button')
    @parser.phase.processStartTag(name, attributes)
  else
    @tree.reconstructActiveFormattingElements
    @tree.insert_element(name, attributes)
    @tree.activeFormattingElements.push(Marker)
  end
end

#startTagCdata(name, attributes) ⇒ Object

iframe, noembed noframes, noscript(if scripting enabled)



296
297
298
299
# File 'lib/html5/html5parser/in_body_phase.rb', line 296

def startTagCdata(name, attributes)
  @tree.insert_element(name, attributes)
  @parser.tokenizer.content_model_flag = :CDATA
end

#startTagCloseP(name, attributes) ⇒ Object



111
112
113
114
115
116
117
118
119
120
# File 'lib/html5/html5parser/in_body_phase.rb', line 111

def startTagCloseP(name, attributes)
  endTagP('p') if in_scope?('p')
  @tree.insert_element(name, attributes)
  if ['pre', 'listing'].include?(name) 
    class << self
      remove_method :processSpaceCharacters rescue nil
      alias processSpaceCharacters processSpaceCharactersDropNewline
    end
  end
end

#startTagForeignContent(name, attributes) ⇒ Object



344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/html5/html5parser/in_body_phase.rb', line 344

def startTagForeignContent(name, attributes)
  @tree.reconstructActiveFormattingElements
  attributes = adjust_mathml_attributes(attributes)
  attributes = adjust_foreign_attributes(attributes)
  @tree.insert_foreign_element(name, attributes, :math)
  if false
    # If the token has its self-closing flag set, pop the current node off the stack
    #  of open elements and acknowledge the token's self-closing flag.
  else
    @parser.secondary_phase = @parser.phase
    @parser.phase = @parser.phases[:inForeignContent]
  end
end

#startTagForm(name, attributes) ⇒ Object



122
123
124
125
126
127
128
129
130
# File 'lib/html5/html5parser/in_body_phase.rb', line 122

def startTagForm(name, attributes)
  if @tree.formPointer
    parse_error("unexpected-start-tag", {"name" => name})
  else
    endTagP('p') if in_scope?('p')
    @tree.insert_element(name, attributes)
    @tree.formPointer = @tree.open_elements.last
  end
end

#startTagFormatting(name, attributes) ⇒ Object



193
194
195
196
# File 'lib/html5/html5parser/in_body_phase.rb', line 193

def startTagFormatting(name, attributes)
  @tree.reconstructActiveFormattingElements
  addFormattingElement(name, attributes)
end

#startTagHeading(name, attributes) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/html5/html5parser/in_body_phase.rb', line 164

def startTagHeading(name, attributes)
  endTagP('p') if in_scope?('p')

  # Uncomment the following for IE7 behavior:
  # HEADING_ELEMENTS.each do |element|
  #   if in_scope?(element)
  #     parse_error("unexpected-start-tag", {"name" => name})
  # 
  #     remove_open_elements_until do |element|
  #       HEADING_ELEMENTS.include?(element.name)
  #     end
  #
  #     break
  #   end
  # end
  @tree.insert_element(name, attributes)
end

#startTagHr(name, attributes) ⇒ Object



245
246
247
248
249
# File 'lib/html5/html5parser/in_body_phase.rb', line 245

def startTagHr(name, attributes)
  endTagP('p') if in_scope?('p')
  @tree.insert_element(name, attributes)
  @tree.open_elements.pop
end

#startTagImage(name, attributes) ⇒ Object



251
252
253
254
255
# File 'lib/html5/html5parser/in_body_phase.rb', line 251

def startTagImage(name, attributes)
  # No really...
  parse_error("unexpected-start-tag-treated-as", {"originalName" => "image", "newName" => "img"})
  processStartTag('img', attributes)
end

#startTagInput(name, attributes) ⇒ Object



257
258
259
260
261
262
263
264
265
# File 'lib/html5/html5parser/in_body_phase.rb', line 257

def startTagInput(name, attributes)
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, attributes)
  if @tree.formPointer
    # XXX Not exactly sure what to do here
    # @tree.open_elements[-1].form = @tree.formPointer
  end
  @tree.open_elements.pop
end

#startTagIsindex(name, attributes) ⇒ Object



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/html5/html5parser/in_body_phase.rb', line 267

def startTagIsindex(name, attributes)
  parse_error("deprecated-tag", {"name" => "isindex"})
  return if @tree.formPointer
  processStartTag('form', {})
  processStartTag('hr', {})
  processStartTag('p', {})
  processStartTag('label', {})
  # XXX Localization ...
  processCharacters('This is a searchable index. Insert your search keywords here: ')
  attributes['name'] = 'isindex'
  attrs = attributes.to_a
  processStartTag('input', attributes)
  processEndTag('label')
  processEndTag('p')
  processStartTag('hr', {})
  processEndTag('form')
end

#startTagListItem(name, attributes) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/html5/html5parser/in_body_phase.rb', line 132

def startTagListItem(name, attributes)
  endTagP('p') if in_scope?('p')
  stopNames = {'li' => ['li'], 'dd' => ['dd', 'dt'], 'dt' => ['dd', 'dt']}
  stopName = stopNames[name]

  @tree.open_elements.reverse.each_with_index do |node, i|
    if stopName.include?(node.name)
      poppedNodes = (0..i).collect { @tree.open_elements.pop }
      if i >= 1
        parse_error(
            i == 1 ? "missing-end-tag" : "missing-end-tags",
            {"name" => poppedNodes[0..-1].collect{|n| n.name}.join(", ")})

      end
      break
    end

    # Phrasing elements are all non special, non scoping, non
    # formatting elements
    break if ((SPECIAL_ELEMENTS + SCOPING_ELEMENTS).include?(node.name) && !%w[address div].include?(node.name))
  end

  # Always insert an <li> element.
  @tree.insert_element(name, attributes)
end

#startTagMisplaced(name, attributes) ⇒ Object



314
315
316
317
318
319
320
321
# File 'lib/html5/html5parser/in_body_phase.rb', line 314

def startTagMisplaced(name, attributes)
  # Elements that should be children of other elements that have a
  # different insertion mode; here they are ignored
  # "caption", "col", "colgroup", "frame", "frameset", "head",
  # "tbody", "td", "tfoot", "th", "thead",
  # "tr", "noscript"
  parse_error("unexpected-start-tag-ignored", {"name" => name})
end

#startTagNew(name, attributes) ⇒ Object



331
332
333
334
335
336
337
# File 'lib/html5/html5parser/in_body_phase.rb', line 331

def startTagNew(name, attributes)
  # New HTML5 elements, "event-source", "section", "nav",
  # "article", "aside", "header", "footer", "datagrid", "command"
  # $stderr.puts("Warning: Undefined behaviour for start tag #{name}")
  startTagOther(name, attributes)
  #raise NotImplementedError
end

#startTagNobr(name, attributes) ⇒ Object



198
199
200
201
202
203
204
205
206
207
# File 'lib/html5/html5parser/in_body_phase.rb', line 198

def startTagNobr(name, attributes)
  @tree.reconstructActiveFormattingElements
  if in_scope?('nobr')
    parse_error("unexpected-start-tag-implies-end-tag", {"startName" => "nobr", "endName" => "nobr"})
    processEndTag('nobr')
    # XXX Need tests that trigger the following
    @tree.reconstructActiveFormattingElements
  end
  addFormattingElement(name, attributes)
end

#startTagOptionOptgroup(name, attributes) ⇒ Object



323
324
325
326
327
328
329
# File 'lib/html5/html5parser/in_body_phase.rb', line 323

def startTagOptionOptgroup(name, attributes)
  if in_scope?('option')
    endTagOther('option')
  end
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, attributes)
end

#startTagOther(name, attributes) ⇒ Object



339
340
341
342
# File 'lib/html5/html5parser/in_body_phase.rb', line 339

def startTagOther(name, attributes)
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, attributes)
end

#startTagPlaintext(name, attributes) ⇒ Object



158
159
160
161
162
# File 'lib/html5/html5parser/in_body_phase.rb', line 158

def startTagPlaintext(name, attributes)
  endTagP('p') if in_scope?('p')
  @tree.insert_element(name, attributes)
  @parser.tokenizer.content_model_flag = :PLAINTEXT
end

#startTagProcessInHead(name, attributes) ⇒ Object



93
94
95
# File 'lib/html5/html5parser/in_body_phase.rb', line 93

def startTagProcessInHead(name, attributes)
  @parser.phases[:inHead].processStartTag(name, attributes)
end

#startTagSelect(name, attributes) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/html5/html5parser/in_body_phase.rb', line 301

def startTagSelect(name, attributes)
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, attributes)
  
  if [@parser.phases[:inTable], @parser.phases[:inCaption],
    @parser.phases[:inColumnGroup], @parser.phases[:inTableBody], @parser.phases[:inRow],
    @parser.phases[:inCell]].include?(@parser.phase)
    @parser.phase = @parser.phases[:inSelectInTable]
  else
    @parser.phase = @parser.phases[:inSelect]
  end
end

#startTagTable(name, attributes) ⇒ Object



233
234
235
236
237
# File 'lib/html5/html5parser/in_body_phase.rb', line 233

def startTagTable(name, attributes)
  processEndTag('p') if in_scope?('p')
  @tree.insert_element(name, attributes)
  @parser.phase = @parser.phases[:inTable]
end

#startTagTextarea(name, attributes) ⇒ Object



285
286
287
288
289
290
291
292
293
# File 'lib/html5/html5parser/in_body_phase.rb', line 285

def startTagTextarea(name, attributes)
  # XXX Form element pointer checking here as well...
  @tree.insert_element(name, attributes)
  @parser.tokenizer.content_model_flag = :RCDATA
  class << self
    remove_method :processSpaceCharacters rescue nil
    alias processSpaceCharacters processSpaceCharactersDropNewline
  end
end

#startTagVoidFormatting(name, attributes) ⇒ Object



239
240
241
242
243
# File 'lib/html5/html5parser/in_body_phase.rb', line 239

def startTagVoidFormatting(name, attributes)
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, attributes)
  @tree.open_elements.pop
end

#startTagXmp(name, attributes) ⇒ Object



227
228
229
230
231
# File 'lib/html5/html5parser/in_body_phase.rb', line 227

def startTagXmp(name, attributes)
  @tree.reconstructActiveFormattingElements
  @tree.insert_element(name, attributes)
  @parser.tokenizer.content_model_flag = :CDATA
end