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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp

Issue 2006043002: Improved the reporting of background color information. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/accessibility/background-color.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
index 78acfb0d75c97ab3fd9c16728662883efc8baebf..0dc0fea85520b55967942ac60bbacbdef6748bf6 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
@@ -839,12 +839,30 @@ RGBA32 AXLayoutObject::backgroundColor() const
if (!getLayoutObject())
return AXNodeObject::backgroundColor();
- const ComputedStyle* style = getLayoutObject()->style();
- if (!style || !style->hasBackground())
- return AXNodeObject::backgroundColor();
+ Color blendedColor = Color::transparent;
+ for (LayoutObject* layoutObject = getLayoutObject(); layoutObject;
aboxhall 2016/05/24 17:06:34 Unfortunately, walking up the parent chain often i
+ layoutObject = layoutObject->parent()) {
+ const ComputedStyle* style = layoutObject->style();
+ if (!style || !style->hasBackground())
+ continue;
- Color color = style->visitedDependentColor(CSSPropertyBackgroundColor);
- return color.rgb();
+ Color currentColor = style->visitedDependentColor(CSSPropertyBackgroundColor);
+ blendedColor = blendedColor.blend(currentColor);
+ // Continue blending until we get opacity to more than 50%
+ if (blendedColor.alpha() > 128)
aboxhall 2016/05/24 17:06:34 I share Dominic's concern here: for example, 51% r
+ break;
+ }
+
+ // If we still have a low level of opacity, blend in the document base color.
+ if (blendedColor.alpha() <= 128) {
+ FrameView* view = documentFrameView();
+ if (view) {
+ Color documentBaseColor = view->baseBackgroundColor();
+ blendedColor = blendedColor.blend(documentBaseColor);
+ }
+ }
+
+ return blendedColor.rgb();
}
RGBA32 AXLayoutObject::color() const
@@ -1678,11 +1696,11 @@ Document* AXLayoutObject::getDocument() const
FrameView* AXLayoutObject::documentFrameView() const
{
- if (!m_layoutObject)
- return 0;
+ if (!getLayoutObject())
+ return nullptr;
// this is the LayoutObject's Document's LocalFrame's FrameView
- return m_layoutObject->document().view();
+ return getLayoutObject()->document().view();
}
Element* AXLayoutObject::anchorElement() const
« no previous file with comments | « third_party/WebKit/LayoutTests/accessibility/background-color.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698