зеркало из 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/Element.h"
|
||||||
#include "mozilla/dom/Link.h"
|
#include "mozilla/dom/Link.h"
|
||||||
#include "nsRange.h"
|
#include "nsRange.h"
|
||||||
|
#include "nsXBLBinding.h"
|
||||||
|
|
||||||
#include "nsTypeAheadFind.h"
|
#include "nsTypeAheadFind.h"
|
||||||
|
|
||||||
|
@ -746,19 +747,36 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
|
||||||
if (!rootNode)
|
if (!rootNode)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
uint32_t childCount = rootContent->GetChildCount();
|
|
||||||
|
|
||||||
if (!mSearchRange) {
|
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) {
|
if (!mEndPointRange) {
|
||||||
mEndPointRange = new nsRange(rootContent);
|
mEndPointRange = new nsRange(doc);
|
||||||
}
|
}
|
||||||
|
nsCOMPtr<nsINode> searchRootTmp = do_QueryInterface(searchRootNode);
|
||||||
mSearchRange->SelectNodeContents(rootNode);
|
mEndPointRange->SetEnd(searchRootNode, searchRootTmp->Length());
|
||||||
|
|
||||||
mEndPointRange->SetEnd(rootNode, childCount);
|
|
||||||
mEndPointRange->Collapse(false); // collapse to end
|
mEndPointRange->Collapse(false); // collapse to end
|
||||||
|
|
||||||
// Consider current selection as null if
|
// Consider current selection as null if
|
||||||
|
@ -773,10 +791,6 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
|
||||||
selection->GetRangeAt(0, getter_AddRefs(currentSelectionRange));
|
selection->GetRangeAt(0, getter_AddRefs(currentSelectionRange));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mStartPointRange) {
|
|
||||||
mStartPointRange = new nsRange(doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentSelectionRange) {
|
if (!currentSelectionRange) {
|
||||||
// Ensure visible range, move forward if necessary
|
// Ensure visible range, move forward if necessary
|
||||||
// This uses ignores the return value, but usese the side effect of
|
// This uses ignores the return value, but usese the side effect of
|
||||||
|
|
Загрузка…
Ссылка в новой задаче