Jacek Caban : mshtml: Fixed hr element handling in range object.

Alexandre Julliard julliard at winehq.org
Fri Jan 11 07:20:29 CST 2008


Module: wine
Branch: master
Commit: 0bc9f9a7d542e87199a462e3f9a834bd14ef17ca
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0bc9f9a7d542e87199a462e3f9a834bd14ef17ca

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Jan 10 23:51:25 2008 +0100

mshtml: Fixed hr element handling in range object.

---

 dlls/mshtml/txtrange.c |   41 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/dlls/mshtml/txtrange.c b/dlls/mshtml/txtrange.c
index 31e0791..bd398b9 100644
--- a/dlls/mshtml/txtrange.c
+++ b/dlls/mshtml/txtrange.c
@@ -38,6 +38,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
 static const WCHAR brW[] = {'b','r',0};
+static const WCHAR hrW[] = {'h','r',0};
 
 typedef struct {
     const IHTMLTxtRangeVtbl *lpHTMLTxtRangeVtbl;
@@ -132,7 +133,7 @@ static PRUint16 get_node_type(nsIDOMNode *node)
     return type;
 }
 
-static BOOL is_br_node(nsIDOMNode *node)
+static BOOL is_elem_tag(nsIDOMNode *node, LPCWSTR istag)
 {
     nsIDOMElement *elem;
     nsAString tag_str;
@@ -149,8 +150,31 @@ static BOOL is_br_node(nsIDOMNode *node)
     nsIDOMElement_Release(elem);
     nsAString_GetData(&tag_str, &tag);
 
-    if(!strcmpiW(tag, brW))
-        ret = TRUE;
+    ret = !strcmpiW(tag, istag);
+
+    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);
 
@@ -242,9 +266,12 @@ static void wstrbuf_append_node(wstrbuf_t *buf, nsIDOMNode *node)
         break;
     }
     case ELEMENT_NODE:
-        if(is_br_node(node)) {
+        if(is_elem_tag(node, brW)) {
             static const WCHAR endlW[] = {'\r','\n'};
             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:
         return pos->p[pos->off];
     case ELEMENT_NODE:
-        if(is_br_node(pos->node))
+        if(is_space_elem(pos->node))
             return '\n';
     }
 
@@ -634,7 +661,7 @@ static WCHAR next_char(const dompos_t *pos, dompos_t *new_pos)
             return *p;
 
         case ELEMENT_NODE:
-            if(!is_br_node(iter))
+            if(!is_space_elem(iter))
                 break;
 
             if(cspace)
@@ -718,7 +745,7 @@ static WCHAR prev_char(HTMLTxtRange *This, const dompos_t *pos, dompos_t *new_po
         }
 
         case ELEMENT_NODE:
-            if(!is_br_node(iter))
+            if(!is_space_elem(iter))
                 break;
 
             if(skip_space) {




More information about the wine-cvs mailing list