forked from niklasvh/html2canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speed & accuracy improvements to pseudo element rendering.
Previously, pseudo elements would be processed as they were found in the DOM tree, which was an expensive operation as each element's computed :before and :after style was checked for 'content' styles. This commit traverses the user's stylesheets for :before and :after selectors, gathers the classes affected, selects all elements that likely have a pseudo element present, then checks computed style. If there is actually an element present, it is created but *not* appended to the DOM until after all elements have been processed. After all elements have been found and created, they are added to the DOM in a single batch, and the original pseudo elements are hidden in a single batch. This prevents the layout invalidation / relayout loop that was occuring previously, and in my tests speeds parsing by as much as 50% or more, depending on how many pseudo elements your page uses. Additionally, this commit contains a bugfix to the handling of ":before" pseudo elements; the browser effectively inserts them as the first child of the element, not before the element. This fixes a few rendering inconsistencies and complicated pages look almost perfect in my tests.
- Loading branch information
Showing
3 changed files
with
305 additions
and
101 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
Oops, something went wrong.