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

Unified Diff: Source/core/editing/EditingStyle.cpp

Issue 183763033: Avoid calling hasAttribute() and then getAttribute() for performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/editing/SplitElementCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/EditingStyle.cpp
diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp
index 0d555c04bde1cfc481cbaed227d431cc1525763c..eaee4c96f0619f4b97b386fbaab27d297c494dcf 100644
--- a/Source/core/editing/EditingStyle.cpp
+++ b/Source/core/editing/EditingStyle.cpp
@@ -290,12 +290,13 @@ void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
PassRefPtrWillBeRawPtr<CSSValue> HTMLAttributeEquivalent::attributeValueAsCSSValue(Element* element) const
{
ASSERT(element);
- if (!element->hasAttribute(m_attrName))
+ const AtomicString& value = element->getAttribute(m_attrName);
+ if (value.isNull())
return nullptr;
RefPtr<MutableStylePropertySet> dummyStyle;
dummyStyle = MutableStylePropertySet::create();
- dummyStyle->setProperty(m_propertyID, element->getAttribute(m_attrName));
+ dummyStyle->setProperty(m_propertyID, value);
return dummyStyle->getPropertyCSSValue(m_propertyID);
}
@@ -319,10 +320,11 @@ HTMLFontSizeEquivalent::HTMLFontSizeEquivalent()
PassRefPtrWillBeRawPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* element) const
{
ASSERT(element);
- if (!element->hasAttribute(m_attrName))
+ const AtomicString& value = element->getAttribute(m_attrName);
+ if (value.isNull())
return nullptr;
CSSValueID size;
- if (!HTMLFontElement::cssValueFromFontSizeNumber(element->getAttribute(m_attrName), size))
+ if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size))
return nullptr;
return CSSPrimitiveValue::createIdentifier(size);
}
« no previous file with comments | « no previous file | Source/core/editing/SplitElementCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698