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

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

Issue 757583002: Revert of Use Shadow DOM to display fallback content for images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
« no previous file with comments | « Source/core/rendering/RenderImage.cpp ('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 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
267 AccessibilityRole AXRenderObject::determineAccessibilityRole() 256 AccessibilityRole AXRenderObject::determineAccessibilityRole()
268 { 257 {
269 if (!m_renderer) 258 if (!m_renderer)
270 return UnknownRole; 259 return UnknownRole;
271 260
272 m_ariaRole = determineAriaRoleAttribute(); 261 m_ariaRole = determineAriaRoleAttribute();
273 262
274 Node* node = m_renderer->node(); 263 Node* node = m_renderer->node();
275 AccessibilityRole ariaRole = ariaRoleAttribute(); 264 AccessibilityRole ariaRole = ariaRoleAttribute();
276 if (ariaRole != UnknownRole) 265 if (ariaRole != UnknownRole)
277 return ariaRole; 266 return ariaRole;
278 267
279 RenderBoxModelObject* cssBox = renderBoxModelObject(); 268 RenderBoxModelObject* cssBox = renderBoxModelObject();
280 269
281 if (node && node->isLink()) { 270 if (node && node->isLink()) {
282 if (isImageOrAltText(cssBox, node)) 271 if (cssBox && cssBox->isImage())
283 return ImageMapRole; 272 return ImageMapRole;
284 return LinkRole; 273 return LinkRole;
285 } 274 }
286 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) 275 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node))
287 return ListItemRole; 276 return ListItemRole;
288 if (m_renderer->isListMarker()) 277 if (m_renderer->isListMarker())
289 return ListMarkerRole; 278 return ListMarkerRole;
290 if (isHTMLButtonElement(node)) 279 if (isHTMLButtonElement(node))
291 return buttonRoleType(); 280 return buttonRoleType();
292 if (isHTMLDetailsElement(node)) 281 if (isHTMLDetailsElement(node))
293 return DetailsRole; 282 return DetailsRole;
294 if (isHTMLSummaryElement(node)) { 283 if (isHTMLSummaryElement(node)) {
295 if (node->parentElement() && isHTMLDetailsElement(node->parentElement()) ) 284 if (node->parentElement() && isHTMLDetailsElement(node->parentElement()) )
296 return DisclosureTriangleRole; 285 return DisclosureTriangleRole;
297 return UnknownRole; 286 return UnknownRole;
298 } 287 }
299 if (isHTMLLegendElement(node)) 288 if (isHTMLLegendElement(node))
300 return LegendRole; 289 return LegendRole;
301 if (m_renderer->isText()) 290 if (m_renderer->isText())
302 return StaticTextRole; 291 return StaticTextRole;
303 if (isImageOrAltText(cssBox, node)) { 292 if (cssBox && cssBox->isImage()) {
304 if (isHTMLInputElement(node)) 293 if (isHTMLInputElement(node))
305 return ariaHasPopup() ? PopUpButtonRole : ButtonRole; 294 return ariaHasPopup() ? PopUpButtonRole : ButtonRole;
306 if (isSVGImage()) 295 if (isSVGImage())
307 return SVGRootRole; 296 return SVGRootRole;
308 return ImageRole; 297 return ImageRole;
309 } 298 }
310 299
311 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas . 300 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas .
312 if (isHTMLCanvasElement(node) && m_renderer->isCanvas()) 301 if (isHTMLCanvasElement(node) && m_renderer->isCanvas())
313 return CanvasRole; 302 return CanvasRole;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 Element* elt = toElement(node); 773 Element* elt = toElement(node);
785 const AtomicString& alt = elt->getAttribute(altAttr); 774 const AtomicString& alt = elt->getAttribute(altAttr);
786 // don't ignore an image that has an alt tag 775 // don't ignore an image that has an alt tag
787 if (!alt.string().containsOnlyWhitespace()) 776 if (!alt.string().containsOnlyWhitespace())
788 return false; 777 return false;
789 // informal standard is to ignore images with zero-length alt string s 778 // informal standard is to ignore images with zero-length alt string s
790 if (!alt.isNull()) 779 if (!alt.isNull())
791 return true; 780 return true;
792 } 781 }
793 782
794 if (isNativeImage() && isImageOrAltText(toRenderBoxModelObject(m_rendere r), node)) { 783 if (isNativeImage() && m_renderer->isImage()) {
795 // check for one-dimensional image 784 // check for one-dimensional image
796 RenderImage* image = toRenderImage(m_renderer); 785 RenderImage* image = toRenderImage(m_renderer);
797 if (image->height() <= 1 || image->width() <= 1) 786 if (image->height() <= 1 || image->width() <= 1)
798 return true; 787 return true;
799 788
800 // check whether rendered image was stretched from one-dimensional f ile image 789 // check whether rendered image was stretched from one-dimensional f ile image
801 if (image->cachedImage()) { 790 if (image->cachedImage()) {
802 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor()); 791 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor());
803 return imageSize.height() <= 1 || imageSize.width() <= 1; 792 return imageSize.height() <= 1 || imageSize.width() <= 1;
804 } 793 }
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2464 if (label && label->renderer()) { 2453 if (label && label->renderer()) {
2465 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2454 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2466 result.unite(labelRect); 2455 result.unite(labelRect);
2467 } 2456 }
2468 } 2457 }
2469 2458
2470 return result; 2459 return result;
2471 } 2460 }
2472 2461
2473 } // namespace blink 2462 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698