Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions src/main/java/org/htmlunit/css/CssStyleSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,9 @@ else if ("print".equalsIgnoreCase(mediaType)) {
private static double pixelValue(final CSSValueImpl cssValue, final WebWindow webWindow) {
if (cssValue == null) {
LOG.warn("CSSValue is null but has to be a 'px', 'em', '%', 'ex', 'ch', "
+ "'vw', 'vh', 'vmin', 'vmax', 'rem', 'mm', 'cm', 'Q', or 'pt' value.");
+ "'vw', 'vh', 'vmin', 'vmax', 'dvw', 'dvh', 'dvmin', 'dvmax', "
+ "'lvw', 'lvh', 'lvmin', 'lvmax', 'svw', 'svh', 'svmin', 'svmax', "
+ "'rem', 'mm', 'cm', 'Q', or 'pt' value.");
return -1;
}

Expand Down Expand Up @@ -1499,6 +1501,42 @@ private static double pixelValue(final CSSValueImpl cssValue, final WebWindow we
case VMAX:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case DVW:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case DVH:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case DVMIN:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case DVMAX:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case LVW:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case LVH:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case LVMIN:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case LVMAX:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case SVW:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case SVH:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case SVMIN:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case SVMAX:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
case REM:
// hard coded default for the moment 16px = 100%
return 0.16f * cssValue.getDoubleValue();
Expand All @@ -1522,7 +1560,9 @@ private static double pixelValue(final CSSValueImpl cssValue, final WebWindow we
if (LOG.isWarnEnabled()) {
LOG.warn("CSSValue '" + cssValue.getCssText()
+ "' has to be a 'px', 'em', '%', 'ex', 'ch', "
+ "'vw', 'vh', 'vmin', 'vmax', 'rem', 'mm', 'cm', 'Q', or 'pt' value.");
+ "'vw', 'vh', 'vmin', 'vmax', 'dvw', 'dvh', 'dvmin', 'dvmax', "
+ "'lvw', 'lvh', 'lvmin', 'lvmax', 'svw', 'svh', 'svmin', 'svmax', "
+ "'rem', 'mm', 'cm', 'Q', or 'pt' value.");
}
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.htmlunit.javascript.host.css;

Check warning on line 15 in src/main/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration.java

View workflow job for this annotation

GitHub Actions / PMD

[PMD] reported by reviewdog 🐶 Too many static imports may lead to messy code Raw Output: {"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"uri":"file:///home/runner/work/htmlunit/htmlunit/src/main/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration.java"},"region":{"endColumn":3,"endLine":2058,"startColumn":1,"startLine":15}}}],"message":{"text":"Too many static imports may lead to messy code"},"ruleId":"TooManyStaticImports","ruleIndex":61}

import static org.htmlunit.BrowserVersionFeatures.CSS_BACKGROUND_INITIAL;
import static org.htmlunit.BrowserVersionFeatures.JS_STYLE_LETTER_SPACING_ACCEPTS_PERCENT;
Expand Down Expand Up @@ -2008,6 +2008,24 @@
unit = valueString.substring(valueString.length() - 3);
valueString = valueString.substring(0, valueString.length() - 3);
}
else if (valueString.endsWith("dvw")
|| valueString.endsWith("dvh")
|| valueString.endsWith("lvw")
|| valueString.endsWith("lvh")
|| valueString.endsWith("svw")
|| valueString.endsWith("svh")) {
unit = valueString.substring(valueString.length() - 3);
valueString = valueString.substring(0, valueString.length() - 3);
}
else if (valueString.endsWith("dvmin")
|| valueString.endsWith("dvmax")
|| valueString.endsWith("lvmin")
|| valueString.endsWith("lvmax")
|| valueString.endsWith("svmin")
|| valueString.endsWith("svmax")) {
unit = valueString.substring(valueString.length() - 5);
valueString = valueString.substring(0, valueString.length() - 5);
}
else {
return;
}
Expand Down
Loading
Loading