forked from Mirrors/wine-wine
mshtml: Fixed hr element handling in range object.
parent
8c686f9d00
commit
0bc9f9a7d5
|
@ -38,6 +38,7 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
||||||
|
|
||||||
static const WCHAR brW[] = {'b','r',0};
|
static const WCHAR brW[] = {'b','r',0};
|
||||||
|
static const WCHAR hrW[] = {'h','r',0};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const IHTMLTxtRangeVtbl *lpHTMLTxtRangeVtbl;
|
const IHTMLTxtRangeVtbl *lpHTMLTxtRangeVtbl;
|
||||||
|
@ -132,7 +133,7 @@ static PRUint16 get_node_type(nsIDOMNode *node)
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL is_br_node(nsIDOMNode *node)
|
static BOOL is_elem_tag(nsIDOMNode *node, LPCWSTR istag)
|
||||||
{
|
{
|
||||||
nsIDOMElement *elem;
|
nsIDOMElement *elem;
|
||||||
nsAString tag_str;
|
nsAString tag_str;
|
||||||
|
@ -149,8 +150,31 @@ static BOOL is_br_node(nsIDOMNode *node)
|
||||||
nsIDOMElement_Release(elem);
|
nsIDOMElement_Release(elem);
|
||||||
nsAString_GetData(&tag_str, &tag);
|
nsAString_GetData(&tag_str, &tag);
|
||||||
|
|
||||||
if(!strcmpiW(tag, brW))
|
ret = !strcmpiW(tag, istag);
|
||||||
ret = TRUE;
|
|
||||||
|
nsAString_Finish(&tag_str);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL is_space_elem(nsIDOMNode *node)
|
||||||
|
{
|
||||||
|
nsIDOMElement *elem;
|
||||||
|
nsAString tag_str;
|
||||||
|
const PRUnichar *tag;
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
nsresult nsres;
|
||||||
|
|
||||||
|
nsres = nsIDOMNode_QueryInterface(node, &IID_nsIDOMElement, (void**)&elem);
|
||||||
|
if(NS_FAILED(nsres))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
nsAString_Init(&tag_str, NULL);
|
||||||
|
nsIDOMElement_GetTagName(elem, &tag_str);
|
||||||
|
nsIDOMElement_Release(elem);
|
||||||
|
nsAString_GetData(&tag_str, &tag);
|
||||||
|
|
||||||
|
ret = !strcmpiW(tag, brW) || !strcmpiW(tag, hrW);
|
||||||
|
|
||||||
nsAString_Finish(&tag_str);
|
nsAString_Finish(&tag_str);
|
||||||
|
|
||||||
|
@ -242,9 +266,12 @@ static void wstrbuf_append_node(wstrbuf_t *buf, nsIDOMNode *node)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ELEMENT_NODE:
|
case ELEMENT_NODE:
|
||||||
if(is_br_node(node)) {
|
if(is_elem_tag(node, brW)) {
|
||||||
static const WCHAR endlW[] = {'\r','\n'};
|
static const WCHAR endlW[] = {'\r','\n'};
|
||||||
wstrbuf_append_len(buf, endlW, 2);
|
wstrbuf_append_len(buf, endlW, 2);
|
||||||
|
}else if(is_elem_tag(node, hrW)) {
|
||||||
|
static const WCHAR endl2W[] = {'\r','\n','\r','\n'};
|
||||||
|
wstrbuf_append_len(buf, endl2W, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +551,7 @@ static WCHAR get_pos_char(const dompos_t *pos)
|
||||||
case TEXT_NODE:
|
case TEXT_NODE:
|
||||||
return pos->p[pos->off];
|
return pos->p[pos->off];
|
||||||
case ELEMENT_NODE:
|
case ELEMENT_NODE:
|
||||||
if(is_br_node(pos->node))
|
if(is_space_elem(pos->node))
|
||||||
return '\n';
|
return '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,7 +661,7 @@ static WCHAR next_char(const dompos_t *pos, dompos_t *new_pos)
|
||||||
return *p;
|
return *p;
|
||||||
|
|
||||||
case ELEMENT_NODE:
|
case ELEMENT_NODE:
|
||||||
if(!is_br_node(iter))
|
if(!is_space_elem(iter))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(cspace)
|
if(cspace)
|
||||||
|
@ -718,7 +745,7 @@ static WCHAR prev_char(HTMLTxtRange *This, const dompos_t *pos, dompos_t *new_po
|
||||||
}
|
}
|
||||||
|
|
||||||
case ELEMENT_NODE:
|
case ELEMENT_NODE:
|
||||||
if(!is_br_node(iter))
|
if(!is_space_elem(iter))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(skip_space) {
|
if(skip_space) {
|
||||||
|
|
Loading…
Reference in New Issue