aboutsummaryrefslogtreecommitdiffstats
path: root/include/litehtml/borders.h
diff options
context:
space:
mode:
authorYuri Kobets <[email protected]>2024-01-31 03:48:44 +0300
committerGitHub <[email protected]>2024-01-31 03:48:44 +0300
commit6ca1ab0419e770e6d35a1ef690238773a1dafcee (patch)
tree16df635edd594dc1d1b9d0044993e2ae4d0e0200 /include/litehtml/borders.h
parent8c320007878795fe629de7fe1eaef9328ac9c719 (diff)
parentd85ebec101e77825e5708e58df0e2508ec4fd389 (diff)
Merge pull request #285 from litehtml/flex_layoutHEADv0.9dev
Flex layout
Diffstat (limited to 'include/litehtml/borders.h')
-rw-r--r--include/litehtml/borders.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/litehtml/borders.h b/include/litehtml/borders.h
index e690db6d..9c47abca 100644
--- a/include/litehtml/borders.h
+++ b/include/litehtml/borders.h
@@ -157,6 +157,35 @@ namespace litehtml
if (bottom_left_x < 0) bottom_left_x = 0;
if (bottom_left_y < 0) bottom_left_y = 0;
}
+ void fix_values(int width, int height)
+ {
+ fix_values();
+ int half_width = width / 2;
+ int half_height = height / 2;
+ auto fix_one = [&](int& radii_x, int& radii_y)
+ {
+ double factor = std::min((double) half_width / (double) radii_x, (double) half_height / (double) radii_y);
+ radii_x = (int) ((double) radii_x * factor);
+ radii_y = (int) ((double) radii_y * factor);
+ };
+
+ if(top_left_x > half_width || top_left_y > half_height)
+ {
+ fix_one(top_left_x, top_left_y);
+ }
+ if(top_right_x > half_width || top_right_y > half_height)
+ {
+ fix_one(top_right_x, top_right_y);
+ }
+ if(bottom_right_x > half_width || bottom_right_y > half_height)
+ {
+ fix_one(bottom_right_x, bottom_right_y);
+ }
+ if(bottom_left_x > half_width || bottom_left_y > half_height)
+ {
+ fix_one(bottom_left_x, bottom_left_y);
+ }
+ }
};
struct css_border_radius
@@ -213,6 +242,7 @@ namespace litehtml
ret.top_right_y = top_right_y.calc_percent(height);
ret.bottom_right_x = bottom_right_x.calc_percent(width);
ret.bottom_right_y = bottom_right_y.calc_percent(height);
+ ret.fix_values(width, height);
return ret;
}
};