- Notifications
You must be signed in to change notification settings - Fork 0
HTML API: Implement active format reconstruction#13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
38a771706287d155e20cfd57744fbf356f0564286b2746122921f546File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2832,15 +2832,19 @@ private function generate_implied_end_tags_thoroughly() { | ||
| * @return bool Whether any formatting elements needed to be reconstructed. | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if OwnerAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you think of a case where it would be useful? | ||
| */ | ||
| private function reconstruct_active_formatting_elements() { | ||
| $count = $this->state->active_formatting_elements->count(); | ||
| /* | ||
| * > If there are no entries in the list of active formatting elements, then there is nothing | ||
| * > to reconstruct; stop this algorithm. | ||
| */ | ||
| if ( 0 === $this->state->active_formatting_elements->count() ) { | ||
| if ( 0 === $count ) { | ||
| return false; | ||
| } | ||
| $last_entry = $this->state->active_formatting_elements->current_node(); | ||
| // Start at the last node in the list of active formatting elements. | ||
| $currently_at = $count - 1; | ||
| $last_entry = $this->state->active_formatting_elements->at( $currently_at ); | ||
| if ( | ||
| /* | ||
| @@ -2859,8 +2863,39 @@ private function reconstruct_active_formatting_elements() { | ||
| return false; | ||
| } | ||
| $this->last_error = self::ERROR_UNSUPPORTED; | ||
| throw new WP_HTML_Unsupported_Exception( 'Cannot reconstruct active formatting elements when advancing and rewinding is required.' ); | ||
| $entry = $last_entry; | ||
| while ( $currently_at >= 0 ) { | ||
| if ( 0 === $currently_at ) { | ||
| goto create; | ||
| } | ||
| $entry = $this->state->active_formatting_elements->at( --$currently_at ); | ||
| /* | ||
| * > If entry is neither a marker nor an element that is also in the stack of open elements, | ||
| * > go to the step labeled rewind. | ||
| */ | ||
| if ( 'marker' === $entry->node_name || $this->state->stack_of_open_elements->contains_node( $entry ) ) { | ||
| break; | ||
| } | ||
| } | ||
| advance: | ||
| $entry = $this->state->active_formatting_elements->at( ++$currently_at ); | ||
| create: | ||
| $this->insert_html_element( $entry ); | ||
| /* | ||
| * > Replace the entry for entry in the list with an entry for new element. | ||
| * This doesn't need to happen here since no DOM is being created. | ||
| */ | ||
| if ( $count - 1 !== $currently_at ) { | ||
| goto advance; | ||
| } | ||
| return true; | ||
| } | ||
| /** | ||
Uh oh!
There was an error while loading. Please reload this page.