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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 TextAutosizer::TextAutosizer(Document* document) | 85 TextAutosizer::TextAutosizer(Document* document) |
86 : m_document(document) | 86 : m_document(document) |
87 { | 87 { |
88 } | 88 } |
89 | 89 |
90 TextAutosizer::~TextAutosizer() | 90 TextAutosizer::~TextAutosizer() |
91 { | 91 { |
92 } | 92 } |
93 | 93 |
| 94 void TextAutosizer::recalculateMultipliers() |
| 95 { |
| 96 RenderObject* renderer = m_document->renderer(); |
| 97 while (renderer) { |
| 98 if (renderer->style() && renderer->style()->textAutosizingMultiplier() !
= 1) |
| 99 setMultiplier(renderer, 1); |
| 100 renderer = renderer->nextInPreOrder(); |
| 101 } |
| 102 } |
| 103 |
94 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) | 104 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) |
95 { | 105 { |
96 // FIXME: Text Autosizing should only be enabled when m_document->page()->ma
inFrame()->view()->useFixedLayout() | 106 // FIXME: Text Autosizing should only be enabled when m_document->page()->ma
inFrame()->view()->useFixedLayout() |
97 // is true, but for now it's useful to ignore this so that it can be tested
on desktop. | 107 // is true, but for now it's useful to ignore this so that it can be tested
on desktop. |
98 if (!m_document->settings() || !m_document->settings()->textAutosizingEnable
d() || layoutRoot->view()->printing() || !m_document->page()) | 108 if (!m_document->settings() || !m_document->settings()->textAutosizingEnable
d() || layoutRoot->view()->printing() || !m_document->page()) |
99 return false; | 109 return false; |
100 | 110 |
101 Frame* mainFrame = m_document->page()->mainFrame(); | 111 Frame* mainFrame = m_document->page()->mainFrame(); |
102 | 112 |
103 TextAutosizingWindowInfo windowInfo; | 113 TextAutosizingWindowInfo windowInfo; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 192 |
183 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, T
extAutosizingClusterInfo& clusterInfo, RenderObject* subtreeRoot, const TextAuto
sizingWindowInfo& windowInfo) | 193 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, T
extAutosizingClusterInfo& clusterInfo, RenderObject* subtreeRoot, const TextAuto
sizingWindowInfo& windowInfo) |
184 { | 194 { |
185 ASSERT(isAutosizingContainer(container)); | 195 ASSERT(isAutosizingContainer(container)); |
186 | 196 |
187 float localMultiplier = containerShouldBeAutosized(container) ? multiplier:
1; | 197 float localMultiplier = containerShouldBeAutosized(container) ? multiplier:
1; |
188 | 198 |
189 RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(sub
treeRoot, subtreeRoot); | 199 RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(sub
treeRoot, subtreeRoot); |
190 while (descendant) { | 200 while (descendant) { |
191 if (descendant->isText()) { | 201 if (descendant->isText()) { |
192 if (localMultiplier != descendant->style()->textAutosizingMultiplier
()) { | 202 if (localMultiplier != 1 && descendant->style()->textAutosizingMulti
plier() == 1) { |
193 setMultiplier(descendant, localMultiplier); | 203 setMultiplier(descendant, localMultiplier); |
194 setMultiplier(descendant->parent(), localMultiplier); // Parent
does line spacing. | 204 setMultiplier(descendant->parent(), localMultiplier); // Parent
does line spacing. |
195 } | 205 } |
196 // FIXME: Increase list marker size proportionately. | 206 // FIXME: Increase list marker size proportionately. |
197 } else if (isAutosizingContainer(descendant)) { | 207 } else if (isAutosizingContainer(descendant)) { |
198 RenderBlock* descendantBlock = toRenderBlock(descendant); | 208 RenderBlock* descendantBlock = toRenderBlock(descendant); |
199 TextAutosizingClusterInfo descendantClusterInfo(descendantBlock); | 209 TextAutosizingClusterInfo descendantClusterInfo(descendantBlock); |
200 if (isWiderDescendant(descendantBlock, clusterInfo) || isIndependent
Descendant(descendantBlock)) | 210 if (isWiderDescendant(descendantBlock, clusterInfo) || isIndependent
Descendant(descendantBlock)) |
201 processCluster(descendantClusterInfo, descendantBlock, descendan
tBlock, windowInfo); | 211 processCluster(descendantClusterInfo, descendantBlock, descendan
tBlock, windowInfo); |
202 else if (isNarrowDescendant(descendantBlock, clusterInfo)) { | 212 else if (isNarrowDescendant(descendantBlock, clusterInfo)) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth(); | 602 float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth(); |
593 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) | 603 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) |
594 groups.grow(groups.size() + 1); | 604 groups.grow(groups.size() + 1); |
595 } | 605 } |
596 } | 606 } |
597 } | 607 } |
598 | 608 |
599 } // namespace WebCore | 609 } // namespace WebCore |
600 | 610 |
601 #endif // ENABLE(TEXT_AUTOSIZING) | 611 #endif // ENABLE(TEXT_AUTOSIZING) |
OLD | NEW |