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

Side by Side Diff: Source/core/rendering/style/RenderStyle.cpp

Issue 305883002: Switch arguments to const Length references for performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/style/RenderStyle.h ('k') | Source/platform/LengthBox.h » ('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 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 || rareInheritedData->textEmphasisColor() != other.rareInherited Data->textEmphasisColor() 716 || rareInheritedData->textEmphasisColor() != other.rareInherited Data->textEmphasisColor()
717 || rareInheritedData->textEmphasisFill != other.rareInheritedDat a->textEmphasisFill 717 || rareInheritedData->textEmphasisFill != other.rareInheritedDat a->textEmphasisFill
718 || rareInheritedData->appliedTextDecorations != other.rareInheri tedData->appliedTextDecorations) 718 || rareInheritedData->appliedTextDecorations != other.rareInheri tedData->appliedTextDecorations)
719 changedContextSensitiveProperties |= ContextSensitivePropertyTex tOrColor; 719 changedContextSensitiveProperties |= ContextSensitivePropertyTex tOrColor;
720 } 720 }
721 } 721 }
722 722
723 return changedContextSensitiveProperties; 723 return changedContextSensitiveProperties;
724 } 724 }
725 725
726 void RenderStyle::setClip(Length top, Length right, Length bottom, Length left) 726 void RenderStyle::setClip(const Length& top, const Length& right, const Length& bottom, const Length& left)
727 { 727 {
728 StyleVisualData* data = visual.access(); 728 StyleVisualData* data = visual.access();
729 data->clip.m_top = top; 729 data->clip.m_top = top;
730 data->clip.m_right = right; 730 data->clip.m_right = right;
731 data->clip.m_bottom = bottom; 731 data->clip.m_bottom = bottom;
732 data->clip.m_left = left; 732 data->clip.m_left = left;
733 } 733 }
734 734
735 void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpo t) 735 void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpo t)
736 { 736 {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 // Unlike fontDescription().computedSize() and hence fontSize(), this is 1187 // Unlike fontDescription().computedSize() and hence fontSize(), this is
1188 // recalculated on demand as we only store the specified line height. 1188 // recalculated on demand as we only store the specified line height.
1189 // FIXME: Should consider scaling the fixed part of any calc expressions 1189 // FIXME: Should consider scaling the fixed part of any calc expressions
1190 // too, though this involves messily poking into CalcExpressionLength. 1190 // too, though this involves messily poking into CalcExpressionLength.
1191 float multiplier = textAutosizingMultiplier(); 1191 float multiplier = textAutosizingMultiplier();
1192 if (multiplier > 1 && lh.isFixed()) 1192 if (multiplier > 1 && lh.isFixed())
1193 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multip lier), Fixed); 1193 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multip lier), Fixed);
1194 1194
1195 return lh; 1195 return lh;
1196 } 1196 }
1197 void RenderStyle::setLineHeight(Length specifiedLineHeight) { SET_VAR(inherited, line_height, specifiedLineHeight); } 1197
1198 void RenderStyle::setLineHeight(const Length& specifiedLineHeight) { SET_VAR(inh erited, line_height, specifiedLineHeight); }
1198 1199
1199 int RenderStyle::computedLineHeight() const 1200 int RenderStyle::computedLineHeight() const
1200 { 1201 {
1201 const Length& lh = lineHeight(); 1202 const Length& lh = lineHeight();
1202 1203
1203 // Negative value means the line height is not set. Use the font's built-in spacing. 1204 // Negative value means the line height is not set. Use the font's built-in spacing.
1204 if (lh.isNegative()) 1205 if (lh.isNegative())
1205 return fontMetrics().lineSpacing(); 1206 return fontMetrics().lineSpacing();
1206 1207
1207 if (lh.isPercent()) 1208 if (lh.isPercent())
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth(); 1591 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth();
1591 } 1592 }
1592 1593
1593 unsigned short RenderStyle::borderEndWidth() const 1594 unsigned short RenderStyle::borderEndWidth() const
1594 { 1595 {
1595 if (isHorizontalWritingMode()) 1596 if (isHorizontalWritingMode())
1596 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth() ; 1597 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth() ;
1597 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth(); 1598 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth();
1598 } 1599 }
1599 1600
1600 void RenderStyle::setMarginStart(Length margin) 1601 void RenderStyle::setMarginStart(const Length& margin)
1601 { 1602 {
1602 if (isHorizontalWritingMode()) { 1603 if (isHorizontalWritingMode()) {
1603 if (isLeftToRightDirection()) 1604 if (isLeftToRightDirection())
1604 setMarginLeft(margin); 1605 setMarginLeft(margin);
1605 else 1606 else
1606 setMarginRight(margin); 1607 setMarginRight(margin);
1607 } else { 1608 } else {
1608 if (isLeftToRightDirection()) 1609 if (isLeftToRightDirection())
1609 setMarginTop(margin); 1610 setMarginTop(margin);
1610 else 1611 else
1611 setMarginBottom(margin); 1612 setMarginBottom(margin);
1612 } 1613 }
1613 } 1614 }
1614 1615
1615 void RenderStyle::setMarginEnd(Length margin) 1616 void RenderStyle::setMarginEnd(const Length& margin)
1616 { 1617 {
1617 if (isHorizontalWritingMode()) { 1618 if (isHorizontalWritingMode()) {
1618 if (isLeftToRightDirection()) 1619 if (isLeftToRightDirection())
1619 setMarginRight(margin); 1620 setMarginRight(margin);
1620 else 1621 else
1621 setMarginLeft(margin); 1622 setMarginLeft(margin);
1622 } else { 1623 } else {
1623 if (isLeftToRightDirection()) 1624 if (isLeftToRightDirection())
1624 setMarginBottom(margin); 1625 setMarginBottom(margin);
1625 else 1626 else
(...skipping 26 matching lines...) Expand all
1652 NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth())); 1653 NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth()));
1653 } 1654 }
1654 1655
1655 void RenderStyle::setBorderImageSource(PassRefPtr<StyleImage> image) 1656 void RenderStyle::setBorderImageSource(PassRefPtr<StyleImage> image)
1656 { 1657 {
1657 if (surround->border.m_image.image() == image.get()) 1658 if (surround->border.m_image.image() == image.get())
1658 return; 1659 return;
1659 surround.access()->border.m_image.setImage(image); 1660 surround.access()->border.m_image.setImage(image);
1660 } 1661 }
1661 1662
1662 void RenderStyle::setBorderImageSlices(LengthBox slices) 1663 void RenderStyle::setBorderImageSlices(const LengthBox& slices)
1663 { 1664 {
1664 if (surround->border.m_image.imageSlices() == slices) 1665 if (surround->border.m_image.imageSlices() == slices)
1665 return; 1666 return;
1666 surround.access()->border.m_image.setImageSlices(slices); 1667 surround.access()->border.m_image.setImageSlices(slices);
1667 } 1668 }
1668 1669
1669 void RenderStyle::setBorderImageWidth(const BorderImageLengthBox& slices) 1670 void RenderStyle::setBorderImageWidth(const BorderImageLengthBox& slices)
1670 { 1671 {
1671 if (surround->border.m_image.borderSlices() == slices) 1672 if (surround->border.m_image.borderSlices() == slices)
1672 return; 1673 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 // right 1707 // right
1707 radiiSum = radii.topRight().height() + radii.bottomRight().height(); 1708 radiiSum = radii.topRight().height() + radii.bottomRight().height();
1708 if (radiiSum > rect.height()) 1709 if (radiiSum > rect.height())
1709 factor = std::min(rect.height() / radiiSum, factor); 1710 factor = std::min(rect.height() / radiiSum, factor);
1710 1711
1711 ASSERT(factor <= 1); 1712 ASSERT(factor <= 1);
1712 return factor; 1713 return factor;
1713 } 1714 }
1714 1715
1715 } // namespace WebCore 1716 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/style/RenderStyle.h ('k') | Source/platform/LengthBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698