Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: Source/core/rendering/FastTextAutosizer.cpp

Issue 320393003: Descend into inner blocks for inflateAutoTable. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // for column sizing. 408 // for column sizing.
409 for (RenderObject* section = table->firstChild(); section; section = section ->nextSibling()) { 409 for (RenderObject* section = table->firstChild(); section; section = section ->nextSibling()) {
410 if (!section->isTableSection()) 410 if (!section->isTableSection())
411 continue; 411 continue;
412 for (RenderTableRow* row = toRenderTableSection(section)->firstRow(); ro w; row = row->nextRow()) { 412 for (RenderTableRow* row = toRenderTableSection(section)->firstRow(); ro w; row = row->nextRow()) {
413 for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->ne xtCell()) { 413 for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->ne xtCell()) {
414 if (!cell->needsLayout()) 414 if (!cell->needsLayout())
415 continue; 415 continue;
416 416
417 beginLayout(cell); 417 beginLayout(cell);
418 inflate(cell); 418 inflate(cell, DescendToInnerBlocks);
419 endLayout(cell); 419 endLayout(cell);
420 } 420 }
421 } 421 }
422 } 422 }
423 } 423 }
424 424
425 void FastTextAutosizer::endLayout(RenderBlock* block) 425 void FastTextAutosizer::endLayout(RenderBlock* block)
426 { 426 {
427 ASSERT(shouldHandleLayout()); 427 ASSERT(shouldHandleLayout());
428 428
429 if (block == m_firstBlockToBeginLayout) { 429 if (block == m_firstBlockToBeginLayout) {
430 m_firstBlockToBeginLayout = 0; 430 m_firstBlockToBeginLayout = 0;
431 m_clusterStack.clear(); 431 m_clusterStack.clear();
432 m_superclusters.clear(); 432 m_superclusters.clear();
433 m_stylesRetainedDuringLayout.clear(); 433 m_stylesRetainedDuringLayout.clear();
434 #ifndef NDEBUG 434 #ifndef NDEBUG
435 m_blocksThatHaveBegunLayout.clear(); 435 m_blocksThatHaveBegunLayout.clear();
436 #endif 436 #endif
437 // Tables can create two layout scopes for the same block so the isEmpty 437 // Tables can create two layout scopes for the same block so the isEmpty
438 // check below is needed to guard against endLayout being called twice. 438 // check below is needed to guard against endLayout being called twice.
439 } else if (!m_clusterStack.isEmpty() && currentCluster()->m_root == block) { 439 } else if (!m_clusterStack.isEmpty() && currentCluster()->m_root == block) {
440 m_clusterStack.removeLast(); 440 m_clusterStack.removeLast();
441 } 441 }
442 } 442 }
443 443
444 float FastTextAutosizer::inflate(RenderObject* parent, float multiplier) 444 float FastTextAutosizer::inflate(RenderObject* parent, InflateBehavior behavior, float multiplier)
445 { 445 {
446 Cluster* cluster = currentCluster(); 446 Cluster* cluster = currentCluster();
447 bool hasTextChild = false; 447 bool hasTextChild = false;
448 448
449 RenderObject* child = 0; 449 RenderObject* child = 0;
450 if (parent->isRenderBlock() && parent->childrenInline()) 450 if (parent->isRenderBlock() && (parent->childrenInline() || behavior == Desc endToInnerBlocks))
451 child = toRenderBlock(parent)->firstChild(); 451 child = toRenderBlock(parent)->firstChild();
452 else if (parent->isRenderInline()) 452 else if (parent->isRenderInline())
453 child = toRenderInline(parent)->firstChild(); 453 child = toRenderInline(parent)->firstChild();
454 454
455 while (child) { 455 while (child) {
456 if (child->isText()) { 456 if (child->isText()) {
457 hasTextChild = true; 457 hasTextChild = true;
458 // We only calculate this multiplier on-demand to ensure the parent block of this text 458 // We only calculate this multiplier on-demand to ensure the parent block of this text
459 // has entered layout. 459 // has entered layout.
460 if (!multiplier) 460 if (!multiplier)
461 multiplier = cluster->m_flags & SUPPRESSING ? 1.0f : clusterMult iplier(cluster); 461 multiplier = cluster->m_flags & SUPPRESSING ? 1.0f : clusterMult iplier(cluster);
462 applyMultiplier(child, multiplier); 462 applyMultiplier(child, multiplier);
463 // FIXME: Investigate why MarkOnlyThis is sufficient. 463 // FIXME: Investigate why MarkOnlyThis is sufficient.
464 if (parent->isRenderInline()) 464 if (parent->isRenderInline())
465 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); 465 child->setPreferredLogicalWidthsDirty(MarkOnlyThis);
466 } else if (child->isRenderInline()) { 466 } else if (child->isRenderInline()) {
467 multiplier = inflate(child, multiplier); 467 multiplier = inflate(child, behavior, multiplier);
468 } else if (child->isRenderBlock() && behavior == DescendToInnerBlocks
469 && !classifyBlock(child, INDEPENDENT | EXPLICIT_WIDTH | SUPPRESSING) ) {
470 multiplier = inflate(child, behavior, multiplier);
pdr. 2014/06/10 03:42:10 This can lead to an assert or incorrect values in
skobes 2014/06/10 17:22:51 There is special logic in widthFromBlock to handle
468 } 471 }
469 child = child->nextSibling(); 472 child = child->nextSibling();
470 } 473 }
471 474
472 if (hasTextChild) { 475 if (hasTextChild) {
473 applyMultiplier(parent, multiplier); // Parent handles line spacing. 476 applyMultiplier(parent, multiplier); // Parent handles line spacing.
474 } else if (!parent->isListItem()) { 477 } else if (!parent->isListItem()) {
475 // For consistency, a block with no immediate text child should always h ave a 478 // For consistency, a block with no immediate text child should always h ave a
476 // multiplier of 1 (except for list items which are handled in inflateLi stItem). 479 // multiplier of 1 (except for list items which are handled in inflateLi stItem).
477 applyMultiplier(parent, 1); 480 applyMultiplier(parent, 1);
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() 1125 FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo()
1123 { 1126 {
1124 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto sizer()) { 1127 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto sizer()) {
1125 ASSERT(textAutosizer->m_updatePageInfoDeferred); 1128 ASSERT(textAutosizer->m_updatePageInfoDeferred);
1126 textAutosizer->m_updatePageInfoDeferred = false; 1129 textAutosizer->m_updatePageInfoDeferred = false;
1127 textAutosizer->updatePageInfoInAllFrames(); 1130 textAutosizer->updatePageInfoInAllFrames();
1128 } 1131 }
1129 } 1132 }
1130 1133
1131 } // namespace WebCore 1134 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698