@@ -24,6 +24,7 @@ use crate::properties::{
2424use crate :: targets:: Browsers ;
2525use crate :: parser:: ParserOptions ;
2626use crate :: error:: { ParserError , PrinterError } ;
27+ use crate :: logical:: LogicalProperties ;
2728
2829#[ derive( Debug , PartialEq ) ]
2930pub struct DeclarationBlock {
@@ -67,20 +68,25 @@ impl ToCss for DeclarationBlock {
6768}
6869
6970impl DeclarationBlock {
70- pub ( crate ) fn minify ( & mut self , handler : & mut DeclarationHandler , important_handler : & mut DeclarationHandler ) {
71+ pub ( crate ) fn minify (
72+ & mut self ,
73+ handler : & mut DeclarationHandler ,
74+ important_handler : & mut DeclarationHandler ,
75+ logical_properties : & mut LogicalProperties
76+ ) {
7177 let mut decls: Vec < Declaration > = vec ! [ ] ;
7278 for decl in self . declarations . iter ( ) {
7379 let handled =
74- ( decl. important && important_handler. handle_property ( decl) ) ||
75- ( !decl. important && handler. handle_property ( decl) ) ;
80+ ( decl. important && important_handler. handle_property ( decl, logical_properties ) ) ||
81+ ( !decl. important && handler. handle_property ( decl, logical_properties ) ) ;
7682
7783 if !handled {
7884 decls. push ( decl. clone ( ) ) ;
7985 }
8086 }
8187
82- decls. extend ( handler. finalize ( ) ) ;
83- decls. extend ( important_handler. finalize ( ) ) ;
88+ decls. extend ( handler. finalize ( logical_properties ) ) ;
89+ decls. extend ( important_handler. finalize ( logical_properties ) ) ;
8490 self . declarations = decls;
8591 }
8692}
@@ -157,7 +163,6 @@ impl DeclarationList {
157163 }
158164}
159165
160- #[ derive( Default ) ]
161166pub ( crate ) struct DeclarationHandler {
162167 background : BackgroundHandler ,
163168 border : BorderHandler ,
@@ -188,68 +193,76 @@ impl DeclarationHandler {
188193 DeclarationHandler {
189194 background : BackgroundHandler :: new ( targets) ,
190195 border : BorderHandler :: new ( targets) ,
196+ outline : OutlineHandler :: default ( ) ,
191197 flex : FlexHandler :: new ( targets) ,
198+ grid : GridHandler :: default ( ) ,
192199 align : AlignHandler :: new ( targets) ,
200+ margin : MarginHandler :: default ( ) ,
201+ padding : PaddingHandler :: default ( ) ,
202+ scroll_margin : ScrollMarginHandler :: default ( ) ,
203+ scroll_padding : ScrollPaddingHandler :: default ( ) ,
204+ font : FontHandler :: default ( ) ,
205+ text : TextDecorationHandler :: new ( targets) ,
206+ list : ListStyleHandler :: default ( ) ,
193207 transition : TransitionHandler :: new ( targets) ,
194208 animation : AnimationHandler :: new ( targets) ,
195209 display : DisplayHandler :: new ( targets) ,
196210 position : PositionHandler :: new ( targets) ,
211+ inset : InsetHandler :: default ( ) ,
197212 overflow : OverflowHandler :: new ( targets) ,
198213 transform : TransformHandler :: new ( targets) ,
199- text : TextDecorationHandler :: new ( targets) ,
200214 prefix : PrefixHandler :: new ( targets) ,
201- decls : DeclarationList :: new ( important) ,
202- ..DeclarationHandler :: default ( )
215+ decls : DeclarationList :: new ( important)
203216 }
204217 }
205218
206- pub fn handle_property ( & mut self , decl : & Declaration ) -> bool {
219+ pub fn handle_property ( & mut self , decl : & Declaration , logical_properties : & mut LogicalProperties ) -> bool {
207220 let property = & decl. property ;
208- self . background . handle_property ( property, & mut self . decls ) ||
209- self . border . handle_property ( property, & mut self . decls ) ||
210- self . outline . handle_property ( property, & mut self . decls ) ||
211- self . flex . handle_property ( property, & mut self . decls ) ||
212- self . grid . handle_property ( property, & mut self . decls ) ||
213- self . align . handle_property ( property, & mut self . decls ) ||
214- self . margin . handle_property ( property, & mut self . decls ) ||
215- self . padding . handle_property ( property, & mut self . decls ) ||
216- self . scroll_margin . handle_property ( property, & mut self . decls ) ||
217- self . scroll_padding . handle_property ( property, & mut self . decls ) ||
218- self . font . handle_property ( property, & mut self . decls ) ||
219- self . text . handle_property ( property, & mut self . decls ) ||
220- self . list . handle_property ( property, & mut self . decls ) ||
221- self . transition . handle_property ( property, & mut self . decls ) ||
222- self . animation . handle_property ( property, & mut self . decls ) ||
223- self . display . handle_property ( property, & mut self . decls ) ||
224- self . position . handle_property ( property, & mut self . decls ) ||
225- self . inset . handle_property ( property, & mut self . decls ) ||
226- self . overflow . handle_property ( property, & mut self . decls ) ||
227- self . transform . handle_property ( property, & mut self . decls ) ||
228- self . prefix . handle_property ( property, & mut self . decls )
221+ self . background . handle_property ( property, & mut self . decls , logical_properties ) ||
222+ self . border . handle_property ( property, & mut self . decls , logical_properties ) ||
223+ self . outline . handle_property ( property, & mut self . decls , logical_properties ) ||
224+ self . flex . handle_property ( property, & mut self . decls , logical_properties ) ||
225+ self . grid . handle_property ( property, & mut self . decls , logical_properties ) ||
226+ self . align . handle_property ( property, & mut self . decls , logical_properties ) ||
227+ self . margin . handle_property ( property, & mut self . decls , logical_properties ) ||
228+ self . padding . handle_property ( property, & mut self . decls , logical_properties ) ||
229+ self . scroll_margin . handle_property ( property, & mut self . decls , logical_properties ) ||
230+ self . scroll_padding . handle_property ( property, & mut self . decls , logical_properties ) ||
231+ self . font . handle_property ( property, & mut self . decls , logical_properties ) ||
232+ self . text . handle_property ( property, & mut self . decls , logical_properties ) ||
233+ self . list . handle_property ( property, & mut self . decls , logical_properties ) ||
234+ self . transition . handle_property ( property, & mut self . decls , logical_properties ) ||
235+ self . animation . handle_property ( property, & mut self . decls , logical_properties ) ||
236+ self . display . handle_property ( property, & mut self . decls , logical_properties ) ||
237+ self . position . handle_property ( property, & mut self . decls , logical_properties ) ||
238+ self . inset . handle_property ( property, & mut self . decls , logical_properties ) ||
239+ self . overflow . handle_property ( property, & mut self . decls , logical_properties ) ||
240+ self . transform . handle_property ( property, & mut self . decls , logical_properties ) ||
241+ self . prefix . handle_property ( property, & mut self . decls , logical_properties )
229242 }
230243
231- pub fn finalize ( & mut self ) -> Vec < Declaration > {
232- self . background . finalize ( & mut self . decls ) ;
233- self . border . finalize ( & mut self . decls ) ;
234- self . outline . finalize ( & mut self . decls ) ;
235- self . flex . finalize ( & mut self . decls ) ;
236- self . grid . finalize ( & mut self . decls ) ;
237- self . align . finalize ( & mut self . decls ) ;
238- self . margin . finalize ( & mut self . decls ) ;
239- self . padding . finalize ( & mut self . decls ) ;
240- self . scroll_margin . finalize ( & mut self . decls ) ;
241- self . scroll_padding . finalize ( & mut self . decls ) ;
242- self . font . finalize ( & mut self . decls ) ;
243- self . text . finalize ( & mut self . decls ) ;
244- self . list . finalize ( & mut self . decls ) ;
245- self . transition . finalize ( & mut self . decls ) ;
246- self . animation . finalize ( & mut self . decls ) ;
247- self . display . finalize ( & mut self . decls ) ;
248- self . position . finalize ( & mut self . decls ) ;
249- self . inset . finalize ( & mut self . decls ) ;
250- self . overflow . finalize ( & mut self . decls ) ;
251- self . transform . finalize ( & mut self . decls ) ;
252- self . prefix . finalize ( & mut self . decls ) ;
244+ pub fn finalize ( & mut self , logical_properties : & mut LogicalProperties ) -> Vec < Declaration > {
245+ self . background . finalize ( & mut self . decls , logical_properties ) ;
246+ self . border . finalize ( & mut self . decls , logical_properties ) ;
247+ self . outline . finalize ( & mut self . decls , logical_properties ) ;
248+ self . flex . finalize ( & mut self . decls , logical_properties ) ;
249+ self . grid . finalize ( & mut self . decls , logical_properties ) ;
250+ self . align . finalize ( & mut self . decls , logical_properties ) ;
251+ self . margin . finalize ( & mut self . decls , logical_properties ) ;
252+ self . padding . finalize ( & mut self . decls , logical_properties ) ;
253+ self . scroll_margin . finalize ( & mut self . decls , logical_properties ) ;
254+ self . scroll_padding . finalize ( & mut self . decls , logical_properties ) ;
255+ self . font . finalize ( & mut self . decls , logical_properties ) ;
256+ self . text . finalize ( & mut self . decls , logical_properties ) ;
257+ self . list . finalize ( & mut self . decls , logical_properties ) ;
258+ self . transition . finalize ( & mut self . decls , logical_properties ) ;
259+ self . animation . finalize ( & mut self . decls , logical_properties ) ;
260+ self . display . finalize ( & mut self . decls , logical_properties ) ;
261+ self . position . finalize ( & mut self . decls , logical_properties ) ;
262+ self . inset . finalize ( & mut self . decls , logical_properties ) ;
263+ self . overflow . finalize ( & mut self . decls , logical_properties ) ;
264+ self . transform . finalize ( & mut self . decls , logical_properties ) ;
265+ self . prefix . finalize ( & mut self . decls , logical_properties ) ;
253266 std:: mem:: take ( & mut self . decls . declarations )
254267 }
255268}
0 commit comments