Commit Graph

101 Commits

Author SHA1 Message Date
Cameron McCormack
14c9ae88db Bug 773296 - Part 11: Give nsCSSParser and nsCSSScanner the ability to save/restore their current input state. r=dbaron
This adds functions to nsCSSParser and nsCSSScanner that let us save the
current input position (and corresponding information like line/column
number) and parser pushback, and be able to restore it later.  We'll use
this when rewinding the scanner after we first encounter a property with
a variable reference and go back to reparse it as a token stream.
2013-12-12 13:09:42 +11:00
Cameron McCormack
6c08a4ff75 Bug 773296 - Part 9: Give nsCSSScanner the ability to remember when it encounters a "var(" token. r=dbaron
This is the first part of handling variable references in regular
properties.  We have the scanner set a flag whenever it returns a "var("
token, so that when we come to the end of parsing a property that
failed, we know that it is because of a variable reference.
2013-12-12 13:09:42 +11:00
Cameron McCormack
4fb5922824 Bug 773296 - Part 8: Resolve and compute CSS variables. r=dbaron
We add a new class CSSVariableResolver whose job is to take the
inherited computed variables and the specified variable declarations and
to perform cycle removal and resolution of the variables, storing the
result in the CSSVariableValues object on an nsStyleVariables.  We use
CSSVariableResolver in nsRuleNode::ComputeVariablesData.

The variable resolver does this:

  1. Asks the CSSVariableValues and CSSVariableDeclarations objects
     to add their variables to it.
  2. Calls in to a new nsCSSParser function
     EnumerateVariableReferences that informs the resolver which
     other variables a given variable references, and by doing so,
     builds a graph of variable dependencies.
  3. Removes variables involved in cyclic references using Tarjan's
     strongly connected component algorithm, setting those variables
     to have an invalid value.
  4. Calls in to a new nsCSSParser function ResolveVariableValue
     to resolve the remaining valid variables by substituting variable
     references.

We extend nsCSSParser::ParseValueWithVariables to take a callback
function to be invoked when encountering a variable reference.  This
lets EnumerateVariableReferences re-use ParseValueWithVariables.

CSSParserImpl::ResolveValueWithVariableReferences needs different
error handling behaviour from ParseValueWithVariables, so we don't
re-use it.

CSSParserImpl::AppendImpliedEOFCharacters is used to take the
value returned from nsCSSScanner::GetImpliedEOFCharacters while
resolving variable references that were declared using custom
properties that encountered EOF before being closed properly.

The SeparatorRequiredBetweenTokens helper function in nsCSSParser.cpp
implements the serialization rules in CSS Syntax Module Level 3:

https://dvcs.w3.org/hg/csswg/raw-file/3479cdefc59a/css-syntax/Overview.html#serialization
2013-12-12 13:09:41 +11:00
Birunthan Mohanathas
58325c73be Bug 713082 - Part 2: Rename Util.h to ArrayUtils.h. r=Waldo
--HG--
rename : mfbt/Util.h => mfbt/ArrayUtils.h
2013-12-08 21:52:54 -05:00
Birunthan Mohanathas
bd0f161288 Bug 713082 - Part 1: Remove unnecessary Util.h includes. r=Waldo 2013-12-08 21:52:33 -05:00
Cameron McCormack
42f0f46be2 Bug 914072 - Have nsCSSScanner store any implied characters at EOF needed for correct serialization. r=dbaron 2013-12-07 12:25:07 +11:00
Ehsan Akhgari
d5d3a9ae84 Bug 916610 - Minimize the #includes in layout/style; r=roc 2013-09-15 21:06:52 -04:00
Ehsan Akhgari
085494b95d Bug 895322 - Part 1: Replace the usages of MOZ_STATIC_ASSERT with C++11 static_assert; r=Waldo
This patch was mostly generated by running the following scripts on the codebase, with some
manual changes made afterwards:

# static_assert.sh
#!/bin/bash
# Command to convert an NSPR integer type to the equivalent standard integer type

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.cc" \
         -o -iname "*.mm" \) | \
    xargs -n 1 `dirname $0`/assert_replacer.py #sed -i -e "s/\b$1\b/$2/g"
}

convert MOZ_STATIC_ASSERT static_assert
hg rev --no-backup mfbt/Assertions.h \
                   media/webrtc/signaling/src/sipcc/core/includes/ccapi.h \
                   modules/libmar/src/mar_private.h \
                   modules/libmar/src/mar.h


# assert_replacer.py
#!/usr/bin/python

import sys
import re

pattern = re.compile(r"\bMOZ_STATIC_ASSERT\b")

def replaceInPlace(fname):
  print fname
  f = open(fname, "rw+")
  lines = f.readlines()
  for i in range(0, len(lines)):
    while True:
      index = re.search(pattern, lines[i])
      if index != None:
        index = index.start()
        lines[i] = lines[i][0:index] + "static_assert" + lines[i][index+len("MOZ_STATIC_ASSERT"):]
        for j in range(i + 1, len(lines)):
          if lines[j].find("                 ", index) == index:
            lines[j] = lines[j][0:index] + lines[j][index+4:]
          else:
            break
      else:
        break
  f.seek(0, 0)
  f.truncate()
  f.write("".join(lines))
  f.close()

argc = len(sys.argv)
for i in range(1, argc):
  replaceInPlace(sys.argv[i])

--HG--
extra : rebase_source : 4b4a4047d82f2c205b9fad8d56dfc3f1afc0b045
2013-07-18 13:59:53 -04:00
Corey Ford
fbf08070fa Bug 883987 - Don't allow BAD_STRING or BAD_URL tokens in @supports conditions. r=dbaron 2013-06-27 17:03:33 -07:00
Corey Ford
417fcffdce Bug 829816 - Treat \0 and U+0000 in CSS style sheets as U+FFFD. r=dbaron 2013-06-26 15:17:14 -07:00
Cameron McCormack
1cc273c880 Bug 880150 - Treat \<EOF> as U+FFFD outside a string, and drop it inside a string. r=dbaron 2013-06-10 17:04:27 +10:00
David Zbarsky
c596ef885a [Bug 847110] Fix up includes in layout/style r=dbaron 2013-03-02 19:31:48 -05:00
Zack Weinberg
def7baa066 Bug 842134: fix serialization of unquoted url() in CSS. r=heycam 2013-02-17 22:03:55 -05:00
Zack Weinberg
b78db0f4d6 Bug 543151, part A4: unify the inner text-scanning loops used by GatherIdent, ScanString, NextURL. r=heycam 2013-02-16 18:27:53 -05:00
Zack Weinberg
0fbb550fc0 Bug 543151, part A3: convert the scanner to use peek/advance. r=heycam 2013-02-16 18:27:53 -05:00
Zack Weinberg
57e2a60ca6 Bug 543151, part A2: Introduce the new peek/advance API and reimplement the old read/pushback API on top of it. r=heycam 2013-02-16 18:27:53 -05:00
Zack Weinberg
575de8ae8c Bug 543151, part A1: Preliminary cleanups to the scanner/parser interface and the organization of nsCSSScanner.cpp. r=heycam 2013-02-16 18:27:53 -05:00
L. David Baron
68ac09e29e Bug 836530: Make all non-ASCII characters be CSS identifier characters. r=bzbarsky
This is as was proposed in
http://lists.w3.org/Archives/Public/www-style/2013Jan/0394.html
and resolved in the CSS Working Group's teleconference on 2013-01-30.

