-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(css-bkg-pos): Added possibility to declare background pos by single numeric value #7958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
34407f8
d3bb4e6
b757cfb
dcecf27
2f929f6
f246f8f
5834f92
ae4a5be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -713,6 +713,18 @@ private BackgroundDrawParams getDrawParams(float width, float height) { | |
| res.posX = spaceX; | ||
| } | ||
|
|
||
| if ("center".equals(vy.getString().toLowerCase(Locale.ENGLISH))) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't this logic be reused with the one below? This
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid that without strong unit tests around this area, an important part of the parser could brake. I could write those unit tests, but as stated above, I would need some help with that 😞 |
||
| res.posY = spaceY / 2; | ||
| } else if ("bottom".equals(vy.getString().toLowerCase(Locale.ENGLISH))) { | ||
| res.posY = spaceY; | ||
| } | ||
| } else if ("number".equals(vx.getType()) && "ident".equals(vy.getType())) { | ||
| if ("%".equals(vx.getUnit())) { | ||
| res.posX = spaceX * vx.getValue() / 100; | ||
| } else if ("px".equals(vx.getUnit()) || vx.getUnit() == null || vx.getUnit().isEmpty()) { | ||
| res.posX = vx.getValue(); | ||
| } | ||
|
|
||
| if ("center".equals(vy.getString().toLowerCase(Locale.ENGLISH))) { | ||
| res.posY = spaceY / 2; | ||
| } else if ("bottom".equals(vy.getString().toLowerCase(Locale.ENGLISH))) { | ||
|
|
@@ -731,17 +743,22 @@ private static CSSValue[] parsePosition(CSSValue[] values) { | |
| } | ||
|
|
||
| CSSValue[] result = null; | ||
| if (values.length == 1 && "ident".equals(values[0].getType())) { | ||
| String val = values[0].getString().toLowerCase(Locale.ENGLISH); | ||
| if (values.length == 1) { | ||
| // If you only one keyword is specified, the other value is "center" | ||
| CSSValue center = new CSSValue("ident", "center", null, 0); | ||
|
|
||
| // If you only one keyword is specified, the other value is "center" | ||
| if ("left".equals(val) || "right".equals(val)) { | ||
| if ("ident".equals(values[0].getType())) { | ||
| String val = values[0].getString().toLowerCase(Locale.ENGLISH); | ||
|
|
||
| if ("left".equals(val) || "right".equals(val)) { | ||
| result = new CSSValue[]{values[0], center}; | ||
| } else if ("top".equals(val) || "bottom".equals(val)) { | ||
| result = new CSSValue[]{center, values[0]}; | ||
| } else if ("center".equals(val)) { | ||
| result = new CSSValue[]{center, center}; | ||
| } | ||
| } else if ("number".equals(values[0].getType())) { | ||
| result = new CSSValue[]{values[0], center}; | ||
| } else if ("top".equals(val) || "bottom".equals(val)) { | ||
| result = new CSSValue[]{center, values[0]}; | ||
| } else if ("center".equals(val)) { | ||
| result = new CSSValue[]{center, center}; | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.