|
Lines 25-30
a/Source/WebCore/rendering/TextAutosizer.cpp_sec1
|
| 25 |
#include "TextAutosizer.h" |
25 |
#include "TextAutosizer.h" |
| 26 |
|
26 |
|
| 27 |
#include "Document.h" |
27 |
#include "Document.h" |
|
|
28 |
#include "HTMLElement.h" |
| 28 |
#include "InspectorInstrumentation.h" |
29 |
#include "InspectorInstrumentation.h" |
| 29 |
#include "RenderObject.h" |
30 |
#include "RenderObject.h" |
| 30 |
#include "RenderStyle.h" |
31 |
#include "RenderStyle.h" |
|
Lines 37-42
a/Source/WebCore/rendering/TextAutosizer.cpp_sec2
|
| 37 |
|
38 |
|
| 38 |
namespace WebCore { |
39 |
namespace WebCore { |
| 39 |
|
40 |
|
|
|
41 |
using namespace HTMLNames; |
| 42 |
|
| 40 |
struct TextAutosizingWindowInfo { |
43 |
struct TextAutosizingWindowInfo { |
| 41 |
IntSize windowSize; |
44 |
IntSize windowSize; |
| 42 |
IntSize minLayoutSize; |
45 |
IntSize minLayoutSize; |
|
Lines 89-94
bool TextAutosizer::processSubtree(RenderObject* layoutRoot)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec3
|
| 89 |
cluster = cluster->containingBlock(); |
92 |
cluster = cluster->containingBlock(); |
| 90 |
|
93 |
|
| 91 |
processCluster(cluster, container, layoutRoot, windowInfo); |
94 |
processCluster(cluster, container, layoutRoot, windowInfo); |
|
|
95 |
|
| 92 |
return true; |
96 |
return true; |
| 93 |
} |
97 |
} |
| 94 |
|
98 |
|
|
Lines 119-129
void TextAutosizer::processCluster(RenderBlock* cluster, RenderBlock* container,
a/Source/WebCore/rendering/TextAutosizer.cpp_sec4
|
| 119 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
123 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
| 120 |
} |
124 |
} |
| 121 |
|
125 |
|
| 122 |
static bool contentHeightIsConstrained(const RenderBlock* container) |
126 |
bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container) |
| 123 |
{ |
127 |
{ |
| 124 |
// FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. |
128 |
// FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. |
| 125 |
// FIXME: This code needs to take into account vertical writing modes. |
129 |
// FIXME: This code needs to take into account vertical writing modes. |
| 126 |
// FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in. |
130 |
// FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in. |
|
|
131 |
QualifiedName tags[4] = {inputTag, textareaTag, buttonTag, formTag}; |
| 132 |
if (containerContainsTags(container, tags, 4)) |
| 133 |
return true; |
| 134 |
|
| 127 |
for (; container; container = container->containingBlock()) { |
135 |
for (; container; container = container->containingBlock()) { |
| 128 |
RenderStyle* style = container->style(); |
136 |
RenderStyle* style = container->style(); |
| 129 |
if (style->overflowY() >= OSCROLL) |
137 |
if (style->overflowY() >= OSCROLL) |
|
Lines 211-216
bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec5
|
| 211 |
return false; |
219 |
return false; |
| 212 |
if (renderer->isListItem()) |
220 |
if (renderer->isListItem()) |
| 213 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
221 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
|
|
222 |
// avoid creating containers for text within text controls or buttons |
| 223 |
if (renderer->parent()) { |
| 224 |
if (renderer->parent()->isRenderButton() || renderer->parent()->isTextControl()) |
| 225 |
return false; |
| 226 |
} |
| 227 |
|
| 214 |
return true; |
228 |
return true; |
| 215 |
} |
229 |
} |
| 216 |
|
230 |
|
|
Lines 271-276
bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAnce
a/Source/WebCore/rendering/TextAutosizer.cpp_sec6
|
| 271 |
return false; |
285 |
return false; |
| 272 |
} |
286 |
} |
| 273 |
|
287 |
|
|
|
288 |
bool TextAutosizer::containerContainsTags(const RenderObject* container, const QualifiedName tags[], const size_t numTags) |
| 289 |
{ |
| 290 |
const Node* containerNode = container->node(); |
| 291 |
bool validCandidate = containerNode && containerNode->isHTMLElement() && !containerNode->isShadowRoot(); |
| 292 |
if (validCandidate) { |
| 293 |
for (size_t i = 0; i < numTags; ++i) { |
| 294 |
if (containerNode->hasTagName(tags[i])) |
| 295 |
return true; |
| 296 |
} |
| 297 |
} |
| 298 |
|
| 299 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
| 300 |
while (descendant) { |
| 301 |
const Node* descendantNode = descendant->node(); |
| 302 |
bool validCandidate = descendantNode && descendantNode->isHTMLElement() && !descendantNode->isShadowRoot(); |
| 303 |
if (validCandidate) { |
| 304 |
for (size_t i = 0; i < numTags; ++i) { |
| 305 |
if (descendantNode->hasTagName(tags[i])) |
| 306 |
return true; |
| 307 |
} |
| 308 |
} |
| 309 |
descendant = nextInPreOrderSkippingDescendantsOfContainers(descendant, container); |
| 310 |
} |
| 311 |
return false; |
| 312 |
} |
| 313 |
|
| 274 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
314 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
| 275 |
{ |
315 |
{ |
| 276 |
bool skipLocalText = contentHeightIsConstrained(container); |
316 |
bool skipLocalText = contentHeightIsConstrained(container); |
|
Lines 319-325
const RenderBlock* TextAutosizer::findDeepestBlockContainingAllText(const Render
a/Source/WebCore/rendering/TextAutosizer.cpp_sec7
|
| 319 |
const RenderObject* lastTextLeaf = findFirstTextLeafNotInCluster(cluster, lastDepth, LastToFirst); |
359 |
const RenderObject* lastTextLeaf = findFirstTextLeafNotInCluster(cluster, lastDepth, LastToFirst); |
| 320 |
ASSERT(lastTextLeaf); |
360 |
ASSERT(lastTextLeaf); |
| 321 |
|
361 |
|
| 322 |
// Equalize the depths if necessary. Only one of the while loops below will get executed. |
362 |
// Equalize the depths if contentHeightIsConstrainednecessary. Only one of the while loops below will get executed. |
| 323 |
const RenderObject* firstNode = firstTextLeaf; |
363 |
const RenderObject* firstNode = firstTextLeaf; |
| 324 |
const RenderObject* lastNode = lastTextLeaf; |
364 |
const RenderObject* lastNode = lastTextLeaf; |
| 325 |
while (firstDepth > lastDepth) { |
365 |
while (firstDepth > lastDepth) { |