To reduce use of CSSMappedAttributeDeclaration..
Created attachment 124107 [details] Possibly a patch
Comment on attachment 124107 [details] Possibly a patch We can do a lot better than this, Mr. Kling. Srsly.
Created attachment 124119 [details] Probably a patch
Attachment 124119 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/html/HTMLTableElement.cpp:453: An else statement can be removed when the prior "if" concludes with a return, break, continue or goto statement. [readability/control_flow] [4] Source/WebCore/html/HTMLTableElement.cpp:558: An else statement can be removed when the prior "if" concludes with a return, break, continue or goto statement. [readability/control_flow] [4] Total errors found: 2 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 124119 [details] Probably a patch View in context: https://bugs.webkit.org/attachment.cgi?id=124119&action=review > Source/WebCore/html/HTMLTableElement.cpp:472 > + if (m_borderColorAttr) { > + DEFINE_STATIC_LOCAL(RefPtr<CSSMutableStyleDeclaration>, style, ()); > + if (!style) { > + style = CSSMutableStyleDeclaration::create(); > + style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid); > + style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid); > + style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid); > + style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid); > + } > + return style; > + } else { > + DEFINE_STATIC_LOCAL(RefPtr<CSSMutableStyleDeclaration>, style, ()); > + if (!style) { > + style = CSSMutableStyleDeclaration::create(); > + style->setProperty(CSSPropertyBorderTopStyle, CSSValueOutset); > + style->setProperty(CSSPropertyBorderBottomStyle, CSSValueOutset); > + style->setProperty(CSSPropertyBorderLeftStyle, CSSValueOutset); > + style->setProperty(CSSPropertyBorderRightStyle, CSSValueOutset); > + } > + return style; We can make this a lot cleaner with a helper function: static CSSMutableStyleDeclaration* leakBorderStyle(int value) { RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create(); style->setProperty(CSSPropertyBorderTopStyle, CSSValueOutset); style->setProperty(CSSPropertyBorderBottomStyle, CSSValueOutset); style->setProperty(CSSPropertyBorderLeftStyle, CSSValueOutset); style->setProperty(CSSPropertyBorderRightStyle, CSSValueOutset); return style.release().leakRef(); } if (m_borderColorAttr) { static CSSMutableStyleDeclaration* solidBorderStyle = leakBorderStyle(CSSValueSolid); return solidBorderStyle; } static CSSMutableStyleDeclaration* outsetBorderStyle = leakBorderStyle(CSSValueOutset); return outsetBorderStyle; > Source/WebCore/html/HTMLTableElement.cpp:504 > +PassRefPtr<CSSMutableStyleDeclaration> HTMLTableElement::additionalCellStyle() > +{ > + if (m_sharedCellStyle) > + return m_sharedCellStyle; > + > + m_sharedCellStyle = CSSMutableStyleDeclaration::create(); I think it’s better to put the management of the data member into a separate function from the one with the case statement that creates the style. The function could even be inlined; the out of line part would be the “create the declaration” bit. > Source/WebCore/html/HTMLTableElement.cpp:548 > + if (m_padding) { > + String value = String::number(m_padding); > + m_sharedCellStyle->setProperty(CSSPropertyPaddingTop, value); > + m_sharedCellStyle->setProperty(CSSPropertyPaddingBottom, value); > + m_sharedCellStyle->setProperty(CSSPropertyPaddingLeft, value); > + m_sharedCellStyle->setProperty(CSSPropertyPaddingRight, value); > } I notice we’re not adding “px” here. Is that OK? > Source/WebCore/html/HTMLTableElement.cpp:578 > + if (rows) { > + DEFINE_STATIC_LOCAL(RefPtr<CSSMutableStyleDeclaration>, style, ()); > + if (!style) { > + style = CSSMutableStyleDeclaration::create(); > + style->setProperty(CSSPropertyBorderTopWidth, CSSValueThin); > + style->setProperty(CSSPropertyBorderBottomWidth, CSSValueThin); > + style->setProperty(CSSPropertyBorderTopStyle, CSSValueSolid); > + style->setProperty(CSSPropertyBorderBottomStyle, CSSValueSolid); > } > - > - setMappedAttributeDecl(ePersistent, rulesAttr, rulesValue, decl); > - decl->setMappedState(ePersistent, rulesAttr, rulesValue); > + return style; > + } else { > + DEFINE_STATIC_LOCAL(RefPtr<CSSMutableStyleDeclaration>, style, ()); > + if (!style) { > + style = CSSMutableStyleDeclaration::create(); > + style->setProperty(CSSPropertyBorderLeftWidth, CSSValueThin); > + style->setProperty(CSSPropertyBorderRightWidth, CSSValueThin); > + style->setProperty(CSSPropertyBorderLeftStyle, CSSValueSolid); > + style->setProperty(CSSPropertyBorderRightStyle, CSSValueSolid); > + } > + return style; > } Again, I suggest using helper functions so we don’t need the “if (!style)” here.
Committed r106015: <http://trac.webkit.org/changeset/106015>