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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1590193002: Partial implementation of inline StylePropertyMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maps
Patch Set: Address Tim's comments 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after
3420 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); 3420 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom);
3421 } 3421 }
3422 3422
3423 CSSStyleDeclaration* Element::style() 3423 CSSStyleDeclaration* Element::style()
3424 { 3424 {
3425 if (!isStyledElement()) 3425 if (!isStyledElement())
3426 return nullptr; 3426 return nullptr;
3427 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3427 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3428 } 3428 }
3429 3429
3430 StylePropertyMap* Element::styleMap()
3431 {
3432 if (!isStyledElement())
3433 return nullptr;
3434 return &ensureElementRareData().ensureInlineStylePropertyMap(this);
3435 }
3436
3430 MutableStylePropertySet& Element::ensureMutableInlineStyle() 3437 MutableStylePropertySet& Element::ensureMutableInlineStyle()
3431 { 3438 {
3432 ASSERT(isStyledElement()); 3439 ASSERT(isStyledElement());
3433 Member<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle; 3440 Member<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle;
3434 if (!inlineStyle) { 3441 if (!inlineStyle) {
3435 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3442 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3436 inlineStyle = MutableStylePropertySet::create(mode); 3443 inlineStyle = MutableStylePropertySet::create(mode);
3437 } else if (!inlineStyle->isMutable()) { 3444 } else if (!inlineStyle->isMutable()) {
3438 inlineStyle = inlineStyle->mutableCopy(); 3445 inlineStyle = inlineStyle->mutableCopy();
3439 } 3446 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 3497
3491 void Element::inlineStyleChanged() 3498 void Element::inlineStyleChanged()
3492 { 3499 {
3493 ASSERT(isStyledElement()); 3500 ASSERT(isStyledElement());
3494 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline)); 3501 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline));
3495 ASSERT(elementData()); 3502 ASSERT(elementData());
3496 elementData()->m_styleAttributeIsDirty = true; 3503 elementData()->m_styleAttributeIsDirty = true;
3497 InspectorInstrumentation::didInvalidateStyleAttr(this); 3504 InspectorInstrumentation::didInvalidateStyleAttr(this);
3498 } 3505 }
3499 3506
3500 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important) 3507 void Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important)
3508 {
3509 setInlineStyleProperty(propertyID, cssValuePool().createIdentifierValue(iden tifier), important);
3510 }
3511
3512 void Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important)
3513 {
3514 setInlineStyleProperty(propertyID, cssValuePool().createValue(value, unit), important);
3515 }
3516
3517 void Element::setInlineStyleProperty(CSSPropertyID propertyID, const RawPtr<CSSV alue> value, bool important)
3501 { 3518 {
3502 ASSERT(isStyledElement()); 3519 ASSERT(isStyledElement());
3503 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIden tifierValue(identifier), important); 3520 ensureMutableInlineStyle().setProperty(propertyID, value, important);
3504 inlineStyleChanged(); 3521 inlineStyleChanged();
3505 return true;
3506 }
3507
3508 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important)
3509 {
3510 ASSERT(isStyledElement());
3511 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createValu e(value, unit), important);
3512 inlineStyleChanged();
3513 return true;
3514 } 3522 }
3515 3523
3516 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important) 3524 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important)
3517 { 3525 {
3518 ASSERT(isStyledElement()); 3526 ASSERT(isStyledElement());
3519 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents()); 3527 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents());
3520 if (changes) 3528 if (changes)
3521 inlineStyleChanged(); 3529 inlineStyleChanged();
3522 return changes; 3530 return changes;
3523 } 3531 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 { 3678 {
3671 #if ENABLE(OILPAN) 3679 #if ENABLE(OILPAN)
3672 if (hasRareData()) 3680 if (hasRareData())
3673 visitor->trace(elementRareData()); 3681 visitor->trace(elementRareData());
3674 visitor->trace(m_elementData); 3682 visitor->trace(m_elementData);
3675 #endif 3683 #endif
3676 ContainerNode::trace(visitor); 3684 ContainerNode::trace(visitor);
3677 } 3685 }
3678 3686
3679 } // namespace blink 3687 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698