Fix bugzilla bug 4219, crash because we tried to do the fake paint
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Aug 2005 21:23:42 +0000 (21:23 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Aug 2005 21:23:42 +0000 (21:23 +0000)
when layout was not updated yet.

Also landing accessibility for checkboxes.

        Reviewed by darin/mjs (accessibility), kocienda(crash)

        * ChangeLog:
        * khtml/rendering/render_theme.h:
        (khtml::RenderTheme::supportsControlTints):
        * kwq/KWQAccObject.mm:
        (-[KWQAccObject actionElement]):
        (-[KWQAccObject role]):
        (-[KWQAccObject roleDescription]):
        (-[KWQAccObject value]):
        (boundingBoxRect):
        (-[KWQAccObject accessibilityIsIgnored]):
        (-[KWQAccObject accessibilityAttributeValue:]):
        (-[KWQAccObject accessibilityIsAttributeSettable:]):
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::setDisplaysWithFocusAttributes):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9999 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_theme.h
WebCore/kwq/KWQAccObject.mm
WebCore/kwq/KWQKHTMLPart.mm

index b3a33c8..090d06d 100644 (file)
@@ -1,3 +1,27 @@
+2005-08-01  David Hyatt  <hyatt@apple.com>
+
+       Fix bugzilla bug 4219, crash because we tried to do the fake paint
+       when layout was not updated yet.
+
+       Also landing accessibility for checkboxes.
+       
+        Reviewed by darin/mjs (accessibility), kocienda(crash)
+
+        * ChangeLog:
+        * khtml/rendering/render_theme.h:
+        (khtml::RenderTheme::supportsControlTints):
+        * kwq/KWQAccObject.mm:
+        (-[KWQAccObject actionElement]):
+        (-[KWQAccObject role]):
+        (-[KWQAccObject roleDescription]):
+        (-[KWQAccObject value]):
+        (boundingBoxRect):
+        (-[KWQAccObject accessibilityIsIgnored]):
+        (-[KWQAccObject accessibilityAttributeValue:]):
+        (-[KWQAccObject accessibilityIsAttributeSettable:]):
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::setDisplaysWithFocusAttributes):
+
 2005-08-01  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Beth Dakin.
 
 2005-07-31  David Hyatt  <hyatt@apple.com>
 
+       Implement support for checkbox accessibility for VoiceOver.
+       
+        Reviewed by mjs
+
+        * kwq/KWQAccObject.mm:
+        (-[KWQAccObject actionElement]):
+        (-[KWQAccObject role]):
+        (-[KWQAccObject roleDescription]):
+        (-[KWQAccObject value]):
+        (boundingBoxRect):
+        (-[KWQAccObject accessibilityIsIgnored]):
+        (-[KWQAccObject accessibilityAttributeValue:]):
+        (-[KWQAccObject accessibilityIsAttributeSettable:]):
+
+2005-07-31  David Hyatt  <hyatt@apple.com>
+
        Make node lists more refined in their invalidation when children are added/removed
        in the DOM or attributes are changed.  This is sort of a band-aid fix.  The
        architecture of node list notifications (as well as how they are stored) should
index f2c6f36..d461482 100644 (file)
@@ -62,6 +62,9 @@ public:
     // An API asking if the control changes its tint when the window has focus or not.
     virtual bool controlSupportsTints(const RenderObject* o) const { return false; }
 
+    // A general API asking if any control tinting is supported at all.
+    virtual bool supportsControlTints() const { return false; }
+
     // Some controls may spill out of their containers (e.g., the check on an OS X checkbox).  When these controls repaint,
     // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control.
     virtual void adjustRepaintRect(const RenderObject* o, QRect& r) { }
index f47812c..b01af86 100644 (file)
@@ -55,6 +55,7 @@
 #import "render_object.h"
 #import "render_style.h"
 #import "render_text.h"
+#import "render_theme.h"
 #import "selection.h"
 #import "kjs_html.h"
 #import "text_granularity.h"
@@ -80,6 +81,7 @@ using DOM::Node;
 using DOM::NodeImpl;
 using DOM::Position;
 
+using khtml::theme;
 using khtml::EAffinity;
 using khtml::EVerticalAlign;
 using khtml::plainText;
@@ -202,6 +204,12 @@ using khtml::VisiblePosition;
 
 -(ElementImpl *)actionElement
 {
+    if (m_renderer->element() && m_renderer->element()->hasTagName(inputTag)) {
+        HTMLInputElementImpl* input = static_cast<HTMLInputElementImpl*>(m_renderer->element());
+        if (!input->disabled() && input->inputType() == HTMLInputElementImpl::CHECKBOX)
+            return input;
+    }
+
     if ([self isImageButton])
         return static_cast<ElementImpl*>(m_renderer->element());
 
@@ -376,6 +384,13 @@ using khtml::VisiblePosition;
     }
     if (m_renderer->isCanvas())
         return @"AXWebArea";
+    
+    if (m_renderer->element() && m_renderer->element()->hasTagName(inputTag)) {
+        HTMLInputElementImpl* input = static_cast<HTMLInputElementImpl*>(m_renderer->element());
+        if (input->inputType() == HTMLInputElementImpl::CHECKBOX)
+            return NSAccessibilityCheckBoxRole;
+    }
+    
     if (m_renderer->isBlockFlow())
         return NSAccessibilityGroupRole;
     if ([self isAttachment])
