| Differences between
and this patch
- a/Source/WebCore/ChangeLog +27 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-12-12  Tim Volodine  <timvolodine@google.com>
2
3
        Text Autosizing: Work out what to do about form controls
4
        https://bugs.webkit.org/show_bug.cgi?id=102560
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Disallow autosizing of form input controls like buttons, text input fields, selection controls, radio buttons
9
        and check boxes. This is a short term solution to avoid inconsistent autosizing of form controls (which is
10
        worse than not autosizing at all).
11
12
        Tests: fast/text-autosizing/form-controls-boosting-button-textarea-input-elements.html
13
               fast/text-autosizing/form-controls-boosting-checkbox-input-element.html
14
               fast/text-autosizing/form-controls-boosting-radio-input-element.html
15
               fast/text-autosizing/form-controls-boosting-select-element.html
16
17
        * rendering/TextAutosizer.cpp:
18
        (WebCore):
19
        (WebCore::TextAutosizer::containerShouldBeAutosized):
20
        (WebCore::TextAutosizer::contentHeightIsConstrained):
21
        (WebCore::TextAutosizer::processContainer):
22
        (WebCore::TextAutosizer::isAutosizingContainer):
23
        (WebCore::TextAutosizer::containerContainsTags):
24
        (WebCore::TextAutosizer::measureDescendantTextWidth):
25
        (WebCore::TextAutosizer::findDeepestBlockContainingAllText):
26
        * rendering/TextAutosizer.h:
27
1
2012-12-04  Antoine Quint  <graouts@apple.com>
28
2012-12-04  Antoine Quint  <graouts@apple.com>
2
29
3
        TextTrack's .kind property should return lower-case values
30
        TextTrack's .kind property should return lower-case values
- a/Source/WebCore/rendering/TextAutosizer.cpp -3 / +49 lines
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) {
- a/Source/WebCore/rendering/TextAutosizer.h +4 lines
Lines 28-33 a/Source/WebCore/rendering/TextAutosizer.h_sec1
28
28
29
#if ENABLE(TEXT_AUTOSIZING)
29
#if ENABLE(TEXT_AUTOSIZING)
30
30
31
#include "HTMLNames.h"
31
#include "IntSize.h"
32
#include "IntSize.h"
32
#include <wtf/Noncopyable.h>
33
#include <wtf/Noncopyable.h>
33
#include <wtf/PassOwnPtr.h>
34
#include <wtf/PassOwnPtr.h>
Lines 71-76 private: a/Source/WebCore/rendering/TextAutosizer.h_sec2
71
    static bool isAutosizingCluster(const RenderBlock*);
72
    static bool isAutosizingCluster(const RenderBlock*);
72
73
73
    static bool clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth);
74
    static bool clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth);
75
    static bool containerShouldBeAutosized(const RenderBlock* container);
76
    static bool contentHeightIsConstrained(const RenderBlock* container);
77
    static bool containerContainsTags(const RenderBlock* cluster, const Vector<QualifiedName>& tags);
74
    static void measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth);
78
    static void measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth);
75
79
76
    // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
80
    // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
- a/LayoutTests/ChangeLog +19 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2012-12-12  Tim Volodine  <timvolodine@google.com>
2
3
        Text Autosizing: Work out what to do about form controls
4
        https://bugs.webkit.org/show_bug.cgi?id=102560
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Tests for form input elements autosizing. Added tests to check that various kinds of form elements
9
        don't get autosized, i.e. buttons, textareas, check boxes, radio button and selection menus.
10
11
        * fast/text-autosizing/form-controls-boosting-button-textarea-input-elements-expected.html: Added.
12
        * fast/text-autosizing/form-controls-boosting-button-textarea-input-elements.html: Added.
13
        * fast/text-autosizing/form-controls-boosting-checkbox-input-element-expected.html: Added.
14
        * fast/text-autosizing/form-controls-boosting-checkbox-input-element.html: Added.
15
        * fast/text-autosizing/form-controls-boosting-radio-input-element-expected.html: Added.
16
        * fast/text-autosizing/form-controls-boosting-radio-input-element.html: Added.
17
        * fast/text-autosizing/form-controls-boosting-select-element-expected.html: Added.
18
        * fast/text-autosizing/form-controls-boosting-select-element.html: Added.
19
1
2012-12-04  Antoine Quint  <graouts@apple.com>
20
2012-12-04  Antoine Quint  <graouts@apple.com>
2
21
3
        TextTrack's .kind property should return lower-case values
