CN105094938A - Method and device for generating CSS code - Google Patents

Method and device for generating CSS code Download PDF

Info

Publication number
CN105094938A
CN105094938A CN201510385820.1A CN201510385820A CN105094938A CN 105094938 A CN105094938 A CN 105094938A CN 201510385820 A CN201510385820 A CN 201510385820A CN 105094938 A CN105094938 A CN 105094938A
Authority
CN
China
Prior art keywords
code
function
statement
css
compiled
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510385820.1A
Other languages
Chinese (zh)
Inventor
谭国斌
沈建荣
马哲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Technology Co Ltd
Xiaomi Inc
Original Assignee
Xiaomi Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiaomi Inc filed Critical Xiaomi Inc
Priority to CN201510385820.1A priority Critical patent/CN105094938A/en
Publication of CN105094938A publication Critical patent/CN105094938A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a method and a device for generating a CSS code, which belong to the technical field of computers. The method comprises that the CSS code to be compiled is acquired, and the CSS code to be compiled comprises a statement code and a pattern description code; and according to the statement code and code compilation rules corresponding to the statement code, the pattern description code is compiled, and a primitive CSS code corresponding to the pattern description code is generated. By compiling the statement code in the CSS code to be compiled and the pattern description code in the CSS code to be compiled, the CSS code to be compiled is restored into the primitive CSS code. In this way, a complete CSS code can be maintained by directly modifying the statement code during subsequent maintenance of the CSS code, the complete CSS code does not need to be modified, and maintainability and maintenance efficiency of the compiled CSS code can be increased.

Description

Generate method and the device of Cascading Style Sheet code
Technical field
The disclosure relates to field of computer technology, particularly a kind of method and device generating Cascading Style Sheet code.
Background technology
CSS (CascadingStyleSheets, Cascading Style Sheet) be a kind of form design language, relative to conventional HTML (HyperTextMarkupLanguage, HyperText Markup Language) performance, CSS can carry out the accurate control of Pixel-level to the position typesetting of the object in webpage, accomplish that webpage performance is separated with content.
Programming personnel, when writing CSS code, needs the redaction rule according to CSS language itself, to each attribute of object style each in webpage being described one by one.Such as: the color arranged in head subject is white, and font is 14px; The color arranged in agent object is white, and font is 14px.Then corresponding code is:
#header{
color:#FFF;
font-size:14px;}
#body{
color:#FFF;
font-size:14px;}
Programming personnel at later stage modify or when safeguarding code, then needs for the modifying one by one of each attribute in each object.
Summary of the invention
In order to solve the problem of correlation technique, disclosure embodiment provides a kind of method and the device that generate Cascading Style Sheet code.Described technical scheme is as follows:
According to the first aspect of disclosure embodiment, a kind of method generating Cascading Style Sheet code is provided, comprises:
Obtain Cascading Style Sheet CSS code to be compiled, described CSS code to be compiled comprises statement code and pattern coded description;
According to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding.
Optionally, described according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding, comprising:
If find variable in described pattern coded description, then in described statement code, search the variate-value of described variable;
The variate-value of described variable is replaced the described variable found.
By searching the variable stated in advance in pattern coded description, and replace this variable by the variate-value stated in advance, can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, describedly the variate-value of described variable is replaced the described variable found, comprising:
If detect arithmetic expression in the statement comprising described variable, then according to described arithmetic expression, computing is carried out to the variate-value of described variable;
Variate-value after described computing is replaced the described variable found.
By detecting the arithmetic expression comprised in the statement of variable, and variate-value is replaced variable by the value after arithmetic expression computing, add the mode of operation to variable, so follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, described according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding, comprising:
If find function in described pattern coded description, then in described statement code, search the function body of described function;
Detect in described function and whether carry self-defining function variate-value;
If do not carry self-defining function variate-value in described function, then the function body of described function is replaced described function, and use the default function variate-value of described function;
If carry self-defining function variate-value in described function, then the function body of described function is replaced described function, and described self-defining function variate-value is replaced the default function variate-value in the function body of described function.
By searching the function stated in advance in pattern coded description, and replace this function by the function body stated in advance, can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, described according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding, comprising:
If find the object of derived class in described pattern coded description, then in described statement code, search the class body content of described class;
The class body content of described class is added in the object inheriting described class.
By searching the class stated in advance in pattern coded description, and be added in the object of derived class by the class body content of class stated in advance, can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, after the Cascading Style Sheet CSS code that described acquisition is to be compiled, described method also comprises:
If the code importing file detected in described statement code, then obtain code file to be imported according to the path in the code of described importing file;
Code in described code file to be imported is added in described CSS code to be compiled.
By searching the code importing file in pattern coded description, and according to the path of file, the code of the code file of importing is added in CSS code to be compiled when the code importing file being detected; Achieve the function that code imports, improve the efficiency of writing CSS code.
Optionally, after the Cascading Style Sheet CSS code that described acquisition is to be compiled, described method also comprises:
If detect the code of nested form in described pattern coded description, then the subobject described in the code according to described nested form and the object comprising described subobject, generate the coded description of described subobject;
Delete the code of the described nested form comprised in the object of described subobject.
By detecting the code of the nested form in pattern coded description, and being the coded description of the code building subobject of nested form, improve the efficiency of writing CSS code.
According to the second aspect of disclosure embodiment, a kind of device generating Cascading Style Sheet code is provided, comprises:
Acquisition module, for obtaining Cascading Style Sheet CSS code to be compiled, described CSS code to be compiled comprises statement code and pattern coded description;
Collector, for according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding.
Optionally, described collector, comprising:
First searches submodule, during for finding variable in described pattern coded description, searches the variate-value of described variable in described statement code;
First replaces submodule, for the variate-value of described variable being replaced the described variable found.
By searching the variable stated in advance in pattern coded description, and replace this variable by the variate-value stated in advance, can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, described first replacement submodule is used for:
When detecting arithmetic expression in the statement comprising described variable, according to described arithmetic expression, computing is carried out to the variate-value of described variable; And the variate-value after described computing is replaced the described variable found.
By detecting the arithmetic expression comprised in the statement of variable, and variate-value is replaced variable by the value after arithmetic expression computing, add the mode of operation to variable, so follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, described collector, comprising:
Second searches submodule, during for finding function in described pattern coded description, searches the function body of described function in described statement code;
Detection sub-module, for detecting in described function whether carry self-defining function variate-value;
Second replaces submodule, during for not carrying self-defining function variate-value in described function, the function body of described function is replaced described function, and uses the default function variate-value of described function;
3rd replaces submodule, during for carrying self-defining function variate-value in described function, the function body of described function is replaced described function, and described self-defining function variate-value is replaced the default function variate-value in the function body of described function.
By searching the function stated in advance in pattern coded description, and replace this function by the function body stated in advance, can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, described collector, comprising:
3rd searches submodule, during for finding the object of derived class in described pattern coded description, searches the class body content of described class in described statement code;
First adds submodule, for the class body content of described class being added in the object inheriting described class.
By searching the class stated in advance in pattern coded description, and be added in the object of derived class by the class body content of class stated in advance, can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded.
Optionally, described collector, also comprises:
Obtaining submodule, during for the code importing file being detected in described statement code, obtaining code file to be imported according to the path in the code of described importing file;
Second adds submodule, for being added in described CSS code to be compiled by the code in described code file to be imported.
By searching the code importing file in pattern coded description, and according to the path of file, the code of the code file of importing is added in CSS code to be compiled when the code importing file being detected; Achieve the function that code imports, improve the efficiency of writing CSS code.
Optionally, described collector, also comprises:
Generate submodule, during for detecting the code of nested form in described pattern coded description, the subobject described in the code according to described nested form and the object comprising described subobject, generate the coded description of described subobject;
Delete submodule, for delete comprise described subobject object in the code of described nested form.
By detecting the code of the nested form in pattern coded description, and being the coded description of the code building subobject of nested form, improve the efficiency of writing CSS code.
According to the third aspect of disclosure embodiment, a kind of device generating Cascading Style Sheet code is provided, comprises:
Processor;
For the storer of storage of processor executable instruction;
Wherein, described processor is configured to:
Obtain Cascading Style Sheet CSS code to be compiled, described CSS code to be compiled comprises statement code and pattern coded description;
According to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding.
The technical scheme that embodiment of the present disclosure provides can comprise following beneficial effect:
By compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, be primary CSS code by CSS code reverse to be compiled.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
Accompanying drawing explanation
Accompanying drawing to be herein merged in instructions and to form the part of this instructions, shows and meets embodiment of the present disclosure, and is used from instructions one and explains principle of the present disclosure.
Fig. 1 is a kind of process flow diagram generating the method for Cascading Style Sheet code according to an exemplary embodiment;
Fig. 2 is a kind of process flow diagram generating the method for Cascading Style Sheet code according to an exemplary embodiment;
Fig. 3 is a kind of process flow diagram generating the method for Cascading Style Sheet code according to an exemplary embodiment;
Fig. 4 is a kind of process flow diagram generating the method for Cascading Style Sheet code according to an exemplary embodiment;
Fig. 5 is a kind of process flow diagram generating the method for Cascading Style Sheet code according to an exemplary embodiment;
Fig. 6 is a kind of process flow diagram generating the method for Cascading Style Sheet code according to an exemplary embodiment;
Fig. 7 is a kind of block diagram generating the device of Cascading Style Sheet code according to an exemplary embodiment;
Fig. 8 is a kind of block diagram generating collector in the device of Cascading Style Sheet code according to an exemplary embodiment;
Fig. 9 is a kind of block diagram generating the device of Cascading Style Sheet code according to an exemplary embodiment;
Figure 10 is a kind of block diagram generating the device of Cascading Style Sheet code according to an exemplary embodiment.
Embodiment
For making object of the present disclosure, technical scheme and advantage clearly, below in conjunction with accompanying drawing, disclosure embodiment is described in further detail.
The disclosure one exemplary embodiment provides a kind of method generating Cascading Style Sheet code, and see Fig. 1, method flow comprises:
In a step 101, obtain Cascading Style Sheet CSS code to be compiled, CSS code to be compiled comprises statement code and pattern coded description.
Wherein, the code of statement code not for describing pattern in webpage, but for informing how compiler identifies the code that in pattern coded description, OO mode is write; Pattern coded description is then the code for describing pattern in webpage, uses the code that OO mode is write.
In a step 102, according to stating code and stating that the code compilation rule that code is corresponding compiles pattern coded description, the primary CSS code that pattern coded description is corresponding is generated.
Wherein, primary CSS code is the code write according to the syntax rule of CSS, can viewed device identification webpage is carried out to the code of typesetting.
Wherein, the CSS code to be compiled in disclosure embodiment comprises two category codes.
First kind code is: statement code, and wherein, statement code comprises but is not limited with following four kinds of forms:
Comprise:
The first: statement variable;
Wherein, variable name and variate-value is comprised;
Such as: color:#FFF; Namely color is variable name, and #FFF is variate-value.
The second: statement function;
Wherein, comprise function name sum functions body, and default function variable;
Such as:
.round-corners(radius:5px){
border-radius:radius;
-webkit-border-radius:radius; The privately owned attribute * of/* webkit browser/
-moz-border-radius:radius; The privately owned attribute * of }/* Firefox browser/
Wherein .round-corners is function name, and radius is function variable, and 5px is default function variate-value; Content in { } is function body.
The third: statement class;
Wherein, class body content is comprised;
Such as:
.Base{
color:#FFF;
font-size:14px;
}
Wherein, Base is class name; Content in { } is class body content.
4th kind: statement imports file;
Wherein, the path of file to be imported is comprised;
Such as: include ' test.css ';
Wherein, can be defined as by include the information importing code, ' test.css ' is routing information.
Equations of The Second Kind code is: pattern coded description, i.e. the CSS code to be compiled developed by OO mode of programming personnel.
In addition, disclosure embodiment can perform at server side or end side.
When implementing scene at server side, can for programming personnel to the files passe of the CSS code to be compiled developed by OO mode to server, be converted to primary CSS code by the compiler engine in server, then the file of the primary CSS code after conversion is kept in the storage area of the web page files of specifying.
When implementing scene in end side, webpage can be opened by browser for user, in this webpage of browser downloads comprise the file of CSS code to be compiled after, by the compiler engine in browser, the file that this comprises CSS code to be compiled is changed, and after being converted to primary CSS code, typesetting display is carried out to this webpage.
When safeguarding CSS code, programming personnel directly can revise the statement code in the file of CSS code to be compiled, again this amended CSS code to be compiled is compiled, and then obtain amended complete primary CSS code, without the need to revising the complete file in CSS code.
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
The disclosure one exemplary embodiment provides a kind of method generating Cascading Style Sheet code, and see Fig. 2, method flow comprises:
In step 201, obtain Cascading Style Sheet CSS code to be compiled, CSS code to be compiled comprises statement code and pattern coded description.
In step 202., if find variable in pattern coded description, then in statement code, search the variate-value of variable.
Wherein, the mode of searching variable is search initial character.
Such as: CSS code to be compiled is:
Color:#FFF; (herein for statement code)/* state color be #FFF*/
#header{
color:color;
(being pattern coded description) herein
Detect in #header object have the variable color stated in advance time, statement code region search variate-value #FFF corresponding to color.
In step 203, the variate-value of variable is replaced the variable found.
#FFF is replaced the color in pattern coded description, after conversion, primary CSS code is:
#header{
color:#FFF;
}
Optionally, if having operational formula in the statement at variable place, then further can carry out computing to the variate-value of variable according to this operational formula, then result is replaced variable.
Therefore, step 203 can realize in the following manner:
In step 2031, if detect arithmetic expression in the statement comprising variable, then according to arithmetic expression, computing is carried out to the variate-value of variable.
Such as:
Base-size:12px; / * states that specification size is 12px*/(being statement code) herein
#body{
Font-size:base-size+2; (being pattern coded description) herein
}
Wherein, can determine that the variate-value of base-size is 12px in statement code, after detecting that arithmetic expression is base-size+2, the computing that variate-value carries out this arithmetic expression be obtained 14px.
Optionally, can for the computing carried out between multiple variable in arithmetic expression; Also can be the computing between a variable and a numerical value.
In step 2032, the variate-value after computing is replaced the variable found.
Connect the example in step 2031, after conversion, primary CSS code is:
#body{
font-size:14px;
}
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
The disclosure one exemplary embodiment provides a kind of method generating Cascading Style Sheet code, and see Fig. 3, method flow comprises:
In step 301, obtain Cascading Style Sheet CSS code to be compiled, CSS code to be compiled comprises statement code and pattern coded description.
In step 302, if find function in pattern coded description, then in statement code, search the function body of function.
Wherein, the mode of function is searched for searching the content of " character+() ".
Such as:
.round-corners(radius:5px){
Border-radius:radius; / * states functional style */(being statement code) herein
-webkit-border-radius:radius; The privately owned attribute * of/* webkit browser/
-moz-border-radius:radius; The privately owned attribute * of }/* Firefox browser/
#header{
.round-corners();
}
#body{
.round-corners(7px);
(being pattern coded description) herein
Wherein, the function found in pattern coded description is round-corners (), and each in header object and body object respectively exist one.
In step 303, self-defining function variate-value whether is carried in detection function.
Although have invoked identical function in these above-mentioned two objects, in header object, employ the function variable value of acquiescence, i.e. round-corners (); Self-defining function variate-value round-corners (7px) is employed in body object.If detect in function and do not carry self-defining function variate-value, then perform step 304; If detect in function and carry self-defining function variate-value, then perform step 305.
In step 304, if do not carry self-defining function variate-value in function, then by the function body replacement function of function, and use the default function variate-value of function.
Accordingly, the primary CSS code after changing for header object is:
#header{
border-radius:5px;
-webkit-border-radius:5px;
-moz-border-radius:5px;
}
In step 305, if carry self-defining function variate-value in function, then by the function body replacement function of function, and by the default function variate-value in the function body of self-defining function variate-value replacement function.
Accordingly, the primary CSS code after changing for body object is:
#body{
border-radius:7px;
-webkit-border-radius:7px;
-moz-border-radius:7px;
}
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
The disclosure one exemplary embodiment provides a kind of method generating Cascading Style Sheet code, and see Fig. 4, method flow comprises:
In step 401, obtain Cascading Style Sheet CSS code to be compiled, CSS code to be compiled comprises statement code and pattern coded description.
In step 402, if find the object of derived class in pattern coded description, then in statement code, search the class body content of class.
Wherein, the mode of class is searched for searching the content of " (extends. character) ".
Such as:
.round-corners(radius:5px){
Border-radius:radius; (being statement code) herein
-webkit-border-radius:radius; The privately owned attribute * of/* webkit browser/
-moz-border-radius:radius; The privately owned attribute * of }/* Firefox browser/
.Base{
color:#FFF;
font-size:14px;
}/* states class */(being statement code) herein
}
#body(extends.Base){
.round-corners(7px);
(being pattern coded description) herein
In pattern coded description, find the body object inheriting Base class, and then search the class body content of Base class in statement code.
In step 403, the class body content of class is added in the object of derived class.
In addition, the key message (extends.Base) searched in the body object inheriting Base class is deleted.
Connect the example in step 402, the primary CSS code after compiling is:
#body{
color:#FFF;
font-size:14px;
border-radius:7px;
-webkit-border-radius:7px;
-moz-border-radius:7px;
}
Further, foregoing is the mode of single inheritance, and namely body object only inherits the class body content in Base class; The mode of multiple inheritance can also be realized, the class body content namely in the multiple class of certain object inherits.
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
The disclosure one exemplary embodiment provides a kind of method generating Cascading Style Sheet code, and see Fig. 5, method flow comprises:
In step 501, obtain Cascading Style Sheet CSS code to be compiled, CSS code to be compiled comprises statement code and pattern coded description.
In step 502, if the code importing file detected in statement code, then code file to be imported is obtained according to the path imported in the code of file.
Wherein, need in the disclosed embodiments to import the code beyond file belonging to current CSS code to be compiled in other CSS code files.
By detecting the code include importing file in statement code, the CSS code needing to import namely can be determined whether there is.
Such as: include ' test.css '.Wherein, the content in ' ' is routing information.The file of the CSS code that these needs import can be got by this routing information.
Wherein, the CSS code in the CSS code file of this importing can be primary CSS code, also can be CSS code to be compiled.
In step 503, the code in code file to be imported is added in CSS code to be compiled.
In step 504, according to stating code and stating that the code compilation rule that code is corresponding compiles pattern coded description, the primary CSS code that pattern coded description is corresponding is generated.
The flow process performing compiled code can be continued after importing.
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
The disclosure one exemplary embodiment provides a kind of method generating Cascading Style Sheet code, and see Fig. 6, method flow comprises:
In step 601, obtain Cascading Style Sheet CSS code to be compiled, CSS code to be compiled comprises statement code and pattern coded description.
In step 602, if detect the code of nested form in pattern coded description, then the subobject described in the code according to nested form and comprise the object of subobject, generates the coded description of subobject.
Wherein, the mode of searching the code of nested form is the content of ". character { } " for searching.
Wherein, in pattern coded description, also there is a kind of code not needing to state in statement code, but need when compiling according to the regular code carrying out processing of the compiling preset, be i.e. the code of nested form.
Such as:
Wherein, logo is the subobject of header object.
For the description of this seed object, need to carry out separately the description of this kind of subobject in primary CSS code.And when writing the CSS code to be compiled developed by OO mode, the full content belonging to this object can be write writing in region in this object by programming personnel.
Accordingly, corresponding in above-mentioned example primary CSS code is:
In step 603, the code of the nested form comprised in the object of subobject is deleted.
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
Corresponding to the method for the generation Cascading Style Sheet code that above-mentioned exemplary embodiment provides, another exemplary embodiment of the disclosure provides a kind of device generating Cascading Style Sheet code, and see Fig. 7, this device comprises:
Acquisition module 701, for obtaining Cascading Style Sheet CSS code to be compiled, CSS code to be compiled comprises statement code and pattern coded description.
Collector 702, compiles pattern coded description for the statement code that gets according to acquisition module 701 and code compilation rule corresponding to statement code, generates the primary CSS code that pattern coded description is corresponding.
Wherein, as shown in Figure 8, collector 702, comprising:
First searches submodule 7021, during for finding variable in pattern coded description, searches the variate-value of variable in statement code.
First replaces submodule 7022, for the variate-value of variable replacement first being searched the variable that submodule 7021 finds.
Wherein, first replace submodule 7022 for:
When detecting arithmetic expression in the statement comprising variable, according to arithmetic expression, computing is carried out to the variate-value of variable; And the variate-value after computing is replaced the variable found.
Wherein, as shown in Figure 8, collector 702, comprising:
Second searches submodule 7023, during for finding function in pattern coded description, searches the function body of function in statement code.
Detection sub-module 7024, searches in the function that submodule 7023 finds whether carry self-defining function variate-value for detecting second.
Second replaces submodule 7025, when not carrying self-defining function variate-value for detecting in function in detection sub-module 7024, searching the function body replacement function of the function that submodule 7023 finds, and use the default function variate-value of function by second.
3rd replaces submodule 7026, when carrying self-defining function variate-value for detecting in function in detection sub-module 7024, the function body replacement function of the function that submodule 7023 finds is searched by second, and by the default function variate-value in the function body of self-defining function variate-value replacement function.
Wherein, as shown in Figure 8, collector 702, comprising:
3rd searches submodule 7027, during for finding the object of derived class in pattern coded description, searches the class body content of class in statement code.
First adds submodule 7028, is added in the object of derived class for the class body content of searching the class that submodule 7027 finds by the 3rd.
Wherein, as shown in Figure 8, collector 702, comprising:
Obtain submodule 7029, for when stating in code code importing file being detected, the path according to importing in the code of file obtains code file to be imported.
Second adds submodule 70210, for being added in CSS code to be compiled by the code obtained in the code file to be imported that gets of submodule 7029.
Wherein, as shown in Figure 8, collector 702, comprising:
Generate submodule 70211, during for detecting the code of nested form in pattern coded description, the subobject described in the code according to nested form and comprise the object of subobject, generates the coded description of subobject.
Delete submodule 70212, for deleting the code of the nested form comprised in the object of subobject.
What deserves to be explained is, above-mentioned accompanying drawing as shown in Figure 8, describe 5 kinds of ways of realization of collector 702.Describe to simplify accompanying drawing, these 5 kinds of ways of realization are showed in the same figure, in conjunction with above-mentioned text description, there is not mutual correspondence in the intermodule of different way of realization, the then collector 702 of different way of realization in corresponding accompanying drawing,, there is not mutual correspondence with all the other four kinds of ways of realization, therefore do not connected by line between it in an independent one-tenth little entirety.
Device shown in Fig. 7 to Fig. 9 in disclosure embodiment, for realizing the method flow shown in above-mentioned Fig. 1 to Fig. 6, the related content of the device shown in disclosure embodiment describes and describes identical with the related content in said method flow process.
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
Corresponding to the control device of the generation Cascading Style Sheet code that above-mentioned exemplary embodiment provides, another exemplary embodiment of the disclosure provides a kind of terminal 900, see Fig. 9.Such as, terminal 900 can be mobile phone, computing machine, digital broadcast terminal, messaging devices, game console, tablet device, Medical Devices, body-building equipment, personal digital assistant, terminal etc.Alternatively, terminal 900 can also be that intelligent router, Intelligent air purifier, intelligent water purifier, intelligent camera are first-class.
With reference to Fig. 9, terminal 900 can comprise following one or more assembly: processing components 902, storer 904, electric power assembly 906, multimedia groupware 908, audio-frequency assembly 910, the interface 912 of I/O (I/O), sensor module 914, and communications component 916.
The integrated operation of the usual control terminal 900 of processing components 902, such as with display, call, data communication, camera operation and record operate the operation be associated.Processing components 902 can comprise one or more processor 920 to perform instruction, to complete all or part of step of above-mentioned method.In addition, processing components 902 can comprise one or more module, and what be convenient between processing components 902 and other assemblies is mutual.Such as, processing components 902 can comprise multi-media module, mutual with what facilitate between multimedia groupware 908 and processing components 902.
Storer 904 is configured to store various types of data to be supported in the operation of terminal 900.The example of these data comprises for any application program of operation in terminal 900 or the instruction of method, contact data, telephone book data, message, picture, video etc.Storer 904 can be realized by the volatibility of any type or non-volatile memory device or their combination, as static RAM (SRAM), Electrically Erasable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory EPROM (EPROM), programmable read only memory (PROM), ROM (read-only memory) (ROM), magnetic store, flash memory, disk or CD.
The various assemblies that electric power assembly 906 is terminal 900 provide electric power.Electric power assembly 906 can comprise power-supply management system, one or more power supply, and other and the assembly generating, manage and distribute electric power for terminal 900 and be associated.
Multimedia groupware 908 is included in the screen providing an output interface between described terminal 900 and user.In certain embodiments, screen can comprise liquid crystal display (LCD) and touch panel (TP).If screen comprises touch panel, screen may be implemented as touch-screen, to receive the input signal from user.Touch panel comprises one or more touch sensor with the gesture on sensing touch, slip and touch panel.Described touch sensor can the border of not only sensing touch or sliding action, but also detects the duration relevant to described touch or slide and pressure.In certain embodiments, multimedia groupware 908 comprises a front-facing camera and/or post-positioned pick-up head.When terminal 900 is in operator scheme, during as screening-mode or video mode, front-facing camera and/or post-positioned pick-up head can receive outside multi-medium data.Each front-facing camera and post-positioned pick-up head can be fixing optical lens systems or have focal length and optical zoom ability.
Audio-frequency assembly 910 is configured to export and/or input audio signal.Such as, audio-frequency assembly 910 comprises a microphone (MIC), and when terminal 900 is in operator scheme, during as call model, logging mode and speech recognition mode, microphone is configured to receive external audio signal.The sound signal received can be stored in storer 904 further or be sent via communications component 916.In certain embodiments, audio-frequency assembly 910 also comprises a loudspeaker, for output audio signal.
I/O interface 912 is for providing interface between processing components 902 and peripheral interface module, and above-mentioned peripheral interface module can be keyboard, some striking wheel, button etc.These buttons can include but not limited to: home button, volume button, start button and locking press button.
Sensor module 914 comprises one or more sensor, for providing the state estimation of various aspects for terminal 900.Such as, sensor module 914 can detect the opening/closing state of terminal 900, the relative positioning of assembly, such as described assembly is display and the keypad of terminal 900, the position of all right sense terminals 900 of sensor module 914 or terminal 900 1 assemblies changes, the presence or absence that user contacts with terminal 900, the temperature variation of terminal 900 orientation or acceleration/deceleration and terminal 900.Sensor module 914 can comprise proximity transducer, be configured to without any physical contact time detect near the existence of object.Sensor module 914 can also comprise optical sensor, as CMOS or ccd image sensor, for using in imaging applications.In certain embodiments, this sensor module 914 can also comprise acceleration transducer, gyro sensor, Magnetic Sensor, pressure transducer or temperature sensor.
Communications component 916 is configured to the communication being convenient to wired or wireless mode between terminal 900 and other equipment.Terminal 900 can access the wireless network based on communication standard, as WiFi, 2G or 3G, or their combination.In one exemplary embodiment, communications component 916 receives from the broadcast singal of external broadcasting management system or broadcast related information via broadcast channel.In one exemplary embodiment, described communications component 916 also comprises near-field communication (NFC) module, to promote junction service.Such as, can based on radio-frequency (RF) identification (RFID) technology in NFC module, Infrared Data Association (IrDA) technology, ultra broadband (UWB) technology, bluetooth (BT) technology and other technologies realize.
In the exemplary embodiment, terminal 900 can be realized, for performing said method by one or more application specific integrated circuit (ASIC), digital signal processor (DSP), digital signal processing appts (DSPD), programmable logic device (PLD) (PLD), field programmable gate array (FPGA), controller, microcontroller, microprocessor or other electronic components.
In the exemplary embodiment, additionally provide a kind of non-transitory computer-readable recording medium comprising instruction, such as, comprise the storer 904 of instruction, above-mentioned instruction can perform said method by the processor 920 of terminal 900.Such as, described non-transitory computer-readable recording medium can be ROM, random access memory (RAM), CD-ROM, tape, floppy disk and optical data storage devices etc.
Figure 10 is the block diagram of a kind of device 1900 for generating Cascading Style Sheet code according to an exemplary embodiment.Such as, device 1900 may be provided in a server.With reference to Figure 10, device 1900 comprises processing components 1922, and it comprises one or more processor further, and the memory resource representated by storer 1932, can such as, by the instruction of the execution of processing components 1922, application program for storing.The application program stored in storer 1932 can comprise each module corresponding to one group of instruction one or more.In addition, processing components 1922 is configured to perform instruction, to perform the method for above-mentioned generation Cascading Style Sheet code.
Device 1900 can also comprise the power management that a power supply module 1926 is configured to actuating unit 1900, and a wired or wireless network interface 1950 is configured to device 1900 to be connected to network, and input and output (I/O) interface 1958.Device 1900 can operate the operating system based on being stored in storer 1932, such as WindowsServerTM, MacOSXTM, UnixTM, LinuxTM, FreeBSDTM or similar.
CSS code reverse to be compiled, by compiling the pattern coded description in CSS code to be compiled the statement code in CSS code to be compiled, is primary CSS code by disclosure embodiment.Can follow-up to the maintenance process of CSS code in directly amendment statement code can complete CSS code be safeguarded, without the need to revising complete CSS code, improve maintainability and the maintenance efficiency of the CSS code after writing.
Those skilled in the art, at consideration instructions and after putting into practice invention disclosed herein, will easily expect other embodiment of the present disclosure.The application is intended to contain any modification of the present disclosure, purposes or adaptations, and these modification, purposes or adaptations are followed general principle of the present disclosure and comprised the undocumented common practise in the art of the disclosure or conventional techniques means.Instructions and embodiment are only regarded as exemplary, and true scope of the present disclosure and spirit are pointed out by claim below.
Should be understood that, the present invention is not limited to precision architecture described above and illustrated in the accompanying drawings, and can carry out various amendment and change not departing from its scope.Scope of the present invention is only limited by appended claim.

