Title: [185137] trunk/Source/WebCore
Revision
185137
Author
commit-qu...@webkit.org
Date
2015-06-02 18:29:43 -0700 (Tue, 02 Jun 2015)

Log Message

AX: debugging attributes for text markers
https://bugs.webkit.org/show_bug.cgi?id=145283

Patch by Doug Russell <d_russ...@apple.com> on 2015-06-02
Reviewed by Chris Fleizach.

AXTextMarkerDebugDescription: returns the result of
VisiblePosition::formatForDebugger() for the visible position that a text marker
represents.
AXTextMarkerNodeDebugDescription: calls Node::showNode() and
Node::showNodePathForThis() for the visible position that a text marker
represents.
AXTextMarkerNodeTreeDebugDescription: calls Node::showTreeForThis() for the
visible position that a text marker represents.
AXTextMarkerRangeDebugDescription: returns the result of
formatForDebugger(VisiblePositionRange) for the visible position range that a text
marker range represents.

This is debug only tooling. Tests would be flakey and not very helpful.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper debugDescriptionForTextMarker:]):
(-[WebAccessibilityObjectWrapper debugDescriptionForTextMarkerRange:]):
(-[WebAccessibilityObjectWrapper showNodeForTextMarker:]):
(-[WebAccessibilityObjectWrapper showNodeTreeForTextMarker:]):
(formatForDebugger):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
* dom/Text.cpp:
(WebCore::Text::formatForDebugger):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185136 => 185137)


--- trunk/Source/WebCore/ChangeLog	2015-06-03 00:45:00 UTC (rev 185136)
+++ trunk/Source/WebCore/ChangeLog	2015-06-03 01:29:43 UTC (rev 185137)
@@ -1,3 +1,34 @@
+2015-06-02  Doug Russell  <d_russ...@apple.com>
+
+        AX: debugging attributes for text markers
+        https://bugs.webkit.org/show_bug.cgi?id=145283
+
+        Reviewed by Chris Fleizach.
+
+        AXTextMarkerDebugDescription: returns the result of
+        VisiblePosition::formatForDebugger() for the visible position that a text marker
+        represents.
+        AXTextMarkerNodeDebugDescription: calls Node::showNode() and
+        Node::showNodePathForThis() for the visible position that a text marker
+        represents.
+        AXTextMarkerNodeTreeDebugDescription: calls Node::showTreeForThis() for the
+        visible position that a text marker represents.
+        AXTextMarkerRangeDebugDescription: returns the result of
+        formatForDebugger(VisiblePositionRange) for the visible position range that a text
+        marker range represents.
+
+        This is debug only tooling. Tests would be flakey and not very helpful.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper debugDescriptionForTextMarker:]):
+        (-[WebAccessibilityObjectWrapper debugDescriptionForTextMarkerRange:]):
+        (-[WebAccessibilityObjectWrapper showNodeForTextMarker:]):
+        (-[WebAccessibilityObjectWrapper showNodeTreeForTextMarker:]):
+        (formatForDebugger):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+        * dom/Text.cpp:
+        (WebCore::Text::formatForDebugger):
+
 2015-06-02  Matt Rajca  <mra...@apple.com>
 
         MediaSessions should keep track of their current state.

Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (185136 => 185137)


--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2015-06-03 00:45:00 UTC (rev 185136)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2015-06-03 01:29:43 UTC (rev 185137)
@@ -3485,6 +3485,62 @@
     return [attrString RTFFromRange: NSMakeRange(0, [attrString length]) documentAttributes:@{ }];
 }
 
+#if ENABLE(TREE_DEBUGGING)
+- (NSString *)debugDescriptionForTextMarker:(id)textMarker
+{
+    char description[1024];
+    [self visiblePositionForTextMarker:textMarker].formatForDebugger(description, sizeof(description));
+    return [NSString stringWithUTF8String:description];
+
+}
+
+- (NSString *)debugDescriptionForTextMarkerRange:(id)textMarkerRange
+{
+    VisiblePositionRange visiblePositionRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
+    if (visiblePositionRange.isNull())
+        return @"<null>";
+    char description[2048];
+    formatForDebugger(visiblePositionRange, description, sizeof(description));
+    return [NSString stringWithUTF8String:description];
+
+}
+
+- (void)showNodeForTextMarker:(id)textMarker
+{
+    VisiblePosition visiblePosition = [self visiblePositionForTextMarker:textMarker];
+    Node* node = visiblePosition.deepEquivalent().deprecatedNode();
+    if (!node)
+        return;
+    node->showNode();
+    node->showNodePathForThis();
+}
+
+- (void)showNodeTreeForTextMarker:(id)textMarker
+{
+    VisiblePosition visiblePosition = [self visiblePositionForTextMarker:textMarker];
+    Node* node = visiblePosition.deepEquivalent().deprecatedNode();
+    if (!node)
+        return;
+    node->showTreeForThis();
+}
+
+static void formatForDebugger(const VisiblePositionRange& range, char* buffer, unsigned length)
+{
+    StringBuilder result;
+    
+    const int FormatBufferSize = 1024;
+    char format[FormatBufferSize];
+    result.appendLiteral("from ");
+    range.start.formatForDebugger(format, FormatBufferSize);
+    result.append(format);
+    result.appendLiteral(" to ");
+    range.end.formatForDebugger(format, FormatBufferSize);
+    result.append(format);
+    
+    strlcpy(buffer, result.toString().utf8().data(), length);
+}
+#endif
+
 - (id)accessibilityAttributeValue:(NSString*)attribute forParameter:(id)parameter
 {
     id textMarker = nil;
@@ -3773,7 +3829,25 @@
         VisiblePositionRange visiblePosRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
         return [self textMarkerForVisiblePosition:visiblePosRange.end];
     }
-    
+
+#if ENABLE(TREE_DEBUGGING)
+    if ([attribute isEqualToString:@"AXTextMarkerDebugDescription"])
+        return [self debugDescriptionForTextMarker:textMarker];
+
+    if ([attribute isEqualToString:@"AXTextMarkerRangeDebugDescription"])
+        return [self debugDescriptionForTextMarkerRange:textMarkerRange];
+
+    if ([attribute isEqualToString:@"AXTextMarkerNodeDebugDescription"]) {
+        [self showNodeForTextMarker:textMarker];
+        return nil;
+    }
+
+    if ([attribute isEqualToString:@"AXTextMarkerNodeTreeDebugDescription"]) {
+        [self showNodeTreeForTextMarker:textMarker];
+        return nil;
+    }
+#endif
+
     if (is<AccessibilityTable>(*m_object) && downcast<AccessibilityTable>(*m_object).isExposableThroughAccessibility()) {
         if ([attribute isEqualToString:NSAccessibilityCellForColumnAndRowParameterizedAttribute]) {
             if (array == nil || [array count] != 2)

Modified: trunk/Source/WebCore/dom/Text.cpp (185136 => 185137)


--- trunk/Source/WebCore/dom/Text.cpp	2015-06-03 00:45:00 UTC (rev 185136)
+++ trunk/Source/WebCore/dom/Text.cpp	2015-06-03 01:29:43 UTC (rev 185137)
@@ -228,11 +228,14 @@
     if (s.length() > 0) {
         if (result.length())
             result.appendLiteral("; ");
-        result.appendLiteral("value=");
+        result.appendLiteral("length=");
+        result.appendNumber(s.length());
+        result.appendLiteral("; value=\"");
         result.append(s);
+        result.append('"');
     }
 
-    strncpy(buffer, result.toString().utf8().data(), length - 1);
+    strlcpy(buffer, result.toString().utf8().data(), length);
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to