-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tag Processor: Add bookmark system for tracking semantic locations in…
… document It can be helpful to track a location in an HTML document while updates are being made to it such that we can instruct the Tag Processor to seek to the location of one of the bookmarks. In this patch we're introducing a bookmarks system to do just that. Bookmarks are referenced by name and handled internally by a tracking object which will follow all updates made to the document. It will be possible to rewind or jump around a document by setting a bookmark and then calling `seek( $bookmark_name )` to move there. Co-authored-by: Adam Zielinski <adam@adamziel.com> Co-authored-by: Dennis Snell <dennis.snell@automattic.com>
- Loading branch information
Showing
5 changed files
with
684 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* HTML Span: Represents a textual span inside an HTML document. | ||
* | ||
* @package WordPress | ||
* @subpackage HTML | ||
* @since 6.2.0 | ||
*/ | ||
|
||
/** | ||
* Represents a textual span inside an HTML document. | ||
* | ||
* This is a two-tuple in disguise, used to avoid the memory | ||
* overhead involved in using an array for the same purpose. | ||
* | ||
* This class is for internal usage of the WP_HTML_Tag_Processor class. | ||
* | ||
* @access private | ||
* @since 6.2.0 | ||
* | ||
* @see WP_HTML_Tag_Processor | ||
*/ | ||
class WP_HTML_Span { | ||
/** | ||
* Byte offset into document where span begins. | ||
* | ||
* @since 6.2.0 | ||
* @var int | ||
*/ | ||
public $start; | ||
|
||
/** | ||
* Byte offset into document where span ends. | ||
* | ||
* @since 6.2.0 | ||
* @var int | ||
*/ | ||
public $end; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @since 6.2.0 | ||
* | ||
* @param int $start Byte offset into document where replacement span begins. | ||
* @param int $end Byte offset into document where replacement span ends. | ||
*/ | ||
public function __construct( $start, $end ) { | ||
$this->start = $start; | ||
$this->end = $end; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
5fcf00d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit broke PHP 5.6 unit tests. FYI @dmsnell
5fcf00d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. sorry about that @anton-vlasenko - I rely on the CI test suites to confirm that something doesn't break and I didn't realize that was a false safety.
I'll try and look into this and see what happened.
5fcf00d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I absolutely agree with you on that, @dmsnell.
The CI jobs should be fixed to run PHPUnit tests on all PHP versions.
There is a PR (work in progress) to change that: #46510
Hopefully, it will be ready and merged before the end of the year.
Thank you for looking into it!