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

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

Issue 336553003: Change Page::m_mainFrame to be a Frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 6 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.cpp ('k') | Source/core/svg/graphics/SVGImage.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) 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 m_hashCache.add(renderer, combinedHashValue); 170 m_hashCache.add(renderer, combinedHashValue);
171 return combinedHashValue; 171 return combinedHashValue;
172 } 172 }
173 173
174 bool TextAutosizer::isApplicable() const 174 bool TextAutosizer::isApplicable() const
175 { 175 {
176 return m_document->settings() 176 return m_document->settings()
177 && m_document->settings()->textAutosizingEnabled() 177 && m_document->settings()->textAutosizingEnabled()
178 && m_document->page() 178 && m_document->page()
179 && m_document->page()->mainFrame() 179 && m_document->page()->mainFrame()
180 && m_document->page()->mainFrame()->loader().stateMachine()->committedFi rstRealDocumentLoad(); 180 && m_document->page()->deprecatedLocalMainFrame()->loader().stateMachine ()->committedFirstRealDocumentLoad();
181 } 181 }
182 182
183 void TextAutosizer::recalculateMultipliers() 183 void TextAutosizer::recalculateMultipliers()
184 { 184 {
185 if (!isApplicable() && !m_previouslyAutosized) 185 if (!isApplicable() && !m_previouslyAutosized)
186 return; 186 return;
187 187
188 RenderObject* renderer = m_document->renderView(); 188 RenderObject* renderer = m_document->renderView();
189 while (renderer) { 189 while (renderer) {
190 if (renderer->style() && renderer->style()->textAutosizingMultiplier() ! = 1) 190 if (renderer->style() && renderer->style()->textAutosizingMultiplier() ! = 1)
191 setMultiplier(renderer, 1); 191 setMultiplier(renderer, 1);
192 renderer = renderer->nextInPreOrder(); 192 renderer = renderer->nextInPreOrder();
193 } 193 }
194 m_previouslyAutosized = false; 194 m_previouslyAutosized = false;
195 } 195 }
196 196
197 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) 197 bool TextAutosizer::processSubtree(RenderObject* layoutRoot)
198 { 198 {
199 TRACE_EVENT0("webkit", "TextAutosizer: check if needed"); 199 TRACE_EVENT0("webkit", "TextAutosizer: check if needed");
200 200
201 if (!isApplicable() || layoutRoot->view()->document().printing()) 201 if (!isApplicable() || layoutRoot->view()->document().printing())
202 return false; 202 return false;
203 203
204 LocalFrame* mainFrame = m_document->page()->mainFrame(); 204 LocalFrame* mainFrame = m_document->page()->deprecatedLocalMainFrame();
205 TextAutosizingWindowInfo windowInfo; 205 TextAutosizingWindowInfo windowInfo;
206 206
207 // Window area, in logical (density-independent) pixels. 207 // Window area, in logical (density-independent) pixels.
208 windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOver ride(); 208 windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOver ride();
209 if (windowInfo.windowSize.isEmpty()) 209 if (windowInfo.windowSize.isEmpty())
210 windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(In cludeScrollbars); 210 windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(In cludeScrollbars);
211 211
212 // Largest area of block that can be visible at once (assuming the main 212 // Largest area of block that can be visible at once (assuming the main
213 // frame doesn't get scaled to less than overview scale), in CSS pixels. 213 // frame doesn't get scaled to less than overview scale), in CSS pixels.
214 windowInfo.minLayoutSize = mainFrame->view()->layoutSize(); 214 windowInfo.minLayoutSize = mainFrame->view()->layoutSize();
215 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().parent ()) { 215 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().parent ()) {
216 if (frame->isLocalFrame()) 216 windowInfo.minLayoutSize = windowInfo.minLayoutSize.shrunkTo(toLocalFram e(frame)->view()->layoutSize());
217 windowInfo.minLayoutSize = windowInfo.minLayoutSize.shrunkTo(toLocal Frame(frame)->view()->layoutSize());
218 } 217 }
219 218
220 // The layoutRoot could be neither a container nor a cluster, so walk up the tree till we find each of these. 219 // The layoutRoot could be neither a container nor a cluster, so walk up the tree till we find each of these.
221 RenderBlock* container = layoutRoot->isRenderBlock() ? toRenderBlock(layoutR oot) : layoutRoot->containingBlock(); 220 RenderBlock* container = layoutRoot->isRenderBlock() ? toRenderBlock(layoutR oot) : layoutRoot->containingBlock();
222 while (container && !isAutosizingContainer(container)) 221 while (container && !isAutosizingContainer(container))
223 container = container->containingBlock(); 222 container = container->containingBlock();
224 223
225 RenderBlock* cluster = container; 224 RenderBlock* cluster = container;
226 while (cluster && (!isAutosizingContainer(cluster) || !isIndependentDescenda nt(cluster))) 225 while (cluster && (!isAutosizingContainer(cluster) || !isIndependentDescenda nt(cluster)))
227 cluster = cluster->containingBlock(); 226 cluster = cluster->containingBlock();
(...skipping 27 matching lines...) Expand all
255 { 254 {
256 int logicalWindowWidth = isHorizontalWritingMode(writingMode) ? windowInfo.w indowSize.width() : windowInfo.windowSize.height(); 255 int logicalWindowWidth = isHorizontalWritingMode(writingMode) ? windowInfo.w indowSize.width() : windowInfo.windowSize.height();
257 int logicalLayoutWidth = isHorizontalWritingMode(writingMode) ? windowInfo.m inLayoutSize.width() : windowInfo.minLayoutSize.height(); 256 int logicalLayoutWidth = isHorizontalWritingMode(writingMode) ? windowInfo.m inLayoutSize.width() : windowInfo.minLayoutSize.height();
258 // 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.
259 float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth); 258 float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth);
260 259
261 float multiplier = logicalClusterWidth / logicalWindowWidth; 260 float multiplier = logicalClusterWidth / logicalWindowWidth;
262 multiplier *= m_document->settings()->accessibilityFontScaleFactor(); 261 multiplier *= m_document->settings()->accessibilityFontScaleFactor();
263 262
264 // If the page has a meta viewport or @viewport, don't apply the device scal e adjustment. 263 // If the page has a meta viewport or @viewport, don't apply the device scal e adjustment.
265 const ViewportDescription& viewportDescription = m_document->page()->mainFra me()->document()->viewportDescription(); 264 const ViewportDescription& viewportDescription = m_document->page()->depreca tedLocalMainFrame()->document()->viewportDescription();
266 if (!viewportDescription.isSpecifiedByAuthor()) { 265 if (!viewportDescription.isSpecifiedByAuthor()) {
267 float deviceScaleAdjustment = m_document->settings()->deviceScaleAdjustm ent(); 266 float deviceScaleAdjustment = m_document->settings()->deviceScaleAdjustm ent();
268 multiplier *= deviceScaleAdjustment; 267 multiplier *= deviceScaleAdjustment;
269 } 268 }
270 return std::max(1.0f, multiplier); 269 return std::max(1.0f, multiplier);
271 } 270 }
272 271
273 void TextAutosizer::processClusterInternal(TextAutosizingClusterInfo& clusterInf o, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindow Info& windowInfo, float multiplier) 272 void TextAutosizer::processClusterInternal(TextAutosizingClusterInfo& clusterInf o, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindow Info& windowInfo, float multiplier)
274 { 273 {
275 processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo ); 274 processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo );
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 if (i + 1 < clusterInfos.size()) { 847 if (i + 1 < clusterInfos.size()) {
849 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( ); 848 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( );
850 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth (); 849 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth ();
851 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) 850 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup)
852 groups.grow(groups.size() + 1); 851 groups.grow(groups.size() + 1);
853 } 852 }
854 } 853 }
855 } 854 }
856 855
857 } // namespace WebCore 856 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.cpp ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698