Skip to content

Make StyleCollectionExtentions.ComputeDeclarations take a IEnumerable<ICssStyleRule>to allow for caching of the StyleCollection. #53

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

Closed
5 tasks done
The-Nutty opened this issue May 4, 2020 · 2 comments
Labels

Comments

@The-Nutty
Copy link
Contributor

Bug Report

Iterating through IWindow.GetStyleCollection is slow if doing on multiple elements, this could be because _sheets is deferred or just because GetEnumerator is doing lots of work.

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Description

This relates to #51 where i was hoping to be able to cache the StyleCollection returned by IWindow.GetStyleCollection to significantly speed up the process of calling StyleCollection.ComputeDeclarations on every element in a document. However it is still just as slow.

Possible Solution

  1. Make ComputeDeclarations take a IEnumerable that could be pre calculated.
  2. Optionally 1 but return a IEnumerable from IWindow.GetStyleCollection.

Im happy to implement the change if that would help as if possible i would appreciate it if we could get this out in a patch version, but wanted to run potential solutions by you before creating a PR.

@The-Nutty The-Nutty added the bug label May 4, 2020
@FlorianRappl
Copy link
Contributor

Im happy to implement the change if that would help as if possible i would appreciate it if we could get this out in a patch version, but wanted to run potential solutions by you before creating a PR.

Sure just make a PR and adjust the version to 0.14.1!
(https://github.com/AngleSharp/AngleSharp.Css/blob/master/src/Directory.Build.props and in the CHANGELOG)

@FlorianRappl
Copy link
Contributor

Thanks for the superb contribution! I'll close the issue the update should be out in a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants