Changeset 92000 in webkit
- Timestamp:
- Jul 29, 2011 10:37:31 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r91999 r92000 1 2011-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 1 52 2011-07-29 Zeng Huiqing <huiqing.zeng@intel.com> 2 53 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r87856 r92000 50 50 #include "RenderView.h" 51 51 #include "RenderWidget.h" 52 #include "TextCheckerClient.h" 52 53 #include "TextIterator.h" 53 54 #include "htmlediting.h" … … 84 85 setWrapper(0); 85 86 #endif 87 } 88 89 bool AccessibilityObject::isBlockquote() const 90 { 91 return node() && node()->hasTagName(blockquoteTag); 92 } 93 94 bool 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 107 bool 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 148 int 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; 86 157 } 87 158 -
trunk/Source/WebCore/accessibility/AccessibilityObject.h
r91718 r92000 314 314 bool isCheckboxOrRadio() const { return isCheckbox() || isRadioButton(); } 315 315 bool isScrollView() const { return roleValue() == ScrollAreaRole; } 316 bool isBlockquote() const; 317 bool isLandmark() const; 316 318 317 319 virtual bool isChecked() const { return false; } … … 326 328 virtual bool isPressed() const { return false; } 327 329 virtual bool isReadOnly() const { return false; } 330 virtual bool isUnvisited() const { return false; } 328 331 virtual bool isVisited() const { return false; } 329 332 virtual bool isRequired() const { return false; } … … 334 337 virtual void setIsExpanded(bool) { } 335 338 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 336 349 virtual bool canSetFocusAttribute() const { return false; } 337 350 virtual bool canSetTextRangeAttributes() const { return false; } … … 349 362 virtual bool accessibilityIsIgnored() const { return true; } 350 363 364 int blockquoteLevel() const; 351 365 virtual int headingLevel() const { return 0; } 366 virtual int tableLevel() const { return 0; } 352 367 virtual AccessibilityButtonState checkboxOrRadioValue() const; 353 368 virtual String valueDescription() const { return String(); } -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r91718 r92000 2082 2082 } 2083 2083 2084 bool 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 2084 2090 bool AccessibilityRenderObject::isVisited() const 2085 2091 { … … 3666 3672 } 3667 3673 3674 bool AccessibilityRenderObject::hasBoldFont() const 3675 { 3676 if (!m_renderer) 3677 return false; 3678 3679 return m_renderer->style()->fontDescription().weight() >= FontWeightBold; 3680 } 3681 3682 bool AccessibilityRenderObject::hasItalicFont() const 3683 { 3684 if (!m_renderer) 3685 return false; 3686 3687 return m_renderer->style()->fontDescription().italic() == FontItalicOn; 3688 } 3689 3690 bool 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 3702 bool 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 3710 bool 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 3718 bool AccessibilityRenderObject::hasSameStyle(RenderObject* renderer) const 3719 { 3720 if (!m_renderer || !renderer) 3721 return false; 3722 3723 return m_renderer->style() == renderer->style(); 3724 } 3725 3726 bool AccessibilityRenderObject::hasUnderline() const 3727 { 3728 if (!m_renderer) 3729 return false; 3730 3731 return m_renderer->style()->textDecorationsInEffect() & UNDERLINE; 3732 } 3733 3668 3734 String AccessibilityRenderObject::nameForMSAA() const 3669 3735 { -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h
r91718 r92000 99 99 virtual bool isPressed() const; 100 100 virtual bool isReadOnly() const; 101 virtual bool isUnvisited() const; 101 102 virtual bool isVisited() const; 102 103 virtual bool isRequired() const; 103 104 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; 104 112 105 113 virtual bool canSetFocusAttribute() const; -
trunk/Source/WebCore/accessibility/AccessibilityTable.cpp
r70554 r92000 447 447 return m_rows.size(); 448 448 } 449 449 450 int 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 450 461 AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column, unsigned row) 451 462 { -
trunk/Source/WebCore/accessibility/AccessibilityTable.h
r85036 r92000 69 69 unsigned columnCount(); 70 70 unsigned rowCount(); 71 virtual int tableLevel() const; 71 72 72 73 virtual String title() const; -
trunk/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
r86451 r92000 452 452 } 453 453 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 468 454 static void AXAttributeStringSetBlockquoteLevel(NSMutableAttributedString* attrString, RenderObject* renderer, NSRange range) 469 455 { 470 int quoteLevel = blockquoteLevel(renderer); 456 AccessibilityObject* obj = renderer->document()->axObjectCache()->getOrCreate(renderer); 457 int quoteLevel = obj->blockquoteLevel(); 471 458 472 459 if (quoteLevel) … … 1987 1974 1988 1975 if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute]) 1989 return [NSNumber numberWithInt: blockquoteLevel(renderer)];1976 return [NSNumber numberWithInt:m_object->blockquoteLevel()]; 1990 1977 } else { 1991 1978 if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute]) {
Note: See TracChangeset
for help on using the changeset viewer.