Changeset 141901 in webkit
- Timestamp:
- Feb 5, 2013 10:36:33 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141893 r141901 1 2013-02-05 Anton Vayvod <avayvod@chromium.org> 2 3 TextAutosizing: adjust the maximum difference between cluster text width and its descendant 4 width. 5 https://bugs.webkit.org/show_bug.cgi?id=108411 6 7 Reviewed by Kenneth Rohde Christiansen. 8 9 Tests that certain width difference doesn't make descendants separate clusters. 10 11 * fast/text-autosizing/nested-child-expected.html: Added. 12 * fast/text-autosizing/nested-child.html: Added. 13 1 14 2013-02-05 Ádám Kallai <kadam@inf.u-szeged.hu> 2 15 -
trunk/Source/WebCore/ChangeLog
r141897 r141901 1 2013-02-05 Anton Vayvod <avayvod@chromium.org> 2 3 TextAutosizing: adjust the maximum difference between cluster text width and its descendant 4 width. 5 https://bugs.webkit.org/show_bug.cgi?id=108411 6 7 Currently, if a render object is more than 200 CSS units shorter than its parent cluster, it 8 becomes a separate autosizing cluster (see https://bugs.webkit.org/show_bug.cgi?id=105188). 9 This doesn't work well for layouts when narrow nodes are related, like nested comments: 10 deeper comments are all shorter than the parent cluster and become autosized differently. To 11 avoid that the difference that makes a shorter descendant a new autosizing cluster is 12 adjusted each time the width difference is not greater than 50 CSS units from the previous 13 one. This allows nested comments, for example, to remain a part of the parent cluster and be 14 autosized with the same multiplier. 15 16 Reviewed by Kenneth Rohde Christiansen. 17 18 Tests: 19 fast/text-autosizing/nested-child.html 20 21 * rendering/TextAutosizer.cpp: 22 (WebCore::TextAutosizingClusterInfo::TextAutosizingClusterInfo): 23 24 Added a new field to store the current maximum width difference for the cluster. 25 26 (WebCore::TextAutosizer::isAutosizingCluster): 27 28 Uses the new field to determine if the current node is a separate cluster, 29 updates the maximum allowed width difference between the cluster and its descendant. 30 31 (WebCore::TextAutosizer::processContainer): 32 (WebCore::TextAutosizer::clusterShouldBeAutosized): 33 (WebCore::TextAutosizer::measureDescendantTextWidth): 34 35 Non-const reference passed to the methods above. 36 37 * rendering/TextAutosizer.h: updated method parameters. 38 1 39 2013-02-05 Tony Gentilcore <tonyg@chromium.org> 2 40 -
trunk/Source/WebCore/rendering/TextAutosizer.cpp
r141489 r141901 52 52 : root(root) 53 53 , blockContainingAllText(0) 54 , maxAllowedDifferenceFromTextWidth(150) 54 55 { 55 56 } … … 57 58 RenderBlock* root; 58 59 const RenderBlock* blockContainingAllText; 60 61 // Upper limit on the difference between the width of the cluster's block containing all 62 // text and that of a narrow child before the child becomes a separate cluster. 63 float maxAllowedDifferenceFromTextWidth; 59 64 }; 60 65 … … 148 153 } 149 154 150 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, constTextAutosizingClusterInfo* clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)155 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo) 151 156 { 152 157 ASSERT(isAutosizingContainer(container)); … … 231 236 } 232 237 233 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, constTextAutosizingClusterInfo* parentClusterInfo)238 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo) 234 239 { 235 240 // "Autosizing clusters" are special autosizing containers within which we … … 257 262 ASSERT(isAutosizingContainer(renderer)); 258 263 259 // Upper limit on the difference between the width of the parent block containing all260 // text and that of a narrow child before the child becomes a cluster.261 const float maxWidthDifference = 200;262 263 264 if (parentClusterInfo->blockContainingAllText) { 264 265 float contentWidth = renderer->contentLogicalWidth(); 265 266 float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth(); 266 if (contentWidth > clusterTextWidth || (clusterTextWidth - contentWidth) > maxWidthDifference)267 if (contentWidth > clusterTextWidth) 267 268 return true; 269 270 // The upper limit on how many pixels the difference between the renderer width 271 // and its parent cluster width can exceed the current maximum difference by 272 // 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); 268 279 } 269 280 … … 379 390 } 380 391 381 bool TextAutosizer::clusterShouldBeAutosized( constTextAutosizingClusterInfo* clusterInfo, float blockWidth)392 bool TextAutosizer::clusterShouldBeAutosized(TextAutosizingClusterInfo* clusterInfo, float blockWidth) 382 393 { 383 394 // Don't autosize clusters that contain less than 4 lines of text (in … … 400 411 } 401 412 402 void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, constTextAutosizingClusterInfo* clusterInfo, float minTextWidth, float& textWidth)413 void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, float minTextWidth, float& textWidth) 403 414 { 404 415 bool skipLocalText = !containerShouldBeAutosized(container); -
trunk/Source/WebCore/rendering/TextAutosizer.h
r141489 r141901 63 63 64 64 void processCluster(TextAutosizingClusterInfo*, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&); 65 void processContainer(float multiplier, RenderBlock* container, constTextAutosizingClusterInfo*, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);65 void processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo*, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&); 66 66 67 67 void setMultiplier(RenderObject*, float); 68 68 69 69 static bool isAutosizingContainer(const RenderObject*); 70 static bool isAutosizingCluster(const RenderBlock*, constTextAutosizingClusterInfo* parentClusterInfo);70 static bool isAutosizingCluster(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo); 71 71 static bool isAutosizingCluster(const RenderObject*); 72 72 … … 75 75 static bool containerIsRowOfLinks(const RenderObject* container); 76 76 static bool contentHeightIsConstrained(const RenderBlock* container); 77 static bool clusterShouldBeAutosized( constTextAutosizingClusterInfo*, float blockWidth);78 static void measureDescendantTextWidth(const RenderBlock* container, constTextAutosizingClusterInfo*, float minTextWidth, float& textWidth);77 static bool clusterShouldBeAutosized(TextAutosizingClusterInfo*, float blockWidth); 78 static void measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo*, float minTextWidth, float& textWidth); 79 79 80 80 // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
Note: See TracChangeset
for help on using the changeset viewer.