зеркало из https://github.com/mozilla/gecko-dev.git
Bug 263049. Hack nsTypeAheadFind to search XMLPrettyPrinter's pretty-printed DOM when the root node has an XBL binding. r=mrbkap
--HG-- extra : rebase_source : 33bfe389b08dfb76964eb986f13ee7b93a2f0f54
This commit is contained in:
Родитель
139b358c46
Коммит
3fa85fd10e
|
@ -51,6 +51,7 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Link.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsXBLBinding.h"
|
||||
|
||||
#include "nsTypeAheadFind.h"
|
||||
|
||||
|
@ -746,19 +747,36 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
|
|||
if (!rootNode)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
uint32_t childCount = rootContent->GetChildCount();
|
||||
|
||||
if (!mSearchRange) {
|
||||
mSearchRange = new nsRange(rootContent);
|
||||
mSearchRange = new nsRange(doc);
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> searchRootNode = rootNode;
|
||||
|
||||
// Hack for XMLPrettyPrinter. nsFind can't handle complex anonymous content.
|
||||
// If the root node has an XBL binding then there's not much we can do in
|
||||
// in general, but we can try searching the binding's first child, which
|
||||
// in the case of XMLPrettyPrinter contains the visible pretty-printed
|
||||
// content.
|
||||
nsXBLBinding* binding = rootContent->GetXBLBinding();
|
||||
if (binding) {
|
||||
nsIContent* child = binding->GetAnonymousContent()->GetFirstChild();
|
||||
if (child) {
|
||||
searchRootNode = do_QueryInterface(child);
|
||||
}
|
||||
}
|
||||
mSearchRange->SelectNodeContents(searchRootNode);
|
||||
|
||||
if (!mStartPointRange) {
|
||||
mStartPointRange = new nsRange(doc);
|
||||
}
|
||||
mStartPointRange->SetStart(searchRootNode, 0);
|
||||
mStartPointRange->Collapse(true); // collapse to start
|
||||
|
||||
if (!mEndPointRange) {
|
||||
mEndPointRange = new nsRange(rootContent);
|
||||
mEndPointRange = new nsRange(doc);
|
||||
}
|
||||
|
||||
mSearchRange->SelectNodeContents(rootNode);
|
||||
|
||||
mEndPointRange->SetEnd(rootNode, childCount);
|
||||
nsCOMPtr<nsINode> searchRootTmp = do_QueryInterface(searchRootNode);
|
||||
mEndPointRange->SetEnd(searchRootNode, searchRootTmp->Length());
|
||||
mEndPointRange->Collapse(false); // collapse to end
|
||||
|
||||
// Consider current selection as null if
|
||||
|
@ -773,10 +791,6 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
|
|||
selection->GetRangeAt(0, getter_AddRefs(currentSelectionRange));
|
||||
}
|
||||
|
||||
if (!mStartPointRange) {
|
||||
mStartPointRange = new nsRange(doc);
|
||||
}
|
||||
|
||||
if (!currentSelectionRange) {
|
||||
// Ensure visible range, move forward if necessary
|
||||
// This uses ignores the return value, but usese the side effect of
|
||||
|
|
Загрузка…
Ссылка в новой задаче