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

Side by Side Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 2366313006: CSS Properties and Values API: Support non-inherited custom properties (Closed)
Patch Set: use de morgan's law Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * Copyright (C) 2015 Google Inc. All rights reserved. 7 * Copyright (C) 2015 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "core/css/PropertyRegistry.h" 56 #include "core/css/PropertyRegistry.h"
57 #include "core/layout/LayoutBlock.h" 57 #include "core/layout/LayoutBlock.h"
58 #include "core/layout/LayoutBox.h" 58 #include "core/layout/LayoutBox.h"
59 #include "core/layout/LayoutGrid.h" 59 #include "core/layout/LayoutGrid.h"
60 #include "core/layout/LayoutObject.h" 60 #include "core/layout/LayoutObject.h"
61 #include "core/style/ComputedStyle.h" 61 #include "core/style/ComputedStyle.h"
62 #include "core/style/ContentData.h" 62 #include "core/style/ContentData.h"
63 #include "core/style/CursorData.h" 63 #include "core/style/CursorData.h"
64 #include "core/style/QuotesData.h" 64 #include "core/style/QuotesData.h"
65 #include "core/style/ShadowList.h" 65 #include "core/style/ShadowList.h"
66 #include "core/style/StyleVariableData.h" 66 #include "core/style/StyleInheritedVariables.h"
67 #include "core/style/StyleNonInheritedVariables.h"
67 #include "platform/LengthFunctions.h" 68 #include "platform/LengthFunctions.h"
68 69
69 namespace blink { 70 namespace blink {
70 71
71 inline static bool isFlexOrGrid(const ComputedStyle* style) 72 inline static bool isFlexOrGrid(const ComputedStyle* style)
72 { 73 {
73 return style && style->isDisplayFlexibleOrGridBox(); 74 return style && style->isDisplayFlexibleOrGridBox();
74 } 75 }
75 76
76 inline static CSSPrimitiveValue* zoomAdjustedPixelValue(double value, const Comp utedStyle& style) 77 inline static CSSPrimitiveValue* zoomAdjustedPixelValue(double value, const Comp utedStyle& style)
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 return BreakAlways; 1642 return BreakAlways;
1642 case BreakAvoidColumn: 1643 case BreakAvoidColumn:
1643 return BreakAvoid; 1644 return BreakAvoid;
1644 default: 1645 default:
1645 return genericBreakValue; 1646 return genericBreakValue;
1646 } 1647 }
1647 } 1648 }
1648 1649
1649 const CSSValue* ComputedStyleCSSValueMapping::get(const AtomicString customPrope rtyName, const ComputedStyle& style, const PropertyRegistry* registry) 1650 const CSSValue* ComputedStyleCSSValueMapping::get(const AtomicString customPrope rtyName, const ComputedStyle& style, const PropertyRegistry* registry)
1650 { 1651 {
1651 StyleVariableData* variables = style.variables();
1652 if (registry) { 1652 if (registry) {
1653 const PropertyRegistry::Registration* registration = registry->registrat ion(customPropertyName); 1653 const PropertyRegistry::Registration* registration = registry->registrat ion(customPropertyName);
1654 if (registration) { 1654 if (registration) {
1655 if (variables) { 1655 const CSSValue* result = nullptr;
1656 const CSSValue* result = variables->registeredInheritedProperty( customPropertyName); 1656 if (registration->inherits()) {
1657 if (result) 1657 if (StyleInheritedVariables* variables = style.inheritedVariable s())
1658 return result; 1658 result = variables->registeredVariable(customPropertyName);
1659 } else {
1660 if (StyleNonInheritedVariables* variables = style.nonInheritedVa riables())
1661 result = variables->registeredVariable(customPropertyName);
1659 } 1662 }
1663 if (result)
1664 return result;
1660 return registration->initial(); 1665 return registration->initial();
1661 } 1666 }
1662 } 1667 }
1663 1668
1669 StyleInheritedVariables* variables = style.inheritedVariables();
1664 if (!variables) 1670 if (!variables)
1665 return nullptr; 1671 return nullptr;
1666 1672
1667 CSSVariableData* data = variables->getVariable(customPropertyName); 1673 CSSVariableData* data = variables->getVariable(customPropertyName);
1668 if (!data) 1674 if (!data)
1669 return nullptr; 1675 return nullptr;
1670 1676
1671 return CSSCustomPropertyDeclaration::create(customPropertyName, data); 1677 return CSSCustomPropertyDeclaration::create(customPropertyName, data);
1672 } 1678 }
1673 1679
1674 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> ComputedStyleCSS ValueMapping::getVariables(const ComputedStyle& style) 1680 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> ComputedStyleCSS ValueMapping::getVariables(const ComputedStyle& style)
1675 { 1681 {
1676 StyleVariableData* variables = style.variables(); 1682 // TODO(timloh): Also return non-inherited variables
1683 StyleInheritedVariables* variables = style.inheritedVariables();
1677 if (variables) 1684 if (variables)
1678 return variables->getVariables(); 1685 return variables->getVariables();
1679 return nullptr; 1686 return nullptr;
1680 } 1687 }
1681 1688
1682 const CSSValue* ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, cons t ComputedStyle& style, const LayoutObject* layoutObject, Node* styledNode, bool allowVisitedStyle) 1689 const CSSValue* ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, cons t ComputedStyle& style, const LayoutObject* layoutObject, Node* styledNode, bool allowVisitedStyle)
1683 { 1690 {
1684 const SVGComputedStyle& svgStyle = style.svgStyle(); 1691 const SVGComputedStyle& svgStyle = style.svgStyle();
1685 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style.di rection(), style.getWritingMode()); 1692 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style.di rection(), style.getWritingMode());
1686 switch (propertyID) { 1693 switch (propertyID) {
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 case CSSPropertyAll: 3044 case CSSPropertyAll:
3038 return nullptr; 3045 return nullptr;
3039 default: 3046 default:
3040 break; 3047 break;
3041 } 3048 }
3042 ASSERT_NOT_REACHED(); 3049 ASSERT_NOT_REACHED();
3043 return nullptr; 3050 return nullptr;
3044 } 3051 }
3045 3052
3046 } // namespace blink 3053 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698