Changeset 137738 in webkit
- Timestamp:
- Dec 14, 2012 3:58:39 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r137736 r137738 1 2012-12-14 John Mellor <johnme@chromium.org> 2 3 Text Autosizing: Don't autosize unwrappable blocks 4 https://bugs.webkit.org/show_bug.cgi?id=104925 5 6 Reviewed by Julien Chaffraix. 7 8 Added tests verifying that this prevents unwrappable blocks from being 9 autosized, and that this has no effect on unwrappable inlines. 10 11 * fast/text-autosizing/unwrappable-blocks-expected.html: Added. 12 * fast/text-autosizing/unwrappable-blocks.html: Added. 13 * fast/text-autosizing/unwrappable-inlines-expected.html: Added. 14 * fast/text-autosizing/unwrappable-inlines.html: Added. 15 1 16 2012-12-14 Kentaro Hara <haraken@chromium.org> 2 17 -
trunk/Source/WebCore/ChangeLog
r137737 r137738 1 2012-12-14 John Mellor <johnme@chromium.org> 2 3 Text Autosizing: Don't autosize unwrappable blocks 4 https://bugs.webkit.org/show_bug.cgi?id=104925 5 6 Reviewed by Julien Chaffraix. 7 8 If we autosize an unwrappable block (white-space:nowrap/pre), it'll 9 expand sideways. This doesn't actually improve its legibility, and it 10 can often severely break web page layouts. This patch prevents us from 11 autosizing unwrappable blocks. A follow-up patch will address the more 12 complex issue of unwrappable inline elements. 13 14 Tests: fast/text-autosizing/unwrappable-blocks.html 15 fast/text-autosizing/unwrappable-inlines.html 16 17 * rendering/TextAutosizer.cpp: 18 (WebCore::TextAutosizer::processContainer): 19 Use containerShouldbeAutosized instead of contentHeightIsConstrained. 20 (WebCore::contentHeightIsConstrained): 21 Unchanged, just moved lower down the file. 22 (WebCore::TextAutosizer::containerShouldbeAutosized): 23 Checks that the block is wrappable, and also that contentHeightIsConstrained is false. 24 (WebCore::TextAutosizer::measureDescendantTextWidth): 25 Use containerShouldbeAutosized instead of contentHeightIsConstrained. 26 * rendering/TextAutosizer.h: 27 Declared containerShouldbeAutosized. 28 1 29 2012-12-14 Vsevolod Vlasov <vsevik@chromium.org> 2 30 -
trunk/Source/WebCore/rendering/TextAutosizer.cpp
r136411 r137738 120 120 } 121 121 122 static bool contentHeightIsConstrained(const RenderBlock* container)123 {124 // FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box.125 // FIXME: This code needs to take into account vertical writing modes.126 // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in.127 for (; container; container = container->containingBlock()) {128 RenderStyle* style = container->style();129 if (style->overflowY() >= OSCROLL)130 return false;131 if (style->height().isSpecified() || style->maxHeight().isSpecified()) {132 // Some sites (e.g. wikipedia) set their html and/or body elements to height:100%,133 // without intending to constrain the height of the content within them.134 return !container->isRoot() && !container->isBody();135 }136 if (container->isFloatingOrOutOfFlowPositioned())137 return false;138 }139 return false;140 }141 142 122 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo) 143 123 { 144 124 ASSERT(isAutosizingContainer(container)); 145 125 146 float localMultiplier = cont entHeightIsConstrained(container) ? 1 : multiplier;126 float localMultiplier = containerShouldbeAutosized(container) ? multiplier: 1; 147 127 148 128 RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); … … 251 231 } 252 232 233 static bool contentHeightIsConstrained(const RenderBlock* container) 234 { 235 // FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. 236 // FIXME: This code needs to take into account vertical writing modes. 237 // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in. 238 for (; container; container = container->containingBlock()) { 239 RenderStyle* style = container->style(); 240 if (style->overflowY() >= OSCROLL) 241 return false; 242 if (style->height().isSpecified() || style->maxHeight().isSpecified()) { 243 // Some sites (e.g. wikipedia) set their html and/or body elements to height:100%, 244 // without intending to constrain the height of the content within them. 245 return !container->isRoot() && !container->isBody(); 246 } 247 if (container->isFloatingOrOutOfFlowPositioned()) 248 return false; 249 } 250 return false; 251 } 252 253 bool TextAutosizer::containerShouldbeAutosized(const RenderBlock* container) 254 { 255 // Don't autosize block-level text that can't wrap (as it's likely to 256 // expand sideways and break the page's layout). 257 if (!container->style()->autoWrap()) 258 return false; 259 260 return !contentHeightIsConstrained(container); 261 } 262 253 263 bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth) 254 264 { … … 274 284 void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) 275 285 { 276 bool skipLocalText = contentHeightIsConstrained(container);286 bool skipLocalText = !containerShouldbeAutosized(container); 277 287 278 288 RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); -
trunk/Source/WebCore/rendering/TextAutosizer.h
r136047 r137738 71 71 static bool isAutosizingCluster(const RenderBlock*); 72 72 73 static bool containerShouldbeAutosized(const RenderBlock* container); 73 74 static bool clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth); 74 75 static void measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth);
Note: See TracChangeset
for help on using the changeset viewer.