-
Notifications
You must be signed in to change notification settings - Fork 42
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
Some CSS attribute selectors and pseudoclasses fixes #303
Merged
Conversation
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
In the initial loading phase, when the HTML is parsed and the DOM is being built, and styles computed (cause we know enough: the node class, all the parents), when meeting the nodes as they are parsed, the current node is... always the last child (which might be the only thing we don't know yet...). So, some CSS pseudoclasses like: :last-child :last-of-type :nth-last-child() :nth-last-of-type() :only-child :only-of-type might be matched on more nodes that they should. So, when meeting such a pseudoclass, we flag that a re-render is needed, which will be done on the fully made DOM, so they are matched correctly.
An empty string attribute selector (div[attr=""]) should not match a node when that attribute is absent. (getAttributeValue() returns an empty string when the attribute is absent, that would make us do some work with it.) This should also avoid the expensive lowercase() needed by our epub.css attribute selectors (eg. br[clear=left i]) when there is no clear= attribute on the <br> we meet.
The ' i' flag should be outside the parenthesis with the attribute value: div[foo="bar i"] should not match foo="bar" nor foo="BAR", but only foo="bar i". Also, "div[foo=], blockquote {...}" is invalid and should make the whole declaration discarded (including the blockquote).
Frenzie
approved these changes
Aug 3, 2019
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.
👍
Strangely, the commits didn't reach github in the same order they are on my side :/:
So, switch 2nd and 3rd when reading first post. They got re-ordered correctly by rebase&merge when merged into master... |
This was referenced Aug 3, 2019
Frenzie
pushed a commit
to koreader/koreader
that referenced
this pull request
Aug 3, 2019
Includes koreader/crengine#303: - Force a re-render when :last-child & other pseudoclasses are met - CSS: attribute selectors: don't check when there is no such attribute - CSS: attribute selectors: fix parsing of case insensitive flag
mwoz123
pushed a commit
to mwoz123/koreader
that referenced
this pull request
Mar 29, 2020
…der#5178) Includes koreader/crengine#303: - Force a re-render when :last-child & other pseudoclasses are met - CSS: attribute selectors: don't check when there is no such attribute - CSS: attribute selectors: fix parsing of case insensitive flag
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See individual commit messages for details.
First commit fixes the another strange thing noticed in #276 (comment):
Second commit fixes attribute selectors that should not match when there is no such attribute. It should avoid some uneeded expensive work, as noticed in #276 (comment).
Third commit makes the parsing of attribute selectors more correct that what was done in 3430e51.
Before 2nd and 3rd commits, this HTML:
would render as that (Firefox on the left, KOReader on the right):
![before](https://user-images.githubusercontent.com/24273478/62414996-62404300-b623-11e9-8dd2-28c8551a0c8a.png)
With 2nd and 3rd commits, we now render as Firefox:
![after](https://user-images.githubusercontent.com/24273478/62414998-65d3ca00-b623-11e9-85c2-cf18c42c4ed3.png)