forked from sailfishos/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1789967 - part 3: Make `HTMLEditor::CollapseSelectionToEndOfLastL…
…eafNodeOfDocument` and `HTMLEditor::InitEditorContentAndSelection` do nothing if the document is partially editable r=m_kato They and their callees work with the result of `GetRoot()` which is the document element or the body element. If the body is not editable, `Selection` should not be updated in non-editable region nor `<br>` elements should not be inserted in both non-focused editable elements and non-editable elements. Therefore, they should run only when the document element or the `<body>` element is editable. To keep testing crashtests as reported, this patch makes tests which have `contenteditable` except `<html>` and `<body>` initialize `Selection` as what we've done. And clean up the tests for helping to port them to WPT in the future (bug 1725850). Differential Revision: https://phabricator.services.mozilla.com/D157408
- Loading branch information
1 parent
b1f3f5e
commit a353ab7
Showing
63 changed files
with
1,005 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
<body> | ||
<table contenteditable="true"></table> | ||
<table contenteditable></table> | ||
</body> | ||
<script> | ||
window.onload = function() { | ||
document.execCommand("useCSS", false, false); | ||
document.designMode = 'on'; | ||
document.execCommand("insertunorderedlist", false); | ||
document.execCommand("justifyfull", false); | ||
// For emulating the traditional behavior, collapse Selection to end of the | ||
// <body>, i.e., at the text node after the <table>. | ||
getSelection().collapse(document.body, document.body.childNodes.length); | ||
document.execCommand("styleWithCSS", false, false); | ||
document.designMode = "on"; | ||
document.execCommand("insertUnorderedList"); | ||
document.execCommand("justifyFull"); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,60 @@ | ||
<html> | ||
<head> | ||
<script> | ||
try { o1 = document.createElement('style'); } catch(e) { } | ||
try { o2 = document.createElement('output') } catch(e) { } | ||
try { o3 = document.createElement('input') } catch(e) { } | ||
try { o4 = document.createElement('script'); } catch(e) { } | ||
try { o5 = o2.cloneNode(false); } catch(e) { } | ||
try { document.documentElement.appendChild(o1) } catch(e) { } | ||
try { o1.outerHTML = '<a contenteditable=\'true\'>'; } catch(e) { } | ||
try { document.documentElement.appendChild(o3) } catch(e) { } | ||
try { o7 = document.createTextNode(' '); } catch(e) { } | ||
try { o4.appendChild(o7) } catch(e) { } | ||
try { document.documentElement.appendChild(o4) } catch(e) { } | ||
try { o6 = window.getSelection() } catch(e) { } | ||
try { o3.select() } catch(e) { } | ||
try { document.replaceChild(document.documentElement, document.documentElement); } catch(e) { } | ||
try { o6.setBaseAndExtent(o7, 0, o5, 0) } catch(e) { } | ||
try { document.designMode = 'on'; } catch(e) { } | ||
try { document.execCommand('insertimage', false, 'http://localhost/') } catch(e) { } | ||
</script> | ||
</head> | ||
<head> | ||
<script> | ||
try { | ||
var style = document.createElement("style"); | ||
} catch(e) {} | ||
try { | ||
var output = document.createElement("output"); | ||
} catch(e) {} | ||
try { | ||
var input = document.createElement("input"); | ||
} catch(e) {} | ||
try { | ||
var script = document.createElement("script"); | ||
} catch(e) {} | ||
try { | ||
var clonedOutput = output.cloneNode(false); | ||
} catch(e) {} | ||
try { | ||
document.documentElement.appendChild(style); | ||
} catch(e) {} | ||
try { | ||
style.outerHTML = '<a contenteditable="true">'; | ||
} catch(e) {} | ||
// For emulating the traditional behavior, collapse Selection to end of the | ||
// <body> which must be empty (<style> was added after the <body>). | ||
getSelection().collapse(document.body, document.body.childNodes.length); | ||
try { | ||
document.documentElement.appendChild(input); | ||
} catch(e) {} | ||
try { | ||
var text = document.createTextNode(" "); | ||
} catch(e) {} | ||
try { | ||
script.appendChild(text); | ||
} catch(e) {} | ||
try { | ||
document.documentElement.appendChild(script); | ||
} catch(e) {} | ||
try { | ||
var selection = getSelection(); | ||
} catch(e) {} | ||
try { | ||
input.select(); | ||
} catch(e) {} | ||
try { | ||
document.replaceChild(document.documentElement, document.documentElement); | ||
} catch(e) {} | ||
try { | ||
selection.setBaseAndExtent(text, 0, clonedOutput, 0); | ||
} catch(e) {} | ||
try { | ||
document.designMode = "on"; | ||
} catch(e) {} | ||
try { | ||
document.execCommand("insertImage", false, "http://localhost/"); | ||
} catch(e) {} | ||
</script> | ||
</head> | ||
</html> |
Oops, something went wrong.