This removes a difference between Gecko and other browsers.
2013-01-31 20:09:47 -08:00
Mats Palmgren
d5826be6d7 Bug 786533 - Replace NS_MIN/NS_MAX with std::min/std::max and #include <algorithm> where needed. r=ehsan 2013-01-15 13:22:03 +01:00
Zack Weinberg
02d54c729f Bug 413958: report the text of the offending line in CSS error messages. r=dbaron 2013-01-11 12:27:43 -05:00
Zack Weinberg
3156225b0e Bug 229827: escape unprintable characters in CSS parser diagnostics. r=dbaron 2012-11-16 21:53:38 -05:00
Ryan VanderMeulen
2621afbb4e Backed out changesets b242651c3c1b (bug 229827), b36eaac9ecf8, and 40f38a8aa660 (bug 663291) for mochitest-3/4 failures.
CLOSED TREE
2012-11-16 16:59:38 -05:00
Zack Weinberg
5c6f43e9ec Bug 229827: escape unprintable characters in CSS parser diagnostics. r=dbaron
--HG--
extra : rebase_source : 9298095c2cd7669b5ca1a07cd5378a852c4a7f36
2012-11-16 15:29:21 -05:00
Zack Weinberg
35c608da33 Bug 455839: simplify the CSS error reporting API. r=dbaron 2012-11-15 11:36:15 -05:00
Zack Weinberg
974d69cf27 Bug 516091: Split CSS error reporting to its own file and class. Allows CSS scanner to become a stack object. r=dbaron 2012-11-15 11:36:15 -05:00
Jacek Szpot
bea8356b2c Bug 792180 - Replace NS_{UN,}LIKELY with MOZ_{UN,}LIKELY; r=ehsan 2012-10-26 15:32:10 +02:00
Seth Fowler
ed479625af Bug 786108 - Cache UTF-16 version of URI to prevent repeated conversions in the CSS scanner, and free the cache after a short time. r=bz 2012-10-03 15:28:57 -07:00
Ed Morley
9bd985c476 Backout ec0dcd401a3f (bug 786108) for crashes 2012-09-28 22:04:56 +01:00
Seth Fowler
e97e0bcb99 Bug 786108 - Cache UTF-16 version of URI to prevent repeated conversions in the CSS scanner, and free the cache after a short time. r=bz 2012-09-28 09:56:47 -07:00
Isaac Aggrey
0cc4b12d36 Bug 791906: Replace NSPR integer limit constants with stdint ones; r=ehsan 2012-09-28 01:57:33 -05:00
Mats Palmgren
b602620a6a Bug 788836 - Simplify @-keyword parsing by letting ParseAtKeyword deal with everthing after the @. Make it pass the first char to GatherIdent so that it returns false for a bad escape sequence at the start. r=dbaron 2012-09-12 00:20:52 +02:00
Daniel Holbert
f8dfa24152 Bug 789382: Change nsIScriptError methods init() and initWithWindowID() to take nsAString, rather than wchar / PRUnichar*. r=bz sr=bsmedberg 2012-09-09 16:29:12 -07:00
Ehsan Akhgari
8c296bbcd4 Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00
Aryeh Gregor
4c54d98fcb Bug 782252 - Change named constants to correct types; r=ehsan 2012-08-07 18:11:35 +03:00
Cameron McCormack
78727e2c15 Bug 649740 - Implement @supports. r=dbaron,bz 2012-08-02 10:32:12 +10:00
Aryeh Gregor
57c0ad57fb Bug 777292 part 2 - Change all nsnull to nullptr 2012-07-30 17:20:58 +03:00
Gervase Markham
87620f5676 Bug 716478 - update licence to MPL 2. 2012-05-21 12:12:37 +01:00
Kang-Hao (Kenny) Lu
74ab6d1729 Bug 752230 - Disallow control characters above 0x7e in CSS unquoted url() tokenization. r=dbaron 2012-05-14 19:01:05 -04:00
Jacob Holzinger
86f648606c Bug 696242 - Convert NS_RegisterStaticAtoms and nsCSSScanner::ReportUnexpectedParams to take an array-reference rather than a pointer and length, making it impossible to pass a pointer/length that are inconsistent. r=jwalden
--HG--
extra : rebase_source : 882b5b4d500b1fa242c0a3cfa3084e4171cbaa9d
2012-03-08 18:22:57 -08:00
Zack Weinberg
dc30af584b Bug 729142 - Convert layout/style to MOZ_STATIC_ASSERT. r=dbaron 2012-02-23 08:19:00 -08:00
aceman
42a71aa907 Bug 711721 - merge nsIScriptError and nsIScriptError2 interfaces; r=neil, sr=bzbarsky 2011-12-21 16:51:29 -05:00
Zack Weinberg
7ef69cf55a Bug 659963: consistently use infallible malloc in the CSS parser. r=dbaron 2011-05-28 15:38:48 -07:00
Zack Weinberg
432b298661 Bug 543151 part 2: Remove the special (but inconsistent with the error console) handling of hard tabs; small tidiness tweaks. r=dbaron 2011-05-19 15:44:14 -07:00
Zack Weinberg
6f73ba4b1a Bug 543151 part 1: Remove stream-processing code from nsCSSScanner.cpp. r=dbaron 2011-05-18 10:33:16 -07:00
Ehsan Akhgari
2a602a5685 Bug 690892 - Replace PR_TRUE/PR_FALSE with true/false on mozilla-central; rs=dbaron
Landing on a CLOSED TREE
2011-10-17 10:59:28 -04:00
Jeff Walden
b7753477cf Bug 693469 - Implement mozilla::ArrayLength and mozilla::ArrayEnd, and replace uses of NS_ARRAY_LENGTH whenever possible. (Exceptions: assigning to static initializers, use in static assertions, as template parameters, etc. These will go away when the relevant compilers have C++11 constexpr support.) r=cjones
--HG--
extra : rebase_source : b4bae9a0f85abf2feb828609b50e756916b99a6f
2011-10-10 22:50:08 -07:00
Jeff Walden
eb2cb918a4 Back out everything since 5435ee09cf7b. Tinderbox compilers hate me. r=epic-fail 2011-10-12 12:21:53 -07:00
Jeff Walden
77ebbde4ab Bug 639469 - Implement mozilla::ArrayLength and mozilla::ArrayEnd, and replace uses of NS_ARRAY_LENGTH whenever possible. r=cjones
--HG--
extra : rebase_source : 860a8271bf7e51cde358f2a4185c410de1fc2960
2011-10-10 22:50:08 -07:00
Michael Wu
d8e503c38b Bug 675553 - Switch from PRBool to bool on a CLOSED TREE , r=bsmedberg,khuey,bz,cjones
--HG--
rename : tools/trace-malloc/bloatblame.c => tools/trace-malloc/bloatblame.cpp
2011-09-28 23:19:26 -07:00
Mihai Sucan
726b8bb058 Bug 670896 - Add inner window ID and timestamp to nsIScriptError2; r=bzbarsky 2011-08-24 23:44:35 +03:00