Bug 79719
Summary: | Hover State + Custom Attributes Fail | ||
---|---|---|---|
Product: | WebKit | Reporter: | Jeffrey Way <jeffrey> |
Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Minor | CC: | davidbarr, kling, koivisto, shanestephens, shezbaig.wk, simon.fraser |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | Unspecified | ||
URL: | http://jsbin.com/akulos |
Jeffrey Way
1. Visit this demo: http://jsbin.com/akulos
2. Hover over the boxer image. It should add a red outline -- img[data-type="thing"]:hover { outline: 5px solid red; }.
Tested in Webkit nightly, but still doesn't work. If you select the element from dev tools, that somehow triggers it into working.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Shezan Baig
Hi, is anyone already investigating this issue? I took a quick look and the bug happens because the last two images share the same RenderStyle as the first image. In CSSStyleSelector::styleForElement, allowSharing is true, and locateSharedStyle() returns the RenderStyle for the first image (which doesn't have the hover rule).
A couple of ways to fix this I can think of:
1. add a check in CSSStyleSelector::canShareStyleWithElement, which looks at the attributes of m_element and returns false if CSSStyleSelector::hasSelectorForAttribute returns true for any of the attributes
2. add a flag in MatchOptions (something like 'ignoreHoverOrActiveState'), and set this flag to true inside matchesRuleSet (which, right now, is only used from locateSharedStyle). This flag will make SelectorChecker::checkOneSelector ignore the state of element->hovered() and element->active() when evaluating PseudoHover and PseudoActive.
(1) is definitely simpler, but would result in many false positives, which will reduce the likelihood of sharing styles. (2) is a little more complex but more "correct". Also, right now I'm only considering 'hover' and 'active' states, but theoretically we should be able to specify more states to ignore in MatchOptions (e.g. focus etc)
I was wondering if anybody was already working on this before I start hacking. Also, I'm looking for feedback on these 2 approaches (and also if there are any other possible approaches).
Thanks, -shez-
Shezan Baig
I'm starting to realize that (1) is the better fix, as it will also fix https://bugs.webkit.org/show_bug.cgi?id=79774, which seems somewhat related to this bug. David, do you want to make this a dup of that bug?
Shezan Baig
correction: option (1) should be at the end of CSSStyleSelector::locateSharedStyle, not CSSStyleSelector::canShareStyleWithElement
David Barr
*** This bug has been marked as a duplicate of bug 79774 ***