Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csscom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Taddeüs Kroes
csscom
Commits
04843037
Commit
04843037
authored
12 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Compression methods now alter their argument instead of making a copy
parent
2737089c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compress.py
+24
-3
24 additions, 3 deletions
compress.py
generate.py
+3
-3
3 additions, 3 deletions
generate.py
with
27 additions
and
6 deletions
compress.py
+
24
−
3
View file @
04843037
from
color
import
color_shortcut
def
combine_blocks
(
blocks
):
def
combine_blocks
(
blocks
):
# Map of property stringification to list of containing blocks
# Map of property stringification to list of containing blocks
#property_locations = {}
#property_locations = {}
...
@@ -5,13 +8,31 @@ def combine_blocks(blocks):
...
@@ -5,13 +8,31 @@ def combine_blocks(blocks):
return
blocks
return
blocks
def
_filter_property
(
basename
,
properties
):
prefix
=
basename
+
'
-
'
filtered
=
[]
for
prop
in
list
(
properties
):
name
,
value
=
prop
if
name
==
basename
or
name
[:
len
(
prefix
)]
==
prefix
:
filtered
.
append
(
properties
.
remove
(
prop
))
return
filtered
def
compress_color
(
properties
):
def
compress_color
(
properties
):
return
properties
for
i
,
(
name
,
value
)
in
enumerate
(
properties
):
if
name
in
(
'
color
'
,
'
background-color
'
,
'
border-color
'
):
properties
[
i
]
=
(
name
,
color_shortcut
(
value
))
def
compress_font
(
properties
):
def
compress_font
(
properties
):
return
properties
#fonts = _filter_property('font', properties)
pass
def
compress_dimension
(
properties
):
def
compress_dimension
(
properties
):
return
properties
#margins = _filter_property('margin', properties)
#paddings = _filter_property('padding', properties)
pass
This diff is collapsed.
Click to expand it.
generate.py
+
3
−
3
View file @
04843037
...
@@ -70,13 +70,13 @@ def generate_group(selectors, blocks, combine_blocks=True,
...
@@ -70,13 +70,13 @@ def generate_group(selectors, blocks, combine_blocks=True,
for
block_selectors
,
properties
in
blocks
:
for
block_selectors
,
properties
in
blocks
:
if
compress_color
:
if
compress_color
:
properties
=
compress
.
compress_color
(
properties
)
compress
.
compress_color
(
properties
)
if
compress_font
:
if
compress_font
:
properties
=
compress
.
compress_font
(
properties
)
compress
.
compress_font
(
properties
)
if
compress_dimension
:
if
compress_dimension
:
properties
=
compress
.
compress_dimension
(
properties
)
compress
.
compress_dimension
(
properties
)
compressed_blocks
.
append
(
generate_block
(
block_selectors
,
properties
,
compressed_blocks
.
append
(
generate_block
(
block_selectors
,
properties
,
compress_whitespace
=
compress_whitespace
,
compress_whitespace
=
compress_whitespace
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment