Interface StyleFormattingContext
- All Superinterfaces:
DeclarationFormattingContext
- All Known Implementing Classes:
DefaultStyleFormattingContext
,InlineStyleFormattingContext
Different implementations of this interface can provide different style text formatting.
If the rule does not contain a style declaration (of either properties or descriptors), the methods in this interface are not called.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This auxiliary method can be used to deepen the indentation at places where the general serialization flow does not give the desired results.void
endCurrentContext
(org.w3c.dom.css.CSSRule rule) Notify this context that the style was serialized for the given rule.void
endInlinePropertyDeclaration
(io.sf.carte.util.SimpleWriter wri) End an inline property declaration.void
Ends the serialization of a rule.void
endRuleList
(io.sf.carte.util.SimpleWriter wri) Called after a list of rules is serialized.void
endStyleDeclaration
(io.sf.carte.util.SimpleWriter wri) End a style declaration.void
setParentContext
(org.w3c.dom.css.CSSRule rule) Sets the parent of the rule being serialized, if any, providing additional context for the serialization.void
Starts the serialization of a rule.void
startStyleDeclaration
(io.sf.carte.util.SimpleWriter wri) Start a style declaration (of either properties or descriptors).void
updateContext
(org.w3c.dom.css.CSSRule rule) Update this context for the given rule.void
writeComment
(io.sf.carte.util.SimpleWriter wri, String comment) Serialize a comment that precedes a rule, with the appropriate indent.void
writeImportantPriority
(io.sf.carte.util.SimpleWriter wri) Serialize animportant
priority declaration to aSimpleWriter
.void
writeLeftCurlyBracket
(io.sf.carte.util.SimpleWriter wri) Serialize a left curly bracket to aSimpleWriter
.void
writeLevelIndent
(io.sf.carte.util.SimpleWriter wri) Serialize one level of indentation to aSimpleWriter
.void
writeRightCurlyBracket
(io.sf.carte.util.SimpleWriter wri) Serialize a right curly bracket to aSimpleWriter
.default void
writeShorthandValue
(io.sf.carte.util.SimpleWriter wri, String shorthandName, CSSShorthandValue value) Serialize a css shorthand value to the given writer.Methods inherited from interface io.sf.carte.doc.style.css.DeclarationFormattingContext
endPropertyDeclaration, startPropertyDeclaration, writeColon, writeComma, writeFullIndent, writeMinifiedValue, writeSemiColon, writeURL, writeValue
-
Method Details
-
deepenCurrentContext
void deepenCurrentContext()This auxiliary method can be used to deepen the indentation at places where the general serialization flow does not give the desired results.It is used only by the
@font-feature-values
rule. -
endCurrentContext
void endCurrentContext(org.w3c.dom.css.CSSRule rule) Notify this context that the style was serialized for the given rule.It is called before
endStyleDeclaration(SimpleWriter)
.- Parameters:
rule
- the rule being serialized.
-
endInlinePropertyDeclaration
End an inline property declaration.Called after
DeclarationFormattingContext.writeSemiColon(SimpleWriter)
, only from inline styles.- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endRule
Ends the serialization of a rule.It is called after
writeRightCurlyBracket(SimpleWriter)
.- Parameters:
wri
- the writer to write to.trailingComments
- the comments that go after the rule.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endRuleList
Called after a list of rules is serialized.May be used for indentation.
- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endStyleDeclaration
End a style declaration.Called after
endCurrentContext(CSSRule)
and beforewriteRightCurlyBracket(SimpleWriter)
.- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
setParentContext
void setParentContext(org.w3c.dom.css.CSSRule rule) Sets the parent of the rule being serialized, if any, providing additional context for the serialization.It is called before
startRule(SimpleWriter, List)
. However, this method being called does not guarantee thatstartRule()
will be called.- Parameters:
rule
- the parent rule. May benull
.
-
startRule
void startRule(io.sf.carte.util.SimpleWriter wri, List<String> precedingComments) throws IOException Starts the serialization of a rule.It is the first stage of the serialization of a rule. For example, in the case of style rules it is called before serializing the rule selector list. At-rules call it before writing the @-rule name.
- Parameters:
wri
- the writer to write to.precedingComments
- the comments that precede the rule.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
startStyleDeclaration
Start a style declaration (of either properties or descriptors).Called after
writeLeftCurlyBracket(SimpleWriter)
and before serializing the style declaration.- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
updateContext
void updateContext(org.w3c.dom.css.CSSRule rule) Update this context for the given rule.For style rules, it is called after serializing the selector list and before
writeLeftCurlyBracket(SimpleWriter)
. At-rules call it after writing the rule name.May be used for indentation.
- Parameters:
rule
- the rule being serialized.
-
writeComment
Serialize a comment that precedes a rule, with the appropriate indent.Trailing comments are generally written directly by
endRule(SimpleWriter, List)
because no indent is necessary.- Parameters:
wri
- the writer to write to.comment
- the comment to serialize.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeImportantPriority
Serialize animportant
priority declaration to aSimpleWriter
.If the property declaration has
important
priority, it is called after the value is written and beforeDeclarationFormattingContext.writeSemiColon(SimpleWriter)
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeLeftCurlyBracket
Serialize a left curly bracket to aSimpleWriter
.Called after
updateContext(CSSRule)
and beforestartStyleDeclaration(SimpleWriter)
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeLevelIndent
Serialize one level of indentation to aSimpleWriter
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeRightCurlyBracket
Serialize a right curly bracket to aSimpleWriter
.Called after
endStyleDeclaration(SimpleWriter)
and beforeendRule(SimpleWriter, List)
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeShorthandValue
default void writeShorthandValue(io.sf.carte.util.SimpleWriter wri, String shorthandName, CSSShorthandValue value) throws IOException Serialize a css shorthand value to the given writer.Although the
CSSShorthandValue
type contains priority information, this method only writes the value.The default implementation just writes
CSSValue.getCssText()
.- Parameters:
wri
- the writer.shorthandName
- the name of the shorthand property whose value is being printed.value
- the value to write.- Throws:
IOException
- if an error happened while writing.
-