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

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

Issue 215063004: Reset multipliers correctly when autosizing is turned off. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add initializer. Created 6 years, 9 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/TextAutosizer.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) 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // consider for adding: writing mode, padding. 141 // consider for adding: writing mode, padding.
142 142
143 podForHash.width = style->width().getFloatValue(); 143 podForHash.width = style->width().getFloatValue();
144 } 144 }
145 145
146 return hashMemory(&podForHash, sizeof(podForHash)); 146 return hashMemory(&podForHash, sizeof(podForHash));
147 } 147 }
148 148
149 TextAutosizer::TextAutosizer(Document* document) 149 TextAutosizer::TextAutosizer(Document* document)
150 : m_document(document) 150 : m_document(document)
151 , m_previouslyAutosized(false)
151 { 152 {
152 } 153 }
153 154
154 unsigned TextAutosizer::getCachedHash(const RenderObject* renderer, bool putInCa cheIfAbsent) 155 unsigned TextAutosizer::getCachedHash(const RenderObject* renderer, bool putInCa cheIfAbsent)
155 { 156 {
156 HashMap<const RenderObject*, unsigned>::const_iterator it = m_hashCache.find (renderer); 157 HashMap<const RenderObject*, unsigned>::const_iterator it = m_hashCache.find (renderer);
157 if (it != m_hashCache.end()) 158 if (it != m_hashCache.end())
158 return it->value; 159 return it->value;
159 160
160 RenderObject* rendererParent = renderer->parent(); 161 RenderObject* rendererParent = renderer->parent();
(...skipping 12 matching lines...) Expand all
173 { 174 {
174 return m_document->settings() 175 return m_document->settings()
175 && m_document->settings()->textAutosizingEnabled() 176 && m_document->settings()->textAutosizingEnabled()
176 && m_document->page() 177 && m_document->page()
177 && m_document->page()->mainFrame() 178 && m_document->page()->mainFrame()
178 && m_document->page()->mainFrame()->loader().stateMachine()->committedFi rstRealDocumentLoad(); 179 && m_document->page()->mainFrame()->loader().stateMachine()->committedFi rstRealDocumentLoad();
179 } 180 }
180 181
181 void TextAutosizer::recalculateMultipliers() 182 void TextAutosizer::recalculateMultipliers()
182 { 183 {
183 if (!isApplicable()) 184 if (!isApplicable() && !m_previouslyAutosized)
184 return; 185 return;
185 186
186 RenderObject* renderer = m_document->renderer(); 187 RenderObject* renderer = m_document->renderer();
187 while (renderer) { 188 while (renderer) {
188 if (renderer->style() && renderer->style()->textAutosizingMultiplier() ! = 1) 189 if (renderer->style() && renderer->style()->textAutosizingMultiplier() ! = 1)
189 setMultiplier(renderer, 1); 190 setMultiplier(renderer, 1);
190 renderer = renderer->nextInPreOrder(); 191 renderer = renderer->nextInPreOrder();
191 } 192 }
193 m_previouslyAutosized = false;
192 } 194 }
193 195
194 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) 196 bool TextAutosizer::processSubtree(RenderObject* layoutRoot)
195 { 197 {
196 TRACE_EVENT0("webkit", "TextAutosizer: check if needed"); 198 TRACE_EVENT0("webkit", "TextAutosizer: check if needed");
197 199
198 if (!isApplicable() || layoutRoot->view()->document().printing()) 200 if (!isApplicable() || layoutRoot->view()->document().printing())
199 return false; 201 return false;
200 202
201 LocalFrame* mainFrame = m_document->page()->mainFrame(); 203 LocalFrame* mainFrame = m_document->page()->mainFrame();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 239
238 #ifdef AUTOSIZING_CLUSTER_HASH 240 #ifdef AUTOSIZING_CLUSTER_HASH
239 // Second pass to autosize stale non-autosized clusters for consistency. 241 // Second pass to autosize stale non-autosized clusters for consistency.
240 secondPassProcessStaleNonAutosizedClusters(); 242 secondPassProcessStaleNonAutosizedClusters();
241 m_hashCache.clear(); 243 m_hashCache.clear();
242 m_hashToMultiplier.clear(); 244 m_hashToMultiplier.clear();
243 m_hashesToAutosizeSecondPass.clear(); 245 m_hashesToAutosizeSecondPass.clear();
244 m_nonAutosizedClusters.clear(); 246 m_nonAutosizedClusters.clear();
245 #endif 247 #endif
246 InspectorInstrumentation::didAutosizeText(layoutRoot); 248 InspectorInstrumentation::didAutosizeText(layoutRoot);
249 m_previouslyAutosized = true;
247 return true; 250 return true;
248 } 251 }
249 252
250 float TextAutosizer::clusterMultiplier(WritingMode writingMode, const TextAutosi zingWindowInfo& windowInfo, float textWidth) const 253 float TextAutosizer::clusterMultiplier(WritingMode writingMode, const TextAutosi zingWindowInfo& windowInfo, float textWidth) const
251 { 254 {
252 int logicalWindowWidth = isHorizontalWritingMode(writingMode) ? windowInfo.w indowSize.width() : windowInfo.windowSize.height(); 255 int logicalWindowWidth = isHorizontalWritingMode(writingMode) ? windowInfo.w indowSize.width() : windowInfo.windowSize.height();
253 int logicalLayoutWidth = isHorizontalWritingMode(writingMode) ? windowInfo.m inLayoutSize.width() : windowInfo.minLayoutSize.height(); 256 int logicalLayoutWidth = isHorizontalWritingMode(writingMode) ? windowInfo.m inLayoutSize.width() : windowInfo.minLayoutSize.height();
254 // Ignore box width in excess of the layout width, to avoid extreme multipli ers. 257 // Ignore box width in excess of the layout width, to avoid extreme multipli ers.
255 float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth); 258 float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth);
256 259
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 if (i + 1 < clusterInfos.size()) { 847 if (i + 1 < clusterInfos.size()) {
845 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( ); 848 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( );
846 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth (); 849 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth ();
847 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) 850 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup)
848 groups.grow(groups.size() + 1); 851 groups.grow(groups.size() + 1);
849 } 852 }
850 } 853 }
851 } 854 }
852 855
853 } // namespace WebCore 856 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/TextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698