OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2012 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // | 209 // |
210 // Clusters are chosen using very similar criteria to CSS flow roots, aka | 210 // Clusters are chosen using very similar criteria to CSS flow roots, aka |
211 // block formatting contexts (http://w3.org/TR/css3-box/#flow-root), since | 211 // block formatting contexts (http://w3.org/TR/css3-box/#flow-root), since |
212 // flow roots correspond to box containers that behave somewhat | 212 // flow roots correspond to box containers that behave somewhat |
213 // independently from their parent (for example they don't overlap floats). | 213 // independently from their parent (for example they don't overlap floats). |
214 // The definition of a flow root also conveniently includes most of the | 214 // The definition of a flow root also conveniently includes most of the |
215 // ways that a box and its children can have significantly different width | 215 // ways that a box and its children can have significantly different width |
216 // from the box's parent (we want to avoid having significantly different | 216 // from the box's parent (we want to avoid having significantly different |
217 // width blocks within a cluster, since the narrower blocks would end up | 217 // width blocks within a cluster, since the narrower blocks would end up |
218 // larger than would otherwise be necessary). | 218 // larger than would otherwise be necessary). |
219 // Additionally, any containers that are wider than the |blockContainingAllT
ext| | 219 // Additionally, any containers that are wider or at least 200px narrower th
an |
220 // of their enclosing cluster also become clusters, since they need special | 220 // the |blockContainingAllText| of their enclosing cluster also become clust
ers, |
221 // treatment due to their width. | 221 // since they need special treatment due to their width. |
222 ASSERT(isAutosizingContainer(renderer)); | 222 ASSERT(isAutosizingContainer(renderer)); |
223 | 223 |
| 224 // Upper limit on the difference between the width of the parent block conta
ining all |
| 225 // text and that of a narrow child before the child becomes a cluster. |
| 226 const float maxWidthDifference = 200; |
| 227 |
| 228 if (parentBlockContainingAllText) { |
| 229 float contentWidth = renderer->contentLogicalWidth(); |
| 230 float clusterTextWidth = parentBlockContainingAllText->contentLogicalWid
th(); |
| 231 if (contentWidth > clusterTextWidth || (clusterTextWidth - contentWidth)
> maxWidthDifference) |
| 232 return true; |
| 233 } |
| 234 |
224 return renderer->isRenderView() | 235 return renderer->isRenderView() |
225 || renderer->isFloating() | 236 || renderer->isFloating() |
226 || renderer->isOutOfFlowPositioned() | 237 || renderer->isOutOfFlowPositioned() |
227 || renderer->isTableCell() | 238 || renderer->isTableCell() |
228 || renderer->isTableCaption() | 239 || renderer->isTableCaption() |
229 || renderer->isFlexibleBoxIncludingDeprecated() | 240 || renderer->isFlexibleBoxIncludingDeprecated() |
230 || renderer->hasColumns() | 241 || renderer->hasColumns() |
231 || renderer->containingBlock()->isHorizontalWritingMode() != renderer->i
sHorizontalWritingMode() | 242 || renderer->containingBlock()->isHorizontalWritingMode() != renderer->i
sHorizontalWritingMode() |
232 || renderer->style()->isDisplayReplacedType() | 243 || renderer->style()->isDisplayReplacedType(); |
233 || (parentBlockContainingAllText | |
234 && renderer->contentLogicalWidth() > parentBlockContainingAllText->c
ontentLogicalWidth()); | |
235 // FIXME: Tables need special handling to multiply all their columns by | 244 // FIXME: Tables need special handling to multiply all their columns by |
236 // the same amount even if they're different widths; so do hasColumns() | 245 // the same amount even if they're different widths; so do hasColumns() |
237 // containers, and probably flexboxes... | 246 // containers, and probably flexboxes... |
238 } | 247 } |
239 | 248 |
240 bool TextAutosizer::isAutosizingCluster(const RenderObject* object) | 249 bool TextAutosizer::isAutosizingCluster(const RenderObject* object) |
241 { | 250 { |
242 return isAutosizingContainer(object) && isAutosizingCluster(toRenderBlock(ob
ject), 0); | 251 return isAutosizingContainer(object) && isAutosizingCluster(toRenderBlock(ob
ject), 0); |
243 } | 252 } |
244 | 253 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 child = (direction == FirstToLast) ? child->nextSibling() : child->previ
ousSibling(); | 395 child = (direction == FirstToLast) ? child->nextSibling() : child->previ
ousSibling(); |
387 } | 396 } |
388 --depth; | 397 --depth; |
389 | 398 |
390 return 0; | 399 return 0; |
391 } | 400 } |
392 | 401 |
393 } // namespace WebCore | 402 } // namespace WebCore |
394 | 403 |
395 #endif // ENABLE(TEXT_AUTOSIZING) | 404 #endif // ENABLE(TEXT_AUTOSIZING) |
OLD | NEW |