| OLD | NEW |
| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 DCHECK_NE(keywordSize, 0); | 394 DCHECK_NE(keywordSize, 0); |
| 395 DCHECK_LE(keywordSize, 8); | 395 DCHECK_LE(keywordSize, 8); |
| 396 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); | 396 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); |
| 397 } | 397 } |
| 398 | 398 |
| 399 inline static CSSPrimitiveValue* zoomAdjustedPixelValue(double value, const Comp
utedStyle& style) | 399 inline static CSSPrimitiveValue* zoomAdjustedPixelValue(double value, const Comp
utedStyle& style) |
| 400 { | 400 { |
| 401 return CSSPrimitiveValue::create(adjustFloatForAbsoluteZoom(value, style), C
SSPrimitiveValue::UnitType::Pixels); | 401 return CSSPrimitiveValue::create(adjustFloatForAbsoluteZoom(value, style), C
SSPrimitiveValue::UnitType::Pixels); |
| 402 } | 402 } |
| 403 | 403 |
| 404 const CSSValue* CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeywor
d() const | 404 CSSValue* CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() co
nst |
| 405 { | 405 { |
| 406 if (!m_node) | 406 if (!m_node) |
| 407 return nullptr; | 407 return nullptr; |
| 408 | 408 |
| 409 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 409 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 410 | 410 |
| 411 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); | 411 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); |
| 412 if (!style) | 412 if (!style) |
| 413 return nullptr; | 413 return nullptr; |
| 414 | 414 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 { | 507 { |
| 508 if (!m_node) | 508 if (!m_node) |
| 509 return nullptr; | 509 return nullptr; |
| 510 if (m_node->isElementNode()) { | 510 if (m_node->isElementNode()) { |
| 511 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) | 511 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) |
| 512 return element; | 512 return element; |
| 513 } | 513 } |
| 514 return m_node.get(); | 514 return m_node.get(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 const CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString cu
stomPropertyName) const | 517 CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString customPr
opertyName) const |
| 518 { | 518 { |
| 519 Node* styledNode = this->styledNode(); | 519 Node* styledNode = this->styledNode(); |
| 520 if (!styledNode) | 520 if (!styledNode) |
| 521 return nullptr; | 521 return nullptr; |
| 522 | 522 |
| 523 styledNode->document().updateStyleAndLayoutTreeForNode(styledNode); | 523 styledNode->document().updateStyleAndLayoutTreeForNode(styledNode); |
| 524 | 524 |
| 525 const ComputedStyle* style = computeComputedStyle(); | 525 const ComputedStyle* style = computeComputedStyle(); |
| 526 if (!style) | 526 if (!style) |
| 527 return nullptr; | 527 return nullptr; |
| 528 return ComputedStyleCSSValueMapping::get(customPropertyName, *style); | 528 return ComputedStyleCSSValueMapping::get(customPropertyName, *style); |
| 529 } | 529 } |
| 530 | 530 |
| 531 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> CSSComputedStyle
Declaration::getVariables() const | 531 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> CSSComputedStyle
Declaration::getVariables() const |
| 532 { | 532 { |
| 533 const ComputedStyle* style = computeComputedStyle(); | 533 const ComputedStyle* style = computeComputedStyle(); |
| 534 if (!style) | 534 if (!style) |
| 535 return nullptr; | 535 return nullptr; |
| 536 return ComputedStyleCSSValueMapping::getVariables(*style); | 536 return ComputedStyleCSSValueMapping::getVariables(*style); |
| 537 } | 537 } |
| 538 | 538 |
| 539 const CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID p
ropertyID) const | 539 CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propert
yID) const |
| 540 { | 540 { |
| 541 Node* styledNode = this->styledNode(); | 541 Node* styledNode = this->styledNode(); |
| 542 if (!styledNode) | 542 if (!styledNode) |
| 543 return nullptr; | 543 return nullptr; |
| 544 | 544 |
| 545 Document& document = styledNode->document(); | 545 Document& document = styledNode->document(); |
| 546 document.updateStyleAndLayoutTreeForNode(styledNode); | 546 document.updateStyleAndLayoutTreeForNode(styledNode); |
| 547 | 547 |
| 548 // The style recalc could have caused the styled node to be discarded or rep
laced | 548 // The style recalc could have caused the styled node to be discarded or rep
laced |
| 549 // if it was a PseudoElement so we need to update it. | 549 // if it was a PseudoElement so we need to update it. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 569 CSSValue* value = ComputedStyleCSSValueMapping::get(propertyID, *style, layo
utObject, styledNode, m_allowVisitedStyle); | 569 CSSValue* value = ComputedStyleCSSValueMapping::get(propertyID, *style, layo
utObject, styledNode, m_allowVisitedStyle); |
| 570 if (value) | 570 if (value) |
| 571 return value; | 571 return value; |
| 572 | 572 |
| 573 logUnimplementedPropertyID(propertyID); | 573 logUnimplementedPropertyID(propertyID); |
| 574 return nullptr; | 574 return nullptr; |
| 575 } | 575 } |
| 576 | 576 |
| 577 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst | 577 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst |
| 578 { | 578 { |
| 579 const CSSValue* value = getPropertyCSSValue(propertyID); | 579 CSSValue* value = getPropertyCSSValue(propertyID); |
| 580 if (value) | 580 if (value) |
| 581 return value->cssText(); | 581 return value->cssText(); |
| 582 return ""; | 582 return ""; |
| 583 } | 583 } |
| 584 | 584 |
| 585 | 585 |
| 586 unsigned CSSComputedStyleDeclaration::length() const | 586 unsigned CSSComputedStyleDeclaration::length() const |
| 587 { | 587 { |
| 588 if (!m_node || !m_node->inActiveDocument()) | 588 if (!m_node || !m_node->inActiveDocument()) |
| 589 return 0; | 589 return 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 603 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { | 603 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { |
| 604 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 604 m_node->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 605 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); | 605 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); |
| 606 if (style && style->getFontDescription().keywordSize()) { | 606 if (style && style->getFontDescription().keywordSize()) { |
| 607 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->getFon
tDescription().keywordSize()); | 607 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->getFon
tDescription().keywordSize()); |
| 608 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); | 608 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); |
| 609 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) | 609 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) |
| 610 return true; | 610 return true; |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 const CSSValue* value = getPropertyCSSValue(propertyID); | 613 CSSValue* value = getPropertyCSSValue(propertyID); |
| 614 return value && propertyValue && value->equals(*propertyValue); | 614 return value && propertyValue && value->equals(*propertyValue); |
| 615 } | 615 } |
| 616 | 616 |
| 617 MutableStylePropertySet* CSSComputedStyleDeclaration::copyProperties() const | 617 MutableStylePropertySet* CSSComputedStyleDeclaration::copyProperties() const |
| 618 { | 618 { |
| 619 return copyPropertiesInSet(computableProperties()); | 619 return copyPropertiesInSet(computableProperties()); |
| 620 } | 620 } |
| 621 | 621 |
| 622 MutableStylePropertySet* CSSComputedStyleDeclaration::copyPropertiesInSet(const
Vector<CSSPropertyID>& properties) const | 622 MutableStylePropertySet* CSSComputedStyleDeclaration::copyPropertiesInSet(const
Vector<CSSPropertyID>& properties) const |
| 623 { | 623 { |
| 624 HeapVector<CSSProperty, 256> list; | 624 HeapVector<CSSProperty, 256> list; |
| 625 list.reserveInitialCapacity(properties.size()); | 625 list.reserveInitialCapacity(properties.size()); |
| 626 for (unsigned i = 0; i < properties.size(); ++i) { | 626 for (unsigned i = 0; i < properties.size(); ++i) { |
| 627 const CSSValue* value = getPropertyCSSValue(properties[i]); | 627 CSSValue* value = getPropertyCSSValue(properties[i]); |
| 628 if (value) | 628 if (value) |
| 629 list.append(CSSProperty(properties[i], value, false)); | 629 list.append(CSSProperty(properties[i], value, false)); |
| 630 } | 630 } |
| 631 return MutableStylePropertySet::create(list.data(), list.size()); | 631 return MutableStylePropertySet::create(list.data(), list.size()); |
| 632 } | 632 } |
| 633 | 633 |
| 634 CSSRule* CSSComputedStyleDeclaration::parentRule() const | 634 CSSRule* CSSComputedStyleDeclaration::parentRule() const |
| 635 { | 635 { |
| 636 return nullptr; | 636 return nullptr; |
| 637 } | 637 } |
| 638 | 638 |
| 639 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) | 639 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) |
| 640 { | 640 { |
| 641 CSSPropertyID propertyID = cssPropertyID(propertyName); | 641 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 642 if (!propertyID) { | 642 if (!propertyID) { |
| 643 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::
isValidVariableName(propertyName)) { | 643 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::
isValidVariableName(propertyName)) { |
| 644 const CSSValue* value = getPropertyCSSValue(AtomicString(propertyNam
e)); | 644 CSSValue* value = getPropertyCSSValue(AtomicString(propertyName)); |
| 645 if (value) | 645 if (value) |
| 646 return value->cssText(); | 646 return value->cssText(); |
| 647 } | 647 } |
| 648 return String(); | 648 return String(); |
| 649 } | 649 } |
| 650 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); | 650 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); |
| 651 return getPropertyValue(propertyID); | 651 return getPropertyValue(propertyID); |
| 652 } | 652 } |
| 653 | 653 |
| 654 String CSSComputedStyleDeclaration::getPropertyPriority(const String&) | 654 String CSSComputedStyleDeclaration::getPropertyPriority(const String&) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 671 { | 671 { |
| 672 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 672 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
| 673 } | 673 } |
| 674 | 674 |
| 675 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) | 675 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) |
| 676 { | 676 { |
| 677 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 677 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
| 678 return String(); | 678 return String(); |
| 679 } | 679 } |
| 680 | 680 |
| 681 const CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSProp
ertyID propertyID) | 681 CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID
propertyID) |
| 682 { | 682 { |
| 683 return getPropertyCSSValue(propertyID); | 683 return getPropertyCSSValue(propertyID); |
| 684 } | 684 } |
| 685 | 685 |
| 686 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) | 686 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) |
| 687 { | 687 { |
| 688 return getPropertyValue(propertyID); | 688 return getPropertyValue(propertyID); |
| 689 } | 689 } |
| 690 | 690 |
| 691 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, const String&, bool, ExceptionState& exceptionState) | 691 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, const String&, bool, ExceptionState& exceptionState) |
| 692 { | 692 { |
| 693 // TODO(leviw): This code is currently unreachable, but shouldn't be. | 693 // TODO(leviw): This code is currently unreachable, but shouldn't be. |
| 694 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + getPropertyNameString(id) + "' property is r
ead-only."); | 694 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + getPropertyNameString(id) + "' property is r
ead-only."); |
| 695 } | 695 } |
| 696 | 696 |
| 697 DEFINE_TRACE(CSSComputedStyleDeclaration) | 697 DEFINE_TRACE(CSSComputedStyleDeclaration) |
| 698 { | 698 { |
| 699 visitor->trace(m_node); | 699 visitor->trace(m_node); |
| 700 CSSStyleDeclaration::trace(visitor); | 700 CSSStyleDeclaration::trace(visitor); |
| 701 } | 701 } |
| 702 | 702 |
| 703 } // namespace blink | 703 } // namespace blink |
| OLD | NEW |