Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 const AtomicString& AXLayoutObject::accessKey() const | 826 const AtomicString& AXLayoutObject::accessKey() const |
| 827 { | 827 { |
| 828 Node* node = m_layoutObject->node(); | 828 Node* node = m_layoutObject->node(); |
| 829 if (!node) | 829 if (!node) |
| 830 return nullAtom; | 830 return nullAtom; |
| 831 if (!node->isElementNode()) | 831 if (!node->isElementNode()) |
| 832 return nullAtom; | 832 return nullAtom; |
| 833 return toElement(node)->getAttribute(accesskeyAttr); | 833 return toElement(node)->getAttribute(accesskeyAttr); |
| 834 } | 834 } |
| 835 | 835 |
| 836 RGBA32 AXLayoutObject::backgroundColor() const | 836 RGBA32 AXLayoutObject::computeBackgroundColor() const |
| 837 { | 837 { |
| 838 if (!getLayoutObject()) | 838 if (!getLayoutObject()) |
| 839 return AXNodeObject::backgroundColor(); | 839 return AXNodeObject::backgroundColor(); |
| 840 | 840 |
| 841 const ComputedStyle* style = getLayoutObject()->style(); | 841 Color blendedColor = Color::transparent; |
| 842 if (!style || !style->hasBackground()) | 842 // Color::blend should be called like this: background.blend(foreground). |
|
aboxhall
2016/05/25 20:59:07
Great comment :)
| |
| 843 return AXNodeObject::backgroundColor(); | 843 for (LayoutObject* layoutObject = getLayoutObject(); layoutObject; |
| 844 layoutObject = layoutObject->parent()) { | |
| 845 const AXObject* axParent = axObjectCache().getOrCreate(layoutObject); | |
| 846 if (axParent && axParent != this) { | |
| 847 Color parentColor = axParent->backgroundColor(); | |
| 848 blendedColor = parentColor.blend(blendedColor); | |
| 849 return blendedColor.rgb(); | |
| 850 } | |
| 844 | 851 |
| 845 Color color = style->visitedDependentColor(CSSPropertyBackgroundColor); | 852 const ComputedStyle* style = layoutObject->style(); |
| 846 return color.rgb(); | 853 if (!style || !style->hasBackground()) |
| 854 continue; | |
| 855 | |
| 856 Color currentColor = style->visitedDependentColor(CSSPropertyBackgroundC olor); | |
| 857 blendedColor = currentColor.blend(blendedColor); | |
| 858 // Continue blending until we get no transparency. | |
| 859 if (!blendedColor.hasAlpha()) | |
| 860 break; | |
| 861 } | |
| 862 | |
| 863 // If we still have some transparency, blend in the document base color. | |
| 864 if (blendedColor.hasAlpha()) { | |
| 865 FrameView* view = documentFrameView(); | |
| 866 if (view) { | |
| 867 Color documentBaseColor = view->baseBackgroundColor(); | |
| 868 blendedColor = documentBaseColor.blend(blendedColor); | |
| 869 } else { | |
| 870 // Default to a white background. | |
| 871 blendedColor.blendWithWhite(); | |
| 872 } | |
| 873 } | |
| 874 | |
| 875 return blendedColor.rgb(); | |
| 847 } | 876 } |
| 848 | 877 |
| 849 RGBA32 AXLayoutObject::color() const | 878 RGBA32 AXLayoutObject::color() const |
| 850 { | 879 { |
| 851 if (!getLayoutObject() || isColorWell()) | 880 if (!getLayoutObject() || isColorWell()) |
| 852 return AXNodeObject::color(); | 881 return AXNodeObject::color(); |
| 853 | 882 |
| 854 const ComputedStyle* style = getLayoutObject()->style(); | 883 const ComputedStyle* style = getLayoutObject()->style(); |
| 855 if (!style) | 884 if (!style) |
| 856 return AXNodeObject::color(); | 885 return AXNodeObject::color(); |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1670 | 1699 |
| 1671 Document* AXLayoutObject::getDocument() const | 1700 Document* AXLayoutObject::getDocument() const |
| 1672 { | 1701 { |
| 1673 if (!getLayoutObject()) | 1702 if (!getLayoutObject()) |
| 1674 return nullptr; | 1703 return nullptr; |
| 1675 return &getLayoutObject()->document(); | 1704 return &getLayoutObject()->document(); |
| 1676 } | 1705 } |
| 1677 | 1706 |
| 1678 FrameView* AXLayoutObject::documentFrameView() const | 1707 FrameView* AXLayoutObject::documentFrameView() const |
| 1679 { | 1708 { |
| 1680 if (!m_layoutObject) | 1709 if (!getLayoutObject()) |
| 1681 return 0; | 1710 return nullptr; |
| 1682 | 1711 |
| 1683 // this is the LayoutObject's Document's LocalFrame's FrameView | 1712 // this is the LayoutObject's Document's LocalFrame's FrameView |
| 1684 return m_layoutObject->document().view(); | 1713 return getLayoutObject()->document().view(); |
| 1685 } | 1714 } |
| 1686 | 1715 |
| 1687 Element* AXLayoutObject::anchorElement() const | 1716 Element* AXLayoutObject::anchorElement() const |
| 1688 { | 1717 { |
| 1689 if (!m_layoutObject) | 1718 if (!m_layoutObject) |
| 1690 return 0; | 1719 return 0; |
| 1691 | 1720 |
| 1692 AXObjectCacheImpl& cache = axObjectCache(); | 1721 AXObjectCacheImpl& cache = axObjectCache(); |
| 1693 LayoutObject* currLayoutObject; | 1722 LayoutObject* currLayoutObject; |
| 1694 | 1723 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2476 if (label && label->layoutObject()) { | 2505 if (label && label->layoutObject()) { |
| 2477 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct(); | 2506 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct(); |
| 2478 result.unite(labelRect); | 2507 result.unite(labelRect); |
| 2479 } | 2508 } |
| 2480 } | 2509 } |
| 2481 | 2510 |
| 2482 return result; | 2511 return result; |
| 2483 } | 2512 } |
| 2484 | 2513 |
| 2485 } // namespace blink | 2514 } // namespace blink |
| OLD | NEW |