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