|
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 119-125
void TextAutosizer::processCluster(RenderBlock* cluster, RenderBlock* container,
a/Source/WebCore/rendering/TextAutosizer.cpp_sec3
|
| 119 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
122 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
| 120 |
} |
123 |
} |
| 121 |
|
124 |
|
| 122 |
static bool contentHeightIsConstrained(const RenderBlock* container) |
125 |
bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container) |
|
|
126 |
{ |
| 127 |
Vector<QualifiedName> tags; |
| 128 |
tags.append(inputTag); |
| 129 |
tags.append(textareaTag); |
| 130 |
tags.append(buttonTag); |
| 131 |
tags.append(selectTag); |
| 132 |
if (containerContainsTags(container, tags)) |
| 133 |
return false; |
| 134 |
|
| 135 |
return !contentHeightIsConstrained(container); |
| 136 |
} |
| 137 |
|
| 138 |
bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container) |
| 123 |
{ |
139 |
{ |
| 124 |
// FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. |
140 |
// 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. |
141 |
// FIXME: This code needs to take into account vertical writing modes. |
|
Lines 143-149
void TextAutosizer::processContainer(float multiplier, RenderBlock* container, R
a/Source/WebCore/rendering/TextAutosizer.cpp_sec4
|
| 143 |
{ |
159 |
{ |
| 144 |
ASSERT(isAutosizingContainer(container)); |
160 |
ASSERT(isAutosizingContainer(container)); |
| 145 |
|
161 |
|
| 146 |
float localMultiplier = contentHeightIsConstrained(container) ? 1 : multiplier; |
162 |
float localMultiplier = containerShouldBeAutosized(container) ? multiplier : 1; |
| 147 |
|
163 |
|
| 148 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
164 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
| 149 |
while (descendant) { |
165 |
while (descendant) { |
|
Lines 211-216
bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec5
|
| 211 |
return false; |
227 |
return false; |
| 212 |
if (renderer->isListItem()) |
228 |
if (renderer->isListItem()) |
| 213 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
229 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
|
|
230 |
// avoid creating containers for text within text controls, buttons, or selection menus. |
| 231 |
RenderObject* parent = renderer->parent(); |
| 232 |
if (parent) { |
| 233 |
if (parent->isRenderButton() || parent->isTextControl() || parent->isMenuList()) |
| 234 |
return false; |
| 235 |
} |
| 236 |
|
| 214 |
return true; |
237 |
return true; |
| 215 |
} |
238 |
} |
| 216 |
|
239 |
|
|
Lines 271-279
bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAnce
a/Source/WebCore/rendering/TextAutosizer.cpp_sec6
|
| 271 |
return false; |
294 |
return false; |
| 272 |
} |
295 |
} |
| 273 |
|
296 |
|
|
|
297 |
bool TextAutosizer::containerContainsTags(const RenderObject* container, Vector<QualifiedName>& tags) |
| 298 |
{ |
| 299 |
const Node* containerNode = container->node(); |
| 300 |
bool validCandidate = containerNode && containerNode->isHTMLElement() && !containerNode->isShadowRoot(); |
| 301 |
if (validCandidate) { |
| 302 |
for (size_t i = 0; i < tags.size(); ++i) { |
| 303 |
if (containerNode->hasTagName(tags[i])) |
| 304 |
return true; |
| 305 |
} |
| 306 |
} |
| 307 |
|
| 308 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
| 309 |
while (descendant) { |
| 310 |
const Node* descendantNode = descendant->node(); |
| 311 |
bool validCandidate = descendantNode && descendantNode->isHTMLElement() && !descendantNode->isShadowRoot(); |
| 312 |
if (validCandidate) { |
| 313 |
for (size_t i = 0; i < tags.size(); ++i) { |
| 314 |
if (descendantNode->hasTagName(tags[i])) |
| 315 |
return true; |
| 316 |
} |
| 317 |
} |
| 318 |
descendant = nextInPreOrderSkippingDescendantsOfContainers(descendant, container); |
| 319 |
} |
| 320 |
return false; |
| 321 |
} |
| 322 |
|
| 274 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
323 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
| 275 |
{ |
324 |
{ |
| 276 |
bool skipLocalText = contentHeightIsConstrained(container); |
325 |
bool skipLocalText = !containerShouldBeAutosized(container); |
| 277 |
|
326 |
|
| 278 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
327 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
| 279 |
while (descendant) { |
328 |
while (descendant) { |
|
Lines 319-325
const RenderBlock* TextAutosizer::findDeepestBlockContainingAllText(const Render
a/Source/WebCore/rendering/TextAutosizer.cpp_sec7
|
| 319 |
const RenderObject* lastTextLeaf = findFirstTextLeafNotInCluster(cluster, lastDepth, LastToFirst); |
368 |
const RenderObject* lastTextLeaf = findFirstTextLeafNotInCluster(cluster, lastDepth, LastToFirst); |
| 320 |
ASSERT(lastTextLeaf); |
369 |
ASSERT(lastTextLeaf); |
| 321 |
|
370 |
|
| 322 |
// Equalize the depths if necessary. Only one of the while loops below will get executed. |
371 |
// Equalize the depths if containerShouldBeAutosized necessary. Only one of the while loops below will get executed. |
| 323 |
const RenderObject* firstNode = firstTextLeaf; |
372 |
const RenderObject* firstNode = firstTextLeaf; |
| 324 |
const RenderObject* lastNode = lastTextLeaf; |
373 |
const RenderObject* lastNode = lastTextLeaf; |
| 325 |
while (firstDepth > lastDepth) { |
374 |
while (firstDepth > lastDepth) { |