[evolution/wip/mcrha/webkit-jsc-api] e-editor.js: Slightly optimalize Font Name change to the Default value



commit dffa6ccb2e29e41b0573b9b4251dedb11d3cea2a
Author: Milan Crha <mcrha redhat com>
Date:   Mon Apr 27 09:58:42 2020 +0200

    e-editor.js: Slightly optimalize Font Name change to the Default value

 data/webkit/e-editor.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 924bc25779..9054f8f1c5 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -2254,11 +2254,12 @@ EvoEditor.applyFontReset = function(record, isUndo)
        }
 }
 
-EvoEditor.replaceInheritFonts = function(undoRedoRecord, selectionUpdater)
+EvoEditor.replaceInheritFonts = function(undoRedoRecord, selectionUpdater, nodes)
 {
-       var nodes, ii;
+       var ii;
 
-       nodes = document.querySelectorAll("FONT[face=inherit]");
+       if (!nodes)
+               nodes = document.querySelectorAll("FONT[face=inherit]");
 
        for (ii = nodes.length - 1; ii >= 0; ii--) {
                var node = nodes.item(ii);
@@ -2296,7 +2297,7 @@ EvoEditor.replaceInheritFonts = function(undoRedoRecord, selectionUpdater)
                                selectionUpdater.afterRemove(child);
                        }
 
-                       parent.removeChild(node);
+                       node.remove();
                } else {
                        node.removeAttribute("face");
                }
@@ -2311,7 +2312,9 @@ EvoEditor.replaceInheritFonts = function(undoRedoRecord, selectionUpdater)
 
 EvoEditor.maybeReplaceInheritFonts = function()
 {
-       if (document.querySelectorAll("FONT[face=inherit]").length <= 0)
+       var nodes = document.querySelectorAll("FONT[face=inherit]");
+
+       if (nodes.length <= 0)
                return;
 
        var record, selectionUpdater;
@@ -2320,7 +2323,7 @@ EvoEditor.maybeReplaceInheritFonts = function()
 
        record = EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "UnsetFontName", null, null, 
EvoEditor.CLAIM_CONTENT_FLAG_NONE);
        try {
-               EvoEditor.replaceInheritFonts(record, selectionUpdater);
+               EvoEditor.replaceInheritFonts(record, selectionUpdater, nodes);
 
                selectionUpdater.restore();
        } finally {


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