Bug 185846. Create ISimpleDOMText for accessibility API support of pieces of text smaller than a node. r=bolian, sr=alecf, a=asa

git-svn-id: svn://10.0.0.236/trunk@142607 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
aaronl%netscape.com
2003-05-19 09:07:41 +00:00
parent c18da71a33
commit 040d929493
21 changed files with 637 additions and 19 deletions

View File

@@ -6,12 +6,13 @@ extern "C" {
EXTERN_PROXY_FILE( ISimpleDOMDocument )
EXTERN_PROXY_FILE( ISimpleDOMNode )
EXTERN_PROXY_FILE( ISimpleDOMText )
PROXYFILE_LIST_START
/* Start of list */
REFERENCE_PROXY_FILE( ISimpleDOMDocument ),
REFERENCE_PROXY_FILE( ISimpleDOMNode ),
REFERENCE_PROXY_FILE( ISimpleDOMText ),
/* End of list */
PROXYFILE_LIST_END

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: Aaron Leventhal (aaronl@netscape.com)
*
*/
import "objidl.idl";
import "oaidl.idl";
[object, uuid(aa24e510-a4e6-4112-a258-0ba7f12e85a9)]
interface ISimpleDOMText: IUnknown
{
// Includes whitespace in DOM
[propget] HRESULT domText([out, retval] BSTR *domText);
HRESULT get_clippedSubstringBounds([in] unsigned int startIndex,
[in] unsigned int endIndex,
[out] int *x,
[out] int *y,
[out] int *width,
[out] int *height);
HRESULT get_unclippedSubstringBounds([in] unsigned int startIndex,
[in] unsigned int endIndex,
[out] int *x,
[out] int *y,
[out] int *width,
[out] int *height);
HRESULT scrollToSubstring([in] unsigned int startIndex,
[in] unsigned int endIndex);
};

View File

@@ -65,6 +65,8 @@ CSRCS = \
ISimpleDOMNode_i.c \
ISimpleDOMDocument_p.c \
ISimpleDOMDocument_i.c \
ISimpleDOMText_p.c \
ISimpleDOMText_i.c \
$(NULL)
MIDL_GENERATED_FILES = \
@@ -74,6 +76,9 @@ MIDL_GENERATED_FILES = \
ISimpleDOMDocument.h \
ISimpleDOMDocument_p.c \
ISimpleDOMDocument_i.c \
ISimpleDOMText.h \
ISimpleDOMText_p.c \
ISimpleDOMText_i.c \
$(NULL)
SRCDIR_CSRCS = $(addprefix $(srcdir)/,$(CSRCS))
@@ -88,9 +93,10 @@ OS_LIBS = \
$(MIDL_GENERATED_FILES): done_gen
done_gen: ISimpleDOMNode.idl ISimpleDOMDocument.idl
done_gen: ISimpleDOMNode.idl ISimpleDOMDocument.idl ISimpleDOMText.idl
"$(MIDL)" $(srcdir)/ISimpleDOMNode.idl
"$(MIDL)" $(srcdir)/ISimpleDOMDocument.idl
"$(MIDL)" $(srcdir)/ISimpleDOMText.idl
touch $@
EXPORTS = \
@@ -98,6 +104,8 @@ EXPORTS = \
ISimpleDOMNode_i.c \
ISimpleDOMDocument.h \
ISimpleDOMDocument_i.c \
ISimpleDOMText.h \
ISimpleDOMText_i.c \
$(NULL)
export:: done_gen

View File

@@ -100,6 +100,8 @@ EXPORTS = \
nsAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsTextAccessibleWrap.h \
nsAccessibleText.h \
$(NULL)
# we want to force the creation of a static lib.

View File

@@ -48,6 +48,7 @@
#include "nsIEditor.h"
#include "nsISelectionController.h"
#include "nsITextControlFrame.h"
#include "nsTextAccessibleWrap.h"
#include "nsTextAccessible.h"
enum EGetTextType { eGetBefore=-1, eGetAt=0, eGetAfter=1 };

View File

@@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape Corp.
* Portions created by Netscape Corp.are Copyright (C) 2003 Netscape
* Corp. All Rights Reserved.
*
* Original Author: Aaron Leventhal
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsTextAccessibleWrap_H_
#define _nsTextAccessibleWrap_H_
#include "nsTextAccessible.h"
#include "nsAccessibleText.h"
#endif

View File

@@ -98,15 +98,16 @@ nsDocAccessible::nsDocAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell)
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
nsCOMPtr<nsIWidget> widget;
vm->GetWidget(getter_AddRefs(widget));
mWnd = widget->GetNativeData(NS_NATIVE_WINDOW);
if (vm) {
vm->GetWidget(getter_AddRefs(widget));
if (widget) {
mWnd = widget->GetNativeData(NS_NATIVE_WINDOW);
}
}
}
NS_ASSERTION(gGlobalDocAccessibleCache, "No global doc accessible cache");
PutCacheEntry(gGlobalDocAccessibleCache, mWeakShell, this);
#ifdef DEBUG
printf("\nATTENTION: New doc accessible for weak shell %x\n", mWeakShell.get());
#endif
// XXX aaronl should we use an algorithm for the initial cache size?
#ifdef OLD_HASH
@@ -408,10 +409,52 @@ nsIFrame* nsDocAccessible::GetFrame()
void nsDocAccessible::GetBounds(nsRect& aBounds, nsIFrame** aRelativeFrame)
{
*aRelativeFrame = GetFrame();
if (*aRelativeFrame)
(*aRelativeFrame)->GetRect(aBounds);
nsCOMPtr<nsIDocument> document(mDocument);
nsRect viewBounds;
nsCOMPtr<nsIViewManager> vm;
nsCOMPtr<nsIDocument> parentDoc;
while (document) {
nsCOMPtr<nsIPresShell> presShell;
document->GetShellAt(0, getter_AddRefs(presShell));
if (!presShell) {
return;
}
presShell->GetViewManager(getter_AddRefs(vm));
nsIScrollableView* scrollableView = nsnull;
if (vm)
vm->GetRootScrollableView(&scrollableView);
if (scrollableView) {
const nsIView *view = nsnull;
scrollableView->GetClipView(&view);
if (view) {
view->GetBounds(viewBounds);
}
}
else {
nsIView *view;
vm->GetRootView(view);
if (view) {
view->GetBounds(viewBounds);
}
}
if (parentDoc) { // After first time thru loop
aBounds.IntersectRect(viewBounds, aBounds);
}
else { // First time through loop
aBounds = viewBounds;
}
document->GetParentDocument(getter_AddRefs(parentDoc));
document = parentDoc;
}
}
void nsDocAccessible::AddContentDocListeners()
{
// 1) Set up scroll position listener

View File

@@ -82,3 +82,8 @@ NS_IMETHODIMP nsOuterDocAccessible::GetAccState(PRUint32 *aAccState)
return nsAccessible::GetAccState(aAccState);
}
NS_IMETHODIMP nsOuterDocAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y,
PRInt32 *width, PRInt32 *height)
{
return mFirstChild? mFirstChild->AccGetBounds(x, y, width, height): NS_ERROR_FAILURE;
}

