| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 }; | 345 }; |
| 346 | 346 |
| 347 static const Vector<CSSPropertyID>& computableProperties() | 347 static const Vector<CSSPropertyID>& computableProperties() |
| 348 { | 348 { |
| 349 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); | 349 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
| 350 if (properties.isEmpty()) | 350 if (properties.isEmpty()) |
| 351 CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticComputab
leProperties, WTF_ARRAY_LENGTH(staticComputableProperties), properties); | 351 CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticComputab
leProperties, WTF_ARRAY_LENGTH(staticComputableProperties), properties); |
| 352 return properties; | 352 return properties; |
| 353 } | 353 } |
| 354 | 354 |
| 355 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtrWillBeRawPtr<
Node> n, bool allowVisitedStyle, const String& pseudoElementName) | 355 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(RawPtr<Node> n, bool al
lowVisitedStyle, const String& pseudoElementName) |
| 356 : m_node(n) | 356 : m_node(n) |
| 357 , m_allowVisitedStyle(allowVisitedStyle) | 357 , m_allowVisitedStyle(allowVisitedStyle) |
| 358 #if !ENABLE(OILPAN) | 358 #if !ENABLE(OILPAN) |
| 359 , m_refCount(1) | 359 , m_refCount(1) |
| 360 #endif | 360 #endif |
| 361 { | 361 { |
| 362 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoEleme
ntName[1] == ':' ? 2 : 1) : 0; | 362 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoEleme
ntName[1] == ':' ? 2 : 1) : 0; |
| 363 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoTyp
e( | 363 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoTyp
e( |
| 364 AtomicString(pseudoElementName.substring(nameWithoutColonsStart)), false
)); | 364 AtomicString(pseudoElementName.substring(nameWithoutColonsStart)), false
)); |
| 365 } | 365 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore read-only."); | 404 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore read-only."); |
| 405 } | 405 } |
| 406 | 406 |
| 407 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize) | 407 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize) |
| 408 { | 408 { |
| 409 ASSERT_ARG(keywordSize, keywordSize); | 409 ASSERT_ARG(keywordSize, keywordSize); |
| 410 ASSERT_ARG(keywordSize, keywordSize <= 8); | 410 ASSERT_ARG(keywordSize, keywordSize <= 8); |
| 411 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); | 411 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); |
| 412 } | 412 } |
| 413 | 413 |
| 414 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(d
ouble value, const ComputedStyle& style) | 414 inline static RawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, con
st ComputedStyle& style) |
| 415 { | 415 { |
| 416 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::UnitType::Pixels); | 416 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::UnitType::Pixels); |
| 417 } | 417 } |
| 418 | 418 |
| 419 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValu
ePreferringKeyword() const | 419 RawPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeywo
rd() const |
| 420 { | 420 { |
| 421 if (!m_node) | 421 if (!m_node) |
| 422 return nullptr; | 422 return nullptr; |
| 423 | 423 |
| 424 m_node->document().updateLayoutIgnorePendingStylesheets(); | 424 m_node->document().updateLayoutIgnorePendingStylesheets(); |
| 425 | 425 |
| 426 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); | 426 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); |
| 427 if (!style) | 427 if (!style) |
| 428 return nullptr; | 428 return nullptr; |
| 429 | 429 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 { | 522 { |
| 523 if (!m_node) | 523 if (!m_node) |
| 524 return nullptr; | 524 return nullptr; |
| 525 if (m_node->isElementNode()) { | 525 if (m_node->isElementNode()) { |
| 526 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) | 526 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) |
| 527 return element; | 527 return element; |
| 528 } | 528 } |
| 529 return m_node.get(); | 529 return m_node.get(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(AtomicString customPropertyName) const | 532 RawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString c
ustomPropertyName) const |
| 533 { | 533 { |
| 534 const ComputedStyle* style = computeComputedStyle(); | 534 const ComputedStyle* style = computeComputedStyle(); |
| 535 if (!style) | 535 if (!style) |
| 536 return nullptr; | 536 return nullptr; |
| 537 return ComputedStyleCSSValueMapping::get(customPropertyName, *style); | 537 return ComputedStyleCSSValueMapping::get(customPropertyName, *style); |
| 538 } | 538 } |
| 539 | 539 |
| 540 const HashMap<AtomicString, RefPtr<CSSVariableData>>* CSSComputedStyleDeclaratio
n::getVariables() const | 540 const HashMap<AtomicString, RefPtr<CSSVariableData>>* CSSComputedStyleDeclaratio
n::getVariables() const |
| 541 { | 541 { |
| 542 const ComputedStyle* style = computeComputedStyle(); | 542 const ComputedStyle* style = computeComputedStyle(); |
| 543 if (!style) | 543 if (!style) |
| 544 return nullptr; | 544 return nullptr; |
| 545 return ComputedStyleCSSValueMapping::getVariables(*style); | 545 return ComputedStyleCSSValueMapping::getVariables(*style); |
| 546 } | 546 } |
| 547 | 547 |
| 548 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(CSSPropertyID propertyID) const | 548 RawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID
propertyID) const |
| 549 { | 549 { |
| 550 Node* styledNode = this->styledNode(); | 550 Node* styledNode = this->styledNode(); |
| 551 if (!styledNode) | 551 if (!styledNode) |
| 552 return nullptr; | 552 return nullptr; |
| 553 LayoutObject* layoutObject = styledNode->layoutObject(); | 553 LayoutObject* layoutObject = styledNode->layoutObject(); |
| 554 const ComputedStyle* style; | 554 const ComputedStyle* style; |
| 555 | 555 |
| 556 Document& document = styledNode->document(); | 556 Document& document = styledNode->document(); |
| 557 | 557 |
| 558 document.updateLayoutTreeForNodeIfNeeded(styledNode); | 558 document.updateLayoutTreeForNodeIfNeeded(styledNode); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 571 if (forceFullLayout) { | 571 if (forceFullLayout) { |
| 572 document.updateLayoutIgnorePendingStylesheets(); | 572 document.updateLayoutIgnorePendingStylesheets(); |
| 573 styledNode = this->styledNode(); | 573 styledNode = this->styledNode(); |
| 574 style = computeComputedStyle(); | 574 style = computeComputedStyle(); |
| 575 layoutObject = styledNode->layoutObject(); | 575 layoutObject = styledNode->layoutObject(); |
| 576 } | 576 } |
| 577 | 577 |
| 578 if (!style) | 578 if (!style) |
| 579 return nullptr; | 579 return nullptr; |
| 580 | 580 |
| 581 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(prope
rtyID, *style, layoutObject, styledNode, m_allowVisitedStyle); | 581 RawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(propertyID, *styl
e, layoutObject, styledNode, m_allowVisitedStyle); |
| 582 if (value) | 582 if (value) |
| 583 return value; | 583 return value; |
| 584 | 584 |
| 585 logUnimplementedPropertyID(propertyID); | 585 logUnimplementedPropertyID(propertyID); |
| 586 return nullptr; | 586 return nullptr; |
| 587 } | 587 } |
| 588 | 588 |
| 589 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst | 589 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst |
| 590 { | 590 { |
| 591 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 591 RawPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
| 592 if (value) | 592 if (value) |
| 593 return value->cssText(); | 593 return value->cssText(); |
| 594 return ""; | 594 return ""; |
| 595 } | 595 } |
| 596 | 596 |
| 597 | 597 |
| 598 unsigned CSSComputedStyleDeclaration::length() const | 598 unsigned CSSComputedStyleDeclaration::length() const |
| 599 { | 599 { |
| 600 if (!m_node || !m_node->inActiveDocument()) | 600 if (!m_node || !m_node->inActiveDocument()) |
| 601 return 0; | 601 return 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 615 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { | 615 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { |
| 616 m_node->document().updateLayoutIgnorePendingStylesheets(); | 616 m_node->document().updateLayoutIgnorePendingStylesheets(); |
| 617 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); | 617 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); |
| 618 if (style && style->fontDescription().keywordSize()) { | 618 if (style && style->fontDescription().keywordSize()) { |
| 619 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); | 619 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); |
| 620 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); | 620 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); |
| 621 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) | 621 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) |
| 622 return true; | 622 return true; |
| 623 } | 623 } |
| 624 } | 624 } |
| 625 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 625 RawPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
| 626 return value && propertyValue && value->equals(*propertyValue); | 626 return value && propertyValue && value->equals(*propertyValue); |
| 627 } | 627 } |
| 628 | 628 |
| 629 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yProperties() const | 629 RawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyProperties() co
nst |
| 630 { | 630 { |
| 631 return copyPropertiesInSet(computableProperties()); | 631 return copyPropertiesInSet(computableProperties()); |
| 632 } | 632 } |
| 633 | 633 |
| 634 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yPropertiesInSet(const Vector<CSSPropertyID>& properties) const | 634 RawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet
(const Vector<CSSPropertyID>& properties) const |
| 635 { | 635 { |
| 636 WillBeHeapVector<CSSProperty, 256> list; | 636 HeapVector<CSSProperty, 256> list; |
| 637 list.reserveInitialCapacity(properties.size()); | 637 list.reserveInitialCapacity(properties.size()); |
| 638 for (unsigned i = 0; i < properties.size(); ++i) { | 638 for (unsigned i = 0; i < properties.size(); ++i) { |
| 639 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); | 639 RawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); |
| 640 if (value) | 640 if (value) |
| 641 list.append(CSSProperty(properties[i], value.release(), false)); | 641 list.append(CSSProperty(properties[i], value.release(), false)); |
| 642 } | 642 } |
| 643 return MutableStylePropertySet::create(list.data(), list.size()); | 643 return MutableStylePropertySet::create(list.data(), list.size()); |
| 644 } | 644 } |
| 645 | 645 |
| 646 CSSRule* CSSComputedStyleDeclaration::parentRule() const | 646 CSSRule* CSSComputedStyleDeclaration::parentRule() const |
| 647 { | 647 { |
| 648 return nullptr; | 648 return nullptr; |
| 649 } | 649 } |
| 650 | 650 |
| 651 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) | 651 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) |
| 652 { | 652 { |
| 653 CSSPropertyID propertyID = cssPropertyID(propertyName); | 653 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 654 if (!propertyID) { | 654 if (!propertyID) { |
| 655 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::
isValidVariableName(propertyName)) { | 655 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::
isValidVariableName(propertyName)) { |
| 656 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(AtomicStrin
g(propertyName)); | 656 RawPtr<CSSValue> value = getPropertyCSSValue(AtomicString(propertyNa
me)); |
| 657 if (value) | 657 if (value) |
| 658 return value->cssText(); | 658 return value->cssText(); |
| 659 } | 659 } |
| 660 return String(); | 660 return String(); |
| 661 } | 661 } |
| 662 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); | 662 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); |
| 663 return getPropertyValue(propertyID); | 663 return getPropertyValue(propertyID); |
| 664 } | 664 } |
| 665 | 665 |
| 666 String CSSComputedStyleDeclaration::getPropertyPriority(const String&) | 666 String CSSComputedStyleDeclaration::getPropertyPriority(const String&) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 683 { | 683 { |
| 684 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 684 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
| 685 } | 685 } |
| 686 | 686 |
| 687 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) | 687 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) |
| 688 { | 688 { |
| 689 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 689 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
| 690 return String(); | 690 return String(); |
| 691 } | 691 } |
| 692 | 692 |
| 693 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
eInternal(CSSPropertyID propertyID) | 693 RawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPro
pertyID propertyID) |
| 694 { | 694 { |
| 695 return getPropertyCSSValue(propertyID); | 695 return getPropertyCSSValue(propertyID); |
| 696 } | 696 } |
| 697 | 697 |
| 698 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) | 698 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) |
| 699 { | 699 { |
| 700 return getPropertyValue(propertyID); | 700 return getPropertyValue(propertyID); |
| 701 } | 701 } |
| 702 | 702 |
| 703 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, const String&, bool, ExceptionState& exceptionState) | 703 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, const String&, bool, ExceptionState& exceptionState) |
| 704 { | 704 { |
| 705 // TODO(leviw): This code is currently unreachable, but shouldn't be. | 705 // TODO(leviw): This code is currently unreachable, but shouldn't be. |
| 706 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + getPropertyNameString(id) + "' property is r
ead-only."); | 706 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + getPropertyNameString(id) + "' property is r
ead-only."); |
| 707 } | 707 } |
| 708 | 708 |
| 709 DEFINE_TRACE(CSSComputedStyleDeclaration) | 709 DEFINE_TRACE(CSSComputedStyleDeclaration) |
| 710 { | 710 { |
| 711 visitor->trace(m_node); | 711 visitor->trace(m_node); |
| 712 CSSStyleDeclaration::trace(visitor); | 712 CSSStyleDeclaration::trace(visitor); |
| 713 } | 713 } |
| 714 | 714 |
| 715 } // namespace blink | 715 } // namespace blink |
| OLD | NEW |