Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
38 / 38 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
InFrameset | |
100.00% |
38 / 38 |
|
100.00% |
4 / 4 |
15 | |
100.00% |
1 / 1 |
characters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
startTag | |
100.00% |
19 / 19 |
|
100.00% |
1 / 1 |
6 | |||
endTag | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
6 | |||
endDocument | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Wikimedia\RemexHtml\TreeBuilder; |
4 | |
5 | use Wikimedia\RemexHtml\Tokenizer\Attributes; |
6 | |
7 | /** |
8 | * The "in frameset" insertion mode |
9 | */ |
10 | class InFrameset extends InsertionMode { |
11 | public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
12 | $this->handleFramesetWhitespace( false, $text, $start, $length, $sourceStart, $sourceLength ); |
13 | } |
14 | |
15 | public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
16 | $builder = $this->builder; |
17 | $dispatcher = $this->dispatcher; |
18 | |
19 | switch ( $name ) { |
20 | case 'html': |
21 | $dispatcher->inBody->startTag( |
22 | $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
23 | break; |
24 | |
25 | case 'frameset': |
26 | $builder->insertElement( $name, $attrs, false, $sourceStart, $sourceLength ); |
27 | break; |
28 | |
29 | case 'frame': |
30 | $dispatcher->ack = true; |
31 | $builder->insertElement( $name, $attrs, true, $sourceStart, $sourceLength ); |
32 | break; |
33 | |
34 | case 'noframes': |
35 | $dispatcher->inHead->startTag( |
36 | $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
37 | break; |
38 | |
39 | default: |
40 | $builder->error( "unexpected start tag in frameset, ignoring", $sourceStart ); |
41 | return; |
42 | } |
43 | } |
44 | |
45 | public function endTag( $name, $sourceStart, $sourceLength ) { |
46 | $builder = $this->builder; |
47 | $stack = $builder->stack; |
48 | $dispatcher = $this->dispatcher; |
49 | |
50 | switch ( $name ) { |
51 | case 'frameset': |
52 | if ( $stack->current->htmlName === 'html' ) { |
53 | $builder->error( "unexpected </frameset> in fragment context", $sourceStart ); |
54 | return; |
55 | } |
56 | $builder->pop( $sourceStart, $sourceLength ); |
57 | if ( !$builder->isFragment && $stack->current !== 'frameset' ) { |
58 | $dispatcher->switchMode( Dispatcher::AFTER_FRAMESET ); |
59 | } |
60 | break; |
61 | |
62 | default: |
63 | $builder->error( "unexpected </$name> in frameset", $sourceStart ); |
64 | return; |
65 | } |
66 | } |
67 | |
68 | public function endDocument( $pos ) { |
69 | $builder = $this->builder; |
70 | $stack = $builder->stack; |
71 | |
72 | if ( $stack->current->htmlName !== 'html' ) { |
73 | $builder->error( "unexpected end of file in frameset mode", $pos ); |
74 | } |
75 | |
76 | $builder->stopParsing( $pos ); |
77 | } |
78 | } |