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

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

Issue 1858753003: Remove RawPtr from core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 }; 342 };
343 343
344 static const Vector<CSSPropertyID>& computableProperties() 344 static const Vector<CSSPropertyID>& computableProperties()
345 { 345 {
346 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); 346 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
347 if (properties.isEmpty()) 347 if (properties.isEmpty())
348 CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticComputab leProperties, WTF_ARRAY_LENGTH(staticComputableProperties), properties); 348 CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticComputab leProperties, WTF_ARRAY_LENGTH(staticComputableProperties), properties);
349 return properties; 349 return properties;
350 } 350 }
351 351
352 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(RawPtr<Node> n, bool al lowVisitedStyle, const String& pseudoElementName) 352 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(Node* n, bool allowVisi tedStyle, const String& pseudoElementName)
353 : m_node(n) 353 : m_node(n)
354 , m_allowVisitedStyle(allowVisitedStyle) 354 , m_allowVisitedStyle(allowVisitedStyle)
355 #if !ENABLE(OILPAN) 355 #if !ENABLE(OILPAN)
356 , m_refCount(1) 356 , m_refCount(1)
357 #endif 357 #endif
358 { 358 {
359 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoEleme ntName[1] == ':' ? 2 : 1) : 0; 359 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoEleme ntName[1] == ':' ? 2 : 1) : 0;
360 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoTyp e( 360 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoTyp e(
361 AtomicString(pseudoElementName.substring(nameWithoutColonsStart)), false )); 361 AtomicString(pseudoElementName.substring(nameWithoutColonsStart)), false ));
362 } 362 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore read-only."); 401 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore read-only.");
402 } 402 }
403 403
404 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize) 404 static CSSValueID cssIdentifierForFontSizeKeyword(int keywordSize)
405 { 405 {
406 DCHECK_NE(keywordSize, 0); 406 DCHECK_NE(keywordSize, 0);
407 DCHECK_LE(keywordSize, 8); 407 DCHECK_LE(keywordSize, 8);
408 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1); 408 return static_cast<CSSValueID>(CSSValueXxSmall + keywordSize - 1);
409 } 409 }
410 410
411 inline static RawPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, con st ComputedStyle& style) 411 inline static CSSPrimitiveValue* zoomAdjustedPixelValue(double value, const Comp utedStyle& style)
412 { 412 {
413 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::UnitType::Pixels); 413 return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::UnitType::Pixels);
414 } 414 }
415 415
416 RawPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeywo rd() const 416 CSSValue* CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() co nst
417 { 417 {
418 if (!m_node) 418 if (!m_node)
419 return nullptr; 419 return nullptr;
420 420
421 m_node->document().updateLayoutIgnorePendingStylesheets(); 421 m_node->document().updateLayoutIgnorePendingStylesheets();
422 422
423 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec ifier); 423 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElementSpec ifier);
424 if (!style) 424 if (!style)
425 return nullptr; 425 return nullptr;
426 426
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 { 519 {
520 if (!m_node) 520 if (!m_node)
521 return nullptr; 521 return nullptr;
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 RawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString c ustomPropertyName) const 529 CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString customPr opertyName) const
530 { 530 {
531 const ComputedStyle* style = computeComputedStyle(); 531 const ComputedStyle* style = computeComputedStyle();
532 if (!style) 532 if (!style)
533 return nullptr; 533 return nullptr;
534 return ComputedStyleCSSValueMapping::get(customPropertyName, *style); 534 return ComputedStyleCSSValueMapping::get(customPropertyName, *style);
535 } 535 }
536 536
537 const HashMap<AtomicString, RefPtr<CSSVariableData>>* CSSComputedStyleDeclaratio n::getVariables() const 537 const HashMap<AtomicString, RefPtr<CSSVariableData>>* CSSComputedStyleDeclaratio n::getVariables() const
538 { 538 {
539 const ComputedStyle* style = computeComputedStyle(); 539 const ComputedStyle* style = computeComputedStyle();
540 if (!style) 540 if (!style)
541 return nullptr; 541 return nullptr;
542 return ComputedStyleCSSValueMapping::getVariables(*style); 542 return ComputedStyleCSSValueMapping::getVariables(*style);
543 } 543 }
544 544
545 RawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID) const 545 CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propert yID) const
546 { 546 {
547 Node* styledNode = this->styledNode(); 547 Node* styledNode = this->styledNode();
548 if (!styledNode) 548 if (!styledNode)
549 return nullptr; 549 return nullptr;
550 LayoutObject* layoutObject = styledNode->layoutObject(); 550 LayoutObject* layoutObject = styledNode->layoutObject();
551 const ComputedStyle* style; 551 const ComputedStyle* style;
552 552
553 Document& document = styledNode->document(); 553 Document& document = styledNode->document();
554 554
555 document.updateLayoutTreeForNode(styledNode); 555 document.updateLayoutTreeForNode(styledNode);
(...skipping 12 matching lines...) Expand all
568 if (forceFullLayout) { 568 if (forceFullLayout) {
569 document.updateLayoutIgnorePendingStylesheetsForNode(styledNode); 569 document.updateLayoutIgnorePendingStylesheetsForNode(styledNode);
570 styledNode = this->styledNode(); 570 styledNode = this->styledNode();
571 style = computeComputedStyle(); 571 style = computeComputedStyle();
572 layoutObject = styledNode->layoutObject(); 572 layoutObject = styledNode->layoutObject();
573 } 573 }
574 574
575 if (!style) 575 if (!style)
576 return nullptr; 576 return nullptr;
577 577
578 RawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(propertyID, *styl e, layoutObject, styledNode, m_allowVisitedStyle); 578 CSSValue* value = ComputedStyleCSSValueMapping::get(propertyID, *style, layo utObject, styledNode, m_allowVisitedStyle);
579 if (value) 579 if (value)
580 return value; 580 return value;
581 581
582 logUnimplementedPropertyID(propertyID); 582 logUnimplementedPropertyID(propertyID);
583 return nullptr; 583 return nullptr;
584 } 584 }
585 585
586 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c onst 586 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c onst
587 { 587 {
588 RawPtr<CSSValue> value = getPropertyCSSValue(propertyID); 588 CSSValue* value = getPropertyCSSValue(propertyID);
589 if (value) 589 if (value)
590 return value->cssText(); 590 return value->cssText();
591 return ""; 591 return "";
592 } 592 }
593 593
594 594
595 unsigned CSSComputedStyleDeclaration::length() const 595 unsigned CSSComputedStyleDeclaration::length() const
596 { 596 {
597 if (!m_node || !m_node->inActiveDocument()) 597 if (!m_node || !m_node->inActiveDocument())
598 return 0; 598 return 0;
(...skipping 13 matching lines...) Expand all
612 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() & & m_node) { 612 if (propertyID == CSSPropertyFontSize && propertyValue->isPrimitiveValue() & & m_node) {
613 m_node->document().updateLayoutIgnorePendingStylesheets(); 613 m_node->document().updateLayoutIgnorePendingStylesheets();
614 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement Specifier); 614 const ComputedStyle* style = m_node->ensureComputedStyle(m_pseudoElement Specifier);
615 if (style && style->getFontDescription().keywordSize()) { 615 if (style && style->getFontDescription().keywordSize()) {
616 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->getFon tDescription().keywordSize()); 616 CSSValueID sizeValue = cssIdentifierForFontSizeKeyword(style->getFon tDescription().keywordSize());
617 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper tyValue); 617 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(proper tyValue);
618 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s izeValue) 618 if (primitiveValue->isValueID() && primitiveValue->getValueID() == s izeValue)
619 return true; 619 return true;
620 } 620 }
621 } 621 }
622 RawPtr<CSSValue> value = getPropertyCSSValue(propertyID); 622 CSSValue* value = getPropertyCSSValue(propertyID);
623 return value && propertyValue && value->equals(*propertyValue); 623 return value && propertyValue && value->equals(*propertyValue);
624 } 624 }
625 625
626 RawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyProperties() co nst 626 MutableStylePropertySet* CSSComputedStyleDeclaration::copyProperties() const
627 { 627 {
628 return copyPropertiesInSet(computableProperties()); 628 return copyPropertiesInSet(computableProperties());
629 } 629 }
630 630
631 RawPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyPropertiesInSet (const Vector<CSSPropertyID>& properties) const 631 MutableStylePropertySet* CSSComputedStyleDeclaration::copyPropertiesInSet(const Vector<CSSPropertyID>& properties) const
632 { 632 {
633 HeapVector<CSSProperty, 256> list; 633 HeapVector<CSSProperty, 256> list;
634 list.reserveInitialCapacity(properties.size()); 634 list.reserveInitialCapacity(properties.size());
635 for (unsigned i = 0; i < properties.size(); ++i) { 635 for (unsigned i = 0; i < properties.size(); ++i) {
636 RawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); 636 CSSValue* value = getPropertyCSSValue(properties[i]);
637 if (value) 637 if (value)
638 list.append(CSSProperty(properties[i], value.release(), false)); 638 list.append(CSSProperty(properties[i], value, false));
639 } 639 }
640 return MutableStylePropertySet::create(list.data(), list.size()); 640 return MutableStylePropertySet::create(list.data(), list.size());
641 } 641 }
642 642
643 CSSRule* CSSComputedStyleDeclaration::parentRule() const 643 CSSRule* CSSComputedStyleDeclaration::parentRule() const
644 { 644 {
645 return nullptr; 645 return nullptr;
646 } 646 }
647 647
648 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName) 648 String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName)
649 { 649 {
650 CSSPropertyID propertyID = cssPropertyID(propertyName); 650 CSSPropertyID propertyID = cssPropertyID(propertyName);
651 if (!propertyID) { 651 if (!propertyID) {
652 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser:: isValidVariableName(propertyName)) { 652 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser:: isValidVariableName(propertyName)) {
653 RawPtr<CSSValue> value = getPropertyCSSValue(AtomicString(propertyNa me)); 653 CSSValue* value = getPropertyCSSValue(AtomicString(propertyName));
654 if (value) 654 if (value)
655 return value->cssText(); 655 return value->cssText();
656 } 656 }
657 return String(); 657 return String();
658 } 658 }
659 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); 659 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID));
660 return getPropertyValue(propertyID); 660 return getPropertyValue(propertyID);
661 } 661 }
662 662
663 String CSSComputedStyleDeclaration::getPropertyPriority(const String&) 663 String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
(...skipping 16 matching lines...) Expand all
680 { 680 {
681 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + name + "' property is read-only."); 681 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + name + "' property is read-only.");
682 } 682 }
683 683
684 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception State& exceptionState) 684 String CSSComputedStyleDeclaration::removeProperty(const String& name, Exception State& exceptionState)
685 { 685 {
686 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + name + "' property is read-only."); 686 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + name + "' property is read-only.");
687 return String(); 687 return String();
688 } 688 }
689 689
690 RawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPro pertyID propertyID) 690 CSSValue* CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
691 { 691 {
692 return getPropertyCSSValue(propertyID); 692 return getPropertyCSSValue(propertyID);
693 } 693 }
694 694
695 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope rtyID) 695 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope rtyID)
696 { 696 {
697 return getPropertyValue(propertyID); 697 return getPropertyValue(propertyID);
698 } 698 }
699 699
700 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St ring&, const String&, bool, ExceptionState& exceptionState) 700 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID id, const St ring&, const String&, bool, ExceptionState& exceptionState)
701 { 701 {
702 // TODO(leviw): This code is currently unreachable, but shouldn't be. 702 // TODO(leviw): This code is currently unreachable, but shouldn't be.
703 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + getPropertyNameString(id) + "' property is r ead-only."); 703 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + getPropertyNameString(id) + "' property is r ead-only.");
704 } 704 }
705 705
706 DEFINE_TRACE(CSSComputedStyleDeclaration) 706 DEFINE_TRACE(CSSComputedStyleDeclaration)
707 { 707 {
708 visitor->trace(m_node); 708 visitor->trace(m_node);
709 CSSStyleDeclaration::trace(visitor); 709 CSSStyleDeclaration::trace(visitor);
710 } 710 }
711 711
712 } // namespace blink 712 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698