aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2020-11-09 16:57:03 +0200
committerEli Zaretskii2020-11-09 16:57:03 +0200
commitbffd5d3a9d44ed99d6a573dc0fabe542d6b3bb8b (patch)
tree2da0e2b231fd18ffa54212016c352f24cf60f472 /src
parentb83e31bf9561f05204f503236373cbef14d61012 (diff)
parent18a7267c32a909bb26bd93d24543155aeb10e042 (diff)
downloademacs-bffd5d3a9d44ed99d6a573dc0fabe542d6b3bb8b.tar.gz
emacs-bffd5d3a9d44ed99d6a573dc0fabe542d6b3bb8b.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/image.c102
-rw-r--r--src/nsterm.m4
-rw-r--r--src/xwidget.c10
3 files changed, 110 insertions, 6 deletions
diff --git a/src/image.c b/src/image.c
index c857b8e62a4..b4cb1b7bf83 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9545,6 +9545,9 @@ DEF_DLL_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **));
9545#endif 9545#endif
9546 9546
9547#if LIBRSVG_CHECK_VERSION (2, 46, 0) 9547#if LIBRSVG_CHECK_VERSION (2, 46, 0)
9548DEF_DLL_FN (void, rsvg_handle_get_intrinsic_dimensions,
9549 RsvgHandle *, gboolean *, RsvgLength *, gboolean *,
9550 RsvgLength *, gboolean *, RsvgRectangle *));
9548DEF_DLL_FN (gboolean, rsvg_handle_get_geometry_for_layer, 9551DEF_DLL_FN (gboolean, rsvg_handle_get_geometry_for_layer,
9549 (RsvgHandle *, const char *, const RsvgRectangle *, 9552 (RsvgHandle *, const char *, const RsvgRectangle *,
9550 RsvgRectangle *, RsvgRectangle *, GError **)); 9553 RsvgRectangle *, RsvgRectangle *, GError **));
@@ -9599,6 +9602,7 @@ init_svg_functions (void)
9599 LOAD_DLL_FN (library, rsvg_handle_close); 9602 LOAD_DLL_FN (library, rsvg_handle_close);
9600#endif 9603#endif
9601#if LIBRSVG_CHECK_VERSION (2, 46, 0) 9604#if LIBRSVG_CHECK_VERSION (2, 46, 0)
9605 LOAD_DLL_FN (library, rsvg_handle_get_intrinsic_dimensions);
9602 LOAD_DLL_FN (library, rsvg_handle_get_geometry_for_layer); 9606 LOAD_DLL_FN (library, rsvg_handle_get_geometry_for_layer);
9603#else 9607#else
9604 LOAD_DLL_FN (library, rsvg_handle_get_dimensions); 9608 LOAD_DLL_FN (library, rsvg_handle_get_dimensions);
@@ -9742,6 +9746,44 @@ svg_load (struct frame *f, struct image *img)
9742 return success_p; 9746 return success_p;
9743} 9747}
9744 9748
9749static double
9750svg_css_length_to_pixels (RsvgLength length)
9751{
9752 /* FIXME: 96 appears to be a pretty standard DPI but we should
9753 probably use the real DPI if we can get it. */
9754 double dpi = 96;
9755 double value = length.length;
9756
9757 switch (length.unit)
9758 {
9759 case RSVG_UNIT_PX:
9760 /* Already a pixel value. */
9761 break;
9762 case RSVG_UNIT_CM:
9763 /* 2.54 cm in an inch. */
9764 value = dpi * value / 2.54;
9765 case RSVG_UNIT_MM:
9766 /* 25.4 mm in an inch. */
9767 value = dpi * value / 25.4;
9768 break;
9769 case RSVG_UNIT_PT:
9770 /* 72 points in an inch. */
9771 value = dpi * value / 72;
9772 case RSVG_UNIT_PC:
9773 /* 6 picas in an inch. */
9774 value = dpi * value / 6;
9775 case RSVG_UNIT_IN:
9776 value *= dpi;
9777 break;
9778 default:
9779 /* Probably one of em, ex, or %. We can't know what the pixel
9780 value is without more information. */
9781 value = 0;
9782 }
9783
9784 return value;
9785}
9786
9745/* Load frame F and image IMG. CONTENTS contains the SVG XML data to 9787/* Load frame F and image IMG. CONTENTS contains the SVG XML data to
9746 be parsed, SIZE is its size, and FILENAME is the name of the SVG 9788 be parsed, SIZE is its size, and FILENAME is the name of the SVG
9747 file being loaded. 9789 file being loaded.
@@ -9810,11 +9852,48 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9810#if LIBRSVG_CHECK_VERSION (2, 46, 0) 9852#if LIBRSVG_CHECK_VERSION (2, 46, 0)
9811 RsvgRectangle zero_rect, viewbox, out_logical_rect; 9853 RsvgRectangle zero_rect, viewbox, out_logical_rect;
9812 9854
9813 rsvg_handle_get_geometry_for_layer (rsvg_handle, NULL, 9855 /* Try the instrinsic dimensions first. */
9814 &zero_rect, &viewbox, 9856 gboolean has_width, has_height, has_viewbox;
9815 &out_logical_rect, NULL); 9857 RsvgLength iwidth, iheight;
9816 viewbox_width = viewbox.x + viewbox.width; 9858
9817 viewbox_height = viewbox.y + viewbox.height; 9859 rsvg_handle_get_intrinsic_dimensions (rsvg_handle,
9860 &has_width, &iwidth,
9861 &has_height, &iheight,
9862 &has_viewbox, &viewbox);
9863
9864 if (has_width && has_height)
9865 {
9866 /* Success! We can use these values directly. */
9867 viewbox_width = svg_css_length_to_pixels (iwidth);
9868 viewbox_height = svg_css_length_to_pixels (iheight);
9869 }
9870 else if (has_width && has_viewbox)
9871 {
9872 viewbox_width = svg_css_length_to_pixels (iwidth);
9873 viewbox_height = svg_css_length_to_pixels (iwidth)
9874 * viewbox.width / viewbox.height;
9875 }
9876 else if (has_height && has_viewbox)
9877 {
9878 viewbox_height = svg_css_length_to_pixels (iheight);
9879 viewbox_width = svg_css_length_to_pixels (iheight)
9880 * viewbox.height / viewbox.width;
9881 }
9882 else if (has_viewbox)
9883 {
9884 viewbox_width = viewbox.width;
9885 viewbox_height = viewbox.height;
9886 }
9887 else
9888 {
9889 /* We haven't found a useable set of sizes, so try working out
9890 the visible area. */
9891 rsvg_handle_get_geometry_for_layer (rsvg_handle, NULL,
9892 &zero_rect, &viewbox,
9893 &out_logical_rect, NULL);
9894 viewbox_width = viewbox.x + viewbox.width;
9895 viewbox_height = viewbox.y + viewbox.height;
9896 }
9818#else 9897#else
9819 /* The function used above to get the geometry of the visible area 9898 /* The function used above to get the geometry of the visible area
9820 of the SVG are only available in librsvg 2.46 and above, so in 9899 of the SVG are only available in librsvg 2.46 and above, so in
@@ -9827,6 +9906,19 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9827 viewbox_width = dimension_data.width; 9906 viewbox_width = dimension_data.width;
9828 viewbox_height = dimension_data.height; 9907 viewbox_height = dimension_data.height;
9829#endif 9908#endif
9909
9910 if (viewbox_width == 0 || viewbox_height == 0)
9911 {
9912 /* We do not have any usable dimensions, so make some up. The
9913 values below are supposedly the default values most web
9914 browsers use for SVGs with no set size. */
9915 /* FIXME: At this stage we should perhaps consider rendering the
9916 image out to a bitmap and getting the dimensions from
9917 that. */
9918 viewbox_width = 300;
9919 viewbox_height = 150;
9920 }
9921
9830 compute_image_size (viewbox_width, viewbox_height, img->spec, 9922 compute_image_size (viewbox_width, viewbox_height, img->spec,
9831 &width, &height); 9923 &width, &height);
9832 9924
diff --git a/src/nsterm.m b/src/nsterm.m
index fa38350a2f6..4fad521b74c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1782,6 +1782,8 @@ ns_destroy_window (struct frame *f)
1782{ 1782{
1783 NSTRACE ("ns_destroy_window"); 1783 NSTRACE ("ns_destroy_window");
1784 1784
1785 check_window_system (f);
1786
1785 /* If this frame has a parent window, detach it as not doing so can 1787 /* If this frame has a parent window, detach it as not doing so can
1786 cause a crash in GNUStep. */ 1788 cause a crash in GNUStep. */
1787 if (FRAME_PARENT_FRAME (f) != NULL) 1789 if (FRAME_PARENT_FRAME (f) != NULL)
@@ -1792,7 +1794,7 @@ ns_destroy_window (struct frame *f)
1792 [parent removeChildWindow: child]; 1794 [parent removeChildWindow: child];
1793 } 1795 }
1794 1796
1795 check_window_system (f); 1797 [[FRAME_NS_VIEW (f) window] close];
1796 ns_free_frame_resources (f); 1798 ns_free_frame_resources (f);
1797 ns_window_num--; 1799 ns_window_num--;
1798} 1800}
diff --git a/src/xwidget.c b/src/xwidget.c
index 031975fafb9..e078a28a35b 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -128,6 +128,16 @@ Returns the newly constructed xwidget, or nil if construction fails. */)
128 if (EQ (xw->type, Qwebkit)) 128 if (EQ (xw->type, Qwebkit))
129 { 129 {
130 xw->widget_osr = webkit_web_view_new (); 130 xw->widget_osr = webkit_web_view_new ();
131
132 /* webkitgtk uses GSubprocess which sets sigaction causing
133 Emacs to not catch SIGCHLD with its usual handle setup in
134 catch_child_signal(). This resets the SIGCHLD
135 sigaction. */
136 struct sigaction old_action;
137 sigaction (SIGCHLD, NULL, &old_action);
138 webkit_web_view_load_uri(WEBKIT_WEB_VIEW (xw->widget_osr),
139 "about:blank");
140 sigaction (SIGCHLD, &old_action, NULL);
131 } 141 }
132 142
133 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, 143 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width,