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

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: Added blank line to test expectations. 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
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 a3c5f574b68ce5697e704040fe343c6f03d897ba..e58da33e987d19a4aaf7bbb5406be3d7349705c0 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
@@ -833,17 +833,46 @@ const AtomicString& AXLayoutObject::accessKey() const
return toElement(node)->getAttribute(accesskeyAttr);
}
-RGBA32 AXLayoutObject::backgroundColor() const
+RGBA32 AXLayoutObject::computeBackgroundColor() const
{
if (!getLayoutObject())
return AXNodeObject::backgroundColor();
- const ComputedStyle* style = getLayoutObject()->style();
- if (!style || !style->hasBackground())
- return AXNodeObject::backgroundColor();
+ Color blendedColor = Color::transparent;
+ // Color::blend should be called like this: background.blend(foreground).
+ for (LayoutObject* layoutObject = getLayoutObject(); layoutObject;
+ layoutObject = layoutObject->parent()) {
+ const AXObject* axParent = axObjectCache().getOrCreate(layoutObject);
+ if (axParent && axParent != this) {
+ Color parentColor = axParent->backgroundColor();
+ blendedColor = parentColor.blend(blendedColor);
+ return blendedColor.rgb();
+ }
- Color color = style->visitedDependentColor(CSSPropertyBackgroundColor);
- return color.rgb();
+ const ComputedStyle* style = layoutObject->style();
+ if (!style || !style->hasBackground())
+ continue;
+
+ Color currentColor = style->visitedDependentColor(CSSPropertyBackgroundColor);
+ blendedColor = currentColor.blend(blendedColor);
+ // Continue blending until we get no transparency.
+ if (!blendedColor.hasAlpha())
+ break;
+ }
+
+ // If we still have some transparency, blend in the document base color.
+ if (blendedColor.hasAlpha()) {
+ FrameView* view = documentFrameView();
+ if (view) {
+ Color documentBaseColor = view->baseBackgroundColor();
+ blendedColor = documentBaseColor.blend(blendedColor);
+ } else {
+ // Default to a white background.
+ blendedColor.blendWithWhite();
+ }
+ }
+
+ return blendedColor.rgb();
}
RGBA32 AXLayoutObject::color() const
@@ -1677,11 +1706,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

Powered by Google App Engine
This is Rietveld 408576698