[evolution/wip/webkit2] EHTMLEditorSelection - Alignment could be wrong
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] EHTMLEditorSelection - Alignment could be wrong
- Date: Fri, 26 Feb 2016 07:47:11 +0000 (UTC)
commit 8a941726a17fba5dfb01cafa6bcdca811d400ff2
Author: Tomas Popela <tpopela redhat com>
Date: Fri Feb 26 08:46:55 2016 +0100
EHTMLEditorSelection - Alignment could be wrong
.../e-html-editor-selection-dom-functions.c | 29 +++++++++++++++----
1 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/web-extensions/composer/e-html-editor-selection-dom-functions.c
b/web-extensions/composer/e-html-editor-selection-dom-functions.c
index 8f2efdf..ba530b3 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.c
@@ -5181,6 +5181,7 @@ dom_selection_set_block_format (WebKitDOMDocument *document,
EHTMLEditorSelectionBlockFormat format)
{
EHTMLEditorSelectionBlockFormat current_format;
+ EHTMLEditorSelectionAlignment current_alignment;
EHTMLEditorUndoRedoManager *manager;
EHTMLEditorHistoryEvent *ev = NULL;
const gchar *value;
@@ -5253,6 +5254,8 @@ dom_selection_set_block_format (WebKitDOMDocument *document,
if (!range)
return;
+ current_alignment = e_html_editor_web_extension_get_alignment (extension);
+
dom_selection_save (document);
manager = e_html_editor_web_extension_get_undo_redo_manager (extension);
@@ -5337,8 +5340,7 @@ dom_selection_set_block_format (WebKitDOMDocument *document,
dom_force_spell_check_for_current_paragraph (document, extension);
/* When changing the format we need to re-set the alignment */
- dom_selection_set_alignment (
- document, extension, e_html_editor_web_extension_get_alignment (extension));
+ dom_selection_set_alignment (document, extension, current_alignment);
e_html_editor_web_extension_set_content_changed (extension);
@@ -5428,19 +5430,31 @@ dom_selection_get_alignment (WebKitDOMDocument *document,
WebKitDOMRange *range;
range = dom_get_current_range (document);
- if (!range)
- return E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT;
+ if (!range) {
+ alignment = E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT;
+ goto out;
+ }
node = webkit_dom_range_get_start_container (range, NULL);
g_object_unref (range);
- if (!node)
- return E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT;
+ if (!node) {
+ alignment = E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT;
+ goto out;
+ }
if (WEBKIT_DOM_IS_ELEMENT (node))
element = WEBKIT_DOM_ELEMENT (node);
else
element = webkit_dom_node_get_parent_element (node);
+ if (element_has_class (element, "-x-evo-align-right")) {
+ alignment = E_HTML_EDITOR_SELECTION_ALIGNMENT_RIGHT;
+ goto out;
+ } else if (element_has_class (element, "-x-evo-align-center")) {
+ alignment = E_HTML_EDITOR_SELECTION_ALIGNMENT_CENTER;
+ goto out;
+ }
+
style = webkit_dom_element_get_style (element);
value = webkit_dom_css_style_declaration_get_property_value (style, "text-align");
@@ -5458,6 +5472,9 @@ dom_selection_get_alignment (WebKitDOMDocument *document,
g_object_unref (style);
g_free (value);
+ out:
+ set_dbus_property_unsigned (extension, "Alignment", alignment);
+
return alignment;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]