Changeset 15967 in webkit


Ignore:
Timestamp:
Aug 22, 2006, 10:28:07 AM (18 years ago)
Author:
harrison
Message:

Reviewed by John.

<rdar://problem/4523606> Represent heading elements in AXAttributedStringForTextMarkerRange

  • bridge/mac/WebCoreAXObject.mm: (headingLevel): (-[WebCoreAXObject headingLevel]): (-[WebCoreAXObject isHeading]): New. Heading level is per the tag (h1 == 1, h2 == 2, etc.)


(-[WebCoreAXObject role]):
(-[WebCoreAXObject roleDescription]):
Add role and roleDescription for headings.


(-[WebCoreAXObject value]):
Value is the headingLevel.


(AXAttributeStringSetHeadingLevel):
(AXAttributedStringAppendText):
Put text's heading level (if applicable) in the attributes.

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r15966 r15967  
     12006-08-22  David Harrison  <harrison@apple.com>
     2
     3        Reviewed by John.
     4
     5        <rdar://problem/4523606> Represent heading elements in AXAttributedStringForTextMarkerRange
     6
     7        * bridge/mac/WebCoreAXObject.mm:
     8        (headingLevel):
     9        (-[WebCoreAXObject headingLevel]):
     10        (-[WebCoreAXObject isHeading]):
     11        New. Heading level is per the tag (h1 == 1, h2 == 2, etc.)
     12       
     13        (-[WebCoreAXObject role]):
     14        (-[WebCoreAXObject roleDescription]):
     15        Add role and roleDescription for headings.
     16       
     17        (-[WebCoreAXObject value]):
     18        Value is the headingLevel.
     19       
     20        (AXAttributeStringSetHeadingLevel):
     21        (AXAttributedStringAppendText):
     22        Put text's heading level (if applicable) in the attributes.
     23       
    1242006-08-22  David Harrison  <harrison@apple.com>
    225
  • trunk/WebCore/bridge/mac/WebCoreAXObject.mm

    r15965 r15967  
    303303}
    304304
     305static int headingLevel(RenderObject* renderer)
     306{
     307    if (!renderer->isBlockFlow())
     308        return 0;
     309       
     310    Node* node = renderer->element();
     311    if (!node)
     312        return 0;
     313   
     314    if (node->hasTagName(h1Tag))
     315        return 1;
     316   
     317    if (node->hasTagName(h2Tag))
     318        return 2;
     319   
     320    if (node->hasTagName(h3Tag))
     321        return 3;
     322   
     323    if (node->hasTagName(h4Tag))
     324        return 4;
     325   
     326    if (node->hasTagName(h5Tag))
     327        return 5;
     328   
     329    if (node->hasTagName(h6Tag))
     330        return 6;
     331
     332    return 0;
     333}
     334
     335-(int)headingLevel
     336{
     337    return headingLevel(m_renderer);
     338}
     339
     340-(BOOL)isHeading
     341{
     342    return [self headingLevel] != 0;
     343}
     344
    305345-(NSString*)role
    306346{
     
    344384        return NSAccessibilityPopUpButtonRole;
    345385
     386    if ([self isHeading])
     387        return @"AXHeading";
     388       
    346389    if (m_renderer->isBlockFlow())
    347390        return NSAccessibilityGroupRole;
     
    409452    if ([role isEqualToString:@"AXImageMap"])
    410453        return UI_STRING("image map", "accessibility role description for image map");
     454
     455    if ([role isEqualToString:@"AXHeading"])
     456        return UI_STRING("heading", "accessibility role description for headings");
    411457   
    412458    return NSAccessibilityRoleDescription(NSAccessibilityUnknownRole, nil);
     
    495541    if ([self isAttachment])
    496542        return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityValueAttribute];
     543
     544    if ([self isHeading])
     545        return [NSNumber numberWithInt:[self headingLevel]];
    497546
    498547    if (m_renderer->element() && m_renderer->element()->hasTagName(inputTag)) {
     
    12831332}
    12841333
     1334static void AXAttributeStringSetHeadingLevel(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
     1335{
     1336    int parentHeadingLevel = headingLevel(renderer->parent());
     1337   
     1338    if (parentHeadingLevel)
     1339        [attrString addAttribute:@"AXHeadingLevel" value:[NSNumber numberWithInt:parentHeadingLevel] range:range];
     1340    else
     1341        [attrString removeAttribute:@"AXHeadingLevel" range:range];
     1342}
     1343
    12851344static void AXAttributeStringSetElement(NSMutableAttributedString* attrString, NSString* attribute, id element, NSRange range)
    12861345{
     
    13611420    // set new attributes
    13621421    AXAttributeStringSetStyle(attrString, node->renderer(), attrStringRange);
     1422    AXAttributeStringSetHeadingLevel(attrString, node->renderer(), attrStringRange);
    13631423    AXAttributeStringSetElement(attrString, NSAccessibilityLinkTextAttribute, AXLinkElementForNode(node), attrStringRange);
    13641424   
Note: See TracChangeset for help on using the changeset viewer.