Bug 79719 - Hover State + Custom Attributes Fail
Summary: Hover State + Custom Attributes Fail
Status: RESOLVED DUPLICATE of bug 79774
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All Unspecified
: P2 Minor
Assignee: Nobody
URL: http://jsbin.com/akulos
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-27 17:09 PST by Jeffrey Way
Modified: 2012-03-06 14:38 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Way 2012-02-27 17:09:06 PST
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.
Comment 1 Shezan Baig 2012-03-06 09:37:39 PST
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-
Comment 2 Shezan Baig 2012-03-06 13:57:46 PST
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?
Comment 3 Shezan Baig 2012-03-06 14:11:54 PST
correction: option (1) should be at the end of CSSStyleSelector::locateSharedStyle, not CSSStyleSelector::canShareStyleWithElement
Comment 4 David Barr 2012-03-06 14:38:50 PST

*** This bug has been marked as a duplicate of bug 79774 ***