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

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

Issue 295513003: add 'slow' prefix to RenderObject's firstChild() / lastChild() methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/TextAutosizer.h ('k') | Source/core/rendering/svg/RenderSVGInline.h » ('j') | 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 void TextAutosizer::setMultiplierForList(RenderObject* renderer, float multiplie r) 453 void TextAutosizer::setMultiplierForList(RenderObject* renderer, float multiplie r)
454 { 454 {
455 #ifndef NDEBUG 455 #ifndef NDEBUG
456 Node* parentNode = renderer->generatingNode(); 456 Node* parentNode = renderer->generatingNode();
457 ASSERT(parentNode); 457 ASSERT(parentNode);
458 ASSERT(isHTMLOListElement(parentNode) || isHTMLUListElement(parentNode)); 458 ASSERT(isHTMLOListElement(parentNode) || isHTMLUListElement(parentNode));
459 #endif 459 #endif
460 setMultiplier(renderer, multiplier); 460 setMultiplier(renderer, multiplier);
461 461
462 // Make sure all list items are autosized consistently. 462 // Make sure all list items are autosized consistently.
463 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) { 463 for (RenderObject* child = renderer->slowFirstChild(); child; child = child- >nextSibling()) {
464 if (child->isListItem() && child->style()->textAutosizingMultiplier() == 1) 464 if (child->isListItem() && child->style()->textAutosizingMultiplier() == 1)
465 setMultiplier(child, multiplier); 465 setMultiplier(child, multiplier);
466 } 466 }
467 } 467 }
468 468
469 float TextAutosizer::computeAutosizedFontSize(float specifiedSize, float multipl ier) 469 float TextAutosizer::computeAutosizedFontSize(float specifiedSize, float multipl ier)
470 { 470 {
471 // Somewhat arbitrary "pleasant" font size. 471 // Somewhat arbitrary "pleasant" font size.
472 const float pleasantSize = 16; 472 const float pleasantSize = 16;
473 473
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 // containingBlock() should never leave the cluster, since it only skips anc estors when finding the 788 // containingBlock() should never leave the cluster, since it only skips anc estors when finding the
789 // container of position:absolute/fixed blocks, and those cannot exist betwe en a cluster and its text 789 // container of position:absolute/fixed blocks, and those cannot exist betwe en a cluster and its text
790 // nodes lowest common ancestor as isAutosizingCluster would have made them into their own independent 790 // nodes lowest common ancestor as isAutosizingCluster would have made them into their own independent
791 // cluster. 791 // cluster.
792 RenderBlock* containingBlock = firstNode->containingBlock(); 792 RenderBlock* containingBlock = firstNode->containingBlock();
793 ASSERT(containingBlock->isDescendantOf(cluster)); 793 ASSERT(containingBlock->isDescendantOf(cluster));
794 794
795 return containingBlock; 795 return containingBlock;
796 } 796 }
797 797
798 const RenderObject* TextAutosizer::findFirstTextLeafNotInCluster(const RenderObj ect* parent, size_t& depth, TraversalDirection direction) 798 const RenderObject* TextAutosizer::findFirstTextLeafNotInCluster(const RenderBlo ck* parent, size_t& depth, TraversalDirection direction)
799 { 799 {
800 if (parent->isText()) 800 if (parent->isText())
801 return parent; 801 return parent;
802 802
803 ++depth; 803 ++depth;
804 const RenderObject* child = (direction == FirstToLast) ? parent->firstChild( ) : parent->lastChild(); 804 const RenderObject* child = (direction == FirstToLast) ? parent->firstChild( ) : parent->lastChild();
805 while (child) { 805 while (child) {
806 if (!isAutosizingContainer(child) || !isIndependentDescendant(toRenderBl ock(child))) { 806 if (!isAutosizingContainer(child) || !isIndependentDescendant(toRenderBl ock(child))) {
807 const RenderObject* leaf = findFirstTextLeafNotInCluster(child, dept h, direction); 807 const RenderObject* leaf = findFirstTextLeafNotInCluster(toRenderBlo ck(child), depth, direction);
808 if (leaf) 808 if (leaf)
809 return leaf; 809 return leaf;
810 } 810 }
811 child = (direction == FirstToLast) ? child->nextSibling() : child->previ ousSibling(); 811 child = (direction == FirstToLast) ? child->nextSibling() : child->previ ousSibling();
812 } 812 }
813 --depth; 813 --depth;
814 814
815 return 0; 815 return 0;
816 } 816 }
817 817
(...skipping 28 matching lines...) Expand all
846 if (i + 1 < clusterInfos.size()) { 846 if (i + 1 < clusterInfos.size()) {
847 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( ); 847 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( );
848 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth (); 848 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth ();
849 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) 849 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup)
850 groups.grow(groups.size() + 1); 850 groups.grow(groups.size() + 1);
851 } 851 }
852 } 852 }
853 } 853 }
854 854
855 } // namespace WebCore 855 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/TextAutosizer.h ('k') | Source/core/rendering/svg/RenderSVGInline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698