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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // have the same specified font size. | 187 // have the same specified font size. |
188 // 3. It should not contain <br> elements. | 188 // 3. It should not contain <br> elements. |
189 // 4. It should contain only inline elements unless they are containers, | 189 // 4. It should contain only inline elements unless they are containers, |
190 // children of link elements or children of sub-containers. | 190 // children of link elements or children of sub-containers. |
191 int linkCount = 0; | 191 int linkCount = 0; |
192 LayoutObject* renderer = block->firstChild(); | 192 LayoutObject* renderer = block->firstChild(); |
193 float matchingFontSize = -1; | 193 float matchingFontSize = -1; |
194 | 194 |
195 while (renderer) { | 195 while (renderer) { |
196 if (!isPotentialClusterRoot(renderer)) { | 196 if (!isPotentialClusterRoot(renderer)) { |
197 if (renderer->isText() && toRenderText(renderer)->text().stripWhiteS
pace().length() > 3) | 197 if (renderer->isText() && toLayoutText(renderer)->text().stripWhiteS
pace().length() > 3) |
198 return false; | 198 return false; |
199 if (!renderer->isInline() || renderer->isBR()) | 199 if (!renderer->isInline() || renderer->isBR()) |
200 return false; | 200 return false; |
201 } | 201 } |
202 if (renderer->style()->isLink()) { | 202 if (renderer->style()->isLink()) { |
203 linkCount++; | 203 linkCount++; |
204 if (matchingFontSize < 0) | 204 if (matchingFontSize < 0) |
205 matchingFontSize = renderer->style()->specifiedFontSize(); | 205 matchingFontSize = renderer->style()->specifiedFontSize(); |
206 else if (matchingFontSize != renderer->style()->specifiedFontSize()) | 206 else if (matchingFontSize != renderer->style()->specifiedFontSize()) |
207 return false; | 207 return false; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 while (descendant) { | 647 while (descendant) { |
648 if (descendant->isLayoutBlock()) { | 648 if (descendant->isLayoutBlock()) { |
649 if (classifyBlock(descendant, INDEPENDENT | SUPPRESSING)) { | 649 if (classifyBlock(descendant, INDEPENDENT | SUPPRESSING)) { |
650 descendant = descendant->nextInPreOrderAfterChildren(root); | 650 descendant = descendant->nextInPreOrderAfterChildren(root); |
651 continue; | 651 continue; |
652 } | 652 } |
653 } else if (descendant->isText()) { | 653 } else if (descendant->isText()) { |
654 // Note: Using text().stripWhiteSpace().length() instead of rendered
TextLength() because | 654 // Note: Using text().stripWhiteSpace().length() instead of rendered
TextLength() because |
655 // the lineboxes will not be built until layout. These values can be
different. | 655 // the lineboxes will not be built until layout. These values can be
different. |
656 // Note: This is an approximation assuming each character is 1em wid
e. | 656 // Note: This is an approximation assuming each character is 1em wid
e. |
657 length += toRenderText(descendant)->text().stripWhiteSpace().length(
) * descendant->style()->specifiedFontSize(); | 657 length += toLayoutText(descendant)->text().stripWhiteSpace().length(
) * descendant->style()->specifiedFontSize(); |
658 | 658 |
659 if (length >= minimumTextLengthToAutosize) { | 659 if (length >= minimumTextLengthToAutosize) { |
660 cluster->m_hasEnoughTextToAutosize = HasEnoughText; | 660 cluster->m_hasEnoughTextToAutosize = HasEnoughText; |
661 return true; | 661 return true; |
662 } | 662 } |
663 } | 663 } |
664 descendant = descendant->nextInPreOrder(root); | 664 descendant = descendant->nextInPreOrder(root); |
665 } | 665 } |
666 | 666 |
667 cluster->m_hasEnoughTextToAutosize = NotEnoughText; | 667 cluster->m_hasEnoughTextToAutosize = NotEnoughText; |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 } | 1174 } |
1175 return computedSize; | 1175 return computedSize; |
1176 } | 1176 } |
1177 | 1177 |
1178 DEFINE_TRACE(TextAutosizer) | 1178 DEFINE_TRACE(TextAutosizer) |
1179 { | 1179 { |
1180 visitor->trace(m_document); | 1180 visitor->trace(m_document); |
1181 } | 1181 } |
1182 | 1182 |
1183 } // namespace blink | 1183 } // namespace blink |
OLD | NEW |