зеркало из https://github.com/mozilla/gecko-dev.git
Bug 916534 - Find Highlight should work in subframes. r=mikdeboer
This commit is contained in:
Родитель
a75f16d6d4
Коммит
b7a410b816
|
@ -434,28 +434,6 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<!--
|
||||
- For a given node, walk up it's parent chain, to try and find an
|
||||
- editable node.
|
||||
-
|
||||
- @param aNode the node we want to check
|
||||
- @returns the first node in the parent chain that is editable,
|
||||
- null if there is no such node
|
||||
-->
|
||||
<method name="_getEditableNode">
|
||||
<parameter name="aNode"/>
|
||||
<body><![CDATA[
|
||||
while (aNode) {
|
||||
if (aNode instanceof Components.interfaces.nsIDOMNSEditableElement) {
|
||||
return aNode.editor ? aNode : null;
|
||||
}
|
||||
aNode = aNode.parentNode;
|
||||
}
|
||||
return null;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
||||
<!--
|
||||
- Turns highlight on or off.
|
||||
- @param aHighlight (boolean)
|
||||
|
|
|
@ -80,7 +80,11 @@ Finder.prototype = {
|
|||
|
||||
highlight: function (aHighlight, aWord) {
|
||||
this._searchString = aWord;
|
||||
this._highlight(aHighlight, aWord, null);
|
||||
let found = this._highlight(aHighlight, aWord, null);
|
||||
if (found)
|
||||
this._notify(Ci.nsITypeAheadFind.FIND_FOUND, false, false);
|
||||
else
|
||||
this._notify(Ci.nsITypeAheadFind.FIND_NOTFOUND, false, false);
|
||||
},
|
||||
|
||||
removeSelection: function() {
|
||||
|
@ -178,10 +182,10 @@ Finder.prototype = {
|
|||
_highlight: function (aHighlight, aWord, aWindow) {
|
||||
let win = aWindow || this._getWindow();
|
||||
|
||||
let result = Ci.nsITypeAheadFind.FIND_NOTFOUND;
|
||||
let found = false;
|
||||
for (let i = 0; win.frames && i < win.frames.length; i++) {
|
||||
if (this._highlight(aHighlight, aWord, win.frames[i]))
|
||||
result = Ci.nsITypeAheadFind.FIND_FOUND;
|
||||
found = true;
|
||||
}
|
||||
|
||||
let controller = this._getSelectionController(win);
|
||||
|
@ -189,8 +193,7 @@ Finder.prototype = {
|
|||
if (!controller || !doc || !doc.documentElement) {
|
||||
// Without the selection controller,
|
||||
// we are unable to (un)highlight any matches
|
||||
this._notify(result)
|
||||
return;
|
||||
return found;
|
||||
}
|
||||
|
||||
let body = (doc instanceof Ci.nsIDOMHTMLDocument && doc.body) ?
|
||||
|
@ -219,7 +222,7 @@ Finder.prototype = {
|
|||
startPt = retRange.cloneRange();
|
||||
startPt.collapse(false);
|
||||
|
||||
result = Ci.nsITypeAheadFind.FIND_FOUND;
|
||||
found = true;
|
||||
}
|
||||
} else {
|
||||
// First, attempt to remove highlighting from main document
|
||||
|
@ -239,10 +242,12 @@ Finder.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
//Removing the highlighting always succeeds, so return true.
|
||||
found = true;
|
||||
}
|
||||
|
||||
this._notify(result);
|
||||
return found;
|
||||
},
|
||||
|
||||
_highlightRange: function(aRange, aController) {
|
||||
|
@ -291,6 +296,14 @@ Finder.prototype = {
|
|||
return controller;
|
||||
},
|
||||
|
||||
/*
|
||||
* For a given node, walk up it's parent chain, to try and find an
|
||||
* editable node.
|
||||
*
|
||||
* @param aNode the node we want to check
|
||||
* @returns the first node in the parent chain that is editable,
|
||||
* null if there is no such node
|
||||
*/
|
||||
_getEditableNode: function (aNode) {
|
||||
while (aNode) {
|
||||
if (aNode instanceof Ci.nsIDOMNSEditableElement)
|
||||
|
|
Загрузка…
Ссылка в новой задаче