Changeset 111733 in webkit
- Timestamp:
- Mar 22, 2012 11:10:55 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r111674 r111733 500 500 css/FontFeatureValue.cpp 501 501 css/FontValue.cpp 502 css/LengthFunctions.cpp 502 503 css/MediaFeatureNames.cpp 503 504 css/MediaList.cpp -
trunk/Source/WebCore/ChangeLog
r111731 r111733 1 2012-03-22 Joe Thomas <joethomas@motorola.com> 2 3 Make Length Calculation functions non-inline 4 https://bugs.webkit.org/show_bug.cgi?id=81733 5 6 Currently length calculation functions in LengthFunctions.h are inline. These functions are pretty big to be inline. 7 And these functions are expected to grow again when new length units will be introduced in bug 27160. 8 9 A decent rule of thumb is to not inline a function if it is more than 10 lines long. Also it's typically not cost effective to inline 10 functions with loops or switch statements. (Reference: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Inline_Functions). 11 12 Ran PerformanceTests/Parser/html5-full-render.html on Mac Snow-Leopard with and without the patch and did not see much performance difference. 13 14 Reviewed by Antti Koivisto. 15 16 * CMakeLists.txt: 17 * GNUmakefile.list.am: 18 * Target.pri: 19 * WebCore.gypi: 20 * WebCore.vcproj/WebCore.vcproj: 21 * WebCore.xcodeproj/project.pbxproj: 22 * css/LengthFunctions.cpp: Added. 23 (WebCore): 24 (WebCore::miminumValueForLength): 25 (WebCore::valueForLength): 26 (WebCore::floatValueForLength): 27 * css/LengthFunctions.h: 28 (WebCore): 29 1 30 2012-03-22 Alexis Menard <alexis.menard@openbossa.org> 2 31 -
trunk/Source/WebCore/GNUmakefile.list.am
r111686 r111733 1648 1648 Source/WebCore/css/FontValue.cpp \ 1649 1649 Source/WebCore/css/FontValue.h \ 1650 Source/WebCore/css/LengthFunctions.cpp \ 1650 1651 Source/WebCore/css/LengthFunctions.h \ 1651 1652 Source/WebCore/css/MediaFeatureNames.cpp \ -
trunk/Source/WebCore/Target.pri
r111674 r111733 476 476 css/FontFeatureValue.cpp \ 477 477 css/FontValue.cpp \ 478 css/LengthFunctions.cpp \ 478 479 css/MediaFeatureNames.cpp \ 479 480 css/MediaList.cpp \ -
trunk/Source/WebCore/WebCore.gypi
r111686 r111733 2431 2431 'css/FontValue.cpp', 2432 2432 'css/FontValue.h', 2433 'css/LengthFunctions.cpp', 2433 2434 'css/MediaFeatureNames.cpp', 2434 2435 'css/MediaFeatureNames.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r111655 r111733 36475 36475 </File> 36476 36476 <File 36477 RelativePath="..\css\LengthFunctions.cpp" 36478 > 36479 </File> 36480 <File 36477 36481 RelativePath="..\css\LengthFunctions.h" 36478 36482 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r111674 r111733 5966 5966 E4D687770ED7AE3D006EA978 /* PurgeableBufferMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D687760ED7AE3D006EA978 /* PurgeableBufferMac.cpp */; }; 5967 5967 E4D687790ED7AE4F006EA978 /* PurgeableBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */; }; 5968 E55F497A151B888000BB67DB /* LengthFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E55F4979151B888000BB67DB /* LengthFunctions.cpp */; }; 5968 5969 E5BA7D63151437CA00FE1E3F /* LengthFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5969 5970 ED2BA83C09A24B91006C0AC4 /* DocumentMarker.h in Headers */ = {isa = PBXBuildFile; fileRef = ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 13087 13088 E4D687760ED7AE3D006EA978 /* PurgeableBufferMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PurgeableBufferMac.cpp; sourceTree = "<group>"; }; 13088 13089 E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgeableBuffer.h; sourceTree = "<group>"; }; 13090 E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = "<group>"; }; 13089 13091 E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthFunctions.h; sourceTree = "<group>"; }; 13090 13092 ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarker.h; sourceTree = "<group>"; }; … … 20491 20493 CDBD93BA1333BD4B002570E3 /* fullscreenQuickTime.css */, 20492 20494 93CA4C9909DF93FA00DF8677 /* html.css */, 20495 E55F4979151B888000BB67DB /* LengthFunctions.cpp */, 20493 20496 E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */, 20494 20497 93CA4C9A09DF93FA00DF8677 /* make-css-file-arrays.pl */, … … 27611 27614 9393E5FF151A99F200066F06 /* CSSImageSetValue.cpp in Sources */, 27612 27615 9393E604151A9A1800066F06 /* StyleCachedImageSet.cpp in Sources */, 27616 E55F497A151B888000BB67DB /* LengthFunctions.cpp in Sources */, 27613 27617 ); 27614 27618 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/css/LengthFunctions.cpp
r111732 r111733 22 22 */ 23 23 24 #i fndef LengthFunctions_h25 # define LengthFunctions_h24 #include "config.h" 25 #include "LengthFunctions.h" 26 26 27 27 #include "Length.h" … … 29 29 namespace WebCore { 30 30 31 in line int miminumValueForLength(Length length, int maximumValue, bool roundPercentages = false)31 int miminumValueForLength(Length length, int maximumValue, bool roundPercentages) 32 32 { 33 33 switch (length.type()) { … … 54 54 } 55 55 56 in line int valueForLength(Length length, int maximumValue, bool roundPercentages = false)56 int valueForLength(Length length, int maximumValue, bool roundPercentages) 57 57 { 58 58 switch (length.type()) { … … 75 75 76 76 // FIXME: when subpixel layout is supported this copy of floatValueForLength() can be removed. See bug 71143. 77 inlinefloat floatValueForLength(Length length, int maximumValue)77 float floatValueForLength(Length length, int maximumValue) 78 78 { 79 79 switch (length.type()) { … … 97 97 } 98 98 99 inlinefloat floatValueForLength(Length length, float maximumValue)99 float floatValueForLength(Length length, float maximumValue) 100 100 { 101 101 switch (length.type()) { … … 120 120 121 121 } // namespace WebCore 122 123 #endif // LengthFunctions_h -
trunk/Source/WebCore/css/LengthFunctions.h
r111126 r111733 25 25 #define LengthFunctions_h 26 26 27 #include "Length.h"28 29 27 namespace WebCore { 30 28 31 inline int miminumValueForLength(Length length, int maximumValue, bool roundPercentages = false) 32 { 33 switch (length.type()) { 34 case Fixed: 35 return length.value(); 36 case Percent: 37 if (roundPercentages) 38 return static_cast<int>(round(maximumValue * length.percent() / 100.0f)); 39 // Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack. 40 return static_cast<int>(static_cast<float>(maximumValue * length.percent() / 100.0f)); 41 case Calculated: 42 return length.nonNanCalculatedValue(maximumValue); 43 case Auto: 44 return 0; 45 case Relative: 46 case Intrinsic: 47 case MinIntrinsic: 48 case Undefined: 49 ASSERT_NOT_REACHED(); 50 return 0; 51 } 52 ASSERT_NOT_REACHED(); 53 return 0; 54 } 29 struct Length; 55 30 56 inline int valueForLength(Length length, int maximumValue, bool roundPercentages = false) 57 { 58 switch (length.type()) { 59 case Fixed: 60 case Percent: 61 case Calculated: 62 return miminumValueForLength(length, maximumValue, roundPercentages); 63 case Auto: 64 return maximumValue; 65 case Relative: 66 case Intrinsic: 67 case MinIntrinsic: 68 case Undefined: 69 ASSERT_NOT_REACHED(); 70 return 0; 71 } 72 ASSERT_NOT_REACHED(); 73 return 0; 74 } 75 76 // FIXME: when subpixel layout is supported this copy of floatValueForLength() can be removed. See bug 71143. 77 inline float floatValueForLength(Length length, int maximumValue) 78 { 79 switch (length.type()) { 80 case Fixed: 81 return length.getFloatValue(); 82 case Percent: 83 return static_cast<float>(maximumValue * length.percent() / 100.0f); 84 case Auto: 85 return static_cast<float>(maximumValue); 86 case Calculated: 87 return length.nonNanCalculatedValue(maximumValue); 88 case Relative: 89 case Intrinsic: 90 case MinIntrinsic: 91 case Undefined: 92 ASSERT_NOT_REACHED(); 93 return 0; 94 } 95 ASSERT_NOT_REACHED(); 96 return 0; 97 } 98 99 inline float floatValueForLength(Length length, float maximumValue) 100 { 101 switch (length.type()) { 102 case Fixed: 103 return length.getFloatValue(); 104 case Percent: 105 return static_cast<float>(maximumValue * length.percent() / 100.0f); 106 case Auto: 107 return static_cast<float>(maximumValue); 108 case Calculated: 109 return length.nonNanCalculatedValue(maximumValue); 110 case Relative: 111 case Intrinsic: 112 case MinIntrinsic: 113 case Undefined: 114 ASSERT_NOT_REACHED(); 115 return 0; 116 } 117 ASSERT_NOT_REACHED(); 118 return 0; 119 } 31 int miminumValueForLength(Length, int maximumValue, bool roundPercentages = false); 32 int valueForLength(Length, int maximumValue, bool roundPercentages = false); 33 float floatValueForLength(Length, int maximumValue); 34 float floatValueForLength(Length, float maximumValue); 120 35 121 36 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.