michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //#define DEBUG_FIND 1 michael@0: michael@0: #include "nsFind.h" michael@0: #include "nsContentCID.h" michael@0: #include "nsIContent.h" michael@0: #include "nsIDOMNode.h" michael@0: #include "nsIDOMNodeList.h" michael@0: #include "nsISelection.h" michael@0: #include "nsISelectionController.h" michael@0: #include "nsIFrame.h" michael@0: #include "nsITextControlFrame.h" michael@0: #include "nsIFormControl.h" michael@0: #include "nsIEditor.h" michael@0: #include "nsIPlaintextEditor.h" michael@0: #include "nsTextFragment.h" michael@0: #include "nsString.h" michael@0: #include "nsIAtom.h" michael@0: #include "nsServiceManagerUtils.h" michael@0: #include "nsUnicharUtils.h" michael@0: #include "nsIDOMElement.h" michael@0: #include "nsIWordBreaker.h" michael@0: #include "nsCRT.h" michael@0: #include "nsRange.h" michael@0: #include "nsContentUtils.h" michael@0: #include "mozilla/DebugOnly.h" michael@0: michael@0: using namespace mozilla; michael@0: michael@0: // Yikes! Casting a char to unichar can fill with ones! michael@0: #define CHAR_TO_UNICHAR(c) ((char16_t)(const unsigned char)c) michael@0: michael@0: static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); michael@0: static NS_DEFINE_CID(kCPreContentIteratorCID, NS_PRECONTENTITERATOR_CID); michael@0: michael@0: #define CH_QUOTE ((char16_t) 0x22) michael@0: #define CH_APOSTROPHE ((char16_t) 0x27) michael@0: #define CH_LEFT_SINGLE_QUOTE ((char16_t) 0x2018) michael@0: #define CH_RIGHT_SINGLE_QUOTE ((char16_t) 0x2019) michael@0: #define CH_LEFT_DOUBLE_QUOTE ((char16_t) 0x201C) michael@0: #define CH_RIGHT_DOUBLE_QUOTE ((char16_t) 0x201D) michael@0: michael@0: #define CH_SHY ((char16_t) 0xAD) michael@0: michael@0: // nsFind::Find casts CH_SHY to char before calling StripChars michael@0: // This works correctly if and only if CH_SHY <= 255 michael@0: PR_STATIC_ASSERT(CH_SHY <= 255); michael@0: michael@0: // ----------------------------------------------------------------------- michael@0: // nsFindContentIterator is a special iterator that also goes through michael@0: // any existing