|
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 35-47
a/Source/WebCore/rendering/TextAutosizer.cpp_sec2
|
| 35 |
|
36 |
|
| 36 |
#include <algorithm> |
37 |
#include <algorithm> |
| 37 |
|
38 |
|
|
|
39 |
#include <wtf/StdLibExtras.h> |
| 40 |
|
| 38 |
namespace WebCore { |
41 |
namespace WebCore { |
| 39 |
|
42 |
|
|
|
43 |
using namespace HTMLNames; |
| 44 |
|
| 40 |
struct TextAutosizingWindowInfo { |
45 |
struct TextAutosizingWindowInfo { |
| 41 |
IntSize windowSize; |
46 |
IntSize windowSize; |
| 42 |
IntSize minLayoutSize; |
47 |
IntSize minLayoutSize; |
| 43 |
}; |
48 |
}; |
| 44 |
|
49 |
|
|
|
50 |
|
| 51 |
static const Vector<QualifiedName>& formInputTags() |
| 52 |
{ |
| 53 |
// Returns the tags for the form input elements. |
| 54 |
DEFINE_STATIC_LOCAL(Vector<QualifiedName>, formInputTags, ()); |
| 55 |
if (formInputTags.isEmpty()) { |
| 56 |
formInputTags.append(inputTag); |
| 57 |
formInputTags.append(textareaTag); |
| 58 |
formInputTags.append(buttonTag); |
| 59 |
formInputTags.append(selectTag); |
| 60 |
} |
| 61 |
return formInputTags; |
| 62 |
} |
| 63 |
|
| 45 |
TextAutosizer::TextAutosizer(Document* document) |
64 |
TextAutosizer::TextAutosizer(Document* document) |
| 46 |
: m_document(document) |
65 |
: m_document(document) |
| 47 |
{ |
66 |
{ |
|
Lines 119-125
void TextAutosizer::processCluster(RenderBlock* cluster, RenderBlock* container,
a/Source/WebCore/rendering/TextAutosizer.cpp_sec3
|
| 119 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
138 |
processContainer(multiplier, container, subtreeRoot, windowInfo); |
| 120 |
} |
139 |
} |
| 121 |
|
140 |
|
| 122 |
static bool contentHeightIsConstrained(const RenderBlock* container) |
141 |
bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container) |
|
|
142 |
{ |
| 143 |
if (containerContainsTags(container, formInputTags())) |
| 144 |
return false; |
| 145 |
|
| 146 |
return !contentHeightIsConstrained(container); |
| 147 |
} |
| 148 |
|
| 149 |
bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container) |
| 123 |
{ |
150 |
{ |
| 124 |
// FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. |
151 |
// 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. |
152 |
// 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 |
{ |
170 |
{ |
| 144 |
ASSERT(isAutosizingContainer(container)); |
171 |
ASSERT(isAutosizingContainer(container)); |
| 145 |
|
172 |
|
| 146 |
float localMultiplier = contentHeightIsConstrained(container) ? 1 : multiplier; |
173 |
float localMultiplier = containerShouldBeAutosized(container) ? multiplier : 1; |
| 147 |
|
174 |
|
| 148 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
175 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
| 149 |
while (descendant) { |
176 |
while (descendant) { |
|
Lines 211-216
bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec5
|
| 211 |
return false; |
238 |
return false; |
| 212 |
if (renderer->isListItem()) |
239 |
if (renderer->isListItem()) |
| 213 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
240 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
|
|
241 |
// Avoid creating containers for text within text controls, buttons, or <select> dropdowns. |
| 242 |
Node* parentNode = renderer->parent() ? renderer->parent()->generatingNode() : 0; |
| 243 |
if (parentNode && parentNode->isElementNode() && formInputTags().contains(toElement(parentNode)->tagQName())) |
| 244 |
return false; |
| 245 |
|
| 214 |
return true; |
246 |
return true; |
| 215 |
} |
247 |
} |
| 216 |
|
248 |
|
|
Lines 271-279
bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAnce
a/Source/WebCore/rendering/TextAutosizer.cpp_sec6
|
| 271 |
return false; |
303 |
return false; |
| 272 |
} |
304 |
} |
| 273 |
|
305 |
|
|
|
306 |
bool TextAutosizer::containerContainsTags(const RenderBlock* container, const Vector<QualifiedName>& tags) |
| 307 |
{ |
| 308 |
const RenderObject* renderer = container; |
| 309 |
while (renderer) { |
| 310 |
const Node* rendererNode = renderer->node(); |
| 311 |
if (rendererNode && rendererNode->isElementNode()) { |
| 312 |
if (tags.contains(toElement(rendererNode)->tagQName())) |
| 313 |
return true; |
| 314 |
} |
| 315 |
renderer = nextInPreOrderSkippingDescendantsOfContainers(renderer, container); |
| 316 |
} |
| 317 |
|
| 318 |
return false; |
| 319 |
} |
| 320 |
|
| 274 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
321 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
| 275 |
{ |
322 |
{ |
| 276 |
bool skipLocalText = contentHeightIsConstrained(container); |
323 |
bool skipLocalText = !containerShouldBeAutosized(container); |
| 277 |
|
324 |
|
| 278 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
325 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
| 279 |
while (descendant) { |
326 |
while (descendant) { |