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

Side by Side Diff: third_party/WebKit/Source/core/layout/TextAutosizer.cpp

Issue 2683553002: Fix not autosizing ruby elements issue. (Closed)
Patch Set: Use MarkContainerChain for setPreferredLogicalWidthsDirty, when we skipped inline-block before Created 3 years, 10 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
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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/layout/TextAutosizer.h" 31 #include "core/layout/TextAutosizer.h"
32 32
33 #include <memory>
33 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
34 #include "core/frame/FrameHost.h" 35 #include "core/frame/FrameHost.h"
35 #include "core/frame/FrameView.h" 36 #include "core/frame/FrameView.h"
36 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
37 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
38 #include "core/frame/VisualViewport.h" 39 #include "core/frame/VisualViewport.h"
39 #include "core/html/HTMLTextAreaElement.h" 40 #include "core/html/HTMLTextAreaElement.h"
40 #include "core/layout/LayoutBlock.h" 41 #include "core/layout/LayoutBlock.h"
41 #include "core/layout/LayoutInline.h" 42 #include "core/layout/LayoutInline.h"
42 #include "core/layout/LayoutListItem.h" 43 #include "core/layout/LayoutListItem.h"
43 #include "core/layout/LayoutListMarker.h" 44 #include "core/layout/LayoutListMarker.h"
45 #include "core/layout/LayoutRubyRun.h"
44 #include "core/layout/LayoutTable.h" 46 #include "core/layout/LayoutTable.h"
45 #include "core/layout/LayoutTableCell.h" 47 #include "core/layout/LayoutTableCell.h"
46 #include "core/layout/LayoutView.h" 48 #include "core/layout/LayoutView.h"
47 #include "core/layout/api/LayoutAPIShim.h" 49 #include "core/layout/api/LayoutAPIShim.h"
48 #include "core/layout/api/LayoutViewItem.h" 50 #include "core/layout/api/LayoutViewItem.h"
49 #include "core/page/Page.h" 51 #include "core/page/Page.h"
50 #include "wtf/PtrUtil.h" 52 #include "wtf/PtrUtil.h"
51 #include <memory>
52 53
53 #ifdef AUTOSIZING_DOM_DEBUG_INFO 54 #ifdef AUTOSIZING_DOM_DEBUG_INFO
54 #include "core/dom/ExecutionContextTask.h" 55 #include "core/dom/ExecutionContextTask.h"
55 #endif 56 #endif
56 57
57 namespace blink { 58 namespace blink {
58 59
59 #ifdef AUTOSIZING_DOM_DEBUG_INFO 60 #ifdef AUTOSIZING_DOM_DEBUG_INFO
60 class WriteDebugInfoTask : public ExecutionContextTask { 61 class WriteDebugInfoTask : public ExecutionContextTask {
61 public: 62 public:
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 394 }
394 } 395 }
395 396
396 void TextAutosizer::beginLayout(LayoutBlock* block, 397 void TextAutosizer::beginLayout(LayoutBlock* block,
397 SubtreeLayoutScope* layouter) { 398 SubtreeLayoutScope* layouter) {
398 ASSERT(shouldHandleLayout()); 399 ASSERT(shouldHandleLayout());
399 400
400 if (prepareForLayout(block) == StopLayout) 401 if (prepareForLayout(block) == StopLayout)
401 return; 402 return;
402 403
404 // Skip ruby's inner blocks, because these blocks already be inflated.
pdr. 2017/02/10 04:10:46 nit: "...these blocks already are inflated."
cathiechentx 2017/02/10 05:17:47 Got it. Thank you :)
405 if (block->isRubyRun() || block->isRubyBase() || block->isRubyText())
406 return;
407
403 ASSERT(!m_clusterStack.isEmpty() || block->isLayoutView()); 408 ASSERT(!m_clusterStack.isEmpty() || block->isLayoutView());
404 409
405 if (Cluster* cluster = maybeCreateCluster(block)) 410 if (Cluster* cluster = maybeCreateCluster(block))
406 m_clusterStack.push_back(WTF::wrapUnique(cluster)); 411 m_clusterStack.push_back(WTF::wrapUnique(cluster));
407 412
408 ASSERT(!m_clusterStack.isEmpty()); 413 ASSERT(!m_clusterStack.isEmpty());
409 414
410 // Cells in auto-layout tables are handled separately by inflateAutoTable. 415 // Cells in auto-layout tables are handled separately by inflateAutoTable.
411 bool isAutoTableCell = 416 bool isAutoTableCell =
412 block->isTableCell() && 417 block->isTableCell() &&
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 468 }
464 469
465 float TextAutosizer::inflate(LayoutObject* parent, 470 float TextAutosizer::inflate(LayoutObject* parent,
466 SubtreeLayoutScope* layouter, 471 SubtreeLayoutScope* layouter,
467 InflateBehavior behavior, 472 InflateBehavior behavior,
468 float multiplier) { 473 float multiplier) {
469 Cluster* cluster = currentCluster(); 474 Cluster* cluster = currentCluster();
470 bool hasTextChild = false; 475 bool hasTextChild = false;
471 476
472 LayoutObject* child = nullptr; 477 LayoutObject* child = nullptr;
473 if (parent->isLayoutBlock() && 478 if (parent->isRuby()) {
474 (parent->childrenInline() || behavior == DescendToInnerBlocks)) 479 // Skip layoutRubyRun which is inline-block.
480 // Inflate rubyRun's inner blocks.
481 LayoutObject* run = parent->slowFirstChild();
482 if (run && run->isRubyRun()) {
483 child = toLayoutRubyRun(run)->firstChild();
484 behavior = SkippedInlineBlockAndDescendToInnerBlocks;
485 }
486 } else if (parent->isLayoutBlock() &&
487 (parent->childrenInline() || behavior == DescendToInnerBlocks)) {
475 child = toLayoutBlock(parent)->firstChild(); 488 child = toLayoutBlock(parent)->firstChild();
476 else if (parent->isLayoutInline()) 489 } else if (parent->isLayoutInline()) {
477 child = toLayoutInline(parent)->firstChild(); 490 child = toLayoutInline(parent)->firstChild();
491 }
478 492
479 while (child) { 493 while (child) {
480 if (child->isText()) { 494 if (child->isText()) {
481 hasTextChild = true; 495 hasTextChild = true;
482 // We only calculate this multiplier on-demand to ensure the parent block 496 // We only calculate this multiplier on-demand to ensure the parent block
483 // of this text has entered layout. 497 // of this text has entered layout.
484 if (!multiplier) 498 if (!multiplier)
485 multiplier = 499 multiplier =
486 cluster->m_flags & SUPPRESSING ? 1.0f : clusterMultiplier(cluster); 500 cluster->m_flags & SUPPRESSING ? 1.0f : clusterMultiplier(cluster);
487 applyMultiplier(child, multiplier, layouter); 501 applyMultiplier(child, multiplier, layouter);
488 502
489 // FIXME: Investigate why MarkOnlyThis is sufficient. 503 // FIXME: Investigate why MarkOnlyThis is sufficient.
490 if (parent->isLayoutInline()) 504 // If inlineBlocks have been skipped, we should use MarkContainerChain
505 // here.
506 if (behavior == SkippedInlineBlockAndDescendToInnerBlocks)
pdr. 2017/02/10 04:10:46 Nit: setPreferredLogicalWidthsDirty has lost its c
cathiechentx 2017/02/10 05:17:47 yes, it's much simpler. But rubyText is a block;(
pdr. 2017/02/10 19:27:09 Yeah, something like that seems good (just don't f
507 child->setPreferredLogicalWidthsDirty(MarkContainerChain);
508 else if (parent->isLayoutInline())
491 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); 509 child->setPreferredLogicalWidthsDirty(MarkOnlyThis);
492 } else if (child->isLayoutInline()) { 510 } else if (child->isLayoutInline()) {
493 multiplier = inflate(child, layouter, behavior, multiplier); 511 multiplier = inflate(child, layouter, behavior, multiplier);
494 } else if (child->isLayoutBlock() && behavior == DescendToInnerBlocks && 512 } else if (child->isLayoutBlock() && behavior >= DescendToInnerBlocks &&
495 !classifyBlock(child, 513 !classifyBlock(child,
496 INDEPENDENT | EXPLICIT_WIDTH | SUPPRESSING)) { 514 INDEPENDENT | EXPLICIT_WIDTH | SUPPRESSING)) {
497 multiplier = inflate(child, layouter, behavior, multiplier); 515 multiplier = inflate(child, layouter, behavior, multiplier);
498 } 516 }
499 child = child->nextSibling(); 517 child = child->nextSibling();
500 } 518 }
501 519
502 if (hasTextChild) { 520 if (hasTextChild) {
503 applyMultiplier(parent, multiplier, 521 applyMultiplier(parent, multiplier,
504 layouter); // Parent handles line spacing. 522 layouter); // Parent handles line spacing.
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 } 1449 }
1432 } 1450 }
1433 potentiallyInconsistentSuperclusters.clear(); 1451 potentiallyInconsistentSuperclusters.clear();
1434 } 1452 }
1435 1453
1436 DEFINE_TRACE(TextAutosizer) { 1454 DEFINE_TRACE(TextAutosizer) {
1437 visitor->trace(m_document); 1455 visitor->trace(m_document);
1438 } 1456 }
1439 1457
1440 } // namespace blink 1458 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698