2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-03-29 04:05:39 -07:00
|
|
|
/* vim: set ts=2 sw=2 et tw=78: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
#include "HyperTextAccessible.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2012-04-13 07:17:03 -07:00
|
|
|
#include "Accessible-inl.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsAccessibilityService.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccUtils.h"
|
2012-05-27 02:01:40 -07:00
|
|
|
#include "DocAccessible.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2012-03-09 23:29:51 -08:00
|
|
|
#include "TextAttrs.h"
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIClipboard.h"
|
2012-03-06 09:08:02 -08:00
|
|
|
#include "nsContentUtils.h"
|
2011-10-15 20:38:19 -07:00
|
|
|
#include "nsFocusManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMRange.h"
|
2007-08-14 09:25:24 -07:00
|
|
|
#include "nsIEditingSession.h"
|
|
|
|
#include "nsIEditor.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIFrame.h"
|
2007-12-04 23:34:47 -08:00
|
|
|
#include "nsFrameSelection.h"
|
2007-12-11 06:15:21 -08:00
|
|
|
#include "nsILineIterator.h"
|
2007-08-14 09:25:24 -07:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPlaintextEditor.h"
|
2007-12-11 06:15:21 -08:00
|
|
|
#include "nsIScrollableFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsTextFragment.h"
|
2012-06-08 07:20:55 -07:00
|
|
|
#include "mozilla/Selection.h"
|
2007-08-03 18:12:24 -07:00
|
|
|
#include "gfxSkipChars.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
using namespace mozilla;
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-31 01:04:41 -07:00
|
|
|
// HyperTextAccessible
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::
|
|
|
|
HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) :
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap(aNode, aDoc)
|
2010-06-11 01:23:18 -07:00
|
|
|
{
|
2012-12-17 21:22:26 -08:00
|
|
|
mGenericTypes |= eHyperText;
|
2010-06-11 01:23:18 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMPL_ADDREF_INHERITED(HyperTextAccessible, AccessibleWrap)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HyperTextAccessible, AccessibleWrap)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
nsresult
|
|
|
|
HyperTextAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aInstancePtr = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-13 18:19:41 -07:00
|
|
|
// ARIA roles that these interfaces are not appropriate for.
|
|
|
|
if (!IsTextRole())
|
2012-05-28 18:18:45 -07:00
|
|
|
return Accessible::QueryInterface(aIID, aInstancePtr);
|
2007-08-20 20:18:26 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAccessibleText))) {
|
|
|
|
*aInstancePtr = static_cast<nsIAccessibleText*>(this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText))) {
|
|
|
|
*aInstancePtr = static_cast<nsIAccessibleHyperText*>(this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText))) {
|
|
|
|
*aInstancePtr = static_cast<nsIAccessibleEditableText*>(this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return Accessible::QueryInterface(aIID, aInstancePtr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
nsIAtom *tag = mContent->Tag();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-24 11:35:23 -07:00
|
|
|
if (tag == nsGkAtoms::dd)
|
|
|
|
return roles::DEFINITION;
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::form)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::FORM;
|
2010-09-04 19:14:01 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
if (tag == nsGkAtoms::blockquote || tag == nsGkAtoms::div ||
|
2012-03-28 01:20:50 -07:00
|
|
|
tag == nsGkAtoms::section || tag == nsGkAtoms::nav)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::SECTION;
|
2010-09-04 19:14:01 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
if (tag == nsGkAtoms::h1 || tag == nsGkAtoms::h2 ||
|
|
|
|
tag == nsGkAtoms::h3 || tag == nsGkAtoms::h4 ||
|
|
|
|
tag == nsGkAtoms::h5 || tag == nsGkAtoms::h6)
|
|
|
|
return roles::HEADING;
|
2010-09-04 19:14:01 -07:00
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::article)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::DOCUMENT;
|
2010-11-29 10:32:19 -08:00
|
|
|
|
2010-11-08 05:33:34 -08:00
|
|
|
// Deal with html landmark elements
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::header)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::HEADER;
|
2010-11-08 05:33:34 -08:00
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::footer)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::FOOTER;
|
2010-11-08 05:33:34 -08:00
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::aside)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::NOTE;
|
2010-11-15 10:30:44 -08:00
|
|
|
|
2010-11-08 05:33:34 -08:00
|
|
|
// Treat block frames as paragraphs
|
2010-09-04 19:14:01 -07:00
|
|
|
nsIFrame *frame = GetFrame();
|
2011-11-30 04:36:20 -08:00
|
|
|
if (frame && frame->GetType() == nsGkAtoms::blockFrame)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PARAGRAPH;
|
2010-09-04 19:14:01 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::TEXT_CONTAINER; // In ATK this works
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t states = AccessibleWrap::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 19:28:38 -08:00
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (editor) {
|
2012-03-14 10:48:01 -07:00
|
|
|
states |= states::EDITABLE;
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
} else if (mContent->Tag() == nsGkAtoms::article) {
|
2010-11-29 10:32:19 -08:00
|
|
|
// We want <article> to behave like a document in terms of readonly state.
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::READONLY;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-25 03:53:45 -07:00
|
|
|
if (HasChildren())
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::SELECTABLE_TEXT;
|
2007-04-02 08:56:24 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return states;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Substring must be entirely within the same text node
|
2012-05-31 01:04:41 -07:00
|
|
|
nsIntRect
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetBoundsForString(nsIFrame* aFrame, uint32_t aStartRenderedOffset,
|
|
|
|
uint32_t aEndRenderedOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-10-20 04:04:45 -07:00
|
|
|
nsPresContext* presContext = mDoc->PresContext();
|
2011-06-03 14:35:17 -07:00
|
|
|
if (aFrame->GetType() != nsGkAtoms::textFrame) {
|
2007-09-05 06:31:33 -07:00
|
|
|
// XXX fallback for non-text frames, happens for bullets right now
|
|
|
|
// but in the future bullets will have proper text frames
|
2012-10-20 04:04:45 -07:00
|
|
|
return aFrame->GetScreenRectInAppUnits().
|
|
|
|
ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
2007-09-05 06:31:33 -07:00
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startContentOffset, endContentOffset;
|
2007-08-10 12:24:10 -07:00
|
|
|
nsresult rv = RenderedToContentOffset(aFrame, aStartRenderedOffset, &startContentOffset);
|
2012-10-20 04:04:45 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, nsIntRect());
|
2007-08-10 12:24:10 -07:00
|
|
|
rv = RenderedToContentOffset(aFrame, aEndRenderedOffset, &endContentOffset);
|
2012-10-20 04:04:45 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, nsIntRect());
|
2007-08-03 18:12:24 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame *frame;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startContentOffsetInFrame;
|
2007-08-03 18:12:24 -07:00
|
|
|
// Get the right frame continuation -- not really a child, but a sibling of
|
|
|
|
// the primary frame passed in
|
2011-10-17 07:59:28 -07:00
|
|
|
rv = aFrame->GetChildFrameContainingOffset(startContentOffset, false,
|
2007-08-10 12:24:10 -07:00
|
|
|
&startContentOffsetInFrame, &frame);
|
2012-10-20 04:04:45 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, nsIntRect());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-20 04:04:45 -07:00
|
|
|
nsRect screenRect;
|
2007-08-10 12:24:10 -07:00
|
|
|
while (frame && startContentOffset < endContentOffset) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Start with this frame's screen rect, which we will
|
|
|
|
// shrink based on the substring we care about within it.
|
|
|
|
// We will then add that frame to the total screenRect we
|
|
|
|
// are returning.
|
2012-10-20 04:04:45 -07:00
|
|
|
nsRect frameScreenRect = frame->GetScreenRectInAppUnits();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Get the length of the substring in this frame that we want the bounds for
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startFrameTextOffset, endFrameTextOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
frame->GetOffsets(startFrameTextOffset, endFrameTextOffset);
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t frameTotalTextLength = endFrameTextOffset - startFrameTextOffset;
|
|
|
|
int32_t seekLength = endContentOffset - startContentOffset;
|
2013-01-15 04:22:03 -08:00
|
|
|
int32_t frameSubStringLength = std::min(frameTotalTextLength - startContentOffsetInFrame, seekLength);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Add the point where the string starts to the frameScreenRect
|
|
|
|
nsPoint frameTextStartPoint;
|
2007-08-16 20:43:00 -07:00
|
|
|
rv = frame->GetPointFromOffset(startContentOffset, &frameTextStartPoint);
|
2009-01-14 19:27:09 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, nsIntRect());
|
2012-10-20 04:04:45 -07:00
|
|
|
frameScreenRect.x += frameTextStartPoint.x;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Use the point for the end offset to calculate the width
|
|
|
|
nsPoint frameTextEndPoint;
|
2007-08-16 20:43:00 -07:00
|
|
|
rv = frame->GetPointFromOffset(startContentOffset + frameSubStringLength, &frameTextEndPoint);
|
2009-01-14 19:27:09 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, nsIntRect());
|
2012-10-20 04:04:45 -07:00
|
|
|
frameScreenRect.width = frameTextEndPoint.x - frameTextStartPoint.x;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
screenRect.UnionRect(frameScreenRect, screenRect);
|
|
|
|
|
|
|
|
// Get ready to loop back for next frame continuation
|
2007-08-10 12:24:10 -07:00
|
|
|
startContentOffset += frameSubStringLength;
|
|
|
|
startContentOffsetInFrame = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
frame = frame->GetNextContinuation();
|
|
|
|
}
|
|
|
|
|
2012-10-20 04:04:45 -07:00
|
|
|
return screenRect.ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the specified text.
|
|
|
|
*/
|
2007-08-13 22:30:15 -07:00
|
|
|
nsIFrame*
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
nsAString* aText, nsIFrame** aEndFrame,
|
|
|
|
nsIntRect* aBoundsRect,
|
|
|
|
Accessible** aStartAcc,
|
|
|
|
Accessible** aEndAcc)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-12 12:24:13 -08:00
|
|
|
aStartOffset = ConvertMagicOffset(aStartOffset);
|
|
|
|
aEndOffset = ConvertMagicOffset(aEndOffset);
|
2007-09-18 15:31:06 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startOffset = aStartOffset;
|
|
|
|
int32_t endOffset = aEndOffset;
|
2008-02-11 04:22:56 -08:00
|
|
|
// XXX this prevents text interface usage on <input type="password">
|
2012-01-11 19:07:35 -08:00
|
|
|
bool isPassword = (Role() == roles::PASSWORD_TEXT);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Clear out parameters and set up loop
|
|
|
|
if (aText) {
|
|
|
|
aText->Truncate();
|
|
|
|
}
|
|
|
|
if (endOffset < 0) {
|
2012-08-22 08:56:38 -07:00
|
|
|
const int32_t kMaxTextLength = 32767;
|
2007-03-22 10:30:00 -07:00
|
|
|
endOffset = kMaxTextLength; // Max end offset
|
|
|
|
}
|
|
|
|
else if (startOffset > endOffset) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame *startFrame = nullptr;
|
2013-03-12 06:43:19 -07:00
|
|
|
nsIFrame* endFrame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aEndFrame) {
|
2012-07-30 07:20:58 -07:00
|
|
|
*aEndFrame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aBoundsRect) {
|
2011-04-18 20:07:23 -07:00
|
|
|
aBoundsRect->SetEmpty();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-08-23 21:54:45 -07:00
|
|
|
if (aStartAcc)
|
2012-07-30 07:20:58 -07:00
|
|
|
*aStartAcc = nullptr;
|
2007-08-23 21:54:45 -07:00
|
|
|
if (aEndAcc)
|
2012-07-30 07:20:58 -07:00
|
|
|
*aEndAcc = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIntRect unionRect;
|
2012-07-30 07:20:58 -07:00
|
|
|
Accessible* lastAccessible = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-08-03 18:12:24 -07:00
|
|
|
gfxSkipChars skipChars;
|
|
|
|
gfxSkipCharsIterator iter;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Loop through children and collect valid offsets, text and bounds
|
2010-04-19 06:39:57 -07:00
|
|
|
// depending on what we need for out parameters.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = ChildCount();
|
|
|
|
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* childAcc = mChildren[childIdx];
|
2010-04-19 06:39:57 -07:00
|
|
|
lastAccessible = childAcc;
|
2008-10-31 20:58:07 -07:00
|
|
|
|
2010-04-19 06:39:57 -07:00
|
|
|
nsIFrame *frame = childAcc->GetFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!frame) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-08-13 22:30:15 -07:00
|
|
|
nsIFrame *primaryFrame = frame;
|
2013-03-12 06:43:19 -07:00
|
|
|
endFrame = frame;
|
2013-03-13 21:21:34 -07:00
|
|
|
if (!nsAccUtils::IsEmbeddedObject(childAcc)) {
|
2007-08-13 22:30:15 -07:00
|
|
|
// We only need info up to rendered offset -- that is what we're
|
|
|
|
// converting to content offset
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t substringEndOffset = -1;
|
|
|
|
uint32_t ourRenderedStart = 0;
|
|
|
|
int32_t ourContentStart = 0;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (frame->GetType() == nsGkAtoms::textFrame) {
|
2012-07-30 07:20:58 -07:00
|
|
|
nsresult rv = frame->GetRenderedText(nullptr, &skipChars, &iter);
|
2007-09-05 06:31:33 -07:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
ourRenderedStart = iter.GetSkippedOffset();
|
|
|
|
ourContentStart = iter.GetOriginalOffset();
|
|
|
|
substringEndOffset =
|
|
|
|
iter.ConvertOriginalToSkipped(skipChars.GetOriginalCharCount() +
|
|
|
|
ourContentStart) - ourRenderedStart;
|
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
}
|
2007-09-05 06:31:33 -07:00
|
|
|
if (substringEndOffset < 0) {
|
2007-08-13 22:30:15 -07:00
|
|
|
// XXX for non-textframe text like list bullets,
|
|
|
|
// should go away after list bullet rewrite
|
2010-04-19 06:39:57 -07:00
|
|
|
substringEndOffset = nsAccUtils::TextLength(childAcc);
|
2007-08-03 18:12:24 -07:00
|
|
|
}
|
2013-03-23 17:57:06 -07:00
|
|
|
if (startOffset < substringEndOffset ||
|
|
|
|
(startOffset == substringEndOffset && (childIdx == childCount - 1))) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Our start is within this substring
|
|
|
|
if (startOffset > 0 || endOffset < substringEndOffset) {
|
2007-08-03 18:12:24 -07:00
|
|
|
// We don't want the whole string for this accessible
|
|
|
|
// Get out the continuing text frame with this offset
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t outStartLineUnused;
|
|
|
|
int32_t contentOffset;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (frame->GetType() == nsGkAtoms::textFrame) {
|
2007-09-05 08:22:36 -07:00
|
|
|
contentOffset = iter.ConvertSkippedToOriginal(startOffset) +
|
|
|
|
ourRenderedStart - ourContentStart;
|
2007-09-05 06:31:33 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
contentOffset = startOffset;
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
frame->GetChildFrameContainingOffset(contentOffset, true,
|
2007-08-13 22:30:15 -07:00
|
|
|
&outStartLineUnused, &frame);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aEndFrame) {
|
|
|
|
*aEndFrame = frame; // We ended in the current frame
|
2007-08-23 21:54:45 -07:00
|
|
|
if (aEndAcc)
|
2010-04-19 06:39:57 -07:00
|
|
|
NS_ADDREF(*aEndAcc = childAcc);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
if (substringEndOffset > endOffset) {
|
|
|
|
// Need to stop before the end of the available text
|
|
|
|
substringEndOffset = endOffset;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
aEndOffset = endOffset;
|
|
|
|
}
|
|
|
|
if (aText) {
|
2008-02-11 04:22:56 -08:00
|
|
|
if (isPassword) {
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t count = startOffset; count < substringEndOffset; count ++)
|
2008-02-11 04:22:56 -08:00
|
|
|
*aText += '*'; // Show *'s only for password text
|
|
|
|
}
|
|
|
|
else {
|
2010-04-19 06:39:57 -07:00
|
|
|
childAcc->AppendTextTo(*aText, startOffset,
|
|
|
|
substringEndOffset - startOffset);
|
2008-02-11 04:22:56 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
if (aBoundsRect) { // Caller wants the bounds of the text
|
2007-08-13 22:30:15 -07:00
|
|
|
aBoundsRect->UnionRect(*aBoundsRect,
|
|
|
|
GetBoundsForString(primaryFrame, startOffset,
|
|
|
|
substringEndOffset));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (!startFrame) {
|
|
|
|
startFrame = frame;
|
|
|
|
aStartOffset = startOffset;
|
2007-08-23 21:54:45 -07:00
|
|
|
if (aStartAcc)
|
2010-04-19 06:39:57 -07:00
|
|
|
NS_ADDREF(*aStartAcc = childAcc);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
// We already started copying in this accessible's string,
|
|
|
|
// for the next accessible we'll start at offset 0
|
2007-03-22 10:30:00 -07:00
|
|
|
startOffset = 0;
|
|
|
|
}
|
|
|
|
else {
|
2007-08-03 18:12:24 -07:00
|
|
|
// We have not found the start position yet, get the new startOffset
|
|
|
|
// that is relative to next accessible
|
2007-03-22 10:30:00 -07:00
|
|
|
startOffset -= substringEndOffset;
|
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
// The endOffset needs to be relative to the new startOffset
|
2007-03-22 10:30:00 -07:00
|
|
|
endOffset -= substringEndOffset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Embedded object, append marker
|
|
|
|
// XXX Append \n for <br>'s
|
|
|
|
if (startOffset >= 1) {
|
|
|
|
-- startOffset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (endOffset > 0) {
|
|
|
|
if (aText) {
|
2010-06-09 20:29:56 -07:00
|
|
|
// XXX: should use nsIAccessible::AppendTextTo.
|
2011-06-03 14:35:17 -07:00
|
|
|
if (frame->GetType() == nsGkAtoms::brFrame) {
|
2007-11-16 19:44:49 -08:00
|
|
|
*aText += kForcedNewLineChar;
|
2008-10-17 03:10:43 -07:00
|
|
|
} else if (nsAccUtils::MustPrune(this)) {
|
2007-11-16 19:44:49 -08:00
|
|
|
*aText += kImaginaryEmbeddedObjectChar;
|
|
|
|
// Expose imaginary embedded object character if the accessible
|
|
|
|
// hans't children.
|
|
|
|
} else {
|
|
|
|
*aText += kEmbeddedObjectChar;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aBoundsRect) {
|
2012-10-20 04:04:45 -07:00
|
|
|
nsIntRect frameScreenRect = frame->GetScreenRectInAppUnits().
|
|
|
|
ToNearestPixels(frame->PresContext()->AppUnitsPerDevPixel());
|
|
|
|
aBoundsRect->UnionRect(*aBoundsRect, frameScreenRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!startFrame) {
|
|
|
|
startFrame = frame;
|
|
|
|
aStartOffset = 0;
|
2007-08-23 21:54:45 -07:00
|
|
|
if (aStartAcc)
|
2010-04-19 06:39:57 -07:00
|
|
|
NS_ADDREF(*aStartAcc = childAcc);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
-- endOffset;
|
|
|
|
}
|
|
|
|
if (endOffset <= 0 && startFrame) {
|
|
|
|
break; // If we don't have startFrame yet, get that in next loop iteration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 15:31:06 -07:00
|
|
|
if (aStartAcc && !*aStartAcc) {
|
|
|
|
NS_IF_ADDREF(*aStartAcc = lastAccessible);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aEndFrame && !*aEndFrame) {
|
2013-03-12 06:43:19 -07:00
|
|
|
*aEndFrame = endFrame;
|
|
|
|
if (aEndAcc && !*aEndAcc)
|
|
|
|
NS_IF_ADDREF(*aEndAcc = lastAccessible);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return startFrame;
|
|
|
|
}
|
|
|
|
|
2011-02-01 08:08:36 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetText(int32_t aStartOffset, int32_t aEndOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
nsAString& aText)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-02-01 08:08:36 -08:00
|
|
|
aText.Truncate();
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-06-11 01:23:18 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startOffset = ConvertMagicOffset(aStartOffset);
|
|
|
|
int32_t endOffset = ConvertMagicOffset(aEndOffset);
|
2012-05-23 11:06:07 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startChildIdx = GetChildIndexAtOffset(startOffset);
|
2012-05-23 11:06:07 -07:00
|
|
|
if (startChildIdx == -1) {
|
|
|
|
// 0 offsets are considered valid for empty text.
|
|
|
|
return (startOffset == 0 && endOffset == 0) ? NS_OK : NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2011-02-01 08:08:36 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t endChildIdx = GetChildIndexAtOffset(endOffset);
|
2011-02-01 08:08:36 -08:00
|
|
|
if (endChildIdx == -1)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
if (startChildIdx == endChildIdx) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t childOffset = GetChildOffset(startChildIdx);
|
2011-02-01 08:08:36 -08:00
|
|
|
NS_ENSURE_STATE(childOffset != -1);
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* child = GetChildAt(startChildIdx);
|
2011-02-03 06:29:12 -08:00
|
|
|
child->AppendTextTo(aText, startOffset - childOffset,
|
|
|
|
endOffset - startOffset);
|
2011-02-01 08:08:36 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startChildOffset = GetChildOffset(startChildIdx);
|
2011-02-01 08:08:36 -08:00
|
|
|
NS_ENSURE_STATE(startChildOffset != -1);
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* startChild = GetChildAt(startChildIdx);
|
2011-02-03 06:29:12 -08:00
|
|
|
startChild->AppendTextTo(aText, startOffset - startChildOffset);
|
2011-02-01 08:08:36 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t childIdx = startChildIdx + 1; childIdx < endChildIdx; childIdx++) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* child = GetChildAt(childIdx);
|
2011-02-01 08:08:36 -08:00
|
|
|
child->AppendTextTo(aText);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t endChildOffset = GetChildOffset(endChildIdx);
|
2011-02-01 08:08:36 -08:00
|
|
|
NS_ENSURE_STATE(endChildOffset != -1);
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* endChild = GetChildAt(endChildIdx);
|
2011-02-03 06:29:12 -08:00
|
|
|
endChild->AppendTextTo(aText, 0, endOffset - endChildOffset);
|
2011-02-01 08:08:36 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the character count.
|
|
|
|
*/
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetCharacterCount(int32_t* aCharacterCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-04-19 06:39:57 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aCharacterCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
*aCharacterCount = 0;
|
2010-04-19 06:39:57 -07:00
|
|
|
|
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-01-24 19:33:47 -08:00
|
|
|
*aCharacterCount = CharacterCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the specified character.
|
|
|
|
*/
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetCharacterAtOffset(int32_t aOffset, PRUnichar* aCharacter)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-02-03 06:29:12 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aCharacter);
|
2012-07-20 04:16:17 -07:00
|
|
|
*aCharacter = L'\0';
|
2011-02-03 06:29:12 -08:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-06-11 01:23:18 -07:00
|
|
|
|
2011-02-03 06:29:12 -08:00
|
|
|
nsAutoString character;
|
|
|
|
if (GetCharAt(aOffset, eGetAt, character)) {
|
|
|
|
*aCharacter = character.First();
|
|
|
|
return NS_OK;
|
2007-08-06 23:10:31 -07:00
|
|
|
}
|
|
|
|
|
2011-02-03 06:29:12 -08:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::DOMPointToHypertextOffset(nsINode* aNode,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aNodeOffset,
|
|
|
|
int32_t* aHyperTextOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
bool aIsEndOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-05-17 09:16:52 -07:00
|
|
|
if (!aHyperTextOffset)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-08-03 18:12:24 -07:00
|
|
|
*aHyperTextOffset = 0;
|
2008-01-25 05:47:48 -08:00
|
|
|
|
2010-05-17 09:16:52 -07:00
|
|
|
if (!aNode)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t addTextOffset = 0;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsINode* findNode = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-08-28 14:57:53 -07:00
|
|
|
if (aNodeOffset == -1) {
|
|
|
|
findNode = aNode;
|
2010-06-11 01:23:18 -07:00
|
|
|
|
|
|
|
} else if (aNode->IsNodeOfType(nsINode::eTEXT)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// For text nodes, aNodeOffset comes in as a character offset
|
|
|
|
// Text offset will be added at the end, if we find the offset in this hypertext
|
2007-08-03 18:12:24 -07:00
|
|
|
// We want the "skipped" offset into the text (rendered text without the extra whitespace)
|
2012-04-06 11:08:24 -07:00
|
|
|
nsIFrame *frame = aNode->AsContent()->GetPrimaryFrame();
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(frame, nullptr);
|
2007-08-03 18:12:24 -07:00
|
|
|
nsresult rv = ContentToRenderedOffset(frame, aNodeOffset, &addTextOffset);
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
// Get the child node and
|
|
|
|
findNode = aNode;
|
2010-06-11 01:23:18 -07:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// findNode could be null if aNodeOffset == # of child nodes, which means
|
|
|
|
// one of two things:
|
2013-01-05 02:14:34 -08:00
|
|
|
// 1) there are no children, and the passed-in node is not mContent -- use
|
2010-06-11 01:23:18 -07:00
|
|
|
// parentContent for the node to find
|
2013-01-05 02:14:34 -08:00
|
|
|
// 2) there are no children and the passed-in node is mContent, which means
|
|
|
|
// we're an empty nsIAccessibleText
|
|
|
|
// 3) there are children and we're at the end of the children
|
2010-06-11 01:23:18 -07:00
|
|
|
|
|
|
|
findNode = aNode->GetChildAt(aNodeOffset);
|
2013-01-05 02:14:34 -08:00
|
|
|
if (!findNode) {
|
|
|
|
if (aNodeOffset == 0) {
|
|
|
|
if (aNode == GetNode()) {
|
|
|
|
// Case #1: this accessible has no children and thus has empty text,
|
|
|
|
// we can only be at hypertext offset 0.
|
|
|
|
*aHyperTextOffset = 0;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Case #2: there are no children, we're at this node.
|
|
|
|
findNode = aNode;
|
|
|
|
} else if (aNodeOffset == aNode->GetChildCount()) {
|
|
|
|
// Case #3: we're after the last child, get next node to this one.
|
|
|
|
for (nsINode* tmpNode = aNode;
|
|
|
|
!findNode && tmpNode && tmpNode != mContent;
|
|
|
|
tmpNode = tmpNode->GetParent()) {
|
|
|
|
findNode = tmpNode->GetNextSibling();
|
|
|
|
}
|
2007-08-10 18:44:44 -07:00
|
|
|
}
|
2007-04-19 06:56:09 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get accessible for this findNode, or if that node isn't accessible, use the
|
|
|
|
// accessible for the next DOM node which has one (based on forward depth first search)
|
2012-07-30 07:20:58 -07:00
|
|
|
Accessible* descendantAcc = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (findNode) {
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIContent> findContent(do_QueryInterface(findNode));
|
|
|
|
if (findContent && findContent->IsHTML() &&
|
2011-06-03 14:35:17 -07:00
|
|
|
findContent->NodeInfo()->Equals(nsGkAtoms::br) &&
|
2010-02-08 13:02:18 -08:00
|
|
|
findContent->AttrValueIs(kNameSpaceID_None,
|
2011-06-03 14:35:17 -07:00
|
|
|
nsGkAtoms::mozeditorbogusnode,
|
|
|
|
nsGkAtoms::_true,
|
2010-02-08 13:02:18 -08:00
|
|
|
eIgnoreCase)) {
|
|
|
|
// This <br> is the hacky "bogus node" used when there is no text in a control
|
|
|
|
*aHyperTextOffset = 0;
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-01-21 17:32:11 -08:00
|
|
|
}
|
2010-04-23 17:40:51 -07:00
|
|
|
descendantAcc = GetFirstAvailableAccessible(findNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-04-19 06:39:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// From the descendant, go up and get the immediate child of this hypertext
|
2012-07-30 07:20:58 -07:00
|
|
|
Accessible* childAccAtOffset = nullptr;
|
2010-04-19 06:39:57 -07:00
|
|
|
while (descendantAcc) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* parentAcc = descendantAcc->Parent();
|
2010-04-19 06:39:57 -07:00
|
|
|
if (parentAcc == this) {
|
|
|
|
childAccAtOffset = descendantAcc;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
2010-04-19 06:39:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// This offset no longer applies because the passed-in text object is not a child
|
|
|
|
// of the hypertext. This happens when there are nested hypertexts, e.g.
|
|
|
|
// <div>abc<h1>def</h1>ghi</div>
|
|
|
|
// If the passed-in DOM point was not on a direct child of the hypertext, we will
|
|
|
|
// return the offset for that entire hypertext
|
2007-09-18 15:28:26 -07:00
|
|
|
if (aIsEndOffset) {
|
|
|
|
// Not inclusive, the indicated char comes at index before this offset
|
|
|
|
// If the end offset is after the first character of the passed in object, use 1 for
|
2007-05-09 10:42:42 -07:00
|
|
|
// addTextOffset, to put us after the embedded object char. We'll only treat the offset as
|
|
|
|
// before the embedded object char if we end at the very beginning of the child.
|
|
|
|
addTextOffset = addTextOffset > 0;
|
2007-09-18 15:28:26 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Start offset, inclusive
|
|
|
|
// Make sure the offset lands on the embedded object character in order to indicate
|
|
|
|
// the true inner offset is inside the subtree for that link
|
2008-10-17 03:10:43 -07:00
|
|
|
addTextOffset =
|
2010-05-25 01:40:54 -07:00
|
|
|
(nsAccUtils::TextLength(descendantAcc) == addTextOffset) ? 1 : 0;
|
2007-09-18 15:28:26 -07:00
|
|
|
}
|
2010-04-19 06:39:57 -07:00
|
|
|
|
2010-05-25 01:05:52 -07:00
|
|
|
descendantAcc = parentAcc;
|
2010-04-19 06:39:57 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Loop through, adding offsets until we reach childAccessible
|
|
|
|
// If childAccessible is null we will end up adding up the entire length of
|
|
|
|
// the hypertext, which is good -- it just means our offset node
|
|
|
|
// came after the last accessible child's node
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = ChildCount();
|
2010-04-19 06:39:57 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childIdx = 0;
|
2012-07-30 07:20:58 -07:00
|
|
|
Accessible* childAcc = nullptr;
|
2010-04-19 06:39:57 -07:00
|
|
|
for (; childIdx < childCount; childIdx++) {
|
|
|
|
childAcc = mChildren[childIdx];
|
|
|
|
if (childAcc == childAccAtOffset)
|
|
|
|
break;
|
|
|
|
|
2010-05-25 01:40:54 -07:00
|
|
|
*aHyperTextOffset += nsAccUtils::TextLength(childAcc);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-04-19 06:39:57 -07:00
|
|
|
|
|
|
|
if (childIdx < childCount) {
|
2007-08-03 18:12:24 -07:00
|
|
|
*aHyperTextOffset += addTextOffset;
|
2010-04-19 06:39:57 -07:00
|
|
|
NS_ASSERTION(childAcc == childAccAtOffset,
|
2012-07-30 07:20:58 -07:00
|
|
|
"These should be equal whenever we exit loop and childAcc != nullptr");
|
2010-04-19 06:39:57 -07:00
|
|
|
|
2010-05-17 09:16:52 -07:00
|
|
|
if (childIdx < childCount - 1 ||
|
2010-05-25 01:40:54 -07:00
|
|
|
addTextOffset < nsAccUtils::TextLength(childAccAtOffset)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// If not at end of last text node, we will return the accessible we were in
|
2010-05-17 09:16:52 -07:00
|
|
|
return childAccAtOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2007-08-28 14:57:53 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-09-24 22:48:51 -07:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::HypertextOffsetsToDOMRange(int32_t aStartHTOffset,
|
|
|
|
int32_t aEndHTOffset,
|
2012-04-06 11:08:24 -07:00
|
|
|
nsRange* aRange)
|
2007-09-24 22:48:51 -07:00
|
|
|
{
|
2008-08-28 07:48:41 -07:00
|
|
|
// If the given offsets are 0 and associated editor is empty then return
|
|
|
|
// collapsed range with editor root element as range container.
|
|
|
|
if (aStartHTOffset == 0 && aEndHTOffset == 0) {
|
2012-03-07 19:28:38 -08:00
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2008-08-28 07:48:41 -07:00
|
|
|
if (editor) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isEmpty = false;
|
2008-08-28 07:48:41 -07:00
|
|
|
editor->GetDocumentIsEmpty(&isEmpty);
|
|
|
|
if (isEmpty) {
|
|
|
|
nsCOMPtr<nsIDOMElement> editorRootElm;
|
|
|
|
editor->GetRootElement(getter_AddRefs(editorRootElm));
|
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
nsCOMPtr<nsINode> editorRoot(do_QueryInterface(editorRootElm));
|
2008-08-28 07:48:41 -07:00
|
|
|
if (editorRoot) {
|
2012-04-06 11:08:24 -07:00
|
|
|
aRange->SetStart(editorRoot, 0);
|
|
|
|
aRange->SetEnd(editorRoot, 0);
|
2008-08-28 07:48:41 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> startAcc, endAcc;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startOffset = aStartHTOffset, endOffset = aEndHTOffset;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame *startFrame = nullptr, *endFrame = nullptr;
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
startFrame = GetPosAndText(startOffset, endOffset, nullptr, &endFrame, nullptr,
|
2007-09-24 22:48:51 -07:00
|
|
|
getter_AddRefs(startAcc), getter_AddRefs(endAcc));
|
|
|
|
if (!startAcc || !endAcc)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
DOMPoint startPoint, endPoint;
|
2007-09-24 22:48:51 -07:00
|
|
|
nsresult rv = GetDOMPointByFrameOffset(startFrame, startOffset, startAcc,
|
2012-04-06 11:08:24 -07:00
|
|
|
&startPoint);
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
rv = aRange->SetStart(startPoint.node, startPoint.idx);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
if (aStartHTOffset == aEndHTOffset)
|
|
|
|
return aRange->SetEnd(startPoint.node, startPoint.idx);
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
rv = GetDOMPointByFrameOffset(endFrame, endOffset, endAcc, &endPoint);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
return aRange->SetEnd(endPoint.node, endPoint.idx);
|
2007-09-24 22:48:51 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::GetRelativeOffset(nsIPresShell* aPresShell,
|
|
|
|
nsIFrame* aFromFrame,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aFromOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
Accessible* aFromAccessible,
|
|
|
|
nsSelectionAmount aAmount,
|
|
|
|
nsDirection aDirection,
|
2013-03-23 17:57:06 -07:00
|
|
|
bool aNeedsStart,
|
|
|
|
EWordMovementType aWordMovementType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
const bool kIsJumpLinesOk = true; // okay to jump lines
|
|
|
|
const bool kIsScrollViewAStop = false; // do not stop at scroll views
|
|
|
|
const bool kIsKeyboardSelect = true; // is keyboard selection
|
|
|
|
const bool kIsVisualBidi = false; // use visual order for bidi text
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Ask layout for the new node and offset, after moving the appropriate amount
|
2007-08-03 18:12:24 -07:00
|
|
|
|
2007-08-29 00:12:09 -07:00
|
|
|
nsresult rv;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t contentOffset = aFromOffset;
|
2013-03-13 21:21:34 -07:00
|
|
|
nsIFrame *frame = aFromAccessible->GetFrame();
|
|
|
|
NS_ENSURE_TRUE(frame, -1);
|
2008-10-31 20:58:07 -07:00
|
|
|
|
2013-03-13 21:21:34 -07:00
|
|
|
if (frame->GetType() == nsGkAtoms::textFrame) {
|
|
|
|
rv = RenderedToContentOffset(frame, aFromOffset, &contentOffset);
|
|
|
|
NS_ENSURE_SUCCESS(rv, -1);
|
2007-08-29 00:12:09 -07:00
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
|
2012-03-26 09:09:38 -07:00
|
|
|
nsPeekOffsetStruct pos(aAmount, aDirection, contentOffset,
|
|
|
|
0, kIsJumpLinesOk, kIsScrollViewAStop, kIsKeyboardSelect, kIsVisualBidi,
|
2013-03-23 17:57:06 -07:00
|
|
|
aWordMovementType);
|
2007-08-03 18:12:24 -07:00
|
|
|
rv = aFromFrame->PeekOffset(&pos);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-07-03 08:29:20 -07:00
|
|
|
pos.mResultContent = aFromFrame->GetContent();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aDirection == eDirPrevious) {
|
|
|
|
// Use passed-in frame as starting point in failure case for now,
|
|
|
|
// this is a hack to deal with starting on a list bullet frame,
|
|
|
|
// which fails in PeekOffset() because the line iterator doesn't see it.
|
|
|
|
// XXX Need to look at our overall handling of list bullets, which are an odd case
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t endOffsetUnused;
|
2007-03-22 10:30:00 -07:00
|
|
|
aFromFrame->GetOffsets(pos.mContentOffset, endOffsetUnused);
|
|
|
|
}
|
|
|
|
else {
|
2013-07-03 08:29:20 -07:00
|
|
|
// XXX: PeekOffset fails on a last frame in the document for
|
|
|
|
// eSelectLine/eDirNext. DOM selection (up/down arrowing processing) has
|
|
|
|
// similar code to handle this case. One day it should be incorporated
|
|
|
|
// into PeekOffset.
|
|
|
|
int32_t startOffsetUnused;
|
|
|
|
aFromFrame->GetOffsets(startOffsetUnused, pos.mContentOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Turn the resulting node and offset into a hyperTextOffset
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t hyperTextOffset;
|
2010-06-11 01:23:18 -07:00
|
|
|
if (!pos.mResultContent)
|
|
|
|
return -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
// If finalAccessible is nullptr, then DOMPointToHypertextOffset() searched
|
2010-05-17 09:16:52 -07:00
|
|
|
// through the hypertext children without finding the node/offset position.
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* finalAccessible =
|
2010-06-11 01:23:18 -07:00
|
|
|
DOMPointToHypertextOffset(pos.mResultContent, pos.mContentOffset,
|
|
|
|
&hyperTextOffset, aDirection == eDirNext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (!finalAccessible && aDirection == eDirPrevious) {
|
|
|
|
// If we reached the end during search, this means we didn't find the DOM point
|
|
|
|
// and we're actually at the start of the paragraph
|
|
|
|
hyperTextOffset = 0;
|
|
|
|
}
|
|
|
|
else if (aAmount == eSelectBeginLine) {
|
2012-07-30 07:20:58 -07:00
|
|
|
Accessible* firstChild = mChildren.SafeElementAt(0, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
// For line selection with needsStart, set start of line exactly to line break
|
2009-12-10 11:12:19 -08:00
|
|
|
if (pos.mContentOffset == 0 && firstChild &&
|
2012-01-11 19:07:35 -08:00
|
|
|
firstChild->Role() == roles::STATICTEXT &&
|
2012-08-22 08:56:38 -07:00
|
|
|
static_cast<int32_t>(nsAccUtils::TextLength(firstChild)) == hyperTextOffset) {
|
2007-04-24 11:25:00 -07:00
|
|
|
// XXX Bullet hack -- we should remove this once list bullets use anonymous content
|
|
|
|
hyperTextOffset = 0;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!aNeedsStart && hyperTextOffset > 0) {
|
|
|
|
-- hyperTextOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hyperTextOffset;
|
|
|
|
}
|
|
|
|
|
2013-03-31 06:39:29 -07:00
|
|
|
int32_t
|
2013-07-02 05:57:29 -07:00
|
|
|
HyperTextAccessible::FindBoundary(int32_t aOffset, nsDirection aDirection,
|
|
|
|
nsSelectionAmount aAmount,
|
|
|
|
EWordMovementType aWordMovementType)
|
2013-03-31 06:39:29 -07:00
|
|
|
{
|
|
|
|
// Convert hypertext offset to frame-relative offset.
|
|
|
|
int32_t offsetInFrame = aOffset, notUsedOffset = aOffset;
|
|
|
|
nsRefPtr<Accessible> accAtOffset;
|
|
|
|
nsIFrame* frameAtOffset =
|
|
|
|
GetPosAndText(offsetInFrame, notUsedOffset, nullptr, nullptr,
|
|
|
|
nullptr, getter_AddRefs(accAtOffset));
|
|
|
|
if (!frameAtOffset) {
|
|
|
|
if (aOffset == CharacterCount()) {
|
|
|
|
// Asking for start of line, while on last character.
|
|
|
|
if (accAtOffset)
|
|
|
|
frameAtOffset = accAtOffset->GetFrame();
|
|
|
|
}
|
|
|
|
NS_ASSERTION(frameAtOffset, "No start frame for text getting!");
|
|
|
|
if (!frameAtOffset)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
// We're on the last continuation since we're on the last character.
|
|
|
|
frameAtOffset = frameAtOffset->GetLastContinuation();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return hypertext offset of the boundary of the found word.
|
|
|
|
return GetRelativeOffset(mDoc->PresShell(), frameAtOffset, offsetInFrame,
|
2013-07-02 05:57:29 -07:00
|
|
|
accAtOffset, aAmount, aDirection,
|
|
|
|
(aWordMovementType == eStartWord || aAmount == eSelectBeginLine),
|
2013-03-31 06:39:29 -07:00
|
|
|
aWordMovementType);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
Gets the specified text relative to aBoundaryType, which means:
|
|
|
|
BOUNDARY_CHAR The character before/at/after the offset is returned.
|
|
|
|
BOUNDARY_WORD_START From the word start before/at/after the offset to the next word start.
|
|
|
|
BOUNDARY_WORD_END From the word end before/at/after the offset to the next work end.
|
|
|
|
BOUNDARY_LINE_START From the line start before/at/after the offset to the next line start.
|
|
|
|
BOUNDARY_LINE_END From the line end before/at/after the offset to the next line start.
|
|
|
|
*/
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
nsresult
|
2013-03-23 17:57:06 -07:00
|
|
|
HyperTextAccessible::GetTextHelper(EGetTextType aType,
|
|
|
|
AccessibleTextBoundary aBoundaryType,
|
|
|
|
int32_t aOffset,
|
|
|
|
int32_t* aStartOffset, int32_t* aEndOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
nsAString& aText)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aText.Truncate();
|
2008-07-24 08:20:39 -07:00
|
|
|
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
|
2013-03-23 17:57:06 -07:00
|
|
|
int32_t offset = ConvertMagicOffset(aOffset);
|
|
|
|
if (offset < 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2013-03-24 12:28:34 -07:00
|
|
|
|
2013-03-23 17:57:06 -07:00
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET && offset > 0 &&
|
|
|
|
(aBoundaryType == BOUNDARY_LINE_START ||
|
|
|
|
aBoundaryType == BOUNDARY_LINE_END)) {
|
|
|
|
// It is the same character offset when the caret is visually at
|
|
|
|
// the very end of a line or the start of a new line. Getting text at
|
|
|
|
// the line should provide the line with the visual caret,
|
|
|
|
// otherwise screen readers will announce the wrong line as the user
|
|
|
|
// presses up or down arrow and land at the end of a line.
|
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
if (frameSelection &&
|
|
|
|
frameSelection->GetHint() == nsFrameSelection::HINTLEFT) {
|
|
|
|
-- offset; // We are at the start of a line
|
2007-12-04 23:34:47 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-12-04 23:34:47 -08:00
|
|
|
|
2008-07-24 08:20:39 -07:00
|
|
|
nsSelectionAmount amount;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool needsStart = false;
|
2008-07-24 08:20:39 -07:00
|
|
|
switch (aBoundaryType) {
|
|
|
|
case BOUNDARY_WORD_START:
|
2011-10-17 07:59:28 -07:00
|
|
|
needsStart = true;
|
2008-07-24 08:20:39 -07:00
|
|
|
amount = eSelectWord;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOUNDARY_WORD_END:
|
|
|
|
amount = eSelectWord;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOUNDARY_LINE_START:
|
|
|
|
// Newlines are considered at the end of a line. Since getting
|
|
|
|
// the BOUNDARY_LINE_START gets the text from the line-start to the next
|
|
|
|
// line-start, the newline is included at the end of the string.
|
2011-10-17 07:59:28 -07:00
|
|
|
needsStart = true;
|
2008-07-24 08:20:39 -07:00
|
|
|
amount = eSelectLine;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOUNDARY_LINE_END:
|
|
|
|
// Newlines are considered at the end of a line. Since getting
|
|
|
|
// the BOUNDARY_END_START gets the text from the line-end to the next
|
|
|
|
//line-end, the newline is included at the beginning of the string.
|
|
|
|
amount = eSelectLine;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOUNDARY_ATTRIBUTE_RANGE:
|
|
|
|
{
|
2013-03-23 17:57:06 -07:00
|
|
|
nsresult rv = GetTextAttributes(false, offset,
|
2012-07-30 07:20:58 -07:00
|
|
|
aStartOffset, aEndOffset, nullptr);
|
2008-07-24 08:20:39 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
|
|
|
|
|
|
|
default: // Note, sentence support is deprecated and falls through to here
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2013-03-23 17:57:06 -07:00
|
|
|
int32_t startOffset = offset + (aBoundaryType == BOUNDARY_LINE_END); // Avoid getting the previous line
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t endOffset = startOffset;
|
2007-12-04 23:34:47 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Convert offsets to frame-relative
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> startAcc;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame *startFrame = GetPosAndText(startOffset, endOffset, nullptr, nullptr,
|
|
|
|
nullptr, getter_AddRefs(startAcc));
|
2007-08-29 00:12:09 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!startFrame) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t textLength = CharacterCount();
|
2013-03-23 17:57:06 -07:00
|
|
|
if (aBoundaryType == BOUNDARY_LINE_START && offset > 0 && offset == textLength) {
|
2007-09-18 15:34:50 -07:00
|
|
|
// Asking for start of line, while on last character
|
2010-06-11 21:04:50 -07:00
|
|
|
if (startAcc)
|
|
|
|
startFrame = startAcc->GetFrame();
|
2007-09-18 15:34:50 -07:00
|
|
|
}
|
|
|
|
if (!startFrame) {
|
2013-03-23 17:57:06 -07:00
|
|
|
return offset > textLength ? NS_ERROR_FAILURE : NS_OK;
|
2007-09-18 15:34:50 -07:00
|
|
|
}
|
2007-12-04 21:16:26 -08:00
|
|
|
else {
|
|
|
|
// We're on the last continuation since we're on the last character
|
|
|
|
startFrame = startFrame->GetLastContinuation();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-23 17:57:06 -07:00
|
|
|
int32_t finalStartOffset = 0, finalEndOffset = 0;
|
|
|
|
EWordMovementType wordMovementType = needsStart ? eStartWord : eEndWord;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-23 17:57:06 -07:00
|
|
|
nsIPresShell* presShell = mDoc->PresShell();
|
2007-03-22 10:30:00 -07:00
|
|
|
// If aType == eGetAt we'll change both the start and end offset from
|
|
|
|
// the original offset
|
|
|
|
if (aType == eGetAfter) {
|
2013-03-23 17:57:06 -07:00
|
|
|
finalStartOffset = offset;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2007-08-29 00:12:09 -07:00
|
|
|
finalStartOffset = GetRelativeOffset(presShell, startFrame, startOffset,
|
2013-03-23 17:57:06 -07:00
|
|
|
startAcc,
|
|
|
|
(amount == eSelectLine ? eSelectBeginLine : amount),
|
|
|
|
eDirPrevious, needsStart,
|
|
|
|
wordMovementType);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_TRUE(finalStartOffset >= 0, NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aType == eGetBefore) {
|
2013-03-23 17:57:06 -07:00
|
|
|
finalEndOffset = offset;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Start moving forward from the start so that we don't get
|
2010-05-13 05:19:50 -07:00
|
|
|
// 2 words/lines if the offset occurred on whitespace boundary
|
2007-03-22 10:30:00 -07:00
|
|
|
// Careful, startOffset and endOffset are passed by reference to GetPosAndText() and changed
|
2007-12-04 23:34:47 -08:00
|
|
|
// For BOUNDARY_LINE_END, make sure we start of this line
|
|
|
|
startOffset = endOffset = finalStartOffset + (aBoundaryType == BOUNDARY_LINE_END);
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> endAcc;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset, nullptr, nullptr,
|
|
|
|
nullptr, getter_AddRefs(endAcc));
|
2012-01-11 19:07:35 -08:00
|
|
|
if (endAcc && endAcc->Role() == roles::STATICTEXT) {
|
2008-01-21 17:26:49 -08:00
|
|
|
// Static text like list bullets will ruin our forward calculation,
|
|
|
|
// since the caret cannot be in the static text. Start just after the static text.
|
2008-10-17 03:10:43 -07:00
|
|
|
startOffset = endOffset = finalStartOffset +
|
|
|
|
(aBoundaryType == BOUNDARY_LINE_END) +
|
|
|
|
nsAccUtils::TextLength(endAcc);
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
endFrame = GetPosAndText(startOffset, endOffset, nullptr, nullptr,
|
|
|
|
nullptr, getter_AddRefs(endAcc));
|
2008-01-21 17:26:49 -08:00
|
|
|
}
|
2008-01-28 19:59:50 -08:00
|
|
|
if (!endFrame) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2007-08-29 00:12:09 -07:00
|
|
|
finalEndOffset = GetRelativeOffset(presShell, endFrame, endOffset, endAcc,
|
2013-03-23 17:57:06 -07:00
|
|
|
(amount == eSelectLine ? eSelectEndLine : amount),
|
|
|
|
eDirNext, needsStart, wordMovementType);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_TRUE(endOffset >= 0, NS_ERROR_FAILURE);
|
2013-03-23 17:57:06 -07:00
|
|
|
if (finalEndOffset == offset) {
|
2007-09-18 14:36:41 -07:00
|
|
|
if (aType == eGetAt && amount == eSelectWord) {
|
|
|
|
// Fix word error for the first character in word: PeekOffset() will return the previous word when
|
2013-03-23 17:57:06 -07:00
|
|
|
// offset points to the first character of the word, but accessibility APIs want the current word
|
2007-09-18 14:36:41 -07:00
|
|
|
// that the first character is in
|
2013-03-23 17:57:06 -07:00
|
|
|
return GetTextHelper(eGetAfter, aBoundaryType, offset,
|
|
|
|
aStartOffset, aEndOffset, aText);
|
2007-09-18 14:36:41 -07:00
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t textLength = CharacterCount();
|
2007-09-18 15:34:50 -07:00
|
|
|
if (finalEndOffset < textLength) {
|
|
|
|
// This happens sometimes when current character at finalStartOffset
|
|
|
|
// is an embedded object character representing another hypertext, that
|
|
|
|
// the AT really needs to dig into separately
|
|
|
|
++ finalEndOffset;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aStartOffset = finalStartOffset;
|
|
|
|
*aEndOffset = finalEndOffset;
|
|
|
|
|
2013-03-23 17:57:06 -07:00
|
|
|
NS_ASSERTION((finalStartOffset < offset && finalEndOffset >= offset) || aType != eGetBefore, "Incorrect results for GetTextHelper");
|
|
|
|
NS_ASSERTION((finalStartOffset <= offset && finalEndOffset > offset) || aType == eGetBefore, "Incorrect results for GetTextHelper");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-18 15:34:50 -07:00
|
|
|
GetPosAndText(finalStartOffset, finalEndOffset, &aText);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsIAccessibleText impl.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetTextBeforeOffset(int32_t aOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
AccessibleTextBoundary aBoundaryType,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset, nsAString& aText)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-03-23 17:57:06 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2013-03-31 06:39:29 -07:00
|
|
|
int32_t offset = ConvertMagicOffset(aOffset);
|
|
|
|
if (offset < 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
switch (aBoundaryType) {
|
|
|
|
case BOUNDARY_CHAR:
|
|
|
|
GetCharAt(offset, eGetBefore, aText, aStartOffset, aEndOffset);
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
case BOUNDARY_WORD_START: {
|
2013-05-16 21:06:13 -07:00
|
|
|
// If the offset is a word start (except text length offset) then move
|
|
|
|
// backward to find a start offset (end offset is the given offset).
|
|
|
|
// Otherwise move backward twice to find both start and end offsets.
|
|
|
|
if (offset == CharacterCount()) {
|
|
|
|
*aEndOffset = FindWordBoundary(offset, eDirPrevious, eStartWord);
|
|
|
|
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
|
|
|
|
} else {
|
|
|
|
*aStartOffset = FindWordBoundary(offset, eDirPrevious, eStartWord);
|
|
|
|
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eStartWord);
|
|
|
|
if (*aEndOffset != offset) {
|
|
|
|
*aEndOffset = *aStartOffset;
|
|
|
|
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
|
|
|
|
}
|
2013-03-31 06:39:29 -07:00
|
|
|
}
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
2011-02-03 06:29:12 -08:00
|
|
|
|
2013-03-31 06:39:29 -07:00
|
|
|
case BOUNDARY_WORD_END: {
|
|
|
|
// Move word backward twice to find start and end offsets.
|
|
|
|
*aEndOffset = FindWordBoundary(offset, eDirPrevious, eEndWord);
|
|
|
|
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
|
|
|
|
2013-07-11 06:16:18 -07:00
|
|
|
case BOUNDARY_LINE_START: {
|
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
|
|
|
|
offset = AdjustCaretOffset(offset);
|
|
|
|
|
|
|
|
// If we are at last empty then home key and get the text (last empty line
|
|
|
|
// doesn't have own frame).
|
2013-07-12 10:34:13 -07:00
|
|
|
if (IsEmptyLastLineOffset(offset)) {
|
|
|
|
*aStartOffset = FindLineBoundary(offset, eDirPrevious, eSelectBeginLine);
|
|
|
|
*aEndOffset = offset;
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
2013-07-11 06:16:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Home key, up arrow, home key.
|
|
|
|
*aEndOffset = FindLineBoundary(offset, eDirPrevious, eSelectBeginLine);
|
|
|
|
*aStartOffset = FindLineBoundary(offset, eDirPrevious, eSelectLine);
|
|
|
|
*aStartOffset = FindLineBoundary(*aStartOffset, eDirPrevious, eSelectBeginLine);
|
|
|
|
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
|
|
|
|
2013-07-12 10:34:13 -07:00
|
|
|
case BOUNDARY_LINE_END: {
|
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
|
|
|
|
offset = AdjustCaretOffset(offset);
|
|
|
|
|
|
|
|
// Nothing if we are at first line.
|
|
|
|
int32_t tmpOffset = FindLineBoundary(offset, eDirPrevious, eSelectBeginLine);
|
|
|
|
if (tmpOffset == 0) {
|
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Up arrow, end key to find previous line endings.
|
|
|
|
if (IsEmptyLastLineOffset(offset)) { // no own frame for a last line
|
|
|
|
tmpOffset = FindLineBoundary(offset, eDirPrevious, eSelectLine);
|
|
|
|
*aStartOffset = FindLineBoundary(tmpOffset, eDirNext, eSelectEndLine);
|
|
|
|
*aEndOffset = offset - 1;
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpOffset = FindLineBoundary(offset, eDirPrevious, eSelectLine);
|
|
|
|
*aEndOffset = FindLineBoundary(tmpOffset, eDirNext, eSelectEndLine);
|
|
|
|
tmpOffset = FindLineBoundary(*aEndOffset, eDirPrevious, eSelectLine);
|
|
|
|
*aStartOffset = FindLineBoundary(tmpOffset, eDirNext, eSelectEndLine);
|
|
|
|
if (*aStartOffset == *aEndOffset) // we are at second line
|
|
|
|
*aStartOffset = 0;
|
|
|
|
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
|
|
|
|
2013-03-31 06:39:29 -07:00
|
|
|
case BOUNDARY_ATTRIBUTE_RANGE:
|
|
|
|
return GetTextHelper(eGetBefore, aBoundaryType, aOffset,
|
|
|
|
aStartOffset, aEndOffset, aText);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetTextAtOffset(int32_t aOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
AccessibleTextBoundary aBoundaryType,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset, nsAString& aText)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-03-23 17:57:06 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2013-03-31 06:39:29 -07:00
|
|
|
int32_t offset = ConvertMagicOffset(aOffset);
|
|
|
|
if (offset < 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2013-03-23 17:57:06 -07:00
|
|
|
switch (aBoundaryType) {
|
|
|
|
case BOUNDARY_CHAR:
|
|
|
|
return GetCharAt(aOffset, eGetAt, aText, aStartOffset, aEndOffset) ?
|
|
|
|
NS_OK : NS_ERROR_INVALID_ARG;
|
|
|
|
|
2013-05-03 07:10:05 -07:00
|
|
|
case BOUNDARY_WORD_START:
|
2013-03-31 06:39:29 -07:00
|
|
|
*aEndOffset = FindWordBoundary(offset, eDirNext, eStartWord);
|
|
|
|
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
|
2013-05-03 07:10:05 -07:00
|
|
|
case BOUNDARY_WORD_END:
|
2013-05-07 02:18:37 -07:00
|
|
|
// Ignore the spec and follow what WebKitGtk does because Orca expects it,
|
|
|
|
// i.e. return a next word at word end offset of the current word
|
|
|
|
// (WebKitGtk behavior) instead the current word (AKT spec).
|
|
|
|
*aEndOffset = FindWordBoundary(offset, eDirNext, eEndWord);
|
|
|
|
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
|
2013-03-31 06:39:29 -07:00
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
2013-03-23 17:57:06 -07:00
|
|
|
|
2013-07-02 05:57:29 -07:00
|
|
|
case BOUNDARY_LINE_START: {
|
2013-07-05 06:00:01 -07:00
|
|
|
// Empty last line doesn't have own frame (a previous line contains '\n'
|
|
|
|
// character instead) thus we can't operate on last line separately
|
|
|
|
// from previous line.
|
2013-07-12 10:34:13 -07:00
|
|
|
if (IsEmptyLastLineOffset(offset)) {
|
|
|
|
*aStartOffset = *aEndOffset = offset;
|
|
|
|
return NS_OK;
|
2013-07-05 06:00:01 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 10:32:07 -07:00
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
|
|
|
|
offset = AdjustCaretOffset(offset);
|
|
|
|
|
2013-07-15 06:01:03 -07:00
|
|
|
// Start offset is begin of the current line (as the home key was
|
|
|
|
// pressed). End offset is begin of the next line if any (arrow down and
|
|
|
|
// home keys), otherwise end of the current line (arrow down only).
|
2013-07-02 05:57:29 -07:00
|
|
|
*aStartOffset = FindLineBoundary(offset, eDirPrevious, eSelectBeginLine);
|
|
|
|
*aEndOffset = FindLineBoundary(offset, eDirNext, eSelectLine);
|
|
|
|
int32_t tmpOffset = FindLineBoundary(*aEndOffset, eDirPrevious, eSelectBeginLine);
|
|
|
|
if (tmpOffset != *aStartOffset)
|
|
|
|
*aEndOffset = tmpOffset;
|
|
|
|
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
|
|
|
|
|
|
|
case BOUNDARY_LINE_END: {
|
2013-07-08 08:26:09 -07:00
|
|
|
// Empty last line doesn't have own frame (a previous line contains '\n'
|
|
|
|
// character instead) thus we can't operate on last line separately
|
|
|
|
// from the previous line.
|
2013-07-12 10:34:13 -07:00
|
|
|
if (IsEmptyLastLineOffset(offset)) {
|
|
|
|
*aStartOffset = offset - 1;
|
|
|
|
*aEndOffset = offset;
|
|
|
|
aText.AssignLiteral("\n");
|
|
|
|
return NS_OK;
|
2013-07-08 08:26:09 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 10:32:07 -07:00
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
|
|
|
|
offset = AdjustCaretOffset(offset);
|
|
|
|
|
2013-07-15 06:01:03 -07:00
|
|
|
// In contrast to word end boundary we follow the spec here.
|
|
|
|
// End offset is end of the current line (as the end key was pressed).
|
|
|
|
// Start offset is end of the previous line if any (up arrow and end keys),
|
|
|
|
// otherwise 0 offset (up arrow only).
|
2013-07-02 05:57:29 -07:00
|
|
|
*aEndOffset = FindLineBoundary(offset, eDirNext, eSelectEndLine);
|
|
|
|
int32_t tmpOffset = FindLineBoundary(offset, eDirPrevious, eSelectLine);
|
|
|
|
*aStartOffset = FindLineBoundary(tmpOffset, eDirNext, eSelectEndLine);
|
|
|
|
if (*aStartOffset == *aEndOffset)
|
|
|
|
*aStartOffset = 0;
|
|
|
|
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
}
|
|
|
|
|
2013-03-31 06:39:29 -07:00
|
|
|
case BOUNDARY_ATTRIBUTE_RANGE:
|
2013-03-23 17:57:06 -07:00
|
|
|
return GetTextHelper(eGetAt, aBoundaryType, aOffset,
|
|
|
|
aStartOffset, aEndOffset, aText);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
NS_IMETHODIMP
|
2013-03-23 17:57:06 -07:00
|
|
|
HyperTextAccessible::GetTextAfterOffset(int32_t aOffset,
|
|
|
|
AccessibleTextBoundary aBoundaryType,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset, nsAString& aText)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-03-23 17:57:06 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2013-05-15 01:26:17 -07:00
|
|
|
int32_t offset = ConvertMagicOffset(aOffset);
|
|
|
|
if (offset < 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2011-02-03 06:29:12 -08:00
|
|
|
|
2013-05-15 01:26:17 -07:00
|
|
|
switch (aBoundaryType) {
|
|
|
|
case BOUNDARY_CHAR:
|
|
|
|
GetCharAt(aOffset, eGetAfter, aText, aStartOffset, aEndOffset);
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
case BOUNDARY_WORD_START:
|
|
|
|
// Move word forward twice to find start and end offsets.
|
|
|
|
*aStartOffset = FindWordBoundary(offset, eDirNext, eStartWord);
|
|
|
|
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eStartWord);
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
|
|
|
|
case BOUNDARY_WORD_END:
|
|
|
|
// If the offset is a word end (except 0 offset) then move forward to find
|
|
|
|
// end offset (start offset is the given offset). Otherwise move forward
|
|
|
|
// twice to find both start and end offsets.
|
|
|
|
if (offset == 0) {
|
|
|
|
*aStartOffset = FindWordBoundary(offset, eDirNext, eEndWord);
|
|
|
|
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord);
|
|
|
|
} else {
|
|
|
|
*aEndOffset = FindWordBoundary(offset, eDirNext, eEndWord);
|
|
|
|
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
|
|
|
|
if (*aStartOffset != offset) {
|
|
|
|
*aStartOffset = *aEndOffset;
|
|
|
|
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
|
|
|
|
case BOUNDARY_LINE_START:
|
2013-07-15 08:56:38 -07:00
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
|
|
|
|
offset = AdjustCaretOffset(offset);
|
|
|
|
|
|
|
|
// Down arrow, home key, down arrow, home key.
|
|
|
|
*aStartOffset = FindLineBoundary(offset, eDirNext, eSelectLine);
|
|
|
|
if (*aStartOffset != CharacterCount()) {
|
|
|
|
*aStartOffset = FindLineBoundary(*aStartOffset, eDirPrevious, eSelectBeginLine);
|
|
|
|
*aEndOffset = FindLineBoundary(*aStartOffset, eDirNext, eSelectLine);
|
|
|
|
if (*aEndOffset != CharacterCount())
|
|
|
|
*aEndOffset = FindLineBoundary(*aEndOffset, eDirPrevious, eSelectBeginLine);
|
|
|
|
} else {
|
|
|
|
*aEndOffset = CharacterCount();
|
|
|
|
}
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
|
2013-05-15 01:26:17 -07:00
|
|
|
case BOUNDARY_LINE_END:
|
2013-07-15 08:56:38 -07:00
|
|
|
if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET)
|
|
|
|
offset = AdjustCaretOffset(offset);
|
|
|
|
|
|
|
|
// Empty last line doesn't have own frame (a previous line contains '\n'
|
|
|
|
// character instead) thus we can't operate on last line separately
|
|
|
|
// from the previous line.
|
|
|
|
if (IsEmptyLastLineOffset(offset)) {
|
|
|
|
*aStartOffset = *aEndOffset = offset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// End key, down arrow, end key.
|
|
|
|
*aStartOffset = FindLineBoundary(offset, eDirNext, eSelectEndLine);
|
|
|
|
*aEndOffset = FindLineBoundary(*aStartOffset, eDirNext, eSelectLine);
|
|
|
|
if (*aEndOffset != CharacterCount())
|
|
|
|
*aEndOffset = FindLineBoundary(*aEndOffset, eDirNext, eSelectEndLine);
|
|
|
|
|
|
|
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
|
|
|
|
2013-05-15 01:26:17 -07:00
|
|
|
case BOUNDARY_ATTRIBUTE_RANGE:
|
|
|
|
return GetTextHelper(eGetAfter, aBoundaryType, aOffset,
|
|
|
|
aStartOffset, aEndOffset, aText);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-07-17 05:06:24 -07:00
|
|
|
// nsIPersistentProperties
|
|
|
|
// nsIAccessibleText::getTextAttributes(in boolean includeDefAttrs,
|
|
|
|
// in long offset,
|
|
|
|
// out long rangeStartOffset,
|
|
|
|
// out long rangeEndOffset);
|
|
|
|
NS_IMETHODIMP
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::GetTextAttributes(bool aIncludeDefAttrs,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aOffset,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
nsIPersistentProperties** aAttributes)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-05-25 01:40:26 -07:00
|
|
|
// 1. Get each attribute and its ranges one after another.
|
2008-07-17 05:06:24 -07:00
|
|
|
// 2. As we get each new attribute, we pass the current start and end offsets
|
|
|
|
// as in/out parameters. In other words, as attributes are collected,
|
|
|
|
// the attribute range itself can only stay the same or get smaller.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-07-17 05:06:24 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
*aStartOffset = 0;
|
|
|
|
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
2010-05-25 01:40:26 -07:00
|
|
|
*aEndOffset = 0;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2010-05-21 04:27:00 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2013-01-12 12:24:13 -08:00
|
|
|
int32_t offset = ConvertMagicOffset(aOffset);
|
|
|
|
|
2008-07-24 08:20:39 -07:00
|
|
|
if (aAttributes) {
|
2012-07-30 07:20:58 -07:00
|
|
|
*aAttributes = nullptr;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2008-07-24 08:20:39 -07:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
|
|
|
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(attributes, NS_ERROR_OUT_OF_MEMORY);
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2008-07-24 08:20:39 -07:00
|
|
|
NS_ADDREF(*aAttributes = attributes);
|
|
|
|
}
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2013-01-12 12:24:13 -08:00
|
|
|
Accessible* accAtOffset = GetChildAtOffset(offset);
|
2010-08-15 04:28:49 -07:00
|
|
|
if (!accAtOffset) {
|
2010-05-25 01:40:26 -07:00
|
|
|
// Offset 0 is correct offset when accessible has empty text. Include
|
|
|
|
// default attributes if they were requested, otherwise return empty set.
|
2013-01-12 12:24:13 -08:00
|
|
|
if (offset == 0) {
|
2010-05-21 04:27:00 -07:00
|
|
|
if (aIncludeDefAttrs) {
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr textAttrsMgr(this);
|
|
|
|
textAttrsMgr.GetAttributes(*aAttributes);
|
2010-05-21 04:27:00 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-05-25 01:40:26 -07:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
2010-05-21 04:27:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t accAtOffsetIdx = accAtOffset->IndexInParent();
|
|
|
|
int32_t startOffset = GetChildOffset(accAtOffsetIdx);
|
|
|
|
int32_t endOffset = GetChildOffset(accAtOffsetIdx + 1);
|
2013-01-12 12:24:13 -08:00
|
|
|
int32_t offsetInAcc = offset - startOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr textAttrsMgr(this, aIncludeDefAttrs, accAtOffset,
|
|
|
|
accAtOffsetIdx);
|
|
|
|
textAttrsMgr.GetAttributes(*aAttributes, &startOffset, &endOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
// Compute spelling attributes on text accessible only.
|
2010-08-15 04:28:49 -07:00
|
|
|
nsIFrame *offsetFrame = accAtOffset->GetFrame();
|
2011-06-03 14:35:17 -07:00
|
|
|
if (offsetFrame && offsetFrame->GetType() == nsGkAtoms::textFrame) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nodeOffset = 0;
|
2010-05-25 01:40:26 -07:00
|
|
|
nsresult rv = RenderedToContentOffset(offsetFrame, offsetInAcc,
|
|
|
|
&nodeOffset);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
// Set 'misspelled' text attribute.
|
2012-03-06 09:08:02 -08:00
|
|
|
rv = GetSpellTextAttribute(accAtOffset->GetNode(), nodeOffset,
|
|
|
|
&startOffset, &endOffset,
|
2012-07-30 07:20:58 -07:00
|
|
|
aAttributes ? *aAttributes : nullptr);
|
2010-05-25 01:40:26 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
*aStartOffset = startOffset;
|
|
|
|
*aEndOffset = endOffset;
|
|
|
|
return NS_OK;
|
2008-07-17 05:06:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsIPersistentProperties
|
|
|
|
// nsIAccessibleText::defaultTextAttributes
|
|
|
|
NS_IMETHODIMP
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::GetDefaultTextAttributes(nsIPersistentProperties** aAttributes)
|
2008-07-17 05:06:24 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAttributes);
|
2012-07-30 07:20:58 -07:00
|
|
|
*aAttributes = nullptr;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2008-07-17 05:06:24 -07:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
|
|
|
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(attributes, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
NS_ADDREF(*aAttributes = attributes);
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr textAttrsMgr(this);
|
|
|
|
textAttrsMgr.GetAttributes(*aAttributes);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::GetLevelInternal()
|
2010-01-06 02:36:50 -08:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
nsIAtom *tag = mContent->Tag();
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::h1)
|
2010-01-06 02:36:50 -08:00
|
|
|
return 1;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::h2)
|
2010-01-06 02:36:50 -08:00
|
|
|
return 2;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::h3)
|
2010-01-06 02:36:50 -08:00
|
|
|
return 3;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::h4)
|
2010-01-06 02:36:50 -08:00
|
|
|
return 4;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::h5)
|
2010-01-06 02:36:50 -08:00
|
|
|
return 5;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (tag == nsGkAtoms::h6)
|
2010-01-06 02:36:50 -08:00
|
|
|
return 6;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return AccessibleWrap::GetLevelInternal();
|
2010-01-06 02:36:50 -08:00
|
|
|
}
|
|
|
|
|
2012-10-19 00:15:23 -07:00
|
|
|
already_AddRefed<nsIPersistentProperties>
|
|
|
|
HyperTextAccessible::NativeAttributes()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-10-19 00:15:23 -07:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
|
|
|
AccessibleWrap::NativeAttributes();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-19 00:15:23 -07:00
|
|
|
// 'formatting' attribute is deprecated, 'display' attribute should be
|
|
|
|
// instead.
|
2007-10-10 08:31:52 -07:00
|
|
|
nsIFrame *frame = GetFrame();
|
2011-06-03 14:35:17 -07:00
|
|
|
if (frame && frame->GetType() == nsGkAtoms::blockFrame) {
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAutoString unused;
|
|
|
|
attributes->SetStringProperty(NS_LITERAL_CSTRING("formatting"),
|
|
|
|
NS_LITERAL_STRING("block"), unused);
|
2007-10-10 08:31:52 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
if (FocusMgr()->IsFocused(this)) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t lineNumber = CaretLineNumber();
|
2007-12-11 06:15:21 -08:00
|
|
|
if (lineNumber >= 1) {
|
|
|
|
nsAutoString strLineNumber;
|
|
|
|
strLineNumber.AppendInt(lineNumber);
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::lineNumber, strLineNumber);
|
2007-12-11 06:15:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-30 19:25:17 -07:00
|
|
|
if (!HasOwnContent())
|
|
|
|
return attributes.forget();
|
|
|
|
|
2010-11-08 05:33:34 -08:00
|
|
|
// For the html landmark elements we expose them like we do aria landmarks to
|
2013-03-29 04:05:39 -07:00
|
|
|
// make AT navigation schemes "just work".
|
|
|
|
nsIAtom* tag = mContent->Tag();
|
|
|
|
if (tag == nsGkAtoms::nav) {
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
2010-11-08 05:33:34 -08:00
|
|
|
NS_LITERAL_STRING("navigation"));
|
2013-03-29 04:05:39 -07:00
|
|
|
} else if (tag == nsGkAtoms::section) {
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
2012-03-28 01:20:50 -07:00
|
|
|
NS_LITERAL_STRING("region"));
|
2013-03-29 04:05:39 -07:00
|
|
|
} else if (tag == nsGkAtoms::header || tag == nsGkAtoms::footer) {
|
|
|
|
// Only map header and footer if they are not descendants
|
|
|
|
// of an article or section tag.
|
|
|
|
nsIContent* parent = mContent->GetParent();
|
|
|
|
while (parent) {
|
|
|
|
if (parent->Tag() == nsGkAtoms::article ||
|
|
|
|
parent->Tag() == nsGkAtoms::section)
|
|
|
|
break;
|
|
|
|
parent = parent->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
// No article or section elements found.
|
|
|
|
if (!parent) {
|
|
|
|
if (tag == nsGkAtoms::header) {
|
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
|
|
|
NS_LITERAL_STRING("banner"));
|
|
|
|
} else if (tag == nsGkAtoms::footer) {
|
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
|
|
|
NS_LITERAL_STRING("contentinfo"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (tag == nsGkAtoms::aside) {
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
2011-07-05 07:28:53 -07:00
|
|
|
NS_LITERAL_STRING("complementary"));
|
2013-03-29 04:05:39 -07:00
|
|
|
} else if (tag == nsGkAtoms::article) {
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
2012-06-11 08:16:48 -07:00
|
|
|
NS_LITERAL_STRING("article"));
|
2013-03-29 04:05:39 -07:00
|
|
|
} else if (tag == nsGkAtoms::main) {
|
2013-01-29 04:31:45 -08:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
|
|
|
|
NS_LITERAL_STRING("main"));
|
2013-03-29 04:05:39 -07:00
|
|
|
}
|
2010-11-08 05:33:34 -08:00
|
|
|
|
2012-10-19 00:15:23 -07:00
|
|
|
return attributes.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given an offset, the x, y, width, and height values are filled appropriately.
|
|
|
|
*/
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetCharacterExtents(int32_t aOffset, int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aWidth, int32_t* aHeight,
|
|
|
|
uint32_t aCoordType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return GetRangeExtents(aOffset, aOffset + 1, aX, aY, aWidth, aHeight, aCoordType);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a start & end offset, the x, y, width, and height values are filled appropriately.
|
|
|
|
*/
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetRangeExtents(int32_t aStartOffset, int32_t aEndOffset,
|
|
|
|
int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aWidth, int32_t* aHeight,
|
|
|
|
uint32_t aCoordType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsIntRect boundsRect;
|
|
|
|
nsIFrame *endFrameUnused;
|
2012-07-30 07:20:58 -07:00
|
|
|
if (!GetPosAndText(aStartOffset, aEndOffset, nullptr, &endFrameUnused, &boundsRect) ||
|
2007-06-14 10:12:50 -07:00
|
|
|
boundsRect.IsEmpty()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aX = boundsRect.x;
|
|
|
|
*aY = boundsRect.y;
|
|
|
|
*aWidth = boundsRect.width;
|
|
|
|
*aHeight = boundsRect.height;
|
|
|
|
|
2012-12-17 12:11:02 -08:00
|
|
|
nsAccUtils::ConvertScreenCoordsTo(aX, aY, aCoordType, this);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the offset of the character located at coordinates x and y. x and y are interpreted as being relative to
|
|
|
|
* the screen or this widget's window depending on coords.
|
|
|
|
*/
|
2007-04-23 05:00:45 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetOffsetAtPoint(int32_t aX, int32_t aY,
|
|
|
|
uint32_t aCoordType, int32_t* aOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aOffset = -1;
|
2012-02-07 14:38:54 -08:00
|
|
|
|
2012-04-10 20:42:42 -07:00
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-04-10 20:42:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame *hyperFrame = GetFrame();
|
|
|
|
if (!hyperFrame) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-12-17 12:11:02 -08:00
|
|
|
nsIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordType,
|
|
|
|
this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-20 02:03:48 -07:00
|
|
|
nsPresContext* presContext = mDoc->PresContext();
|
|
|
|
nsPoint coordsInAppUnits =
|
|
|
|
coords.ToAppUnits(presContext->AppUnitsPerDevPixel());
|
|
|
|
|
|
|
|
nsRect frameScreenRect = hyperFrame->GetScreenRectInAppUnits();
|
|
|
|
if (!frameScreenRect.Contains(coordsInAppUnits.x, coordsInAppUnits.y))
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK; // Not found, will return -1
|
2012-10-20 02:03:48 -07:00
|
|
|
|
|
|
|
nsPoint pointInHyperText(coordsInAppUnits.x - frameScreenRect.x,
|
|
|
|
coordsInAppUnits.y - frameScreenRect.y);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Go through the frames to check if each one has the point.
|
|
|
|
// When one does, add up the character offsets until we have a match
|
|
|
|
|
|
|
|
// We have an point in an accessible child of this, now we need to add up the
|
|
|
|
// offsets before it to what we already have
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t offset = 0;
|
|
|
|
uint32_t childCount = ChildCount();
|
|
|
|
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* childAcc = mChildren[childIdx];
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-19 06:39:57 -07:00
|
|
|
nsIFrame *primaryFrame = childAcc->GetFrame();
|
2007-08-20 21:24:21 -07:00
|
|
|
NS_ENSURE_TRUE(primaryFrame, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsIFrame *frame = primaryFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
while (frame) {
|
|
|
|
nsIContent *content = frame->GetContent();
|
|
|
|
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
2012-10-20 02:03:48 -07:00
|
|
|
nsPoint pointInFrame = pointInHyperText - frame->GetOffsetTo(hyperFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize frameSize = frame->GetSize();
|
|
|
|
if (pointInFrame.x < frameSize.width && pointInFrame.y < frameSize.height) {
|
|
|
|
// Finished
|
2011-06-03 14:35:17 -07:00
|
|
|
if (frame->GetType() == nsGkAtoms::textFrame) {
|
2012-05-29 06:13:36 -07:00
|
|
|
nsIFrame::ContentOffsets contentOffsets =
|
|
|
|
frame->GetContentOffsetsFromPointExternal(pointInFrame, nsIFrame::IGNORE_SELECTION_STYLE);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (contentOffsets.IsNull() || contentOffsets.content != content) {
|
|
|
|
return NS_OK; // Not found, will return -1
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t addToOffset;
|
2007-08-20 21:24:21 -07:00
|
|
|
nsresult rv = ContentToRenderedOffset(primaryFrame,
|
|
|
|
contentOffsets.offset,
|
|
|
|
&addToOffset);
|
2007-08-03 18:12:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
offset += addToOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
*aOffset = offset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
frame = frame->GetNextContinuation();
|
|
|
|
}
|
2010-05-25 01:40:54 -07:00
|
|
|
|
|
|
|
offset += nsAccUtils::TextLength(childAcc);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK; // Not found, will return -1
|
|
|
|
}
|
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleHyperText
|
|
|
|
|
2008-04-11 00:22:32 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetLinkCount(int32_t* aLinkCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-04-11 00:22:32 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aLinkCount);
|
|
|
|
*aLinkCount = 0;
|
2010-06-21 06:08:27 -07:00
|
|
|
|
2010-04-19 06:39:57 -07:00
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
*aLinkCount = GetLinkCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-29 20:24:02 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetLinkAt(int32_t aIndex, nsIAccessibleHyperLink** aLink)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-29 20:24:02 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aLink);
|
2012-07-30 07:20:58 -07:00
|
|
|
*aLink = nullptr;
|
2008-03-29 20:24:02 -07:00
|
|
|
|
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* link = GetLinkAt(aIndex);
|
2010-06-21 06:08:27 -07:00
|
|
|
if (link)
|
|
|
|
CallQueryInterface(link, aLink);
|
2010-04-19 06:39:57 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::GetLinkIndex(nsIAccessibleHyperLink* aLink,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aIndex)
|
2010-06-21 06:08:27 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLink);
|
2008-03-29 20:24:02 -07:00
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> link(do_QueryObject(aLink));
|
2010-06-21 06:08:27 -07:00
|
|
|
*aIndex = GetLinkIndex(link);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-04-11 00:22:32 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetLinkIndexAtOffset(int32_t aOffset, int32_t* aLinkIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-04-11 00:22:32 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aLinkIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
*aLinkIndex = -1; // API says this magic value means 'not found'
|
|
|
|
|
2010-04-19 06:39:57 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
*aLinkIndex = GetLinkIndexAtOffset(aOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsIAccessibleEditableText impl.
|
|
|
|
*/
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::SetAttributes(int32_t aStartPos, int32_t aEndPos,
|
2012-05-31 01:04:41 -07:00
|
|
|
nsISupports* aAttributes)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HyperTextAccessible::SetTextContents(const nsAString& aText)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t numChars = CharacterCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (numChars == 0 || NS_SUCCEEDED(DeleteText(0, numChars))) {
|
|
|
|
return InsertText(aText, 0);
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::InsertText(const nsAString& aText, int32_t aPosition)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-03-07 19:28:38 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
nsCOMPtr<nsIPlaintextEditor> peditor(do_QueryInterface(editor));
|
|
|
|
NS_ENSURE_STATE(peditor);
|
|
|
|
|
|
|
|
nsresult rv = SetSelectionRange(aPosition, aPosition);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return peditor->InsertText(aText);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::CopyText(int32_t aStartPos, int32_t aEndPos)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-03-07 19:28:38 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_ENSURE_STATE(editor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
nsresult rv = SetSelectionRange(aStartPos, aEndPos);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return editor->Copy();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::CutText(int32_t aStartPos, int32_t aEndPos)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-03-07 19:28:38 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_ENSURE_STATE(editor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
nsresult rv = SetSelectionRange(aStartPos, aEndPos);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return editor->Cut();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::DeleteText(int32_t aStartPos, int32_t aEndPos)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-03-07 19:28:38 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_ENSURE_STATE(editor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
nsresult rv = SetSelectionRange(aStartPos, aEndPos);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-05-10 07:54:33 -07:00
|
|
|
return editor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::PasteText(int32_t aPosition)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-03-07 19:28:38 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_ENSURE_STATE(editor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
nsresult rv = SetSelectionRange(aPosition, aPosition);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return editor->Paste(nsIClipboard::kGlobalClipboard);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 19:28:38 -08:00
|
|
|
already_AddRefed<nsIEditor>
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::GetEditor() const
|
2007-07-05 10:12:28 -07:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
if (!mContent->HasFlag(NODE_IS_EDITABLE)) {
|
2007-09-05 21:18:22 -07:00
|
|
|
// If we're inside an editable container, then return that container's editor
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* ancestor = Parent();
|
2012-03-07 19:28:38 -08:00
|
|
|
while (ancestor) {
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible* hyperText = ancestor->AsHyperText();
|
2012-03-07 19:28:38 -08:00
|
|
|
if (hyperText) {
|
2007-09-05 21:18:22 -07:00
|
|
|
// Recursion will stop at container doc because it has its own impl
|
2012-03-07 19:28:38 -08:00
|
|
|
// of GetEditor()
|
|
|
|
return hyperText->GetEditor();
|
2007-09-05 21:18:22 -07:00
|
|
|
}
|
2012-03-07 19:28:38 -08:00
|
|
|
|
|
|
|
ancestor = ancestor->Parent();
|
2007-09-05 21:18:22 -07:00
|
|
|
}
|
2012-03-07 19:28:38 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-08-14 09:25:24 -07:00
|
|
|
}
|
|
|
|
|
2013-02-12 14:02:51 -08:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = nsCoreUtils::GetDocShellFor(mContent);
|
|
|
|
nsCOMPtr<nsIEditingSession> editingSession(do_GetInterface(docShell));
|
2007-08-14 09:25:24 -07:00
|
|
|
if (!editingSession)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr; // No editing session interface
|
2007-08-14 09:25:24 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIEditor> editor;
|
2012-10-11 19:25:34 -07:00
|
|
|
nsIDocument* docNode = mDoc->DocumentNode();
|
2012-03-07 19:28:38 -08:00
|
|
|
editingSession->GetEditorForWindow(docNode->GetWindow(),
|
|
|
|
getter_AddRefs(editor));
|
|
|
|
return editor.forget();
|
2007-07-05 10:12:28 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* =================== Caret & Selection ======================
|
|
|
|
*/
|
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::SetSelectionRange(int32_t aStartPos, int32_t aEndPos)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-11-03 05:08:09 -07:00
|
|
|
// Before setting the selection range, we need to ensure that the editor
|
|
|
|
// is initialized. (See bug 804927.)
|
|
|
|
// Otherwise, it's possible that lazy editor initialization will override
|
|
|
|
// the selection we set here and leave the caret at the end of the text.
|
|
|
|
// By calling GetEditor here, we ensure that editor initialization is
|
|
|
|
// completed before we set the selection.
|
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
|
|
|
|
2012-06-03 22:41:06 -07:00
|
|
|
bool isFocusable = InteractiveState() & states::FOCUSABLE;
|
2012-02-07 20:31:18 -08:00
|
|
|
|
|
|
|
// If accessible is focusable then focus it before setting the selection to
|
|
|
|
// neglect control's selection changes on focus if any (for example, inputs
|
|
|
|
// that do select all on focus).
|
|
|
|
// some input controls
|
|
|
|
if (isFocusable)
|
|
|
|
TakeFocus();
|
2010-02-20 16:50:50 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Set the selection
|
2010-02-20 16:50:50 -08:00
|
|
|
SetSelectionBounds(0, aStartPos, aEndPos);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// If range 0 was successfully set, clear any additional selection
|
|
|
|
// ranges remaining from previous selection
|
2011-10-12 00:39:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
NS_ENSURE_STATE(frameSelection);
|
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
Selection* domSel =
|
2011-10-12 00:39:58 -07:00
|
|
|
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
|
|
|
NS_ENSURE_STATE(domSel);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t idx = domSel->GetRangeCount() - 1; idx > 0; idx--)
|
2012-04-06 17:09:31 -07:00
|
|
|
domSel->RemoveRange(domSel->GetRangeAt(idx));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-07 20:31:18 -08:00
|
|
|
// When selection is done, move the focus to the selection if accessible is
|
|
|
|
// not focusable. That happens when selection is set within hypertext
|
|
|
|
// accessible.
|
|
|
|
if (isFocusable)
|
|
|
|
return NS_OK;
|
|
|
|
|
2011-10-15 20:38:19 -07:00
|
|
|
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
|
|
|
|
if (DOMFocusManager) {
|
2012-02-07 14:38:54 -08:00
|
|
|
NS_ENSURE_TRUE(mDoc, NS_ERROR_FAILURE);
|
2012-10-11 19:25:34 -07:00
|
|
|
nsIDocument* docNode = mDoc->DocumentNode();
|
2012-02-07 14:38:54 -08:00
|
|
|
NS_ENSURE_TRUE(docNode, NS_ERROR_FAILURE);
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = docNode->GetWindow();
|
2011-10-15 20:38:19 -07:00
|
|
|
nsCOMPtr<nsIDOMElement> result;
|
2012-07-30 07:20:58 -07:00
|
|
|
DOMFocusManager->MoveFocus(window, nullptr, nsIFocusManager::MOVEFOCUS_CARET,
|
2011-10-15 20:38:19 -07:00
|
|
|
nsIFocusManager::FLAG_BYMOVEFOCUS, getter_AddRefs(result));
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-02-20 16:50:50 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::SetCaretOffset(int32_t aCaretOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return SetSelectionRange(aCaretOffset, aCaretOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the offset position of the caret (cursor).
|
|
|
|
*/
|
2008-12-16 02:14:20 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetCaretOffset(int32_t* aCaretOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-02-12 19:37:52 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aCaretOffset);
|
2008-12-16 02:14:20 -08:00
|
|
|
*aCaretOffset = -1;
|
|
|
|
|
2012-02-15 07:11:00 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-02-12 19:37:52 -08:00
|
|
|
// Not focused focusable accessible except document accessible doesn't have
|
|
|
|
// a caret.
|
|
|
|
if (!IsDoc() && !FocusMgr()->IsFocused(this) &&
|
2012-06-03 22:41:06 -07:00
|
|
|
(InteractiveState() & states::FOCUSABLE)) {
|
2012-02-12 19:37:52 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-12-16 02:14:20 -08:00
|
|
|
// No caret if the focused node is not inside this DOM node and this DOM node
|
|
|
|
// is not inside of focused node.
|
2011-09-27 18:46:11 -07:00
|
|
|
FocusManager::FocusDisposition focusDisp =
|
|
|
|
FocusMgr()->IsInOrContainsFocus(this);
|
|
|
|
if (focusDisp == FocusManager::eNone)
|
2008-12-16 02:14:20 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-12-16 02:14:20 -08:00
|
|
|
// Turn the focus node and offset of the selection into caret hypretext
|
|
|
|
// offset.
|
2011-10-12 00:39:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
NS_ENSURE_STATE(frameSelection);
|
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
Selection* domSel =
|
2011-10-12 00:39:58 -07:00
|
|
|
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
|
|
|
NS_ENSURE_STATE(domSel);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
nsINode* focusNode = domSel->GetFocusNode();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t focusOffset = domSel->GetFocusOffset();
|
2008-12-16 02:14:20 -08:00
|
|
|
|
|
|
|
// No caret if this DOM node is inside of focused node but the selection's
|
|
|
|
// focus point is not inside of this DOM node.
|
2011-09-27 18:46:11 -07:00
|
|
|
if (focusDisp == FocusManager::eContainedByFocus) {
|
2010-05-25 01:12:43 -07:00
|
|
|
nsINode *resultNode =
|
2008-12-16 02:14:20 -08:00
|
|
|
nsCoreUtils::GetDOMNodeFromDOMPoint(focusNode, focusOffset);
|
2010-01-27 03:43:25 -08:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
nsINode* thisNode = GetNode();
|
2010-01-27 03:43:25 -08:00
|
|
|
if (resultNode != thisNode &&
|
|
|
|
!nsCoreUtils::IsAncestorOf(thisNode, resultNode))
|
2008-12-16 02:14:20 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
DOMPointToHypertextOffset(focusNode, focusOffset, aCaretOffset);
|
2010-05-17 09:16:52 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::CaretLineNumber()
|
2007-12-11 06:15:21 -08:00
|
|
|
{
|
|
|
|
// Provide the line number for the caret, relative to the
|
|
|
|
// currently focused node. Use a 1-based index
|
2011-10-12 00:39:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
if (!frameSelection)
|
|
|
|
return -1;
|
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
Selection* domSel =
|
2011-10-12 00:39:58 -07:00
|
|
|
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
|
|
|
if (!domSel)
|
|
|
|
return - 1;
|
2007-12-11 06:15:21 -08:00
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
nsINode* caretNode = domSel->GetFocusNode();
|
|
|
|
if (!caretNode || !caretNode->IsContent())
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
nsIContent* caretContent = caretNode->AsContent();
|
|
|
|
if (!nsCoreUtils::IsAncestorOf(GetNode(), caretContent))
|
2007-12-11 06:15:21 -08:00
|
|
|
return -1;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t returnOffsetUnused;
|
|
|
|
int32_t caretOffset = domSel->GetFocusOffset();
|
2007-12-11 06:15:21 -08:00
|
|
|
nsFrameSelection::HINT hint = frameSelection->GetHint();
|
|
|
|
nsIFrame *caretFrame = frameSelection->GetFrameForNodeOffset(caretContent, caretOffset,
|
|
|
|
hint, &returnOffsetUnused);
|
|
|
|
NS_ENSURE_TRUE(caretFrame, -1);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t lineNumber = 1;
|
2008-10-30 12:17:59 -07:00
|
|
|
nsAutoLineIterator lineIterForCaret;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIContent *hyperTextContent = IsContent() ? mContent.get() : nullptr;
|
2007-12-11 06:15:21 -08:00
|
|
|
while (caretFrame) {
|
|
|
|
if (hyperTextContent == caretFrame->GetContent()) {
|
|
|
|
return lineNumber; // Must be in a single line hyper text, there is no line iterator
|
|
|
|
}
|
|
|
|
nsIFrame *parentFrame = caretFrame->GetParent();
|
|
|
|
if (!parentFrame)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Add lines for the sibling frames before the caret
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame *sibling = parentFrame->GetFirstPrincipalChild();
|
2007-12-11 06:15:21 -08:00
|
|
|
while (sibling && sibling != caretFrame) {
|
2008-10-30 12:17:59 -07:00
|
|
|
nsAutoLineIterator lineIterForSibling = sibling->GetLineIterator();
|
2007-12-11 06:15:21 -08:00
|
|
|
if (lineIterForSibling) {
|
|
|
|
// For the frames before that grab all the lines
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t addLines = lineIterForSibling->GetNumLines();
|
2007-12-11 06:15:21 -08:00
|
|
|
lineNumber += addLines;
|
|
|
|
}
|
|
|
|
sibling = sibling->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the line number relative to the container with lines
|
|
|
|
if (!lineIterForCaret) { // Add the caret line just once
|
2008-10-30 12:17:59 -07:00
|
|
|
lineIterForCaret = parentFrame->GetLineIterator();
|
2007-12-11 06:15:21 -08:00
|
|
|
if (lineIterForCaret) {
|
|
|
|
// Ancestor of caret
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t addLines = lineIterForCaret->FindLineContaining(caretFrame);
|
2007-12-11 06:15:21 -08:00
|
|
|
lineNumber += addLines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
caretFrame = parentFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NOTREACHED("DOM ancestry had this hypertext but frame ancestry didn't");
|
|
|
|
return lineNumber;
|
|
|
|
}
|
|
|
|
|
2011-10-12 00:39:58 -07:00
|
|
|
already_AddRefed<nsFrameSelection>
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::FrameSelection()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-12 00:39:58 -07:00
|
|
|
nsIFrame* frame = GetFrame();
|
2012-07-30 07:20:58 -07:00
|
|
|
return frame ? frame->GetFrameSelection() : nullptr;
|
2011-10-12 00:39:58 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-12 00:39:58 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetSelectionDOMRanges(int16_t aType,
|
2012-05-31 01:04:41 -07:00
|
|
|
nsTArray<nsRange*>* aRanges)
|
2011-10-12 00:39:58 -07:00
|
|
|
{
|
2013-04-22 01:10:09 -07:00
|
|
|
// Ignore selection if it is not visible.
|
2011-10-12 00:39:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
2013-04-22 01:10:09 -07:00
|
|
|
if (!frameSelection ||
|
|
|
|
frameSelection->GetDisplaySelection() <= nsISelectionController::SELECTION_HIDDEN)
|
2011-10-12 00:39:58 -07:00
|
|
|
return;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
Selection* domSel = frameSelection->GetSelection(aType);
|
2011-10-12 00:39:58 -07:00
|
|
|
if (!domSel)
|
|
|
|
return;
|
2007-09-18 15:28:26 -07:00
|
|
|
|
2011-10-12 00:39:58 -07:00
|
|
|
nsCOMPtr<nsINode> startNode = GetNode();
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2012-03-07 19:28:38 -08:00
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
2011-10-12 00:39:58 -07:00
|
|
|
if (editor) {
|
|
|
|
nsCOMPtr<nsIDOMElement> editorRoot;
|
|
|
|
editor->GetRootElement(getter_AddRefs(editorRoot));
|
|
|
|
startNode = do_QueryInterface(editorRoot);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!startNode)
|
|
|
|
return;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = startNode->GetChildCount();
|
2012-04-06 17:09:31 -07:00
|
|
|
nsresult rv = domSel->
|
2012-01-10 06:19:54 -08:00
|
|
|
GetRangesForIntervalArray(startNode, 0, startNode, childCount, true, aRanges);
|
2012-09-14 03:00:31 -07:00
|
|
|
NS_ENSURE_SUCCESS_VOID(rv);
|
2011-10-12 00:39:58 -07:00
|
|
|
|
|
|
|
// Remove collapsed ranges
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t numRanges = aRanges->Length();
|
|
|
|
for (uint32_t idx = 0; idx < numRanges; idx ++) {
|
2012-03-06 09:08:02 -08:00
|
|
|
if ((*aRanges)[idx]->Collapsed()) {
|
|
|
|
aRanges->RemoveElementAt(idx);
|
2011-10-12 00:39:58 -07:00
|
|
|
--numRanges;
|
2012-03-06 09:08:02 -08:00
|
|
|
--idx;
|
2007-09-18 15:28:26 -07:00
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the number of selected regions.
|
|
|
|
*/
|
2011-10-12 00:39:58 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetSelectionCount(int32_t* aSelectionCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-12 00:39:58 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aSelectionCount);
|
|
|
|
*aSelectionCount = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-10 06:19:54 -08:00
|
|
|
nsTArray<nsRange*> ranges;
|
2011-10-12 00:39:58 -07:00
|
|
|
GetSelectionDOMRanges(nsISelectionController::SELECTION_NORMAL, &ranges);
|
2012-08-22 08:56:38 -07:00
|
|
|
*aSelectionCount = int32_t(ranges.Length());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-18 15:28:26 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets the start and end offset of the specified selection.
|
|
|
|
*/
|
2011-10-12 00:39:58 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetSelectionBounds(int32_t aSelectionNum,
|
|
|
|
int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-12 00:39:58 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aStartOffset);
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
*aStartOffset = *aEndOffset = 0;
|
|
|
|
|
2012-01-10 06:19:54 -08:00
|
|
|
nsTArray<nsRange*> ranges;
|
2011-10-12 00:39:58 -07:00
|
|
|
GetSelectionDOMRanges(nsISelectionController::SELECTION_NORMAL, &ranges);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t rangeCount = ranges.Length();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aSelectionNum < 0 || aSelectionNum >= rangeCount)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2012-01-10 06:19:54 -08:00
|
|
|
nsRange* range = ranges[aSelectionNum];
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-06 09:08:02 -08:00
|
|
|
// Get start and end points.
|
|
|
|
nsINode* startNode = range->GetStartParent();
|
|
|
|
nsINode* endNode = range->GetEndParent();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startOffset = range->StartOffset(), endOffset = range->EndOffset();
|
2012-03-06 09:08:02 -08:00
|
|
|
|
|
|
|
// Make sure start is before end, by swapping DOM points. This occurs when
|
|
|
|
// the user selects backwards in the text.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rangeCompare = nsContentUtils::ComparePoints(endNode, endOffset,
|
2012-03-06 09:08:02 -08:00
|
|
|
startNode, startOffset);
|
|
|
|
if (rangeCompare < 0) {
|
|
|
|
nsINode* tempNode = startNode;
|
|
|
|
startNode = endNode;
|
|
|
|
endNode = tempNode;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t tempOffset = startOffset;
|
2007-09-18 15:28:26 -07:00
|
|
|
startOffset = endOffset;
|
|
|
|
endOffset = tempOffset;
|
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* startAccessible =
|
2010-05-17 09:16:52 -07:00
|
|
|
DOMPointToHypertextOffset(startNode, startOffset, aStartOffset);
|
2007-09-18 15:28:26 -07:00
|
|
|
if (!startAccessible) {
|
|
|
|
*aStartOffset = 0; // Could not find start point within this hypertext, so starts before
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-09-18 15:28:26 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
DOMPointToHypertextOffset(endNode, endOffset, aEndOffset, true);
|
2010-05-17 09:16:52 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Changes the start and end offset of the specified selection.
|
|
|
|
*/
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::SetSelectionBounds(int32_t aSelectionNum,
|
|
|
|
int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-04-06 17:09:31 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (aSelectionNum < 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2013-01-12 12:24:13 -08:00
|
|
|
int32_t startOffset = ConvertMagicOffset(aStartOffset);
|
|
|
|
int32_t endOffset = ConvertMagicOffset(aEndOffset);
|
|
|
|
|
2011-10-12 00:39:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
NS_ENSURE_STATE(frameSelection);
|
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
Selection* domSel =
|
2011-10-12 00:39:58 -07:00
|
|
|
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
|
|
|
NS_ENSURE_STATE(domSel);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t rangeCount = domSel->GetRangeCount();
|
|
|
|
if (rangeCount < static_cast<uint32_t>(aSelectionNum))
|
2012-04-06 17:09:31 -07:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
nsRefPtr<nsRange> range;
|
|
|
|
if (aSelectionNum == rangeCount)
|
2013-02-07 04:09:41 -08:00
|
|
|
range = new nsRange(mContent);
|
2012-04-06 17:09:31 -07:00
|
|
|
else
|
|
|
|
range = domSel->GetRangeAt(aSelectionNum);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-12 12:24:13 -08:00
|
|
|
nsresult rv = HypertextOffsetsToDOMRange(startOffset, endOffset, range);
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-12 00:39:58 -07:00
|
|
|
// If new range was created then add it, otherwise notify selection listeners
|
|
|
|
// that existing selection range was changed.
|
|
|
|
if (aSelectionNum == rangeCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
return domSel->AddRange(range);
|
2011-10-12 00:39:58 -07:00
|
|
|
|
|
|
|
domSel->RemoveRange(range);
|
|
|
|
domSel->AddRange(range);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Adds a selection bounded by the specified offsets.
|
|
|
|
*/
|
2011-10-12 00:39:58 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::AddSelection(int32_t aStartOffset, int32_t aEndOffset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-12 00:39:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
NS_ENSURE_STATE(frameSelection);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
Selection* domSel =
|
2011-10-12 00:39:58 -07:00
|
|
|
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
|
|
|
NS_ENSURE_STATE(domSel);
|
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
return SetSelectionBounds(domSel->GetRangeCount(), aStartOffset, aEndOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Removes the specified selection.
|
|
|
|
*/
|
2011-10-12 00:39:58 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::RemoveSelection(int32_t aSelectionNum)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-12 00:39:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
|
|
|
|
NS_ENSURE_STATE(frameSelection);
|
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
Selection* domSel =
|
2011-10-12 00:39:58 -07:00
|
|
|
frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
|
|
|
NS_ENSURE_STATE(domSel);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
if (aSelectionNum < 0 || aSelectionNum >= domSel->GetRangeCount())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2012-04-06 17:09:31 -07:00
|
|
|
return domSel->RemoveRange(domSel->GetRangeAt(aSelectionNum));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-09-24 22:48:51 -07:00
|
|
|
// void nsIAccessibleText::
|
|
|
|
// scrollSubstringTo(in long startIndex, in long endIndex,
|
|
|
|
// in unsigned long scrollType);
|
2007-08-23 21:54:45 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::ScrollSubstringTo(int32_t aStartIndex, int32_t aEndIndex,
|
|
|
|
uint32_t aScrollType)
|
2007-08-23 21:54:45 -07:00
|
|
|
{
|
2012-04-06 11:08:24 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2013-02-07 04:09:41 -08:00
|
|
|
nsRefPtr<nsRange> range = new nsRange(mContent);
|
2012-04-06 11:08:24 -07:00
|
|
|
nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-08-23 21:54:45 -07:00
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
return nsCoreUtils::ScrollSubstringTo(GetFrame(), range, aScrollType);
|
2007-09-24 22:48:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// void nsIAccessibleText::
|
|
|
|
// scrollSubstringToPoint(in long startIndex, in long endIndex,
|
|
|
|
// in unsigned long coordinateType,
|
|
|
|
// in long x, in long y);
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartIndex,
|
|
|
|
int32_t aEndIndex,
|
|
|
|
uint32_t aCoordinateType,
|
|
|
|
int32_t aX, int32_t aY)
|
2007-09-24 22:48:51 -07:00
|
|
|
{
|
|
|
|
nsIFrame *frame = GetFrame();
|
|
|
|
if (!frame)
|
2007-08-23 21:54:45 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-12-17 12:11:02 -08:00
|
|
|
nsIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
|
|
|
|
this);
|
2007-08-23 21:54:45 -07:00
|
|
|
|
2013-02-07 04:09:41 -08:00
|
|
|
nsRefPtr<nsRange> range = new nsRange(mContent);
|
2012-12-17 12:11:02 -08:00
|
|
|
nsresult rv = HypertextOffsetsToDOMRange(aStartIndex, aEndIndex, range);
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-08-23 21:54:45 -07:00
|
|
|
|
2012-10-20 18:38:15 -07:00
|
|
|
nsPresContext* presContext = frame->PresContext();
|
|
|
|
nsPoint coordsInAppUnits =
|
|
|
|
coords.ToAppUnits(presContext->AppUnitsPerDevPixel());
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool initialScrolled = false;
|
2007-09-24 22:48:51 -07:00
|
|
|
nsIFrame *parentFrame = frame;
|
2008-02-08 01:35:42 -08:00
|
|
|
while ((parentFrame = parentFrame->GetParent())) {
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIScrollableFrame *scrollableFrame = do_QueryFrame(parentFrame);
|
2007-09-24 22:48:51 -07:00
|
|
|
if (scrollableFrame) {
|
|
|
|
if (!initialScrolled) {
|
|
|
|
// Scroll substring to the given point. Turn the point into percents
|
2008-10-15 18:52:58 -07:00
|
|
|
// relative scrollable area to use nsCoreUtils::ScrollSubstringTo.
|
2012-10-20 18:38:15 -07:00
|
|
|
nsRect frameRect = parentFrame->GetScreenRectInAppUnits();
|
|
|
|
nscoord offsetPointX = coordsInAppUnits.x - frameRect.x;
|
|
|
|
nscoord offsetPointY = coordsInAppUnits.y - frameRect.y;
|
2007-09-24 22:48:51 -07:00
|
|
|
|
|
|
|
nsSize size(parentFrame->GetSize());
|
2009-11-10 06:07:19 -08:00
|
|
|
|
|
|
|
// avoid divide by zero
|
|
|
|
size.width = size.width ? size.width : 1;
|
|
|
|
size.height = size.height ? size.height : 1;
|
|
|
|
|
2012-10-20 18:38:15 -07:00
|
|
|
int16_t hPercent = offsetPointX * 100 / size.width;
|
|
|
|
int16_t vPercent = offsetPointY * 100 / size.height;
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
rv = nsCoreUtils::ScrollSubstringTo(frame, range, vPercent, hPercent);
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
initialScrolled = true;
|
2007-09-24 22:48:51 -07:00
|
|
|
} else {
|
|
|
|
// Substring was scrolled to the given point already inside its closest
|
|
|
|
// scrollable area. If there are nested scrollable areas then make
|
|
|
|
// sure we scroll lower areas to the given point inside currently
|
|
|
|
// traversed scrollable area.
|
2008-10-15 18:52:58 -07:00
|
|
|
nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
|
2007-09-24 22:48:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
frame = parentFrame;
|
2007-08-23 21:54:45 -07:00
|
|
|
}
|
|
|
|
|
2007-09-24 22:48:51 -07:00
|
|
|
return NS_OK;
|
2007-08-23 21:54:45 -07:00
|
|
|
}
|
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible public
|
2010-06-21 06:08:27 -07:00
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
// Accessible protected
|
|
|
|
ENameValueFlag
|
|
|
|
HyperTextAccessible::NativeName(nsString& aName)
|
2011-11-24 03:31:25 -08:00
|
|
|
{
|
2013-06-12 02:13:34 -07:00
|
|
|
// Check @alt attribute for invalid img elements.
|
|
|
|
bool hasImgAlt = false;
|
|
|
|
if (mContent->IsHTML(nsGkAtoms::img)) {
|
|
|
|
hasImgAlt = mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName);
|
|
|
|
if (!aName.IsEmpty())
|
|
|
|
return eNameOK;
|
|
|
|
}
|
|
|
|
|
2012-10-16 23:38:16 -07:00
|
|
|
ENameValueFlag nameFlag = AccessibleWrap::NativeName(aName);
|
|
|
|
if (!aName.IsEmpty())
|
|
|
|
return nameFlag;
|
2011-11-24 03:31:25 -08:00
|
|
|
|
|
|
|
// Get name from title attribute for HTML abbr and acronym elements making it
|
|
|
|
// a valid name from markup. Otherwise their name isn't picked up by recursive
|
|
|
|
// name computation algorithm. See NS_OK_NAME_FROM_TOOLTIP.
|
2012-10-16 23:38:16 -07:00
|
|
|
if (IsAbbreviation() &&
|
2012-10-13 21:18:39 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName))
|
|
|
|
aName.CompressWhitespace();
|
|
|
|
|
2013-06-12 02:13:34 -07:00
|
|
|
return hasImgAlt ? eNoNameOnPurpose : eNameOK;
|
2011-11-24 03:31:25 -08:00
|
|
|
}
|
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
void
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::InvalidateChildren()
|
2010-06-21 06:08:27 -07:00
|
|
|
{
|
2010-07-01 18:50:03 -07:00
|
|
|
mOffsets.Clear();
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap::InvalidateChildren();
|
2010-06-21 06:08:27 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::RemoveChild(Accessible* aAccessible)
|
2011-02-02 09:02:48 -08:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t childIndex = aAccessible->IndexInParent();
|
|
|
|
int32_t count = mOffsets.Length() - childIndex;
|
2011-02-02 09:02:48 -08:00
|
|
|
if (count > 0)
|
|
|
|
mOffsets.RemoveElementsAt(childIndex, count);
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return Accessible::RemoveChild(aAccessible);
|
2011-02-02 09:02:48 -08:00
|
|
|
}
|
|
|
|
|
2010-06-21 06:08:27 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-31 01:04:41 -07:00
|
|
|
// HyperTextAccessible public static
|
2010-06-21 06:08:27 -07:00
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::ContentToRenderedOffset(nsIFrame* aFrame, int32_t aContentOffset,
|
|
|
|
uint32_t* aRenderedOffset)
|
2007-08-03 18:12:24 -07:00
|
|
|
{
|
2007-11-27 10:12:15 -08:00
|
|
|
if (!aFrame) {
|
|
|
|
// Current frame not rendered -- this can happen if text is set on
|
|
|
|
// something with display: none
|
|
|
|
*aRenderedOffset = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-04-05 01:15:26 -07:00
|
|
|
|
|
|
|
if (IsTextField()) {
|
|
|
|
*aRenderedOffset = aContentOffset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
NS_ASSERTION(aFrame->GetType() == nsGkAtoms::textFrame,
|
2007-09-05 06:31:33 -07:00
|
|
|
"Need text frame for offset conversion");
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(aFrame->GetPrevContinuation() == nullptr,
|
2007-09-05 06:31:33 -07:00
|
|
|
"Call on primary frame only");
|
|
|
|
|
2007-08-03 18:12:24 -07:00
|
|
|
gfxSkipChars skipChars;
|
|
|
|
gfxSkipCharsIterator iter;
|
2009-01-11 10:46:17 -08:00
|
|
|
// Only get info up to original offset, we know that will be larger than skipped offset
|
2012-07-30 07:20:58 -07:00
|
|
|
nsresult rv = aFrame->GetRenderedText(nullptr, &skipChars, &iter, 0, aContentOffset);
|
2007-08-03 18:12:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t ourRenderedStart = iter.GetSkippedOffset();
|
|
|
|
int32_t ourContentStart = iter.GetOriginalOffset();
|
2007-08-03 18:12:24 -07:00
|
|
|
|
|
|
|
*aRenderedOffset = iter.ConvertOriginalToSkipped(aContentOffset + ourContentStart) -
|
|
|
|
ourRenderedStart;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::RenderedToContentOffset(nsIFrame* aFrame, uint32_t aRenderedOffset,
|
|
|
|
int32_t* aContentOffset)
|
2007-08-03 18:12:24 -07:00
|
|
|
{
|
2013-04-05 01:15:26 -07:00
|
|
|
if (IsTextField()) {
|
|
|
|
*aContentOffset = aRenderedOffset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-11-27 10:12:15 -08:00
|
|
|
*aContentOffset = 0;
|
|
|
|
NS_ENSURE_TRUE(aFrame, NS_ERROR_FAILURE);
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
NS_ASSERTION(aFrame->GetType() == nsGkAtoms::textFrame,
|
2007-09-05 06:31:33 -07:00
|
|
|
"Need text frame for offset conversion");
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(aFrame->GetPrevContinuation() == nullptr,
|
2007-09-05 06:31:33 -07:00
|
|
|
"Call on primary frame only");
|
|
|
|
|
2007-08-03 18:12:24 -07:00
|
|
|
gfxSkipChars skipChars;
|
|
|
|
gfxSkipCharsIterator iter;
|
|
|
|
// We only need info up to skipped offset -- that is what we're converting to original offset
|
2012-07-30 07:20:58 -07:00
|
|
|
nsresult rv = aFrame->GetRenderedText(nullptr, &skipChars, &iter, 0, aRenderedOffset);
|
2007-08-03 18:12:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t ourRenderedStart = iter.GetSkippedOffset();
|
|
|
|
int32_t ourContentStart = iter.GetOriginalOffset();
|
2007-08-03 18:12:24 -07:00
|
|
|
|
|
|
|
*aContentOffset = iter.ConvertSkippedToOriginal(aRenderedOffset + ourRenderedStart) - ourContentStart;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-01 18:50:03 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-31 01:04:41 -07:00
|
|
|
// HyperTextAccessible public
|
2010-07-01 18:50:03 -07:00
|
|
|
|
2011-02-03 06:29:12 -08:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetCharAt(int32_t aOffset, EGetTextType aShift,
|
|
|
|
nsAString& aChar, int32_t* aStartOffset,
|
|
|
|
int32_t* aEndOffset)
|
2011-02-03 06:29:12 -08:00
|
|
|
{
|
|
|
|
aChar.Truncate();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t offset = ConvertMagicOffset(aOffset) + static_cast<int32_t>(aShift);
|
|
|
|
int32_t childIdx = GetChildIndexAtOffset(offset);
|
2011-02-03 06:29:12 -08:00
|
|
|
if (childIdx == -1)
|
|
|
|
return false;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* child = GetChildAt(childIdx);
|
2011-02-03 06:29:12 -08:00
|
|
|
child->AppendTextTo(aChar, offset - GetChildOffset(childIdx), 1);
|
|
|
|
|
|
|
|
if (aStartOffset)
|
|
|
|
*aStartOffset = offset;
|
|
|
|
if (aEndOffset)
|
|
|
|
*aEndOffset = aChar.IsEmpty() ? offset : offset + 1;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
|
|
|
HyperTextAccessible::GetChildOffset(uint32_t aChildIndex,
|
2012-05-31 01:04:41 -07:00
|
|
|
bool aInvalidateAfter)
|
2010-07-01 18:50:03 -07:00
|
|
|
{
|
2011-01-20 00:02:10 -08:00
|
|
|
if (aChildIndex == 0) {
|
|
|
|
if (aInvalidateAfter)
|
|
|
|
mOffsets.Clear();
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
return aChildIndex;
|
2011-01-20 00:02:10 -08:00
|
|
|
}
|
2010-07-01 18:50:03 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t count = mOffsets.Length() - aChildIndex;
|
2010-07-01 18:50:03 -07:00
|
|
|
if (count > 0) {
|
|
|
|
if (aInvalidateAfter)
|
2010-08-15 04:28:49 -07:00
|
|
|
mOffsets.RemoveElementsAt(aChildIndex, count);
|
2010-07-01 18:50:03 -07:00
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
return mOffsets[aChildIndex - 1];
|
2010-07-01 18:50:03 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t lastOffset = mOffsets.IsEmpty() ?
|
2010-07-01 18:50:03 -07:00
|
|
|
0 : mOffsets[mOffsets.Length() - 1];
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
while (mOffsets.Length() < aChildIndex) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* child = mChildren[mOffsets.Length()];
|
2010-07-01 18:50:03 -07:00
|
|
|
lastOffset += nsAccUtils::TextLength(child);
|
|
|
|
mOffsets.AppendElement(lastOffset);
|
|
|
|
}
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
return mOffsets[aChildIndex - 1];
|
2010-07-01 18:50:03 -07:00
|
|
|
}
|
2010-05-25 01:40:26 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
|
|
|
HyperTextAccessible::GetChildIndexAtOffset(uint32_t aOffset)
|
2010-06-21 06:08:27 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t lastOffset = 0;
|
|
|
|
uint32_t offsetCount = mOffsets.Length();
|
2010-08-15 04:28:49 -07:00
|
|
|
if (offsetCount > 0) {
|
|
|
|
lastOffset = mOffsets[offsetCount - 1];
|
|
|
|
if (aOffset < lastOffset) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t low = 0, high = offsetCount;
|
2010-08-15 04:28:49 -07:00
|
|
|
while (high > low) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mid = (high + low) >> 1;
|
2010-08-15 04:28:49 -07:00
|
|
|
if (mOffsets[mid] == aOffset)
|
|
|
|
return mid < offsetCount - 1 ? mid + 1 : mid;
|
|
|
|
|
|
|
|
if (mOffsets[mid] < aOffset)
|
|
|
|
low = mid + 1;
|
|
|
|
else
|
|
|
|
high = mid;
|
|
|
|
}
|
|
|
|
if (high == offsetCount)
|
|
|
|
return -1;
|
2010-06-21 06:08:27 -07:00
|
|
|
|
2010-08-18 19:14:14 -07:00
|
|
|
return low;
|
2010-05-25 01:40:26 -07:00
|
|
|
}
|
2010-08-15 04:28:49 -07:00
|
|
|
}
|
2010-05-25 01:40:26 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = ChildCount();
|
2010-08-15 04:28:49 -07:00
|
|
|
while (mOffsets.Length() < childCount) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* child = GetChildAt(mOffsets.Length());
|
2010-08-15 04:28:49 -07:00
|
|
|
lastOffset += nsAccUtils::TextLength(child);
|
|
|
|
mOffsets.AppendElement(lastOffset);
|
|
|
|
if (aOffset < lastOffset)
|
|
|
|
return mOffsets.Length() - 1;
|
2010-05-25 01:40:26 -07:00
|
|
|
}
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
if (aOffset == lastOffset)
|
|
|
|
return mOffsets.Length() - 1;
|
|
|
|
|
|
|
|
return -1;
|
2010-05-25 01:40:26 -07:00
|
|
|
}
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-31 01:04:41 -07:00
|
|
|
// HyperTextAccessible protected
|
2010-08-15 04:28:49 -07:00
|
|
|
|
2007-09-24 22:48:51 -07:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
HyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame* aFrame, int32_t aOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
Accessible* aAccessible,
|
2012-04-06 11:08:24 -07:00
|
|
|
DOMPoint* aPoint)
|
2007-09-24 22:48:51 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aAccessible);
|
|
|
|
|
|
|
|
if (!aFrame) {
|
|
|
|
// If the given frame is null then set offset after the DOM node of the
|
|
|
|
// given accessible.
|
2012-04-14 19:24:37 -07:00
|
|
|
NS_ASSERTION(!aAccessible->IsDoc(),
|
|
|
|
"Shouldn't be called on document accessible!");
|
|
|
|
|
|
|
|
nsIContent* content = aAccessible->GetContent();
|
|
|
|
NS_ASSERTION(content, "Shouldn't operate on defunct accessible!");
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2012-04-14 19:24:37 -07:00
|
|
|
nsIContent* parent = content->GetParent();
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
aPoint->idx = parent->IndexOf(content) + 1;
|
|
|
|
aPoint->node = parent;
|
2007-09-24 22:48:51 -07:00
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
} else if (aFrame->GetType() == nsGkAtoms::textFrame) {
|
2012-04-06 11:08:24 -07:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_STATE(content);
|
|
|
|
|
2009-12-24 13:20:05 -08:00
|
|
|
nsIFrame *primaryFrame = content->GetPrimaryFrame();
|
2012-04-06 11:08:24 -07:00
|
|
|
nsresult rv = RenderedToContentOffset(primaryFrame, aOffset, &(aPoint->idx));
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
aPoint->node = content;
|
2007-09-24 22:48:51 -07:00
|
|
|
|
|
|
|
} else {
|
2012-04-06 11:08:24 -07:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_STATE(content);
|
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
nsIContent* parent = content->GetParent();
|
2007-09-24 22:48:51 -07:00
|
|
|
NS_ENSURE_STATE(parent);
|
|
|
|
|
2012-04-06 11:08:24 -07:00
|
|
|
aPoint->idx = parent->IndexOf(content);
|
|
|
|
aPoint->node = parent;
|
2007-09-24 22:48:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-08-03 18:12:24 -07:00
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
// HyperTextAccessible
|
2008-07-17 05:06:24 -07:00
|
|
|
nsresult
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::RangeBoundToHypertextOffset(nsRange* aRange,
|
|
|
|
bool aIsStartBound,
|
|
|
|
bool aIsStartHTOffset,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aHTOffset)
|
2008-07-17 05:06:24 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
nsINode* node = nullptr;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nodeOffset = 0;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
|
|
|
if (aIsStartBound) {
|
2012-03-06 09:08:02 -08:00
|
|
|
node = aRange->GetStartParent();
|
|
|
|
nodeOffset = aRange->StartOffset();
|
2008-07-17 05:06:24 -07:00
|
|
|
} else {
|
2012-03-06 09:08:02 -08:00
|
|
|
node = aRange->GetEndParent();
|
|
|
|
nodeOffset = aRange->EndOffset();
|
2008-07-17 05:06:24 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* startAcc =
|
2010-05-17 09:16:52 -07:00
|
|
|
DOMPointToHypertextOffset(node, nodeOffset, aHTOffset);
|
2008-07-17 05:06:24 -07:00
|
|
|
|
|
|
|
if (aIsStartHTOffset && !startAcc)
|
|
|
|
*aHTOffset = 0;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
// HyperTextAccessible
|
2008-07-17 05:06:24 -07:00
|
|
|
nsresult
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aNodeOffset,
|
|
|
|
int32_t* aHTStartOffset,
|
|
|
|
int32_t* aHTEndOffset,
|
2012-05-31 01:04:41 -07:00
|
|
|
nsIPersistentProperties* aAttributes)
|
2008-07-17 05:06:24 -07:00
|
|
|
{
|
2012-10-19 17:56:58 -07:00
|
|
|
nsRefPtr<nsFrameSelection> fs = FrameSelection();
|
|
|
|
if (!fs)
|
2008-07-17 05:06:24 -07:00
|
|
|
return NS_OK;
|
|
|
|
|
2012-10-19 17:56:58 -07:00
|
|
|
Selection* domSel = fs->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
|
|
|
|
if (!domSel)
|
|
|
|
return NS_OK;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2012-10-19 17:56:58 -07:00
|
|
|
int32_t rangeCount = domSel->GetRangeCount();
|
|
|
|
if (rangeCount <= 0)
|
|
|
|
return NS_OK;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2012-10-19 17:56:58 -07:00
|
|
|
int32_t startHTOffset = 0, endHTOffset = 0;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
for (int32_t idx = 0; idx < rangeCount; idx++) {
|
|
|
|
nsRange* range = domSel->GetRangeAt(idx);
|
|
|
|
if (range->Collapsed())
|
|
|
|
continue;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2012-10-19 17:56:58 -07:00
|
|
|
// See if the point comes after the range in which case we must continue in
|
|
|
|
// case there is another range after this one.
|
|
|
|
nsINode* endNode = range->GetEndParent();
|
|
|
|
int32_t endOffset = range->EndOffset();
|
|
|
|
if (nsContentUtils::ComparePoints(aNode, aNodeOffset, endNode, endOffset) >= 0)
|
|
|
|
continue;
|
2008-07-17 05:06:24 -07:00
|
|
|
|
2012-10-19 17:56:58 -07:00
|
|
|
// At this point our point is either in this range or before it but after
|
|
|
|
// the previous range. So we check to see if the range starts before the
|
|
|
|
// point in which case the point is in the missspelled range, otherwise it
|
|
|
|
// must be before the range and after the previous one if any.
|
|
|
|
nsINode* startNode = range->GetStartParent();
|
|
|
|
int32_t startOffset = range->StartOffset();
|
|
|
|
if (nsContentUtils::ComparePoints(startNode, startOffset, aNode,
|
|
|
|
aNodeOffset) <= 0) {
|
|
|
|
rv = RangeBoundToHypertextOffset(range, true, true, &startHTOffset);
|
2008-07-17 05:06:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-10-19 17:56:58 -07:00
|
|
|
rv = RangeBoundToHypertextOffset(range, false, false, &endHTOffset);
|
2008-07-17 05:06:24 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (startHTOffset > *aHTStartOffset)
|
|
|
|
*aHTStartOffset = startHTOffset;
|
2012-10-19 17:56:58 -07:00
|
|
|
|
2008-07-17 05:06:24 -07:00
|
|
|
if (endHTOffset < *aHTEndOffset)
|
|
|
|
*aHTEndOffset = endHTOffset;
|
|
|
|
|
2008-07-24 08:20:39 -07:00
|
|
|
if (aAttributes) {
|
2011-06-03 14:35:17 -07:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid,
|
2008-10-16 02:12:05 -07:00
|
|
|
NS_LITERAL_STRING("spelling"));
|
2008-07-24 08:20:39 -07:00
|
|
|
}
|
2008-07-17 05:06:24 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-10-19 17:56:58 -07:00
|
|
|
|
|
|
|
// This range came after the point.
|
|
|
|
rv = RangeBoundToHypertextOffset(range, true, false, &endHTOffset);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (idx > 0) {
|
|
|
|
rv = RangeBoundToHypertextOffset(domSel->GetRangeAt(idx - 1), false,
|
|
|
|
true, &startHTOffset);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (startHTOffset > *aHTStartOffset)
|
|
|
|
*aHTStartOffset = startHTOffset;
|
|
|
|
|
|
|
|
if (endHTOffset < *aHTEndOffset)
|
|
|
|
*aHTEndOffset = endHTOffset;
|
|
|
|
|
|
|
|
return NS_OK;
|
2008-07-17 05:06:24 -07:00
|
|
|
}
|
|
|
|
|
2012-10-19 17:56:58 -07:00
|
|
|
// We never found a range that ended after the point, therefore we know that
|
|
|
|
// the point is not in a range, that we do not need to compute an end offset,
|
|
|
|
// and that we should use the end offset of the last range to compute the
|
|
|
|
// start offset of the text attribute range.
|
|
|
|
rv = RangeBoundToHypertextOffset(domSel->GetRangeAt(rangeCount - 1), false,
|
|
|
|
true, &startHTOffset);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (startHTOffset > *aHTStartOffset)
|
|
|
|
*aHTStartOffset = startHTOffset;
|
|
|
|
|
2008-07-17 05:06:24 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-04-13 18:19:41 -07:00
|
|
|
|
|
|
|
bool
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible::IsTextRole()
|
2012-04-13 18:19:41 -07:00
|
|
|
{
|
|
|
|
if (mRoleMapEntry &&
|
|
|
|
(mRoleMapEntry->role == roles::GRAPHIC ||
|
|
|
|
mRoleMapEntry->role == roles::IMAGE_MAP ||
|
|
|
|
mRoleMapEntry->role == roles::SLIDER ||
|
|
|
|
mRoleMapEntry->role == roles::PROGRESSBAR ||
|
|
|
|
mRoleMapEntry->role == roles::SEPARATOR))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|