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

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

Issue 138143004: [FastTextAutosizer] Refactor FTA::inflate() to be internal to FTA (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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/FastTextAutosizer.h ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('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) 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void FastTextAutosizer::beginLayout(RenderBlock* block) 76 void FastTextAutosizer::beginLayout(RenderBlock* block)
77 { 77 {
78 if (!enabled()) 78 if (!enabled())
79 return; 79 return;
80 80
81 if (block->isRenderView()) 81 if (block->isRenderView())
82 prepareRenderViewInfo(toRenderView(block)); 82 prepareRenderViewInfo(toRenderView(block));
83 83
84 if (shouldBeClusterRoot(block)) 84 if (shouldBeClusterRoot(block))
85 m_clusterStack.append(getOrCreateCluster(block)); 85 m_clusterStack.append(getOrCreateCluster(block));
86
87 if (block->childrenInline())
skobes 2014/01/15 01:12:20 Can a block return true for childrenInline() but h
pdr. 2014/01/15 07:08:54 Excellent catch, I found childrenInline() does not
88 inflate(block);
89 }
90
91 void FastTextAutosizer::endLayout(RenderBlock* block)
92 {
93 if (!enabled())
94 return;
95
96 if (!m_clusterStack.isEmpty() && m_clusterStack.last()->m_root == block)
97 m_clusterStack.removeLast();
86 } 98 }
87 99
88 void FastTextAutosizer::inflate(RenderBlock* block) 100 void FastTextAutosizer::inflate(RenderBlock* block)
89 { 101 {
90 if (m_clusterStack.isEmpty()) 102 if (m_clusterStack.isEmpty())
91 return; 103 return;
92 Cluster* cluster = m_clusterStack.last(); 104 Cluster* cluster = m_clusterStack.last();
93 105
94 // localMultiplier is used to prevent inflation of some containers such as a row of links. 106 // localMultiplier is used to prevent inflation of some containers such as a row of links.
95 float localMultiplier = TextAutosizer::containerShouldBeAutosized(block) ? c luster->m_multiplier : 1; 107 float localMultiplier = TextAutosizer::containerShouldBeAutosized(block) ? c luster->m_multiplier : 1;
96 108
97 // FIXME: Add an optimization to not do this walk if it's not needed.
98 for (InlineWalker walker(block); !walker.atEnd(); walker.advance()) { 109 for (InlineWalker walker(block); !walker.atEnd(); walker.advance()) {
99 RenderObject* inlineObj = walker.current(); 110 RenderObject* inlineObj = walker.current();
100 if (inlineObj->isText()) { 111 if (inlineObj->isText()) {
101 applyMultiplier(inlineObj, localMultiplier); 112 applyMultiplier(inlineObj, localMultiplier);
102 applyMultiplier(inlineObj->parent(), localMultiplier); // Parent han dles line spacing. 113 applyMultiplier(inlineObj->parent(), localMultiplier); // Parent han dles line spacing.
103 } 114 }
104 } 115 }
105 } 116 }
106 117
107 void FastTextAutosizer::endLayout(RenderBlock* block)
108 {
109 if (!enabled())
110 return;
111
112 if (!m_clusterStack.isEmpty() && m_clusterStack.last()->m_root == block)
113 m_clusterStack.removeLast();
114 }
115
116 bool FastTextAutosizer::enabled() 118 bool FastTextAutosizer::enabled()
117 { 119 {
118 return m_document->settings() 120 return m_document->settings()
119 && m_document->settings()->textAutosizingEnabled() 121 && m_document->settings()->textAutosizingEnabled()
120 && !m_document->printing() 122 && !m_document->printing()
121 && m_document->page(); 123 && m_document->page();
122 } 124 }
123 125
124 void FastTextAutosizer::prepareRenderViewInfo(RenderView* renderView) 126 void FastTextAutosizer::prepareRenderViewInfo(RenderView* renderView)
125 { 127 {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 { 278 {
277 return m_fingerprints.get(block); 279 return m_fingerprints.get(block);
278 } 280 }
279 281
280 FastTextAutosizer::BlockSet& FastTextAutosizer::FingerprintMapper::getBlocks(Ato micString fingerprint) 282 FastTextAutosizer::BlockSet& FastTextAutosizer::FingerprintMapper::getBlocks(Ato micString fingerprint)
281 { 283 {
282 return *m_blocksForFingerprint.get(fingerprint); 284 return *m_blocksForFingerprint.get(fingerprint);
283 } 285 }
284 286
285 } // namespace WebCore 287 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698