View File

@@ -57,6 +57,8 @@ class nsOuterDocAccessible : public nsBlockAccessible
NS_IMETHOD GetAccValue(nsAString& AccValue);
NS_IMETHOD GetAccRole(PRUint32 *aAccRole);
NS_IMETHOD GetAccState(PRUint32 *aAccState);
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y,
PRInt32 *width, PRInt32 *height);
};
#endif

View File

@@ -46,7 +46,7 @@
#include "nsISelectionController.h"
nsHTMLTextAccessible::nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsTextAccessible(aDomNode, aShell)
nsTextAccessibleWrap(aDomNode, aShell)
{
}

View File

@@ -40,11 +40,11 @@
#ifndef _nsHTMLTextAccessible_H_
#define _nsHTMLTextAccessible_H_
#include "nsTextAccessible.h"
#include "nsTextAccessibleWrap.h"
class nsIWeakReference;
class nsHTMLTextAccessible : public nsTextAccessible
class nsHTMLTextAccessible : public nsTextAccessibleWrap
{
public:

View File

@@ -73,6 +73,7 @@ CPPSRCS = \
EXPORTS = \
nsAccessNodeWrap.h \
nsTextAccessibleWrap.h \
nsAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \

View File

@@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape Corp.
* Portions created by Netscape Corp.are Copyright (C) 2003 Netscape
* Corp. All Rights Reserved.
*
* Original Author: Aaron Leventhal
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsTextAccessibleWrap_H_
#define _nsTextAccessibleWrap_H_
#include "nsTextAccessible.h"
typedef class nsTextAccessible nsTextAccessibleWrap;
#endif

View File

@@ -67,6 +67,7 @@ REQUIRES = content \
CPPSRCS = \
nsAccessNodeWrap.cpp \
nsAccessibleWrap.cpp \
nsTextAccessibleWrap.cpp \
nsDocAccessibleWrap.cpp \
nsRootAccessibleWrap.cpp \
nsHTMLWin32ObjectAccessible.cpp \
@@ -75,6 +76,7 @@ CPPSRCS = \
EXPORTS = \
nsAccessNodeWrap.h \
nsAccessibleWrap.h \
nsTextAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsHTMLWin32ObjectAccessible.h \

View File

@@ -138,10 +138,12 @@ STDMETHODIMP nsDocAccessibleWrap::get_accChild(
getter_AddRefs(parentDocAccessible));
nsCOMPtr<nsIAccessible> accessible(do_QueryInterface(parentDocAccessible));
IAccessible *msaaParentDoc;
accessible->GetNativeInterface((void**)&msaaParentDoc);
HRESULT rv = msaaParentDoc->get_accChild(varChild, ppdispChild);
msaaParentDoc->Release();
return rv;
if (accessible) {
accessible->GetNativeInterface((void**)&msaaParentDoc);
HRESULT rv = msaaParentDoc->get_accChild(varChild, ppdispChild);
msaaParentDoc->Release();
return rv;
}
}
}
}

