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

Side by Side Diff: Source/modules/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 ())
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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 Element* elt = toElement(node); 780 Element* elt = toElement(node);
770 const AtomicString& alt = elt->getAttribute(altAttr); 781 const AtomicString& alt = elt->getAttribute(altAttr);
771 // don't ignore an image that has an alt tag 782 // don't ignore an image that has an alt tag
772 if (!alt.string().containsOnlyWhitespace()) 783 if (!alt.string().containsOnlyWhitespace())
773 return false; 784 return false;
774 // informal standard is to ignore images with zero-length alt string s 785 // informal standard is to ignore images with zero-length alt string s
775 if (!alt.isNull()) 786 if (!alt.isNull())
776 return true; 787 return true;
777 } 788 }
778 789
779 if (isNativeImage() && m_renderer->isImage()) { 790 if (isNativeImage() && isImageOrAltText(toRenderBoxModelObject(m_rendere r), node)) {
780 // check for one-dimensional image 791 // check for one-dimensional image
781 RenderImage* image = toRenderImage(m_renderer); 792 RenderImage* image = toRenderImage(m_renderer);
782 if (image->height() <= 1 || image->width() <= 1) 793 if (image->height() <= 1 || image->width() <= 1)
783 return true; 794 return true;
784 795
785 // check whether rendered image was stretched from one-dimensional f ile image 796 // check whether rendered image was stretched from one-dimensional f ile image
786 if (image->cachedImage()) { 797 if (image->cachedImage()) {
787 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor()); 798 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor());
788 return imageSize.height() <= 1 || imageSize.width() <= 1; 799 return imageSize.height() <= 1 || imageSize.width() <= 1;
789 } 800 }
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 if (label && label->renderer()) { 2448 if (label && label->renderer()) {
2438 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2449 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2439 result.unite(labelRect); 2450 result.unite(labelRect);
2440 } 2451 }
2441 } 2452 }
2442 2453
2443 return result; 2454 return result;
2444 } 2455 }
2445 2456
2446 } // namespace blink 2457 } // namespace blink
OLDNEW
« Source/core/html/HTMLImageFallbackHelper.cpp ('K') | « Source/core/rendering/RenderImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698