Commit Graph

19412 Commits

Author SHA1 Message Date
Cameron McCormack
ba08f38dc0 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
9ee3123e5b 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
ff1a22b1fb Bug 773296 - Part 16a: Followup to move to using nsCSSValueSharedList in OMTA code. r=roc 2013-12-12 13:09:44 +11:00
Cameron McCormack
6f8dcf77b4 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
c9f98a4a96 Bug 773296 - Part 15: Factor out mapping of a single property from an nsCSSCompressedDataBlock to an nsRuleData. r=dbaron
This factors out the part of nsCSSCompressedDataBlock::MapRuleInfoInto
that starts image loading and maybe-copies an nsCSSValue into
an nsRuleData.  We will need this functionality for mapping re-parsed
properties that had variable references into an nsRuleData, which
will be done from an nsCSSExpandedDataBlock.
2013-12-12 13:09:43 +11:00
Cameron McCormack
b6a267e600 Bug 773296 - Part 14: Add an nsCSSProps::IsInherited function. r=dbaron
Add a helper function to nsCSSProps to look up whether a given
nsCSSProperty lives in a style struct for inherited properties.
2013-12-12 13:09:43 +11:00
Cameron McCormack
a0619a17d7 Bug 773296 - Part 13: Parse properties that use variable references and store them as eCSSUnit_TokenStream values. r=dbaron
This adds functionality to nsCSSParser to recognise properties with
variable references and store their recorded token stream as an
eCSSUnit_TokenStream nsCSSValue.
2013-12-12 13:09:43 +11:00
Cameron McCormack
b3d54fbac2 Bug 773296 - Part 12: Record whether we are parsing an @supports condition. r=dbaron
This stores on the nsCSSParser whether we are somewhere in the middle
of parsing an @supports condition.  Because @supports condition parsing
uses the scanner recording function (to save its conditionText), and
variable reference containing values also need it, we can't do both at
once.  Luckily, if we're parsing an @supports condition, we don't really
need to store the token stream text; we only need to know if it was
valid, and we don't need its actual value later.  So we use this flag
later to see if we can skip turning on scanner recording while parsing
variable reference containing values.
2013-12-12 13:09:42 +11:00
Cameron McCormack
199e5af323 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
18286576a6 Bug 773296 - Part 10: Add a new eCSSUnit_TokenStream type for storing unparsed CSS values. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>

This adds a new nsCSSValue unit type to represent an unparsed
stream of CSS tokens as a specified value.  This is what properties
that have a variable reference get as their specified value.

On the nsCSSValueTokenStream object that is used when mUnit ==
eCSSUnit_TokenStream, we store two property IDs: first, the property
ID for the longhand that this token stream value is the value for.  We
pass this back in to nsCSSParser::ParseProperty at computed value time,
when we need to re-parse the property.  Second is the shorthand property
ID, if we used a variable reference in a shorthand.  In such a case, we
store the token stream value for each of the corresponding longhand
properties.  This is because shorthands don't actually get any storage
in an nsRuleData, and because any of the longhands might be overwritten
by subsequent declarations, we need to keep the token stream somewhere.

We also store other information on the nsCSSValueTokenStream required by
the CSS parser (base URI, etc.).
2013-12-12 13:09:42 +11:00
Cameron McCormack
abd5cd702d 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
589b3b4774 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
0d9fb33ac3 Bug 773296 - Part 7: Add a field to nsStyleVariables to store computed variable values. r=dbaron
This defines a class CSSVariableValues which is used to store
computed variable values.  We store them a bit differently from
CSSVariableDeclarations -- here we have a hash table of variable names
to integer IDs, and then an array of variables where the array index
is the ID.  This is because later on we'll want a stable order for the
variables to return from DOM APIs.

In addition to the string value of the variable, we store the type
of the first and last token of the variable value.  This information
will be used when resolving entire variable reference containing
values, to determine when to insert "/**/" before and after a resolved
var(blah) token.

We add a CSSVariableValues member to nsStyleVariables.
2013-12-12 13:09:41 +11:00
Cameron McCormack
923fe40ec1 Bug 773296 - Part 6: Add enum to represent types of CSS tokens involved in serialization. r=dbaron
This adds an enum to nsCSSScanner.h that represents the types of tokens
we need to consider when pasting together two adjacent tokens during
serialization or variable resolution.  For example with:

  var-a:orange;
  var-b:red;
  color:var(a)var(b);

