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

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: Update tests Created 4 years, 10 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 3366 matching lines...) Expand 10 before | Expand all | Expand 10 after
3377 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); 3377 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom);
3378 } 3378 }
3379 3379
3380 CSSStyleDeclaration* Element::style() 3380 CSSStyleDeclaration* Element::style()
3381 { 3381 {
3382 if (!isStyledElement()) 3382 if (!isStyledElement())
3383 return nullptr; 3383 return nullptr;
3384 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3384 return &ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3385 } 3385 }
3386 3386
3387 StylePropertyMap* Element::styleMap()
3388 {
3389 if (!isStyledElement())
3390 return nullptr;
3391 return &ensureElementRareData().ensureInlineStylePropertyMap(this);
3392 }
3393
3387 MutableStylePropertySet& Element::ensureMutableInlineStyle() 3394 MutableStylePropertySet& Element::ensureMutableInlineStyle()
3388 { 3395 {
3389 ASSERT(isStyledElement()); 3396 ASSERT(isStyledElement());
3390 RefPtrWillBeMember<StylePropertySet>& inlineStyle = ensureUniqueElementData( ).m_inlineStyle; 3397 RefPtrWillBeMember<StylePropertySet>& inlineStyle = ensureUniqueElementData( ).m_inlineStyle;
3391 if (!inlineStyle) { 3398 if (!inlineStyle) {
3392 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3399 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3393 inlineStyle = MutableStylePropertySet::create(mode); 3400 inlineStyle = MutableStylePropertySet::create(mode);
3394 } else if (!inlineStyle->isMutable()) { 3401 } else if (!inlineStyle->isMutable()) {
3395 inlineStyle = inlineStyle->mutableCopy(); 3402 inlineStyle = inlineStyle->mutableCopy();
3396 } 3403 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3450 ASSERT(isStyledElement()); 3457 ASSERT(isStyledElement());
3451 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline)); 3458 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(St yleChangeReason::Inline));
3452 ASSERT(elementData()); 3459 ASSERT(elementData());
3453 elementData()->m_styleAttributeIsDirty = true; 3460 elementData()->m_styleAttributeIsDirty = true;
3454 InspectorInstrumentation::didInvalidateStyleAttr(this); 3461 InspectorInstrumentation::didInvalidateStyleAttr(this);
3455 } 3462 }
3456 3463
3457 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important) 3464 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important)
3458 { 3465 {
3459 ASSERT(isStyledElement()); 3466 ASSERT(isStyledElement());
3460 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIden tifierValue(identifier), important); 3467 RefPtrWillBeRawPtr<CSSValue> cssValue = cssValuePool().createIdentifierValue (identifier);
Timothy Loh 2016/02/09 07:29:32 (btw at some point you'll want to look over your p
meade_UTC10 2016/02/10 05:55:39 Acknowledged.
3468 ensureMutableInlineStyle().setProperty(propertyID, cssValue, important);
3461 inlineStyleChanged(); 3469 inlineStyleChanged();
3462 return true; 3470 return true;
3463 } 3471 }
3464 3472
3465 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important) 3473 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitType unit, bool important)
3466 { 3474 {
3467 ASSERT(isStyledElement()); 3475 ASSERT(isStyledElement());
3468 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createValu e(value, unit), important); 3476 RefPtrWillBeRawPtr<CSSValue> cssValue = cssValuePool().createValue(value, un it);
3477 ensureMutableInlineStyle().setProperty(propertyID, cssValue, important);
3469 inlineStyleChanged(); 3478 inlineStyleChanged();
3470 return true; 3479 return true;
3471 } 3480 }
3472 3481
3473 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important) 3482 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important)
3474 { 3483 {
3475 ASSERT(isStyledElement()); 3484 ASSERT(isStyledElement());
3476 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents()); 3485 MutableStylePropertySet& mutableStylePropertySet = ensureMutableInlineStyle( );
3477 if (changes) 3486 bool changes = mutableStylePropertySet.setProperty(propertyID, value, import ant, document().elementSheet().contents());
3487 if (changes) {
3478 inlineStyleChanged(); 3488 inlineStyleChanged();
3489 }
3479 return changes; 3490 return changes;
3480 } 3491 }
3481 3492
3493 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const PassRefPtrW illBeRawPtr<CSSValue> value, bool important)
3494 {
3495 ASSERT(isStyledElement());
3496 ensureMutableInlineStyle().setProperty(propertyID, value);
3497 inlineStyleChanged();
3498 // This is the hook for InlineStylePropertyMap so don't update it here.
3499 return true;
3500 }
3501
3482 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID) 3502 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID)
3483 { 3503 {
3484 ASSERT(isStyledElement()); 3504 ASSERT(isStyledElement());
3485 if (!inlineStyle()) 3505 if (!inlineStyle())
3486 return false; 3506 return false;
3487 bool changes = ensureMutableInlineStyle().removeProperty(propertyID); 3507 bool changes = ensureMutableInlineStyle().removeProperty(propertyID);
3488 if (changes) 3508 if (changes) {
3489 inlineStyleChanged(); 3509 inlineStyleChanged();
3510 }
3490 return changes; 3511 return changes;
3491 } 3512 }
3492 3513
3493 void Element::removeAllInlineStyleProperties() 3514 void Element::removeAllInlineStyleProperties()
3494 { 3515 {
3495 ASSERT(isStyledElement()); 3516 ASSERT(isStyledElement());
3496 if (!inlineStyle()) 3517 if (!inlineStyle())
3497 return; 3518 return;
3498 ensureMutableInlineStyle().clear(); 3519 ensureMutableInlineStyle().clear();
3499 inlineStyleChanged(); 3520 inlineStyleChanged();
3500 } 3521 }
3501 3522
3502 void Element::updatePresentationAttributeStyle() 3523 void Element::updatePresentationAttributeStyle()
3503 { 3524 {
3504 synchronizeAllAttributes(); 3525 synchronizeAllAttributes();
3505 // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData. 3526 // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData.
3506 UniqueElementData& elementData = ensureUniqueElementData(); 3527 UniqueElementData& elementData = ensureUniqueElementData();
3507 elementData.m_presentationAttributeStyleIsDirty = false; 3528 elementData.m_presentationAttributeStyleIsDirty = false;
3508 elementData.m_presentationAttributeStyle = computePresentationAttributeStyle (*this); 3529 elementData.m_presentationAttributeStyle = computePresentationAttributeStyle (*this);
3509 } 3530 }
3510 3531
3532 void Element::invalidateInlineStylePropertyMap()
3533 {
3534 if (!hasRareData())
3535 return;
3536 ElementRareData* rareData = elementRareData();
3537 InlineStylePropertyMap* inlineStylePropertyMap = rareData->inlineStyleProper tyMap();
3538 if (!inlineStylePropertyMap) {
3539 // Probably it's not being used, so don't bother. If/when one is created it will be filed in.
3540 return;
3541 }
3542
3543 inlineStylePropertyMap->invalidate();
3544 }
3545
3511 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, CSSValueID identifier) 3546 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, CSSValueID identifier)
3512 { 3547 {
3513 ASSERT(isStyledElement()); 3548 ASSERT(isStyledElement());
3514 style->setProperty(propertyID, cssValuePool().createIdentifierValue(identifi er)); 3549 style->setProperty(propertyID, cssValuePool().createIdentifierValue(identifi er));
3515 } 3550 }
3516 3551
3517 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType unit) 3552 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType unit)
3518 { 3553 {
3519 ASSERT(isStyledElement()); 3554 ASSERT(isStyledElement());
3520 style->setProperty(propertyID, cssValuePool().createValue(value, unit)); 3555 style->setProperty(propertyID, cssValuePool().createValue(value, unit));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3623 { 3658 {
3624 #if ENABLE(OILPAN) 3659 #if ENABLE(OILPAN)
3625 if (hasRareData()) 3660 if (hasRareData())
3626 visitor->trace(elementRareData()); 3661 visitor->trace(elementRareData());
3627 visitor->trace(m_elementData); 3662 visitor->trace(m_elementData);
3628 #endif 3663 #endif
3629 ContainerNode::trace(visitor); 3664 ContainerNode::trace(visitor);
3630 } 3665 }
3631 3666
3632 } // namespace blink 3667 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698