Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
45 / 45
InFrameset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
13
100.00% covered (success)
100.00%
44 / 44
 characters
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 startTag
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
21 / 21
 endTag
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
15 / 15
 endDocument
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
6 / 6
<?php
namespace Wikimedia\RemexHtml\TreeBuilder;
use Wikimedia\RemexHtml\Tokenizer\Attributes;
/**
 * The "in frameset" insertion mode
 */
class InFrameset extends InsertionMode {
    public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
        $this->handleFramesetWhitespace( false, $text, $start, $length, $sourceStart, $sourceLength );
    }
    public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
        $builder = $this->builder;
        $dispatcher = $this->dispatcher;
        switch ( $name ) {
        case 'html':
            $dispatcher->inBody->startTag(
                $name, $attrs, $selfClose, $sourceStart, $sourceLength );
            break;
        case 'frameset':
            $builder->insertElement( $name, $attrs, false, $sourceStart, $sourceLength );
            break;
        case 'frame':
            $dispatcher->ack = true;
            $builder->insertElement( $name, $attrs, true, $sourceStart, $sourceLength );
            break;
        case 'noframes':
            $dispatcher->inHead->startTag(
                $name, $attrs, $selfClose, $sourceStart, $sourceLength );
            break;
        default:
            $builder->error( "unexpected start tag in frameset, ignoring", $sourceStart );
            return;
        }
    }
    public function endTag( $name, $sourceStart, $sourceLength ) {
        $builder = $this->builder;
        $stack = $builder->stack;
        $dispatcher = $this->dispatcher;
        switch ( $name ) {
        case 'frameset':
            if ( $stack->current->htmlName === 'html' ) {
                $builder->error( "unexpected </frameset> in fragment context", $sourceStart );
                return;
            }
            $builder->pop( $sourceStart, $sourceLength );
            if ( !$builder->isFragment && $stack->current !== 'frameset' ) {
                $dispatcher->switchMode( Dispatcher::AFTER_FRAMESET );
            }
            break;
        default:
            $builder->error( "unexpected </$name> in frameset", $sourceStart );
            return;
        }
    }
    public function endDocument( $pos ) {
        $builder = $this->builder;
        $stack = $builder->stack;
        if ( $stack->current->htmlName !== 'html' ) {
            $builder->error( "unexpected end of file in frameset mode", $pos );
        }
        $builder->stopParsing( $pos );
    }
}
// Retain the old namespace for backwards compatibility.
class_alias( InFrameset::class, 'RemexHtml\TreeBuilder\InFrameset' );