-2006-08-25 David Harrison <harrison@apple.com>
+2006-08-28 David Harrison <harrison@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/3942647> Support AXStyleTextMarkerRangeForTextMarker parameterized attribute
+
+ * bridge/mac/WebCoreAXObject.mm:
+ (-[WebCoreAXObject accessibilityParameterizedAttributeNames]):
+ Add AXStyleTextMarkerRangeForTextMarker.
+
+ (startOfStyleRange):
+ (endOfStyleRange):
+ Return first/last VisiblePosition in range having the same style has the specified VisiblePosition.
+
+ (-[WebCoreAXObject doAXStyleTextMarkerRangeForTextMarker:]):
+ Return AXTextMarkerRange for startOfStyleRange/endOfStyleRange of the specified AXTextMarker.
+
+ (-[WebCoreAXObject accessibilityAttributeValue:forParameter:]):
+ Call doAXStyleTextMarkerRangeForTextMarker for AXStyleTextMarkerRangeForTextMarker.
+
+2006-08-28 David Harrison <harrison@apple.com>
Reviewed by Darin.
@"AXPreviousSentenceStartTextMarkerForTextMarker",
@"AXNextParagraphEndTextMarkerForTextMarker",
@"AXPreviousParagraphStartTextMarkerForTextMarker",
+ @"AXStyleTextMarkerRangeForTextMarker",
@"AXLengthForTextMarkerRange",
nil];
}
return (id) [self textMarkerForVisiblePosition: startPosition];
}
+static VisiblePosition startOfStyleRange (const VisiblePosition visiblePos)
+{
+ RenderObject* renderer = visiblePos.deepEquivalent().node()->renderer();
+ RenderObject* startRenderer = renderer;
+ RenderStyle* style = renderer->style();
+
+ // traverse backward by renderer to look for style change
+ for (RenderObject* r = renderer->previousInPreOrder(); r; r = r->previousInPreOrder()) {
+ // skip non-leaf nodes
+ if (r->firstChild())
+ continue;
+
+ // stop at style change
+ if (r->style() != style)
+ break;
+
+ // remember match
+ startRenderer = r;
+ }
+
+ return VisiblePosition(startRenderer->node(), 0, VP_DEFAULT_AFFINITY);
+}
+
+static VisiblePosition endOfStyleRange (const VisiblePosition visiblePos)
+{
+ RenderObject* renderer = visiblePos.deepEquivalent().node()->renderer();
+ RenderObject* endRenderer = renderer;
+ RenderStyle* style = renderer->style();
+
+ // traverse forward by renderer to look for style change
+ for (RenderObject* r = renderer->nextInPreOrder(); r; r = r->nextInPreOrder()) {
+ // skip non-leaf nodes
+ if (r->firstChild())
+ continue;
+
+ // stop at style change
+ if (r->style() != style)
+ break;
+
+ // remember match
+ endRenderer = r;
+ }
+
+ return VisiblePosition(endRenderer->node(), maxDeepOffset(endRenderer->node()), VP_DEFAULT_AFFINITY);
+}
+
+- (id)doAXStyleTextMarkerRangeForTextMarker: (WebCoreTextMarker*) textMarker
+{
+ VisiblePosition visiblePos = [self visiblePositionForTextMarker:textMarker];
+ if (visiblePos.isNull())
+ return nil;
+
+ VisiblePosition startPosition = startOfStyleRange(visiblePos);
+ VisiblePosition endPosition = endOfStyleRange(visiblePos);
+ return (id) [self textMarkerRangeFromVisiblePositions:startPosition andEndPos:endPosition];
+}
+
- (id)doAXLengthForTextMarkerRange: (WebCoreTextMarkerRange*) textMarkerRange
{
// NOTE: BUG Multi-byte support
if ([attribute isEqualToString: @"AXPreviousParagraphStartTextMarkerForTextMarker"])
return [self doAXPreviousParagraphStartTextMarkerForTextMarker: textMarker];
-
+
+ if ([attribute isEqualToString: @"AXStyleTextMarkerRangeForTextMarker"])
+ return [self doAXStyleTextMarkerRangeForTextMarker: textMarker];
+
if ([attribute isEqualToString: @"AXLengthForTextMarkerRange"])
return [self doAXLengthForTextMarkerRange: textMarkerRange];