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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 return false; | 136 return false; |
137 const Element* element = toElement(node); | 137 const Element* element = toElement(node); |
138 | 138 |
139 return (element->isFormControlElement() && !isHTMLTextAreaElement(element)); | 139 return (element->isFormControlElement() && !isHTMLTextAreaElement(element)); |
140 } | 140 } |
141 | 141 |
142 static bool isPotentialClusterRoot(const LayoutObject* layoutObject) | 142 static bool isPotentialClusterRoot(const LayoutObject* layoutObject) |
143 { | 143 { |
144 // "Potential cluster roots" are the smallest unit for which we can | 144 // "Potential cluster roots" are the smallest unit for which we can |
145 // enable/disable text autosizing. | 145 // enable/disable text autosizing. |
146 // - Must have children. | |
147 // An exception is made for LayoutView which should create a root to | |
148 // maintain consistency with documents that have no child nodes but may | |
149 // still have LayoutObject children. | |
146 // - Must not be inline, as different multipliers on one line looks terrible . | 150 // - Must not be inline, as different multipliers on one line looks terrible . |
147 // Exceptions are inline-block and alike elements (inline-table, -webkit-i nline-*), | 151 // Exceptions are inline-block and alike elements (inline-table, -webkit-i nline-*), |
148 // as they often contain entire multi-line columns of text. | 152 // as they often contain entire multi-line columns of text. |
149 // - Must not be normal list items, as items in the same list should look | 153 // - Must not be normal list items, as items in the same list should look |
150 // consistent, unless they are floating or position:absolute/fixed. | 154 // consistent, unless they are floating or position:absolute/fixed. |
151 Node* node = layoutObject->generatingNode(); | 155 Node* node = layoutObject->generatingNode(); |
152 if (node && !node->hasChildren()) | 156 if (node && !node->hasChildren() && !layoutObject->isLayoutView()) |
mstensho (USE GERRIT)
2015/08/24 10:55:10
Not really a problem with your change here, but I
pdr.
2015/08/24 17:43:28
That's a good question and it's non-obvious.
The
skobes
2015/08/24 17:47:57
The LayoutView is special because it needs to be a
mstensho (USE GERRIT)
2015/08/24 17:51:49
So it's actually called during layout tree buildin
skobes
2015/08/24 17:57:37
It's called during layout. If I'm reading the bug
| |
153 return false; | 157 return false; |
154 if (!layoutObject->isLayoutBlock()) | 158 if (!layoutObject->isLayoutBlock()) |
155 return false; | 159 return false; |
156 if (layoutObject->isInline() && !layoutObject->style()->isDisplayReplacedTyp e()) | 160 if (layoutObject->isInline() && !layoutObject->style()->isDisplayReplacedTyp e()) |
157 return false; | 161 return false; |
158 if (layoutObject->isListItem()) | 162 if (layoutObject->isListItem()) |
159 return (layoutObject->isFloating() || layoutObject->isOutOfFlowPositione d()); | 163 return (layoutObject->isFloating() || layoutObject->isOutOfFlowPositione d()); |
160 | 164 |
161 return true; | 165 return true; |
162 } | 166 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 { | 312 { |
309 if (!m_pageInfo.m_settingEnabled && !m_fingerprintMapper.hasFingerprints()) | 313 if (!m_pageInfo.m_settingEnabled && !m_fingerprintMapper.hasFingerprints()) |
310 return; | 314 return; |
311 | 315 |
312 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); | 316 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); |
313 | 317 |
314 if (m_fingerprintMapper.remove(block) && m_firstBlockToBeginLayout) { | 318 if (m_fingerprintMapper.remove(block) && m_firstBlockToBeginLayout) { |
315 // LayoutBlock with a fingerprint was destroyed during layout. | 319 // LayoutBlock with a fingerprint was destroyed during layout. |
316 // Clear the cluster stack and the supercluster map to avoid stale point ers. | 320 // Clear the cluster stack and the supercluster map to avoid stale point ers. |
317 // Speculative fix for http://crbug.com/369485. | 321 // Speculative fix for http://crbug.com/369485. |
318 m_firstBlockToBeginLayout = 0; | 322 m_firstBlockToBeginLayout = nullptr; |
319 m_clusterStack.clear(); | 323 m_clusterStack.clear(); |
320 m_superclusters.clear(); | 324 m_superclusters.clear(); |
321 } | 325 } |
322 } | 326 } |
323 | 327 |
324 TextAutosizer::BeginLayoutBehavior TextAutosizer::prepareForLayout(const LayoutB lock* block) | 328 TextAutosizer::BeginLayoutBehavior TextAutosizer::prepareForLayout(const LayoutB lock* block) |
325 { | 329 { |
326 #if ENABLE(ASSERT) | 330 #if ENABLE(ASSERT) |
327 m_blocksThatHaveBegunLayout.add(block); | 331 m_blocksThatHaveBegunLayout.add(block); |
328 #endif | 332 #endif |
(...skipping 26 matching lines...) Expand all Loading... | |
355 } | 359 } |
356 } | 360 } |
357 | 361 |
358 void TextAutosizer::beginLayout(LayoutBlock* block) | 362 void TextAutosizer::beginLayout(LayoutBlock* block) |
359 { | 363 { |
360 ASSERT(shouldHandleLayout()); | 364 ASSERT(shouldHandleLayout()); |
361 | 365 |
362 if (prepareForLayout(block) == StopLayout) | 366 if (prepareForLayout(block) == StopLayout) |
363 return; | 367 return; |
364 | 368 |
369 ASSERT(!m_clusterStack.isEmpty() || block->isLayoutView()); | |
370 | |
365 if (Cluster* cluster = maybeCreateCluster(block)) | 371 if (Cluster* cluster = maybeCreateCluster(block)) |
366 m_clusterStack.append(adoptPtr(cluster)); | 372 m_clusterStack.append(adoptPtr(cluster)); |
367 | 373 |
374 ASSERT(!m_clusterStack.isEmpty()); | |
375 | |
368 // Cells in auto-layout tables are handled separately by inflateAutoTable. | 376 // Cells in auto-layout tables are handled separately by inflateAutoTable. |
369 bool isAutoTableCell = block->isTableCell() && !toLayoutTableCell(block)->ta ble()->style()->isFixedTableLayout(); | 377 bool isAutoTableCell = block->isTableCell() && !toLayoutTableCell(block)->ta ble()->style()->isFixedTableLayout(); |
370 if (!isAutoTableCell && !m_clusterStack.isEmpty()) | 378 if (!isAutoTableCell && !m_clusterStack.isEmpty()) |
371 inflate(block); | 379 inflate(block); |
372 } | 380 } |
373 | 381 |
374 void TextAutosizer::inflateAutoTable(LayoutTable* table) | 382 void TextAutosizer::inflateAutoTable(LayoutTable* table) |
375 { | 383 { |
376 ASSERT(table); | 384 ASSERT(table); |
377 ASSERT(!table->style()->isFixedTableLayout()); | 385 ASSERT(!table->style()->isFixedTableLayout()); |
(...skipping 19 matching lines...) Expand all Loading... | |
397 } | 405 } |
398 } | 406 } |
399 } | 407 } |
400 } | 408 } |
401 | 409 |
402 void TextAutosizer::endLayout(LayoutBlock* block) | 410 void TextAutosizer::endLayout(LayoutBlock* block) |
403 { | 411 { |
404 ASSERT(shouldHandleLayout()); | 412 ASSERT(shouldHandleLayout()); |
405 | 413 |
406 if (block == m_firstBlockToBeginLayout) { | 414 if (block == m_firstBlockToBeginLayout) { |
407 m_firstBlockToBeginLayout = 0; | 415 m_firstBlockToBeginLayout = nullptr; |
408 m_clusterStack.clear(); | 416 m_clusterStack.clear(); |
409 m_superclusters.clear(); | 417 m_superclusters.clear(); |
410 m_stylesRetainedDuringLayout.clear(); | 418 m_stylesRetainedDuringLayout.clear(); |
411 #if ENABLE(ASSERT) | 419 #if ENABLE(ASSERT) |
412 m_blocksThatHaveBegunLayout.clear(); | 420 m_blocksThatHaveBegunLayout.clear(); |
413 #endif | 421 #endif |
414 // Tables can create two layout scopes for the same block so the isEmpty | 422 // Tables can create two layout scopes for the same block so the isEmpty |
415 // check below is needed to guard against endLayout being called twice. | 423 // check below is needed to guard against endLayout being called twice. |
416 } else if (!m_clusterStack.isEmpty() && currentCluster()->m_root == block) { | 424 } else if (!m_clusterStack.isEmpty() && currentCluster()->m_root == block) { |
417 m_clusterStack.removeLast(); | 425 m_clusterStack.removeLast(); |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 } | 1181 } |
1174 return computedSize; | 1182 return computedSize; |
1175 } | 1183 } |
1176 | 1184 |
1177 DEFINE_TRACE(TextAutosizer) | 1185 DEFINE_TRACE(TextAutosizer) |
1178 { | 1186 { |
1179 visitor->trace(m_document); | 1187 visitor->trace(m_document); |
1180 } | 1188 } |
1181 | 1189 |
1182 } // namespace blink | 1190 } // namespace blink |
OLD | NEW |