RemexHtml/TreeBuilder/ActiveFormattingElements.php
public function push( Element $elt ) {
		// Must not be in the list already
		if ( $elt->prevAFE !== null || $this->head === $elt ) {
			throw new \Exception( 'Cannot insert a node into the AFE list twice' );
		}

		// "Noah's Ark clause" -- if there are already three copies of
		// this element before we encounter a marker, then drop the last
		// one.
		$noahKey = $elt->getNoahKey();
		$table =& $this->noahTableStack[ count( $this->noahTableStack ) - 1 ];
		if ( !isset( $table[$noahKey] ) ) {
			$table[$noahKey] = $elt;
		} else {
			$count = 1;
			$head = $tail = $table[$noahKey];
			while ( $tail->nextNoah ) {
				$tail = $tail->nextNoah;
				$count++;
			}
			if ( $count >= 3 ) {
				$this->remove( $head );
			}
			$tail->nextNoah = $elt;
		}
		// Add to the main AFE list
		if ( $this->tail ) {
			$this->tail->nextAFE = $elt;
			$elt->prevAFE = $this->tail;
		} else {
			$this->head = $elt;
		}
		$this->tail = $elt;
	}
public function push( Element $elt ) {
		// Must not be in the list already
		if ( $elt->prevAFE !== null || $this->head === $elt ) {
			throw new \Exception( 'Cannot insert a node into the AFE list twice' );
		}

		// "Noah's Ark clause" -- if there are already three copies of
		// this element before we encounter a marker, then drop the last
		// one.
		$noahKey = $elt->getNoahKey();
		$table =& $this->noahTableStack[ count( $this->noahTableStack ) - 1 ];
		if ( !isset( $table[$noahKey] ) ) {
			$table[$noahKey] = $elt;
		} else {
			$count = 1;
			$head = $tail = $table[$noahKey];
			while ( $tail->nextNoah ) {
				$tail = $tail->nextNoah;
				$count++;
			}
			if ( $count >= 3 ) {
				$this->remove( $head );
			}
			$tail->nextNoah = $elt;
		}
		// Add to the main AFE list
		if ( $this->tail ) {
			$this->tail->nextAFE = $elt;
			$elt->prevAFE = $this->tail;
		} else {
			$this->head = $elt;
		}
		$this->tail = $elt;
	}
public function push ( Element $ elt ) { // Must not be in the list already if ( $ elt -> prevAFE !== null || $ this -> head === $ elt ) { throw new \ Exception ( 'Cannot insert a node into the AFE list twice' ) ; } // "Noah's Ark clause" -- if there are already three copies of // this element before we encounter a marker, then drop the last // one. $ noahKey = $ elt -> getNoahKey ( ) ; $ table = & $ this -> noahTableStack [ count ( $ this -> noahTableStack ) - 1 ] ; if ( ! isset ( $ table [ $ noahKey ] ) ) { $ table [ $ noahKey ] = $ elt ; } else { $ count = 1 ; $ head = $ tail = $ table [ $ noahKey ] ; while ( $ tail -> nextNoah ) { $ tail = $ tail -> nextNoah ; $ count ++ ; } if ( $ count >= 3 ) { $ this -> remove ( $ head ) ; } $ tail -> nextNoah = $ elt ; } // Add to the main AFE list if ( $ this -> tail ) { $ this -> tail -> nextAFE = $ elt ; $ elt -> prevAFE = $ this -> tail ; } else { $ this -> head = $ elt ; } $ this -> tail = $ elt ; }
Follow the steps required when the spec requires us to "push onto the
list of active formatting elements".
@param Element $elt
Follow the steps required when the spec requires us to push onto the list of active formatting elements .