@@ -424,6 +439,9 @@ using khtml::VisiblePosition;
     if ([role isEqualToString:NSAccessibilityGroupRole])
         return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, nil);
     
+    if ([role isEqualToString:NSAccessibilityCheckBoxRole])
+        return NSAccessibilityRoleDescription(NSAccessibilityCheckBoxRole, nil);
+
     if ([role isEqualToString:@"AXWebArea"])
         return UI_STRING("web area", "accessibility role description for web area");
     
@@ -488,7 +506,7 @@ using khtml::VisiblePosition;
     return nil;
 }
 
--(NSString*)value
+-(id)value
 {
     if (!m_renderer || m_areaElement)
         return nil;
@@ -518,7 +536,14 @@ using khtml::VisiblePosition;
     
     if ([self isAttachment])
         return [[self attachmentView] accessibilityAttributeValue:NSAccessibilityValueAttribute];
-        
+
+    if (m_renderer->element() && m_renderer->element()->hasTagName(inputTag)) {
+        HTMLInputElementImpl* input = static_cast<HTMLInputElementImpl*>(m_renderer->element());
+        if (input->inputType() == HTMLInputElementImpl::CHECKBOX)
+            // Checkboxes return their state as an integer. 0 for off, 1 for on.
+            return [NSNumber numberWithInt:input->checked()];
+    }
+    
     // FIXME: We might need to implement a value here for more types
     // FIXME: It would be better not to advertise a value at all for the types for which we don't implement one;
     // this would require subclassing or making accessibilityAttributeNames do something other than return a
@@ -570,6 +595,8 @@ static QRect boundingBoxRect(RenderObject* obj)
         for (QValueList<QRect>::ConstIterator it = rects.begin(); it != rects.end(); ++it) {
             QRect r = *it;
             if (r.isValid()) {
+                if (obj->style()->hasAppearance())
+                    theme()->adjustRepaintRect(obj, r);
                 if (rect.isEmpty())
                     rect = r;
                 else
@@ -615,6 +642,10 @@ static QRect boundingBoxRect(RenderObject* obj)
     if (m_areaElement || (m_renderer->element() && m_renderer->element()->isLink()))
         return NO;
 
+    // All controls must be examined.
+    if (m_renderer->element() && m_renderer->element()->isControl())
+        return NO;
+
     if (m_renderer->isBlockFlow() && m_renderer->childrenInline())
         return !static_cast<RenderBlock*>(m_renderer)->firstLineBox() && ![self mouseButtonListener];
 
@@ -895,7 +926,7 @@ static QRect boundingBoxRect(RenderObject* obj)
         return [NSNumber numberWithBool: (m_renderer->element() && m_renderer->document()->focusNode() == m_renderer->element())];
 
     if ([attributeName isEqualToString: NSAccessibilityEnabledAttribute])
-        return [NSNumber numberWithBool: YES];
+        return [NSNumber numberWithBool: m_renderer->element() ? m_renderer->element()->isEnabled() : YES];
     
     if ([attributeName isEqualToString: NSAccessibilitySizeAttribute])
         return [self size];
@@ -1883,7 +1914,9 @@ static void AXAttributedStringAppendReplaced (NSMutableAttributedString *attrStr
     if ([attributeName isEqualToString: @"AXSelectedTextMarkerRangeAttribute"])
         return YES;
     if ([attributeName isEqualToString: NSAccessibilityFocusedAttribute]) {
-        if ([[self role] isEqualToString:@"AXLink"])
+        if ([[self role] isEqualToString:@"AXLink"] ||
+            ([[self role] isEqualToString:NSAccessibilityCheckBoxRole] &&
+              m_renderer->element()->isEnabled()))
             return YES;
     }
 #endif
@@ -1930,7 +1963,9 @@ static void AXAttributedStringAppendReplaced (NSMutableAttributedString *attrStr
         
     } else if ([attributeName isEqualToString: NSAccessibilityFocusedAttribute]) {
         ASSERT(number);
-        if ([[self role] isEqualToString:@"AXLink"]) {
+        if ([[self role] isEqualToString:@"AXLink"] ||
+            ([[self role] isEqualToString:NSAccessibilityCheckBoxRole] &&
+             m_renderer->element()->isEnabled())) {
             if ([number intValue] != 0)
                 m_renderer->document()->setFocusNode(m_renderer->element());
             else
index b70afd6..644d532 100644 (file)
@@ -3751,12 +3751,15 @@ void KWQKHTMLPart::setDisplaysWithFocusAttributes(bool flag)
     
     // 4. Changing the tint of controls from clear to aqua/graphite and vice versa.  We
     // do a "fake" paint.  When the theme gets a paint call, it can then do an invalidate.
-    NSView *documentView = d->m_view ? d->m_view->getDocumentView() : 0;
-    if (documentView && renderer()) {
-        QRect visibleRect([documentView visibleRect]);
-        QPainter p;
-        p.setUpdatingControlTints(true);
-        paint(&p, visibleRect);
+    if (theme()->supportsControlTints()) {
+        NSView *documentView = d->m_view ? d->m_view->getDocumentView() : 0;
+        if (documentView && renderer()) {
+            doc->updateLayout(); // Ensure layout is up to date.
+            QRect visibleRect([documentView visibleRect]);
+            QPainter p;
+            p.setUpdatingControlTints(true);
+            paint(&p, visibleRect);
+        }
     }
 }