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

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

Issue 119533003: Clear mutable inline style when it is empty. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed typo. Created 7 years 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
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 { 3425 {
3426 ensureElementRareData().setHasPendingResources(false); 3426 ensureElementRareData().setHasPendingResources(false);
3427 } 3427 }
3428 3428
3429 void Element::synchronizeStyleAttributeInternal() const 3429 void Element::synchronizeStyleAttributeInternal() const
3430 { 3430 {
3431 ASSERT(isStyledElement()); 3431 ASSERT(isStyledElement());
3432 ASSERT(elementData()); 3432 ASSERT(elementData());
3433 ASSERT(elementData()->m_styleAttributeIsDirty); 3433 ASSERT(elementData()->m_styleAttributeIsDirty);
3434 elementData()->m_styleAttributeIsDirty = false; 3434 elementData()->m_styleAttributeIsDirty = false;
3435 if (const StylePropertySet* inlineStyle = this->inlineStyle()) 3435 const StylePropertySet* inlineStyle = this->inlineStyle();
3436 const_cast<Element*>(this)->setSynchronizedLazyAttribute(styleAttr, inli neStyle->asText()); 3436 const_cast<Element*>(this)->setSynchronizedLazyAttribute(styleAttr,
3437 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom);
3437 } 3438 }
3438 3439
3439 CSSStyleDeclaration* Element::style() 3440 CSSStyleDeclaration* Element::style()
3440 { 3441 {
3441 if (!isStyledElement()) 3442 if (!isStyledElement())
3442 return 0; 3443 return 0;
3443 return ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3444 return ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3444 } 3445 }
3445 3446
3446 MutableStylePropertySet* Element::ensureMutableInlineStyle() 3447 MutableStylePropertySet* Element::ensureMutableInlineStyle()
3447 { 3448 {
3448 ASSERT(isStyledElement()); 3449 ASSERT(isStyledElement());
3449 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineS tyle; 3450 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineS tyle;
3450 if (!inlineStyle) { 3451 if (!inlineStyle) {
3451 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3452 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3452 inlineStyle = MutableStylePropertySet::create(mode); 3453 inlineStyle = MutableStylePropertySet::create(mode);
3453 } else if (!inlineStyle->isMutable()) { 3454 } else if (!inlineStyle->isMutable()) {
3454 inlineStyle = inlineStyle->mutableCopy(); 3455 inlineStyle = inlineStyle->mutableCopy();
3455 } 3456 }
3456 return toMutableStylePropertySet(inlineStyle); 3457 return toMutableStylePropertySet(inlineStyle);
3457 } 3458 }
3458 3459
3460 void Element::clearMutableInlineStyleIfEmpty()
3461 {
3462 if (ensureMutableInlineStyle()->isEmpty()) {
3463 ensureUniqueElementData()->m_inlineStyle.clear();
3464 }
3465 }
3466
3459 PropertySetCSSStyleDeclaration* Element::inlineStyleCSSOMWrapper() 3467 PropertySetCSSStyleDeclaration* Element::inlineStyleCSSOMWrapper()
3460 { 3468 {
3461 if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper()) 3469 if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper())
3462 return 0; 3470 return 0;
3463 PropertySetCSSStyleDeclaration* cssomWrapper = ensureMutableInlineStyle()->c ssStyleDeclaration(); 3471 PropertySetCSSStyleDeclaration* cssomWrapper = ensureMutableInlineStyle()->c ssStyleDeclaration();
3464 ASSERT(cssomWrapper && cssomWrapper->parentElement() == this); 3472 ASSERT(cssomWrapper && cssomWrapper->parentElement() == this);
3465 return cssomWrapper; 3473 return cssomWrapper;
3466 } 3474 }
3467 3475
3468 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString ) 3476 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString )
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 return false; 3565 return false;
3558 bool changes = ensureMutableInlineStyle()->removeProperty(propertyID); 3566 bool changes = ensureMutableInlineStyle()->removeProperty(propertyID);
3559 if (changes) 3567 if (changes)
3560 inlineStyleChanged(); 3568 inlineStyleChanged();
3561 return changes; 3569 return changes;
3562 } 3570 }
3563 3571
3564 void Element::removeAllInlineStyleProperties() 3572 void Element::removeAllInlineStyleProperties()
3565 { 3573 {
3566 ASSERT(isStyledElement()); 3574 ASSERT(isStyledElement());
3567 if (!inlineStyle() || inlineStyle()->isEmpty()) 3575 if (!inlineStyle())
3568 return; 3576 return;
3569 ensureMutableInlineStyle()->clear(); 3577 ensureMutableInlineStyle()->clear();
3570 inlineStyleChanged(); 3578 inlineStyleChanged();
3571 } 3579 }
3572 3580
3573 void Element::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 3581 void Element::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
3574 { 3582 {
3575 ASSERT(isStyledElement()); 3583 ASSERT(isStyledElement());
3576 if (const StylePropertySet* inlineStyle = elementData() ? elementData()->inl ineStyle() : 0) 3584 if (const StylePropertySet* inlineStyle = elementData() ? elementData()->inl ineStyle() : 0)
3577 inlineStyle->addSubresourceStyleURLs(urls, document().elementSheet()->co ntents()); 3585 inlineStyle->addSubresourceStyleURLs(urls, document().elementSheet()->co ntents());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3649 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3657 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3650 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3658 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3651 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3659 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3652 return false; 3660 return false;
3653 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3661 if (FullscreenElementStack::isActiveFullScreenElement(this))
3654 return false; 3662 return false;
3655 return true; 3663 return true;
3656 } 3664 }
3657 3665
3658 } // namespace WebCore 3666 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698