Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
e4af18b0
Commit
e4af18b0
authored
Apr 05, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Giving all colors an alpha channel by default. Will simplify the internals.
parent
dd03cb8a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
17 deletions
+20
-17
eval_apply.cpp
eval_apply.cpp
+16
-14
node.cpp
node.cpp
+1
-1
node.hpp
node.hpp
+3
-2
No files found.
eval_apply.cpp
View file @
e4af18b0
...
...
@@ -127,7 +127,7 @@ namespace Sass {
}
break
;
case
Node
:
:
textual_hex
:
{
Node
triple
(
Node
::
numeric_color
,
expr
.
line_number
,
3
);
Node
triple
(
Node
::
numeric_color
,
expr
.
line_number
,
4
);
Token
hext
(
Token
::
make
(
expr
.
content
.
token
.
begin
+
1
,
expr
.
content
.
token
.
end
));
if
(
hext
.
length
()
==
6
)
{
for
(
int
i
=
0
;
i
<
6
;
i
+=
2
)
{
...
...
@@ -139,7 +139,8 @@ namespace Sass {
triple
<<
Node
(
expr
.
line_number
,
static_cast
<
double
>
(
std
::
strtol
(
string
(
2
,
hext
.
begin
[
i
]).
c_str
(),
NULL
,
16
)));
}
}
return
triple
;
triple
<<
Node
(
expr
.
line_number
,
1.0
);
return
triple
;
}
break
;
case
Node
:
:
variable
:
{
...
...
@@ -194,11 +195,12 @@ namespace Sass {
// TO DO: find a way to merge the following two clauses
else
if
(
lhs
.
type
==
Node
::
number
&&
rhs
.
type
==
Node
::
numeric_color
)
{
if
(
op
!=
Node
::
sub
&&
op
!=
Node
::
div
)
{
double
h1
=
operate
(
op
,
lhs
.
content
.
numeric_value
,
rhs
[
0
].
content
.
numeric_value
);
double
h2
=
operate
(
op
,
lhs
.
content
.
numeric_value
,
rhs
[
1
].
content
.
numeric_value
);
double
h3
=
operate
(
op
,
lhs
.
content
.
numeric_value
,
rhs
[
2
].
content
.
numeric_value
);
// TO DO: check that alphas match
double
r
=
operate
(
op
,
lhs
.
content
.
numeric_value
,
rhs
[
0
].
content
.
numeric_value
);
double
g
=
operate
(
op
,
lhs
.
content
.
numeric_value
,
rhs
[
1
].
content
.
numeric_value
);
double
b
=
operate
(
op
,
lhs
.
content
.
numeric_value
,
rhs
[
2
].
content
.
numeric_value
);
acc
.
content
.
children
->
pop_back
();
acc
<<
Node
(
acc
.
line_number
,
h1
,
h2
,
h3
);
acc
<<
Node
(
acc
.
line_number
,
r
,
g
,
b
);
}
// trying to handle weird edge cases ... not sure if it's worth it
else
if
(
op
==
Node
::
div
)
{
...
...
@@ -214,18 +216,18 @@ namespace Sass {
}
}
else
if
(
lhs
.
type
==
Node
::
numeric_color
&&
rhs
.
type
==
Node
::
number
)
{
double
h1
=
operate
(
op
,
lhs
[
0
].
content
.
numeric_value
,
rhs
.
content
.
numeric_value
);
double
h2
=
operate
(
op
,
lhs
[
1
].
content
.
numeric_value
,
rhs
.
content
.
numeric_value
);
double
h3
=
operate
(
op
,
lhs
[
2
].
content
.
numeric_value
,
rhs
.
content
.
numeric_value
);
double
r
=
operate
(
op
,
lhs
[
0
].
content
.
numeric_value
,
rhs
.
content
.
numeric_value
);
double
g
=
operate
(
op
,
lhs
[
1
].
content
.
numeric_value
,
rhs
.
content
.
numeric_value
);
double
b
=
operate
(
op
,
lhs
[
2
].
content
.
numeric_value
,
rhs
.
content
.
numeric_value
);
acc
.
content
.
children
->
pop_back
();
acc
<<
Node
(
acc
.
line_number
,
h1
,
h2
,
h3
);
acc
<<
Node
(
acc
.
line_number
,
r
,
g
,
b
);
}
else
if
(
lhs
.
type
==
Node
::
numeric_color
&&
rhs
.
type
==
Node
::
numeric_color
)
{
double
h1
=
operate
(
op
,
lhs
[
0
].
content
.
numeric_value
,
rhs
[
0
].
content
.
numeric_value
);
double
h2
=
operate
(
op
,
lhs
[
1
].
content
.
numeric_value
,
rhs
[
1
].
content
.
numeric_value
);
double
h3
=
operate
(
op
,
lhs
[
2
].
content
.
numeric_value
,
rhs
[
2
].
content
.
numeric_value
);
double
r
=
operate
(
op
,
lhs
[
0
].
content
.
numeric_value
,
rhs
[
0
].
content
.
numeric_value
);
double
g
=
operate
(
op
,
lhs
[
1
].
content
.
numeric_value
,
rhs
[
1
].
content
.
numeric_value
);
double
b
=
operate
(
op
,
lhs
[
2
].
content
.
numeric_value
,
rhs
[
2
].
content
.
numeric_value
);
acc
.
content
.
children
->
pop_back
();
acc
<<
Node
(
acc
.
line_number
,
h1
,
h2
,
h3
);
acc
<<
Node
(
acc
.
line_number
,
r
,
g
,
b
);
}
else
{
// TO DO: disallow division and multiplication on lists
...
...
node.cpp
View file @
e4af18b0
...
...
@@ -158,7 +158,7 @@ namespace Sass {
}
break
;
case
numeric_color
:
{
if
(
size
()
==
3
||
(
size
()
==
4
&&
at
(
3
).
content
.
numeric_value
>=
0xff
)
)
{
if
(
at
(
3
).
content
.
numeric_value
>=
1.0
)
{
double
a
=
at
(
0
).
content
.
numeric_value
;
double
b
=
at
(
1
).
content
.
numeric_value
;
double
c
=
at
(
2
).
content
.
numeric_value
;
...
...
node.hpp
View file @
e4af18b0
...
...
@@ -182,16 +182,17 @@ namespace Sass {
content
.
dimension
.
unit
=
tok
.
begin
;
}
Node
(
unsigned
int
ln
,
double
r
,
double
g
,
double
b
)
// colors
Node
(
unsigned
int
ln
,
double
r
,
double
g
,
double
b
,
double
a
=
1.0
)
// colors
{
clear
();
type
=
numeric_color
;
line_number
=
ln
;
content
.
children
=
new
vector
<
Node
>
;
content
.
children
->
reserve
(
3
);
content
.
children
->
reserve
(
4
);
content
.
children
->
push_back
(
Node
(
ln
,
r
));
content
.
children
->
push_back
(
Node
(
ln
,
g
));
content
.
children
->
push_back
(
Node
(
ln
,
b
));
content
.
children
->
push_back
(
Node
(
ln
,
a
));
has_children
=
true
;
++
allocations
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment