Skip to content

Commit ce30484

Browse files
authored
fix: css nullpointer when using cn1-box-shadow-h or cn1-box-shadow-v (#3852)
1 parent 97c6c01 commit ce30484

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

CodenameOneDesigner/src/com/codename1/designer/css/CSSTheme.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,38 +3128,43 @@ Insets getBoxShadowPadding(Map<String, LexicalUnit> style) {
31283128
boxShadow = tmp;
31293129
}
31303130
}
3131-
3132-
3131+
31333132
if (isNone(boxShadow)) {
31343133
return i;
31353134
}
3136-
3137-
3138-
3135+
31393136
ScaledUnit insetUnit = boxShadow;
31403137
while (insetUnit != null) {
31413138
if ("inset".equals(insetUnit.getStringValue())) {
3142-
31433139
return i;
31443140
}
31453141
insetUnit = (ScaledUnit)insetUnit.getNextLexicalUnit();
31463142
}
3147-
3148-
3143+
31493144
double hShadow = boxShadow.getPixelValue();
3150-
3151-
boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();
3152-
3153-
double vShadow = boxShadow.getPixelValue();
31543145
boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();
3146+
3147+
double vShadow = 0;
3148+
if (boxShadow == null) {
3149+
boxShadow = (ScaledUnit)style.get("cn1-box-shadow-v");
3150+
}
3151+
if (boxShadow != null) {
3152+
vShadow = boxShadow.getPixelValue();
3153+
boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();
3154+
}
31553155

31563156
double blur = 0;
3157-
3157+
if (boxShadow == null) {
3158+
boxShadow = (ScaledUnit)style.get("cn1-box-shadow-blur");
3159+
}
31583160
if (boxShadow != null) {
31593161
blur = boxShadow.getPixelValue();
31603162
boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();
31613163
}
31623164
double spread = 0;
3165+
if (boxShadow == null) {
3166+
boxShadow = (ScaledUnit)style.get("cn1-box-shadow-spread");
3167+
}
31633168
if (boxShadow != null) {
31643169
spread = boxShadow.getPixelValue();
31653170
}
@@ -3168,12 +3173,8 @@ Insets getBoxShadowPadding(Map<String, LexicalUnit> style) {
31683173
i.left = Math.max(0, (int)Math.ceil(spread - hShadow + blur/2));
31693174
i.bottom = Math.max(0, (int)Math.ceil(spread + vShadow + blur/2));
31703175
i.right = Math.max(0, (int)Math.ceil(spread + hShadow + blur/2));
3171-
3172-
3176+
31733177
return i;
3174-
3175-
3176-
31773178
}
31783179

31793180
String generateBoxShadowPaddingString() {

0 commit comments

Comments
 (0)