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

Side by Side Diff: Source/core/accessibility/AXRenderObject.cpp

Issue 481753002: Use Shadow DOM to display fallback content for images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 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 | Annotate | Revision Log
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (!m_renderer || !m_renderer->isBox()) 246 if (!m_renderer || !m_renderer->isBox())
247 return 0; 247 return 0;
248 248
249 RenderBox* box = toRenderBox(m_renderer); 249 RenderBox* box = toRenderBox(m_renderer);
250 if (!box->canBeScrolledAndHasScrollableArea()) 250 if (!box->canBeScrolledAndHasScrollableArea())
251 return 0; 251 return 0;
252 252
253 return box->scrollableArea(); 253 return box->scrollableArea();
254 } 254 }
255 255
256 static bool isImageOrAltText(RenderBoxModelObject* box, Node* node)
257 {
258 if (box && box->isImage())
259 return true;
260 if (isHTMLImageElement(node))
261 return true;
262 if (isHTMLInputElement(node) && toHTMLInputElement(node)->hasFallbackContent ())
esprehn 2014/11/11 19:06:06 Why is an input with fallback content an image? Do
rhogan 2014/11/11 19:43:06 Yes, that's correct.
263 return true;
264 return false;
265 }
266
256 AccessibilityRole AXRenderObject::determineAccessibilityRole() 267 AccessibilityRole AXRenderObject::determineAccessibilityRole()
257 { 268 {
258 if (!m_renderer) 269 if (!m_renderer)
259 return UnknownRole; 270 return UnknownRole;
260 271
261 m_ariaRole = determineAriaRoleAttribute(); 272 m_ariaRole = determineAriaRoleAttribute();
262 273
263 Node* node = m_renderer->node(); 274 Node* node = m_renderer->node();
264 AccessibilityRole ariaRole = ariaRoleAttribute(); 275 AccessibilityRole ariaRole = ariaRoleAttribute();
265 if (ariaRole != UnknownRole) 276 if (ariaRole != UnknownRole)
266 return ariaRole; 277 return ariaRole;
267 278
268 RenderBoxModelObject* cssBox = renderBoxModelObject(); 279 RenderBoxModelObject* cssBox = renderBoxModelObject();
269 280
270 if (node && node->isLink()) { 281 if (node && node->isLink()) {
271 if (cssBox && cssBox->isImage()) 282 if (isImageOrAltText(cssBox, node))
272 return ImageMapRole; 283 return ImageMapRole;
273 return LinkRole; 284 return LinkRole;
274 } 285 }
275 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) 286 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node))
276 return ListItemRole; 287 return ListItemRole;
277 if (m_renderer->isListMarker()) 288 if (m_renderer->isListMarker())
278 return ListMarkerRole; 289 return ListMarkerRole;
279 if (isHTMLButtonElement(node)) 290 if (isHTMLButtonElement(node))
280 return buttonRoleType(); 291 return buttonRoleType();
281 if (isHTMLDetailsElement(node)) 292 if (isHTMLDetailsElement(node))
282 return DetailsRole; 293 return DetailsRole;
283 if (isHTMLSummaryElement(node)) { 294 if (isHTMLSummaryElement(node)) {
284 if (node->parentElement() && isHTMLDetailsElement(node->parentElement()) ) 295 if (node->parentElement() && isHTMLDetailsElement(node->parentElement()) )
285 return DisclosureTriangleRole; 296 return DisclosureTriangleRole;
286 return UnknownRole; 297 return UnknownRole;
287 } 298 }
288 if (isHTMLLegendElement(node)) 299 if (isHTMLLegendElement(node))
289 return LegendRole; 300 return LegendRole;
290 if (m_renderer->isText()) 301 if (m_renderer->isText())
291 return StaticTextRole; 302 return StaticTextRole;
292 if (cssBox && cssBox->isImage()) { 303 if (isImageOrAltText(cssBox, node)) {
293 if (isHTMLInputElement(node)) 304 if (isHTMLInputElement(node))
294 return ariaHasPopup() ? PopUpButtonRole : ButtonRole; 305 return ariaHasPopup() ? PopUpButtonRole : ButtonRole;
295 if (isSVGImage()) 306 if (isSVGImage())
296 return SVGRootRole; 307 return SVGRootRole;
297 return ImageRole; 308 return ImageRole;
298 } 309 }
299 310
300 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas . 311 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas .
301 if (isHTMLCanvasElement(node) && m_renderer->isCanvas()) 312 if (isHTMLCanvasElement(node) && m_renderer->isCanvas())
302 return CanvasRole; 313 return CanvasRole;
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 Element* elt = toElement(node); 772 Element* elt = toElement(node);
762 const AtomicString& alt = elt->getAttribute(altAttr); 773 const AtomicString& alt = elt->getAttribute(altAttr);
763 // don't ignore an image that has an alt tag 774 // don't ignore an image that has an alt tag
764 if (!alt.string().containsOnlyWhitespace()) 775 if (!alt.string().containsOnlyWhitespace())
765 return false; 776 return false;
766 // informal standard is to ignore images with zero-length alt string s 777 // informal standard is to ignore images with zero-length alt string s
767 if (!alt.isNull()) 778 if (!alt.isNull())
768 return true; 779 return true;
769 } 780 }
770 781
771 if (isNativeImage() && m_renderer->isImage()) { 782 if (isNativeImage() && isImageOrAltText(toRenderBoxModelObject(m_rendere r), node)) {
772 // check for one-dimensional image 783 // check for one-dimensional image
773 RenderImage* image = toRenderImage(m_renderer); 784 RenderImage* image = toRenderImage(m_renderer);
774 if (image->height() <= 1 || image->width() <= 1) 785 if (image->height() <= 1 || image->width() <= 1)
775 return true; 786 return true;
776 787
777 // check whether rendered image was stretched from one-dimensional f ile image 788 // check whether rendered image was stretched from one-dimensional f ile image
778 if (image->cachedImage()) { 789 if (image->cachedImage()) {
779 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor()); 790 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor());
780 return imageSize.height() <= 1 || imageSize.width() <= 1; 791 return imageSize.height() <= 1 || imageSize.width() <= 1;
781 } 792 }
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 if (label && label->renderer()) { 2439 if (label && label->renderer()) {
2429 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2440 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2430 result.unite(labelRect); 2441 result.unite(labelRect);
2431 } 2442 }
2432 } 2443 }
2433 2444
2434 return result; 2445 return result;
2435 } 2446 }
2436 2447
2437 } // namespace blink 2448 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698