|
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-50
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; |
| 43 |
}; |
46 |
}; |
| 44 |
|
47 |
|
|
|
48 |
// holds the tags for the form input elements |
| 49 |
static Vector<QualifiedName> s_inputTags; |
| 50 |
|
| 45 |
TextAutosizer::TextAutosizer(Document* document) |
51 |
TextAutosizer::TextAutosizer(Document* document) |
| 46 |
: m_document(document) |
52 |
: m_document(document) |
| 47 |
{ |
53 |
{ |
|
|
54 |
s_inputTags.append(inputTag); |
| 55 |
s_inputTags.append(textareaTag); |
| 56 |
s_inputTags.append(buttonTag); |
| 57 |
s_inputTags.append(selectTag); |
| 48 |
} |
58 |
} |
| 49 |
|
59 |
|
| 50 |
TextAutosizer::~TextAutosizer() |
60 |
TextAutosizer::~TextAutosizer() |
|
Lines 119-125
void TextAutosizer::processCluster(RenderBlock* cluster, RenderBlock* container,
a/Source/WebCore/rendering/TextAutosizer.cpp_sec3
|
| 119 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
129 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
| 120 |
} |
130 |
} |
| 121 |
|
131 |
|
| 122 |
static bool contentHeightIsConstrained(const RenderBlock* container) |
132 |
bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container) |
|
|
133 |
{ |
| 134 |
if (containerContainsTags(container, s_inputTags)) |
| 135 |
return false; |
| 136 |
|
| 137 |
return !contentHeightIsConstrained(container); |
| 138 |
} |
| 139 |
|
| 140 |
bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container) |
| 123 |
{ |
141 |
{ |
| 124 |
// FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. |
142 |
// 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. |
143 |
// 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 |
{ |
161 |
{ |
| 144 |
ASSERT(isAutosizingContainer(container)); |
162 |
ASSERT(isAutosizingContainer(container)); |
| 145 |
|
163 |
|
| 146 |
float localMultiplier = contentHeightIsConstrained(container) ? 1 : multiplier; |
164 |
float localMultiplier = containerShouldBeAutosized(container) ? multiplier : 1; |
| 147 |
|
165 |
|
| 148 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
166 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
| 149 |
while (descendant) { |
167 |
while (descendant) { |
|
Lines 211-216
bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec5
|
| 211 |
return false; |
229 |
return false; |
| 212 |
if (renderer->isListItem()) |
230 |
if (renderer->isListItem()) |
| 213 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
231 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
|
|
232 |
// avoid creating containers for text within text controls, buttons, or selection menus. |
| 233 |
Node* parentNode = renderer->parent() ? renderer->parent()->generatingNode() : 0; |
| 234 |
if (parentNode && parentNode->isHTMLElement() && s_inputTags.contains(toElement(parentNode)->tagQName())) |
| 235 |
return false; |
| 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 RenderBlock* container, Vector<QualifiedName>& tags) |
| 298 |
{ |
| 299 |
const RenderObject* runningObject = container; |
| 300 |
while (runningObject) { |
| 301 |
const Node* runningNode = runningObject->node(); |
| 302 |
if (runningNode && runningNode->isHTMLElement()) { |
| 303 |
if (tags.contains(toElement(runningNode)->tagQName())) |
| 304 |
return true; |
| 305 |
} |
| 306 |
runningObject = nextInPreOrderSkippingDescendantsOfContainers(runningObject, container); |
| 307 |
} |
| 308 |
|
| 309 |
return false; |
| 310 |
} |
| 311 |
|
| 274 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
312 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
| 275 |
{ |
313 |
{ |
| 276 |
bool skipLocalText = contentHeightIsConstrained(container); |
314 |
bool skipLocalText = !containerShouldBeAutosized(container); |
| 277 |
|
315 |
|
| 278 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
316 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
| 279 |
while (descendant) { |
317 |
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); |
357 |
const RenderObject* lastTextLeaf = findFirstTextLeafNotInCluster(cluster, lastDepth, LastToFirst); |
| 320 |
ASSERT(lastTextLeaf); |
358 |
ASSERT(lastTextLeaf); |
| 321 |
|
359 |
|
| 322 |
// Equalize the depths if necessary. Only one of the while loops below will get executed. |
360 |
// Equalize the depths if containerShouldBeAutosized necessary. Only one of the while loops below will get executed. |
| 323 |
const RenderObject* firstNode = firstTextLeaf; |
361 |
const RenderObject* firstNode = firstTextLeaf; |
| 324 |
const RenderObject* lastNode = lastTextLeaf; |
362 |
const RenderObject* lastNode = lastTextLeaf; |
| 325 |
while (firstDepth > lastDepth) { |
363 |
while (firstDepth > lastDepth) { |