Commit Graph

477 Commits

Author SHA1 Message Date
Cameron McCormack
4fd40c24b6 Bug 773296 - Part 18: Add error reporting for invalid variable references. r=dbaron
This adds CSS parser error reporting for parsing of custom properties
and normal properties that have variable references.

When re-parsing a normal property that had a variable reference, we
report any parse error to be at the beginning of the property value.
This is because it is difficult to keep track of where exactly each
variable substitution came from to point to the particular value
that would have caused the parse error.  For example, with this:

  :root {
    var-a: 1px 2px;
    var-b: 3px var(a);
  }
  p {
    margin: var(a) var(b);
  }

we would end up resolving the value of 'margin' to:

  "  1px 2px  3px  1px 2px"

In this string, the parse error occurs when we encounter the final
"2px", but by this point we don't know where that value came from.
So instead we just point to the line on which 'margin' was declared.

We extend ErrorReporter with an OutputError overload that takes the
specific line and column number to use in the error report to get this
right, and we store the line and column number for each token stream
we parse on the nsCSSValueTokenStream object.
2013-12-12 13:09:44 +11:00
Cameron McCormack
33b0fd85d7 Bug 773296 - Part 17: Resolve property values that have variable references at computed value time. r=dbaron
This re-parses property values at computed value time if
they had a specified value that was a token stream.  We add
a function nsRuleNode::ResolveVariableReferences that looks
at all the values in the nsRuleData and calls in to a new
nsCSSParser::ParsePropertyWithVariableReferences function if they have a
token stream value.

We add a nsCSSExpandedDataBlock::MapRuleInfoInto function that will
take the re-parsed property value and copy it back into the nsRuleData.

nsRuleNode::ResolveVariableReferences returns whether any variables
were attempted to be resolved, so that nsRuleNode::WalkRuleTree wil
recompute the rule detail in case any became 'inherit'.
2013-12-12 13:09:44 +11:00
Cameron McCormack
835faf601a Bug 773296 - Part 16: Add a ref-counted list nsCSSValue unit and use it for tranform lists; hold a strong reference to one on nsStyleDisplay. r=dbaron
This adds a new eCSSUnit_SharedList type for nsCSSValue, which is a
reference counted object that contains an nsCSSValueList.  We need this
so that nsStyleDisplay::mSpecifiedTransform can hold a strong reference
to a specified transform list value.  When 'transform' is specified
using a variable reference, the resulting nsCSSValue does not stick
around in the Declaration object, so we wouldn't be guaranteed that
it lives long enough for nsStyleDisplay to keep referencing it.
2013-12-12 13:09:44 +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
Cameron McCormack
82a5ba3c0f Bug 773296 - Part 4: Add style struct to store CSS variables. r=dbaron
This adds an nsStyleVariables on which computed variable values
will be stored.  We don't actually have any properties assigned to
nsStyleVariables; eCSSPropertyExtra_Variables which we added earlier
isn't a real property.  To avoid compiler errors for gVariableFlags
being a zero length array, we stick a dummy entry in there.

nsRuleNode::ComputeVariablesData does nothing for the moment.

