accessible/src/base/TextRange.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_a11y_TextRange_h__
     8 #define mozilla_a11y_TextRange_h__
    10 #include "mozilla/Move.h"
    11 #include "nsAutoPtr.h"
    13 namespace mozilla {
    14 namespace a11y {
    16 class Accessible;
    17 class HyperTextAccessible;
    19 /**
    20  * Represents a text range within the text control or document.
    21  */
    22 class TextRange MOZ_FINAL
    23 {
    24 public:
    25   TextRange(HyperTextAccessible* aRoot,
    26             Accessible* aStartContainer, int32_t aStartOffset,
    27             Accessible* aEndContainer, int32_t aEndOffset);
    28   TextRange() {}
    29   TextRange(TextRange&& aRange) :
    30     mRoot(Move(aRange.mRoot)), mStartContainer(Move(aRange.mStartContainer)),
    31     mEndContainer(Move(aRange.mEndContainer)),
    32     mStartOffset(aRange.mStartOffset), mEndOffset(aRange.mEndOffset) {}
    34   TextRange& operator= (TextRange&& aRange)
    35   {
    36     mRoot = Move(aRange.mRoot);
    37     mStartContainer = Move(aRange.mStartContainer);
    38     mEndContainer = Move(aRange.mEndContainer);
    39     mStartOffset = aRange.mStartOffset;
    40     mEndOffset = aRange.mEndOffset;
    41     return *this;
    42   }
    44   Accessible* StartContainer() const { return mStartContainer; }
    45   int32_t StartOffset() const { return mStartOffset; }
    46   Accessible* EndContainer() const { return mEndContainer; }
    47   int32_t EndOffset() const { return mEndOffset; }
    49   /**
    50    * Return text enclosed by the range.
    51    */
    52   void Text(nsAString& aText) const;
    54   /**
    55    * Return true if this TextRange object represents an actual range of text.
    56    */
    57   bool IsValid() const { return mRoot; }
    59 private:
    60   TextRange(const TextRange& aRange) MOZ_DELETE;
    61   TextRange& operator=(const TextRange& aRange) MOZ_DELETE;
    63   friend class HyperTextAccessible;
    64   friend class xpcAccessibleTextRange;
    66   void Set(HyperTextAccessible* aRoot,
    67            Accessible* aStartContainer, int32_t aStartOffset,
    68            Accessible* aEndContainer, int32_t aEndOffset);
    70   nsRefPtr<HyperTextAccessible> mRoot;
    71   nsRefPtr<Accessible> mStartContainer;
    72   nsRefPtr<Accessible> mEndContainer;
    73   int32_t mStartOffset;
    74   int32_t mEndOffset;
    75 };
    78 } // namespace a11y
    79 } // namespace mozilla
    81 #endif

mercurial