22
        TextTrack's .kind property should return lower-case values
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-button-textarea-input-elements-expected.html +84 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-button-textarea-input-elements-expected.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
  
13
  #header form {
14
    font-size: 85%;
15
    display: inline;
16
  }
17
  
18
  #header .links {
19
    font-size: 85%;
20
  }
21
  
22
  ul.links {
23
    margin: 0;
24
    padding: 0;
25
    list-style-type: none;
26
  }
27
28
  ul.links li {
29
    display: inline;
30
    white-space: nowrap;
31
  }
32
</style>
33
34
</head>
35
<body>
36
37
<div id="header">
38
  <ul class="links">
39
    <li>
40
      <a href="./">Home</a>
41
    </li>
42
    <li>
43
      <span>| </span>
44
      <a href="">New</a>
45
    </li>
46
    <li>
47
      <span>| </span>
48
      <a href="">Search</a>
49
    </li>
50
    <li>
51
      <span>| </span>
52
      <form>
53
        <input class="txt" type="text" id="quicksearch_top" name="quicksearch">
54
        <input class="btn" type="submit" value="Find" id=find_top">
55
      </form>
56
    </li>
57
    <li>
58
      <span>| </span>
59
      <a href="">Reports</a>
60
    </li>
61
  </ul>
62
</div>
63
64
<div>
65
  <p><div style="font-size: 2.5rem">
66
  This test checks that form controls like buttons, text inputs and check-boxes are not autosized.
67
  The text in this paragraph should be autosized, while the form controls above and below should not.
68
  The "Find" button and text-input box at the bottom of the page should not be autosized.
69
  </div></p>
70
71
  <form>
72
  <div>
73
    <p><div style="font-size: 2.5rem">
74
    This text should be autosized, while the input controls below should not.
75
    </div></p>
76
    <input id="quicksearch" type="text" name="quicksearch">
77
    <input id="find" type="submit" value="Find">
78
  </div>
79
  </form>
80
81
</div>
82
83
</body>
84
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-button-textarea-input-elements.html +93 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-button-textarea-input-elements.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
  
13
  #header form {
14
    font-size: 85%;
15
    display: inline;
16
  }
17
  
18
  #header .links {
19
    font-size: 85%;
20
  }
21
  
22
  ul.links {
23
    margin: 0;
24
    padding: 0;
25
    list-style-type: none;
26
  }
27
28
  ul.links li {
29
    display: inline;
30
    white-space: nowrap;
31
  }
32
</style>
33
34
<script>
35
if (window.internals) {
36
    window.internals.settings.setTextAutosizingEnabled(true);
37
    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
38
} else if (window.console && console.warn) {
39
    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
40
}
41
</script>
42
43
</head>
44
<body>
45
46
<div id="header">
47
  <ul class="links">
48
    <li>
49
      <a href="./">Home</a>
50
    </li>
51
    <li>
52
      <span>| </span>
53
      <a href="">New</a>
54
    </li>
55
    <li>
56
      <span>| </span>
57
      <a href="">Search</a>
58
    </li>
59
    <li>
60
      <span>| </span>
61
      <form>
62
        <input class="txt" type="text" id="quicksearch_top" name="quicksearch">
63
        <input class="btn" type="submit" value="Find" id=find_top">
64
      </form>
65
    </li>
66
    <li>
67
      <span>| </span>
68
      <a href="">Reports</a>
69
    </li>
70
  </ul>
71
</div>
72
73
<div>
74
  <p><div>
75
  This test checks that form controls like buttons, text inputs and check-boxes are not autosized.
76
  The text in this paragraph should be autosized, while the form controls above and below should not.
77
  The "Find" button and text-input box at the bottom of the page should not be autosized.
78
  </div></p>
79
80
  <form>
81
  <div>
82
    <p><div>
83
    This text should be autosized, while the input controls below should not.
84
    </div></p>
85
    <input id="quicksearch" type="text" name="quicksearch">
86
    <input id="find" type="submit" value="Find">
87
  </div>
88
  </form>