we need to generate the string "orange/**/red" to parse for the value of
'color'.
2013-12-12 13:09:41 +11:00
Cameron McCormack
1d90c6a110 Bug 773296 - Part 5: Map variables on a Declaration to nsRuleData. r=dbaron
This adds a CSSVariableDeclarations object to nsRuleData and adds a
MapRuleInfoInto function to CSSVariableDeclarations so the can copy
variable declarations into a nsRuleData's object.  We call that from
Declaration::Map{Normal,Important}RuleInfoInto.

We make HasImportantData return true if we have important variables
but no important non-custom properties on a declaration, since that
is used to determine whether we have a rule node for important
declarations.  This means MapImportantRuleInfoInto can no longer
assume that mImportantData is non-null.
2013-12-12 13:09:41 +11:00
Cameron McCormack
8a80d29205 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
Cameron McCormack
52ae26eb58 Bug 773296 - Part 3: Allow more than 27 style structs. r=dbaron
This bumps up nsStyleContext::mBits to a uint64_t so that it can fit
another style struct.  If we're going to need to keep at least 27 style
structs, it might be better to split mBits up into two uint32_ts: one
for the flags and one for the style struct bits.
2013-12-12 13:09:40 +11:00
Cameron McCormack
5edbefbd77 Bug 773296 - Part 2: Parse CSS variable declarations and store them on Declaration objects. p=ebassi,heycam r=dbaron
Patch co-authored by Emmanuele Bassi <ebassi@gmail.com>

This defines a CSSVariableDeclarations class that holds a set of
variable declarations.  This is at the specified value stage, so values
can either be 'initial', 'inherit' or a token stream (which is what you
normally have).  The variables are stored in a hash table.  Although
it's a bit of a hack, we store 'initial' and 'inherit' using special
string values that can't be valid token streams (we use "!" and ";").

Declaration objects now can have two CSSVariableDeclarations objects
on them, to store normal and !important variable declarations.  So that
we keep preserving the order of declarations on the object, we inflate
mOrder to store uint32_ts, where values from eCSSProperty_COUNT onwards
represent custom properties.  mVariableOrder stores the names of the
variables corresponding to those entries in mOrder.

We also add a new nsCSSProperty value, eCSSPropertyExtra_variable, which
is used to represent any custom property name.
nsCSSProps::LookupProperty can return this value.

