From 617c559accc02deb3e956b592dc22d7891e28369 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 11 Apr 2017 11:25:14 +0100 Subject: Client API: Various changes due to new thinking about responsibilities. --- include/libnslayout/nslayout.h | 76 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/include/libnslayout/nslayout.h b/include/libnslayout/nslayout.h index b486cba..62ce584 100644 --- a/include/libnslayout/nslayout.h +++ b/include/libnslayout/nslayout.h @@ -22,8 +22,8 @@ extern "C" #include -/** An opaque client-owned replaced element */ -typedef void nslayout_replaced; +/** A client-defined replaced element structure */ +typedef struct nslayout_replaced nslayout_replaced; /** A rectangle */ typedef struct nslayout_rect { @@ -33,15 +33,25 @@ typedef struct nslayout_rect { int h; /**< Height of rect in px */ } nslayout_rect; +/***/ +enum nslayout_dom_node_event_type { + NSLAYOUT_DOM_NODE_INSERTED, + NSLAYOUT_DOM_NODE_MODIFIED, + NSLAYOUT_DOM_NODE_REMOVED, + NSLAYOUT_DOM_NODE__COUNT, +}; + /** Render list */ typedef struct nslayout_render_list { } nslayout_render_list; -/** Render list */ +/** Opaque layout tree object */ typedef struct nslayout_layout nslayout_layout; + /** * A LibNSLayout request + * Client calls to set replaced element intrinsic dimensions. * * Passed to the client via nslayout_callback */ @@ -49,7 +59,6 @@ typedef struct nslayout_request { /** Request type */ enum { NSLAYOUT_GET_RESOURCE, - NSLAYOUT_CREATE_REPLACED, NSLAYOUT_RENDER, NSLAYOUT_SET_EXTENTS, NSLAYOUT_GET_INTRINSIC_SIZE @@ -59,9 +68,6 @@ typedef struct nslayout_request { struct { const char *url; /**< Absolute URL */ } get_resource; - struct { - dom_element *element; /**< DOM element */ - } create_replaced; struct { nslayout_render_list *list; /**< Render list */ } render; @@ -78,9 +84,6 @@ typedef struct nslayout_request { struct { nslayout_replaced **replaced; /** Replacement object */ } get_resource; - struct { - nslayout_replaced **replaced; /** Replacement object */ - } create_replaced; struct { unsigned int *width; /** Replacement object's width */ unsigned int *height; /** Replacement object's height */ @@ -89,6 +92,59 @@ typedef struct nslayout_request { } nslayout_request; +/** + * Client calls for DOM tree change events. + * + * \param[in] layout The layout requiring update for DOM change. + * \param[in] node The DOM node which is concerned in the event. + * \param[in] type The type of DOM change event. + * \return NSLAYOUT_OK on success, appropriate error otherwise. + */ +nslayout_error nslayout_dom_node_event( + nslayout_layout *layout, + dom_event_target *node, + enum nslayout_dom_node_event_type type); + +/** + * Client calls to set node as client-replaced. + * + * \param[in] layout The layout to replace an element in. + * \param[in] node The DOM node which is to be replaced. + * \param[in] replaced The client's replacement object to register with node. + * \return NSLAYOUT_OK on success, appropriate error otherwise. + */ +nslayout_error nslayout_node_event_set_replaced( + nslayout_layout *layout, + dom_event_target *node, + nslayout_replaced *replaced); + + +/** + * Client calls to set replaced element intrinsic dimensions. + * + * \param[in] layout The layout to replace an element in. + * \param[in] node The DOM node which is to be replaced. + * \param[in] width Width in pixels. + * \param[in] height Height in pixels. + * \return NSLAYOUT_OK on success, appropriate error otherwise. + */ +nslayout_error nslayout_node_event_set_intrinsic_dimensions( + nslayout_layout *layout, + dom_event_target *node, + unsigned int width, + unsigned int height); + + +/** + * Client calls to tell NSLayout that everything requires reselection. + * + * \param[in]layout The layout to who's selection context has changed. + * \return NSLAYOUT_OK on success, appropriate error otherwise. + */ +nslayout_error nslayout_selection_context_updated( + nslayout_layout *layout); + + /** * Initialise LibNSLayout * -- cgit v1.2.3