Closed Bug 398962 Opened 14 years ago Closed 10 years ago
Add regular expression function for -moz-document rules
While domain, url, and url-prefix cover the majority of the cases you'd want to use -moz-document rules for, there are situations they can't cover adequately. For example, affecting URLs that end with a certain string ("/Special:RecentChanges") or URLs that have a changeable middle part ("http://example.com/users/1234/profile"). A regular expression function would cover these remaining cases.
(See also discussion in bug 423985, although nothing particularly relevant, I suppose.)
I will send $100 Canadian to anyone who can get this in for Firefox 3.1.
The problem is that Firefox doesn't have a direct regexp implementation, only a JSRegExp, but I can't find any way to access it from C++...
Assignee: nobody → dbaron
Priority: -- → P4
Target Milestone: --- → mozilla6
http://hg.mozilla.org/users/dbaron_mozilla.com/patches/raw-file/44bf5536e765/moz-document-regexp is a patch for this that compiles, but I haven't yet tested it at all.
Comment on attachment 528008 [details] [diff] [review] patch And requesting feedback from Mounir to make sure he's ok with this method moving (unchanged) from nsHTMLInputElement to nsContentUtils.
Attachment #528008 - Flags: feedback?(mounir.lamouri)
Comment on attachment 528008 [details] [diff] [review] patch >+ // copy before we know it's valid Please document why (ExpectSymbol messing with mToken, I assume), and r=me.
Attachment #528008 - Flags: review?(bzbarsky) → review+
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
I am SO excited to see this get implemented. It's going to bring so much extra power to userstyles! Thank you Mozilla.
Documentation updated: https://developer.mozilla.org/index.php?title=en/CSS/%40-moz-document And mentioned on Firefox 6 for developers.
Comment on attachment 528008 [details] [diff] [review] patch I'm happy to see this code moving to nsContentUtils. And I'm sorry that the feedback took so long. I'm abroad for the week for a community event and it's hard to get a good internet connectivity. Though I see the patch has been landed so it didn't block anything ;)
Attachment #528008 - Flags: feedback?(mounir.lamouri) → feedback+
Added one additional test: https://hg.mozilla.org/mozilla-central/rev/278fd4966ed0
It looks to me like you need to enclose the regexp in a single or double quote (unlike url, url-prefix, and domain). Just want to make sure that that was intended. Also, missing a "break;" here? diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -942,16 +942,18 @@ DocumentRule::List(FILE* out, PRInt32 aI case eURL: str.AppendLiteral("url(\""); break; case eURLPrefix: str.AppendLiteral("url-prefix(\""); break; case eDomain: str.AppendLiteral("domain(\""); + case eRegExp: + str.AppendLiteral("regexp(\""); break; }
I should add a general test for rule parse+serialize idempotence that would catch this...
Attachment #537322 - Flags: review?(bzbarsky)
Yes, requiring quotes was intended.
Comment on attachment 537322 [details] [diff] [review] add missing break r=me
Attachment #537322 - Flags: review?(bzbarsky) → review+
Added missing break: https://hg.mozilla.org/mozilla-central/rev/ddc73a8ae402 and added a test that would have caught if that were in the non-DEBUG function: https://hg.mozilla.org/mozilla-central/rev/6772105ec426
You need to log in before you can comment on or make changes to this bug.