nsINode* nsFindContentIterator::GetCurrentNode() { if (mInnerIterator && !mInnerIterator->IsDone()) { return mInnerIterator->GetCurrentNode(); } return mOuterIterator->GetCurrentNode(); }
void nsFindContentIterator::MaybeSetupInnerIterator() { mInnerIterator = nsnull; nsCOMPtr<nsIContent> content = do_QueryInterface(mOuterIterator->GetCurrentNode()); if (!content || !content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) return; nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(content)); if (!formControl->IsTextControl(true)) { return; } SetupInnerIterator(content); if (mInnerIterator) { if (!mFindBackward) { mInnerIterator->First(); // finish setup: position mOuterIterator on the actual "next" // node (this completes its re-init, @see SetupInnerIterator) if (!mOuterIterator->IsDone()) mOuterIterator->First(); } else { mInnerIterator->Last(); // finish setup: position mOuterIterator on the actual "previous" // node (this completes its re-init, @see SetupInnerIterator) if (!mOuterIterator->IsDone()) mOuterIterator->Last(); } } }
void nsFindContentIterator::MaybeSetupInnerIterator() { mInnerIterator = nsnull; nsIContent* content = mOuterIterator->GetCurrentNode(); if (!content || !content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) return; nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(content)); PRInt32 controlType = formControl->GetType(); if (controlType != NS_FORM_TEXTAREA && controlType != NS_FORM_INPUT_TEXT) return; SetupInnerIterator(content); if (mInnerIterator) { if (!mFindBackward) { mInnerIterator->First(); // finish setup: position mOuterIterator on the actual "next" // node (this completes its re-init, @see SetupInnerIterator) mOuterIterator->First(); } else { mInnerIterator->Last(); // finish setup: position mOuterIterator on the actual "previous" // node (this completes its re-init, @see SetupInnerIterator) mOuterIterator->Last(); } } }
nsresult nsFindContentIterator::PositionAt(nsINode* aCurNode) { nsINode* oldNode = mOuterIterator->GetCurrentNode(); nsresult rv = mOuterIterator->PositionAt(aCurNode); if (NS_SUCCEEDED(rv)) { MaybeSetupInnerIterator(); } else { mOuterIterator->PositionAt(oldNode); if (mInnerIterator) rv = mInnerIterator->PositionAt(aCurNode); } return rv; }