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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 ASSERT_ARG(keywordSize, keywordSize); | 402 ASSERT_ARG(keywordSize, keywordSize); |
403 ASSERT_ARG(keywordSize, keywordSize <= 8); | 403 ASSERT_ARG(keywordSize, keywordSize <= 8); |
404 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); | 404 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); |
405 } | 405 } |
406 | 406 |
407 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(d
ouble value, const ComputedStyle& style) | 407 inline static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(d
ouble value, const ComputedStyle& style) |
408 { | 408 { |
409 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::CSS_PX); | 409 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style),
CSSPrimitiveValue::CSS_PX); |
410 } | 410 } |
411 | 411 |
412 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValu
ePreferringKeyword() const | 412 NullableCSSValue CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeywo
rd() const |
413 { | 413 { |
414 if (!m_node) | 414 if (!m_node) |
415 return nullptr; | 415 return nullptr; |
416 | 416 |
417 m_node->document().updateLayoutIgnorePendingStylesheets(); | 417 m_node->document().updateLayoutIgnorePendingStylesheets(); |
418 | 418 |
419 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); | 419 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec
ifier); |
420 if (!style) | 420 if (!style) |
421 return nullptr; | 421 return nullptr; |
422 | 422 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 { | 519 { |
520 if (!m_node) | 520 if (!m_node) |
521 return 0; | 521 return 0; |
522 if (m_node->isElementNode()) { | 522 if (m_node->isElementNode()) { |
523 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) | 523 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) |
524 return element; | 524 return element; |
525 } | 525 } |
526 return m_node.get(); | 526 return m_node.get(); |
527 } | 527 } |
528 | 528 |
529 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(CSSPropertyID propertyID) const | 529 NullableCSSValue CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID
propertyID) const |
530 { | 530 { |
531 Node* styledNode = this->styledNode(); | 531 Node* styledNode = this->styledNode(); |
532 if (!styledNode) | 532 if (!styledNode) |
533 return nullptr; | 533 return nullptr; |
534 LayoutObject* layoutObject = styledNode->layoutObject(); | 534 LayoutObject* layoutObject = styledNode->layoutObject(); |
535 const ComputedStyle* style; | 535 const ComputedStyle* style; |
536 | 536 |
537 Document& document = styledNode->document(); | 537 Document& document = styledNode->document(); |
538 | 538 |
539 // A timing update may be required if a compositor animation is running. | 539 // A timing update may be required if a compositor animation is running. |
(...skipping 15 matching lines...) Expand all Loading... |
555 if (forceFullLayout) { | 555 if (forceFullLayout) { |
556 document.updateLayoutIgnorePendingStylesheets(); | 556 document.updateLayoutIgnorePendingStylesheets(); |
557 styledNode = this->styledNode(); | 557 styledNode = this->styledNode(); |
558 style = computeComputedStyle(); | 558 style = computeComputedStyle(); |
559 layoutObject = styledNode->layoutObject(); | 559 layoutObject = styledNode->layoutObject(); |
560 } | 560 } |
561 | 561 |
562 if (!style) | 562 if (!style) |
563 return nullptr; | 563 return nullptr; |
564 | 564 |
565 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(prope
rtyID, *style, layoutObject, styledNode, m_allowVisitedStyle); | 565 NullableCSSValue value = ComputedStyleCSSValueMapping::get(propertyID, *styl
e, layoutObject, styledNode, m_allowVisitedStyle); |
566 if (value) | 566 if (value) |
567 return value; | 567 return *value; |
568 | 568 |
569 logUnimplementedPropertyID(propertyID); | 569 logUnimplementedPropertyID(propertyID); |
570 return nullptr; | 570 return nullptr; |
571 } | 571 } |
572 | 572 |
573 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst | 573 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c
onst |
574 { | 574 { |
575 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 575 NullableCSSValue value = getPropertyCSSValue(propertyID); |
576 if (value) | 576 if (value) |
577 return value->cssText(); | 577 return value->cssText(); |
578 return ""; | 578 return ""; |
579 } | 579 } |
580 | 580 |
581 | 581 |
582 unsigned CSSComputedStyleDeclaration::length() const | 582 unsigned CSSComputedStyleDeclaration::length() const |
583 { | 583 { |
584 if (!m_node || !m_node->inActiveDocument()) | 584 if (!m_node || !m_node->inActiveDocument()) |
585 return 0; | 585 return 0; |
586 return computableProperties().size(); | 586 return computableProperties().size(); |
587 } | 587 } |
588 | 588 |
589 String CSSComputedStyleDeclaration::item(unsigned i) const | 589 String CSSComputedStyleDeclaration::item(unsigned i) const |
590 { | 590 { |
591 if (i >= length()) | 591 if (i >= length()) |
592 return ""; | 592 return ""; |
593 | 593 |
594 return getPropertyNameString(computableProperties()[i]); | 594 return getPropertyNameString(computableProperties()[i]); |
595 } | 595 } |
596 | 596 |
597 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, c
onst CSSValue* propertyValue) const | 597 bool CSSComputedStyleDeclaration::cssPropertyMatches(CSSPropertyID propertyID, c
onst CSSValue propertyValue) const |
598 { | 598 { |
599 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() &
& m_node) { | 599 if (propertyID == CSSPropertyFontSize && propertyValue.isPrimitiveValue() &&
m_node) { |
600 m_node->document().updateLayoutIgnorePendingStylesheets(); | 600 m_node->document().updateLayoutIgnorePendingStylesheets(); |
601 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); | 601 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement
Specifier); |
602 if (style && style->fontDescription().keywordSize()) { | 602 if (style && style->fontDescription().keywordSize()) { |
603 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); | 603 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->fontDe
scription().keywordSize()); |
604 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper
tyValue); | 604 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(proper
tyValue); |
605 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s
izeValue) | 605 if (primitiveValue.isValueID() && primitiveValue.getValueID() == siz
eValue) |
606 return true; | 606 return true; |
607 } | 607 } |
608 } | 608 } |
609 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 609 NullableCSSValue value = getPropertyCSSValue(propertyID); |
610 return value && propertyValue && value->equals(*propertyValue); | 610 return value && value->equals(propertyValue); |
611 } | 611 } |
612 | 612 |
613 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yProperties() const | 613 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yProperties() const |
614 { | 614 { |
615 return copyPropertiesInSet(computableProperties()); | 615 return copyPropertiesInSet(computableProperties()); |
616 } | 616 } |
617 | 617 |
618 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yPropertiesInSet(const Vector<CSSPropertyID>& properties) const | 618 PassRefPtrWillBeRawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::cop
yPropertiesInSet(const Vector<CSSPropertyID>& properties) const |
619 { | 619 { |
620 WillBeHeapVector<CSSProperty, 256> list; | 620 WillBeHeapVector<CSSProperty, 256> list; |
621 list.reserveInitialCapacity(properties.size()); | 621 list.reserveInitialCapacity(properties.size()); |
622 for (unsigned i = 0; i < properties.size(); ++i) { | 622 for (unsigned i = 0; i < properties.size(); ++i) { |
623 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); | 623 NullableCSSValue value = getPropertyCSSValue(properties[i]); |
624 if (value) | 624 if (value) |
625 list.append(CSSProperty(properties[i], value.release(), false)); | 625 list.append(CSSProperty(properties[i], *value, false)); |
626 } | 626 } |
627 return MutableStylePropertySet::create(list.data(), list.size()); | 627 return MutableStylePropertySet::create(list.data(), list.size()); |
628 } | 628 } |
629 | 629 |
630 CSSRule* CSSComputedStyleDeclaration::parentRule() const | 630 CSSRule* CSSComputedStyleDeclaration::parentRule() const |
631 { | 631 { |
632 return 0; | 632 return 0; |
633 } | 633 } |
634 | 634 |
635 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) | 635 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) |
(...skipping 25 matching lines...) Expand all Loading... |
661 { | 661 { |
662 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 662 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
663 } | 663 } |
664 | 664 |
665 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) | 665 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception
State& exceptionState) |
666 { | 666 { |
667 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); | 667 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + name + "' property is read-only."); |
668 return String(); | 668 return String(); |
669 } | 669 } |
670 | 670 |
671 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
eInternal(CSSPropertyID propertyID) | 671 NullableCSSValue CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPro
pertyID propertyID) |
672 { | 672 { |
673 return getPropertyCSSValue(propertyID); | 673 return getPropertyCSSValue(propertyID); |
674 } | 674 } |
675 | 675 |
676 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) | 676 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
rtyID) |
677 { | 677 { |
678 return getPropertyValue(propertyID); | 678 return getPropertyValue(propertyID); |
679 } | 679 } |
680 | 680 |
681 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, bool, ExceptionState& exceptionState) | 681 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St
ring&, bool, ExceptionState& exceptionState) |
682 { | 682 { |
683 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + getPropertyNameString(id) + "' property is r
ead-only."); | 683 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a
re computed, and therefore the '" + getPropertyNameString(id) + "' property is r
ead-only."); |
684 } | 684 } |
685 | 685 |
686 DEFINE_TRACE(CSSComputedStyleDeclaration) | 686 DEFINE_TRACE(CSSComputedStyleDeclaration) |
687 { | 687 { |
688 visitor->trace(m_node); | 688 visitor->trace(m_node); |
689 CSSStyleDeclaration::trace(visitor); | 689 CSSStyleDeclaration::trace(visitor); |
690 } | 690 } |
691 | 691 |
692 } // namespace blink | 692 } // namespace blink |
OLD | NEW |