Claims (15)

1. generate a method for Cascading Style Sheet code, it is characterized in that, described method comprises:
Obtain Cascading Style Sheet CSS code to be compiled, described CSS code to be compiled comprises statement code and pattern coded description;
According to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding.
2. method according to claim 1, it is characterized in that, described according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding, comprising:
If find variable in described pattern coded description, then in described statement code, search the variate-value of described variable;
The variate-value of described variable is replaced the described variable found.
3. method according to claim 2, is characterized in that, describedly the variate-value of described variable is replaced the described variable found, and comprising:
If detect arithmetic expression in the statement comprising described variable, then according to described arithmetic expression, computing is carried out to the variate-value of described variable;
Variate-value after described computing is replaced the described variable found.
4. method according to claim 1, it is characterized in that, described according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding, comprising:
If find function in described pattern coded description, then in described statement code, search the function body of described function;
Detect in described function and whether carry self-defining function variate-value;
If do not carry self-defining function variate-value in described function, then the function body of described function is replaced described function, and use the default function variate-value of described function;
If carry self-defining function variate-value in described function, then the function body of described function is replaced described function, and described self-defining function variate-value is replaced the default function variate-value in the function body of described function.
5. method according to claim 1, it is characterized in that, described according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding, comprising:
If find the object of derived class in described pattern coded description, then in described statement code, search the class body content of described class;
The class body content of described class is added in the object inheriting described class.
6. method according to claim 1, is characterized in that, after the Cascading Style Sheet CSS code that described acquisition is to be compiled, described method also comprises:
If the code importing file detected in described statement code, then obtain code file to be imported according to the path in the code of described importing file;
Code in described code file to be imported is added in described CSS code to be compiled.
7. method according to claim 1, is characterized in that, after the Cascading Style Sheet CSS code that described acquisition is to be compiled, described method also comprises:
If detect the code of nested form in described pattern coded description, then the subobject described in the code according to described nested form and the object comprising described subobject, generate the coded description of described subobject;
Delete the code of the described nested form comprised in the object of described subobject.
8. generate a device for Cascading Style Sheet code, it is characterized in that, described device comprises:
Acquisition module, for obtaining Cascading Style Sheet CSS code to be compiled, described CSS code to be compiled comprises statement code and pattern coded description;
Collector, for according to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding.
9. device according to claim 8, is characterized in that, described collector, comprising:
First searches submodule, during for finding variable in described pattern coded description, searches the variate-value of described variable in described statement code;
First replaces submodule, for the variate-value of described variable being replaced the described variable found.
10. device according to claim 9, is characterized in that, described first replaces submodule is used for:
When detecting arithmetic expression in the statement comprising described variable, according to described arithmetic expression, computing is carried out to the variate-value of described variable; And the variate-value after described computing is replaced the described variable found.
11. devices according to claim 8, is characterized in that, described collector, comprising:
Second searches submodule, during for finding function in described pattern coded description, searches the function body of described function in described statement code;
Detection sub-module, for detecting in described function whether carry self-defining function variate-value;
Second replaces submodule, during for not carrying self-defining function variate-value in described function, the function body of described function is replaced described function, and uses the default function variate-value of described function;
3rd replaces submodule, during for carrying self-defining function variate-value in described function, the function body of described function is replaced described function, and described self-defining function variate-value is replaced the default function variate-value in the function body of described function.
12. devices according to claim 8, is characterized in that, described collector, comprising:
3rd searches submodule, during for finding the object of derived class in described pattern coded description, searches the class body content of described class in described statement code;
First adds submodule, for the class body content of described class being added in the object inheriting described class.
13. devices according to claim 8, is characterized in that, described collector, also comprises:
Obtaining submodule, during for the code importing file being detected in described statement code, obtaining code file to be imported according to the path in the code of described importing file;
Second adds submodule, for being added in described CSS code to be compiled by the code in described code file to be imported.
14. devices according to claim 8, is characterized in that, described collector, also comprises:
Generate submodule, during for detecting the code of nested form in described pattern coded description, the subobject described in the code according to described nested form and the object comprising described subobject, generate the coded description of described subobject;
Delete submodule, for delete comprise described subobject object in the code of described nested form.
15. 1 kinds of devices generating Cascading Style Sheet code, is characterized in that, comprising:
Processor;
For the storer of storage of processor executable instruction;
Wherein, described processor is configured to:
Obtain Cascading Style Sheet CSS code to be compiled, described CSS code to be compiled comprises statement code and pattern coded description;
According to described statement code and described statement code corresponding code compilation rule described pattern coded description is compiled, generate the primary CSS code that described pattern coded description is corresponding.
CN201510385820.1A 2015-06-30 2015-06-30 Method and device for generating CSS code Pending CN105094938A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510385820.1A CN105094938A (en) 2015-06-30 2015-06-30 Method and device for generating CSS code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510385820.1A CN105094938A (en) 2015-06-30 2015-06-30 Method and device for generating CSS code