View File

@@ -0,0 +1,262 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape Corp.
* Portions created by Netscape Corp.are Copyright (C) 2003 Netscape
* Corp. All Rights Reserved.
*
* Original Author: Aaron Leventhal
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// NOTE: alphabetically ordered
#include "nsTextAccessibleWrap.h"
#include "ISimpleDOMText_i.c"
#include "nsContentCID.h"
#include "nsIDOMRange.h"
#include "nsIFrame.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsIRenderingContext.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
// --------------------------------------------------------
// nsTextAccessibleWrap Accessible
// --------------------------------------------------------
nsTextAccessibleWrap::nsTextAccessibleWrap(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
nsTextAccessible(aDOMNode, aShell)
{
}
STDMETHODIMP_(ULONG) nsTextAccessibleWrap::AddRef()
{
return nsAccessNode::AddRef();
}
STDMETHODIMP_(ULONG) nsTextAccessibleWrap::Release()
{
return nsAccessNode::Release();
}
STDMETHODIMP nsTextAccessibleWrap::QueryInterface(REFIID iid, void** ppv)
{
*ppv = nsnull;
if (IID_IUnknown == iid || IID_ISimpleDOMText == iid)
*ppv = NS_STATIC_CAST(ISimpleDOMText*, this);
if (nsnull == *ppv)
return nsAccessibleWrap::QueryInterface(iid, ppv);
(NS_REINTERPRET_CAST(IUnknown*, *ppv))->AddRef();
return S_OK;
}
STDMETHODIMP nsTextAccessibleWrap::get_domText(
/* [retval][out] */ BSTR __RPC_FAR *aDomText)
{
nsAutoString nodeValue;
mDOMNode->GetNodeValue(nodeValue);
*aDomText = ::SysAllocString(nodeValue.get());
return S_OK;
}
STDMETHODIMP nsTextAccessibleWrap::get_clippedSubstringBounds(
/* [in] */ unsigned int aStartIndex,
/* [in] */ unsigned int aEndIndex,
/* [out] */ int __RPC_FAR *aX,
/* [out] */ int __RPC_FAR *aY,
/* [out] */ int __RPC_FAR *aWidth,
/* [out] */ int __RPC_FAR *aHeight)
{
nscoord x, y, width, height, docX, docY, docWidth, docHeight;
get_unclippedSubstringBounds(aStartIndex, aEndIndex, &x, &y, &width, &height);
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
nsCOMPtr<nsIAccessible> accessible(do_QueryInterface(docAccessible));
NS_ASSERTION(accessible, "There must always be a doc accessible, but there isn't");
accessible->AccGetBounds(&docX, &docY, &docWidth, &docHeight);
nsRect unclippedRect(x, y, width, height);
nsRect docRect(docX, docY, docWidth, docHeight);
nsRect clippedRect;
clippedRect.IntersectRect(unclippedRect, docRect);
*aX = clippedRect.x;
*aY = clippedRect.y;
*aWidth = clippedRect.width;
*aHeight = clippedRect.height;
return S_OK;
}
STDMETHODIMP nsTextAccessibleWrap::get_unclippedSubstringBounds(
/* [in] */ unsigned int aStartIndex,
/* [in] */ unsigned int aEndIndex,
/* [out] */ int __RPC_FAR *aX,
/* [out] */ int __RPC_FAR *aY,
/* [out] */ int __RPC_FAR *aWidth,
/* [out] */ int __RPC_FAR *aHeight)
{
if (NS_FAILED(GetCharacterExtents(aStartIndex, aEndIndex,
aX, aY, aWidth, aHeight))) {
return NS_ERROR_FAILURE;
}
// Add offsets for entire accessible
PRInt32 nodeX, nodeY, nodeWidth, nodeHeight;
AccGetBounds(&nodeX, &nodeY, &nodeWidth, &nodeHeight);
*aX += nodeX;
*aY += nodeY;
return S_OK;
}
STDMETHODIMP nsTextAccessibleWrap::scrollToSubstring(
/* [in] */ unsigned int aStartIndex,
/* [in] */ unsigned int aEndIndex)
{
nsCOMPtr<nsIPresShell> presShell(GetPresShell());
nsIFrame *frame = GetFrame();
if (!frame || !presShell) {
return E_FAIL; // This accessible has been shut down
}
nsCOMPtr<nsIPresContext> presContext;
presShell->GetPresContext(getter_AddRefs(presContext));
nsCOMPtr<nsIDOMRange> scrollToRange = do_CreateInstance(kRangeCID);
nsCOMPtr<nsISelectionController> selCon;
frame->GetSelectionController(presContext, getter_AddRefs(selCon));
if (!presContext || !scrollToRange || !selCon) {
return E_FAIL;
}
scrollToRange->SetStart(mDOMNode, aStartIndex);
scrollToRange->SetEnd(mDOMNode, aEndIndex);
nsCOMPtr<nsISelection> domSel;
selCon->GetSelection(nsISelectionController::SELECTION_ACCESSIBILITY,
getter_AddRefs(domSel));
if (domSel) {
domSel->RemoveAllRanges();
domSel->AddRange(scrollToRange);
selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_ACCESSIBILITY,
nsISelectionController::SELECTION_ANCHOR_REGION, PR_TRUE);
domSel->CollapseToStart();
}
return S_OK;
}
nsIFrame* nsTextAccessibleWrap::GetPointFromOffset(nsIFrame *aContainingFrame,
nsIPresContext *aPresContext,
nsIRenderingContext *aRendContext,
PRInt32 aOffset,
nsPoint& aOutPoint)
{
nsIFrame *textFrame = nsnull;
PRInt32 outOffset;
aContainingFrame->GetChildFrameContainingOffset(aOffset, PR_FALSE, &outOffset, &textFrame);
if (!textFrame) {
return nsnull;
}
textFrame->GetPointFromOffset(aPresContext, aRendContext, aOffset, &aOutPoint);
return textFrame;
}
/*
* Given an offset, the x, y, width, and height values are filled appropriately.
*/
nsresult nsTextAccessibleWrap::GetCharacterExtents(PRInt32 aStartOffset, PRInt32 aEndOffset,
PRInt32* aX, PRInt32* aY,
PRInt32* aWidth, PRInt32* aHeight)
{
nsCOMPtr<nsIPresShell> presShell(GetPresShell());
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresContext> presContext;
presShell->GetPresContext(getter_AddRefs(presContext));
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
float t2p;
if (NS_FAILED(presContext->GetTwipsToPixels(&t2p))) {
return NS_ERROR_FAILURE;
}
nsIFrame *frame = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
presShell->GetPrimaryFrameFor(content, &frame);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewManager> viewManager;
presShell->GetViewManager(getter_AddRefs(viewManager));
NS_ASSERTION(viewManager, "No view manager for pres shell");
nsCOMPtr<nsIWidget> widget;
viewManager->GetWidget(getter_AddRefs(widget));
nsIRenderingContext *rendContext;
rendContext = widget->GetRenderingContext();
nsPoint startPoint, endPoint;
nsIFrame *startFrame = GetPointFromOffset(frame, presContext, rendContext,
aStartOffset, startPoint);
nsIFrame *endFrame = GetPointFromOffset(frame, presContext, rendContext,
aEndOffset, endPoint);
if (!startFrame || !endFrame) {
return E_FAIL;
}
nsRect startRect, endRect;
startFrame->GetRect(startRect);
endFrame->GetRect(endRect);
*aX = NSTwipsToIntPixels(startPoint.x + startRect.x, t2p);
*aY = NSTwipsToIntPixels(startPoint.y, t2p);
*aWidth = NSTwipsToIntPixels(endPoint.x + endRect.x, t2p) - *aX;
*aHeight = NSTwipsToIntPixels(endRect.y + endRect.height -
startPoint.y - startRect.y , t2p);
return NS_OK;
}

