making placeholder work with part

4 views
Skip to first unread message

Fergal Daly

unread,
Jan 16, 2019, 7:38:34 AM1/16/19
to styl...@chromium.org, Rune Lillesveen
https://crrev.com/c/1414536 got ::afer and ::before working with ::part but ::placeholder doesn't. I suspect it's because placeholder rules go into their own bucket

  case CSSSelector::kPseudoPlaceholder:
      LOG(ERROR) << "Adding to placeholder rules";
      AddToRuleSet(AtomicString("-webkit-input-placeholder"),
                   EnsurePendingRules()->shadow_pseudo_element_rules,
                   rule_data);


and not into the part_pseudo_rules_ bucket.

I'm not sure what's an elegant way to address this. Do we need to add another HeapVector just for this special case? If we want to support any other custom pseudos with ::part then another another CompactRuleMap could make sense but do we want to support any others?

F

Rune Lillesveen

unread,
Jan 17, 2019, 10:03:06 AM1/17/19
to Fergal Daly, style-dev
Right, so the CL I lgtm'ed considers all part rules in the scope of input element when matching rules for ::placeholder.

What if you still put the ::placeholder rules in the ::placeholder bucket and passed the part names parameter to CollectMatchingRulesForList here: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/element_rule_collector.cc?type=cs&sq=package:chromium&g=0&l=200-202
Would that work?

An observation is that ::placeholder (and all the ::-webkit-* pseudo elements) are really UA shadow ::part()s and one way to look at it is that ::part(my-input)::placeholder is quite similar to using ::part(my-input-placeholder) if we had a concept where we could use part name forwarding for UA shadow "parts".

Fergal Daly

unread,
Jan 17, 2019, 8:09:02 PM1/17/19
to Rune Lillesveen, style-dev
On Fri, 18 Jan 2019 at 00:03, Rune Lillesveen <fut...@chromium.org> wrote:
Right, so the CL I lgtm'ed considers all part rules in the scope of input element when matching rules for ::placeholder.

I've submitted that CL just so that I can flip the flag, if there's a better way to implement it, I'll switch to that.
 

What if you still put the ::placeholder rules in the ::placeholder bucket and passed the part names parameter to CollectMatchingRulesForList here: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/element_rule_collector.cc?type=cs&sq=package:chromium&g=0&l=200-202
Would that work?

I don't think so but it's been a while since I've been in this code.

For the part stuff to work, we ascend the tree and apply the mappings at each scope. That's done in StyleResolver::MatchPseudoPartRules which does all that and eventually call downs to CollectMatchingRulesForList with part_names. Just adding part_names to the call to CollectMatchingRulesForList without all of the scope and export mapping stuff might work for a rule directly in the scope of the input but I think wouldn't work for any further up the tree.

An observation is that ::placeholder (and all the ::-webkit-* pseudo elements) are really UA shadow ::part()s and one way to look at it is that ::part(my-input)::placeholder is quite similar to using ::part(my-input-placeholder) if we had a concept where we could use part name forwarding for UA shadow "parts".

Yeah, ideally it would just be a part but actually doing that seems to get fairly complicated because ::part can't be chained with another ::part and we would have to do some magic with the part name. I don't know if it actually makes sense to attempt it,

Reply all
Reply to author
Forward
0 new messages