Last Comment Bug 398962 - Add regular expression function for -moz-document rules
: Add regular expression function for -moz-document rules
Status: RESOLVED FIXED
: dev-doc-complete
Product: Core
Classification: Components
Component: CSS Parsing and Computation (show other bugs)
: Trunk
: All All
: P4 enhancement with 5 votes (vote)
: mozilla6
Assigned To: David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch)
:
Mentors:
Depends on: 943217
Blocks: 634764
  Show dependency treegraph
 
Reported: 2007-10-07 22:30 PDT by Jason Barnabe (np)
Modified: 2013-11-26 01:35 PST (History)
13 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch (19.15 KB, patch)
2011-04-24 09:51 PDT, David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch)
bzbarsky: review+
mounir: feedback+
Details | Diff | Review
add missing break (764 bytes, patch)
2011-06-04 00:42 PDT, David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch)
bzbarsky: review+
Details | Diff | Review

Description Jason Barnabe (np) 2007-10-07 22:30:57 PDT
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.
Comment 1 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2008-04-13 11:25:58 PDT
(See also discussion in bug 423985, although nothing particularly relevant, I suppose.)
Comment 2 Jason Barnabe (np) 2008-08-04 19:46:23 PDT
I will send $100 Canadian to anyone who can get this in for Firefox 3.1.
Comment 3 Evengard 2010-04-12 00:46:24 PDT
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++...
Comment 4 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-04-23 20:50:55 PDT
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 5 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-04-24 09:51:14 PDT
Created attachment 528008 [details] [diff] [review]
patch
Comment 6 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-04-24 09:52:16 PDT
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.
Comment 7 Boris Zbarsky [:bz] 2011-04-28 07:43:58 PDT
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.
Comment 8 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-04-28 10:26:57 PDT
https://hg.mozilla.org/mozilla-central/rev/52a05ef70c66
Comment 9 Evgueni Naverniouk 2011-04-28 10:33:30 PDT
I am SO excited to see this get implemented. It's going to bring so much extra power to userstyles! Thank you Mozilla.
Comment 10 Eric Shepherd [:sheppy] 2011-04-28 16:44:17 PDT
Documentation updated:

https://developer.mozilla.org/index.php?title=en/CSS/%40-moz-document

And mentioned on Firefox 6 for developers.
Comment 11 Mounir Lamouri (:mounir) 2011-04-29 11:34:25 PDT
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 ;)
Comment 12 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-04-30 15:28:26 PDT
Added one additional test:
https://hg.mozilla.org/mozilla-central/rev/278fd4966ed0
Comment 13 Jason Barnabe (np) 2011-06-03 19:52:09 PDT
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;
     }
Comment 14 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-06-04 00:42:55 PDT
Created attachment 537322 [details] [diff] [review]
add missing break

I should add a general test for rule parse+serialize idempotence that would catch this...
Comment 15 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-06-04 00:49:08 PDT
Yes, requiring quotes was intended.
Comment 16 Boris Zbarsky [:bz] 2011-06-06 11:49:21 PDT
Comment on attachment 537322 [details] [diff] [review]
add missing break

r=me
Comment 17 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2011-06-12 20:21:13 PDT
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

Note You need to log in before you can comment on or make changes to this bug.