View File

@@ -0,0 +1,98 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape Corp.
* Portions created by Netscape Corp.are Copyright (C) 2003 Netscape
* Corp. All Rights Reserved.
*
* Original Author: Aaron Leventhal
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsTextAccessibleWrap_H_
#define _nsTextAccessibleWrap_H_
#include "nsTextAccessible.h"
#include "ISimpleDOMText.h"
#include "nsRect.h"
class nsIFrame;
class nsIPresContext;
class nsIRenderingContext;
class nsTextAccessibleWrap : public nsTextAccessible,
public ISimpleDOMText
{
public:
nsTextAccessibleWrap(nsIDOMNode *, nsIWeakReference* aShell);
virtual ~nsTextAccessibleWrap() {}
// IUnknown methods - see iunknown.h for documentation
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP QueryInterface(REFIID, void**);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_domText(
/* [retval][out] */ BSTR __RPC_FAR *domText);
virtual HRESULT STDMETHODCALLTYPE get_clippedSubstringBounds(
/* [in] */ unsigned int startIndex,
/* [in] */ unsigned int endIndex,
/* [out] */ int __RPC_FAR *x,
/* [out] */ int __RPC_FAR *y,
/* [out] */ int __RPC_FAR *width,
/* [out] */ int __RPC_FAR *height);
virtual HRESULT STDMETHODCALLTYPE get_unclippedSubstringBounds(
/* [in] */ unsigned int startIndex,
/* [in] */ unsigned int endIndex,
/* [out] */ int __RPC_FAR *x,
/* [out] */ int __RPC_FAR *y,
/* [out] */ int __RPC_FAR *width,
/* [out] */ int __RPC_FAR *height);
virtual HRESULT STDMETHODCALLTYPE scrollToSubstring(
/* [in] */ unsigned int startIndex,
/* [in] */ unsigned int endIndex);
protected:
nsresult GetCharacterExtents(PRInt32 aStartOffset, PRInt32 aEndOffset,
PRInt32* aX, PRInt32* aY,
PRInt32* aWidth, PRInt32* aHeight);
// Return child frame containing offset on success
nsIFrame* GetPointFromOffset(nsIFrame *aContainingFrame, nsIPresContext *aPresContext,
nsIRenderingContext *aRenderingContext,
PRInt32 aOffset, nsPoint& aOutPoint);
};
#endif

View File

@@ -73,6 +73,7 @@ CPPSRCS = \
EXPORTS = \
nsAccessNodeWrap.h \
nsTextAccessibleWrap.h \
nsAccessibleWrap.h \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \

View File

@@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape Corp.
* Portions created by Netscape Corp.are Copyright (C) 2003 Netscape
* Corp. All Rights Reserved.
*
* Original Author: Aaron Leventhal
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsTextAccessibleWrap_H_
#define _nsTextAccessibleWrap_H_
#include "nsTextAccessible.h"
typedef class nsTextAccessible nsTextAccessibleWrap;
#endif

View File

@@ -46,7 +46,7 @@
* For XUL descriptions and labels
*/
nsXULTextAccessible::nsXULTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsTextAccessible(aDomNode, aShell)
nsTextAccessibleWrap(aDomNode, aShell)
{
}

View File

@@ -41,11 +41,11 @@
#ifndef _nsXULTextAccessible_H_
#define _nsXULTextAccessible_H_
#include "nsTextAccessible.h"
#include "nsTextAccessibleWrap.h"
class nsIWeakReference;
class nsXULTextAccessible : public nsTextAccessible
class nsXULTextAccessible : public nsTextAccessibleWrap
{
public: