Changeset 142287 in webkit
- Timestamp:
- Feb 8, 2013 8:40:52 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142283 r142287 1 2013-02-08 Anton Vayvod <avayvod@chromium.org> 2 3 [Text Autosizing] Split isAutosizingCluster into three independent checks 4 https://bugs.webkit.org/show_bug.cgi?id=109093 5 6 Refactoring to create more flexible version of isAutosizingCluster since there're more types 7 of autosizing cluster now: narrower than the parent cluster, wider than the parent cluster 8 and the one that doesn't depend on the parent cluster. 9 10 Reviewed by Kenneth Rohde Christiansen. 11 12 Refactoring, no test changes. 13 14 * rendering/TextAutosizer.cpp: 15 16 (WebCore::TextAutosizer::isNarrowDescendant): 17 18 Separate check for the container to be of the narrow-descendant type. Was a part of 19 isAutosizingCluster(). 20 21 (WebCore::TextAutosizer::isWiderDescendant): 22 23 Separate check for the container to be of the wider-descendant type. Was a part of 24 isAutosizingCluster(). 25 26 (WebCore::TextAutosizer::isIndependentDescendant): 27 28 Separate check for the container to be autosized separately from the ancestor cluster. 29 Checks for conditions independent of the aforementioned cluster. 30 31 (WebCore::TextAutosizer::isAutosizingCluster): 32 33 Handy method to check all separate conditions together. 34 35 (WebCore::TextAutosizer::processSubtree): 36 (WebCore::TextAutosizer::processCluster): 37 (WebCore::TextAutosizer::processContainer): 38 (WebCore::TextAutosizer::clusterShouldBeAutosized): 39 (WebCore::TextAutosizer::measureDescendantTextWidth): 40 (WebCore::TextAutosizer::findFirstTextLeafNotInCluster): 41 42 The methods above were updated to use new functions/arguments. 43 44 * rendering/TextAutosizer.h: 45 46 Updated/added method definitions. 47 1 48 2013-02-08 Vsevolod Vlasov <vsevik@chromium.org> 2 49 -
trunk/Source/WebCore/rendering/TextAutosizer.cpp
r141901 r142287 120 120 121 121 RenderBlock* cluster = container; 122 while (cluster && !isAutosizingCluster(cluster))122 while (cluster && (!isAutosizingContainer(cluster) || !isIndependentDescendant(cluster))) 123 123 cluster = cluster->containingBlock(); 124 124 … … 236 236 } 237 237 238 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo) 239 { 238 bool TextAutosizer::isNarrowDescendant(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo) 239 { 240 ASSERT(isAutosizingContainer(renderer)); 241 242 // Autosizing containers that are significantly narrower than the |blockContainingAllText| of 243 // their enclosing cluster may be acting as separate columns, hence must be autosized 244 // separately. For example the 2nd div in: 245 // <body> 246 // <div style="float: right; width: 50%"></div> 247 // <div style="width: 50%"></div> 248 // <body> 249 // is the left column, and should be autosized differently from the body. 250 // If however the container is only narrower by 150px or less, it's considered part of 251 // the enclosing cluster. This 150px limit is adjusted whenever a descendant container is 252 // less than 50px narrower than the current limit. 253 const float differenceFromMaxWidthDifference = 50; 254 float contentWidth = renderer->contentLogicalWidth(); 255 float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth(); 256 float widthDifference = clusterTextWidth - contentWidth; 257 258 if (widthDifference - parentClusterInfo->maxAllowedDifferenceFromTextWidth > differenceFromMaxWidthDifference) 259 return true; 260 261 parentClusterInfo->maxAllowedDifferenceFromTextWidth = std::max(widthDifference, parentClusterInfo->maxAllowedDifferenceFromTextWidth); 262 return false; 263 } 264 265 bool TextAutosizer::isWiderDescendant(const RenderBlock* renderer, const TextAutosizingClusterInfo* parentClusterInfo) 266 { 267 ASSERT(isAutosizingContainer(renderer)); 268 269 // Autosizing containers that are wider than the |blockContainingAllText| of their enclosing 270 // cluster are treated the same way as autosizing clusters to be autosized separately. 271 float contentWidth = renderer->contentLogicalWidth(); 272 float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth(); 273 return contentWidth > clusterTextWidth; 274 } 275 276 bool TextAutosizer::isIndependentDescendant(const RenderBlock* renderer) 277 { 278 ASSERT(isAutosizingContainer(renderer)); 279 240 280 // "Autosizing clusters" are special autosizing containers within which we 241 281 // want to enforce a uniform text size multiplier, in the hopes of making … … 257 297 // width blocks within a cluster, since the narrower blocks would end up 258 298 // larger than would otherwise be necessary). 259 // Additionally, any containers that are wider or at least 200px narrower than260 // the |blockContainingAllText| of their enclosing cluster also become clusters,261 // since they need special treatment due to their width.262 ASSERT(isAutosizingContainer(renderer));263 264 if (parentClusterInfo->blockContainingAllText) {265 float contentWidth = renderer->contentLogicalWidth();266 float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth();267 if (contentWidth > clusterTextWidth)268 return true;269 270 // The upper limit on how many pixels the difference between the renderer width271 // and its parent cluster width can exceed the current maximum difference by272 // before the object is considered to be a separate autosizing cluster.273 const float differenceFromMaxWidthDifference = 50;274 275 float widthDifference = clusterTextWidth - contentWidth;276 if (widthDifference - parentClusterInfo->maxAllowedDifferenceFromTextWidth > differenceFromMaxWidthDifference)277 return true;278 parentClusterInfo->maxAllowedDifferenceFromTextWidth = std::max(widthDifference, parentClusterInfo->maxAllowedDifferenceFromTextWidth);279 }280 281 299 return renderer->isRenderView() 282 300 || renderer->isFloating() … … 293 311 } 294 312 295 bool TextAutosizer::isAutosizingCluster(const RenderObject* object) 296 { 297 TextAutosizingClusterInfo emptyClusterInfo(0); 298 return isAutosizingContainer(object) && isAutosizingCluster(toRenderBlock(object), &emptyClusterInfo); 313 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo) 314 { 315 ASSERT(isAutosizingContainer(renderer)); 316 317 return isNarrowDescendant(renderer, parentClusterInfo) 318 || isWiderDescendant(renderer, parentClusterInfo) 319 || isIndependentDescendant(renderer); 299 320 } 300 321 … … 487 508 const RenderObject* child = (direction == FirstToLast) ? parent->firstChild() : parent->lastChild(); 488 509 while (child) { 489 if (!isAutosizingC luster(child)) {510 if (!isAutosizingContainer(child) || !isIndependentDescendant(toRenderBlock(child))) { 490 511 const RenderObject* leaf = findFirstTextLeafNotInCluster(child, depth, direction); 491 512 if (leaf) -
trunk/Source/WebCore/rendering/TextAutosizer.h
r141901 r142287 68 68 69 69 static bool isAutosizingContainer(const RenderObject*); 70 static bool isNarrowDescendant(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo); 71 static bool isWiderDescendant(const RenderBlock*, const TextAutosizingClusterInfo* parentClusterInfo); 72 static bool isIndependentDescendant(const RenderBlock*); 70 73 static bool isAutosizingCluster(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo); 71 static bool isAutosizingCluster(const RenderObject*);72 74 73 75 static bool containerShouldBeAutosized(const RenderBlock* container);
Note: See TracChangeset
for help on using the changeset viewer.