Changeset 92000 in webkit


Ignore:
Timestamp:
Jul 29, 2011 10:37:31 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Add the ability to search the AccessibilityObject cache
https://bugs.webkit.org/show_bug.cgi?id=64994

To support searching the AccessibilityObject cache, we first need to
implement a minimal set of functions that will allow AccessibilityObjects
to be identified when searching using common search criteria. The additional
functions below complement the existing identification functionality already
available and together provide a basic working set to build search on top of.
Additionally, the blockquoteLevel function has been moved into the AccessibilityObject
class to make it available to all platforms.

Patch by Samuel White <Samuel White> on 2011-07-29
Reviewed by Chris Fleizach.

New tests will be included in the following patch that will also implement
basic search functionality.

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::isBlockquote):
(WebCore::AccessibilityObject::isLandmark):
(WebCore::AccessibilityObject::hasMisspelling):
(WebCore::AccessibilityObject::blockquoteLevel):

  • accessibility/AccessibilityObject.h:

(WebCore::AccessibilityObject::isUnvisited):
(WebCore::AccessibilityObject::hasBoldFont):
(WebCore::AccessibilityObject::hasItalicFont):
(WebCore::AccessibilityObject::hasPlainText):
(WebCore::AccessibilityObject::hasSameFont):
(WebCore::AccessibilityObject::hasSameFontColor):
(WebCore::AccessibilityObject::hasSameStyle):
(WebCore::AccessibilityObject::hasStaticText):
(WebCore::AccessibilityObject::hasUnderline):
(WebCore::AccessibilityObject::tableLevel):

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::isUnvisited):
(WebCore::AccessibilityRenderObject::hasBoldFont):
(WebCore::AccessibilityRenderObject::hasItalicFont):
(WebCore::AccessibilityRenderObject::hasPlainText):
(WebCore::AccessibilityRenderObject::hasSameFont):
(WebCore::AccessibilityRenderObject::hasSameFontColor):
(WebCore::AccessibilityRenderObject::hasSameStyle):
(WebCore::AccessibilityRenderObject::hasUnderline):

  • accessibility/AccessibilityRenderObject.h:
  • accessibility/AccessibilityTable.cpp:

(WebCore::AccessibilityTable::tableLevel):

  • accessibility/AccessibilityTable.h:
  • accessibility/mac/AccessibilityObjectWrapper.mm:

(AXAttributeStringSetBlockquoteLevel):
(-[AccessibilityObjectWrapper accessibilityAttributeValue:]):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91999 r92000  
     12011-07-29  Samuel White  <samuel_white@apple.com>
     2
     3        Add the ability to search the AccessibilityObject cache
     4        https://bugs.webkit.org/show_bug.cgi?id=64994
     5       
     6        To support searching the AccessibilityObject cache, we first need to
     7        implement a minimal set of functions that will allow AccessibilityObjects
     8        to be identified when searching using common search criteria. The additional
     9        functions below complement the existing identification functionality already
     10        available and together provide a basic working set to build search on top of.
     11        Additionally, the blockquoteLevel function has been moved into the AccessibilityObject
     12        class to make it available to all platforms.
     13
     14        Reviewed by Chris Fleizach.
     15
     16        New tests will be included in the following patch that will also implement
     17        basic search functionality.
     18
     19        * accessibility/AccessibilityObject.cpp:
     20        (WebCore::AccessibilityObject::isBlockquote):
     21        (WebCore::AccessibilityObject::isLandmark):
     22        (WebCore::AccessibilityObject::hasMisspelling):
     23        (WebCore::AccessibilityObject::blockquoteLevel):
     24        * accessibility/AccessibilityObject.h:
     25        (WebCore::AccessibilityObject::isUnvisited):
     26        (WebCore::AccessibilityObject::hasBoldFont):
     27        (WebCore::AccessibilityObject::hasItalicFont):
     28        (WebCore::AccessibilityObject::hasPlainText):
     29        (WebCore::AccessibilityObject::hasSameFont):
     30        (WebCore::AccessibilityObject::hasSameFontColor):
     31        (WebCore::AccessibilityObject::hasSameStyle):
     32        (WebCore::AccessibilityObject::hasStaticText):
     33        (WebCore::AccessibilityObject::hasUnderline):
     34        (WebCore::AccessibilityObject::tableLevel):
     35        * accessibility/AccessibilityRenderObject.cpp:
     36        (WebCore::AccessibilityRenderObject::isUnvisited):
     37        (WebCore::AccessibilityRenderObject::hasBoldFont):
     38        (WebCore::AccessibilityRenderObject::hasItalicFont):
     39        (WebCore::AccessibilityRenderObject::hasPlainText):
     40        (WebCore::AccessibilityRenderObject::hasSameFont):
     41        (WebCore::AccessibilityRenderObject::hasSameFontColor):
     42        (WebCore::AccessibilityRenderObject::hasSameStyle):
     43        (WebCore::AccessibilityRenderObject::hasUnderline):
     44        * accessibility/AccessibilityRenderObject.h:
     45        * accessibility/AccessibilityTable.cpp:
     46        (WebCore::AccessibilityTable::tableLevel):
     47        * accessibility/AccessibilityTable.h:
     48        * accessibility/mac/AccessibilityObjectWrapper.mm:
     49        (AXAttributeStringSetBlockquoteLevel):
     50        (-[AccessibilityObjectWrapper accessibilityAttributeValue:]):
     51
    1522011-07-29  Zeng Huiqing  <huiqing.zeng@intel.com>
    253
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r87856 r92000  
    5050#include "RenderView.h"
    5151#include "RenderWidget.h"
     52#include "TextCheckerClient.h"
    5253#include "TextIterator.h"
    5354#include "htmlediting.h"
     
    8485    setWrapper(0);
    8586#endif   
     87}
     88
     89bool AccessibilityObject::isBlockquote() const
     90{
     91    return node() && node()->hasTagName(blockquoteTag);
     92}
     93
     94bool AccessibilityObject::isLandmark() const
     95{
     96    AccessibilityRole role = roleValue();
     97   
     98    return role == LandmarkApplicationRole
     99        || role == LandmarkBannerRole
     100        || role == LandmarkComplementaryRole
     101        || role == LandmarkContentInfoRole
     102        || role == LandmarkMainRole
     103        || role == LandmarkNavigationRole
     104        || role == LandmarkSearchRole;
     105}
     106
     107bool AccessibilityObject::hasMisspelling() const
     108{
     109    if (!node())
     110        return false;
     111   
     112    Document* document = node()->document();
     113    if (!document)
     114        return false;
     115   
     116    Frame* frame = document->frame();
     117    if (!frame)
     118        return false;
     119   
     120    Editor* editor = frame->editor();
     121    if (!editor)
     122        return false;
     123   
     124    TextCheckerClient* textChecker = editor->textChecker();
     125    if (!textChecker)
     126        return false;
     127   
     128    const UChar* chars = stringValue().characters();
     129    int charsLength = stringValue().length();
     130    bool isMisspelled = false;
     131   
     132#if USE(UNIFIED_TEXT_CHECKING)
     133    Vector<TextCheckingResult> results;
     134    textChecker->checkTextOfParagraph(chars, charsLength, TextCheckingTypeSpelling, results);
     135    if (!results.isEmpty())
     136        isMisspelled = true;
     137#else
     138    int misspellingLength = 0;
     139    int misspellingLocation = -1;
     140    textChecker->checkSpellingOfString(chars, charsLength, &misspellingLocation, &misspellingLength);
     141    if (misspellingLength || misspellingLocation != -1)
     142        isMisspelled = true;
     143#endif
     144   
     145    return isMisspelled;
     146}
     147
     148int AccessibilityObject::blockquoteLevel() const
     149{
     150    int level = 0;
     151    for (Node* elementNode = node(); elementNode; elementNode = elementNode->parentNode()) {
     152        if (elementNode->hasTagName(blockquoteTag))
     153            ++level;
     154    }
     155   
     156    return level;
    86157}
    87158
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r91718 r92000  
    314314    bool isCheckboxOrRadio() const { return isCheckbox() || isRadioButton(); }
    315315    bool isScrollView() const { return roleValue() == ScrollAreaRole; }
     316    bool isBlockquote() const;
     317    bool isLandmark() const;
    316318   
    317319    virtual bool isChecked() const { return false; }
     
    326328    virtual bool isPressed() const { return false; }
    327329    virtual bool isReadOnly() const { return false; }
     330    virtual bool isUnvisited() const { return false; }
    328331    virtual bool isVisited() const { return false; }
    329332    virtual bool isRequired() const { return false; }
     
    334337    virtual void setIsExpanded(bool) { }
    335338
     339    virtual bool hasBoldFont() const { return false; }
     340    virtual bool hasItalicFont() const { return false; }
     341    bool hasMisspelling() const;
     342    virtual bool hasPlainText() const { return false; }
     343    virtual bool hasSameFont(RenderObject*) const { return false; }
     344    virtual bool hasSameFontColor(RenderObject*) const { return false; }
     345    virtual bool hasSameStyle(RenderObject*) const { return false; }
     346    bool hasStaticText() const { return roleValue() == StaticTextRole; }
     347    virtual bool hasUnderline() const { return false; }
     348
    336349    virtual bool canSetFocusAttribute() const { return false; }
    337350    virtual bool canSetTextRangeAttributes() const { return false; }
     
    349362    virtual bool accessibilityIsIgnored() const  { return true; }
    350363
     364    int blockquoteLevel() const;
    351365    virtual int headingLevel() const { return 0; }
     366    virtual int tableLevel() const { return 0; }
    352367    virtual AccessibilityButtonState checkboxOrRadioValue() const;
    353368    virtual String valueDescription() const { return String(); }
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r91718 r92000  
    20822082}
    20832083
     2084bool AccessibilityRenderObject::isUnvisited() const
     2085{
     2086    // FIXME: Is it a privacy violation to expose unvisited information to accessibility APIs?
     2087    return m_renderer->style()->isLink() && m_renderer->style()->insideLink() == InsideUnvisitedLink;
     2088}
     2089
    20842090bool AccessibilityRenderObject::isVisited() const
    20852091{
     
    36663672}
    36673673
     3674bool AccessibilityRenderObject::hasBoldFont() const
     3675{
     3676    if (!m_renderer)
     3677        return false;
     3678   
     3679    return m_renderer->style()->fontDescription().weight() >= FontWeightBold;
     3680}
     3681
     3682bool AccessibilityRenderObject::hasItalicFont() const
     3683{
     3684    if (!m_renderer)
     3685        return false;
     3686   
     3687    return m_renderer->style()->fontDescription().italic() == FontItalicOn;
     3688}
     3689
     3690bool AccessibilityRenderObject::hasPlainText() const
     3691{
     3692    if (!m_renderer)
     3693        return false;
     3694   
     3695    RenderStyle* style = m_renderer->style();
     3696   
     3697    return style->fontDescription().weight() == FontWeightNormal
     3698        && style->fontDescription().italic() == FontItalicOff
     3699        && style->textDecorationsInEffect() == TDNONE;
     3700}
     3701
     3702bool AccessibilityRenderObject::hasSameFont(RenderObject* renderer) const
     3703{
     3704    if (!m_renderer || !renderer)
     3705        return false;
     3706   
     3707    return m_renderer->style()->fontDescription().family() == renderer->style()->fontDescription().family();
     3708}
     3709
     3710bool AccessibilityRenderObject::hasSameFontColor(RenderObject* renderer) const
     3711{
     3712    if (!m_renderer || !renderer)
     3713        return false;
     3714   
     3715    return m_renderer->style()->visitedDependentColor(CSSPropertyColor) == renderer->style()->visitedDependentColor(CSSPropertyColor);
     3716}
     3717
     3718bool AccessibilityRenderObject::hasSameStyle(RenderObject* renderer) const
     3719{
     3720    if (!m_renderer || !renderer)
     3721        return false;
     3722   
     3723    return m_renderer->style() == renderer->style();
     3724}
     3725
     3726bool AccessibilityRenderObject::hasUnderline() const
     3727{
     3728    if (!m_renderer)
     3729        return false;
     3730   
     3731    return m_renderer->style()->textDecorationsInEffect() & UNDERLINE;
     3732}
     3733
    36683734String AccessibilityRenderObject::nameForMSAA() const
    36693735{
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h

    r91718 r92000  
    9999    virtual bool isPressed() const;
    100100    virtual bool isReadOnly() const;
     101    virtual bool isUnvisited() const;
    101102    virtual bool isVisited() const;       
    102103    virtual bool isRequired() const;
    103104    virtual bool isLinked() const;
     105    virtual bool hasBoldFont() const;
     106    virtual bool hasItalicFont() const;
     107    virtual bool hasPlainText() const;
     108    virtual bool hasSameFont(RenderObject*) const;
     109    virtual bool hasSameFontColor(RenderObject*) const;
     110    virtual bool hasSameStyle(RenderObject*) const;
     111    virtual bool hasUnderline() const;
    104112
    105113    virtual bool canSetFocusAttribute() const;
  • trunk/Source/WebCore/accessibility/AccessibilityTable.cpp

    r70554 r92000  
    447447    return m_rows.size();
    448448}
    449    
     449
     450int AccessibilityTable::tableLevel() const
     451{
     452    int level = 0;
     453    for (AccessibilityObject* obj = parentObject(); obj; obj = obj->parentObject()) {
     454        if (obj->isAccessibilityTable())
     455            ++level;
     456    }
     457   
     458    return level;
     459}
     460
    450461AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column, unsigned row)
    451462{
  • trunk/Source/WebCore/accessibility/AccessibilityTable.h

    r85036 r92000  
    6969    unsigned columnCount();
    7070    unsigned rowCount();
     71    virtual int tableLevel() const;
    7172   
    7273    virtual String title() const;
  • trunk/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm

    r86451 r92000  
    452452}
    453453
    454 static int blockquoteLevel(RenderObject* renderer)
    455 {
    456     if (!renderer)
    457         return 0;
    458    
    459     int result = 0;
    460     for (Node* node = renderer->node(); node; node = node->parentNode()) {
    461         if (node->hasTagName(blockquoteTag))
    462             result += 1;
    463     }
    464    
    465     return result;
    466 }
    467 
    468454static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range)
    469455{
    470     int quoteLevel = blockquoteLevel(renderer);
     456    AccessibilityObject* obj = renderer->document()->axObjectCache()->getOrCreate(renderer);
     457    int quoteLevel = obj->blockquoteLevel();
    471458   
    472459    if (quoteLevel)
     
    19871974
    19881975        if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
    1989             return [NSNumber numberWithInt:blockquoteLevel(renderer)];
     1976            return [NSNumber numberWithInt:m_object->blockquoteLevel()];
    19901977    } else {
    19911978        if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute]) {
Note: See TracChangeset for help on using the changeset viewer.