Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ingest https://codereview.appspot.com/6814085/

Import of https://codereview.appspot.com/6826076/



Revision created by MOE tool push_codebase.

R=nnaze
DELTA=35  (23 added, 3 deleted, 9 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=5797


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2289 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
commit a2a622c77c808220df662132c1f231e3a0af4f38 1 parent a29d653
nicksantos@google.com authored
View
5 closure/goog/editor/field.js
@@ -1018,7 +1018,10 @@ goog.editor.Field.MUTATION_EVENTS_GECKO = [
* @protected
*/
goog.editor.Field.prototype.setupMutationEventHandlersGecko = function() {
- if (goog.editor.BrowserFeature.HAS_DOM_SUBTREE_MODIFIED_EVENT) {
+ // Always use DOMSubtreeModified on Gecko when not using an iframe so that
+ // DOM mutations outside the Field do not trigger handleMutationEventGecko_.
+ if (goog.editor.BrowserFeature.HAS_DOM_SUBTREE_MODIFIED_EVENT ||
+ !this.usesIframe()) {
this.eventRegister.listen(this.getElement(), 'DOMSubtreeModified',
this.handleMutationEventGecko_);
} else {
View
19 closure/goog/editor/plugins/removeformatting.js
@@ -185,9 +185,16 @@ goog.editor.plugins.RemoveFormatting.prototype.removeFormatting_ = function() {
* @return {Node} The table, or null if one was not found.
* @private
*/
-goog.editor.plugins.RemoveFormatting.getTableAncestor_ = function(nodeToCheck) {
- return goog.dom.getAncestor(nodeToCheck,
- function(node) { return node.tagName == goog.dom.TagName.TABLE; }, true);
+goog.editor.plugins.RemoveFormatting.prototype.getTableAncestor_ = function(
+ nodeToCheck) {
+ var fieldElement = this.getFieldObject().getElement();
+ while (nodeToCheck && nodeToCheck != fieldElement) {
+ if (nodeToCheck.tagName == goog.dom.TagName.TABLE) {
+ return nodeToCheck;
+ }
+ nodeToCheck = nodeToCheck.parentNode;
+ }
+ return null;
};
@@ -495,10 +502,8 @@ goog.editor.plugins.RemoveFormatting.prototype.convertSelectedHtmlText_ =
var expandedRange = goog.editor.range.expand(range,
this.getFieldObject().getElement());
- var startInTable = goog.editor.plugins.RemoveFormatting.getTableAncestor_(
- expandedRange.getStartNode());
- var endInTable = goog.editor.plugins.RemoveFormatting.getTableAncestor_(
- expandedRange.getEndNode());
+ var startInTable = this.getTableAncestor_(expandedRange.getStartNode());
+ var endInTable = this.getTableAncestor_(expandedRange.getEndNode());
if (startInTable || endInTable) {
if (startInTable == endInTable) {
View
20 closure/goog/editor/plugins/removeformatting_test.html
@@ -32,7 +32,17 @@
</head>
<body>
+<!--
+This wrapper table is outside the mock editor and only used ensure that it is
+ignored by the tests.
+-->
+<table>
+<tr>
+<td>
<div id="html"></div>
+</td>
+</tr>
+</table>
<div id="abcde">abcde</div>
@@ -851,16 +861,18 @@
div.innerHTML = "foo<table><tr><td>foo</td></tr></table>bar";
assertTrue('Full table is in table',
- !!goog.editor.plugins.RemoveFormatting.getTableAncestor_(
- div.childNodes[1]));
+ !!FORMATTER.getTableAncestor_(div.childNodes[1]));
assertFalse('Outside of table',
- !!goog.editor.plugins.RemoveFormatting.getTableAncestor_(div.firstChild));
+ !!FORMATTER.getTableAncestor_(div.firstChild));
assertTrue('Table cell is in table',
- !!goog.editor.plugins.RemoveFormatting.getTableAncestor_(
+ !!FORMATTER.getTableAncestor_(
div.childNodes[1].firstChild.firstChild.firstChild));
+ div.innerHTML = "foo";
+ assertNull('No table inside field.',
+ FORMATTER.getTableAncestor_(div.childNodes[0]));
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.