OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 } | 885 } |
886 supercluster->m_hasEnoughTextToAutosize = NotEnoughText; | 886 supercluster->m_hasEnoughTextToAutosize = NotEnoughText; |
887 return false; | 887 return false; |
888 } | 888 } |
889 | 889 |
890 float TextAutosizer::superclusterMultiplier(Cluster* cluster) { | 890 float TextAutosizer::superclusterMultiplier(Cluster* cluster) { |
891 Supercluster* supercluster = cluster->m_supercluster; | 891 Supercluster* supercluster = cluster->m_supercluster; |
892 if (!supercluster->m_multiplier) { | 892 if (!supercluster->m_multiplier) { |
893 const LayoutBlock* widthProvider = | 893 const LayoutBlock* widthProvider = |
894 maxClusterWidthProvider(cluster->m_supercluster, cluster->m_root); | 894 maxClusterWidthProvider(cluster->m_supercluster, cluster->m_root); |
895 RELEASE_ASSERT(widthProvider); | 895 CHECK(widthProvider); |
896 supercluster->m_multiplier = | 896 supercluster->m_multiplier = |
897 superclusterHasEnoughTextToAutosize(supercluster, widthProvider, false) | 897 superclusterHasEnoughTextToAutosize(supercluster, widthProvider, false) |
898 ? multiplierFromBlock(widthProvider) | 898 ? multiplierFromBlock(widthProvider) |
899 : 1.0f; | 899 : 1.0f; |
900 } | 900 } |
901 ASSERT(supercluster->m_multiplier); | 901 ASSERT(supercluster->m_multiplier); |
902 return supercluster->m_multiplier; | 902 return supercluster->m_multiplier; |
903 } | 903 } |
904 | 904 |
905 const LayoutBlock* TextAutosizer::clusterWidthProvider( | 905 const LayoutBlock* TextAutosizer::clusterWidthProvider( |
(...skipping 23 matching lines...) Expand all Loading... |
929 float width = widthFromBlock(widthProvider); | 929 float width = widthFromBlock(widthProvider); |
930 if (width > maxWidth) { | 930 if (width > maxWidth) { |
931 maxWidth = width; | 931 maxWidth = width; |
932 result = widthProvider; | 932 result = widthProvider; |
933 } | 933 } |
934 } | 934 } |
935 return result; | 935 return result; |
936 } | 936 } |
937 | 937 |
938 float TextAutosizer::widthFromBlock(const LayoutBlock* block) const { | 938 float TextAutosizer::widthFromBlock(const LayoutBlock* block) const { |
939 RELEASE_ASSERT(block); | 939 CHECK(block); |
940 RELEASE_ASSERT(block->style()); | 940 CHECK(block->style()); |
941 | 941 |
942 if (!(block->isTable() || block->isTableCell() || block->isListItem())) | 942 if (!(block->isTable() || block->isTableCell() || block->isListItem())) |
943 return block->contentLogicalWidth().toFloat(); | 943 return block->contentLogicalWidth().toFloat(); |
944 | 944 |
945 if (!block->containingBlock()) | 945 if (!block->containingBlock()) |
946 return 0; | 946 return 0; |
947 | 947 |
948 // Tables may be inflated before computing their preferred widths. Try several | 948 // Tables may be inflated before computing their preferred widths. Try several |
949 // methods to obtain a width, and fall back on a containing block's width. | 949 // methods to obtain a width, and fall back on a containing block's width. |
950 for (; block; block = block->containingBlock()) { | 950 for (; block; block = block->containingBlock()) { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 } | 1372 } |
1373 } | 1373 } |
1374 potentiallyInconsistentSuperclusters.clear(); | 1374 potentiallyInconsistentSuperclusters.clear(); |
1375 } | 1375 } |
1376 | 1376 |
1377 DEFINE_TRACE(TextAutosizer) { | 1377 DEFINE_TRACE(TextAutosizer) { |
1378 visitor->trace(m_document); | 1378 visitor->trace(m_document); |
1379 } | 1379 } |
1380 | 1380 |
1381 } // namespace blink | 1381 } // namespace blink |
OLD | NEW |