Skip to content

Commit

Permalink
fix: css nullpointer when using cn1-box-shadow-h or cn1-box-shadow-v (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shannah authored Oct 26, 2024
1 parent 97c6c01 commit ce30484
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions CodenameOneDesigner/src/com/codename1/designer/css/CSSTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -3128,38 +3128,43 @@ Insets getBoxShadowPadding(Map<String, LexicalUnit> style) {
boxShadow = tmp;
}
}



if (isNone(boxShadow)) {
return i;
}




ScaledUnit insetUnit = boxShadow;
while (insetUnit != null) {
if ("inset".equals(insetUnit.getStringValue())) {

return i;
}
insetUnit = (ScaledUnit)insetUnit.getNextLexicalUnit();
}



double hShadow = boxShadow.getPixelValue();

boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();

double vShadow = boxShadow.getPixelValue();
boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();

double vShadow = 0;
if (boxShadow == null) {
boxShadow = (ScaledUnit)style.get("cn1-box-shadow-v");
}
if (boxShadow != null) {
vShadow = boxShadow.getPixelValue();
boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();
}

double blur = 0;

if (boxShadow == null) {
boxShadow = (ScaledUnit)style.get("cn1-box-shadow-blur");
}
if (boxShadow != null) {
blur = boxShadow.getPixelValue();
boxShadow = (ScaledUnit)boxShadow.getNextLexicalUnit();
}
double spread = 0;
if (boxShadow == null) {
boxShadow = (ScaledUnit)style.get("cn1-box-shadow-spread");
}
if (boxShadow != null) {
spread = boxShadow.getPixelValue();
}
Expand All @@ -3168,12 +3173,8 @@ Insets getBoxShadowPadding(Map<String, LexicalUnit> style) {
i.left = Math.max(0, (int)Math.ceil(spread - hShadow + blur/2));
i.bottom = Math.max(0, (int)Math.ceil(spread + vShadow + blur/2));
i.right = Math.max(0, (int)Math.ceil(spread + hShadow + blur/2));



return i;



}

String generateBoxShadowPaddingString() {
Expand Down

0 comments on commit ce30484

Please sign in to comment.