Closed Bug 1283620 Opened 8 years ago Closed 8 years ago

Add attribute matching hooks for Servo

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: bholley, Assigned: bholley)

References

Details

Attachments

(5 files, 1 obsolete file)

With these hooks, we can remove the need to expose an arbitrary attribute getter to servo, which avoids the need to convert UTF-16 to UTF-8.
I have no idea why these are virtual, but they're somewhat hot, so we should fix that.
Attachment #8766933 - Flags: review?(mrbkap)
Attachment #8766934 - Flags: review?(mrbkap)
Attachment #8766935 - Flags: review?(mrbkap)
Attachment #8766937 - Flags: review?(mrbkap)
Attachment #8766937 - Attachment description: Part 3 - Hoist ValueIncludes into nsStyleUtil. v1 → Part 4 - Hoist ValueIncludes into nsStyleUtil. v1
Attached patch Part 5 - Implement attribute API for servo. v1 (obsolete) (deleted) — Splinter Review
Attachment #8766938 - Flags: review?(mrbkap)
Attachment #8766933 - Flags: review?(mrbkap) → review+
Attachment #8766934 - Flags: review?(mrbkap) → review+
Attachment #8766935 - Flags: review?(mrbkap) → review+
Attachment #8766937 - Flags: review?(mrbkap) → review+
Comment on attachment 8766938 [details] [diff] [review] Part 5 - Implement attribute API for servo. v1 Review of attachment 8766938 [details] [diff] [review]: ----------------------------------------------------------------- I think we can avoid the long (and ugly) macros in favor of some more modern C++-isms. ::: layout/style/ServoBindings.cpp @@ +186,5 @@ > +{ > + return false; > +} > + > +#define IMPL_MATCH(aElement, aNS, aName, args) \ Why not: template <class MatchFn> DoMatch(RawGeckoElement* aElement, nsIAtom* aNS, nsIAtom* aName, MatchFn aMatcher) { ...aMatcher(value)... } Called as (e.g.): bool Gecko_AttrEquals(...) { auto matcher = [ aStr, aIgnoreCase ](nsAttrValue* aValue) { return aValue->Equals(aStr, aIgnoreCase ? eIgnoreCase : eCaseMatters); } return DoMatch(aElement, aNS, aName, matcher); } avoiding long macros and keeping type safety.
Attachment #8766938 - Flags: review?(mrbkap)
Er, DoMatch would obviously return bool.
Nice idea. I initially avoided using lambdas because I knew our static analysis was going to try to make me use strong refs, but I found a workaround. :-)
Attachment #8768187 - Flags: review?(mrbkap)
Attachment #8766938 - Attachment is obsolete: true
CC mystor, who wants to remove the FakeRef thing when he fixes the static analysis.
Comment on attachment 8768187 [details] [diff] [review] Part 5 - Implement attribute API for servo. v2 Review of attachment 8768187 [details] [diff] [review]: ----------------------------------------------------------------- Vive bug 1281935 :-) ::: layout/style/ServoBindings.cpp @@ +190,5 @@ > + NS_ENSURE_TRUE(ns != kNameSpaceID_Unknown, false); > + const nsAttrValue* value = aElement->GetParsedAttr(aName, ns); > + return value && aMatch(value); > + } > + /* No namespace means any namespace - we have to check them all. :-( */ This could be a C++-style comment now, if you want.
Attachment #8768187 - Flags: review?(mrbkap) → review+
Pushed by bholley@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/3b4cb1618f8b Devirtualize a bunch of namespace methods. r=mrbkap https://hg.mozilla.org/integration/mozilla-inbound/rev/44266a61eeac Add an atom overload of GetNameSpaceID. r=mrbkap https://hg.mozilla.org/integration/mozilla-inbound/rev/52828db7c9e4 Add a namespaced overload of GetParsedAttr. r=mrbkap https://hg.mozilla.org/integration/mozilla-inbound/rev/3f2b97db440f Hoist ValueIncludes into nsStyleUtil. r=mrbkap https://hg.mozilla.org/integration/mozilla-inbound/rev/c23ae65921f0 Implement attribute API for servo. r=mrbkap
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: