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

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 review 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 3416 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); 3427 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom);
3428 } 3428 }
3429 3429
3430 CSSStyleDeclaration* Element::style() 3430 CSSStyleDeclaration* Element::style()
3431 { 3431 {
3432 if (!isStyledElement()) 3432 if (!isStyledElement())
3433 return nullptr; 3433 return nullptr;
3434 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3434 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3435 } 3435 }
3436 3436
3437 StylePropertyMap* Element::styleMap()
3438 {
3439 if (!isStyledElement())
3440 return nullptr;
3441 return &ensureElementRareData().ensureInlineStylePropertyMap(this);
3442 }
3443
3437 MutableStylePropertySet& Element::ensureMutableInlineStyle() 3444 MutableStylePropertySet& Element::ensureMutableInlineStyle()
3438 { 3445 {
3439 ASSERT(isStyledElement()); 3446 ASSERT(isStyledElement());
3440 Member<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle; 3447 Member<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle;
3441 if (!inlineStyle) { 3448 if (!inlineStyle) {
3442 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3449 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3443 inlineStyle = MutableStylePropertySet::create(mode); 3450 inlineStyle = MutableStylePropertySet::create(mode);
3444 } else if (!inlineStyle->isMutable()) { 3451 } else if (!inlineStyle->isMutable()) {
3445 inlineStyle = inlineStyle->mutableCopy(); 3452 inlineStyle = inlineStyle->mutableCopy();
3446 } 3453 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3497 3504
3498 void Element::inlineStyleChanged() 3505 void Element::inlineStyleChanged()
3499 { 3506 {
3500 ASSERT(isStyledElement()); 3507 ASSERT(isStyledElement());
3501 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline)); 3508 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline));
3502 ASSERT(elementData()); 3509 ASSERT(elementData());
3503 elementData()->m_styleAttributeIsDirty = true; 3510 elementData()->m_styleAttributeIsDirty = true;
3504 InspectorInstrumentation::didInvalidateStyleAttr(this); 3511 InspectorInstrumentation::didInvalidateStyleAttr(this);
3505 } 3512 }
3506 3513
3507 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important) 3514 void Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important)
3515 {
3516 setInlineStyleProperty(propertyID, cssValuePool().createIdentifierValue(iden tifier), important);
3517 }
3518
3519 void Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important)
3520 {
3521 setInlineStyleProperty(propertyID, cssValuePool().createValue(value, unit), important);
3522 }
3523
3524 void Element::setInlineStyleProperty(CSSPropertyID propertyID, const RawPtr<CSSV alue> value, bool important)
3508 { 3525 {
3509 ASSERT(isStyledElement()); 3526 ASSERT(isStyledElement());
3510 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIden tifierValue(identifier), important); 3527 ensureMutableInlineStyle().setProperty(propertyID, value, important);
3511 inlineStyleChanged(); 3528 inlineStyleChanged();
3512 return true;
3513 }
3514
3515 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important)
3516 {
3517 ASSERT(isStyledElement());
3518 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createValu e(value, unit), important);
3519 inlineStyleChanged();
3520 return true;
3521 } 3529 }
3522 3530
3523 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important) 3531 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important)
3524 { 3532 {
3525 ASSERT(isStyledElement()); 3533 ASSERT(isStyledElement());
3526 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents()); 3534 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents());
3527 if (changes) 3535 if (changes)
3528 inlineStyleChanged(); 3536 inlineStyleChanged();
3529 return changes; 3537 return changes;
3530 } 3538 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
3675 3683
3676 DEFINE_TRACE(Element) 3684 DEFINE_TRACE(Element)
3677 { 3685 {
3678 if (hasRareData()) 3686 if (hasRareData())
3679 visitor->trace(elementRareData()); 3687 visitor->trace(elementRareData());
3680 visitor->trace(m_elementData); 3688 visitor->trace(m_elementData);
3681 ContainerNode::trace(visitor); 3689 ContainerNode::trace(visitor);
3682 } 3690 }
3683 3691
3684 } // namespace blink 3692 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698