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

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 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 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) 272 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole)
262 return m_ariaRole; 273 return m_ariaRole;
263 274
264 Node* node = m_renderer->node(); 275 Node* node = m_renderer->node();
265 RenderBoxModelObject* cssBox = renderBoxModelObject(); 276 RenderBoxModelObject* cssBox = renderBoxModelObject();
266 277
267 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) 278 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node))
268 return ListItemRole; 279 return ListItemRole;
269 if (m_renderer->isListMarker()) 280 if (m_renderer->isListMarker())
270 return ListMarkerRole; 281 return ListMarkerRole;
271 if (isHTMLLegendElement(node)) 282 if (isHTMLLegendElement(node))
272 return LegendRole; 283 return LegendRole;
273 if (m_renderer->isText()) 284 if (m_renderer->isText())
274 return StaticTextRole; 285 return StaticTextRole;
275 if (cssBox && cssBox->isImage()) { 286 if (cssBox && isImageOrAltText(cssBox, node)) {
276 if (node && node->isLink()) 287 if (node && node->isLink())
277 return ImageMapRole; 288 return ImageMapRole;
278 if (isHTMLInputElement(node)) 289 if (isHTMLInputElement(node))
279 return ariaHasPopup() ? PopUpButtonRole : ButtonRole; 290 return ariaHasPopup() ? PopUpButtonRole : ButtonRole;
280 if (isSVGImage()) 291 if (isSVGImage())
281 return SVGRootRole; 292 return SVGRootRole;
282 return ImageRole; 293 return ImageRole;
283 } 294 }
284 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas . 295 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas .
285 if (isHTMLCanvasElement(node) && m_renderer->isCanvas()) 296 if (isHTMLCanvasElement(node) && m_renderer->isCanvas())
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 Element* elt = toElement(node); 687 Element* elt = toElement(node);
677 const AtomicString& alt = elt->getAttribute(altAttr); 688 const AtomicString& alt = elt->getAttribute(altAttr);
678 // don't ignore an image that has an alt tag 689 // don't ignore an image that has an alt tag
679 if (!alt.string().containsOnlyWhitespace()) 690 if (!alt.string().containsOnlyWhitespace())
680 return false; 691 return false;
681 // informal standard is to ignore images with zero-length alt string s 692 // informal standard is to ignore images with zero-length alt string s
682 if (!alt.isNull()) 693 if (!alt.isNull())
683 return true; 694 return true;
684 } 695 }
685 696
686 if (isNativeImage() && m_renderer->isImage()) { 697 if (isNativeImage() && isImageOrAltText(toRenderBoxModelObject(m_rendere r), node)) {
687 // check for one-dimensional image 698 // check for one-dimensional image
688 RenderImage* image = toRenderImage(m_renderer); 699 RenderImage* image = toRenderImage(m_renderer);
689 if (image->size().height() <= 1 || image->size().width() <= 1) 700 if (image->size().height() <= 1 || image->size().width() <= 1)
690 return true; 701 return true;
691 702
692 // check whether rendered image was stretched from one-dimensional f ile image 703 // check whether rendered image was stretched from one-dimensional f ile image
693 if (image->cachedImage()) { 704 if (image->cachedImage()) {
694 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor()); 705 LayoutSize imageSize = image->cachedImage()->imageSizeForRendere r(m_renderer, image->view()->zoomFactor());
695 return imageSize.height() <= 1 || imageSize.width() <= 1; 706 return imageSize.height() <= 1 || imageSize.width() <= 1;
696 } 707 }
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 if (label && label->renderer()) { 2408 if (label && label->renderer()) {
2398 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2409 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2399 result.unite(labelRect); 2410 result.unite(labelRect);
2400 } 2411 }
2401 } 2412 }
2402 2413
2403 return result; 2414 return result;
2404 } 2415 }
2405 2416
2406 } // namespace blink 2417 } // namespace blink
OLDNEW
« Source/core/paint/ImagePainter.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