Changeset 126438 in webkit
- Timestamp:
- Aug 23, 2012 9:24:15 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r126417 r126438 1 2012-08-23 John Mellor <johnme@chromium.org> 2 3 Text Autosizing: Multiply large fonts less, as they are already more legible. 4 https://bugs.webkit.org/show_bug.cgi?id=94227 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Added test demonstrating how various font sizes are affected. 9 10 * fast/text-autosizing/various-font-sizes-expected.html: Added. 11 * fast/text-autosizing/various-font-sizes.html: Added. 12 1 13 2012-08-23 Zan Dobersek <zandobersek@gmail.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r126437 r126438 1 2012-08-23 John Mellor <johnme@chromium.org> 2 3 Text Autosizing: Multiply large fonts less, as they are already more legible. 4 https://bugs.webkit.org/show_bug.cgi?id=94227 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Rather than uniformly multiplying font sizes by the multiplier (derived 9 from the width of the block), we should multiply fonts that are already 10 large less, since they are already more legible hence there is less need 11 for them to grow. 12 13 However it is still important to maintain differentiation between text 14 that the author specified to be of different sizes. 15 16 This algorithm multiplies text by the multiplier up until a predefined 17 "pleasant" font size; beyond that the computedSize goes up with 18 specifiedSize but at a gradient of less than 1 in order to gradually 19 fade out the size increase; finally for very large specifiedSizes the 20 computedSize will be the same as the specifiedSize. 21 22 For further details, including a graph, please see the bug report. 23 24 Test: fast/text-autosizing/various-font-sizes.html 25 26 * rendering/TextAutosizer.cpp: 27 (WebCore::TextAutosizer::computeAutosizedFontSize): 28 29 Implements the custom multiplication. See comment for details. 30 31 * rendering/style/RenderStyle.cpp: 32 (WebCore::RenderStyle::lineHeight): 33 34 Use computeAutosizedFontSize instead of directly multiplying. 35 36 (WebCore::RenderStyle::setFontSize): 37 38 Use computeAutosizedFontSize instead of directly multiplying. 39 1 40 2012-08-23 Emil A Eklund <eae@chromium.org> 2 41 -
trunk/Source/WebCore/rendering/TextAutosizer.cpp
r126359 r126438 108 108 } 109 109 110 float TextAutosizer::computeAutosizedFontSize(float specifiedSize, float multiplier) 111 { 112 // Somewhat arbitrary "pleasant" font size. 113 const float pleasantSize = 16; 114 115 // Multiply fonts that the page author has specified to be larger than 116 // pleasantSize by less and less, until huge fonts are not increased at all. 117 // For specifiedSize between 0 and pleasantSize we directly apply the 118 // multiplier; hence for specifiedSize == pleasantSize, computedSize will be 119 // multiplier * pleasantSize. For greater specifiedSizes we want to 120 // gradually fade out the multiplier, so for every 1px increase in 121 // specifiedSize beyond pleasantSize we will only increase computedSize 122 // by gradientAfterPleasantSize px until we meet the 123 // computedSize = specifiedSize line, after which we stay on that line (so 124 // then every 1px increase in specifiedSize increases computedSize by 1px). 125 const float gradientAfterPleasantSize = 0.5; 126 127 float computedSize; 128 if (specifiedSize <= pleasantSize) 129 computedSize = multiplier * specifiedSize; 130 else { 131 computedSize = multiplier * pleasantSize + gradientAfterPleasantSize * (specifiedSize - pleasantSize); 132 if (computedSize < specifiedSize) 133 computedSize = specifiedSize; 134 } 135 return computedSize; 136 } 137 110 138 bool TextAutosizer::isNotAnAutosizingContainer(const RenderObject* renderer) 111 139 { -
trunk/Source/WebCore/rendering/TextAutosizer.h
r126058 r126438 52 52 bool processSubtree(RenderObject* layoutRoot); 53 53 54 static float computeAutosizedFontSize(float specifiedSize, float multiplier); 55 54 56 private: 55 57 explicit TextAutosizer(Document*); -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r126359 r126438 43 43 #include <wtf/StdLibExtras.h> 44 44 #include <algorithm> 45 46 #if ENABLE(TEXT_AUTOSIZING) 47 #include "TextAutosizer.h" 48 #endif 45 49 46 50 using namespace std; … … 1224 1228 float multiplier = textAutosizingMultiplier(); 1225 1229 if (multiplier > 1 && lh.isFixed()) 1226 return Length( lh.value() * multiplier, Fixed);1230 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multiplier), Fixed); 1227 1231 #endif 1228 1232 return lh; … … 1263 1267 float multiplier = textAutosizingMultiplier(); 1264 1268 if (multiplier > 1) { 1265 // FIXME: Large font sizes needn't be multiplied as much since they are already more legible. 1266 desc.setComputedSize(size * multiplier); 1269 desc.setComputedSize(TextAutosizer::computeAutosizedFontSize(size, multiplier)); 1267 1270 } 1268 1271 #endif
Note: See TracChangeset
for help on using the changeset viewer.