|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.gwt.safecss.shared.SafeStylesUtils
public final class SafeStylesUtils
Utility class containing static methods for creating SafeStyles
.
Nested Class Summary | |
---|---|
(package private) static class |
SafeStylesUtils.Impl
Standard implementation of this class. |
(package private) static class |
SafeStylesUtils.ImplIE8
IE8 implementation of this class. |
(package private) static class |
SafeStylesUtils.ImplServer
Server implementation of this class. |
Method Summary | |
---|---|
static SafeStyles |
forBackgroundImage(SafeUri uri)
Sets the background-image CSS property. |
static SafeStyles |
forBorderStyle(Style.BorderStyle value)
Sets the border-style CSS property. |
static SafeStyles |
forBorderWidth(double value,
Style.Unit unit)
Set the border-width css property. |
static SafeStyles |
forBottom(double value,
Style.Unit unit)
Set the bottom css property. |
static SafeStyles |
forClear(Style.Clear value)
Sets the 'clear' CSS property. |
static SafeStyles |
forCursor(Style.Cursor value)
Sets the cursor CSS property. |
static SafeStyles |
forDisplay(Style.Display value)
Sets the display CSS property. |
static SafeStyles |
forFloat(Style.Float value)
Set the float css property. |
static SafeStyles |
forFontSize(double value,
Style.Unit unit)
Set the font-size css property. |
static SafeStyles |
forFontStyle(Style.FontStyle value)
Sets the font-style CSS property. |
static SafeStyles |
forFontWeight(Style.FontWeight value)
Sets the font-weight CSS property. |
static SafeStyles |
forHeight(double value,
Style.Unit unit)
Set the height css property. |
static SafeStyles |
forLeft(double value,
Style.Unit unit)
Set the left css property. |
static SafeStyles |
forLineHeight(double value,
Style.Unit unit)
Set the line-height css property. |
static SafeStyles |
forListStyleType(Style.ListStyleType value)
Sets the list-style-type CSS property. |
static SafeStyles |
forMargin(double value,
Style.Unit unit)
Set the margin css property. |
static SafeStyles |
forMarginBottom(double value,
Style.Unit unit)
Set the margin-bottom css property. |
static SafeStyles |
forMarginLeft(double value,
Style.Unit unit)
Set the margin-left css property. |
static SafeStyles |
forMarginRight(double value,
Style.Unit unit)
Set the margin-right css property. |
static SafeStyles |
forMarginTop(double value,
Style.Unit unit)
Set the margin-top css property. |
static SafeStyles |
forOpacity(double value)
Set the opacity css property. |
static SafeStyles |
forOutlineStyle(Style.OutlineStyle value)
Sets the outline-style CSS property. |
static SafeStyles |
forOutlineWidth(double value,
Style.Unit unit)
Set the outline-width css property. |
static SafeStyles |
forOverflow(Style.Overflow value)
Sets the overflow CSS property. |
static SafeStyles |
forOverflowX(Style.Overflow value)
Sets the overflow-x CSS property. |
static SafeStyles |
forOverflowY(Style.Overflow value)
Sets the overflow-y CSS property. |
static SafeStyles |
forPadding(double value,
Style.Unit unit)
Set the padding css property. |
static SafeStyles |
forPaddingBottom(double value,
Style.Unit unit)
Set the padding-bottom css property. |
static SafeStyles |
forPaddingLeft(double value,
Style.Unit unit)
Set the padding-left css property. |
static SafeStyles |
forPaddingRight(double value,
Style.Unit unit)
Set the padding-right css property. |
static SafeStyles |
forPaddingTop(double value,
Style.Unit unit)
Set the padding-top css property. |
static SafeStyles |
forPosition(Style.Position value)
Sets the position CSS property. |
static SafeStyles |
forRight(double value,
Style.Unit unit)
Set the right css property. |
static SafeStyles |
forTableLayout(Style.TableLayout value)
Set the table-layout CSS property. |
static SafeStyles |
forTextAlign(Style.TextAlign value)
Sets the 'text-align' CSS property. |
static SafeStyles |
forTextDecoration(Style.TextDecoration value)
Sets the 'text-decoration' CSS property. |
static SafeStyles |
forTextIndent(double value,
Style.Unit unit)
Set the 'text-indent' CSS property. |
static SafeStyles |
forTextJustify(Style.TextJustify value)
Set the 'text-justify' CSS3 property. |
static SafeStyles |
forTextOverflow(Style.TextOverflow value)
Set the 'text-overflow' CSS3 property. |
static SafeStyles |
forTextTransform(Style.TextTransform value)
Set the 'text-transform' CSS property. |
static SafeStyles |
forTop(double value,
Style.Unit unit)
Set the top css property. |
static SafeStyles |
forTrustedBackgroundColor(java.lang.String value)
Returns a SafeStyles constructed from a trusted background color,
i.e., without escaping the value. |
static SafeStyles |
forTrustedBackgroundImage(java.lang.String value)
Returns a SafeStyles constructed from a trusted background image,
i.e., without escaping the value. |
static SafeStyles |
forTrustedBorderColor(java.lang.String value)
Returns a SafeStyles constructed from a trusted border color, i.e.,
without escaping the value. |
static SafeStyles |
forTrustedColor(java.lang.String value)
Returns a SafeStyles constructed from a trusted font color, i.e.,
without escaping the value. |
static SafeStyles |
forTrustedOutlineColor(java.lang.String value)
Returns a SafeStyles constructed from a trusted outline color,
i.e., without escaping the value. |
static SafeStyles |
forVerticalAlign(double value,
Style.Unit unit)
Sets the vertical-align CSS property. |
static SafeStyles |
forVerticalAlign(Style.VerticalAlign value)
Sets the vertical-align CSS property. |
static SafeStyles |
forVisibility(Style.Visibility value)
Sets the visibility CSS property. |
static SafeStyles |
forWhiteSpace(Style.WhiteSpace value)
Set the 'white-space' CSS property. |
static SafeStyles |
forWidth(double value,
Style.Unit unit)
Set the width css property. |
static SafeStyles |
forZIndex(int value)
Set the z-index css property. |
static SafeStyles |
fromTrustedNameAndValue(java.lang.String name,
double value,
Style.Unit unit)
Returns a SafeStyles constructed from a trusted name and a trusted
value, i.e., without escaping the name and value. |
static SafeStyles |
fromTrustedNameAndValue(java.lang.String name,
java.lang.String value)
Returns a SafeStyles constructed from a trusted name and a trusted
value, i.e., without escaping the name and value. |
static SafeStyles |
fromTrustedString(java.lang.String s)
Returns a SafeStyles constructed from a trusted string, i.e.,
without escaping the string. |
(package private) static void |
verifySafeStylesConstraints(java.lang.String styles)
Verify that the basic constraints of a SafeStyles are met. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SafeStyles forBackgroundImage(SafeUri uri)
uri
- the URI of the background image
SafeStyles
instanceforTrustedBackgroundImage(String)
public static SafeStyles forBorderStyle(Style.BorderStyle value)
public static SafeStyles forBorderWidth(double value, Style.Unit unit)
public static SafeStyles forBottom(double value, Style.Unit unit)
public static SafeStyles forClear(Style.Clear value)
public static SafeStyles forCursor(Style.Cursor value)
public static SafeStyles forDisplay(Style.Display value)
public static SafeStyles forFloat(Style.Float value)
public static SafeStyles forFontSize(double value, Style.Unit unit)
public static SafeStyles forFontStyle(Style.FontStyle value)
public static SafeStyles forFontWeight(Style.FontWeight value)
public static SafeStyles forHeight(double value, Style.Unit unit)
public static SafeStyles forLeft(double value, Style.Unit unit)
public static SafeStyles forLineHeight(double value, Style.Unit unit)
public static SafeStyles forListStyleType(Style.ListStyleType value)
public static SafeStyles forMargin(double value, Style.Unit unit)
public static SafeStyles forMarginBottom(double value, Style.Unit unit)
public static SafeStyles forMarginLeft(double value, Style.Unit unit)
public static SafeStyles forMarginRight(double value, Style.Unit unit)
public static SafeStyles forMarginTop(double value, Style.Unit unit)
public static SafeStyles forOpacity(double value)
public static SafeStyles forOutlineStyle(Style.OutlineStyle value)
public static SafeStyles forOutlineWidth(double value, Style.Unit unit)
public static SafeStyles forOverflow(Style.Overflow value)
public static SafeStyles forOverflowX(Style.Overflow value)
public static SafeStyles forOverflowY(Style.Overflow value)
public static SafeStyles forPadding(double value, Style.Unit unit)
public static SafeStyles forPaddingBottom(double value, Style.Unit unit)
public static SafeStyles forPaddingLeft(double value, Style.Unit unit)
public static SafeStyles forPaddingRight(double value, Style.Unit unit)
public static SafeStyles forPaddingTop(double value, Style.Unit unit)
public static SafeStyles forPosition(Style.Position value)
public static SafeStyles forRight(double value, Style.Unit unit)
public static SafeStyles forTableLayout(Style.TableLayout value)
public static SafeStyles forTextAlign(Style.TextAlign value)
public static SafeStyles forTextDecoration(Style.TextDecoration value)
public static SafeStyles forTextIndent(double value, Style.Unit unit)
public static SafeStyles forTextJustify(Style.TextJustify value)
public static SafeStyles forTextOverflow(Style.TextOverflow value)
public static SafeStyles forTextTransform(Style.TextTransform value)
public static SafeStyles forTop(double value, Style.Unit unit)
public static SafeStyles forTrustedBackgroundColor(java.lang.String value)
Returns a SafeStyles
constructed from a trusted background color,
i.e., without escaping the value. No checks are performed. The calling code
should be carefully reviewed to ensure the argument will satisfy the
SafeStyles
contract when they are composed into the form:
"<name>:<value>;".
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
value
- the property value
SafeStyles
instancepublic static SafeStyles forTrustedBackgroundImage(java.lang.String value)
Returns a SafeStyles
constructed from a trusted background image,
i.e., without escaping the value. No checks are performed. The calling code
should be carefully reviewed to ensure the argument will satisfy the
SafeStyles
contract when they are composed into the form:
"<name>:<value>;".
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
value
- the property value
SafeStyles
instanceforBackgroundImage(SafeUri)
public static SafeStyles forTrustedBorderColor(java.lang.String value)
Returns a SafeStyles
constructed from a trusted border color, i.e.,
without escaping the value. No checks are performed. The calling code
should be carefully reviewed to ensure the argument will satisfy the
SafeStyles
contract when they are composed into the form:
"<name>:<value>;".
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
value
- the property value
SafeStyles
instancepublic static SafeStyles forTrustedColor(java.lang.String value)
Returns a SafeStyles
constructed from a trusted font color, i.e.,
without escaping the value. No checks are performed. The calling code
should be carefully reviewed to ensure the argument will satisfy the
SafeStyles
contract when they are composed into the form:
"<name>:<value>;".
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
value
- the property value
SafeStyles
instancepublic static SafeStyles forTrustedOutlineColor(java.lang.String value)
Returns a SafeStyles
constructed from a trusted outline color,
i.e., without escaping the value. No checks are performed. The calling code
should be carefully reviewed to ensure the argument will satisfy the
SafeStyles
contract when they are composed into the form:
"<name>:<value>;".
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
value
- the property value
SafeStyles
instancepublic static SafeStyles forVerticalAlign(double value, Style.Unit unit)
public static SafeStyles forVerticalAlign(Style.VerticalAlign value)
public static SafeStyles forVisibility(Style.Visibility value)
public static SafeStyles forWhiteSpace(Style.WhiteSpace value)
public static SafeStyles forWidth(double value, Style.Unit unit)
public static SafeStyles forZIndex(int value)
public static SafeStyles fromTrustedNameAndValue(java.lang.String name, double value, Style.Unit unit)
Returns a SafeStyles
constructed from a trusted name and a trusted
value, i.e., without escaping the name and value. No checks are performed.
The calling code should be carefully reviewed to ensure the argument will
satisfy the SafeStyles
contract when they are composed into the
form: "<name>:<value>;".
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
The name should be in hyphenated format, not camelCase format.
name
- the property namevalue
- the valueunit
- the units of the value
SafeStyles
instancepublic static SafeStyles fromTrustedNameAndValue(java.lang.String name, java.lang.String value)
Returns a SafeStyles
constructed from a trusted name and a trusted
value, i.e., without escaping the name and value. No checks are performed.
The calling code should be carefully reviewed to ensure the argument will
satisfy the SafeStyles
contract when they are composed into the
form: "<name>:<value>;".
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
The name should be in hyphenated format, not camelCase format.
name
- the property namevalue
- the property value
SafeStyles
instancepublic static SafeStyles fromTrustedString(java.lang.String s)
Returns a SafeStyles
constructed from a trusted string, i.e.,
without escaping the string. No checks are performed. The calling code
should be carefully reviewed to ensure the argument meets the
SafeStyles
contract.
Generally, SafeStyles
should be of the form
cssPropertyName:value;
, where neither the name nor the value
contain malicious scripts.
SafeStyles
may never contain literal angle brackets. Otherwise, it
could be unsafe to place a SafeStyles
into a <style> tag
(where it can't be HTML escaped). For example, if the SafeStyles
containing "
font: 'foo <style><script>evil</script>
'" is
used in a style sheet in a <style> tag, this could then break out of
the style context into HTML.
The following example values comply with this type's contract:
width: 1em;
height:1em;
width: 1em;height: 1em;
background:url('http://url');
The following example values do not comply with this type's contract:
background: red
(missing a trailing semi-colon)background:
(missing a value and a trailing semi-colon)1em
(missing an attribute name, which provides context for
the value)
s
- the input String
SafeStyles
instancestatic void verifySafeStylesConstraints(java.lang.String styles)
SafeStyles
are met. This
method is not a guarantee that the specified css is safe for use in a CSS
style attribute. It is a minimal set of assertions to check for common
errors.
styles
- the CSS properties string
java.lang.NullPointerException
- if the css is null
java.lang.AssertionError
- if the css does not meet the contraints
|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |