Commit c0a6d2d4 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Introduce helper to transfer node ownership to range points when AddRef isn't needed.

parent cc3f61e7
......@@ -174,15 +174,19 @@ static int get_child_index(nsIDOMNode *parent, nsIDOMNode *child)
return ret;
}
static void init_rangepoint(rangepoint_t *rangepoint, nsIDOMNode *node, UINT32 off)
static void init_rangepoint_no_addref(rangepoint_t *rangepoint, nsIDOMNode *node, UINT32 off)
{
nsIDOMNode_AddRef(node);
rangepoint->type = get_node_type(node);
rangepoint->node = node;
rangepoint->off = off;
}
static void init_rangepoint(rangepoint_t *rangepoint, nsIDOMNode *node, UINT32 off)
{
nsIDOMNode_AddRef(node);
init_rangepoint_no_addref(rangepoint, node, off);
}
static inline void free_rangepoint(rangepoint_t *rangepoint)
{
nsIDOMNode_Release(rangepoint->node);
......@@ -203,8 +207,7 @@ static BOOL rangepoint_next_node(rangepoint_t *iter)
node = get_child_node(iter->node, iter->off);
if(node) {
free_rangepoint(iter);
init_rangepoint(iter, node, 0);
nsIDOMNode_Release(node);
init_rangepoint_no_addref(iter, node, 0);
return TRUE;
}
......@@ -216,8 +219,7 @@ static BOOL rangepoint_next_node(rangepoint_t *iter)
off = get_child_index(node, iter->node)+1;
free_rangepoint(iter);
init_rangepoint(iter, node, off);
nsIDOMNode_Release(node);
init_rangepoint_no_addref(iter, node, off);
return TRUE;
}
......@@ -266,8 +268,7 @@ static BOOL rangepoint_prev_node(rangepoint_t *iter)
off = get_node_type(node) == TEXT_NODE ? get_text_length(node) : get_child_count(node);
free_rangepoint(iter);
init_rangepoint(iter, node, off);
nsIDOMNode_Release(node);
init_rangepoint_no_addref(iter, node, off);
return TRUE;
}
......@@ -291,9 +292,7 @@ static void get_start_point(HTMLTxtRange *This, rangepoint_t *ret)
nsIDOMRange_GetStartContainer(This->nsrange, &node);
nsIDOMRange_GetStartOffset(This->nsrange, &off);
init_rangepoint(ret, node, off);
nsIDOMNode_Release(node);
init_rangepoint_no_addref(ret, node, off);
}
static void get_end_point(HTMLTxtRange *This, rangepoint_t *ret)
......@@ -304,9 +303,7 @@ static void get_end_point(HTMLTxtRange *This, rangepoint_t *ret)
nsIDOMRange_GetEndContainer(This->nsrange, &node);
nsIDOMRange_GetEndOffset(This->nsrange, &off);
init_rangepoint(ret, node, off);
nsIDOMNode_Release(node);
init_rangepoint_no_addref(ret, node, off);
}
static void set_start_point(HTMLTxtRange *This, const rangepoint_t *start)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment