Add regular expression function for -moz-document rules

RESOLVED FIXED in mozilla6

Status

()

Core
CSS Parsing and Computation
P4
enhancement
RESOLVED FIXED
10 years ago
7 months ago

People

(Reporter: Jason Barnabe (np), Assigned: dbaron)

Tracking

(Depends on: 1 bug, {dev-doc-complete})

Trunk
mozilla6
dev-doc-complete
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

10 years ago
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.
(Assignee)

Comment 1

9 years ago
(See also discussion in bug 423985, although nothing particularly relevant, I suppose.)
(Reporter)

Comment 2

9 years ago
I will send $100 Canadian to anyone who can get this in for Firefox 3.1.

Comment 3

7 years ago
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++...
Blocks: 634764
(Assignee)

Updated

6 years ago
Assignee: nobody → dbaron
Priority: -- → P4
Target Milestone: --- → mozilla6
(Assignee)

Comment 4

6 years ago
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.
(Assignee)

Comment 5

6 years ago
Created attachment 528008 [details] [diff] [review]
patch
Attachment #528008 - Flags: review?(bzbarsky)
(Assignee)

Comment 6

6 years ago
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)
(Assignee)

Updated

6 years ago
Keywords: dev-doc-needed
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+
(Assignee)

Comment 8

6 years ago
https://hg.mozilla.org/mozilla-central/rev/52a05ef70c66
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED

Comment 9

6 years ago
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.
Keywords: dev-doc-needed → dev-doc-complete
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+
(Assignee)

Comment 12

6 years ago
Added one additional test:
https://hg.mozilla.org/mozilla-central/rev/278fd4966ed0
(Reporter)

Comment 13

6 years ago
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;
     }
(Assignee)

Comment 14

6 years ago
Created attachment 537322 [details] [diff] [review]
add missing break

I should add a general test for rule parse+serialize idempotence that would catch this...
Attachment #537322 - Flags: review?(bzbarsky)
(Assignee)

Comment 15

6 years ago
Yes, requiring quotes was intended.
Comment on attachment 537322 [details] [diff] [review]
add missing break

r=me
Attachment #537322 - Flags: review?(bzbarsky) → review+
(Assignee)

Comment 17

6 years ago
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

Updated

4 years ago
Depends on: 943217
Depends on: 1310335
You need to log in before you can comment on or make changes to this bug.