Bug 111252 - Merge SelectorCheckingContext into SelectorChecker.
Summary: Merge SelectorCheckingContext into SelectorChecker.
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dimitri Glazkov (Google)
URL:
Keywords:
Depends on:
Blocks: 89879
  Show dependency treegraph
 
Reported: 2013-03-02 09:36 PST by Dimitri Glazkov (Google)
Modified: 2014-12-25 22:40 PST (History)
11 users (show)

See Also:


Attachments
WIP (38.12 KB, patch)
2013-03-02 09:45 PST, Dimitri Glazkov (Google)
no flags Details | Formatted Diff | Diff
Patch (38.10 KB, patch)
2013-03-02 13:25 PST, Dimitri Glazkov (Google)
buildbot: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitri Glazkov (Google) 2013-03-02 09:36:57 PST
Merge SelectorCheckingContext into SelectorChecker.
Comment 1 Dimitri Glazkov (Google) 2013-03-02 09:45:39 PST
Created attachment 191108 [details]
WIP
Comment 2 Dimitri Glazkov (Google) 2013-03-02 13:25:58 PST
Created attachment 191117 [details]
Patch
Comment 3 Build Bot 2013-03-02 14:40:38 PST
Comment on attachment 191117 [details]
Patch

Attachment 191117 [details] did not pass mac-ews (mac):
Output: http://webkit-commit-queue.appspot.com/results/16797731

New failing tests:
editing/selection/selection-invalid-offset.html
Comment 4 Eric Seidel (no email) 2013-03-05 12:25:09 PST
I thought I wrote up comments for this patch, but they must have not sent.

I'm slightly surprised to see this, since SelecorChecker (and many of the style classes) could just be static and operate on context objets.  That appears to be someone's eariler goal here.

That said, It's OK for the logic and state to live in a single stack allocated class.  I assume you were the person who did the split before?
Comment 5 Antti Koivisto 2013-03-05 12:36:16 PST
Comment on attachment 191117 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=191117&action=review

> Source/WebCore/css/StyleResolver.cpp:2118
> -    SelectorChecker selectorChecker(document(), state.mode());
> -    SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element(), SelectorChecker::VisitedMatchEnabled);
> -    context.elementStyle = state.style();
> -    context.scope = scope;
> -    context.pseudoId = state.pseudoStyleRequest().pseudoId;
> -    context.scrollbar = state.pseudoStyleRequest().scrollbar;
> -    context.scrollbarPart = state.pseudoStyleRequest().scrollbarPart;
> -    context.behaviorAtBoundary = behaviorAtBoundary;
> -    SelectorChecker::Match match = selectorChecker.match(context, dynamicPseudo, DOMSiblingTraversalStrategy());
> +    SelectorChecker selectorChecker(ruleData.selector(), state.element(), state.mode(), SelectorChecker::VisitedMatchEnabled, state.style(), scope, state.pseudoStyleRequest().pseudoId, state.pseudoStyleRequest().scrollbar, state.pseudoStyleRequest().scrollbarPart, behaviorAtBoundary);

Wasn't the point of having a context object to avoid confusing and inflexible argument lists like this?
Comment 6 Dimitri Glazkov (Google) 2013-03-05 12:45:06 PST
(In reply to comment #4)
> I thought I wrote up comments for this patch, but they must have not sent.
> 
> I'm slightly surprised to see this, since SelecorChecker (and many of the style classes) could just be static and operate on context objets.  That appears to be someone's eariler goal here.
> 
> That said, It's OK for the logic and state to live in a single stack allocated class.  I assume you were the person who did the split before?

Roland did it a while back in bug 77525. Back then, SelectorChecker was a lot more than just an on-stack class. Since then, I whittled it down, and it seems to make little sense to have both of these. The const SelectorCheckerContext& param in front of all of SelectorChecker members even looks like a "this" ptr (if you pretend it's Python :)
Comment 7 Dimitri Glazkov (Google) 2013-03-05 12:48:18 PST
Comment on attachment 191117 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=191117&action=review

>> Source/WebCore/css/StyleResolver.cpp:2118
>> +    SelectorChecker selectorChecker(ruleData.selector(), state.element(), state.mode(), SelectorChecker::VisitedMatchEnabled, state.style(), scope, state.pseudoStyleRequest().pseudoId, state.pseudoStyleRequest().scrollbar, state.pseudoStyleRequest().scrollbarPart, behaviorAtBoundary);
> 
> Wasn't the point of having a context object to avoid confusing and inflexible argument lists like this?

Ideally, SelectorChecker should just take State as a constructor:

SelectorCheckt(ruleData.selector(), SelectorChecker::VisitedMatchEnabled, state);

It's pretty nice logically -- convey the current resolver state into the selector checker. However, the way they are defined is a bit messy. StyleResolver.h needs SelectorChecker.h to pull in some constants. I was thinking of moving them into a separate header, and then it'll be pretty.
Comment 8 Dimitri Glazkov (Google) 2013-03-05 12:58:45 PST
One other thing that might be useful: I was hoping to study the places where nested SelectorCheckers are created next, and:

1) defining better separation between nesting checkers and nested checkers (like, often the nesting checker messes with the nested checker, and that seems bad)
2) exploring selector checker only doing one thing (checking selectors) and some other class doing the thing of traversing the selector chain.

If you have other cool ideas, let me know. This is my hobby hacking anyway :)
Comment 9 Antti Koivisto 2013-03-05 13:12:33 PST
(In reply to comment #7)
> Ideally, SelectorChecker should just take State as a constructor:

You mean StyleResolver::State? That doesn't seem correct. We don't want to have two-way dependency between these. SelectorChecker has clients that have nothing to do with StyleResolver.
Comment 10 Dimitri Glazkov (Google) 2013-03-05 13:34:01 PST
(In reply to comment #9)
> (In reply to comment #7)
> > Ideally, SelectorChecker should just take State as a constructor:
> 
> You mean StyleResolver::State? That doesn't seem correct. We don't want to have two-way dependency between these. SelectorChecker has clients that have nothing to do with StyleResolver.

Right (see the second half of comment 7). StyleResolver doesn't need to depend on SelectorChecker, so by moving a few enums, I can switch the dependency and have SelectorChecker depend on StyleResolver.
Comment 11 Benjamin Poulain 2014-12-25 22:40:32 PST
Closing, SelectorCheckingContext is irrelevant now.