OLD | NEW |
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 { | 173 { |
174 return m_document->settings() | 174 return m_document->settings() |
175 && m_document->settings()->textAutosizingEnabled() | 175 && m_document->settings()->textAutosizingEnabled() |
176 && m_document->page() | 176 && m_document->page() |
177 && m_document->page()->mainFrame() | 177 && m_document->page()->mainFrame() |
178 && m_document->page()->mainFrame()->loader().stateMachine()->committedFi
rstRealDocumentLoad(); | 178 && m_document->page()->mainFrame()->loader().stateMachine()->committedFi
rstRealDocumentLoad(); |
179 } | 179 } |
180 | 180 |
181 void TextAutosizer::recalculateMultipliers() | 181 void TextAutosizer::recalculateMultipliers() |
182 { | 182 { |
183 if (!isApplicable()) | 183 if (!isApplicable() && !m_previouslyAutosized) |
184 return; | 184 return; |
185 | 185 |
186 RenderObject* renderer = m_document->renderer(); | 186 RenderObject* renderer = m_document->renderer(); |
187 while (renderer) { | 187 while (renderer) { |
188 if (renderer->style() && renderer->style()->textAutosizingMultiplier() !
= 1) | 188 if (renderer->style() && renderer->style()->textAutosizingMultiplier() !
= 1) |
189 setMultiplier(renderer, 1); | 189 setMultiplier(renderer, 1); |
190 renderer = renderer->nextInPreOrder(); | 190 renderer = renderer->nextInPreOrder(); |
191 } | 191 } |
| 192 m_previouslyAutosized = false; |
192 } | 193 } |
193 | 194 |
194 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) | 195 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) |
195 { | 196 { |
196 TRACE_EVENT0("webkit", "TextAutosizer: check if needed"); | 197 TRACE_EVENT0("webkit", "TextAutosizer: check if needed"); |
197 | 198 |
198 if (!isApplicable() || layoutRoot->view()->document().printing()) | 199 if (!isApplicable() || layoutRoot->view()->document().printing()) |
199 return false; | 200 return false; |
200 | 201 |
201 LocalFrame* mainFrame = m_document->page()->mainFrame(); | 202 LocalFrame* mainFrame = m_document->page()->mainFrame(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 238 |
238 #ifdef AUTOSIZING_CLUSTER_HASH | 239 #ifdef AUTOSIZING_CLUSTER_HASH |
239 // Second pass to autosize stale non-autosized clusters for consistency. | 240 // Second pass to autosize stale non-autosized clusters for consistency. |
240 secondPassProcessStaleNonAutosizedClusters(); | 241 secondPassProcessStaleNonAutosizedClusters(); |
241 m_hashCache.clear(); | 242 m_hashCache.clear(); |
242 m_hashToMultiplier.clear(); | 243 m_hashToMultiplier.clear(); |
243 m_hashesToAutosizeSecondPass.clear(); | 244 m_hashesToAutosizeSecondPass.clear(); |
244 m_nonAutosizedClusters.clear(); | 245 m_nonAutosizedClusters.clear(); |
245 #endif | 246 #endif |
246 InspectorInstrumentation::didAutosizeText(layoutRoot); | 247 InspectorInstrumentation::didAutosizeText(layoutRoot); |
| 248 m_previouslyAutosized = true; |
247 return true; | 249 return true; |
248 } | 250 } |
249 | 251 |
250 float TextAutosizer::clusterMultiplier(WritingMode writingMode, const TextAutosi
zingWindowInfo& windowInfo, float textWidth) const | 252 float TextAutosizer::clusterMultiplier(WritingMode writingMode, const TextAutosi
zingWindowInfo& windowInfo, float textWidth) const |
251 { | 253 { |
252 int logicalWindowWidth = isHorizontalWritingMode(writingMode) ? windowInfo.w
indowSize.width() : windowInfo.windowSize.height(); | 254 int logicalWindowWidth = isHorizontalWritingMode(writingMode) ? windowInfo.w
indowSize.width() : windowInfo.windowSize.height(); |
253 int logicalLayoutWidth = isHorizontalWritingMode(writingMode) ? windowInfo.m
inLayoutSize.width() : windowInfo.minLayoutSize.height(); | 255 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. | 256 // Ignore box width in excess of the layout width, to avoid extreme multipli
ers. |
255 float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth); | 257 float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth); |
256 | 258 |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 if (i + 1 < clusterInfos.size()) { | 846 if (i + 1 < clusterInfos.size()) { |
845 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth(
); | 847 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth(
); |
846 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth
(); | 848 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth
(); |
847 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) | 849 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) |
848 groups.grow(groups.size() + 1); | 850 groups.grow(groups.size() + 1); |
849 } | 851 } |
850 } | 852 } |
851 } | 853 } |
852 | 854 |
853 } // namespace WebCore | 855 } // namespace WebCore |
OLD | NEW |