diff --git a/.mapping.json b/.mapping.json index c61849525..84cb3bd63 100644 --- a/.mapping.json +++ b/.mapping.json @@ -18583,6 +18583,8 @@ "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/constrained-true-margins-and-paddings-wrap-horizontal/firefoxMobile/constrained-true-margins-and-paddings-wrap-horizontal.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/constrained-true-margins-and-paddings-wrap-horizontal/firefoxMobile/constrained-true-margins-and-paddings-wrap-horizontal.png", "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/constrained-true-margins-and-paddings-wrap-vertical/chromeMobile/constrained-true-margins-and-paddings-wrap-vertical.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/constrained-true-margins-and-paddings-wrap-vertical/chromeMobile/constrained-true-margins-and-paddings-wrap-vertical.png", "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/constrained-true-margins-and-paddings-wrap-vertical/firefoxMobile/constrained-true-margins-and-paddings-wrap-vertical.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/constrained-true-margins-and-paddings-wrap-vertical/firefoxMobile/constrained-true-margins-and-paddings-wrap-vertical.png", + "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/chromeMobile/incorrect-constraints.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/chromeMobile/incorrect-constraints.png", + "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/firefoxMobile/incorrect-constraints.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/firefoxMobile/incorrect-constraints.png", "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/min-max-constrained-false-horizontal/chromeMobile/min-max-constrained-false-horizontal.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/min-max-constrained-false-horizontal/chromeMobile/min-max-constrained-false-horizontal.png", "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/min-max-constrained-false-horizontal/firefoxMobile/min-max-constrained-false-horizontal.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/min-max-constrained-false-horizontal/firefoxMobile/min-max-constrained-false-horizontal.png", "client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/min-max-constrained-false-overlap/chromeMobile/min-max-constrained-false-overlap.png":"divkit/public/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/min-max-constrained-false-overlap/chromeMobile/min-max-constrained-false-overlap.png", diff --git a/client/web/divkit/src/components/utilities/Outer.svelte b/client/web/divkit/src/components/utilities/Outer.svelte index 2c51eb5a4..04a4bcd3c 100644 --- a/client/web/divkit/src/components/utilities/Outer.svelte +++ b/client/web/divkit/src/components/utilities/Outer.svelte @@ -428,11 +428,29 @@ if (type === 'wrap_content') { const width = $jsonWidth as WrapContentSize; + let min; + let max; if (width.min_size && isNonNegativeNumber(width.min_size.value)) { - newWidthMin = pxToEm(width.min_size.value); + min = width.min_size.value; } if (width.max_size && isNonNegativeNumber(width.max_size.value)) { - newWidthMax = pxToEm(width.max_size.value); + max = width.max_size.value; + } + if (min !== undefined && max !== undefined && min > max) { + componentContext.logError(wrapError(new Error('Element has incorrect width constraints (min size is bigger than max size).'), { + additional: { + id: componentContext.json.id, + minSize: min + 'dp', + maxSize: max + 'dp' + } + })); + min = max = undefined; + } + if (min !== undefined) { + newWidthMin = pxToEm(min); + } + if (max !== undefined) { + newWidthMax = pxToEm(max); } } @@ -561,11 +579,29 @@ if (type === 'wrap_content') { const height = $jsonHeight as WrapContentSize; - if (height?.min_size && isNonNegativeNumber(height.min_size.value)) { - newHeightMin = pxToEm(height.min_size.value); + let min; + let max; + if (height.min_size && isNonNegativeNumber(height.min_size.value)) { + min = height.min_size.value; } - if (height?.max_size && isNonNegativeNumber(height.max_size.value)) { - newHeightMax = pxToEm(height.max_size.value); + if (height.max_size && isNonNegativeNumber(height.max_size.value)) { + max = height.max_size.value; + } + if (min !== undefined && max !== undefined && min > max) { + componentContext.logError(wrapError(new Error('Element has incorrect height constraints (min size is bigger than max size).'), { + additional: { + id: componentContext.json.id, + minSize: min + 'dp', + maxSize: max + 'dp' + } + })); + min = max = undefined; + } + if (min !== undefined) { + newHeightMin = pxToEm(min); + } + if (max !== undefined) { + newHeightMax = pxToEm(max); } } diff --git a/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/chromeMobile/incorrect-constraints.png b/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/chromeMobile/incorrect-constraints.png new file mode 100644 index 000000000..be3d55cba Binary files /dev/null and b/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/chromeMobile/incorrect-constraints.png differ diff --git a/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/firefoxMobile/incorrect-constraints.png b/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/firefoxMobile/incorrect-constraints.png new file mode 100644 index 000000000..998ebd3f0 Binary files /dev/null and b/client/web/divkit/tests/hermione/screens/crossplatform/components/div-size/wrap-content/incorrect-constraints/firefoxMobile/incorrect-constraints.png differ diff --git a/test_data/integration_test_data/wrap_content_constraints_warning.json b/test_data/integration_test_data/wrap_content_constraints_warning.json index 6197271d0..ac5df5baa 100644 --- a/test_data/integration_test_data/wrap_content_constraints_warning.json +++ b/test_data/integration_test_data/wrap_content_constraints_warning.json @@ -124,7 +124,29 @@ ], "platforms": [ "android" - ] + ], + "unsupported_platforms": { + "web": "Web error contains an object with the error properties" + } + }, + { + "expected": [ + { + "type": "error", + "value": "Element has incorrect width constraints (min size is bigger than max size)." + }, + { + "type": "error", + "value": "Element has incorrect height constraints (min size is bigger than max size)." + } + ], + "platforms": [ + "web" + ], + "unsupported_platforms": { + "android": "Web error contains an object with the error properties", + "ios": "Web error contains an object with the error properties" + } } ] } diff --git a/test_data/snapshot_test_data/div-size/wrap-content/incorrect-constraints.json b/test_data/snapshot_test_data/div-size/wrap-content/incorrect-constraints.json index 4863d7970..4cb7d4659 100644 --- a/test_data/snapshot_test_data/div-size/wrap-content/incorrect-constraints.json +++ b/test_data/snapshot_test_data/div-size/wrap-content/incorrect-constraints.json @@ -1,7 +1,8 @@ { "description": "Container with elements with incorrect size constraints", "platforms": [ - "android" + "android", + "web" ], "templates": { "test_container": {