nsStyleVariable nsChangeHint calculations always return 0, as later
we will compare the actual properties that reference variables to
see what changes are required for them.
2013-12-12 13:09:40 +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
Cameron McCormack
4b609f14ad Fix some comments; no bug. (DONTBUILD) 2013-12-09 10:14:00 +11:00
Daniel Holbert
951d9cad0d Bug 702508 part 2: Support parsing/computing the CSS property "align-content". r=dbaron 2013-12-05 10:57:50 -08:00
Daniel Holbert
c58200db33 Bug 702508 part 1: Support parsing/computing the CSS property "flex-wrap". r=dbaron 2013-12-05 10:57:50 -08:00
Phil Ringnalda
f9cbdee9b1 Back out 29e6539961c3 (bug 935056) for re-causing bug 939980 2013-12-04 23:11:00 -08:00
Cameron McCormack
a37f2de79b Bug 935056 - Don't apply minimum font sizes to SVG text. r=dbaron 2013-12-05 11:55:45 +11:00
James Kitchener
78f696b93f Bug 114365 - Add CSS properties for -moz-math-variant. r=heycam 2013-12-02 11:49:00 -05:00
John Daggett
595e66c8e0 Bug 934710 - add various text performance metrics and a log to handle these. r=jfkthame 2013-11-25 13:59:56 +09:00
Cameron McCormack
f1bb3132a3 Back out bug 935056 (rev d39a3544a287) on suspicion of causing bug 939980. 2013-11-21 10:24:04 +11:00
Nathan Froyd
8b82865186 Bug 940170 - part 1 - constify PLDHashTableOps in layout/; r=bz 2013-11-18 21:51:48 -05:00
Cameron McCormack
15efcbad48 Bug 935056 - Don't apply minimum font sizes to SVG text. r=dbaron 2013-11-18 14:53:51 +11:00
Horia Iosif Olaru
1340220842 Bug 841601 - Add background-blend-mode to the style parsing mechanism. r=heycam 2013-11-08 10:07:36 -05:00
Mats Palmgren
091575a0f7 Bug 929991 - Style system implementation of 'text-align: true X'. r=heycam 2013-10-27 20:56:32 +00:00
Max Vujovic
b1e4d40e37 Bug 913990 - When encountering bogus URI during style computation for filter, fall back to initial value. r=dholbert 2013-10-17 14:37:57 -04:00
Birunthan Mohanathas
b823b8896b Bug 784739 - Switch from NULL to nullptr in layout/; r=ehsan
--HG--
extra : rebase_source : 0d0d9e11be9d39e4457bddd0bac7e19a50b91b0b
2013-10-08 14:47:21 -04:00
Cameron McCormack
548f50580d Bug 921731 - Part 8: Support "unset" in computation of properties. r=bzbarsky 2013-10-04 04:49:18 +10:00
Cameron McCormack
f3b8113210 Bug 921731 - Part 7: Treat "unset" on inherited properties like "inherit" in nsRuleNode::HasAuthorSpecifiedRules. r=bzbarsky 2013-10-04 04:49:18 +10:00
Cameron McCormack
8058e5a031 Bug 921731 - Part 6: Treat "unset" as "inherit" when determining rule detail for inherited style structs. r=bzbarsky 2013-10-04 04:49:18 +10:00
Cameron McCormack
6699cf7840 Bug 921731 - Part 5: Support eCSSUnit_Unset in nsRuleNode.cpp's SetFactor. r=bzbarsky 2013-10-04 04:49:18 +10:00
Cameron McCormack
ae26d6be95 Bug 921731 - Part 4: Support eCSSUnit_Unset in nsRuleNode.cpp's SetDiscrete. r=bzbarsky 2013-10-04 04:49:17 +10:00
Cameron McCormack
2fb509641f Bug 921731 - Part 3: Support eCSSUnit_Unset in nsRuleNode.cpp's SetCoord. r=bzbarsky 2013-10-04 04:49:17 +10:00
Ehsan Akhgari
1e1f27abed Bug 923151 - Part 2: Don't #include nsIDocument.h in mozilla/dom/Element.h; r=jst
--HG--
extra : rebase_source : 8c5f5429574313a1304eb2779cdb6b5702e4094d
2013-10-02 16:09:18 -04:00
Cameron McCormack
464d030850 Bug 918176 - Silence uninitialized variable warning in nsRuleNode::ComputeContentData. r=dholbert 2013-09-20 11:24:04 +10:00
Cameron McCormack
fd7ff97f2d No bug - Fix copy/paste error in 'mix-blend-mode' comment. (DONTBUILD) 2013-09-28 18:03:31 +10:00
Jonathan Kew
1bb33a7108 Bug 798843 - Rename -moz-objectFill, -moz-objectStroke, -moz-objectValue to context-fill, context-stroke, context-value r=dbaron
* * *
bug 798843 - recompile svg.woff font to pick up the updated glyph definitions
* * *
bug 798843 - update property_database.js to match the new property names
2013-05-16 14:35:15 +12:00
Seth Fowler
e57e4a214f Bug 825771 (Part 1) - Add CSS support for the image-orientation property. r=dbaron 2013-08-28 15:39:06 -07:00
Ehsan Akhgari
2faab8bc9e Bug 908724 - Avoid #including nsPresContext.h in nsIScrollableFrame.h; r=mats
nsPresContext.h pulls in a large number of headers which should not
be needed in nsIScrollableFrame, if we just move ScrollbarStyles to
its own header
2013-08-23 16:20:07 -04:00
John Daggett
0ad5eb80ed Bug 875250 - implement CSS parsing of text-orientation, text-combine-horizontal properties. r=dholbert 2013-08-19 19:26:44 +09:00
Masayuki Nakano
03e0066f13 Bug 812995 Support 'blink' value at -moz-text-decoration-line and drop -moz-text-blink r=dbaron 2013-08-06 23:02:34 +09:00
Ms2ger
7bf62da840 Backout changeset f2ac3d57b445 for insufficient review. 2013-08-08 19:37:47 +02:00
Masayuki Nakano
e08e2dc2d3 Bug 812995 Support 'blink' value at -moz-text-decoration-line and drop -moz-text-blink r=dbaron 2013-08-06 23:02:34 +09:00
Rik Cabanier
6db63a8c81 Bug 901375 - Implement support in CSS for mix-blend-mode; r=heycam 2013-08-07 16:59:10 +09:00
Max Vujovic
a0613f3e89 Bug 898175 - Refactor filter parsing to use a keyword lookup table for filter function names. r=dbaron 2013-08-06 17:53:30 +10:00
Dirk Schulze
c25ee40e1c Bug 898361 - Implement parsing for drop-shadow. r=heycam 2013-08-05 17:02:27 +10:00
Ms2ger
48039b419a Backout changeset a58abd7408bf for mochitest and crashtest crashes. 2013-08-04 12:21:17 +02:00
Dirk Schulze
87b8fb4c7c Bug 898361 - Implement drop-shadow parsing for the filter property. r=heycam 2013-08-04 18:58:28 +10:00
Cameron McCormack
975a0a23c3 Bug 899894 - Don't null check nsStyleSet::ResolveBlah return values. r=dbaron 2013-08-03 14:11:06 +10: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
John Daggett
a9de42a1ec Bug 857142 - change name and switch to grayscale value. r=dbaron 2013-07-30 05:01:14 +09:00
John Daggett
bed3fbfbd2 Bug 857142 - implement -moz-font-smoothing. r=dbaron 2013-07-30 05:00:41 +09:00
Dirk Schulze
835b4ca022 Bug 897392 - Implement parsing of filter:hue-rotate(). r=heycam 2013-07-26 16:02:33 +10:00
Cameron McCormack
379b6a82ac Bug 890773 - Compute -x-text-zoom properly. r=dbaron 2013-07-25 10:42:11 +10:00
Max Vujovic
a3d913c879 Bug 895182 - [CSS Filters] Implement parsing for blur, brightness, contrast, grayscale, invert, opacity, saturate, sepia. Co-authored with Dirk Schulze (krit). r=heycam 2013-07-22 15:08:33 -07:00
Ed Morley
97e3c032bc Backed out changeset f24d81b85929 (bug 895182) for Windows build failures on a CLOSED TREE 2013-07-23 16:36:45 +01:00
Max Vujovic
cac859d2f2 Bug 895182 - [CSS Filters] Implement parsing for blur, brightness, contrast, grayscale, invert, opacity, saturate, sepia. Co-authored with Dirk Schulze (krit). r=heycam 2013-07-23 10:47:16 -04:00