|
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 34-47
a/Source/WebCore/rendering/TextAutosizer.cpp_sec2
|
| 34 |
#include "StyleInheritedData.h" |
35 |
#include "StyleInheritedData.h" |
| 35 |
|
36 |
|
| 36 |
#include <algorithm> |
37 |
#include <algorithm> |
|
|
38 |
#include <wtf/StdLibExtras.h> |
| 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(buttonTag); |
| 57 |
formInputTags.append(selectTag); |
| 58 |
} |
| 59 |
return formInputTags; |
| 60 |
} |
| 61 |
|
| 45 |
TextAutosizer::TextAutosizer(Document* document) |
62 |
TextAutosizer::TextAutosizer(Document* document) |
| 46 |
: m_document(document) |
63 |
: m_document(document) |
| 47 |
{ |
64 |
{ |
|
Lines 123-129
void TextAutosizer::processContainer(float multiplier, RenderBlock* container, R
a/Source/WebCore/rendering/TextAutosizer.cpp_sec3
|
| 123 |
{ |
140 |
{ |
| 124 |
ASSERT(isAutosizingContainer(container)); |
141 |
ASSERT(isAutosizingContainer(container)); |
| 125 |
|
142 |
|
| 126 |
float localMultiplier = containerShouldbeAutosized(container) ? multiplier: 1; |
143 |
float localMultiplier = containerShouldBeAutosized(container) ? multiplier : 1; |
| 127 |
|
144 |
|
| 128 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
145 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot); |
| 129 |
while (descendant) { |
146 |
while (descendant) { |
|
Lines 191-196
bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec4
|
| 191 |
return false; |
208 |
return false; |
| 192 |
if (renderer->isListItem()) |
209 |
if (renderer->isListItem()) |
| 193 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
210 |
return renderer->isFloating() || renderer->isOutOfFlowPositioned(); |
|
|
211 |
// Avoid creating containers for text within text controls, buttons, or <select> buttons. |
| 212 |
Node* parentNode = renderer->parent() ? renderer->parent()->generatingNode() : 0; |
| 213 |
if (parentNode && parentNode->isElementNode() && formInputTags().contains(toElement(parentNode)->tagQName())) |
| 214 |
return false; |
| 215 |
|
| 194 |
return true; |
216 |
return true; |
| 195 |
} |
217 |
} |
| 196 |
|
218 |
|
|
Lines 230-236
bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec5
|
| 230 |
// renderers, and probably flexboxes... |
252 |
// renderers, and probably flexboxes... |
| 231 |
} |
253 |
} |
| 232 |
|
254 |
|
| 233 |
static bool contentHeightIsConstrained(const RenderBlock* container) |
255 |
bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container) |
| 234 |
{ |
256 |
{ |
| 235 |
// FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. |
257 |
// FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box. |
| 236 |
// FIXME: This code needs to take into account vertical writing modes. |
258 |
// FIXME: This code needs to take into account vertical writing modes. |
|
Lines 250-257
static bool contentHeightIsConstrained(const RenderBlock* container)
a/Source/WebCore/rendering/TextAutosizer.cpp_sec6
|
| 250 |
return false; |
272 |
return false; |
| 251 |
} |
273 |
} |
| 252 |
|
274 |
|
| 253 |
bool TextAutosizer::containerShouldbeAutosized(const RenderBlock* container) |
275 |
bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container) |
| 254 |
{ |
276 |
{ |
|
|
277 |
if (containerContainsOneOfTags(container, formInputTags())) |
| 278 |
return false; |
| 279 |
|
| 255 |
// Don't autosize block-level text that can't wrap (as it's likely to |
280 |
// Don't autosize block-level text that can't wrap (as it's likely to |
| 256 |
// expand sideways and break the page's layout). |
281 |
// expand sideways and break the page's layout). |
| 257 |
if (!container->style()->autoWrap()) |
282 |
if (!container->style()->autoWrap()) |
|
Lines 281-289
bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAnce
a/Source/WebCore/rendering/TextAutosizer.cpp_sec7
|
| 281 |
return false; |
306 |
return false; |
| 282 |
} |
307 |
} |
| 283 |
|
308 |
|
|
|
309 |
bool TextAutosizer::containerContainsOneOfTags(const RenderBlock* container, const Vector<QualifiedName>& tags) |
| 310 |
{ |
| 311 |
const RenderObject* renderer = container; |
| 312 |
while (renderer) { |
| 313 |
const Node* rendererNode = renderer->node(); |
| 314 |
if (rendererNode && rendererNode->isElementNode()) { |
| 315 |
if (tags.contains(toElement(rendererNode)->tagQName())) |
| 316 |
return true; |
| 317 |
} |
| 318 |
renderer = nextInPreOrderSkippingDescendantsOfContainers(renderer, container); |
| 319 |
} |
| 320 |
|
| 321 |
return false; |
| 322 |
} |
| 323 |
|
| 284 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
324 |
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth) |
| 285 |
{ |
325 |
{ |
| 286 |
bool skipLocalText = !containerShouldbeAutosized(container); |
326 |
bool skipLocalText = !containerShouldBeAutosized(container); |
| 287 |
|
327 |
|
| 288 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
328 |
RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container); |
| 289 |
while (descendant) { |
329 |
while (descendant) { |