| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // width blocks within a cluster, since the narrower blocks would end up | 345 // width blocks within a cluster, since the narrower blocks would end up |
| 346 // larger than would otherwise be necessary). | 346 // larger than would otherwise be necessary). |
| 347 return renderer->isRenderView() | 347 return renderer->isRenderView() |
| 348 || renderer->isFloating() | 348 || renderer->isFloating() |
| 349 || renderer->isOutOfFlowPositioned() | 349 || renderer->isOutOfFlowPositioned() |
| 350 || renderer->isTableCell() | 350 || renderer->isTableCell() |
| 351 || renderer->isTableCaption() | 351 || renderer->isTableCaption() |
| 352 || renderer->isFlexibleBoxIncludingDeprecated() | 352 || renderer->isFlexibleBoxIncludingDeprecated() |
| 353 || renderer->hasColumns() | 353 || renderer->hasColumns() |
| 354 || renderer->containingBlock()->isHorizontalWritingMode() != renderer->i
sHorizontalWritingMode() | 354 || renderer->containingBlock()->isHorizontalWritingMode() != renderer->i
sHorizontalWritingMode() |
| 355 || renderer->style()->isDisplayReplacedType(); | 355 || renderer->style()->isDisplayReplacedType() |
| 356 || renderer->isTextArea(); |
| 356 // FIXME: Tables need special handling to multiply all their columns by | 357 // FIXME: Tables need special handling to multiply all their columns by |
| 357 // the same amount even if they're different widths; so do hasColumns() | 358 // the same amount even if they're different widths; so do hasColumns() |
| 358 // containers, and probably flexboxes... | 359 // containers, and probably flexboxes... |
| 359 } | 360 } |
| 360 | 361 |
| 361 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosiz
ingClusterInfo& parentClusterInfo) | 362 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosiz
ingClusterInfo& parentClusterInfo) |
| 362 { | 363 { |
| 363 ASSERT(isAutosizingContainer(renderer)); | 364 ASSERT(isAutosizingContainer(renderer)); |
| 364 | 365 |
| 365 return isNarrowDescendant(renderer, parentClusterInfo) | 366 return isNarrowDescendant(renderer, parentClusterInfo) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 // Don't autosize clusters that contain less than 4 lines of text (in | 470 // Don't autosize clusters that contain less than 4 lines of text (in |
| 470 // practice less lines are required, since measureDescendantTextWidth | 471 // practice less lines are required, since measureDescendantTextWidth |
| 471 // assumes that characters are 1em wide, but most characters are narrower | 472 // assumes that characters are 1em wide, but most characters are narrower |
| 472 // than that, so we're overestimating their contribution to the linecount). | 473 // than that, so we're overestimating their contribution to the linecount). |
| 473 // | 474 // |
| 474 // This is to reduce the likelihood of autosizing things like headers and | 475 // This is to reduce the likelihood of autosizing things like headers and |
| 475 // footers, which can be quite visually distracting. The rationale is that | 476 // footers, which can be quite visually distracting. The rationale is that |
| 476 // if a cluster contains very few lines of text then it's ok to have to zoom | 477 // if a cluster contains very few lines of text then it's ok to have to zoom |
| 477 // in and pan from side to side to read each line, since if there are very | 478 // in and pan from side to side to read each line, since if there are very |
| 478 // few lines of text you'll only need to pan across once or twice. | 479 // few lines of text you'll only need to pan across once or twice. |
| 480 // |
| 481 // An exception to the 4 lines of text are the textarea clusters, which are |
| 482 // always autosized by default (i.e. threated as if they contain more than 4 |
| 483 // lines of text). This is to ensure that the text does not suddenly get |
| 484 // autosized when the user enters more than 4 lines of text. |
| 479 float totalTextWidth = 0; | 485 float totalTextWidth = 0; |
| 480 const float minLinesOfText = 4; | 486 const float minLinesOfText = 4; |
| 481 float minTextWidth = blockWidth * minLinesOfText; | 487 float minTextWidth = blockWidth * minLinesOfText; |
| 482 for (size_t i = 0; i < clusterInfos.size(); ++i) { | 488 for (size_t i = 0; i < clusterInfos.size(); ++i) { |
| 489 if (clusterInfos[i].root->isTextArea()) |
| 490 return true; |
| 483 measureDescendantTextWidth(clusterInfos[i].blockContainingAllText, clust
erInfos[i], minTextWidth, totalTextWidth); | 491 measureDescendantTextWidth(clusterInfos[i].blockContainingAllText, clust
erInfos[i], minTextWidth, totalTextWidth); |
| 484 if (totalTextWidth >= minTextWidth) | 492 if (totalTextWidth >= minTextWidth) |
| 485 return true; | 493 return true; |
| 486 } | 494 } |
| 487 return false; | 495 return false; |
| 488 } | 496 } |
| 489 | 497 |
| 490 void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, Tex
tAutosizingClusterInfo& clusterInfo, float minTextWidth, float& textWidth) | 498 void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, Tex
tAutosizingClusterInfo& clusterInfo, float minTextWidth, float& textWidth) |
| 491 { | 499 { |
| 492 bool skipLocalText = !containerShouldBeAutosized(container); | 500 bool skipLocalText = !containerShouldBeAutosized(container); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 if (i + 1 < clusterInfos.size()) { | 614 if (i + 1 < clusterInfos.size()) { |
| 607 float currentWidth = clusterInfos[i].root->contentLogicalWidth(); | 615 float currentWidth = clusterInfos[i].root->contentLogicalWidth(); |
| 608 float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth(); | 616 float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth(); |
| 609 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) | 617 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) |
| 610 groups.grow(groups.size() + 1); | 618 groups.grow(groups.size() + 1); |
| 611 } | 619 } |
| 612 } | 620 } |
| 613 } | 621 } |
| 614 | 622 |
| 615 } // namespace WebCore | 623 } // namespace WebCore |
| OLD | NEW |