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