Bug 1175192. Consistently allow identifiers to start with -- in the CSS parser. r=heycam
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 24 Jun 2015 10:17:05 -0700
changeset 268243 1b09041ef8f256f712d6bb132083ac386c35ab0d
parent 268242 585f52ceab5c45d52a715e18388cea03ece8d16a
child 268244 d86bb3dff4bab20c88bc2f0f298cb2537626ce1b
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1175192
milestone41.0a1
Bug 1175192. Consistently allow identifiers to start with -- in the CSS parser. r=heycam
layout/reftests/css-parsing/reftest.list
layout/reftests/css-parsing/two-dash-identifiers-ref.html
layout/reftests/css-parsing/two-dash-identifiers.html
layout/style/nsCSSScanner.cpp
--- a/layout/reftests/css-parsing/reftest.list
+++ b/layout/reftests/css-parsing/reftest.list
@@ -1,7 +1,8 @@
 == at-rule-013.html at-rule-013-ref.html
 == invalid-url-handling.xhtml invalid-url-handling-ref.xhtml
 == pseudo-elements-1.html pseudo-elements-1-ref.html
 == invalid-attr-1.html invalid-attr-1-ref.html
 == at-rule-error-handling-import-1.html at-rule-error-handling-ref.html
 == at-rule-error-handling-media-1.html at-rule-error-handling-ref.html
 == invalid-font-face-descriptor-1.html invalid-font-face-descriptor-1-ref.html
+== two-dash-identifiers.html two-dash-identifiers-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/two-dash-identifiers-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+  div { color: green; }
+</style>
+<div>This should be green.</div>
+<div>This should be green.</div>
+<div>This should be green.</div>
+<div>This should be green.</div>
+<div>This should be green.</div>
+<div>This should be green.</div>
+<div>This should be green.</div>
+<div>This should be green.</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/two-dash-identifiers.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<style>
+  .ok { color: red; }
+  #-- { color: green; }
+  #-foo { color: green }
+  #--foo { color: green; }
+  .-- { color: green; }
+  .-foo { color: green; }
+  .--foo { color: green; }
+
+  .fail { color: green; }
+  #- { color: red; }
+  .- { color: red; }
+</style>
+<div class="ok" id="--">This should be green.</div>
+<div class="ok" id="-foo">This should be green.</div>
+<div class="ok" id="--foo">This should be green.</div>
+<div class="ok --">This should be green.</div>
+<div class="ok -foo">This should be green.</div>
+<div class="ok --foo">This should be green.</div>
+<div class="fail" id="-">This should be green.</div>
+<div class="fail -">This should be green.</div>
--- a/layout/style/nsCSSScanner.cpp
+++ b/layout/style/nsCSSScanner.cpp
@@ -160,17 +160,17 @@ IsIdentStart(int32_t ch) {
 /**
  * True if the two-character sequence aFirstChar+aSecondChar begins an
  * identifier.
  */
 static inline bool
 StartsIdent(int32_t aFirstChar, int32_t aSecondChar)
 {
   return IsIdentStart(aFirstChar) ||
-    (aFirstChar == '-' && IsIdentStart(aSecondChar));
+    (aFirstChar == '-' && (aSecondChar == '-' || IsIdentStart(aSecondChar)));
 }
 
 /**
  * True if 'ch' is a decimal digit.
  */
 static inline bool
 IsDigit(int32_t ch) {
   return (ch >= '0') && (ch <= '9');