The changes to nsCSSParser are straightforward.  Custom properties
are parsed and checked for syntactic validity (e.g. "var(a,)" being
invalid) and stored on the Declaration.  We use nsCSSScanner's
recording ability to grab the unparsed CSS string corresponding to
the variable's value.
2013-12-12 13:09:40 +11:00
Emmanuele Bassi
2ecde08892 Bug 773296 - Part 1: Add a preference for CSS variables. r=dbaron 2013-12-12 13:09:40 +11:00
Cameron McCormack
695b54e296 Bug 909170 - Add some tests for @supports conditions with tokens after a declaration's priority. r=dbaron 2013-12-12 13:09:39 +11:00
Bobby Holley
517f4b36f3 Bug 937317 - Remove unnecessary AutoSystemCaller usage. r=bz
See bug 937317 comment 38.
2013-12-11 17:51:58 -08:00
Bobby Holley
a7395d2ec6 Bug 937317 - Replace all instance of null cx pushing with AutoSystemCaller. r=bz
This is an easy bonus chunk of the work to phase out cx pushing in the browser.
2013-12-11 17:51:58 -08:00
Benoit Girard
67bca7c4a8 Bug 948531 - Layerize elements with transition or animation immediately. r=mattwoodrow 2013-12-11 15:48:06 -05:00
Ryan VanderMeulen
66b0cd57b1 Backed out changeset d8fb025ca7d2 (bug 948531) for suspicion of causing OSX 10.6 debug mochitest-5 orange.
CLOSED TREE
2013-12-11 18:47:03 -05:00
Benoit Girard
3ab22db671 Bug 948531 - Layerize elements with transition or animation immediately. r=mattwoodrow
--HG--
extra : rebase_source : 06725514680d5041c547149f6ecd758061936a4e
2013-12-11 15:48:06 -05:00
Matt Woodrow
533d84ea6d Bug 948221 - Part 7: Convert SurfaceFromElement to Moz2D. r=roc,Bas,bjacob 2013-12-12 10:05:27 +13:00
Matt Woodrow
3c1166d0d1 Bug 948221 - Part 2: Remove SFE_WANT_NEW_SURFACE since it's never used. r=roc 2013-11-27 14:05:02 +13:00
Xidorn Quan
a85b5ede33 Bug 946895 - Add missing values of list-style-type for property_database.js 2013-12-11 12:55:43 -08:00
Adam Casey
2c3bb0dff5 Bug 874919 - Added a check to DoGetWidth/Height so the width/height properties of getComputedStyle now return correct values on inline SVG elements. r=bz 2013-12-11 14:13:48 -05:00
Ryan VanderMeulen
ec34e0fb19 Merge inbound to m-c. 2013-12-11 13:32:11 -05:00
Ryan VanderMeulen
106d512427 Merge b2g-inbound to m-c. 2013-12-11 13:24:26 -05:00
Henri Sivonen
b9f48db958 Bug 946647 - Remove bidi options from nsIMarkupDocumentViewer as dead code. r=smontagu. 2013-12-11 15:47:50 +02:00
Alexander Surkov
41e7c3ad7c Bug 559761 - make <input type=number> accessible, r=tbsaunde, smaug
--HG--
rename : accessible/tests/mochitest/value/test_range.html => accessible/tests/mochitest/value/test_number.html
2013-12-10 22:19:26 -05:00
Jonathan Watt
f8f9233117 Bug 946184 - Make sure that we reframe the nsIAnonymousContentCreator if any nsIAnonymousContentCreator::ContentInfo created content needs reframing. r=bz 2013-12-11 11:41:51 +00:00
Jonathan Watt
2dc144a988 Bug 948475 - Implement HTMLInputElement.select() for <input type=number> (contrary to the HTML5 spec) since content needs it. r=smaug 2013-12-11 11:41:51 +00:00
Daniel Holbert
33ac0ac009 Bug 948654: Uncomment lines to make 'align-content' and 'flex-wrap' inherit through scroll frames to scrolled flex containers. r=mats
--HG--
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-3-ref.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-4-ref.html
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-3.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-4.html
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-3-ref.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-5-ref.html
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-3.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-horiz-5.html
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-3-ref.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-4-ref.html
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-3.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-4.html
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-3-ref.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-5-ref.html
rename : layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-3.html => layout/reftests/w3c-css/submitted/flexbox/flexbox-overflow-vert-5.html
2013-12-10 22:31:38 -08:00
Cameron McCormack
d1d5dcf5d8 Bug 947082 - List parent style context in frame tree dumps. r=mats 2013-12-11 17:13:20 +11:00
Jonathan Watt
25a2974cc7 Bug 948549 - Make <input type=number> behave and look disabled when the 'disabled' attribute is set or it's inside a disabled fieldset. r=smaug 2013-12-11 02:13:06 +00:00
Wes Kocher
b7e717b615 Merge m-c to b2g-inbound 2013-12-10 17:14:14 -08:00
Ryan VanderMeulen
6fb3114a62 Merge m-c to inbound. 2013-12-10 15:48:16 -05:00
Ryan VanderMeulen
e58ec03427 Merge b2g-inbound to m-c. 2013-12-10 15:38:44 -05:00
Ryan VanderMeulen
4560ff8be7 Bug 933264 - Add fuzz to the reftest on OSX 10.6. r=tn
CLOSED TREE
2013-12-10 15:21:46 -05:00
Daniel Holbert
59884b6080 (no bug) fix typo in comment within reftest reference case 'flexbox-overflow-vert-3-ref.html'. DONTBUILD because comment-only 2013-12-10 16:59:28 -08:00
Nicholas Cameron
d58229b635 Bug 946958 part 2. Remove methods which just forward to compositor. r=mattwoodrow 2013-12-09 14:40:59 +13:00
Ehsan Akhgari
d4490ee3c7 Bug 947736 - Build modules/libpref/ in unified mode; r=bsmedberg 2013-12-10 18:10:01 -05:00
Kartikaya Gupta
7582e1a784 Bug 814435 - Prevent scrollbars from fading out while user is scrolling. r=botond 2013-12-09 22:14:55 -05:00
Kartikaya Gupta
9f80972019 Bug 814435 - Always layerize overlay scrollbars on B2G. r=tn 2013-12-09 22:14:54 -05:00
Kartikaya Gupta
1af8763544 Bug 814435 - Annotate layers for scrollbars as such. r=tn, BenWa 2013-12-09 22:14:53 -05:00
Dan Minor
e108a063d1 Bug 945273 - Update reftest manifests for pandaboards; r=gbrown 2013-12-06 14:56:37 -05:00
Gijs Kruitbosch
5ca31f1d25 Bug 943217 - fix moz-document error message, r=dbaron 2013-11-26 10:36:52 +01:00