[evolution/wip/webkit-composer: 747/966] Fix detection of font format in HTML mode.



commit 50230f62e1476eeff035a6386a8a0948e3aaad71
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Sep 20 08:29:34 2013 +0200

    Fix detection of font format in HTML mode.

 e-util/e-editor-selection.c |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index a504025..db26f19 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -1766,6 +1766,7 @@ e_editor_selection_is_bold (EEditorSelection *selection)
        WebKitDOMDocument *document;
        WebKitDOMDOMWindow *window;
        WebKitDOMNode *node;
+       WebKitDOMElement *element;
        WebKitDOMRange *range;
 
        g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection), FALSE);
@@ -1791,8 +1792,13 @@ e_editor_selection_is_bold (EEditorSelection *selection)
        }
        g_free (text_content);
 
+       if (WEBKIT_DOM_IS_ELEMENT (node))
+               element = WEBKIT_DOM_ELEMENT (node);
+       else
+               element = webkit_dom_node_get_parent_element (node);
+
        style = webkit_dom_dom_window_get_computed_style (
-                       window, webkit_dom_node_get_parent_element (node), NULL);
+                       window, element, NULL);
        value = webkit_dom_css_style_declaration_get_property_value (style, "font-weight");
 
        if (g_strstr_len (value, -1, "normal"))
@@ -1856,6 +1862,7 @@ e_editor_selection_is_italic (EEditorSelection *selection)
        WebKitDOMDocument *document;
        WebKitDOMDOMWindow *window;
        WebKitDOMNode *node;
+       WebKitDOMElement *element;
        WebKitDOMRange *range;
 
        g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection), FALSE);
@@ -1881,8 +1888,13 @@ e_editor_selection_is_italic (EEditorSelection *selection)
        }
        g_free (text_content);
 
+       if (WEBKIT_DOM_IS_ELEMENT (node))
+               element = WEBKIT_DOM_ELEMENT (node);
+       else
+               element = webkit_dom_node_get_parent_element (node);
+
        style = webkit_dom_dom_window_get_computed_style (
-                       window, webkit_dom_node_get_parent_element (node), NULL);
+                       window, element, NULL);
        value = webkit_dom_css_style_declaration_get_property_value (style, "font-style");
 
        if (g_strstr_len (value, -1, "italic"))
@@ -2189,6 +2201,7 @@ e_editor_selection_is_strike_through (EEditorSelection *selection)
        WebKitDOMDocument *document;
        WebKitDOMDOMWindow *window;
        WebKitDOMNode *node;
+       WebKitDOMElement *element;
        WebKitDOMRange *range;
 
        g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection), FALSE);
@@ -2214,8 +2227,13 @@ e_editor_selection_is_strike_through (EEditorSelection *selection)
        }
        g_free (text_content);
 
+       if (WEBKIT_DOM_IS_ELEMENT (node))
+               element = WEBKIT_DOM_ELEMENT (node);
+       else
+               element = webkit_dom_node_get_parent_element (node);
+
        style = webkit_dom_dom_window_get_computed_style (
-                       window, webkit_dom_node_get_parent_element (node), NULL);
+                       window, element, NULL);
        value = webkit_dom_css_style_declaration_get_property_value (style, "text-decoration");
 
        if (g_strstr_len (value, -1, "line-through"))
@@ -2415,6 +2433,7 @@ e_editor_selection_is_underline (EEditorSelection *selection)
        WebKitDOMDocument *document;
        WebKitDOMDOMWindow *window;
        WebKitDOMNode *node;
+       WebKitDOMElement *element;
        WebKitDOMRange *range;
 
        g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection), FALSE);
@@ -2440,8 +2459,13 @@ e_editor_selection_is_underline (EEditorSelection *selection)
        }
        g_free (text_content);
 
+       if (WEBKIT_DOM_IS_ELEMENT (node))
+               element = WEBKIT_DOM_ELEMENT (node);
+       else
+               element = webkit_dom_node_get_parent_element (node);
+
        style = webkit_dom_dom_window_get_computed_style (
-                       window, webkit_dom_node_get_parent_element (node), NULL);
+                       window, element, NULL);
        value = webkit_dom_css_style_declaration_get_property_value (style, "text-decoration");
 
        if (g_strstr_len (value, -1, "underline"))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]