gecko-dev/dom/webidl/MatchGlob.webidl
Kris Maglione 186924219b Bug 1322235: Part 1 - Add native MatchPattern and MatchGlob bindings. r=billm,aswan
Bill, can you please review the binding code, and the general sanity of the
platform code. Andrew and zombie, can you please matching algorithms and
tests.

Change summary:

The existing JavaScript matching code works well overall, but it needs to be
called a lot, particularly from hot code paths. In most cases, the overhead of
the matching code on its own adds up enough to cause a problem. When we have
to call out to JavaScript via XPConnect to make a policy decision, it adds up
even more.

These classes solve both of these problems by a) being very fast, and b) being
accessible directly from C++. They are particularly optimized for the common
cases where only literal or prefix matches are required, and they take special
steps to avoid virtual calls wherever possible, and caching computed URL
values so that they can be reused across many match operations without
additional overhead.

MozReview-Commit-ID: BZzPZDQRnl

--HG--
rename : toolkit/modules/tests/xpcshell/test_MatchPattern.js => toolkit/components/extensions/test/xpcshell/test_MatchPattern.js
extra : rebase_source : c93c4c6c36460eb5ad0fc3aa86ad42a72e76bb6c
2017-05-24 14:57:29 -07:00

25 lines
849 B
Plaintext

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Represents a simple glob pattern matcher. Any occurrence of "*" in the glob
* pattern matches any literal string of characters in the string being
* compared. Additionally, if created with `allowQuestion = true`, any
* occurrence of "?" in the glob matches any single literal character.
*/
[Constructor(DOMString glob, optional boolean allowQuestion = true),
ChromeOnly, Exposed=(Window,System)]
interface MatchGlob {
/**
* Returns true if the string matches the glob.
*/
boolean matches(DOMString string);
/**
* The glob string this MatchGlob represents.
*/
[Constant]
readonly attribute DOMString glob;
};