Changeset 125925 in webkit
- Timestamp:
- Aug 17, 2012 12:17:54 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 18 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r125921 r125925 1 2012-08-17 John Mellor <johnme@chromium.org> 2 3 Text Autosizing: Increase line height in proportion to font size. 4 https://bugs.webkit.org/show_bug.cgi?id=91660 5 6 Reviewed by Julien Chaffraix. 7 8 Adjusted the expectation for simple-paragraph.html and 9 font-scale-factor.html now that line-height is correctly increased. 10 Also added 5 more tests making sure that autosized children of 11 non-autosized parents work correctly, and vice versa; that nested 12 inline elements behave correctly; and documenting the behavior of 13 margins, borders, and padding with em lengths. 14 15 * fast/text-autosizing/em-margin-border-padding-expected.html: Added. 16 * fast/text-autosizing/em-margin-border-padding.html: Copied from LayoutTests/fast/text-autosizing/simple-paragraph.html. 17 * fast/text-autosizing/font-scale-factor-expected.html: 18 * fast/text-autosizing/font-scale-factor.html: 19 * fast/text-autosizing/narrow-child-expected.html: Added. 20 * fast/text-autosizing/narrow-child.html: Copied from LayoutTests/fast/text-autosizing/simple-paragraph.html. 21 * fast/text-autosizing/nested-em-line-height-expected.html: Added. 22 * fast/text-autosizing/nested-em-line-height.html: Added. 23 * fast/text-autosizing/simple-paragraph-expected.html: 24 * fast/text-autosizing/simple-paragraph.html: 25 * fast/text-autosizing/span-child-expected.html: Added. 26 * fast/text-autosizing/span-child.html: Copied from LayoutTests/fast/text-autosizing/simple-paragraph.html. 27 * fast/text-autosizing/wide-child-expected.html: Added. 28 * fast/text-autosizing/wide-child.html: Copied from LayoutTests/fast/text-autosizing/simple-paragraph.html. 29 1 30 2012-08-17 Zan Dobersek <zandobersek@gmail.com> 2 31 -
trunk/LayoutTests/fast/text-autosizing/em-margin-border-padding.html
r125924 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 19 20 <body> 20 21 21 <p style="line-height: 1.5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 22 <p style="margin: 1em; border: 1em solid blue; padding: 1em"> 23 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 24 </p> 22 25 23 26 </body> -
trunk/LayoutTests/fast/text-autosizing/font-scale-factor-expected.html
r124372 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 10 11 </head> 11 12 <body> 12 <!-- FIXME: The line-height and margin-top shouldn't need to be changed here. The margins are a bug. See http://wkbug.com/91660. --> 13 <p style="font-size: 5rem; line-height: 0.30; margin: 2.20rem 0 1rem 0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 13 <div style="font-size: 5rem">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</div> 14 14 </body> 15 15 </html> -
trunk/LayoutTests/fast/text-autosizing/font-scale-factor.html
r124372 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 19 20 </head> 20 21 <body> 21 <!-- FIXME: The line-height and margin-top shouldn't need to be changed here. See http://wkbug.com/91660. --> 22 <p style="line-height: 1.5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 22 <div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</div> 23 23 </body> 24 24 </html> -
trunk/LayoutTests/fast/text-autosizing/narrow-child.html
r125924 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 19 20 <body> 20 21 21 <p style="line-height: 1.5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 22 <div> 23 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 24 <div style="width: 320px"> 25 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 26 </div> 27 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 28 </div> 22 29 23 30 </body> -
trunk/LayoutTests/fast/text-autosizing/simple-paragraph-expected.html
r121907 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 10 11 <body> 11 12 12 <!-- The font-size change is intentional; the line-height change is a known FIXME; the margin-top change is a bug --> 13 <p style="font-size: 2.5rem; line-height: 0.6; margin-top: 0.8rem">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 13 <div style="font-size: 2.5rem"> 14 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 15 </div> 14 16 15 17 </body> -
trunk/LayoutTests/fast/text-autosizing/simple-paragraph.html
r121907 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 19 20 <body> 20 21 21 <p style="line-height: 1.5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 22 <div> 23 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 24 </div> 22 25 23 26 </body> -
trunk/LayoutTests/fast/text-autosizing/span-child.html
r125924 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 19 20 <body> 20 21 21 <p style="line-height: 1.5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 22 <div> 23 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 24 <span> 25 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 26 </span> 27 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 28 </div> 22 29 23 30 </body> -
trunk/LayoutTests/fast/text-autosizing/wide-child.html
r125924 r125925 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> … … 19 20 <body> 20 21 21 <p style="line-height: 1.5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sapien sapien, tempus id egestas a, consectetur et felis. Ut pharetra mi eget lectus laoreet rutrum. Mauris tellus odio, egestas vitae sodales in, vehicula eget ante. Pellentesque id egestas arcu. Quisque tellus quam, rhoncus ac elementum vel, volutpat vel felis. Aliquam ut leo dolor, eget egestas tellus. Nunc ut velit gravida nisl fringilla rutrum eget at arcu. Vivamus et pretium mauris.</p> 22 <div style="width: 320px"> 23 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 24 <div style="width: 800px"> 25 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 26 </div> 27 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 28 </div> 22 29 23 30 </body> -
trunk/Source/WebCore/ChangeLog
r125924 r125925 1 2012-08-17 John Mellor <johnme@chromium.org> 2 3 Text Autosizing: Increase line height in proportion to font size. 4 https://bugs.webkit.org/show_bug.cgi?id=91660 5 6 Reviewed by Julien Chaffraix. 7 8 This patch causes line heights to be increased in proportion to font 9 size (so autosized text doesn't overlap itself). It does this by adding 10 a textAutosizingMultiplier() to RenderStyle, which the lineHeight() 11 getter multiplies its response by. 12 13 It also cleans up one or two things, for example treatAsInline is 14 renamed isNotAnAutosizingContainer to clarify that its purpose is to 15 discriminate autosizing containers (the smallest unit that we can turn 16 Text Autosizing on or off for; in particular these are not allowed to 17 be line participants, since multiple sizes on one line looks awful). 18 19 Tests: fast/text-autosizing/em-margin-border-padding.html 20 fast/text-autosizing/narrow-child.html 21 fast/text-autosizing/nested-em-line-height.html 22 fast/text-autosizing/simple-paragraph.html 23 fast/text-autosizing/span-child.html 24 fast/text-autosizing/wide-child.html 25 26 * css/StyleBuilder.cpp: 27 (WebCore::ApplyPropertyLineHeight::applyValue): 28 29 Replaced Length(-100.0, Percent) with RenderStyle::initialLineHeight(), 30 which is equivalent but makes the intent clearer. 31 32 (WebCore::ApplyPropertyLineHeight::createHandler): 33 34 Use specifiedLineHeight to match setLineHeight which takes a specified 35 line height (and generally this avoids accidentally inheriting text 36 autosizing). 37 38 * css/StyleResolver.cpp: 39 (WebCore::StyleResolver::applyProperty): 40 41 Similarly use specifiedLineHeight when inheriting line height. 42 43 * page/animation/CSSPropertyAnimation.cpp: 44 (WebCore::CSSPropertyAnimation::ensurePropertyMap): 45 46 Get and set specified lineHeight/fontSize if Text Autosizing is 47 enabled to avoid setting the specified value to the computed value 48 (causing values to be multiplied more than once!). 49 50 * platform/blackberry/RenderThemeBlackBerry.cpp: 51 (WebCore::RenderThemeBlackBerry::adjustMediaControlStyle): 52 53 Adjust for renamed setBlendedFontSize, and maintain cast to int. 54 55 * rendering/RenderTextControlSingleLine.cpp: 56 (WebCore::RenderTextControlSingleLine::createInnerTextStyle): 57 58 Replaced Length(-100.0, Percent) with RenderStyle::initialLineHeight(), 59 which is equivalent but makes the intent clearer. 60 61 * rendering/TextAutosizer.cpp: 62 (WebCore::TextAutosizer::processSubtree): 63 64 Use nextInPreOrderMatchingFilter instead of traverseNext, and some 65 other methods that got renamed. 66 67 (WebCore::TextAutosizer::processBox): 68 69 Renamed from processBlock, since RenderBoxes are sufficient; use 70 renamed nextInPreOrderMatchingFilter; make two calls to setMultiplier 71 (one for parent for line height) instead of processText. 72 73 (WebCore::TextAutosizer::setMultiplier): 74 75 Simplified from previous processText method; this just sets the 76 style's textAutosizingMultiplier (and the style does the rest). 77 78 (WebCore::TextAutosizer::isNotAnAutosizingContainer): 79 80 Renamed from treatAsInline; added explanatory comment; changed 81 isRenderBlock to isBox as boxes still have logicalWidth; changed 82 isInlineBlockOrInlineTable to isInline as it was an omission that 83 other inlines were allowed. 84 85 (WebCore::TextAutosizer::nextInPreOrderMatchingFilter): 86 87 Renamed from TextAutosizer::traverseNext. 88 89 (RenderObjectFilterFunctor): 90 91 Renamed from RenderObjectFilter to clafiry that it's a function ptr. 92 93 * rendering/TextAutosizer.h: 94 (TextAutosizer): Previously mentioned renamings. 95 96 * rendering/mathml/RenderMathMLSubSup.cpp: 97 (WebCore::RenderMathMLSubSup::fixScriptsStyle): 98 99 Adjust for renamed setBlendedFontSize. 100 101 * rendering/style/RenderStyle.cpp: 102 (WebCore::RenderStyle::diff): 103 104 textAutosizingMultiplier is a StyleDifferenceLayout (we want 105 setNeedsLayoutAndPrefWidthsRecalc to get called). 106 107 (WebCore::RenderStyle::setFontSize): 108 109 Renamed from setBlendedFontSize; if Text Autosizing is enabled and a 110 multiplier is set it auto-calculates the computedSize; float 111 param instead of int as discussed on webkit.org/b/91660. 112 113 * rendering/style/RenderStyle.h: 114 115 Added specifiedFontSize, computedFontSize and specifiedLineHeight 116 getters; changed lineHeight to dynamically calculate autosized line 117 height, and made computedLineHeight use this value instead of the 118 specified line height; also added textAutosizingMultiplier 119 getter/setter (the setter updated the font description's computed 120 size, by calling setFontSize); also renamed the parameter to 121 setLineHeight to explicitly note that it's setting the 122 specifiedLineHeight (and can still be adjusted by autosizing). 123 124 * rendering/style/StyleVisualData.cpp/.h: 125 126 Added m_textAutosizingMultiplier (this seems the best place to put a 127 non-inherited non-rare presentational property). 128 1 129 2012-08-17 Raphael Kubo da Costa <rakuco@webkit.org> 2 130 -
trunk/Source/WebCore/css/StyleBuilder.cpp
r125716 r125925 1212 1212 1213 1213 if (primitiveValue->getIdent() == CSSValueNormal) 1214 lineHeight = Length(-100.0, Percent);1214 lineHeight = RenderStyle::initialLineHeight(); 1215 1215 else if (primitiveValue->isLength()) { 1216 1216 double multiplier = styleResolver->style()->effectiveZoom(); … … 1234 1234 static PropertyHandler createHandler() 1235 1235 { 1236 PropertyHandler handler = ApplyPropertyDefaultBase<Length, &RenderStyle:: lineHeight, Length, &RenderStyle::setLineHeight, Length, &RenderStyle::initialLineHeight>::createHandler();1236 PropertyHandler handler = ApplyPropertyDefaultBase<Length, &RenderStyle::specifiedLineHeight, Length, &RenderStyle::setLineHeight, Length, &RenderStyle::initialLineHeight>::createHandler(); 1237 1237 return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue); 1238 1238 } -
trunk/Source/WebCore/css/StyleResolver.cpp
r125716 r125925 3670 3670 if (isInherit) { 3671 3671 FontDescription fontDescription = m_parentStyle->fontDescription(); 3672 m_style->setLineHeight(m_parentStyle-> lineHeight());3672 m_style->setLineHeight(m_parentStyle->specifiedLineHeight()); 3673 3673 m_lineHeightValue = 0; 3674 3674 setFontDescription(fontDescription); -
trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp
r120780 r125925 1088 1088 gPropertyWrappers->append(new FillLayersPropertyWrapper(CSSPropertyWebkitMaskSize, &RenderStyle::maskLayers, &RenderStyle::accessMaskLayers)); 1089 1089 1090 gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyFontSize, &RenderStyle::fontSize, &RenderStyle::setBlendedFontSize)); 1090 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyFontSize, 1091 // Must pass a specified size to setFontSize if Text Autosizing is enabled, but a computed size 1092 // if text zoom is enabled (if neither is enabled it's irrelevant as they're probably the same). 1093 // FIXME: Find some way to assert that text zoom isn't activated when Text Autosizing is compiled in. 1094 #if ENABLE(TEXT_AUTOSIZING) 1095 &RenderStyle::specifiedFontSize, 1096 #else 1097 &RenderStyle::computedFontSize, 1098 #endif 1099 &RenderStyle::setFontSize)); 1091 1100 gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyWebkitColumnRuleWidth, &RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth)); 1092 1101 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitColumnGap, &RenderStyle::columnGap, &RenderStyle::setColumnGap)); … … 1096 1105 gPropertyWrappers->append(new PropertyWrapper<short>(CSSPropertyWebkitBorderVerticalSpacing, &RenderStyle::verticalBorderSpacing, &RenderStyle::setVerticalBorderSpacing)); 1097 1106 gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyZIndex, &RenderStyle::zIndex, &RenderStyle::setZIndex)); 1098 gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyLineHeight, &RenderStyle:: lineHeight, &RenderStyle::setLineHeight));1107 gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyLineHeight, &RenderStyle::specifiedLineHeight, &RenderStyle::setLineHeight)); 1099 1108 gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyOutlineOffset, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset)); 1100 1109 gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyOutlineWidth, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth)); -
trunk/Source/WebCore/platform/blackberry/RenderThemeBlackBerry.cpp
r125811 r125925 789 789 style->setHeight(controlsHeight); 790 790 style->setPaddingRight(padding); 791 style->set BlendedFontSize(fontSize);791 style->setFontSize(static_cast<int>(fontSize)); 792 792 break; 793 793 case MediaVolumeSliderContainerPart: -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r125648 r125925 352 352 // Do not allow line-height to be smaller than our default. 353 353 if (textBlockStyle->fontMetrics().lineSpacing() > lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes)) 354 textBlockStyle->setLineHeight( Length(-100.0f, Percent));354 textBlockStyle->setLineHeight(RenderStyle::initialLineHeight()); 355 355 356 356 textBlockStyle->setDisplay(BLOCK); -
trunk/Source/WebCore/rendering/TextAutosizer.cpp
r124372 r125925 28 28 #include "InspectorInstrumentation.h" 29 29 #include "RenderObject.h" 30 #include "RenderStyle.h" 30 31 #include "RenderText.h" 31 32 #include "RenderView.h" … … 57 58 } 58 59 59 for (RenderObject* descendant = traverseNext(layoutRoot, layoutRoot); descendant; descendant = traverseNext(descendant, layoutRoot)) { 60 if (!treatAsInline(descendant)) 61 processBlock(toRenderBlock(descendant), windowSize); 60 for (RenderObject* descendant = layoutRoot->nextInPreOrder(layoutRoot); descendant; descendant = descendant->nextInPreOrder(layoutRoot)) { 61 if (isNotAnAutosizingContainer(descendant)) 62 continue; 63 processBox(toRenderBox(descendant), windowSize); 62 64 } 63 65 … … 65 67 } 66 68 67 void TextAutosizer::processB lock(RenderBlock* block, const IntSize& windowSize)69 void TextAutosizer::processBox(RenderBox* box, const IntSize& windowSize) 68 70 { 69 int windowLogicalWidth = b lock->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();70 float multiplier = static_cast<float>(b lock->logicalWidth()) / windowLogicalWidth; // FIXME: This is overly simplistic.71 int windowLogicalWidth = box->isHorizontalWritingMode() ? windowSize.width() : windowSize.height(); 72 float multiplier = static_cast<float>(box->logicalWidth()) / windowLogicalWidth; // FIXME: This is overly simplistic. 71 73 multiplier *= m_document->settings()->textAutosizingFontScaleFactor(); 72 74 73 75 if (multiplier < 1) 74 76 return; 75 for (RenderObject* descendant = traverseNext(block, block, treatAsInline); descendant; descendant = traverseNext(descendant, block, treatAsInline)) { 76 if (descendant->isText()) 77 processText(toRenderText(descendant), multiplier); 77 RenderObject* descendant = nextInPreOrderMatchingFilter(box, box, isNotAnAutosizingContainer); 78 while (descendant) { 79 if (descendant->isText()) { 80 setMultiplier(descendant, multiplier); 81 setMultiplier(descendant->parent(), multiplier); // Parent does line spacing. 82 // FIXME: Increase list marker size proportionately. 83 } 84 descendant = nextInPreOrderMatchingFilter(descendant, box, isNotAnAutosizingContainer); 78 85 } 79 86 } 80 87 81 void TextAutosizer:: processText(RenderText* text, float multiplier)88 void TextAutosizer::setMultiplier(RenderObject* renderer, float multiplier) 82 89 { 83 float specifiedSize = text->style()->fontDescription().specifiedSize(); 84 float newSize = specifiedSize * multiplier; // FIXME: This is overly simplistic. 85 86 RefPtr<RenderStyle> style = RenderStyle::clone(text->style()); 87 FontDescription fontDescription(style->fontDescription()); 88 fontDescription.setComputedSize(newSize); 89 style->setFontDescription(fontDescription); 90 style->font().update(style->font().fontSelector()); 91 text->setStyle(style.release()); 92 93 // FIXME: Increase computed line height proportionately. 94 // FIXME: Increase list marker size proportionately. 90 RefPtr<RenderStyle> newStyle = RenderStyle::clone(renderer->style()); 91 newStyle->setTextAutosizingMultiplier(multiplier); 92 renderer->setStyle(newStyle.release()); 95 93 } 96 94 97 bool TextAutosizer:: treatAsInline(const RenderObject* renderer)95 bool TextAutosizer::isNotAnAutosizingContainer(const RenderObject* renderer) 98 96 { 99 return !renderer->isRenderBlock() || renderer->isListItem() || renderer->isInlineBlockOrInlineTable(); 97 // "Autosizing containers" are the smallest unit for which we can enable/disable 98 // Text Autosizing. A uniform text size multiplier is enforced within them. 99 // - Must be RenderBoxes since they need a well-defined logicalWidth(). 100 // - Must not be inline, as different multipliers on one line looks terrible. 101 // - Must not be list items, as items in the same list should look consistent. 102 return !renderer->isBox() || renderer->isInline() || renderer->isListItem(); 100 103 } 101 104 102 // FIXME: Consider making this a method on RenderObject if it remains this generic. 103 RenderObject* TextAutosizer::traverseNext(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilter filter) 105 RenderObject* TextAutosizer::nextInPreOrderMatchingFilter(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilterFunctor filter) 104 106 { 105 for (RenderObject* child = current->firstChild(); child; child = child->nextSibling()) { 106 if (!filter || filter(child)) { 107 ASSERT(!stayWithin || child->isDescendantOf(stayWithin)); 107 for (RenderObject* child = current->firstChild(); child; child = child->nextSibling()) 108 if (filter(child)) 108 109 return child; 109 }110 }111 110 112 for ( RenderObject* ancestor = current; ancestor; ancestor = ancestor->parent()) {111 for (const RenderObject* ancestor = current; ancestor; ancestor = ancestor->parent()) { 113 112 if (ancestor == stayWithin) 114 113 return 0; 115 for (RenderObject* sibling = ancestor->nextSibling(); sibling; sibling = sibling->nextSibling()) { 116 if (!filter || filter(sibling)) { 117 ASSERT(!stayWithin || sibling->isDescendantOf(stayWithin)); 114 for (RenderObject* sibling = ancestor->nextSibling(); sibling; sibling = sibling->nextSibling()) 115 if (filter(sibling)) 118 116 return sibling; 119 }120 }121 117 } 122 118 -
trunk/Source/WebCore/rendering/TextAutosizer.h
r121920 r125925 37 37 38 38 class Document; 39 class RenderB lock;39 class RenderBox; 40 40 class RenderObject; 41 41 class RenderStyle; … … 55 55 explicit TextAutosizer(Document*); 56 56 57 void processB lock(RenderBlock*, const IntSize& windowSize);58 void processText(RenderText*, float multiplier);57 void processBox(RenderBox*, const IntSize& windowSize); 58 void setMultiplier(RenderObject*, float); 59 59 60 typedef bool (*RenderObjectFilter)(const RenderObject*); 61 static bool treatAsInline(const RenderObject*); 60 static bool isNotAnAutosizingContainer(const RenderObject*); 62 61 63 RenderObject* traverseNext(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilter = 0); 62 typedef bool (*RenderObjectFilterFunctor)(const RenderObject*); 63 // Use to traverse the tree of descendants, excluding any subtrees within that whose root doesn't pass the filter. 64 static RenderObject* nextInPreOrderMatchingFilter(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilterFunctor); 64 65 65 66 Document* m_document; -
trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp
r124512 r125925 72 72 scriptsStyle->setTextAlign(LEFT); 73 73 // Set this wrapper's font-size for its line-height & baseline position, for its children. 74 scriptsStyle->set BlendedFontSize(static_cast<int>(0.75 * style()->fontSize()));74 scriptsStyle->setFontSize(static_cast<int>(0.75 * style()->fontSize())); 75 75 } 76 76 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r125612 r125925 488 488 return StyleDifferenceLayout; 489 489 } 490 491 #if ENABLE(TEXT_AUTOSIZING) 492 if (visual->m_textAutosizingMultiplier != other->visual->m_textAutosizingMultiplier) 493 return StyleDifferenceLayout; 494 #endif 490 495 491 496 if (inherited->line_height != other->inherited->line_height … … 1185 1190 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->font.fontMetrics(); } 1186 1191 const FontDescription& RenderStyle::fontDescription() const { return inherited->font.fontDescription(); } 1192 float RenderStyle::specifiedFontSize() const { return fontDescription().specifiedSize(); } 1193 float RenderStyle::computedFontSize() const { return fontDescription().computedSize(); } 1187 1194 int RenderStyle::fontSize() const { return inherited->font.pixelSize(); } 1188 1195 … … 1199 1206 } 1200 1207 1201 Length RenderStyle::lineHeight() const { return inherited->line_height; } 1202 void RenderStyle::setLineHeight(Length v) { SET_VAR(inherited, line_height, v); } 1208 Length RenderStyle::specifiedLineHeight() const { return inherited->line_height; } 1209 Length RenderStyle::lineHeight() const 1210 { 1211 const Length& lh = inherited->line_height; 1212 #if ENABLE(TEXT_AUTOSIZING) 1213 // Unlike fontDescription().computedSize() and hence fontSize(), this is 1214 // recalculated on demand as we only store the specified line height. 1215 // FIXME: Should consider scaling the fixed part of any calc expressions 1216 // too, though this involves messily poking into CalcExpressionLength. 1217 float multiplier = textAutosizingMultiplier(); 1218 if (multiplier > 1 && lh.isFixed()) 1219 return Length(lh.value() * multiplier, Fixed); 1220 #endif 1221 return lh; 1222 } 1223 void RenderStyle::setLineHeight(Length specifiedLineHeight) { SET_VAR(inherited, line_height, specifiedLineHeight); } 1203 1224 1204 1225 int RenderStyle::computedLineHeight(RenderView* renderView) const 1205 1226 { 1206 const Length& lh = inherited->line_height;1227 const Length& lh = lineHeight(); 1207 1228 1208 1229 // Negative value means the line height is not set. Use the font's built-in spacing. … … 1222 1243 void RenderStyle::setLetterSpacing(int v) { inherited.access()->font.setLetterSpacing(v); } 1223 1244 1224 void RenderStyle::setBlendedFontSize(int size) 1225 { 1245 void RenderStyle::setFontSize(float size) 1246 { 1247 // size must be specifiedSize if Text Autosizing is enabled, but computedSize if text 1248 // zoom is enabled (if neither is enabled it's irrelevant as they're probably the same). 1249 1226 1250 FontSelector* currentFontSelector = font().fontSelector(); 1227 1251 FontDescription desc(fontDescription()); 1228 1252 desc.setSpecifiedSize(size); 1229 1253 desc.setComputedSize(size); 1254 1255 #if ENABLE(TEXT_AUTOSIZING) 1256 float multiplier = textAutosizingMultiplier(); 1257 if (multiplier > 1) { 1258 // FIXME: Large font sizes needn't be multiplied as much since they are already more legible. 1259 desc.setComputedSize(size * multiplier); 1260 } 1261 #endif 1262 1230 1263 setFontDescription(desc); 1231 1264 font().update(currentFontSelector); -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r125612 r125925 598 598 const FontMetrics& fontMetrics() const; 599 599 const FontDescription& fontDescription() const; 600 float specifiedFontSize() const; 601 float computedFontSize() const; 600 602 int fontSize() const; 603 604 #if ENABLE(TEXT_AUTOSIZING) 605 float textAutosizingMultiplier() const { return visual->m_textAutosizingMultiplier; } 606 #endif 601 607 602 608 Length textIndent() const { return rareInheritedData->indent; } … … 614 620 bool isLeftToRightDirection() const { return direction() == LTR; } 615 621 622 Length specifiedLineHeight() const; 616 623 Length lineHeight() const; 617 624 int computedLineHeight(RenderView* = 0) const; … … 1103 1110 1104 1111 bool setFontDescription(const FontDescription&); 1105 1106 // Only used for blending font sizes when animating, or MathML anonymous blocks. 1107 void setBlendedFontSize(int); 1112 // Only used for blending font sizes when animating, for MathML anonymous blocks, and for text autosizing. 1113 void setFontSize(float); 1114 1115 #if ENABLE(TEXT_AUTOSIZING) 1116 void setTextAutosizingMultiplier(float v) 1117 { 1118 SET_VAR(visual, m_textAutosizingMultiplier, v) 1119 setFontSize(fontDescription().specifiedSize()); 1120 } 1121 #endif 1108 1122 1109 1123 void setColor(const Color&); … … 1115 1129 void setTextDecoration(ETextDecoration v) { SET_VAR(visual, textDecoration, v); } 1116 1130 void setDirection(TextDirection v) { inherited_flags._direction = v; } 1117 void setLineHeight(Length );1131 void setLineHeight(Length specifiedLineHeight); 1118 1132 bool setZoom(float); 1119 1133 void setZoomWithoutReturnValue(float f) { setZoom(f); } -
trunk/Source/WebCore/rendering/style/StyleVisualData.cpp
r59629 r125925 30 30 : hasClip(false) 31 31 , textDecoration(RenderStyle::initialTextDecoration()) 32 #if ENABLE(TEXT_AUTOSIZING) 33 , m_textAutosizingMultiplier(1) 34 #endif 32 35 , m_zoom(RenderStyle::initialZoom()) 33 36 { … … 43 46 , hasClip(o.hasClip) 44 47 , textDecoration(o.textDecoration) 48 #if ENABLE(TEXT_AUTOSIZING) 49 , m_textAutosizingMultiplier(o.m_textAutosizingMultiplier) 50 #endif 45 51 , m_zoom(RenderStyle::initialZoom()) 46 52 { -
trunk/Source/WebCore/rendering/style/StyleVisualData.h
r97314 r125925 41 41 bool operator==(const StyleVisualData& o) const 42 42 { 43 return ( clip == o.clip && 44 hasClip == o.hasClip && 45 textDecoration == o.textDecoration && 46 m_zoom == o.m_zoom); 43 return clip == o.clip 44 && hasClip == o.hasClip 45 && textDecoration == o.textDecoration 46 #if ENABLE(TEXT_AUTOSIZING) 47 && m_textAutosizingMultiplier == o.m_textAutosizingMultiplier 48 #endif 49 && m_zoom == o.m_zoom; 47 50 } 48 51 bool operator!=(const StyleVisualData& o) const { return !(*this == o); } … … 51 54 bool hasClip : 1; 52 55 unsigned textDecoration : ETextDecorationBits; // Text decorations defined *only* by this element. 53 56 57 #if ENABLE(TEXT_AUTOSIZING) 58 float m_textAutosizingMultiplier; 59 #endif 54 60 float m_zoom; 55 61
Note: See TracChangeset
for help on using the changeset viewer.