[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
hyatt
hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:59:21 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 1a1e5eaeeff5ee2ccca88b66dfe0e7c8b7e5cc64
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Oct 2 18:23:53 2003 +0000
Work on exposing elements to the Acc API. This patch gets us to the point where text
under the mouse is voiced.
Reviewed by darin
* kwq/KWQAccObject.h:
* kwq/KWQAccObject.mm:
(-[KWQAccObject initWithRenderer:]):
(-[KWQAccObject parentObject]):
(-[KWQAccObject parentObjectUnignored]):
(-[KWQAccObject addChildrenToArray:]):
(-[KWQAccObject role]):
(-[KWQAccObject roleDescription]):
(-[KWQAccObject value]):
(-[KWQAccObject title]):
(-[KWQAccObject position]):
(-[KWQAccObject size]):
(-[KWQAccObject accessibilityIsIgnored]):
(-[KWQAccObject accessibilityAttributeNames]):
(-[KWQAccObject accessibilityActionNames]):
(-[KWQAccObject accessibilityIsAttributeSettable:]):
(-[KWQAccObject accessibilityAttributeValue:]):
(-[KWQAccObject accessibilityHitTest:]):
* kwq/KWQAccObjectCache.mm:
(KWQAccObjectCache::accObject):
(KWQAccObjectCache::setAccObject):
(KWQAccObjectCache::removeAccObject):
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge accessibilityTree]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 6bb6643..dd2046e 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,36 @@
+2003-10-02 David Hyatt <hyatt at apple.com>
+
+ Work on exposing elements to the Acc API. This patch gets us to the point where text
+ under the mouse is voiced.
+
+ Reviewed by darin
+
+ * kwq/KWQAccObject.h:
+ * kwq/KWQAccObject.mm:
+ (-[KWQAccObject initWithRenderer:]):
+ (-[KWQAccObject parentObject]):
+ (-[KWQAccObject parentObjectUnignored]):
+ (-[KWQAccObject addChildrenToArray:]):
+ (-[KWQAccObject role]):
+ (-[KWQAccObject roleDescription]):
+ (-[KWQAccObject value]):
+ (-[KWQAccObject title]):
+ (-[KWQAccObject position]):
+ (-[KWQAccObject size]):
+ (-[KWQAccObject accessibilityIsIgnored]):
+ (-[KWQAccObject accessibilityAttributeNames]):
+ (-[KWQAccObject accessibilityActionNames]):
+ (-[KWQAccObject accessibilityIsAttributeSettable:]):
+ (-[KWQAccObject accessibilityAttributeValue:]):
+ (-[KWQAccObject accessibilityHitTest:]):
+ * kwq/KWQAccObjectCache.mm:
+ (KWQAccObjectCache::accObject):
+ (KWQAccObjectCache::setAccObject):
+ (KWQAccObjectCache::removeAccObject):
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge accessibilityTree]):
+
2003-10-02 Darin Adler <darin at apple.com>
Reviewed by Ken.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 6bb6643..dd2046e 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,36 @@
+2003-10-02 David Hyatt <hyatt at apple.com>
+
+ Work on exposing elements to the Acc API. This patch gets us to the point where text
+ under the mouse is voiced.
+
+ Reviewed by darin
+
+ * kwq/KWQAccObject.h:
+ * kwq/KWQAccObject.mm:
+ (-[KWQAccObject initWithRenderer:]):
+ (-[KWQAccObject parentObject]):
+ (-[KWQAccObject parentObjectUnignored]):
+ (-[KWQAccObject addChildrenToArray:]):
+ (-[KWQAccObject role]):
+ (-[KWQAccObject roleDescription]):
+ (-[KWQAccObject value]):
+ (-[KWQAccObject title]):
+ (-[KWQAccObject position]):
+ (-[KWQAccObject size]):
+ (-[KWQAccObject accessibilityIsIgnored]):
+ (-[KWQAccObject accessibilityAttributeNames]):
+ (-[KWQAccObject accessibilityActionNames]):
+ (-[KWQAccObject accessibilityIsAttributeSettable:]):
+ (-[KWQAccObject accessibilityAttributeValue:]):
+ (-[KWQAccObject accessibilityHitTest:]):
+ * kwq/KWQAccObjectCache.mm:
+ (KWQAccObjectCache::accObject):
+ (KWQAccObjectCache::setAccObject):
+ (KWQAccObjectCache::removeAccObject):
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge accessibilityTree]):
+
2003-10-02 Darin Adler <darin at apple.com>
Reviewed by Ken.
diff --git a/WebCore/kwq/KWQAccObject.h b/WebCore/kwq/KWQAccObject.h
index 90da091..dbfe510 100644
--- a/WebCore/kwq/KWQAccObject.h
+++ b/WebCore/kwq/KWQAccObject.h
@@ -35,6 +35,8 @@ namespace khtml {
id m_data;
}
+-(id)initWithRenderer:(khtml::RenderObject*)renderer;
+
-(long)x;
-(long)y;
-(long)width;
diff --git a/WebCore/kwq/KWQAccObject.mm b/WebCore/kwq/KWQAccObject.mm
index 3bfb829..108708a 100644
--- a/WebCore/kwq/KWQAccObject.mm
+++ b/WebCore/kwq/KWQAccObject.mm
@@ -25,11 +25,38 @@
#import "KWQAccObject.h"
#import "KWQAccObjectCache.h"
+#import "KWQWidget.h"
-#import "render_object.h"
#import "dom_docimpl.h"
+#import "dom_elementimpl.h"
+#import "dom_string.h"
+#import "htmlattrs.h"
+#import "khtmlview.h"
+#import "render_canvas.h"
+#import "render_object.h"
+#import "render_replaced.h"
+#import "render_style.h"
+#import "render_text.h"
+
+using DOM::DOMString;
+using DOM::ElementImpl;
+using khtml::InlineTextBoxArray;
+using khtml::RenderCanvas;
+using khtml::RenderObject;
+using khtml::RenderText;
+using khtml::RenderWidget;
+
+// FIXME: This will eventually need to really localize.
+#define UI_STRING(string, comment) ((NSString *)[NSString stringWithUTF8String:(string)])
@implementation KWQAccObject
+-(id)initWithRenderer:(RenderObject*)renderer
+{
+ [super init];
+ m_renderer = renderer;
+ return self;
+}
+
-(long)x
{
if (!m_renderer)
@@ -123,4 +150,221 @@
return nil;
return m_renderer->document()->getOrCreateAccObjectCache()->accObject(m_renderer->parent());
}
+
+-(KWQAccObject*)parentObjectUnignored
+{
+ if (!m_renderer || !m_renderer->parent())
+ return nil;
+ KWQAccObject* obj = m_renderer->document()->getOrCreateAccObjectCache()->accObject(m_renderer->parent());
+ if ([obj accessibilityIsIgnored])
+ return [obj parentObjectUnignored];
+ else
+ return obj;
+}
+
+-(void)addChildrenToArray:(NSMutableArray*)array
+{
+ if (!m_renderer)
+ return;
+
+ if (m_renderer->isWidget()) {
+ RenderWidget* renderWidget = static_cast<RenderWidget*>(m_renderer);
+ QWidget* widget = renderWidget->widget();
+ if (widget) {
+ NSArray* childArr = [(widget->getView()) accessibilityAttributeValue: NSAccessibilityChildrenAttribute];
+ [array addObjectsFromArray: childArr];
+ return;
+ }
+ }
+
+ for (KWQAccObject* obj = [self firstChild]; obj; obj = [obj nextSibling]) {
+ if ([obj accessibilityIsIgnored])
+ [obj addChildrenToArray: array];
+ else
+ [array addObject: obj];
+ }
+}
+
+-(NSString*)role
+{
+ if (!m_renderer)
+ return NSAccessibilityUnknownRole;
+
+ if (m_renderer->element() && m_renderer->element()->hasAnchor())
+ return NSAccessibilityButtonRole;
+ if (m_renderer->isText())
+ return NSAccessibilityStaticTextRole;
+ if (m_renderer->isImage())
+ return NSAccessibilityImageRole;
+ if (m_renderer->isListMarker()) // FIXME: Can be an image/bullet or can be text.
+ return NSAccessibilityStaticTextRole;
+ if (m_renderer->isCanvas())
+ return NSAccessibilityGroupRole;
+ if (m_renderer->isTable() || m_renderer->isTableCell())
+ return NSAccessibilityTableRole;
+
+ return NSAccessibilityUnknownRole;
+}
+
+-(NSString*)roleDescription
+{
+ if (!m_renderer)
+ return nil;
+
+ if (m_renderer->element() && m_renderer->element()->isHTMLElement()) {
+ QString title = static_cast<ElementImpl*>(m_renderer->element())->getAttribute(ATTR_TITLE).string();
+ if (!title.isEmpty())
+ return title.getNSString();
+ }
+
+ return UI_STRING("Testing role description", "not real yet");
+}
+
+-(NSString*)value
+{
+ if (!m_renderer)
+ return nil;
+ if (m_renderer->isText()) {
+ RenderText* textObj = static_cast<RenderText*>(m_renderer);
+ QString text;
+ QString str = textObj->data().string();
+ InlineTextBoxArray runs = textObj->inlineTextBoxes();
+ bool addedSpace = true;
+ for (unsigned i = 0; i < runs.count(); i++) {
+ int runStart = runs[i]->m_start;
+ int runEnd = runs[i]->m_start + runs[i]->m_len;
+ bool spaceBetweenRuns = false;
+ text += str.mid(runStart, runEnd - runStart);
+ spaceBetweenRuns = i+1 < runs.count() && runs[i+1]->m_start > runEnd;
+ addedSpace = str[runEnd-1].direction() == QChar::DirWS;
+ if (spaceBetweenRuns && !addedSpace) {
+ text += " ";
+ addedSpace = true;
+ }
+ }
+ return text.getNSString();
+ }
+
+ return UI_STRING("Value not implemented yet.", "not real yet");
+}
+
+-(NSString*)title
+{
+ return UI_STRING("Title not implemented yet.", "not real yet");
+}
+
+-(NSValue*)position
+{
+ return [NSValue valueWithPoint: NSMakePoint([self x],[self y])];
+}
+
+-(NSValue*)size
+{
+ return [NSValue valueWithSize: NSMakeSize([self width],[self height])];
+}
+
+-(BOOL)accessibilityIsIgnored
+{
+ if (!m_renderer || m_renderer->style()->visibility() != khtml::VISIBLE)
+ return YES;
+
+ if (m_renderer->element() && m_renderer->element()->hasAnchor())
+ return NO;
+
+ return (!m_renderer->isCanvas() && !m_renderer->isTable() && !m_renderer->isTableCell() &&
+ !m_renderer->isImage() && !m_renderer->isText() && !m_renderer->isListMarker());
+}
+
+- (NSArray *)accessibilityAttributeNames
+{
+ return [NSArray arrayWithObjects: NSAccessibilityRoleAttribute,
+ NSAccessibilityRoleDescriptionAttribute,
+ NSAccessibilityChildrenAttribute,
+ NSAccessibilityHelpAttribute,
+ NSAccessibilityParentAttribute,
+ NSAccessibilityPositionAttribute,
+ NSAccessibilitySizeAttribute,
+ //NSAccessibilitySubroleAttribute,
+ NSAccessibilityTitleAttribute,
+ NSAccessibilityValueAttribute,
+ NSAccessibilityFocusedAttribute,
+ NSAccessibilityEnabledAttribute,
+ NSAccessibilityWindowAttribute,
+ nil];
+}
+
+- (NSArray*)accessibilityActionNames
+{
+ return nil;
+}
+
+- (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName
+{
+ return NO;
+}
+
+- (id)accessibilityAttributeValue:(NSString *)attributeName
+{
+ if (!m_renderer)
+ return nil;
+
+ if ([attributeName isEqualToString: NSAccessibilityRoleAttribute])
+ return [self role];
+
+ if ([attributeName isEqualToString: NSAccessibilityRoleDescriptionAttribute])
+ return [self roleDescription];
+
+ if ([attributeName isEqualToString: NSAccessibilityParentAttribute]) {
+ if (m_renderer->isCanvas())
+ return m_renderer->canvas()->view()->getView();
+ return [self parentObjectUnignored];
+ }
+
+ if ([attributeName isEqualToString: NSAccessibilityChildrenAttribute]) {
+ NSMutableArray* arr = [NSMutableArray arrayWithCapacity: 8];
+ [self addChildrenToArray: arr];
+ return arr;
+ }
+
+ if ([attributeName isEqualToString: NSAccessibilityTitleAttribute])
+ return [self title];
+
+ if ([attributeName isEqualToString: NSAccessibilityValueAttribute])
+ return [self value];
+
+ if ([attributeName isEqualToString: NSAccessibilityHelpAttribute])
+ return @"Help";
+
+ if ([attributeName isEqualToString: NSAccessibilityFocusedAttribute])
+ return [NSNumber numberWithBool: (m_renderer->element() && m_renderer->document()->focusNode() == m_renderer->element())];
+
+ if ([attributeName isEqualToString: NSAccessibilityEnabledAttribute])
+ return [NSNumber numberWithBool: YES];
+
+ if ([attributeName isEqualToString: NSAccessibilitySizeAttribute])
+ return [self size];
+
+ if ([attributeName isEqualToString: NSAccessibilityPositionAttribute])
+ return [self position];
+
+ if ([attributeName isEqualToString: NSAccessibilityWindowAttribute])
+ return [m_renderer->canvas()->view()->getView() window];
+
+ return nil;
+}
+
+- (id)accessibilityHitTest:(NSPoint)point
+{
+ if (!m_renderer)
+ return self;
+
+ RenderObject::NodeInfo nodeInfo(true, true);
+ m_renderer->layer()->nodeAtPoint(nodeInfo, (int)point.x, (int)point.y);
+ if (!nodeInfo.innerNode())
+ return self;
+ RenderObject* obj = nodeInfo.innerNode()->renderer();
+ if (!obj)
+ return self;
+ return obj->document()->getOrCreateAccObjectCache()->accObject(obj);
+}
@end
diff --git a/WebCore/kwq/KWQAccObjectCache.mm b/WebCore/kwq/KWQAccObjectCache.mm
index 4e05341..a8359cf 100644
--- a/WebCore/kwq/KWQAccObjectCache.mm
+++ b/WebCore/kwq/KWQAccObjectCache.mm
@@ -40,16 +40,22 @@ KWQAccObjectCache::~KWQAccObjectCache()
KWQAccObject* KWQAccObjectCache::accObject(khtml::RenderObject* renderer)
{
if (!accCache)
- return NULL;
+ // No need to retain/free either impl key, or id value.
+ accCache = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
- return (KWQAccObject*)CFDictionaryGetValue(accCache, renderer);
+ KWQAccObject* obj = (KWQAccObject*)CFDictionaryGetValue(accCache, renderer);
+ if (!obj) {
+ obj = [[KWQAccObject alloc] initWithRenderer: renderer]; // Initial ref happens here.
+ setAccObject(renderer, obj);
+ }
+
+ return obj;
}
void KWQAccObjectCache::setAccObject(khtml::RenderObject* impl, KWQAccObject* accObject)
{
if (!accCache)
- // No need to retain/free either impl key, or id value. Items will be removed
- // from the cache in the object's dealloc method.
+ // No need to retain/free either impl key, or id value.
accCache = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
CFDictionarySetValue(accCache, (const void *)impl, accObject);
@@ -57,8 +63,15 @@ void KWQAccObjectCache::setAccObject(khtml::RenderObject* impl, KWQAccObject* ac
void KWQAccObjectCache::removeAccObject(khtml::RenderObject* impl)
{
- [accObject(impl) detach];
- CFDictionaryRemoveValue(accCache, impl);
+ if (!accCache)
+ return;
+
+ KWQAccObject* obj = (KWQAccObject*)CFDictionaryGetValue(accCache, impl);
+ if (obj) {
+ [obj detach];
+ [obj release];
+ CFDictionaryRemoveValue(accCache, impl);
+ }
}
void KWQAccObjectCache::detach(khtml::RenderObject* renderer)
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index bf4e777..ce9365a 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -227,6 +227,8 @@ typedef enum {
+ (void)updateAllViews;
+-(id)accessibilityTree;
+
@end
// The WebCoreBridge protocol contains methods for use by the WebCore side of the bridge.
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 01cc8a2..0c14794 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -56,6 +56,7 @@
#import "KWQRenderTreeDebug.h"
#import "KWQView.h"
#import "KWQPrinter.h"
+#import "KWQAccObjectCache.h"
#import "WebCoreDOMPrivate.h"
#import "WebCoreImageRenderer.h"
@@ -1034,4 +1035,11 @@ static HTMLFormElementImpl *formElementFromDOMElement(id <WebDOMElement>element)
view->adjustViewSize();
}
+-(id)accessibilityTree
+{
+ if (!_part || !_part->xmlDocImpl()) return nil;
+ RenderCanvas* root = static_cast<khtml::RenderCanvas *>(_part->xmlDocImpl()->renderer());
+ if (!root) return nil;
+ return _part->xmlDocImpl()->getOrCreateAccObjectCache()->accObject(root);
+}
@end
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list