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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 rendererParent = rendererParent->parent(); | 162 rendererParent = rendererParent->parent(); |
163 | 163 |
164 const unsigned parentHashValue = rendererParent ? getCachedHash(rendererPare
nt, true) : 0; | 164 const unsigned parentHashValue = rendererParent ? getCachedHash(rendererPare
nt, true) : 0; |
165 const unsigned hashes[2] = { parentHashValue, computeLocalHash(renderer) }; | 165 const unsigned hashes[2] = { parentHashValue, computeLocalHash(renderer) }; |
166 const unsigned combinedHashValue = hashMemory(hashes, sizeof(hashes)); | 166 const unsigned combinedHashValue = hashMemory(hashes, sizeof(hashes)); |
167 if (putInCacheIfAbsent) | 167 if (putInCacheIfAbsent) |
168 m_hashCache.add(renderer, combinedHashValue); | 168 m_hashCache.add(renderer, combinedHashValue); |
169 return combinedHashValue; | 169 return combinedHashValue; |
170 } | 170 } |
171 | 171 |
| 172 bool TextAutosizer::isApplicable() const |
| 173 { |
| 174 return m_document->settings() |
| 175 && m_document->settings()->textAutosizingEnabled() |
| 176 && m_document->page() |
| 177 && m_document->page()->mainFrame() |
| 178 && m_document->page()->mainFrame()->loader().stateMachine()->committedFi
rstRealDocumentLoad(); |
| 179 } |
| 180 |
172 void TextAutosizer::recalculateMultipliers() | 181 void TextAutosizer::recalculateMultipliers() |
173 { | 182 { |
| 183 if (!isApplicable()) |
| 184 return; |
| 185 |
174 RenderObject* renderer = m_document->renderer(); | 186 RenderObject* renderer = m_document->renderer(); |
175 while (renderer) { | 187 while (renderer) { |
176 if (renderer->style() && renderer->style()->textAutosizingMultiplier() !
= 1) | 188 if (renderer->style() && renderer->style()->textAutosizingMultiplier() !
= 1) |
177 setMultiplier(renderer, 1); | 189 setMultiplier(renderer, 1); |
178 renderer = renderer->nextInPreOrder(); | 190 renderer = renderer->nextInPreOrder(); |
179 } | 191 } |
180 } | 192 } |
181 | 193 |
182 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) | 194 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) |
183 { | 195 { |
184 TRACE_EVENT0("webkit", "TextAutosizer::processSubtree"); | 196 TRACE_EVENT0("webkit", "TextAutosizer::processSubtree"); |
185 | 197 |
186 if (!m_document->settings() || layoutRoot->view()->document().printing() ||
!m_document->page()) | 198 if (!isApplicable() || layoutRoot->view()->document().printing()) |
187 return false; | |
188 | |
189 bool textAutosizingEnabled = m_document->settings()->textAutosizingEnabled()
; | |
190 if (!textAutosizingEnabled) | |
191 return false; | 199 return false; |
192 | 200 |
193 LocalFrame* mainFrame = m_document->page()->mainFrame(); | 201 LocalFrame* mainFrame = m_document->page()->mainFrame(); |
194 TextAutosizingWindowInfo windowInfo; | 202 TextAutosizingWindowInfo windowInfo; |
195 | 203 |
196 if (!mainFrame->loader().stateMachine()->committedFirstRealDocumentLoad()) | |
197 return false; | |
198 | |
199 InspectorInstrumentation::willAutosizeText(layoutRoot); | 204 InspectorInstrumentation::willAutosizeText(layoutRoot); |
200 | 205 |
201 // Window area, in logical (density-independent) pixels. | 206 // Window area, in logical (density-independent) pixels. |
202 windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOver
ride(); | 207 windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOver
ride(); |
203 if (windowInfo.windowSize.isEmpty()) | 208 if (windowInfo.windowSize.isEmpty()) |
204 windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(In
cludeScrollbars); | 209 windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(In
cludeScrollbars); |
205 | 210 |
206 // Largest area of block that can be visible at once (assuming the main | 211 // Largest area of block that can be visible at once (assuming the main |
207 // frame doesn't get scaled to less than overview scale), in CSS pixels. | 212 // frame doesn't get scaled to less than overview scale), in CSS pixels. |
208 windowInfo.minLayoutSize = mainFrame->view()->layoutSize(); | 213 windowInfo.minLayoutSize = mainFrame->view()->layoutSize(); |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 if (i + 1 < clusterInfos.size()) { | 846 if (i + 1 < clusterInfos.size()) { |
842 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth(
); | 847 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth(
); |
843 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth
(); | 848 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth
(); |
844 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) | 849 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) |
845 groups.grow(groups.size() + 1); | 850 groups.grow(groups.size() + 1); |
846 } | 851 } |
847 } | 852 } |
848 } | 853 } |
849 | 854 |
850 } // namespace WebCore | 855 } // namespace WebCore |
OLD | NEW |