89
90
</div>
91
92
</body>
93
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-checkbox-input-element-expected.html +35 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-checkbox-input-element-expected.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
</style>
13
14
15
</head>
16
<body>
17
18
<div>
19
<div style="font-size: 2.5rem">
20
This tests the autosizing of check boxes. This paragraph should be autosized, while
21
the check boxes below and the surrounding text should not be autosized.
22
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
23
incididunt ut labore et dolore magna aliqua.
24
</div>
25
<div>
26
<form action="">
27
Check one or more:
28
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br/>
29
<input type="checkbox" name="vehicle" value="Car">I have a car <br/>
30
</form>
31
</div>
32
</div>
33
34
</body>
35
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-checkbox-input-element.html +43 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-checkbox-input-element.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
</style>
13
14
<script>
15
if (window.internals) {
16
    window.internals.settings.setTextAutosizingEnabled(true);
17
    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
18
} else if (window.console && console.warn) {
19
    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
20
}
21
</script>
22
23
</head>
24
<body>
25
26
<div>
27
<div>
28
This tests the autosizing of check boxes. This paragraph should be autosized, while
29
the check boxes below and the surrounding text should not be autosized.
30
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
31
incididunt ut labore et dolore magna aliqua.
32
</div>
33
<div>
34
<form action="">
35
Check one or more:
36
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br/>
37
<input type="checkbox" name="vehicle" value="Car">I have a car <br/>
38
</form>
39
</div>
40
</div>
41
42
</body>
43
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-radio-input-element-expected.html +37 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-radio-input-element-expected.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
</style>
13
14
15
</head>
16
<body>
17
18
<div>
19
<div style="font-size: 2.5rem">
20
This tests the autosizing of radio buttons. This paragraph should be autosized, while
21
the radio buttons below and the surrounding text should not be autosized.
22
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
23
incididunt ut labore et dolore magna aliqua.
24
</div>
25
<div>
26
<form action="">
27
Select one of:<br/>
28
<input type="radio" id="radio1" checked="checked"/>
29
<label for="radio1">Radio1</label><br/>
30
<input type="radio" id="radio2"/>
31
<label for="radio2">Radio2</label><br/>
32
</form>
33
</div>
34
</div>
35
36
</body>
37
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-radio-input-element.html +45 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-radio-input-element.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
</style>
13
14
<script>
15
if (window.internals) {
16
    window.internals.settings.setTextAutosizingEnabled(true);
17
    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
18
} else if (window.console && console.warn) {
19
    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
20
}
21
</script>
22
23
</head>
24
<body>
25
26
<div>
27
<div>
28
This tests the autosizing of radio buttons. This paragraph should be autosized, while
29
the radio buttons below and the surrounding text should not be autosized.
30
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
31
incididunt ut labore et dolore magna aliqua.
32
</div>
33
<div>
34
<form action="">
35
Select one of:<br/>
36
<input type="radio" id="radio1" checked="checked"/>
37
<label for="radio1">Radio1</label><br/>
38
<input type="radio" id="radio2"/>
39
<label for="radio2">Radio2</label><br/>
40
</form>
41
</div>
42
</div>
43
44
</body>
45
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-select-element-expected.html +36 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-select-element-expected.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
</style>
13
14
</head>
15
<body>
16
17
<div>
18
<div style="font-size: 2.5rem">
19
This tests the autosizing of a selection menu element. This paragraph should be autosized, while
20
the selection box below should not be autosized. Lorem ipsum dolor sit amet, consectetur adipisicing
21
elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
22
</div>
23
<div>
24
<form action="">
25
Selection:
26
<select>
27
  <option selected value=default>Default</option>
28
  <option>Option 1</option>
29
  <option>Option 2</option>
30
</select>
31
</form>
32
</div>
33
</div>
34
35
</body>
36
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-select-element.html +45 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-select-element.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
5
<meta name="viewport" content="width=800">
6
<style>
7
  body {
8
    width: 800px;
9
    margin: 0;
10
    overflow-y: hidden;
11
  }
12
</style>
13
14
<script>
15
if (window.internals) {
16
    window.internals.settings.setTextAutosizingEnabled(true);
17
    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
18
} else if (window.console && console.warn) {
19
    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
20
}
21
</script>
22
23
</head>
24
<body>
25
26
<div>
27
<div>
28
This tests the autosizing of a selection menu element. This paragraph should be autosized, while
29
the selection box below should not be autosized. Lorem ipsum dolor sit amet, consectetur adipisicing
30
elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
31
</div>
32
<div>
33
<form action="">
34
Selection:
35
<select>
36
  <option selected value=default>Default</option>
37
  <option>Option 1</option>
38
  <option>Option 2</option>
39
</select>
40
</form>
41
</div>
42
</div>
43
44
</body>
45
</html>

Return to Bug 102560