2008-04-02 Beth Dakin <bdakin@apple.com>
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Apr 2008 22:02:45 +0000 (22:02 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Apr 2008 22:02:45 +0000 (22:02 +0000)
        Reviewed by Hyatt.

        This patch eliminates AccessibilityObjectMac. All of the platform-
        specific code is now in AccessibilityObjectWrapper.

        * WebCore.xcodeproj/project.pbxproj:
        * dom/Element.h:
        (WebCore::Element::isPasswordField):
        * html/HTMLInputElement.h:
        (WebCore::HTMLInputElement::isPasswordField):
        * page/AXObjectCache.h:
        (WebCore::AXObjectCache::isIDinUse):
        * page/AccessibilityObject.cpp:
        (WebCore::AccessibilityObject::isPasswordField):
        (WebCore::AccessibilityObject::press):
        (WebCore::AccessibilityObject::widgetForAttachmentView):
        (WebCore::AccessibilityObject::doAXBoundsForTextMarkerRange):
        (WebCore::AccessibilityObject::doAXTextMarkerForPosition):
        * page/AccessibilityObject.h:
        (WebCore::AccessibilityObject::areaElement):
        (WebCore::AccessibilityObject::setWrapper):
        * page/mac/AXObjectCacheMac.mm:
        * page/mac/AccessibilityObjectMac.mm: Removed.
        * page/mac/AccessibilityObjectWrapper.h:
        * page/mac/AccessibilityObjectWrapper.mm:
        (-[AccessibilityObjectWrapper attachmentView]):
        (textMarkerForVisiblePosition):
        (visiblePositionForTextMarker):
        (visiblePositionForStartOfTextMarkerRange):
        (visiblePositionForEndOfTextMarkerRange):
        (textMarkerRangeFromMarkers):
        (AXAttributeStringSetFont):
        (CreateCGColorIfDifferent):
        (AXAttributeStringSetColor):
        (AXAttributeStringSetNumber):
        (AXAttributeStringSetStyle):
        (blockquoteLevel):
        (AXAttributeStringSetBlockquoteLevel):
        (AXAttributeStringSetSpelling):
        (AXAttributeStringSetHeadingLevel):
        (AXLinkElementForNode):
        (AXAttributeStringSetElement):
        (AXAttributedStringAppendText):
        (nsStringForReplacedNode):
        (-[AccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]):
        (textMarkerRangeFromVisiblePositions):
        (-[AccessibilityObjectWrapper accessibilityActionNames]):
        (-[AccessibilityObjectWrapper accessibilityAttributeNames]):
        (-[AccessibilityObjectWrapper visiblePositionRangeForTextMarkerRange:]):
        (-[AccessibilityObjectWrapper textMarkerRangeForSelection]):
        (-[AccessibilityObjectWrapper position]):
        (createAccessibilityRoleMap):
        (RoleEntry::):
        (roleValueToNSString):
        (-[AccessibilityObjectWrapper role]):
        (-[AccessibilityObjectWrapper subrole]):
        (-[AccessibilityObjectWrapper roleDescription]):
        (-[AccessibilityObjectWrapper accessibilityAttributeValue:]):
        (-[AccessibilityObjectWrapper accessibilityIsIgnored]):
        (-[AccessibilityObjectWrapper accessibilityPerformAction:]):
        (-[AccessibilityObjectWrapper doAXAttributedStringForRange:]):
        (-[AccessibilityObjectWrapper doAXRTFForRange:]):
        (-[AccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
        (-[AccessibilityObjectWrapper accessibilityShouldUseUniqueId]):
        * platform/ScrollView.h:
        * platform/mac/ScrollViewMac.mm:
        (WebCore::ScrollView::viewRectToScreen):
        (WebCore::ScrollView::absolutePointToView):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@31608 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/Element.h
WebCore/html/HTMLInputElement.h
WebCore/page/AXObjectCache.h
WebCore/page/AccessibilityObject.cpp
WebCore/page/AccessibilityObject.h
WebCore/page/mac/AXObjectCacheMac.mm
WebCore/page/mac/AccessibilityObjectMac.mm [deleted file]
WebCore/page/mac/AccessibilityObjectWrapper.h
WebCore/page/mac/AccessibilityObjectWrapper.mm
WebCore/platform/ScrollView.h
WebCore/platform/mac/ScrollViewMac.mm

index 60e9f02f83542b29b967e470f626071a1f19d810..821a521be906500519ee5484705a5cc2e9d7a98b 100644 (file)
@@ -1,3 +1,74 @@
+2008-04-02  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Hyatt.
+
+        This patch eliminates AccessibilityObjectMac. All of the platform-
+        specific code is now in AccessibilityObjectWrapper.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Element.h:
+        (WebCore::Element::isPasswordField):
+        * html/HTMLInputElement.h:
+        (WebCore::HTMLInputElement::isPasswordField):
+        * page/AXObjectCache.h:
+        (WebCore::AXObjectCache::isIDinUse):
+        * page/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::isPasswordField):
+        (WebCore::AccessibilityObject::press):
+        (WebCore::AccessibilityObject::widgetForAttachmentView):
+        (WebCore::AccessibilityObject::doAXBoundsForTextMarkerRange):
+        (WebCore::AccessibilityObject::doAXTextMarkerForPosition):
+        * page/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::areaElement):
+        (WebCore::AccessibilityObject::setWrapper):
+        * page/mac/AXObjectCacheMac.mm:
+        * page/mac/AccessibilityObjectMac.mm: Removed.
+        * page/mac/AccessibilityObjectWrapper.h:
+        * page/mac/AccessibilityObjectWrapper.mm:
+        (-[AccessibilityObjectWrapper attachmentView]):
+        (textMarkerForVisiblePosition):
+        (visiblePositionForTextMarker):
+        (visiblePositionForStartOfTextMarkerRange):
+        (visiblePositionForEndOfTextMarkerRange):
+        (textMarkerRangeFromMarkers):
+        (AXAttributeStringSetFont):
+        (CreateCGColorIfDifferent):
+        (AXAttributeStringSetColor):
+        (AXAttributeStringSetNumber):
+        (AXAttributeStringSetStyle):
+        (blockquoteLevel):
+        (AXAttributeStringSetBlockquoteLevel):
+        (AXAttributeStringSetSpelling):
+        (AXAttributeStringSetHeadingLevel):
+        (AXLinkElementForNode):
+        (AXAttributeStringSetElement):
+        (AXAttributedStringAppendText):
+        (nsStringForReplacedNode):
+        (-[AccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]):
+        (textMarkerRangeFromVisiblePositions):
+        (-[AccessibilityObjectWrapper accessibilityActionNames]):
+        (-[AccessibilityObjectWrapper accessibilityAttributeNames]):
+        (-[AccessibilityObjectWrapper visiblePositionRangeForTextMarkerRange:]):
+        (-[AccessibilityObjectWrapper textMarkerRangeForSelection]):
+        (-[AccessibilityObjectWrapper position]):
+        (createAccessibilityRoleMap):
+        (RoleEntry::):
+        (roleValueToNSString):
+        (-[AccessibilityObjectWrapper role]):
+        (-[AccessibilityObjectWrapper subrole]):
+        (-[AccessibilityObjectWrapper roleDescription]):
+        (-[AccessibilityObjectWrapper accessibilityAttributeValue:]):
+        (-[AccessibilityObjectWrapper accessibilityIsIgnored]):
+        (-[AccessibilityObjectWrapper accessibilityPerformAction:]):
+        (-[AccessibilityObjectWrapper doAXAttributedStringForRange:]):
+        (-[AccessibilityObjectWrapper doAXRTFForRange:]):
+        (-[AccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+        (-[AccessibilityObjectWrapper accessibilityShouldUseUniqueId]):
+        * platform/ScrollView.h:
+        * platform/mac/ScrollViewMac.mm:
+        (WebCore::ScrollView::viewRectToScreen):
+        (WebCore::ScrollView::absolutePointToView):
+
 2008-04-03  David Hyatt  <hyatt@apple.com>
 
         Create a new cross-platform Gradient abstraction and make CanvasGradient wrap it.  This first
index 5d9c8cdb5f1f8d550e77f9a549ed981ffc7c86da..d468cd02dc475b4a943c3610b5e6fa128ebf041c 100644 (file)
                4B3043CC0AE0373B00A82647 /* Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B3043CA0AE0373B00A82647 /* Editor.cpp */; };
                4B3043CD0AE0373B00A82647 /* Editor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3043CB0AE0373B00A82647 /* Editor.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4B5B7C8E0D945CFA00DDF3AB /* AccessibilityObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5B7C8D0D945CFA00DDF3AB /* AccessibilityObject.cpp */; };
-               4B5B7C9C0D945D5600DDF3AB /* AccessibilityObjectMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B5B7C9B0D945D5500DDF3AB /* AccessibilityObjectMac.mm */; };
                4B6FA6F40C39E48C00087011 /* SmartReplace.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6FA6F20C39E48C00087011 /* SmartReplace.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4B6FA6F50C39E48C00087011 /* SmartReplace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6FA6F30C39E48C00087011 /* SmartReplace.cpp */; };
                4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */; };
                4B3043CA0AE0373B00A82647 /* Editor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Editor.cpp; sourceTree = "<group>"; };
                4B3043CB0AE0373B00A82647 /* Editor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Editor.h; sourceTree = "<group>"; };
                4B5B7C8D0D945CFA00DDF3AB /* AccessibilityObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityObject.cpp; sourceTree = "<group>"; };
-               4B5B7C9B0D945D5500DDF3AB /* AccessibilityObjectMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityObjectMac.mm; sourceTree = "<group>"; };
                4B6FA6F20C39E48C00087011 /* SmartReplace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartReplace.h; sourceTree = "<group>"; };
                4B6FA6F30C39E48C00087011 /* SmartReplace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartReplace.cpp; sourceTree = "<group>"; };
                4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartReplaceCF.cpp; sourceTree = "<group>"; };
                93C09A820B064F05005ABD4D /* mac */ = {
                        isa = PBXGroup;
                        children = (
-                               4B5B7C9B0D945D5500DDF3AB /* AccessibilityObjectMac.mm */,
                                4B17CBCA0D945B910053F183 /* AccessibilityObjectWrapper.mm */,
                                4B17CBCB0D945B910053F183 /* AccessibilityObjectWrapper.h */,
                                1AF326400D78B5530068F0C4 /* AXObjectCacheMac.mm */,
                                1CE3F8B40D89CFDC00FB035F /* MainThread.cpp in Sources */,
                                4B17CBCC0D945B910053F183 /* AccessibilityObjectWrapper.mm in Sources */,
                                4B5B7C8E0D945CFA00DDF3AB /* AccessibilityObject.cpp in Sources */,
-                               4B5B7C9C0D945D5600DDF3AB /* AccessibilityObjectMac.mm in Sources */,
                                512DD8E30D91E2B4000F89EE /* SharedBufferCF.cpp in Sources */,
                                512DD8F40D91E6AF000F89EE /* LegacyWebArchive.cpp in Sources */,
                                512DD8F70D91E6AF000F89EE /* ArchiveResourceCollection.cpp in Sources */,
index fbb73c4e0099516e81748ea9e2cddb70e2557083..502da126d893c583918898cf3fabcc2822d81dcc 100644 (file)
@@ -120,6 +120,7 @@ public:
     void normalizeAttributes();
 
     virtual bool isInputTypeHidden() const { return false; }
+    virtual bool isPasswordField() const { return false; }
 
     String nodeNamePreservingCase() const;
 
index 49e0ef80c11ae26b9d5423913355e4a149499601..2efeb624c051049b2bd93913747aed4bcb307d05 100644 (file)
@@ -82,6 +82,7 @@ public:
     bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH || m_type == ISINDEX; }
     bool isSearchField() const { return m_type == SEARCH; }
     virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
+    virtual bool isPasswordField() const { return m_type == PASSWORD; }
 
     bool checked() const { return m_checked; }
     void setChecked(bool, bool sendChangeEvent = false);
index 65930e9699956a42a2db46f39e525d97841dc30a..a86d04f8c294dcf99f724b5052458f37a481e643 100644 (file)
@@ -50,20 +50,20 @@ namespace WebCore {
         static TraitType deletedValue() { return UINT_MAX; }
     };
 
+    struct TextMarkerData  {
+        AXID axID;
+        Node* node;
+        int offset;
+        EAffinity affinity;
+    };
+
     class AXObjectCache {
     public:
         ~AXObjectCache();
 
         AccessibilityObject* get(RenderObject*);
         void remove(RenderObject*);
-
         void removeAXID(AccessibilityObject*);
-
-#if PLATFORM(MAC)
-        // FIXME: Move this to AccessibilityObjectWrapper.
-        WebCoreTextMarker* textMarkerForVisiblePosition(const VisiblePosition&);
-        VisiblePosition visiblePositionForTextMarker(WebCoreTextMarker*);
-#endif
         
         void childrenChanged(RenderObject*);
         void postNotification(RenderObject*, const String& message);
@@ -76,14 +76,14 @@ namespace WebCore {
 #else
         static bool accessibilityEnabled() { return false; }
 #endif
+        AXID getAXID(AccessibilityObject*);
+        bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); }
 
     private:
 #if PLATFORM(MAC)
         static bool gAccessibilityEnabled;
 #endif
 
-        AXID getAXID(AccessibilityObject*);
-
 #if PLATFORM(MAC)
         HashMap<RenderObject*, RefPtr<AccessibilityObject> > m_objects;
         HashSet<AXID, IntHash<AXID>, AXIDHashTraits> m_idsInUse;
index 88abad06898bb15fb4c131ba00d96b95ddce8716..1e7837aac174a1ddfa499a500709051f4071c625 100644 (file)
@@ -183,18 +183,15 @@ bool AccessibilityObject::isAttachment() const
     return isWidget;
 }
 
-bool isPasswordFieldElement(Node* node)
-{
-    if (!node || !node->hasTagName(inputTag))
-        return false;
-    
-    HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
-    return input->inputType() == HTMLInputElement::PASSWORD;
-}
-
 bool AccessibilityObject::isPasswordField() const
 {
-    return m_renderer && isPasswordFieldElement(m_renderer->element());
+    if (!m_renderer)
+        return 0;
+    if (!m_renderer->element())
+        return 0;
+    if (!m_renderer->element()->isHTMLElement())
+        return 0;
+    return static_cast<HTMLElement*>(m_renderer->element())->isPasswordField();
 }
 
 int AccessibilityObject::headingLevel(Node* node) const
@@ -740,12 +737,7 @@ bool AccessibilityObject::isEnabled()
 }
 
 void AccessibilityObject::press()
-{
-    if (isAttachment()) {
-        performPressActionForAttachment();
-        return;
-    }
-        
+{    
     Element* actionElem = actionElement();
     if (!actionElem)
         return;
@@ -809,6 +801,13 @@ FrameView* AccessibilityObject::documentFrameView()
     return m_renderer->document()->view();
 }
 
+Widget* AccessibilityObject::widgetForAttachmentView()
+{
+    if (!isAttachment())
+        return 0;
+    return static_cast<RenderWidget*>(m_renderer)->widget();
+}
+
 FrameView* AccessibilityObject::frameViewIfRenderView()
 {
     if (!m_renderer->isRenderView())
@@ -1156,7 +1155,11 @@ IntRect AccessibilityObject::doAXBoundsForTextMarkerRange(VisiblePositionRange v
             ourrect = boundingBox;
     }
 
-    return convertViewRectToScreenCoords(ourrect);
+#if PLATFORM(MAC)
+    return m_renderer->document()->view()->contentsToScreen(ourrect);
+#else
+    return ourrect;
+#endif
 }
 
 int AccessibilityObject::doAXLengthForTextMarkerRange(VisiblePositionRange visiblePositionRange)
@@ -1189,7 +1192,12 @@ VisiblePosition AccessibilityObject::doAXTextMarkerForPosition(const IntPoint& p
     // locate the node containing the point
     IntPoint pointResult;
     while (1) {
-        IntPoint ourpoint = convertAbsolutePointToViewCoords(point, frameView);
+        IntPoint ourpoint;
+#if PLATFORM(MAC)
+        ourpoint = frameView->screenToContents(point);
+#else
+        ourpoint = point;
+#endif
         HitTestRequest request(true, true);
         HitTestResult result(ourpoint);
         renderer->layer()->hitTest(request, result);
@@ -1509,11 +1517,6 @@ AccessibilityObject::PlainTextRange AccessibilityObject::doAXRangeForLine(unsign
 // screen coordinates.
 // NOTE: This varies from AppKit when the point is below the last line. AppKit returns an
 // an error in that case. We return textControl->text().length(), 1. Does this matter?
-
-// NOTE: Any existing callers of this function need to run code like this on the NSPoint
-// before passing it into this function as an IntPoint:
-// NSPoint windowCoord = [[view window] convertScreenToBase: point];
-// doAXTextMarkerForPosition([view convertPoint:windowCoord fromView:nil]);
 AccessibilityObject::PlainTextRange AccessibilityObject::doAXRangeForPosition(const IntPoint& point)
 {
     int index = indexForTextMarker(doAXTextMarkerForPosition(point));
index 45e977ed33f6a9938e0305f4a3eda0124ba8b83a..5452f3998ecd3f0ad2a62b4ed7d7f6e5174ba8c7 100644 (file)
@@ -241,12 +241,14 @@ public:
     void press();
     RenderObject* renderer() { return m_renderer; }
     RenderObject* topRenderer();
+    HTMLAreaElement* areaElement() { return m_areaElement.get(); }
     RenderTextControl* textControl();
     Widget* widget();
     AXObjectCache* axObjectCache();
     void documentLinks(Vector<RefPtr<AccessibilityObject> >&);
     FrameView* frameViewIfRenderView();
     FrameView* documentFrameView();
+    Widget* widgetForAttachmentView();
 
     VisiblePositionRange visiblePositionRange();
     VisiblePositionRange doAXTextMarkerRangeForLine(unsigned);
@@ -260,9 +262,6 @@ public:
     VisiblePositionRange doAXStyleTextMarkerRangeForTextMarker(const VisiblePosition&);
     VisiblePositionRange textMarkerRangeForRange(const PlainTextRange&, RenderTextControl*);
 
-    IntRect convertViewRectToScreenCoords(const IntRect&);
-    IntPoint convertAbsolutePointToViewCoords(const IntPoint&, const FrameView*);
-
     String doAXStringForTextMarkerRange(VisiblePositionRange&);
     IntRect doAXBoundsForTextMarkerRange(VisiblePositionRange);
     int doAXLengthForTextMarkerRange(VisiblePositionRange);
@@ -311,37 +310,6 @@ public:
 #if PLATFORM(MAC)
     AccessibilityObjectWrapper* wrapper() { return m_wrapper.get(); }
     void setWrapper(AccessibilityObjectWrapper* wrapper) { m_wrapper = wrapper; }
-
-    NSView* attachmentView();
-    void performPressActionForAttachment();
-    NSArray* accessibilityAttributeNames();
-    WebCoreTextMarkerRange* textMarkerRange(WebCoreTextMarker* fromMarker, WebCoreTextMarker* toMarker);
-    WebCoreTextMarker* textMarkerForVisiblePosition(VisiblePosition);
-    WebCoreTextMarker* startTextMarker();
-    VisiblePositionRange visiblePositionRangeForTextMarkerRange(WebCoreTextMarkerRange*);
-    VisiblePosition visiblePositionForTextMarker(WebCoreTextMarker*);
-    VisiblePosition visiblePositionForStartOfTextMarkerRange(WebCoreTextMarkerRange*);
-    VisiblePosition visiblePositionForEndOfTextMarkerRange(WebCoreTextMarkerRange*);
-    WebCoreTextMarkerRange* textMarkerRangeFromVisiblePositions(VisiblePosition startPosition, VisiblePosition endPosition);
-    WebCoreTextMarkerRange* textMarkerRangeForSelection();
-    WebCoreTextMarkerRange* textMarkerRange();
-    WebCoreTextMarkerRange* textMarkerRangeFromMarkers(WebCoreTextMarker*, WebCoreTextMarker*);
-    NSAttributedString* doAXAttributedStringForTextMarkerRange(WebCoreTextMarkerRange*);
-    NSAttributedString* doAXAttributedStringForRange(NSRange);
-    NSData* doAXRTFForRange(NSRange);
-
-    NSArray* convertChildrenToNSArray();
-    NSArray* convertWidgetChildrenToNSArray();
-   
-    NSValue* position(); 
-    NSString* role();
-    NSString* subrole();
-    NSString* roleDescription();
-    
-    void AXAttributeStringSetElement(NSMutableAttributedString*, NSString*, AccessibilityObject*, NSRange);
-    void AXAttributeStringSetHeadingLevel(NSMutableAttributedString*, RenderObject*, NSRange);
-    void AXAttributedStringAppendText(NSMutableAttributedString*, Node*, int offset, const UChar* chars, int length);
-    AccessibilityObject* AXLinkElementForNode(Node*);
 #endif
     
 private:
@@ -355,8 +323,6 @@ private:
 #endif
 };
 
-bool isPasswordFieldElement(Node*);
-
 } // namespace WebCore
 
 #endif // AccessibilityObject_h
index fbc5b9b799622fe18160ba902f3caf687e31ebe0..749dc2a08f5ed898ed0b1c99eadf51bc8eaee5af 100644 (file)
 
 namespace WebCore {
 
-struct TextMarkerData  {
-    AXID axID;
-    Node* node;
-    int offset;
-    EAffinity affinity;
-};
-
 bool AXObjectCache::gAccessibilityEnabled = false;
 
 AXObjectCache::~AXObjectCache()
@@ -117,52 +110,6 @@ void AXObjectCache::removeAXID(AccessibilityObject* obj)
     m_idsInUse.remove(objID);
 }
 
-WebCoreTextMarker* AXObjectCache::textMarkerForVisiblePosition(const VisiblePosition& visiblePos)
-{
-    Position deepPos = visiblePos.deepEquivalent();
-    Node* domNode = deepPos.node();
-    ASSERT(domNode);
-    if (!domNode)
-        return nil;
-    
-    // locate the renderer, which must exist for a visible dom node
-    RenderObject* renderer = domNode->renderer();
-    ASSERT(renderer);
-    
-    // find or create an accessibility object for this renderer
-    RefPtr<AccessibilityObject> obj = get(renderer);
-    
-    // create a text marker, adding an ID for the AccessibilityObject if needed
-    TextMarkerData textMarkerData;
-    textMarkerData.axID = getAXID(obj.get());
-    textMarkerData.node = domNode;
-    textMarkerData.offset = deepPos.offset();
-    textMarkerData.affinity = visiblePos.affinity();
-    return [[WebCoreViewFactory sharedFactory] textMarkerWithBytes:&textMarkerData length:sizeof(textMarkerData)]; 
-}
-
-VisiblePosition AXObjectCache::visiblePositionForTextMarker(WebCoreTextMarker* textMarker)
-{
-    TextMarkerData textMarkerData;
-    
-    if (![[WebCoreViewFactory sharedFactory] getBytes:&textMarkerData fromTextMarker:textMarker length:sizeof(textMarkerData)])
-        return VisiblePosition();
-
-    // return empty position if the text marker is no longer valid
-    if (!m_idsInUse.contains(textMarkerData.axID))
-        return VisiblePosition();
-
-    // generate a VisiblePosition from the data we stored earlier
-    VisiblePosition visiblePos = VisiblePosition(textMarkerData.node, textMarkerData.offset, textMarkerData.affinity);
-
-    // make sure the node and offset still match (catches stale markers). affinity is not critical for this.
-    Position deepPos = visiblePos.deepEquivalent();
-    if (deepPos.node() != textMarkerData.node || deepPos.offset() != textMarkerData.offset)
-        return VisiblePosition();
-    
-    return visiblePos;
-}
-
 void AXObjectCache::childrenChanged(RenderObject* renderer)
 {
     AccessibilityObject* obj = m_objects.get(renderer).get();
diff --git a/WebCore/page/mac/AccessibilityObjectMac.mm b/WebCore/page/mac/AccessibilityObjectMac.mm
deleted file mode 100644 (file)
index 181f254..0000000
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "AccessibilityObject.h"
-
-#import "AXObjectCache.h"
-#import "ColorMac.h"
-#import "HTMLAreaElement.h"
-#import "LocalizedStrings.h"
-#import "RenderView.h"
-#import "RenderWidget.h"
-#import "RenderTextControl.h"
-#import "Selection.h"
-#import "SimpleFontData.h"
-#import "TextIterator.h"
-#import "WebCoreViewFactory.h"
-#import "htmlediting.h"
-#import "visible_units.h"
-
-using namespace WebCore;
-using namespace HTMLNames;
-
-typedef HashMap<int, NSString*> AccessibilityRoleMap;
-
-static const AccessibilityRoleMap& createAccessibilityRoleMap()
-{
-    struct RoleEntry {
-        AccessibilityRole value;
-        NSString* string;
-    };
-    
-    static const RoleEntry roles[] = {
-        { UnknownRole, NSAccessibilityUnknownRole },
-        { ButtonRole, NSAccessibilityButtonRole },
-        { RadioButtonRole, NSAccessibilityRadioButtonRole },
-        { CheckBoxRole, NSAccessibilityCheckBoxRole },
-        { SliderRole, NSAccessibilitySliderRole },
-        { TabGroupRole, NSAccessibilityTabGroupRole },
-        { TextFieldRole, NSAccessibilityTextFieldRole },
-        { StaticTextRole, NSAccessibilityStaticTextRole },
-        { TextAreaRole, NSAccessibilityTextAreaRole },
-        { ScrollAreaRole, NSAccessibilityScrollAreaRole },
-        { PopUpButtonRole, NSAccessibilityPopUpButtonRole },
-        { MenuButtonRole, NSAccessibilityMenuButtonRole },
-        { TableRole, NSAccessibilityTableRole },
-        { ApplicationRole, NSAccessibilityApplicationRole },
-        { GroupRole, NSAccessibilityGroupRole },
-        { RadioGroupRole, NSAccessibilityRadioGroupRole },
-        { ListRole, NSAccessibilityListRole },
-        { ScrollBarRole, NSAccessibilityScrollBarRole },
-        { ValueIndicatorRole, NSAccessibilityValueIndicatorRole },
-        { ImageRole, NSAccessibilityImageRole },
-        { MenuBarRole, NSAccessibilityMenuBarRole },
-        { MenuRole, NSAccessibilityMenuRole },
-        { MenuItemRole, NSAccessibilityMenuItemRole },
-        { ColumnRole, NSAccessibilityColumnRole },
-        { RowRole, NSAccessibilityRowRole },
-        { ToolbarRole, NSAccessibilityToolbarRole },
-        { BusyIndicatorRole, NSAccessibilityBusyIndicatorRole },
-        { ProgressIndicatorRole, NSAccessibilityProgressIndicatorRole },
-        { WindowRole, NSAccessibilityWindowRole },
-        { DrawerRole, NSAccessibilityDrawerRole },
-        { SystemWideRole, NSAccessibilitySystemWideRole },
-        { OutlineRole, NSAccessibilityOutlineRole },
-        { IncrementorRole, NSAccessibilityIncrementorRole },
-        { BrowserRole, NSAccessibilityBrowserRole },
-        { ComboBoxRole, NSAccessibilityComboBoxRole },
-        { SplitGroupRole, NSAccessibilitySplitGroupRole },
-        { SplitterRole, NSAccessibilitySplitterRole },
-        { ColorWellRole, NSAccessibilityColorWellRole },
-        { GrowAreaRole, NSAccessibilityGrowAreaRole },
-        { SheetRole, NSAccessibilitySheetRole },
-        { HelpTagRole, NSAccessibilityHelpTagRole },
-        { MatteRole, NSAccessibilityMatteRole }, 
-        { RulerRole, NSAccessibilityRulerRole },
-        { RulerMarkerRole, NSAccessibilityRulerMarkerRole },
-        { SortButtonRole, NSAccessibilitySortButtonRole },
-        { LinkRole, NSAccessibilityLinkRole },
-#ifndef BUILDING_ON_TIGER        
-        { DisclosureTriangleRole, NSAccessibilityDisclosureTriangleRole },
-        { GridRole, NSAccessibilityGridRole },
-#endif
-        { WebCoreLinkRole, @"AXLink" }, // why isn't this just NSAccessibilityLinkRole ?
-        { ImageMapRole, @"AXImageMap" },
-        { ListMarkerRole, @"AXListMarker" },
-        { WebAreaRole, @"AXWebArea" },
-        { HeadingRole, @"AXHeading" }
-    };
-    AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;
-    
-    const unsigned numRoles = sizeof(roles) / sizeof(roles[0]);
-    for (unsigned i = 0; i < numRoles; ++i)
-        roleMap.set(roles[i].value, roles[i].string);
-    return roleMap;
-}
-
-static NSString* roleValueToNSString(AccessibilityRole value)
-{
-    ASSERT(value);
-    static const AccessibilityRoleMap& roleMap = createAccessibilityRoleMap();
-    return roleMap.get(value);
-}
-
-NSView* AccessibilityObject::attachmentView()
-{
-    ASSERT(m_renderer->isReplaced() && m_renderer->isWidget() && !m_renderer->isImage());
-
-    Widget* widget = static_cast<RenderWidget*>(m_renderer)->widget();
-    if (!widget)
-        return nil;
-    return widget->getView();
-}
-
-void AccessibilityObject::performPressActionForAttachment()
-{
-    [attachmentView() accessibilityPerformAction:NSAccessibilityPressAction];
-}
-
-WebCoreTextMarkerRange* AccessibilityObject::textMarkerRange(WebCoreTextMarker* fromMarker, WebCoreTextMarker* toMarker)
-{
-    return [[WebCoreViewFactory sharedFactory] textMarkerRangeWithStart:fromMarker end:toMarker];
-}
-
-WebCoreTextMarker* AccessibilityObject::textMarkerForVisiblePosition(VisiblePosition visiblePos)
-{
-    if (visiblePos.isNull())
-        return nil;
-    
-    if (isPasswordFieldElement(visiblePos.deepEquivalent().node()))
-        return nil;
-        
-    return m_renderer->document()->axObjectCache()->textMarkerForVisiblePosition(visiblePos);
-}
-
-WebCoreTextMarker* AccessibilityObject::startTextMarker()
-{
-    return textMarkerForVisiblePosition(startOfDocument(m_renderer->document()));
-}
-
-VisiblePosition AccessibilityObject::visiblePositionForTextMarker(WebCoreTextMarker* textMarker)
-{
-    return m_renderer->document()->axObjectCache()->visiblePositionForTextMarker(textMarker);
-}
-
-VisiblePosition AccessibilityObject::visiblePositionForStartOfTextMarkerRange(WebCoreTextMarkerRange* textMarkerRange)
-{
-    return visiblePositionForTextMarker([[WebCoreViewFactory sharedFactory] startOfTextMarkerRange:textMarkerRange]);
-}
-
-VisiblePosition AccessibilityObject::visiblePositionForEndOfTextMarkerRange(WebCoreTextMarkerRange* textMarkerRange)
-{
-    return visiblePositionForTextMarker([[WebCoreViewFactory sharedFactory] endOfTextMarkerRange:textMarkerRange]);
-}
-
-WebCoreTextMarkerRange* AccessibilityObject::textMarkerRangeFromVisiblePositions(VisiblePosition startPosition, VisiblePosition endPosition)
-{
-    WebCoreTextMarker* startTextMarker = textMarkerForVisiblePosition(startPosition);
-    WebCoreTextMarker* endTextMarker   = textMarkerForVisiblePosition(endPosition);
-    return textMarkerRangeFromMarkers(startTextMarker, endTextMarker);
-}
-
-WebCoreTextMarkerRange* AccessibilityObject::textMarkerRangeForSelection()
-{
-    Selection selection = this->selection();
-    if (selection.isNone())
-        return nil;
-    return textMarkerRangeFromVisiblePositions(selection.visibleStart(), selection.visibleEnd());
-}
-
-WebCoreTextMarkerRange* AccessibilityObject::textMarkerRange()
-{
-    if (!m_renderer)
-        return nil;
-    
-    // construct VisiblePositions for start and end
-    Node* node = m_renderer->element();
-    VisiblePosition visiblePos1 = VisiblePosition(node, 0, VP_DEFAULT_AFFINITY);
-    VisiblePosition visiblePos2 = VisiblePosition(node, maxDeepOffset(node), VP_DEFAULT_AFFINITY);
-    
-    // the VisiblePositions are equal for nodes like buttons, so adjust for that
-    if (visiblePos1 == visiblePos2) {
-        visiblePos2 = visiblePos2.next();
-        if (visiblePos2.isNull())
-            visiblePos2 = visiblePos1;
-    }
-    
-    WebCoreTextMarker* startTextMarker = textMarkerForVisiblePosition(visiblePos1);
-    WebCoreTextMarker* endTextMarker   = textMarkerForVisiblePosition(visiblePos2);
-    return textMarkerRangeFromMarkers(startTextMarker, endTextMarker);
-}
-
-WebCoreTextMarkerRange* AccessibilityObject::textMarkerRangeFromMarkers(WebCoreTextMarker* textMarker1, WebCoreTextMarker* textMarker2)
-{
-    return [[WebCoreViewFactory sharedFactory] textMarkerRangeWithStart:textMarker1 end:textMarker2];
-}
-
-IntRect AccessibilityObject::convertViewRectToScreenCoords(const IntRect& ourrect)
-{
-    // convert our rectangle to screen coordinates
-    FrameView* fv = m_renderer->document()->view();
-    NSView *view = fv->getView();
-    NSRect rect = ourrect;
-    rect = NSOffsetRect(rect, -fv->contentsX(), -fv->contentsY());
-    rect = [view convertRect:rect toView:nil];
-    rect.origin = [[view window] convertBaseToScreen:rect.origin];
-
-    // return the converted rect
-    return enclosingIntRect(rect);
-}
-
-IntPoint AccessibilityObject::convertAbsolutePointToViewCoords(const IntPoint& point, const FrameView* frameView)
-{
-    NSView* view = frameView->documentView();
-    NSPoint windowCoord = [[view window] convertScreenToBase: point];
-    return IntPoint([view convertPoint:windowCoord fromView:nil]);
-}
-
-NSArray* AccessibilityObject::convertWidgetChildrenToNSArray()
-{
-    if (!m_renderer->isWidget())
-        return nil;
-
-    RenderWidget* renderWidget = static_cast<RenderWidget*>(m_renderer);
-    Widget* widget = renderWidget->widget();
-    if (!widget)
-        return nil;
-
-    NSArray* childArr = [(widget->getOuterView()) accessibilityAttributeValue: NSAccessibilityChildrenAttribute];
-    return childArr;
-}
-
-NSValue* AccessibilityObject::position()
-{
-    IntRect rect = m_areaElement ? m_areaElement->getRect(m_renderer) : boundingBoxRect();
-    
-    // The Cocoa accessibility API wants the lower-left corner.
-    NSPoint point = NSMakePoint(rect.x(), rect.bottom());
-    if (m_renderer && m_renderer->view() && m_renderer->view()->frameView()) {
-        NSView* view = m_renderer->view()->frameView()->documentView();
-        point = [[view window] convertBaseToScreen: [view convertPoint: point toView:nil]];
-    }
-
-    return [NSValue valueWithPoint: point];
-}
-
-NSString* AccessibilityObject::role()
-{
-    if (isAttachment())
-        return [attachmentView() accessibilityAttributeValue:NSAccessibilityRoleAttribute];
-    NSString* string = roleValueToNSString(roleValue());
-    if (string != nil)
-        return string;
-    return NSAccessibilityUnknownRole;
-}
-
-NSString* AccessibilityObject::subrole()
-{
-    if (isPasswordField())
-        return NSAccessibilitySecureTextFieldSubrole;
-    
-    if (isAttachment()) {
-        NSView* attachView = attachmentView();
-        if ([[attachView accessibilityAttributeNames] containsObject:NSAccessibilitySubroleAttribute]) {
-            return [attachView accessibilityAttributeValue:NSAccessibilitySubroleAttribute];
-        }
-    }
-
-    return nil;
-}
-
-NSString* AccessibilityObject::roleDescription()
-{
-    if (!m_renderer)
-        return nil;
-
-    // attachments have the AXImage role, but a different subrole
-    if (isAttachment())
-        return [attachmentView() accessibilityAttributeValue:NSAccessibilityRoleDescriptionAttribute];
-    
-    // FIXME 3447564: It would be better to call some AppKit API to get these strings
-    // (which would be the best way to localize them)
-    
-    NSString* axRole = role();
-    if ([axRole isEqualToString:NSAccessibilityButtonRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityButtonRole, subrole());
-    
-    if ([axRole isEqualToString:NSAccessibilityPopUpButtonRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityPopUpButtonRole, subrole());
-   
-    if ([axRole isEqualToString:NSAccessibilityStaticTextRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityStaticTextRole, subrole());
-
-    if ([axRole isEqualToString:NSAccessibilityImageRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityImageRole, subrole());
-    
-    if ([axRole isEqualToString:NSAccessibilityGroupRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, subrole());
-    
-    if ([axRole isEqualToString:NSAccessibilityCheckBoxRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityCheckBoxRole, subrole());
-        
-    if ([axRole isEqualToString:NSAccessibilityRadioButtonRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityRadioButtonRole, subrole());
-        
-    if ([axRole isEqualToString:NSAccessibilityTextFieldRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityTextFieldRole, subrole());
-
-    if ([axRole isEqualToString:NSAccessibilityTextAreaRole])
-        return NSAccessibilityRoleDescription(NSAccessibilityTextAreaRole, subrole());
-
-    if ([axRole isEqualToString:@"AXWebArea"])
-        return AXWebAreaText();
-    
-    if ([axRole isEqualToString:@"AXLink"])
-        return AXLinkText();
-    
-    if ([axRole isEqualToString:@"AXListMarker"])
-        return AXListMarkerText();
-    
-    if ([axRole isEqualToString:@"AXImageMap"])
-        return AXImageMapText();
-
-    if ([axRole isEqualToString:@"AXHeading"])
-        return AXHeadingText();
-    
-    return NSAccessibilityRoleDescription(NSAccessibilityUnknownRole, nil);
-}
-
-static int blockquoteLevel(RenderObject* renderer)
-{
-    int result = 0;
-    for (Node* node = renderer->element(); node; node = node->parent()) {
-        if (node->hasTagName(blockquoteTag))
-            result += 1;
-    }
-    
-    return result;
-}
-
-void AccessibilityObject::AXAttributeStringSetElement(NSMutableAttributedString* attrString, NSString* attribute, AccessibilityObject* object, NSRange range)
-{
-    if (object) {
-        // make a serialiazable AX object
-        RenderObject* renderer = object->renderer();
-        if (!renderer)
-            return;
-        
-        Document* doc = renderer->document();
-        if (!doc)
-            return;
-        
-        AXObjectCache* cache = doc->axObjectCache();
-        if (!cache)
-            return;
-
-        AXUIElementRef axElement = [[WebCoreViewFactory sharedFactory] AXUIElementForElement:object->wrapper()];
-        if (axElement) {
-            [attrString addAttribute:attribute value:(id)axElement range:range];
-            CFRelease(axElement);
-        }
-    } else
-        [attrString removeAttribute:attribute range:range];
-}
-
-static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
-{
-    int quoteLevel = blockquoteLevel(renderer);
-    
-    if (quoteLevel)
-        [attrString addAttribute:@"AXBlockQuoteLevel" value:[NSNumber numberWithInt:quoteLevel] range:range];
-    else
-        [attrString removeAttribute:@"AXBlockQuoteLevel" range:range];
-}
-
-static CGColorRef CreateCGColorIfDifferent(NSColor* nsColor, CGColorRef existingColor)
-{
-    // get color information assuming NSDeviceRGBColorSpace 
-    NSColor* rgbColor = [nsColor colorUsingColorSpaceName:NSDeviceRGBColorSpace];
-    if (rgbColor == nil)
-        rgbColor = [NSColor blackColor];
-    CGFloat components[4];
-    [rgbColor getRed:&components[0] green:&components[1] blue:&components[2] alpha:&components[3]];
-    
-    // create a new CGColorRef to return
-    CGColorSpaceRef cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
-    CGColorRef cgColor = CGColorCreate(cgColorSpace, components);
-    CGColorSpaceRelease(cgColorSpace);
-    CFMakeCollectable(cgColor);
-    
-    // check for match with existing color
-    if (existingColor && CGColorEqualToColor(cgColor, existingColor))
-        cgColor = nil;
-        
-    return cgColor;
-}
-
-static void AXAttributeStringSetColor(NSMutableAttributedString* attrString, NSString* attribute, NSColor* color, NSRange range)
-{
-    if (color) {
-        CGColorRef existingColor = (CGColorRef) [attrString attribute:attribute atIndex:range.location effectiveRange:nil];
-        CGColorRef cgColor = CreateCGColorIfDifferent(color, existingColor);
-        if (cgColor) {
-            [attrString addAttribute:attribute value:(id)cgColor range:range];
-            CGColorRelease(cgColor);
-        }
-    } else
-        [attrString removeAttribute:attribute range:range];
-}
-
-static void AXAttributeStringSetNumber(NSMutableAttributedString* attrString, NSString* attribute, NSNumber* number, NSRange range)
-{
-    if (number)
-        [attrString addAttribute:attribute value:number range:range];
-    else
-        [attrString removeAttribute:attribute range:range];
-}
-
-static void AXAttributeStringSetFont(NSMutableAttributedString* attrString, NSString* attribute, NSFont* font, NSRange range)
-{
-    NSDictionary* dict;
-    
-    if (font) {
-        dict = [NSDictionary dictionaryWithObjectsAndKeys:
-            [font fontName]                             , NSAccessibilityFontNameKey,
-            [font familyName]                           , NSAccessibilityFontFamilyKey,
-            [font displayName]                          , NSAccessibilityVisibleNameKey,
-            [NSNumber numberWithFloat:[font pointSize]] , NSAccessibilityFontSizeKey,
-        nil];
-
-        [attrString addAttribute:attribute value:dict range:range];
-    } else
-        [attrString removeAttribute:attribute range:range];
-    
-}
-
-static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
-{
-    RenderStyle* style = renderer->style();
-
-    // set basic font info
-    AXAttributeStringSetFont(attrString, NSAccessibilityFontTextAttribute, style->font().primaryFont()->getNSFont(), range);
-
-    // set basic colors
-    AXAttributeStringSetColor(attrString, NSAccessibilityForegroundColorTextAttribute, nsColor(style->color()), range);
-    AXAttributeStringSetColor(attrString, NSAccessibilityBackgroundColorTextAttribute, nsColor(style->backgroundColor()), range);
-
-    // set super/sub scripting
-    EVerticalAlign alignment = style->verticalAlign();
-    if (alignment == SUB)
-        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, [NSNumber numberWithInt:(-1)], range);
-    else if (alignment == SUPER)
-        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, [NSNumber numberWithInt:1], range);
-    else
-        [attrString removeAttribute:NSAccessibilitySuperscriptTextAttribute range:range];
-    
-    // set shadow
-    if (style->textShadow())
-        AXAttributeStringSetNumber(attrString, NSAccessibilityShadowTextAttribute, [NSNumber numberWithBool:YES], range);
-    else
-        [attrString removeAttribute:NSAccessibilityShadowTextAttribute range:range];
-    
-    // set underline and strikethrough
-    int decor = style->textDecorationsInEffect();
-    if ((decor & UNDERLINE) == 0) {
-        [attrString removeAttribute:NSAccessibilityUnderlineTextAttribute range:range];
-        [attrString removeAttribute:NSAccessibilityUnderlineColorTextAttribute range:range];
-    }
-    
-    if ((decor & LINE_THROUGH) == 0) {
-        [attrString removeAttribute:NSAccessibilityStrikethroughTextAttribute range:range];
-        [attrString removeAttribute:NSAccessibilityStrikethroughColorTextAttribute range:range];
-    }
-
-    if ((decor & (UNDERLINE | LINE_THROUGH)) != 0) {
-        // find colors using quirk mode approach (strict mode would use current
-        // color for all but the root line box, which would use getTextDecorationColors)
-        Color underline, overline, linethrough;
-        renderer->getTextDecorationColors(decor, underline, overline, linethrough);
-        
-        if ((decor & UNDERLINE) != 0) {
-            AXAttributeStringSetNumber(attrString, NSAccessibilityUnderlineTextAttribute, [NSNumber numberWithBool:YES], range);
-            AXAttributeStringSetColor(attrString, NSAccessibilityUnderlineColorTextAttribute, nsColor(underline), range);
-        }
-
-        if ((decor & LINE_THROUGH) != 0) {
-            AXAttributeStringSetNumber(attrString, NSAccessibilityStrikethroughTextAttribute, [NSNumber numberWithBool:YES], range);
-            AXAttributeStringSetColor(attrString, NSAccessibilityStrikethroughColorTextAttribute, nsColor(linethrough), range);
-        }
-    }
-}
-
-void AccessibilityObject::AXAttributeStringSetHeadingLevel(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
-{
-    int parentHeadingLevel = headingLevel(renderer->parent()->element());
-    
-    if (parentHeadingLevel)
-        [attrString addAttribute:@"AXHeadingLevel" value:[NSNumber numberWithInt:parentHeadingLevel] range:range];
-    else
-        [attrString removeAttribute:@"AXHeadingLevel" range:range];
-}
-
-AccessibilityObject* AccessibilityObject::AXLinkElementForNode (Node* node)
-{
-    RenderObject* obj = node->renderer();
-    if (!obj)
-        return 0;
-
-    RefPtr<AccessibilityObject> axObj = obj->document()->axObjectCache()->get(obj);
-    HTMLAnchorElement* anchor = axObj->anchorElement();
-    if (!anchor || !anchor->renderer())
-        return 0;
-
-    return anchor->renderer()->document()->axObjectCache()->get(anchor->renderer());
-}
-
-static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, int offset, NSRange range)
-{
-    Vector<DocumentMarker> markers = node->renderer()->document()->markersForNode(node);
-    Vector<DocumentMarker>::iterator markerIt = markers.begin();
-
-    unsigned endOffset = (unsigned)offset + range.length;
-    for ( ; markerIt != markers.end(); markerIt++) {
-        DocumentMarker marker = *markerIt;
-        
-        if (marker.type != DocumentMarker::Spelling)
-            continue;
-        
-        if (marker.endOffset <= (unsigned)offset)
-            continue;
-        
-        if (marker.startOffset > endOffset)
-            break;
-        
-        // add misspelling attribute for the intersection of the marker and the range
-        int rStart = range.location + (marker.startOffset - offset);
-        int rLength = MIN(marker.endOffset, endOffset) - marker.startOffset;
-        NSRange spellRange = NSMakeRange(rStart, rLength);
-        AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, [NSNumber numberWithBool:YES], spellRange);
-        
-        if (marker.endOffset > endOffset + 1)
-            break;
-    }
-}
-
-void AccessibilityObject::AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, int offset, const UChar* chars, int length)
-{
-    // skip invisible text
-    if (!node->renderer())
-        return;
-        
-    // easier to calculate the range before appending the string
-    NSRange attrStringRange = NSMakeRange([attrString length], length);
-    
-    // append the string from this node
-    [[attrString mutableString] appendString:[NSString stringWithCharacters:chars length:length]];
-
-    // add new attributes and remove irrelevant inherited ones
-    // NOTE: color attributes are handled specially because -[NSMutableAttributedString addAttribute: value: range:] does not merge
-    // identical colors.  Workaround is to not replace an existing color attribute if it matches what we are adding.  This also means
-    // we cannot just pre-remove all inherited attributes on the appended string, so we have to remove the irrelevant ones individually.
-
-    // remove inherited attachment from prior AXAttributedStringAppendReplaced
-    [attrString removeAttribute:NSAccessibilityAttachmentTextAttribute range:attrStringRange];
-    
-    // set new attributes
-    AXAttributeStringSetStyle(attrString, node->renderer(), attrStringRange);
-    AXAttributeStringSetHeadingLevel(attrString, node->renderer(), attrStringRange);
-    AXAttributeStringSetBlockquoteLevel(attrString, node->renderer(), attrStringRange);
-    AXAttributeStringSetElement(attrString, NSAccessibilityLinkTextAttribute, AXLinkElementForNode(node), attrStringRange);
-    
-    // do spelling last because it tends to break up the range
-    AXAttributeStringSetSpelling(attrString, node, offset, attrStringRange);
-}
-
-static NSString* nsStringForReplacedNode(Node* replacedNode)
-{
-    // we should always be given a rendered node and a replaced node, but be safe
-    // replaced nodes are either attachments (widgets) or images
-    if (!replacedNode || !replacedNode->renderer() || !replacedNode->renderer()->isReplaced() || replacedNode->isTextNode()) {
-        ASSERT_NOT_REACHED();
-        return nil;
-    }
-
-    // create an AX object, but skip it if it is not supposed to be seen
-    RefPtr<AccessibilityObject> obj = replacedNode->renderer()->document()->axObjectCache()->get(replacedNode->renderer());
-    if (obj->accessibilityIsIgnored())
-        return nil;
-    
-    // use the attachmentCharacter to represent the replaced node
-    const UniChar attachmentChar = NSAttachmentCharacter;
-    return [NSString stringWithCharacters:&attachmentChar length:1];
-}
-
-NSAttributedString* AccessibilityObject::doAXAttributedStringForTextMarkerRange(WebCoreTextMarkerRange* textMarkerRange)
-{
-    // extract the start and end VisiblePosition
-    VisiblePosition startVisiblePosition = visiblePositionForStartOfTextMarkerRange(textMarkerRange);
-    if (startVisiblePosition.isNull())
-        return nil;
-
-    VisiblePosition endVisiblePosition = visiblePositionForEndOfTextMarkerRange(textMarkerRange);
-    if (endVisiblePosition.isNull())
-        return nil;
-
-    // iterate over the range to build the AX attributed string
-    NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] init];
-    TextIterator it(makeRange(startVisiblePosition, endVisiblePosition).get());
-    while (!it.atEnd()) {
-        // locate the node and starting offset for this range
-        int exception = 0;
-        Node* node = it.range()->startContainer(exception);
-        ASSERT(node == it.range()->endContainer(exception));
-        int offset = it.range()->startOffset(exception);
-
-        // non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
-        if (it.length() != 0) {
-            AXAttributedStringAppendText(attrString, node, offset, it.characters(), it.length());
-        } else {
-            Node* replacedNode = node->childNode(offset);
-            NSString *attachmentString = nsStringForReplacedNode(replacedNode);
-            if (attachmentString) {
-                NSRange attrStringRange = NSMakeRange([attrString length], [attachmentString length]);
-
-                // append the placeholder string
-                [[attrString mutableString] appendString:attachmentString];
-
-                // remove all inherited attributes
-                [attrString setAttributes:nil range:attrStringRange];
-
-                // add the attachment attribute
-                AccessibilityObject* obj = replacedNode->renderer()->document()->axObjectCache()->get(replacedNode->renderer());
-                AXAttributeStringSetElement(attrString, NSAccessibilityAttachmentTextAttribute, obj, attrStringRange);
-            }
-        }
-        it.advance();
-    }
-
-    return [attrString autorelease];
-}
-
-// The CFAttributedStringType representation of the text associated with this accessibility
-// object that is specified by the given range.
-NSAttributedString* AccessibilityObject::doAXAttributedStringForRange(NSRange range)
-{
-    AccessibilityObject::PlainTextRange textRange = AccessibilityObject::PlainTextRange(range.location, range.length);
-    VisiblePositionRange visiblePosRange = textMarkerRangeForRange(textRange, static_cast<RenderTextControl*>(m_renderer));
-    return doAXAttributedStringForTextMarkerRange(textMarkerRangeFromVisiblePositions(visiblePosRange.start, visiblePosRange.end));
-}
-
-// The RTF representation of the text associated with this accessibility object that is
-// specified by the given range.
-NSData* AccessibilityObject::doAXRTFForRange(NSRange range)
-{
-    NSAttributedString* attrString = doAXAttributedStringForRange(range);
-    return [attrString RTFFromRange: NSMakeRange(0, [attrString length]) documentAttributes: nil];
-}
index 9d6fa25f944d13a0e1259ce2a1f801980a29d98f..2c75c1d8af50ad765ac35d7a71d7b9e5e61f3716 100644 (file)
  */
  
 #import <wtf/RefPtr.h> 
+
+#ifdef __OBJC__
+@class WebCoreTextMarker;
+@class WebCoreTextMarkerRange;
+#else
+class WebCoreTextMarker;
+class WebCoreTextMarkerRange;
+#endif
+
 namespace WebCore {
     class AccessibilityObject;
+    class VisiblePosition;
 }
 
 @interface AccessibilityObjectWrapper : NSObject
index 472bef1ff57e13f628e94870c8d7322ff210ec81..5e7d025ae84e3d8d3f0822f5bac06af53b238f9c 100644 (file)
 #import "AccessibilityObjectWrapper.h"
 
 #import "AXObjectCache.h"
+#import "ColorMac.h"
 #import "Frame.h"
 #import "HTMLAnchorElement.h"
+#import "HTMLAreaElement.h"
 #import "HTMLImageElement.h"
 #import "HTMLInputElement.h"
 #import "HTMLTextAreaElement.h"
+#import "LocalizedStrings.h"
 #import "RenderTextControl.h"
 #import "RenderView.h"
 #import "RenderWidget.h"
 #import "SelectionController.h"
+#import "SimpleFontData.h"
 #import "TextIterator.h"
 #import "WebCoreFrameView.h"
 #import "WebCoreObjCExtras.h"
@@ -86,6 +90,400 @@ using namespace HTMLNames;
     return m_object;
 }
 
+- (NSView*)attachmentView
+{
+    ASSERT(m_object->isAttachment());
+    Widget* widget = m_object->widgetForAttachmentView();
+    if (!widget)
+        return nil;
+    return widget->getView();
+}
+
+static WebCoreTextMarker* textMarkerForVisiblePosition(const VisiblePosition& visiblePos)
+{
+    if (visiblePos.isNull())
+        return nil;
+
+    Position deepPos = visiblePos.deepEquivalent();
+    Node* domNode = deepPos.node();
+    ASSERT(domNode);
+    if (!domNode)
+        return nil;
+
+    if (domNode->isHTMLElement())
+        if (static_cast<HTMLElement*>(domNode)->isPasswordField())
+            return nil;
+
+    // locate the renderer, which must exist for a visible dom node
+    RenderObject* renderer = domNode->renderer();
+    ASSERT(renderer);
+
+    // find or create an accessibility object for this renderer
+    AXObjectCache* cache = renderer->document()->axObjectCache();
+    RefPtr<AccessibilityObject> obj =  cache->get(renderer);
+
+    // create a text marker, adding an ID for the AccessibilityObject if needed
+    TextMarkerData textMarkerData;
+    textMarkerData.axID = cache->getAXID(obj.get());
+    textMarkerData.node = domNode;
+    textMarkerData.offset = deepPos.offset();
+    textMarkerData.affinity = visiblePos.affinity();
+    return [[WebCoreViewFactory sharedFactory] textMarkerWithBytes:&textMarkerData length:sizeof(textMarkerData)];
+}
+
+static VisiblePosition visiblePositionForTextMarker(WebCoreTextMarker* textMarker)
+{
+    TextMarkerData textMarkerData;
+    
+    if (![[WebCoreViewFactory sharedFactory] getBytes:&textMarkerData fromTextMarker:textMarker length:sizeof(textMarkerData)])
+        return VisiblePosition();
+
+    VisiblePosition visiblePos = VisiblePosition(textMarkerData.node, textMarkerData.offset, textMarkerData.affinity);
+    Position deepPos = visiblePos.deepEquivalent();
+    AXObjectCache* cache = deepPos.node()->renderer()->document()->axObjectCache();
+    if (!cache->isIDinUse(textMarkerData.axID))
+        return VisiblePosition();
+
+    if (deepPos.node() != textMarkerData.node || deepPos.offset() != textMarkerData.offset)
+        return VisiblePosition();
+    
+    return visiblePos;
+}
+
+static VisiblePosition visiblePositionForStartOfTextMarkerRange(WebCoreTextMarkerRange* textMarkerRange)
+{
+    return visiblePositionForTextMarker([[WebCoreViewFactory sharedFactory] startOfTextMarkerRange:textMarkerRange]);
+}
+
+static VisiblePosition visiblePositionForEndOfTextMarkerRange(WebCoreTextMarkerRange* textMarkerRange)
+{
+    return visiblePositionForTextMarker([[WebCoreViewFactory sharedFactory] endOfTextMarkerRange:textMarkerRange]);
+}
+
+static WebCoreTextMarkerRange* textMarkerRangeFromMarkers(WebCoreTextMarker* textMarker1, WebCoreTextMarker* textMarker2)
+{
+    return [[WebCoreViewFactory sharedFactory] textMarkerRangeWithStart:textMarker1 end:textMarker2];
+}
+
+static void AXAttributeStringSetFont(NSMutableAttributedString* attrString, NSString* attribute, NSFont* font, NSRange range)
+{
+    NSDictionary* dict;
+    
+    if (font) {
+        dict = [NSDictionary dictionaryWithObjectsAndKeys:
+            [font fontName]                             , NSAccessibilityFontNameKey,
+            [font familyName]                           , NSAccessibilityFontFamilyKey,
+            [font displayName]                          , NSAccessibilityVisibleNameKey,
+            [NSNumber numberWithFloat:[font pointSize]] , NSAccessibilityFontSizeKey,
+        nil];
+
+        [attrString addAttribute:attribute value:dict range:range];
+    } else
+        [attrString removeAttribute:attribute range:range];
+    
+}
+
+static CGColorRef CreateCGColorIfDifferent(NSColor* nsColor, CGColorRef existingColor)
+{
+    // get color information assuming NSDeviceRGBColorSpace 
+    NSColor* rgbColor = [nsColor colorUsingColorSpaceName:NSDeviceRGBColorSpace];
+    if (rgbColor == nil)
+        rgbColor = [NSColor blackColor];
+    CGFloat components[4];
+    [rgbColor getRed:&components[0] green:&components[1] blue:&components[2] alpha:&components[3]];
+    
+    // create a new CGColorRef to return
+    CGColorSpaceRef cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+    CGColorRef cgColor = CGColorCreate(cgColorSpace, components);
+    CGColorSpaceRelease(cgColorSpace);
+    CFMakeCollectable(cgColor);
+    
+    // check for match with existing color
+    if (existingColor && CGColorEqualToColor(cgColor, existingColor))
+        cgColor = nil;
+        
+    return cgColor;
+}
+
+static void AXAttributeStringSetColor(NSMutableAttributedString* attrString, NSString* attribute, NSColor* color, NSRange range)
+{
+    if (color) {
+        CGColorRef existingColor = (CGColorRef) [attrString attribute:attribute atIndex:range.location effectiveRange:nil];
+        CGColorRef cgColor = CreateCGColorIfDifferent(color, existingColor);
+        if (cgColor) {
+            [attrString addAttribute:attribute value:(id)cgColor range:range];
+            CGColorRelease(cgColor);
+        }
+    } else
+        [attrString removeAttribute:attribute range:range];
+}
+
+static void AXAttributeStringSetNumber(NSMutableAttributedString* attrString, NSString* attribute, NSNumber* number, NSRange range)
+{
+    if (number)
+        [attrString addAttribute:attribute value:number range:range];
+    else
+        [attrString removeAttribute:attribute range:range];
+}
+
+static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
+{
+    RenderStyle* style = renderer->style();
+
+    // set basic font info
+    AXAttributeStringSetFont(attrString, NSAccessibilityFontTextAttribute, style->font().primaryFont()->getNSFont(), range);
+
+    // set basic colors
+    AXAttributeStringSetColor(attrString, NSAccessibilityForegroundColorTextAttribute, nsColor(style->color()), range);
+    AXAttributeStringSetColor(attrString, NSAccessibilityBackgroundColorTextAttribute, nsColor(style->backgroundColor()), range);
+
+    // set super/sub scripting
+    EVerticalAlign alignment = style->verticalAlign();
+    if (alignment == SUB)
+        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, [NSNumber numberWithInt:(-1)], range);
+    else if (alignment == SUPER)
+        AXAttributeStringSetNumber(attrString, NSAccessibilitySuperscriptTextAttribute, [NSNumber numberWithInt:1], range);
+    else
+        [attrString removeAttribute:NSAccessibilitySuperscriptTextAttribute range:range];
+    
+    // set shadow
+    if (style->textShadow())
+        AXAttributeStringSetNumber(attrString, NSAccessibilityShadowTextAttribute, [NSNumber numberWithBool:YES], range);
+    else
+        [attrString removeAttribute:NSAccessibilityShadowTextAttribute range:range];
+    
+    // set underline and strikethrough
+    int decor = style->textDecorationsInEffect();
+    if ((decor & UNDERLINE) == 0) {
+        [attrString removeAttribute:NSAccessibilityUnderlineTextAttribute range:range];
+        [attrString removeAttribute:NSAccessibilityUnderlineColorTextAttribute range:range];
+    }
+    
+    if ((decor & LINE_THROUGH) == 0) {
+        [attrString removeAttribute:NSAccessibilityStrikethroughTextAttribute range:range];
+        [attrString removeAttribute:NSAccessibilityStrikethroughColorTextAttribute range:range];
+    }
+
+    if ((decor & (UNDERLINE | LINE_THROUGH)) != 0) {
+        // find colors using quirk mode approach (strict mode would use current
+        // color for all but the root line box, which would use getTextDecorationColors)
+        Color underline, overline, linethrough;
+        renderer->getTextDecorationColors(decor, underline, overline, linethrough);
+        
+        if ((decor & UNDERLINE) != 0) {
+            AXAttributeStringSetNumber(attrString, NSAccessibilityUnderlineTextAttribute, [NSNumber numberWithBool:YES], range);
+            AXAttributeStringSetColor(attrString, NSAccessibilityUnderlineColorTextAttribute, nsColor(underline), range);
+        }
+
+        if ((decor & LINE_THROUGH) != 0) {
+            AXAttributeStringSetNumber(attrString, NSAccessibilityStrikethroughTextAttribute, [NSNumber numberWithBool:YES], range);
+            AXAttributeStringSetColor(attrString, NSAccessibilityStrikethroughColorTextAttribute, nsColor(linethrough), range);
+        }
+    }
+}
+
+static int blockquoteLevel(RenderObject* renderer)
+{
+    int result = 0;
+    for (Node* node = renderer->element(); node; node = node->parent()) {
+        if (node->hasTagName(blockquoteTag))
+            result += 1;
+    }
+    
+    return result;
+}
+
+static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
+{
+    int quoteLevel = blockquoteLevel(renderer);
+    
+    if (quoteLevel)
+        [attrString addAttribute:@"AXBlockQuoteLevel" value:[NSNumber numberWithInt:quoteLevel] range:range];
+    else
+        [attrString removeAttribute:@"AXBlockQuoteLevel" range:range];
+}
+
+static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, int offset, NSRange range)
+{
+    Vector<DocumentMarker> markers = node->renderer()->document()->markersForNode(node);
+    Vector<DocumentMarker>::iterator markerIt = markers.begin();
+
+    unsigned endOffset = (unsigned)offset + range.length;
+    for ( ; markerIt != markers.end(); markerIt++) {
+        DocumentMarker marker = *markerIt;
+        
+        if (marker.type != DocumentMarker::Spelling)
+            continue;
+        
+        if (marker.endOffset <= (unsigned)offset)
+            continue;
+        
+        if (marker.startOffset > endOffset)
+            break;
+        
+        // add misspelling attribute for the intersection of the marker and the range
+        int rStart = range.location + (marker.startOffset - offset);
+        int rLength = MIN(marker.endOffset, endOffset) - marker.startOffset;
+        NSRange spellRange = NSMakeRange(rStart, rLength);
+        AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, [NSNumber numberWithBool:YES], spellRange);
+        
+        if (marker.endOffset > endOffset + 1)
+            break;
+    }
+}
+
+static void AXAttributeStringSetHeadingLevel(AccessibilityObject* object, NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
+{
+    int parentHeadingLevel = object->headingLevel(renderer->parent()->element());
+    
+    if (parentHeadingLevel)
+        [attrString addAttribute:@"AXHeadingLevel" value:[NSNumber numberWithInt:parentHeadingLevel] range:range];
+    else
+        [attrString removeAttribute:@"AXHeadingLevel" range:range];
+}
+
+static AccessibilityObject* AXLinkElementForNode(Node* node)
+{
+    RenderObject* obj = node->renderer();
+    if (!obj)
+        return 0;
+
+    RefPtr<AccessibilityObject> axObj = obj->document()->axObjectCache()->get(obj);
+    HTMLAnchorElement* anchor = axObj->anchorElement();
+    if (!anchor || !anchor->renderer())
+        return 0;
+
+    return anchor->renderer()->document()->axObjectCache()->get(anchor->renderer());
+}
+
+static void AXAttributeStringSetElement(NSMutableAttributedString* attrString, NSString* attribute, AccessibilityObject* object, NSRange range)
+{
+    if (object) {
+        // make a serialiazable AX object
+        RenderObject* renderer = object->renderer();
+        if (!renderer)
+            return;
+        
+        Document* doc = renderer->document();
+        if (!doc)
+            return;
+        
+        AXObjectCache* cache = doc->axObjectCache();
+        if (!cache)
+            return;
+
+        AXUIElementRef axElement = [[WebCoreViewFactory sharedFactory] AXUIElementForElement:object->wrapper()];
+        if (axElement) {
+            [attrString addAttribute:attribute value:(id)axElement range:range];
+            CFRelease(axElement);
+        }
+    } else
+        [attrString removeAttribute:attribute range:range];
+}
+
+static void AXAttributedStringAppendText(AccessibilityObject* object, NSMutableAttributedString* attrString, Node* node, int offset, const UChar* chars, int length)
+{
+    // skip invisible text
+    if (!node->renderer())
+        return;
+        
+    // easier to calculate the range before appending the string
+    NSRange attrStringRange = NSMakeRange([attrString length], length);
+    
+    // append the string from this node
+    [[attrString mutableString] appendString:[NSString stringWithCharacters:chars length:length]];
+
+    // add new attributes and remove irrelevant inherited ones
+    // NOTE: color attributes are handled specially because -[NSMutableAttributedString addAttribute: value: range:] does not merge
+    // identical colors.  Workaround is to not replace an existing color attribute if it matches what we are adding.  This also means
+    // we cannot just pre-remove all inherited attributes on the appended string, so we have to remove the irrelevant ones individually.
+
+    // remove inherited attachment from prior AXAttributedStringAppendReplaced
+    [attrString removeAttribute:NSAccessibilityAttachmentTextAttribute range:attrStringRange];
+    
+    // set new attributes
+    AXAttributeStringSetStyle(attrString, node->renderer(), attrStringRange);
+    AXAttributeStringSetHeadingLevel(object, attrString, node->renderer(), attrStringRange);
+    AXAttributeStringSetBlockquoteLevel(attrString, node->renderer(), attrStringRange);
+    AXAttributeStringSetElement(attrString, NSAccessibilityLinkTextAttribute, AXLinkElementForNode(node), attrStringRange);
+    
+    // do spelling last because it tends to break up the range
+    AXAttributeStringSetSpelling(attrString, node, offset, attrStringRange);
+}
+
+static NSString* nsStringForReplacedNode(Node* replacedNode)
+{
+    // we should always be given a rendered node and a replaced node, but be safe
+    // replaced nodes are either attachments (widgets) or images
+    if (!replacedNode || !replacedNode->renderer() || !replacedNode->renderer()->isReplaced() || replacedNode->isTextNode()) {
+        ASSERT_NOT_REACHED();
+        return nil;
+    }
+
+    // create an AX object, but skip it if it is not supposed to be seen
+    RefPtr<AccessibilityObject> obj = replacedNode->renderer()->document()->axObjectCache()->get(replacedNode->renderer());
+    if (obj->accessibilityIsIgnored())
+        return nil;
+    
+    // use the attachmentCharacter to represent the replaced node
+    const UniChar attachmentChar = NSAttachmentCharacter;
+    return [NSString stringWithCharacters:&attachmentChar length:1];
+}
+
+- (NSAttributedString*)doAXAttributedStringForTextMarkerRange:(WebCoreTextMarkerRange*)textMarkerRange
+{
+    // extract the start and end VisiblePosition
+    VisiblePosition startVisiblePosition = visiblePositionForStartOfTextMarkerRange(textMarkerRange);
+    if (startVisiblePosition.isNull())
+        return nil;
+
+    VisiblePosition endVisiblePosition = visiblePositionForEndOfTextMarkerRange(textMarkerRange);
+    if (endVisiblePosition.isNull())
+        return nil;
+
+    // iterate over the range to build the AX attributed string
+    NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] init];
+    TextIterator it(makeRange(startVisiblePosition, endVisiblePosition).get());
+    while (!it.atEnd()) {
+        // locate the node and starting offset for this range
+        int exception = 0;
+        Node* node = it.range()->startContainer(exception);
+        ASSERT(node == it.range()->endContainer(exception));
+        int offset = it.range()->startOffset(exception);
+
+        // non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
+        if (it.length() != 0) {
+            AXAttributedStringAppendText(m_object, attrString, node, offset, it.characters(), it.length());
+        } else {
+            Node* replacedNode = node->childNode(offset);
+            NSString *attachmentString = nsStringForReplacedNode(replacedNode);
+            if (attachmentString) {
+                NSRange attrStringRange = NSMakeRange([attrString length], [attachmentString length]);
+
+                // append the placeholder string
+                [[attrString mutableString] appendString:attachmentString];
+
+                // remove all inherited attributes
+                [attrString setAttributes:nil range:attrStringRange];
+
+                // add the attachment attribute
+                AccessibilityObject* obj = replacedNode->renderer()->document()->axObjectCache()->get(replacedNode->renderer());
+                AXAttributeStringSetElement(attrString, NSAccessibilityAttachmentTextAttribute, obj, attrStringRange);
+            }
+        }
+        it.advance();
+    }
+
+    return [attrString autorelease];
+}
+
+static WebCoreTextMarkerRange* textMarkerRangeFromVisiblePositions(VisiblePosition startPosition, VisiblePosition endPosition)
+{
+    WebCoreTextMarker* startTextMarker = textMarkerForVisiblePosition(startPosition);
+    WebCoreTextMarker* endTextMarker   = textMarkerForVisiblePosition(endPosition);
+    return textMarkerRangeFromMarkers(startTextMarker, endTextMarker);
+}
+
 - (NSArray*)accessibilityActionNames
 {
     static NSArray* actions = nil;
@@ -94,7 +492,7 @@ using namespace HTMLNames;
         if (m_object->actionElement()) 
             actions = [[NSArray alloc] initWithObjects: NSAccessibilityPressAction, nil];
         else if (m_object->isAttachment())
-            actions = [[m_object->attachmentView() accessibilityActionNames] retain];
+            actions = [[[self attachmentView] accessibilityActionNames] retain];
     }
 
     return actions;
@@ -103,7 +501,7 @@ using namespace HTMLNames;
 - (NSArray*)accessibilityAttributeNames
 {
     if (m_object->isAttachment())
-        return [m_object->attachmentView() accessibilityAttributeNames];
+        return [[self attachmentView] accessibilityAttributeNames];
         
     static NSArray* attributes = nil;
     static NSArray* anchorAttrs = nil;
@@ -174,7 +572,7 @@ using namespace HTMLNames;
 
 - (VisiblePositionRange)visiblePositionRangeForTextMarkerRange:(WebCoreTextMarkerRange*) textMarkerRange
 {
-    return VisiblePositionRange(m_object->visiblePositionForStartOfTextMarkerRange(textMarkerRange), m_object->visiblePositionForEndOfTextMarkerRange(textMarkerRange));
+    return VisiblePositionRange(visiblePositionForStartOfTextMarkerRange(textMarkerRange), visiblePositionForEndOfTextMarkerRange(textMarkerRange));
 }
 
 - (NSArray*)renderWidgetChildren
@@ -194,6 +592,192 @@ static NSMutableArray* convertToNSArray(const Vector<RefPtr<AccessibilityObject>
     return array;
 }
 
+- (WebCoreTextMarkerRange*)textMarkerRangeForSelection
+{
+    Selection selection = m_object->selection();
+    if (selection.isNone())
+        return nil;
+    return textMarkerRangeFromVisiblePositions(selection.visibleStart(), selection.visibleEnd());
+}
+
+- (NSValue*)position
+{
+    IntRect rect = m_object->areaElement() ? m_object->areaElement()->getRect(m_object->renderer()) : m_object->boundingBoxRect();
+    
+    // The Cocoa accessibility API wants the lower-left corner.
+    NSPoint point = NSMakePoint(rect.x(), rect.bottom());
+    if (FrameView* frameView = m_object->frameViewIfRenderView()) {
+        NSView* view = frameView->documentView();
+        point = [[view window] convertBaseToScreen: [view convertPoint: point toView:nil]];
+    }
+
+    return [NSValue valueWithPoint: point];
+}
+
+typedef HashMap<int, NSString*> AccessibilityRoleMap;
+
+static const AccessibilityRoleMap& createAccessibilityRoleMap()
+{
+    struct RoleEntry {
+        AccessibilityRole value;
+        NSString* string;
+    };
+    
+    static const RoleEntry roles[] = {
+        { UnknownRole, NSAccessibilityUnknownRole },
+        { ButtonRole, NSAccessibilityButtonRole },
+        { RadioButtonRole, NSAccessibilityRadioButtonRole },
+        { CheckBoxRole, NSAccessibilityCheckBoxRole },
+        { SliderRole, NSAccessibilitySliderRole },
+        { TabGroupRole, NSAccessibilityTabGroupRole },
+        { TextFieldRole, NSAccessibilityTextFieldRole },
+        { StaticTextRole, NSAccessibilityStaticTextRole },
+        { TextAreaRole, NSAccessibilityTextAreaRole },
+        { ScrollAreaRole, NSAccessibilityScrollAreaRole },
+        { PopUpButtonRole, NSAccessibilityPopUpButtonRole },
+        { MenuButtonRole, NSAccessibilityMenuButtonRole },
+        { TableRole, NSAccessibilityTableRole },
+        { ApplicationRole, NSAccessibilityApplicationRole },
+        { GroupRole, NSAccessibilityGroupRole },
+        { RadioGroupRole, NSAccessibilityRadioGroupRole },
+        { ListRole, NSAccessibilityListRole },
+        { ScrollBarRole, NSAccessibilityScrollBarRole },
+        { ValueIndicatorRole, NSAccessibilityValueIndicatorRole },
+        { ImageRole, NSAccessibilityImageRole },
+        { MenuBarRole, NSAccessibilityMenuBarRole },
+        { MenuRole, NSAccessibilityMenuRole },
+        { MenuItemRole, NSAccessibilityMenuItemRole },
+        { ColumnRole, NSAccessibilityColumnRole },
+        { RowRole, NSAccessibilityRowRole },
+        { ToolbarRole, NSAccessibilityToolbarRole },
+        { BusyIndicatorRole, NSAccessibilityBusyIndicatorRole },
+        { ProgressIndicatorRole, NSAccessibilityProgressIndicatorRole },
+        { WindowRole, NSAccessibilityWindowRole },
+        { DrawerRole, NSAccessibilityDrawerRole },
+        { SystemWideRole, NSAccessibilitySystemWideRole },
+        { OutlineRole, NSAccessibilityOutlineRole },
+        { IncrementorRole, NSAccessibilityIncrementorRole },
+        { BrowserRole, NSAccessibilityBrowserRole },
+        { ComboBoxRole, NSAccessibilityComboBoxRole },
+        { SplitGroupRole, NSAccessibilitySplitGroupRole },
+        { SplitterRole, NSAccessibilitySplitterRole },
+        { ColorWellRole, NSAccessibilityColorWellRole },
+        { GrowAreaRole, NSAccessibilityGrowAreaRole },
+        { SheetRole, NSAccessibilitySheetRole },
+        { HelpTagRole, NSAccessibilityHelpTagRole },
+        { MatteRole, NSAccessibilityMatteRole }, 
+        { RulerRole, NSAccessibilityRulerRole },
+        { RulerMarkerRole, NSAccessibilityRulerMarkerRole },
+        { SortButtonRole, NSAccessibilitySortButtonRole },
+        { LinkRole, NSAccessibilityLinkRole },
+#ifndef BUILDING_ON_TIGER        
+        { DisclosureTriangleRole, NSAccessibilityDisclosureTriangleRole },
+        { GridRole, NSAccessibilityGridRole },
+#endif
+        { WebCoreLinkRole, @"AXLink" }, // why isn't this just NSAccessibilityLinkRole ?
+        { ImageMapRole, @"AXImageMap" },
+        { ListMarkerRole, @"AXListMarker" },
+        { WebAreaRole, @"AXWebArea" },
+        { HeadingRole, @"AXHeading" }
+    };
+    AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;
+    
+    const unsigned numRoles = sizeof(roles) / sizeof(roles[0]);
+    for (unsigned i = 0; i < numRoles; ++i)
+        roleMap.set(roles[i].value, roles[i].string);
+    return roleMap;
+}
+
+static NSString* roleValueToNSString(AccessibilityRole value)
+{
+    ASSERT(value);
+    static const AccessibilityRoleMap& roleMap = createAccessibilityRoleMap();
+    return roleMap.get(value);
+}
+
+- (NSString*)role
+{
+    if (m_object->isAttachment())
+        return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityRoleAttribute];
+    NSString* string = roleValueToNSString(m_object->roleValue());
+    if (string != nil)
+        return string;
+    return NSAccessibilityUnknownRole;
+}
+
+- (NSString*)subrole
+{
+    if (m_object->isPasswordField())
+        return NSAccessibilitySecureTextFieldSubrole;
+    
+    if (m_object->isAttachment()) {
+        NSView* attachView = [self attachmentView];
+        if ([[attachView accessibilityAttributeNames] containsObject:NSAccessibilitySubroleAttribute]) {
+            return [attachView accessibilityAttributeValue:NSAccessibilitySubroleAttribute];
+        }
+    }
+
+    return nil;
+}
+
+- (NSString*)roleDescription
+{
+    if (!m_object->renderer())
+        return nil;
+
+    // attachments have the AXImage role, but a different subrole
+    if (m_object->isAttachment())
+        return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityRoleDescriptionAttribute];
+    
+    // FIXME 3447564: It would be better to call some AppKit API to get these strings
+    // (which would be the best way to localize them)
+    
+    NSString* axRole = [self role];
+    if ([axRole isEqualToString:NSAccessibilityButtonRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityButtonRole, [self subrole]);
+    
+    if ([axRole isEqualToString:NSAccessibilityPopUpButtonRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityPopUpButtonRole, [self subrole]);
+   
+    if ([axRole isEqualToString:NSAccessibilityStaticTextRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityStaticTextRole, [self subrole]);
+
+    if ([axRole isEqualToString:NSAccessibilityImageRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityImageRole, [self subrole]);
+    
+    if ([axRole isEqualToString:NSAccessibilityGroupRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, [self subrole]);
+    
+    if ([axRole isEqualToString:NSAccessibilityCheckBoxRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityCheckBoxRole, [self subrole]);
+        
+    if ([axRole isEqualToString:NSAccessibilityRadioButtonRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityRadioButtonRole, [self subrole]);
+        
+    if ([axRole isEqualToString:NSAccessibilityTextFieldRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityTextFieldRole, [self subrole]);
+
+    if ([axRole isEqualToString:NSAccessibilityTextAreaRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityTextAreaRole, [self subrole]);
+
+    if ([axRole isEqualToString:@"AXWebArea"])
+        return AXWebAreaText();
+    
+    if ([axRole isEqualToString:@"AXLink"])
+        return AXLinkText();
+    
+    if ([axRole isEqualToString:@"AXListMarker"])
+        return AXListMarkerText();
+    
+    if ([axRole isEqualToString:@"AXImageMap"])
+        return AXImageMapText();
+
+    if ([axRole isEqualToString:@"AXHeading"])
+        return AXHeadingText();
+    
+    return NSAccessibilityRoleDescription(NSAccessibilityUnknownRole, nil);
+}
+
 // FIXME: split up this function in a better way.  
 // suggestions: Use a hash table that maps attribute names to function calls,
 // or maybe pointers to member functions
@@ -204,13 +788,13 @@ static NSMutableArray* convertToNSArray(const Vector<RefPtr<AccessibilityObject>
         return nil;
 
     if ([attributeName isEqualToString: NSAccessibilityRoleAttribute])
-        return m_object->role();
+        return [self role];
 
     if ([attributeName isEqualToString: NSAccessibilitySubroleAttribute])
-        return m_object->subrole();
+        return [self subrole];
 
     if ([attributeName isEqualToString: NSAccessibilityRoleDescriptionAttribute])
-        return m_object->roleDescription();
+        return [self roleDescription];
 
     if ([attributeName isEqualToString: NSAccessibilityParentAttribute]) {
         FrameView* fv = m_object->frameViewIfRenderView();
@@ -284,24 +868,24 @@ static NSMutableArray* convertToNSArray(const Vector<RefPtr<AccessibilityObject>
     
     if ([attributeName isEqualToString: NSAccessibilityTitleAttribute]) {
         if (m_object->isAttachment()) {
-            if ([[m_object->attachmentView() accessibilityAttributeNames] containsObject:NSAccessibilityTitleAttribute]) 
-                return [m_object->attachmentView() accessibilityAttributeValue:NSAccessibilityTitleAttribute];
+            if ([[[self attachmentView] accessibilityAttributeNames] containsObject:NSAccessibilityTitleAttribute]) 
+                return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityTitleAttribute];
         }
         return m_object->title();
     }
     
     if ([attributeName isEqualToString: NSAccessibilityDescriptionAttribute]) {
         if (m_object->isAttachment()) {
-            if ([[m_object->attachmentView() accessibilityAttributeNames] containsObject:NSAccessibilityDescriptionAttribute])
-                return [m_object->attachmentView() accessibilityAttributeValue:NSAccessibilityDescriptionAttribute];
+            if ([[[self attachmentView] accessibilityAttributeNames] containsObject:NSAccessibilityDescriptionAttribute])
+                return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityDescriptionAttribute];
         }
         return m_object->accessibilityDescription();
     }
     
     if ([attributeName isEqualToString: NSAccessibilityValueAttribute]) {
         if (m_object->isAttachment()) {
-            if ([[m_object->attachmentView() accessibilityAttributeNames] containsObject:NSAccessibilityValueAttribute]) 
-                return [m_object->attachmentView() accessibilityAttributeValue:NSAccessibilityValueAttribute];
+            if ([[[self attachmentView] accessibilityAttributeNames] containsObject:NSAccessibilityValueAttribute]) 
+                return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityValueAttribute];
         }    
         if (m_object->hasIntValue())
             return [NSNumber numberWithInt:m_object->intValue()];
@@ -323,7 +907,7 @@ static NSMutableArray* convertToNSArray(const Vector<RefPtr<AccessibilityObject>
     }
 
     if ([attributeName isEqualToString: NSAccessibilityPositionAttribute])
-        return m_object->position();
+        return [self position];
 
     if ([attributeName isEqualToString: NSAccessibilityWindowAttribute]) {
         FrameView* fv = m_object->documentFrameView();
@@ -333,11 +917,11 @@ static NSMutableArray* convertToNSArray(const Vector<RefPtr<AccessibilityObject>
     }
     
     if ([attributeName isEqualToString: @"AXSelectedTextMarkerRange"])
-        return m_object->textMarkerRangeForSelection();
+        return [self textMarkerRangeForSelection];
     if ([attributeName isEqualToString: @"AXStartTextMarker"])
-        return m_object->startTextMarker();
+        return textMarkerForVisiblePosition(startOfDocument(m_object->renderer()->document()));;
     if ([attributeName isEqualToString: @"AXEndTextMarker"])
-        return m_object->textMarkerForVisiblePosition(endOfDocument(renderer->document()));
+        return textMarkerForVisiblePosition(endOfDocument(renderer->document()));
 
     if ([attributeName isEqualToString: NSAccessibilityLinkedUIElementsAttribute]) {
         AccessibilityObject* obj = m_object->linkedUIElement();
@@ -398,7 +982,7 @@ static NSMutableArray* convertToNSArray(const Vector<RefPtr<AccessibilityObject>
 - (BOOL)accessibilityIsIgnored
 {
     if (m_object->isAttachment())
-        return [m_object->attachmentView() accessibilityIsIgnored];
+        return [[self attachmentView] accessibilityIsIgnored];
     return m_object->accessibilityIsIgnored();
 }
 
@@ -470,8 +1054,13 @@ static NSMutableArray* convertToNSArray(const Vector<RefPtr<AccessibilityObject>
 
 - (void)accessibilityPerformAction:(NSString*)action
 {
-    if ([action isEqualToString:NSAccessibilityPressAction])
-        m_object->press();
+    if (![action isEqualToString:NSAccessibilityPressAction])
+        return;
+    
+    if (m_object->isAttachment())
+        [[self attachmentView] accessibilityPerformAction:NSAccessibilityPressAction];
+
+    m_object->press();
 }
 
 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName
@@ -551,6 +1140,23 @@ static RenderObject* rendererForView(NSView* view)
     return NSAccessibilityActionDescription(action);
 }
 
+// The CFAttributedStringType representation of the text associated with this accessibility
+// object that is specified by the given range.
+- (NSAttributedString*)doAXAttributedStringForRange:(NSRange)range
+{
+    AccessibilityObject::PlainTextRange textRange = AccessibilityObject::PlainTextRange(range.location, range.length);
+    VisiblePositionRange visiblePosRange = m_object->textMarkerRangeForRange(textRange, static_cast<RenderTextControl*>(m_object->renderer()));
+    return [self doAXAttributedStringForTextMarkerRange:textMarkerRangeFromVisiblePositions(visiblePosRange.start, visiblePosRange.end)];
+}
+
+// The RTF representation of the text associated with this accessibility object that is
+// specified by the given range.
+- (NSData*)doAXRTFForRange:(NSRange)range
+{
+    NSAttributedString* attrString = [self doAXAttributedStringForRange:range];
+    return [attrString RTFFromRange: NSMakeRange(0, [attrString length]) documentAttributes: nil];
+}
+
 - (id)accessibilityAttributeValue:(NSString*)attribute forParameter:(id)parameter
 {
     WebCoreTextMarker* textMarker = nil;
@@ -603,7 +1209,7 @@ static RenderObject* rendererForView(NSView* view)
     }
     
     // Convert values to WebCore types
-    VisiblePosition visiblePos = m_object->visiblePositionForTextMarker(textMarker);
+    VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
     int intNumber = [number intValue];
     VisiblePositionRange visiblePosRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
     IntPoint webCorePoint = IntPoint(point);
@@ -615,7 +1221,7 @@ static RenderObject* rendererForView(NSView* view)
 
     if ([attribute isEqualToString: @"AXTextMarkerRangeForUIElement"]) {
         VisiblePositionRange vpRange = uiElement.get()->visiblePositionRange();
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXLineForTextMarker"])
@@ -623,14 +1229,14 @@ static RenderObject* rendererForView(NSView* view)
 
     if ([attribute isEqualToString: @"AXTextMarkerRangeForLine"]) {
         VisiblePositionRange vpRange = m_object->doAXTextMarkerRangeForLine(intNumber);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXStringForTextMarkerRange"])
         return m_object->doAXStringForTextMarkerRange(visiblePosRange);
 
     if ([attribute isEqualToString: @"AXTextMarkerForPosition"])
-        return pointSet ? m_object->textMarkerForVisiblePosition(m_object->doAXTextMarkerForPosition(webCorePoint)) : nil;
+        return pointSet ? textMarkerForVisiblePosition(m_object->doAXTextMarkerForPosition(webCorePoint)) : nil;
 
     if ([attribute isEqualToString: @"AXBoundsForTextMarkerRange"]) {
         NSRect rect = m_object->doAXBoundsForTextMarkerRange(visiblePosRange);
@@ -638,7 +1244,7 @@ static RenderObject* rendererForView(NSView* view)
     }
 
     if ([attribute isEqualToString: @"AXAttributedStringForTextMarkerRange"])
-        return m_object->doAXAttributedStringForTextMarkerRange(textMarkerRange);
+        return [self doAXAttributedStringForTextMarkerRange:textMarkerRange];
 
     if ([attribute isEqualToString: @"AXTextMarkerRangeForUnorderedTextMarkers"]) {
         if ([array count] < 2)
@@ -650,75 +1256,75 @@ static RenderObject* rendererForView(NSView* view)
             || ![[WebCoreViewFactory sharedFactory] objectIsTextMarker:textMarker2])
             return nil;
 
-        VisiblePosition visiblePos1 = m_object->visiblePositionForTextMarker(textMarker1);
-        VisiblePosition visiblePos2 = m_object->visiblePositionForTextMarker(textMarker2);
+        VisiblePosition visiblePos1 = visiblePositionForTextMarker(textMarker1);
+        VisiblePosition visiblePos2 = visiblePositionForTextMarker(textMarker2);
         VisiblePositionRange vpRange = m_object->doAXTextMarkerRangeForUnorderedTextMarkers(visiblePos1, visiblePos2);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXNextTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXNextTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXNextTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXPreviousTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXPreviousTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXPreviousTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXLeftWordTextMarkerRangeForTextMarker"]) {
         VisiblePositionRange vpRange = m_object->doAXLeftWordTextMarkerRangeForTextMarker(visiblePos);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXRightWordTextMarkerRangeForTextMarker"]) {
         VisiblePositionRange vpRange = m_object->doAXRightWordTextMarkerRangeForTextMarker(visiblePos);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXLeftLineTextMarkerRangeForTextMarker"]) {
         VisiblePositionRange vpRange = m_object->doAXLeftLineTextMarkerRangeForTextMarker(visiblePos);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXRightLineTextMarkerRangeForTextMarker"]) {
         VisiblePositionRange vpRange = m_object->doAXRightLineTextMarkerRangeForTextMarker(visiblePos);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXSentenceTextMarkerRangeForTextMarker"]) {
         VisiblePositionRange vpRange = m_object->doAXSentenceTextMarkerRangeForTextMarker(visiblePos);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXParagraphTextMarkerRangeForTextMarker"]) {
         VisiblePositionRange vpRange = m_object->doAXParagraphTextMarkerRangeForTextMarker(visiblePos);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXNextWordEndTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXNextWordEndTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXNextWordEndTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXPreviousWordStartTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXPreviousWordStartTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXPreviousWordStartTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXNextLineEndTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXNextLineEndTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXNextLineEndTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXPreviousLineStartTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXPreviousLineStartTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXPreviousLineStartTextMarkerForTextMarker(visiblePos));
        
     if ([attribute isEqualToString: @"AXNextSentenceEndTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXNextSentenceEndTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXNextSentenceEndTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXPreviousSentenceStartTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXPreviousSentenceStartTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXPreviousSentenceStartTextMarkerForTextMarker(visiblePos));
        
     if ([attribute isEqualToString: @"AXNextParagraphEndTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXNextParagraphEndTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXNextParagraphEndTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXPreviousParagraphStartTextMarkerForTextMarker"])
-        return m_object->textMarkerForVisiblePosition(m_object->doAXPreviousParagraphStartTextMarkerForTextMarker(visiblePos));
+        return textMarkerForVisiblePosition(m_object->doAXPreviousParagraphStartTextMarkerForTextMarker(visiblePos));
 
     if ([attribute isEqualToString: @"AXStyleTextMarkerRangeForTextMarker"]) {
         VisiblePositionRange vpRange = m_object->doAXStyleTextMarkerRangeForTextMarker(visiblePos);
-        return (id)(m_object->textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end));
+        return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
     if ([attribute isEqualToString: @"AXLengthForTextMarkerRange"]) {
@@ -760,10 +1366,10 @@ static RenderObject* rendererForView(NSView* view)
         }
 
         if ([attribute isEqualToString: (NSString*)kAXRTFForRangeParameterizedAttribute])
-            return rangeSet ? m_object->doAXRTFForRange(range) : nil;
+            return rangeSet ? [self doAXRTFForRange:range] : nil;
 
         if ([attribute isEqualToString: (NSString*)kAXAttributedStringForRangeParameterizedAttribute])
-            return rangeSet ? m_object->doAXAttributedStringForRange(range) : nil;
+            return rangeSet ? [self doAXAttributedStringForRange:range] : nil;
        
         if ([attribute isEqualToString: (NSString*)kAXStyleRangeForIndexParameterizedAttribute]) {
             AccessibilityObject::PlainTextRange textRange = m_object->doAXStyleRangeForIndex(intNumber);
@@ -774,7 +1380,7 @@ static RenderObject* rendererForView(NSView* view)
     return nil;
 }
 
--(BOOL) accessibilityShouldUseUniqueId
+- (BOOL)accessibilityShouldUseUniqueId
 {
     return m_object->accessibilityShouldUseUniqueId();
 }
index 855928d70a2539a3094fda61dd47ae16529ebc60..17dc15e148dc4795a9c7cced66cebb899be267e6 100644 (file)
@@ -114,6 +114,11 @@ namespace WebCore {
 
         bool scroll(ScrollDirection, ScrollGranularity);
 
+#if PLATFORM(MAC)
+        IntRect contentsToScreen(const IntRect&) const;
+        IntPoint screenToContents(const IntPoint&) const;
+#endif
+
 #if PLATFORM(MAC) && defined __OBJC__
     public:
         NSView* documentView() const;
index 21014cb85dee51eb1ff716fa076cfa29f8ce7378..91ba8b0acabf7d2bc91660acf10bea9b77d5f057 100644 (file)
@@ -303,6 +303,30 @@ IntRect ScrollView::windowToContents(const IntRect& rect) const
     return IntRect();
 }
 
+IntRect ScrollView::contentsToScreen(const IntRect& rect) const
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    if (NSView* documentView = this->documentView()) {
+        NSRect tempRect = rect;
+        tempRect = [documentView convertRect:tempRect toView:nil];
+        tempRect.origin = [[documentView window] convertBaseToScreen:tempRect.origin];
+        return enclosingIntRect(tempRect);
+    }
+    END_BLOCK_OBJC_EXCEPTIONS;
+    return IntRect();
+}
+
+IntPoint ScrollView::screenToContents(const IntPoint& point) const
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    if (NSView* documentView = this->documentView()) {
+        NSPoint windowCoord = [[documentView window] convertScreenToBase: point];
+        return IntPoint([documentView convertPoint:windowCoord fromView:nil]);
+    }
+    END_BLOCK_OBJC_EXCEPTIONS;
+    return IntPoint();
+}
+
 void ScrollView::setStaticBackground(bool staticBackground)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;