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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore read-only."); | 403 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore read-only."); |
404 } | 404 } |
405 | 405 |
406 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize) | 406 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize) |
407 { | 407 { |
408 ASSERT_ARG(keywordSize, keywordSize); | 408 ASSERT_ARG(keywordSize, keywordSize); |
409 ASSERT_ARG(keywordSize, keywordSize <= 8); | 409 ASSERT_ARG(keywordSize, keywordSize <= 8); |
410 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); | 410 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); |
411 } | 411 } |
412 | 412 |
413 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(d
ouble value, const ComputedStyle& style) | 413 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value,
const ComputedStyle& style) |
414 { | 414 { |
415 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::UnitType::Pixels); | 415 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::UnitType::Pixels); |
416 } | 416 } |
417 | 417 |
418 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValu
ePreferringKeyword() const | 418 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringK
eyword() const |
419 { | 419 { |
420 if (!m_node) | 420 if (!m_node) |
421 return nullptr; | 421 return nullptr; |
422 | 422 |
423 m_node->document().updateLayoutIgnorePendingStylesheets(); | 423 m_node->document().updateLayoutIgnorePendingStylesheets(); |
424 | 424 |
425 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); | 425 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); |
426 if (!style) | 426 if (!style) |
427 return nullptr; | 427 return nullptr; |
428 | 428 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 { | 528 { |
529 if (!m_node) | 529 if (!m_node) |
530 return 0; | 530 return 0; |
531 if (m_node->isElementNode()) { | 531 if (m_node->isElementNode()) { |
532 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) | 532 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) |
533 return element; | 533 return element; |
534 } | 534 } |
535 return m_node.get(); | 535 return m_node.get(); |
536 } | 536 } |
537 | 537 |
538 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(CSSPropertyID propertyID) const | 538 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
yID propertyID) const |
539 { | 539 { |
540 Node* styledNode = this->styledNode(); | 540 Node* styledNode = this->styledNode(); |
541 if (!styledNode) | 541 if (!styledNode) |
542 return nullptr; | 542 return nullptr; |
543 LayoutObject* layoutObject = styledNode->layoutObject(); | 543 LayoutObject* layoutObject = styledNode->layoutObject(); |
544 const ComputedStyle* style; | 544 const ComputedStyle* style; |
545 | 545 |
546 Document& document = styledNode->document(); | 546 Document& document = styledNode->document(); |
547 | 547 |
548 // A timing update may be required if a compositor animation is running. | 548 // A timing update may be required if a compositor animation is running. |
(...skipping 15 matching lines...) Expand all Loading... |
564 if (forceFullLayout) { | 564 if (forceFullLayout) { |
565 document.updateLayoutIgnorePendingStylesheets(); | 565 document.updateLayoutIgnorePendingStylesheets(); |
566 styledNode = this->styledNode(); | 566 styledNode = this->styledNode(); |
567 style = computeComputedStyle(); | 567 style = computeComputedStyle(); |
568 layoutObject = styledNode->layoutObject(); | 568 layoutObject = styledNode->layoutObject(); |
569 } | 569 } |
570 | 570 |
571 if (!style) | 571 if (!style) |
572 return nullptr; | 572 return nullptr; |
573 | 573 |
574 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(prope
rtyID, *style, layoutObject, styledNode, m_allowVisitedStyle); | 574 RefPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(propertyID, *styl
e, layoutObject, styledNode, m_allowVisitedStyle); |
575 if (value) | 575 if (value) |
576 return value; | 576 return value; |
577 | 577 |
578 logUnimplementedPropertyID(propertyID); | 578 logUnimplementedPropertyID(propertyID); |
579 return nullptr; | 579 return nullptr; |
580 } | 580 } |
581 | 581 |
582 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst | 582 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst |
583 { | 583 { |
584 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 584 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
585 if (value) | 585 if (value) |
586 return value->cssText(); | 586 return value->cssText(); |
587 return ""; | 587 return ""; |
588 } | 588 } |
589 | 589 |
590 | 590 |
591 unsigned CSSComputedStyleDeclaration::length() const | 591 unsigned CSSComputedStyleDeclaration::length() const |
592 { | 592 { |
593 if (!m_node || !m_node->inActiveDocument()) | 593 if (!m_node || !m_node->inActiveDocument()) |
594 return 0; | 594 return 0; |
(...skipping 13 matching lines...) Expand all Loading... |
608 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { | 608 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { |
609 m_node->document().updateLayoutIgnorePendingStylesheets(); | 609 m_node->document().updateLayoutIgnorePendingStylesheets(); |
610 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); | 610 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); |
611 if (style && style->fontDescription().keywordSize()) { | 611 if (style && style->fontDescription().keywordSize()) { |
612 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); | 612 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); |
613 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); | 613 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); |
614 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) | 614 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) |
615 return true; | 615 return true; |
616 } | 616 } |
617 } | 617 } |
618 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 618 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
619 return value && propertyValue && value->equals(*propertyValue); | 619 return value && propertyValue && value->equals(*propertyValue); |
620 } | 620 } |
621 | 621 |
622 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yProperties() const | 622 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yProperties() const |
623 { | 623 { |
624 return copyPropertiesInSet(computableProperties()); | 624 return copyPropertiesInSet(computableProperties()); |
625 } | 625 } |
626 | 626 |
627 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yPropertiesInSet(const Vector<CSSPropertyID>& properties) const | 627 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yPropertiesInSet(const Vector<CSSPropertyID>& properties) const |
628 { | 628 { |
629 WillBeHeapVector<CSSProperty, 256> list; | 629 Vector<CSSProperty, 256> list; |
630 list.reserveInitialCapacity(properties.size()); | 630 list.reserveInitialCapacity(properties.size()); |
631 for (unsigned i = 0; i < properties.size(); ++i) { | 631 for (unsigned i = 0; i < properties.size(); ++i) { |
632 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); | 632 RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]); |
633 if (value) | 633 if (value) |
634 list.append(CSSProperty(properties[i], value.release(), false)); | 634 list.append(CSSProperty(properties[i], value.release(), false)); |
635 } | 635 } |
636 return MutableStylePropertySet::create(list.data(), list.size()); | 636 return MutableStylePropertySet::create(list.data(), list.size()); |
637 } | 637 } |
638 | 638 |
639 CSSRule* CSSComputedStyleDeclaration::parentRule() const | 639 CSSRule* CSSComputedStyleDeclaration::parentRule() const |
640 { | 640 { |
641 return 0; | 641 return 0; |
642 } | 642 } |
(...skipping 27 matching lines...) Expand all Loading... |
670 { | 670 { |
671 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 671 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
672 } | 672 } |
673 | 673 |
674 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) | 674 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) |
675 { | 675 { |
676 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 676 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
677 return String(); | 677 return String(); |
678 } | 678 } |
679 | 679 |
680 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
eInternal(CSSPropertyID propertyID) | 680 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CS
SPropertyID propertyID) |
681 { | 681 { |
682 return getPropertyCSSValue(propertyID); | 682 return getPropertyCSSValue(propertyID); |
683 } | 683 } |
684 | 684 |
685 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) | 685 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) |
686 { | 686 { |
687 return getPropertyValue(propertyID); | 687 return getPropertyValue(propertyID); |
688 } | 688 } |
689 | 689 |
690 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, bool, ExceptionState& exceptionState) | 690 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, bool, ExceptionState& exceptionState) |
691 { | 691 { |
692 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."); |
693 } | 693 } |
694 | 694 |
695 DEFINE_TRACE(CSSComputedStyleDeclaration) | 695 DEFINE_TRACE(CSSComputedStyleDeclaration) |
696 { | 696 { |
697 visitor->trace(m_node); | 697 visitor->trace(m_node); |
698 CSSStyleDeclaration::trace(visitor); | 698 CSSStyleDeclaration::trace(visitor); |
699 } | 699 } |
700 | 700 |
701 } // namespace blink | 701 } // namespace blink |
OLD | NEW |