| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 368 } |
| 369 | 369 |
| 370 bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container) | 370 bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container) |
| 371 { | 371 { |
| 372 if (containerContainsOneOfTags(container, formInputTags())) | 372 if (containerContainsOneOfTags(container, formInputTags())) |
| 373 return false; | 373 return false; |
| 374 | 374 |
| 375 if (containerIsRowOfLinks(container)) | 375 if (containerIsRowOfLinks(container)) |
| 376 return false; | 376 return false; |
| 377 | 377 |
| 378 if (containerIsTextArea(container)) |
| 379 return false; |
| 380 |
| 378 // Don't autosize block-level text that can't wrap (as it's likely to | 381 // Don't autosize block-level text that can't wrap (as it's likely to |
| 379 // expand sideways and break the page's layout). | 382 // expand sideways and break the page's layout). |
| 380 if (!container->style()->autoWrap()) | 383 if (!container->style()->autoWrap()) |
| 381 return false; | 384 return false; |
| 382 | 385 |
| 383 return !contentHeightIsConstrained(container); | 386 return !contentHeightIsConstrained(container); |
| 384 } | 387 } |
| 385 | 388 |
| 386 bool TextAutosizer::containerContainsOneOfTags(const RenderBlock* container, con
st Vector<QualifiedName>& tags) | 389 bool TextAutosizer::containerContainsOneOfTags(const RenderBlock* container, con
st Vector<QualifiedName>& tags) |
| 387 { | 390 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 linkCount++; | 434 linkCount++; |
| 432 // Skip traversing descendants of the link. | 435 // Skip traversing descendants of the link. |
| 433 renderer = renderer->nextInPreOrderAfterChildren(container); | 436 renderer = renderer->nextInPreOrderAfterChildren(container); |
| 434 } else | 437 } else |
| 435 renderer = nextInPreOrderSkippingDescendantsOfContainers(renderer, c
ontainer); | 438 renderer = nextInPreOrderSkippingDescendantsOfContainers(renderer, c
ontainer); |
| 436 } | 439 } |
| 437 | 440 |
| 438 return (linkCount >= 3); | 441 return (linkCount >= 3); |
| 439 } | 442 } |
| 440 | 443 |
| 444 bool TextAutosizer::containerIsTextArea(const RenderBlock* container) |
| 445 { |
| 446 // Don't autosize textareas to prevent annoying oscillation when the entered
texts exceeds |
| 447 // 4 lines and the text inside the area suddenly gets boosted. |
| 448 const RenderObject* parentBlock = (container->parent()) ? container->parent(
) : container; |
| 449 return parentBlock->isTextArea(); |
| 450 } |
| 451 |
| 441 bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container) | 452 bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container) |
| 442 { | 453 { |
| 443 // FIXME: Propagate constrainedness down the tree, to avoid inefficiently wa
lking back up from each box. | 454 // FIXME: Propagate constrainedness down the tree, to avoid inefficiently wa
lking back up from each box. |
| 444 // FIXME: This code needs to take into account vertical writing modes. | 455 // FIXME: This code needs to take into account vertical writing modes. |
| 445 // FIXME: Consider additional heuristics, such as ignoring fixed heights if
the content is already overflowing before autosizing kicks in. | 456 // FIXME: Consider additional heuristics, such as ignoring fixed heights if
the content is already overflowing before autosizing kicks in. |
| 446 for (; container; container = container->containingBlock()) { | 457 for (; container; container = container->containingBlock()) { |
| 447 RenderStyle* style = container->style(); | 458 RenderStyle* style = container->style(); |
| 448 if (style->overflowY() >= OSCROLL) | 459 if (style->overflowY() >= OSCROLL) |
| 449 return false; | 460 return false; |
| 450 if (style->height().isSpecified() || style->maxHeight().isSpecified()) { | 461 if (style->height().isSpecified() || style->maxHeight().isSpecified()) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 if (i + 1 < clusterInfos.size()) { | 617 if (i + 1 < clusterInfos.size()) { |
| 607 float currentWidth = clusterInfos[i].root->contentLogicalWidth(); | 618 float currentWidth = clusterInfos[i].root->contentLogicalWidth(); |
| 608 float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth(); | 619 float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth(); |
| 609 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) | 620 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) |
| 610 groups.grow(groups.size() + 1); | 621 groups.grow(groups.size() + 1); |
| 611 } | 622 } |
| 612 } | 623 } |
| 613 } | 624 } |
| 614 | 625 |
| 615 } // namespace WebCore | 626 } // namespace WebCore |
| OLD | NEW |