Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp

Issue 2479593007: Expose images to accessibility (Closed)
Patch Set: A few more tests rebaselined. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/accessibility/accessibility-ignoredNodes-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // containers with meaningful information, the inclusion of a span can have 690 // containers with meaningful information, the inclusion of a span can have
691 // the side effect of causing the immediate parent accessible to be ignored. 691 // the side effect of causing the immediate parent accessible to be ignored.
692 // This is especially problematic for platforms which have distinct roles for 692 // This is especially problematic for platforms which have distinct roles for
693 // textual block elements. 693 // textual block elements.
694 if (isHTMLSpanElement(node)) { 694 if (isHTMLSpanElement(node)) {
695 if (ignoredReasons) 695 if (ignoredReasons)
696 ignoredReasons->append(IgnoredReason(AXUninteresting)); 696 ignoredReasons->append(IgnoredReason(AXUninteresting));
697 return true; 697 return true;
698 } 698 }
699 699
700 // ignore images seemingly used as spacers 700 if (isImage())
701 if (isImage()) {
702 // If the image can take focus, it should not be ignored, lest the user not
703 // be able to interact with something important.
704 if (canSetFocusAttribute())
705 return false;
706
707 if (node && node->isElementNode()) {
708 Element* elt = toElement(node);
709 const AtomicString& alt = elt->getAttribute(altAttr);
710 // don't ignore an image that has an alt tag
711 if (!alt.getString().containsOnlyWhitespace())
712 return false;
713 // informal standard is to ignore images with zero-length alt strings
714 if (!alt.isNull()) {
715 if (ignoredReasons)
716 ignoredReasons->append(IgnoredReason(AXEmptyAlt));
717 return true;
718 }
719 }
720
721 if (isNativeImage() && m_layoutObject->isImage()) {
722 // check for one-dimensional image
723 LayoutImage* image = toLayoutImage(m_layoutObject);
724 if (image->size().height() <= 1 || image->size().width() <= 1) {
725 if (ignoredReasons)
726 ignoredReasons->append(IgnoredReason(AXProbablyPresentational));
727 return true;
728 }
729
730 // Check whether laid out image was stretched from one-dimensional file
731 // image.
732 if (image->cachedImage()) {
733 LayoutSize imageSize = image->cachedImage()->imageSize(
734 LayoutObject::shouldRespectImageOrientation(m_layoutObject),
735 image->view()->zoomFactor());
736 if (imageSize.height() <= 1 || imageSize.width() <= 1) {
737 if (ignoredReasons)
738 ignoredReasons->append(IgnoredReason(AXProbablyPresentational));
739 return true;
740 }
741 return false;
742 }
743 }
744 return false; 701 return false;
745 }
746 702
747 if (isCanvas()) { 703 if (isCanvas()) {
748 if (canvasHasFallbackContent()) 704 if (canvasHasFallbackContent())
749 return false; 705 return false;
750 LayoutHTMLCanvas* canvas = toLayoutHTMLCanvas(m_layoutObject); 706 LayoutHTMLCanvas* canvas = toLayoutHTMLCanvas(m_layoutObject);
751 if (canvas->size().height() <= 1 || canvas->size().width() <= 1) { 707 if (canvas->size().height() <= 1 || canvas->size().width() <= 1) {
752 if (ignoredReasons) 708 if (ignoredReasons)
753 ignoredReasons->append(IgnoredReason(AXProbablyPresentational)); 709 ignoredReasons->append(IgnoredReason(AXProbablyPresentational));
754 return true; 710 return true;
755 } 711 }
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 2405
2450 bool AXLayoutObject::elementAttributeValue( 2406 bool AXLayoutObject::elementAttributeValue(
2451 const QualifiedName& attributeName) const { 2407 const QualifiedName& attributeName) const {
2452 if (!m_layoutObject) 2408 if (!m_layoutObject)
2453 return false; 2409 return false;
2454 2410
2455 return equalIgnoringCase(getAttribute(attributeName), "true"); 2411 return equalIgnoringCase(getAttribute(attributeName), "true");
2456 } 2412 }
2457 2413
2458 } // namespace blink 2414 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/accessibility/accessibility-ignoredNodes-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698