[evolution/wip/mcrha/webkit-jsc-api] e-editor.js: Change bgColor style lookup



commit 49092aa4b574a387214c1a596686b48977d473c2
Author: Milan Crha <mcrha redhat com>
Date:   Thu Nov 7 14:57:14 2019 +0100

    e-editor.js: Change bgColor style lookup

 data/webkit/e-editor.js | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 94157534fa..413a6e4a18 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -141,13 +141,6 @@ EvoEditor.maybeUpdateFormattingState = function(force)
                nchanges++;
        }
 
-       value = computedStyle ? computedStyle.backgroundColor : "";
-       if (value != EvoEditor.formattingState.bgColor) {
-               EvoEditor.formattingState.bgColor = value;
-               changes["bgColor"] = value;
-               nchanges++;
-       }
-
        tmp = (computedStyle ? computedStyle.textAlign : "").toLowerCase();
        if (tmp == "")
                value = EvoEditor.E_CONTENT_EDITOR_ALIGNMENT_NONE;
@@ -200,11 +193,12 @@ EvoEditor.maybeUpdateFormattingState = function(force)
                script : 0,
                blockFormat : null,
                fontSize : null,
-               indented : null
+               indented : null,
+               bgColor : null
        };
 
-       for (parent = baseElem; parent && !(parent == document.body) &&
-            obj.script == 0 && obj.blockFormat == null && obj.fontSize == null && obj.indented == null;
+       for (parent = baseElem; parent && !(parent == document.body) && (
+            obj.script == 0 || obj.blockFormat == null || obj.fontSize == null || obj.indented == null 
||obj.bgColor == null);
             parent = parent.parentElement) {
                if (obj.script == 0) {
                        if (parent.tagName == "SUB")
@@ -275,6 +269,10 @@ EvoEditor.maybeUpdateFormattingState = function(force)
                                obj.indented = tmp > 0;
                        }
                }
+
+               if (obj.bgColor == null && parent.style.backgroundColor != "") {
+                       obj.bgColor = parent.style.backgroundColor;
+               }
        }
 
        value = obj.script;
@@ -305,6 +303,13 @@ EvoEditor.maybeUpdateFormattingState = function(force)
                nchanges++;
        }
 
+       value = obj.bgColor ? obj.bgColor : computedStyle.backgroundColor;
+       if (value != EvoEditor.formattingState.bgColor) {
+               EvoEditor.formattingState.bgColor = value;
+               changes["bgColor"] = value;
+               nchanges++;
+       }
+
        if (nchanges > 0)
                window.webkit.messageHandlers.formattingChanged.postMessage(changes);
 }


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