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

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

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

Powered by Google App Engine
This is Rietveld 408576698