Publications (1)

Publication Number Publication Date
CN105094938A true CN105094938A (en) 2015-11-25

Family

ID=54575447

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510385820.1A Pending CN105094938A (en) 2015-06-30 2015-06-30 Method and device for generating CSS code

Country Status (1)

Country Link
CN (1) CN105094938A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109032584A (en) * 2018-07-27 2018-12-18 郑州云海信息技术有限公司 A kind of generation method of cascading style sheets, device, equipment and medium
CN111444456A (en) * 2020-03-25 2020-07-24 北京奇艺世纪科技有限公司 Method and device for editing style and electronic equipment
CN114428615A (en) * 2022-01-26 2022-05-03 北京有竹居网络技术有限公司 CSS compiling method, style updating method, device, medium and equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102693323A (en) * 2012-06-06 2012-09-26 新浪网技术(中国)有限公司 Cascading style sheet resolving method, resolver, webpage presentation method and server

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102693323A (en) * 2012-06-06 2012-09-26 新浪网技术(中国)有限公司 Cascading style sheet resolving method, resolver, webpage presentation method and server

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
匿名: ""Less中的继承"", 《HTTPS://GITHUB.COM/BASECSS/RECIPES-FOR-LESS/BLOB/MASTER/TIPS/LESS%E4%B8%AD%E7%9A%84%E7%BB%A7%E6%89%BF.MD》 *
赵春红等: ""LESS CSS框架简介"", 《HTTPS://WWW.IBM.COM/DEVELOPERWORKS/CN/WEB/1207_ZHAOCH_LESSCSS/》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109032584A (en) * 2018-07-27 2018-12-18 郑州云海信息技术有限公司 A kind of generation method of cascading style sheets, device, equipment and medium
CN111444456A (en) * 2020-03-25 2020-07-24 北京奇艺世纪科技有限公司 Method and device for editing style and electronic equipment
CN111444456B (en) * 2020-03-25 2023-10-27 北京奇艺世纪科技有限公司 Style editing method and device and electronic equipment
CN114428615A (en) * 2022-01-26 2022-05-03 北京有竹居网络技术有限公司 CSS compiling method, style updating method, device, medium and equipment

