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

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

Issue 1501313002: Expose custom property values to getComputedStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 14 matching lines...) Expand all
25 #include "core/css/CSSComputedStyleDeclaration.h" 25 #include "core/css/CSSComputedStyleDeclaration.h"
26 26
27 #include "bindings/core/v8/ExceptionState.h" 27 #include "bindings/core/v8/ExceptionState.h"
28 #include "core/CSSPropertyNames.h" 28 #include "core/CSSPropertyNames.h"
29 #include "core/css/CSSPrimitiveValueMappings.h" 29 #include "core/css/CSSPrimitiveValueMappings.h"
30 #include "core/css/CSSPropertyMetadata.h" 30 #include "core/css/CSSPropertyMetadata.h"
31 #include "core/css/CSSSelector.h" 31 #include "core/css/CSSSelector.h"
32 #include "core/css/CSSValuePool.h" 32 #include "core/css/CSSValuePool.h"
33 #include "core/css/ComputedStyleCSSValueMapping.h" 33 #include "core/css/ComputedStyleCSSValueMapping.h"
34 #include "core/css/parser/CSSParser.h" 34 #include "core/css/parser/CSSParser.h"
35 #include "core/css/parser/CSSVariableParser.h"
35 #include "core/css/resolver/StyleResolver.h" 36 #include "core/css/resolver/StyleResolver.h"
36 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
37 #include "core/dom/ExceptionCode.h" 38 #include "core/dom/ExceptionCode.h"
38 #include "core/dom/PseudoElement.h" 39 #include "core/dom/PseudoElement.h"
39 #include "core/layout/LayoutObject.h" 40 #include "core/layout/LayoutObject.h"
40 #include "core/style/ComputedStyle.h" 41 #include "core/style/ComputedStyle.h"
41 #include "wtf/text/StringBuilder.h" 42 #include "wtf/text/StringBuilder.h"
42 43
43 namespace blink { 44 namespace blink {
44 45
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 { 522 {
522 if (!m_node) 523 if (!m_node)
523 return nullptr; 524 return nullptr;
524 if (m_node->isElementNode()) { 525 if (m_node->isElementNode()) {
525 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl ementSpecifier)) 526 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl ementSpecifier))
526 return element; 527 return element;
527 } 528 }
528 return m_node.get(); 529 return m_node.get();
529 } 530 }
530 531
532 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(AtomicString customPropertyName) const
533 {
534 return ComputedStyleCSSValueMapping::get(customPropertyName, *computeCompute dStyle());
535 }
536
531 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID) const 537 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID) const
532 { 538 {
533 Node* styledNode = this->styledNode(); 539 Node* styledNode = this->styledNode();
534 if (!styledNode) 540 if (!styledNode)
535 return nullptr; 541 return nullptr;
536 LayoutObject* layoutObject = styledNode->layoutObject(); 542 LayoutObject* layoutObject = styledNode->layoutObject();
537 const ComputedStyle* style; 543 const ComputedStyle* style;
538 544
539 Document& document = styledNode->document(); 545 Document& document = styledNode->document();
540 546
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 } 633 }
628 634
629 CSSRule* CSSComputedStyleDeclaration::parentRule() const 635 CSSRule* CSSComputedStyleDeclaration::parentRule() const
630 { 636 {
631 return nullptr; 637 return nullptr;
632 } 638 }
633 639
634 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) 640 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName)
635 { 641 {
636 CSSPropertyID propertyID = cssPropertyID(propertyName); 642 CSSPropertyID propertyID = cssPropertyID(propertyName);
637 if (!propertyID) 643 if (!propertyID) {
638 return String(); 644 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser ::isValidVariableName(propertyName))
645 return String();
646 return getPropertyCSSValue(AtomicString(propertyName))->cssText();
647 }
639 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); 648 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID));
640 return getPropertyValue(propertyID); 649 return getPropertyValue(propertyID);
641 } 650 }
642 651
643 String CSSComputedStyleDeclaration::getPropertyPriority(const String&) 652 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
644 { 653 {
645 // All computed styles have a priority of not "important". 654 // All computed styles have a priority of not "important".
646 return ""; 655 return "";
647 } 656 }
648 657
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + getPropertyNameString(id) + "' property is r ead-only."); 692 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + getPropertyNameString(id) + "' property is r ead-only.");
684 } 693 }
685 694
686 DEFINE_TRACE(CSSComputedStyleDeclaration) 695 DEFINE_TRACE(CSSComputedStyleDeclaration)
687 { 696 {
688 visitor->trace(m_node); 697 visitor->trace(m_node);
689 CSSStyleDeclaration::trace(visitor); 698 CSSStyleDeclaration::trace(visitor);
690 } 699 }
691 700
692 } // namespace blink 701 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698