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

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

Issue 189113014: TextAutosizer: unlock multipliers on DOMContentLoaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix TestExpectation to ImageOnlyFailure 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
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: check if needed"); 196 TRACE_EVENT0("webkit", "TextAutosizer: check if needed");
185 if (!m_document->settings() || layoutRoot->view()->document().printing() || !m_document->page())
186 return false;
187 197
188 bool textAutosizingEnabled = m_document->settings()->textAutosizingEnabled() ; 198 if (!isApplicable() || layoutRoot->view()->document().printing())
189 if (!textAutosizingEnabled)
190 return false; 199 return false;
191 200
192 LocalFrame* mainFrame = m_document->page()->mainFrame(); 201 LocalFrame* mainFrame = m_document->page()->mainFrame();
193 TextAutosizingWindowInfo windowInfo; 202 TextAutosizingWindowInfo windowInfo;
194 203
195 if (!mainFrame->loader().stateMachine()->committedFirstRealDocumentLoad())
196 return false;
197
198
199 // Window area, in logical (density-independent) pixels. 204 // Window area, in logical (density-independent) pixels.
200 windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOver ride(); 205 windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOver ride();
201 if (windowInfo.windowSize.isEmpty()) 206 if (windowInfo.windowSize.isEmpty())
202 windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(In cludeScrollbars); 207 windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(In cludeScrollbars);
203 208
204 // Largest area of block that can be visible at once (assuming the main 209 // Largest area of block that can be visible at once (assuming the main
205 // frame doesn't get scaled to less than overview scale), in CSS pixels. 210 // frame doesn't get scaled to less than overview scale), in CSS pixels.
206 windowInfo.minLayoutSize = mainFrame->view()->layoutSize(); 211 windowInfo.minLayoutSize = mainFrame->view()->layoutSize();
207 for (LocalFrame* frame = m_document->frame(); frame; frame = frame->tree().p arent()) 212 for (LocalFrame* frame = m_document->frame(); frame; frame = frame->tree().p arent())
208 windowInfo.minLayoutSize = windowInfo.minLayoutSize.shrunkTo(frame->view ()->layoutSize()); 213 windowInfo.minLayoutSize = windowInfo.minLayoutSize.shrunkTo(frame->view ()->layoutSize());
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 if (i + 1 < clusterInfos.size()) { 844 if (i + 1 < clusterInfos.size()) {
840 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( ); 845 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( );
841 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth (); 846 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth ();
842 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) 847 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup)
843 groups.grow(groups.size() + 1); 848 groups.grow(groups.size() + 1);
844 } 849 }
845 } 850 }
846 } 851 }
847 852
848 } // namespace WebCore 853 } // 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