Similar Documents

Publication Publication Date Title
JP6457655B2 (en) Method, apparatus, program, and recording medium for creating graphical user interface
WO2019233219A1 (en) Dialogue state determining method and device, dialogue system, computer device, and storage medium
CN104536935B (en) Calculate display methods, calculate edit methods and device
CN106202223A (en) Content collection method, device and for collecting the device of content in application program
CN104133844A (en) Method and device for loading webpage
CN107423106A (en) The method and apparatus for supporting more frame grammars
CN104461348B (en) Information choosing method and device
CN108038102A (en) Recommendation method, apparatus, terminal and the storage medium of facial expression image
CN110262904B (en) Data acquisition method and device
CN107193554A (en) A kind of method and apparatus for generating front-end code
CN109710259A (en) A kind of data processing method, device and storage medium
CN105354017A (en) Information processing method and apparatus
CN105955808B (en) The task management method and device of instant messaging application
CN104636164A (en) Generating method and device for starting page
KR20140100315A (en) Mobile terminal and control method thereof
CN104965866B (en) A kind of method and apparatus for establishing label Yu style rule binding relationship
CN105094938A (en) Method and device for generating CSS code
CN104375760B (en) Method for information display and device
CN107450912A (en) Layout method, device and the terminal of the page
CN105320768A (en) Search method and apparatus
CN105183571A (en) Function calling method and device
CN105335061A (en) Information display method and apparatus and terminal
CN108803892A (en) A kind of method and apparatus for calling third party application in input method
CN109558553A (en) Pattern determines method and device
CN105930151A (en) Application compilation method and apparatus as well as terminal

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20151125

RJ01 Rejection of invention patent application after publication