OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/rendering/FastTextAutosizer.h" | 32 #include "core/rendering/FastTextAutosizer.h" |
33 | 33 |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/frame/Frame.h" | 35 #include "core/frame/Frame.h" |
36 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
37 #include "core/frame/Settings.h" | 37 #include "core/frame/Settings.h" |
| 38 #include "core/inspector/InspectorInstrumentation.h" |
38 #include "core/page/Page.h" | 39 #include "core/page/Page.h" |
39 #include "core/rendering/InlineIterator.h" | 40 #include "core/rendering/InlineIterator.h" |
40 #include "core/rendering/RenderBlock.h" | 41 #include "core/rendering/RenderBlock.h" |
41 #include "core/rendering/RenderListItem.h" | 42 #include "core/rendering/RenderListItem.h" |
42 #include "core/rendering/RenderListMarker.h" | 43 #include "core/rendering/RenderListMarker.h" |
43 #include "core/rendering/RenderView.h" | 44 #include "core/rendering/RenderView.h" |
44 #include "core/rendering/TextAutosizer.h" | 45 #include "core/rendering/TextAutosizer.h" |
45 | 46 |
46 using namespace std; | 47 using namespace std; |
47 | 48 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (!multiplier) | 146 if (!multiplier) |
146 multiplier = cluster->m_autosize ? clusterMultiplier(cluster) :
1.0f; | 147 multiplier = cluster->m_autosize ? clusterMultiplier(cluster) :
1.0f; |
147 applyMultiplier(descendant, multiplier); | 148 applyMultiplier(descendant, multiplier); |
148 applyMultiplier(descendant->parent(), multiplier); // Parent handles
line spacing. | 149 applyMultiplier(descendant->parent(), multiplier); // Parent handles
line spacing. |
149 } | 150 } |
150 } | 151 } |
151 } | 152 } |
152 | 153 |
153 bool FastTextAutosizer::enabled() | 154 bool FastTextAutosizer::enabled() |
154 { | 155 { |
155 return m_document->settings() | 156 if (!m_document->settings() || !m_document->page() || m_document->printing()
) |
156 && m_document->settings()->textAutosizingEnabled() | 157 return false; |
157 && !m_document->printing() | 158 |
158 && m_document->page(); | 159 return InspectorInstrumentation::overrideTextAutosizing(m_document->page(),
m_document->settings()->textAutosizingEnabled()); |
159 } | 160 } |
160 | 161 |
161 void FastTextAutosizer::prepareRenderViewInfo(RenderView* renderView) | 162 void FastTextAutosizer::prepareRenderViewInfo(RenderView* renderView) |
162 { | 163 { |
163 bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()->wr
itingMode()); | 164 bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()->wr
itingMode()); |
164 | 165 |
165 Frame* mainFrame = m_document->page()->mainFrame(); | 166 Frame* mainFrame = m_document->page()->mainFrame(); |
166 IntSize frameSize = m_document->settings()->textAutosizingWindowSizeOverride
(); | 167 IntSize frameSize = m_document->settings()->textAutosizingWindowSizeOverride
(); |
167 if (frameSize.isEmpty()) | 168 if (frameSize.isEmpty()) |
168 frameSize = mainFrame->view()->unscaledVisibleContentSize(ScrollableArea
::IncludeScrollbars); | 169 frameSize = mainFrame->view()->unscaledVisibleContentSize(ScrollableArea
::IncludeScrollbars); |
169 m_frameWidth = horizontalWritingMode ? frameSize.width() : frameSize.height(
); | 170 m_frameWidth = horizontalWritingMode ? frameSize.width() : frameSize.height(
); |
170 | 171 |
171 IntSize layoutSize = m_document->page()->mainFrame()->view()->layoutSize(); | 172 IntSize layoutSize = m_document->page()->mainFrame()->view()->layoutSize(); |
172 m_layoutWidth = horizontalWritingMode ? layoutSize.width() : layoutSize.heig
ht(); | 173 m_layoutWidth = horizontalWritingMode ? layoutSize.width() : layoutSize.heig
ht(); |
173 | 174 |
174 // Compute the base font scale multiplier based on device and accessibility
settings. | 175 // Compute the base font scale multiplier based on device and accessibility
settings. |
175 m_baseMultiplier = m_document->settings()->accessibilityFontScaleFactor(); | 176 m_baseMultiplier = m_document->settings()->accessibilityFontScaleFactor(); |
176 // If the page has a meta viewport or @viewport, don't apply the device scal
e adjustment. | 177 // If the page has a meta viewport or @viewport, don't apply the device scal
e adjustment. |
177 const ViewportDescription& viewportDescription = m_document->page()->mainFra
me()->document()->viewportDescription(); | 178 const ViewportDescription& viewportDescription = m_document->page()->mainFra
me()->document()->viewportDescription(); |
178 if (!viewportDescription.isSpecifiedByAuthor()) | 179 if (!viewportDescription.isSpecifiedByAuthor()) { |
179 m_baseMultiplier *= m_document->settings()->deviceScaleAdjustment(); | 180 float deviceScaleAdjustment = InspectorInstrumentation::overrideFontScal
eFactor(m_document->page(), m_document->settings()->deviceScaleAdjustment()); |
| 181 m_baseMultiplier *= deviceScaleAdjustment; |
| 182 } |
180 #ifndef NDEBUG | 183 #ifndef NDEBUG |
181 m_renderViewInfoPrepared = true; | 184 m_renderViewInfoPrepared = true; |
182 #endif | 185 #endif |
183 } | 186 } |
184 | 187 |
185 bool FastTextAutosizer::isFingerprintingCandidate(const RenderBlock* block) | 188 bool FastTextAutosizer::isFingerprintingCandidate(const RenderBlock* block) |
186 { | 189 { |
187 // FIXME: move the logic out of TextAutosizer.cpp into this class. | 190 // FIXME: move the logic out of TextAutosizer.cpp into this class. |
188 return block->isRenderView() | 191 return block->isRenderView() |
189 || (TextAutosizer::isAutosizingContainer(block) | 192 || (TextAutosizer::isAutosizingContainer(block) |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 503 } |
501 | 504 |
502 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO
bject* current, const RenderObject* stayWithin) | 505 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO
bject* current, const RenderObject* stayWithin) |
503 { | 506 { |
504 if (current == stayWithin || !current->isRenderBlock()) | 507 if (current == stayWithin || !current->isRenderBlock()) |
505 return current->nextInPreOrder(stayWithin); | 508 return current->nextInPreOrder(stayWithin); |
506 return current->nextInPreOrderAfterChildren(stayWithin); | 509 return current->nextInPreOrderAfterChildren(stayWithin); |
507 } | 510 } |
508 | 511 |
509 } // namespace WebCore | 512 } // namespace WebCore |
OLD | NEW |