Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
93.02% |
40 / 43 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
InSelectInTable | |
93.02% |
40 / 43 |
|
75.00% |
3 / 4 |
23.18 | |
0.00% |
0 / 1 |
characters | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
startTag | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
10 | |||
endTag | |
86.36% |
19 / 22 |
|
0.00% |
0 / 1 |
11.31 | |||
endDocument | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Wikimedia\RemexHtml\TreeBuilder; |
4 | |
5 | use Wikimedia\RemexHtml\Tokenizer\Attributes; |
6 | |
7 | /** |
8 | * The "in select in table" insertion mode |
9 | */ |
10 | class InSelectInTable extends InsertionMode { |
11 | public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
12 | $this->dispatcher->inSelect->characters( |
13 | $text, $start, $length, $sourceStart, $sourceLength ); |
14 | } |
15 | |
16 | public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
17 | $builder = $this->builder; |
18 | $dispatcher = $this->dispatcher; |
19 | |
20 | switch ( $name ) { |
21 | case 'caption': |
22 | case 'table': |
23 | case 'tbody': |
24 | case 'tfoot': |
25 | case 'thead': |
26 | case 'tr': |
27 | case 'td': |
28 | case 'th': |
29 | $builder->error( "unexpected <$name> in select in table, closing select", |
30 | $sourceStart ); |
31 | $builder->popAllUpToName( 'select', $sourceStart, 0 ); |
32 | $dispatcher->reset() |
33 | ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
34 | break; |
35 | |
36 | default: |
37 | $dispatcher->inSelect->startTag( |
38 | $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
39 | } |
40 | } |
41 | |
42 | public function endTag( $name, $sourceStart, $sourceLength ) { |
43 | $builder = $this->builder; |
44 | $stack = $builder->stack; |
45 | $dispatcher = $this->dispatcher; |
46 | |
47 | switch ( $name ) { |
48 | case 'caption': |
49 | case 'table': |
50 | case 'tbody': |
51 | case 'tfoot': |
52 | case 'thead': |
53 | case 'tr': |
54 | case 'td': |
55 | case 'th': |
56 | if ( !$stack->isInTableScope( $name ) ) { |
57 | $builder->error( "unexpected </$name> in select in table, ignoring", |
58 | $sourceStart ); |
59 | return; |
60 | } |
61 | $builder->error( "unexpected </$name> in select in table, closing select", |
62 | $sourceStart ); |
63 | $builder->popAllUpToName( 'select', $sourceStart, 0 ); |
64 | $dispatcher->reset() |
65 | ->endTag( $name, $sourceStart, $sourceLength ); |
66 | break; |
67 | |
68 | default: |
69 | $dispatcher->inSelect->endTag( $name, $sourceStart, $sourceLength ); |
70 | } |
71 | } |
72 | |
73 | public function endDocument( $pos ) { |
74 | $this->dispatcher->inSelect->endDocument( $pos ); |
75 | } |
76 | } |