Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 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> | |
|
mstensho (USE GERRIT)
2017/02/07 10:32:36
Shouldn't have to move this up here.
pdr.
2017/02/08 04:45:33
I think it's okay, it seems to be the new clang fo
cathiechentx
2017/02/08 07:07:41
yes, "git cl format" did this:)
| |
| 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 Loading... | |
| 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, cause these blocks already be inflated. | |
|
mstensho (USE GERRIT)
2017/02/07 10:32:36
"because these blocks are already inflated"?
cathiechentx
2017/02/08 07:07:41
Done.
| |
| 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 Loading... | |
| 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 if (parent->slowFirstChild() && parent->slowFirstChild()->isRubyRun()) { | |
|
mstensho (USE GERRIT)
2017/02/07 10:32:36
Might want to store parent->slowFirstChild() as a
cathiechentx
2017/02/08 07:07:41
Done.
| |
| 482 child = toLayoutRubyRun(parent->slowFirstChild())->firstChild(); | |
| 483 behavior = DescendToInnerBlocks; | |
| 484 } | |
| 485 } else if (parent->isLayoutBlock() && | |
| 486 (parent->childrenInline() || behavior == DescendToInnerBlocks)) | |
|
pdr.
2017/02/08 04:45:33
style nit: because curly braces were added for the
cathiechentx
2017/02/08 07:07:41
Done.
| |
| 475 child = toLayoutBlock(parent)->firstChild(); | 487 child = toLayoutBlock(parent)->firstChild(); |
| 476 else if (parent->isLayoutInline()) | 488 else if (parent->isLayoutInline()) |
| 477 child = toLayoutInline(parent)->firstChild(); | 489 child = toLayoutInline(parent)->firstChild(); |
| 478 | 490 |
| 479 while (child) { | 491 while (child) { |
| 480 if (child->isText()) { | 492 if (child->isText()) { |
| 481 hasTextChild = true; | 493 hasTextChild = true; |
| 482 // We only calculate this multiplier on-demand to ensure the parent block | 494 // We only calculate this multiplier on-demand to ensure the parent block |
| 483 // of this text has entered layout. | 495 // of this text has entered layout. |
| 484 if (!multiplier) | 496 if (!multiplier) |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 } | 1443 } |
| 1432 } | 1444 } |
| 1433 potentiallyInconsistentSuperclusters.clear(); | 1445 potentiallyInconsistentSuperclusters.clear(); |
| 1434 } | 1446 } |
| 1435 | 1447 |
| 1436 DEFINE_TRACE(TextAutosizer) { | 1448 DEFINE_TRACE(TextAutosizer) { |
| 1437 visitor->trace(m_document); | 1449 visitor->trace(m_document); |
| 1438 } | 1450 } |
| 1439 | 1451 |
| 1440 } // namespace blink | 1452 } // namespace blink |
| OLD | NEW |