| Differences between
and this patch
- a/Source/WebCore/ChangeLog +23 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-12-10  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
        Dissalow boosting of form input controls like buttons and text field inputs. This is a short term solution,
9
        to avoid inconsistent boosting of form controls (which is worse than not boosting at all).
10
11
        Test: fast/text-autosizing/form-controls-boosting.html
12
13
        * rendering/TextAutosizer.cpp:
14
        (WebCore):
15
        (WebCore::TextAutosizer::processSubtree):
16
        (WebCore::TextAutosizer::processCluster):
17
        (WebCore::TextAutosizer::contentHeightIsConstrained):
18
        (WebCore::TextAutosizer::isAutosizingContainer):
19
        (WebCore::TextAutosizer::clusterShouldBeAutosized):
20
        (WebCore::TextAutosizer::containerContainsTags):
21
        (WebCore::TextAutosizer::findDeepestBlockContainingAllText):
22
        * rendering/TextAutosizer.h:
23
1
2012-12-04  Antoine Quint  <graouts@apple.com>
24
2012-12-04  Antoine Quint  <graouts@apple.com>
2
25
3
        TextTrack's .kind property should return lower-case values
26
        TextTrack's .kind property should return lower-case values
- a/Source/WebCore/rendering/TextAutosizer.cpp -2 / +42 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 37-42 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;
Lines 89-94 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) a/Source/WebCore/rendering/TextAutosizer.cpp_sec3
89
        cluster = cluster->containingBlock();
92
        cluster = cluster->containingBlock();
90
93
91
    processCluster(cluster, container, layoutRoot, windowInfo);
94
    processCluster(cluster, container, layoutRoot, windowInfo);
95
92
    return true;
96
    return true;
93
}
97
}
94
98
Lines 119-129 void TextAutosizer::processCluster(RenderBlock* cluster, RenderBlock* container, a/Source/WebCore/rendering/TextAutosizer.cpp_sec4
119
    processContainer(multiplier, container, subtreeRoot, windowInfo);
123
    processContainer(multiplier, container, subtreeRoot, windowInfo);
120
}
124
}
121
125
122
static bool contentHeightIsConstrained(const RenderBlock* container)
126
bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container)
123
{
127
{
124
    // FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box.
128
    // 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.
129
    // FIXME: This code needs to take into account vertical writing modes.
126
    // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in.
130
    // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in.
131
    QualifiedName tags[4] = {inputTag, textareaTag, buttonTag, formTag};
132
    if (containerContainsTags(container, tags, 4))
133
        return true;
134
127
    for (; container; container = container->containingBlock()) {
135
    for (; container; container = container->containingBlock()) {
128
        RenderStyle* style = container->style();
136
        RenderStyle* style = container->style();
129
        if (style->overflowY() >= OSCROLL)
137
        if (style->overflowY() >= OSCROLL)
Lines 211-216 bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer) a/Source/WebCore/rendering/TextAutosizer.cpp_sec5
211
        return false;
219
        return false;
212
    if (renderer->isListItem())
220
    if (renderer->isListItem())
213
        return renderer->isFloating() || renderer->isOutOfFlowPositioned();
221
        return renderer->isFloating() || renderer->isOutOfFlowPositioned();
222
    // avoid creating containers for text within text controls or buttons
223
    if (renderer->parent()) {
224
        if (renderer->parent()->isRenderButton() || renderer->parent()->isTextControl())
225
            return false;
226
    }
227
214
    return true;
228
    return true;
215
}
229
}
216
230
Lines 271-276 bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAnce a/Source/WebCore/rendering/TextAutosizer.cpp_sec6
271
    return false;
285
    return false;
272
}
286
}
273
287
288
bool TextAutosizer::containerContainsTags(const RenderObject* container, const QualifiedName tags[], const size_t numTags)
289
{
290
    const Node* containerNode = container->node();
291
    bool validCandidate = containerNode && containerNode->isHTMLElement() && !containerNode->isShadowRoot();
292
    if (validCandidate) {
293
        for (size_t i = 0; i < numTags; ++i) {
294
            if (containerNode->hasTagName(tags[i]))
295
                return true;
296
        }
297
    }
298
299
    RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container);
300
    while (descendant) {
301
        const Node* descendantNode = descendant->node();
302
        bool validCandidate = descendantNode && descendantNode->isHTMLElement() && !descendantNode->isShadowRoot();
303
        if (validCandidate) {
304
            for (size_t i = 0; i < numTags; ++i) {
305
                if (descendantNode->hasTagName(tags[i]))
306
                    return true;
307
            }
308
        }
309
        descendant = nextInPreOrderSkippingDescendantsOfContainers(descendant, container);
310
    }
311
    return false;
312
}
313
274
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth)
314
void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth)
275
{
315
{
276
    bool skipLocalText = contentHeightIsConstrained(container);
316
    bool skipLocalText = contentHeightIsConstrained(container);
Lines 319-325 const RenderBlock* TextAutosizer::findDeepestBlockContainingAllText(const Render a/Source/WebCore/rendering/TextAutosizer.cpp_sec7
319
    const RenderObject* lastTextLeaf = findFirstTextLeafNotInCluster(cluster, lastDepth, LastToFirst);
359
    const RenderObject* lastTextLeaf = findFirstTextLeafNotInCluster(cluster, lastDepth, LastToFirst);
320
    ASSERT(lastTextLeaf);
360
    ASSERT(lastTextLeaf);
321
361
322
    // Equalize the depths if necessary. Only one of the while loops below will get executed.
362
    // Equalize the depths if contentHeightIsConstrainednecessary. Only one of the while loops below will get executed.
323
    const RenderObject* firstNode = firstTextLeaf;
363
    const RenderObject* firstNode = firstTextLeaf;
324
    const RenderObject* lastNode = lastTextLeaf;
364
    const RenderObject* lastNode = lastTextLeaf;
325
    while (firstDepth > lastDepth) {
365
    while (firstDepth > lastDepth) {
- a/Source/WebCore/rendering/TextAutosizer.h +3 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 contentHeightIsConstrained(const RenderBlock* container);
76
    static bool containerContainsTags(const RenderObject* cluster, const QualifiedName tags[], const size_t numTags);
74
    static void measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth);
77
    static void measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth);
75
78
76
    // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
79
    // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
- a/LayoutTests/ChangeLog +13 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2012-12-10  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
        Dissalow boosting of form input elements like buttons and text input fields. This is a short term solution,
9
        to avoid inconsistent boosting of form controls (which is worse than not boosting).
10
11
        * fast/text-autosizing/form-controls-boosting-expected.html: Added.
12
        * fast/text-autosizing/form-controls-boosting.html: Added.
13
1
2012-12-04  Antoine Quint  <graouts@apple.com>
14
2012-12-04  Antoine Quint  <graouts@apple.com>
2
15
3
        TextTrack's .kind property should return lower-case values
16
        TextTrack's .kind property should return lower-case values
- a/LayoutTests/fast/text-autosizing/form-controls-boosting-expected.html +114 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting-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
    font-family: Verdana, sans-serif;
12
    font-size: small;
13
  }
14
  
15
  #boosted {
16
    font-size: 2.05rem;
17
  }
18
  
19
  #header form {
20
    font-size: 85%;
21
    display: inline;
22
  }
23
  
24
  #header .links {
25
    font-size: 85%;
26
  }
27
  
28
  ul.links {
29
    margin: 0;
30
    padding: 0;
31
    list-style-type: none;
32
  }
33
34
  ul.links li {
35
    display: inline;
36
    white-space: nowrap;
37
  }
38
</style>
39
40
</head>
41
<body>
42
43
<div id="header">
44
  <ul class="links">
45
    <li>
46
      <a href="./">Home</a>
47
    </li>
48
    <li>
49
      <span>| </span>
50
      <a href="">New</a>
51
    </li>
52
    <li>
53
      <span>| </span>
54
      <a href="">Search</a>
55
    </li>
56
    <li>
57
      <span>| </span>
58
      <form>
59
        <input class="txt" type="text" id="quicksearch_top" name="quicksearch">
60
        <input class="btn" type="submit" value="Find" id=find_top">
61
      </form>
62
    </li>
63
    <li>
64
      <span>| </span>
65
      <a href="">Reports</a>
66
    </li>
67
  </ul>
68
</div>
69
70
<div>
71
  <p><div id="boosted">This test checks that from controls like buttons, text inputs and check-boxes are not autosized.
72
    The text in this paragraph should be autosized, while the form controls in the header and in the table-layout
73
    below should not. Also the "Find" button and text-input box at the bottom of the page should not be autosized.
74
  </div></p>
75
76
  <form name="login" action="" method="POST">
77
  <table>
78
    <tr>
79
      <th align="right"><label for="Bugzilla_login">Login:</label></th>
80
      <td><input size="20" id="Bugzilla_login" name="Bugzilla_login"></td>
81
    </tr>
82
    <tr>
83
      <th align="right"><label for="Bugzilla_password">Password:</label></th>
84
      <td>
85
        <input type="password" size="20" id="Bugzilla_password" name="Bugzilla_password">
86
      </td>
87
    </tr>
88
    <tr>
89
      <th>&nbsp;</th>
90
      <td>
91
        <input type="checkbox" id="Bugzilla_restrictlogin" name="Bugzilla_restrictlogin" checked="checked">
92
        <label for="Bugzilla_restrictlogin">Restrict this session to this IP address</label>
93
      </td>
94
    </tr>
95
    <tr>
96
      <td><input type="submit" name="GoAheadAndLogIn" value="Login" id="log_in"></td>
97
      <td>[ <a href="">Forgot my Password</a> ]</td>
98
    </tr>
99
  </table>
100
  </form>
101
  
102
  <form>
103
  <div>
104
    <p><div id="boosted">This text should be autosized, while the input controls below should not.</div></p>
105
    <input id="quicksearch" type="text" name="quicksearch">
106
    <input id="find" type="submit" value="Find">
107
    <a href="">[Help]</a>
108
  </div>
109
  </form>
110
111
</div>
112
113
</body>
114
</html>
- a/LayoutTests/fast/text-autosizing/form-controls-boosting.html +119 lines
Line 0 a/LayoutTests/fast/text-autosizing/form-controls-boosting.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
    font-family: Verdana, sans-serif;
12
    font-size: small;
13
  }
14
  
15
  #header form {
16
    font-size: 85%;
17
    display: inline;
18
  }
19
  
20
  #header .links {
21
    font-size: 85%;
22
  }
23
  
24
  ul.links {
25
    margin: 0;
26
    padding: 0;
27
    list-style-type: none;
28
  }
29
30
  ul.links li {
31
    display: inline;
32
    white-space: nowrap;
33
  }
34
</style>
35
36
<script>
37
if (window.internals) {
38
    window.internals.settings.setTextAutosizingEnabled(true);
39
    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
40
} else if (window.console && console.warn) {
41
    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.");
42
}
43
</script>
44
45
</head>
46
<body>
47
48
<div id="header">
49
  <ul class="links">
50
    <li>
51
      <a href="./">Home</a>
52
    </li>
53
    <li>
54
      <span>| </span>
55
      <a href="">New</a>
56
    </li>
57
    <li>
58
      <span>| </span>
59
      <a href="">Search</a>
60
    </li>
61
    <li>
62
      <span>| </span>
63
      <form>
64
        <input class="txt" type="text" id="quicksearch_top" name="quicksearch">
65
        <input class="btn" type="submit" value="Find" id=find_top">
66
      </form>
67
    </li>
68
    <li>
69
      <span>| </span>
70
      <a href="">Reports</a>
71
    </li>
72
  </ul>
73
</div>
74
75
<div>
76
  <p>This test checks that from controls like buttons, text inputs and check-boxes are not autosized.
77
    The text in this paragraph should be autosized, while the form controls in the header and in the table-layout
78
    below should not. Also the "Find" button and text-input box at the bottom of the page should not be autosized.
79
  </p>
80
81
  <form name="login" action="" method="POST">
82
  <table>
83
    <tr>
84
      <th align="right"><label for="Bugzilla_login">Login:</label></th>
85
      <td><input size="20" id="Bugzilla_login" name="Bugzilla_login"></td>
86
    </tr>
87
    <tr>
88
      <th align="right"><label for="Bugzilla_password">Password:</label></th>
89
      <td>
90
        <input type="password" size="20" id="Bugzilla_password" name="Bugzilla_password">
91
      </td>
92
    </tr>
93
    <tr>
94
      <th>&nbsp;</th>
95
      <td>
96
        <input type="checkbox" id="Bugzilla_restrictlogin" name="Bugzilla_restrictlogin" checked="checked">
97
        <label for="Bugzilla_restrictlogin">Restrict this session to this IP address</label>
98
      </td>
99
    </tr>
100
    <tr>
101
      <td><input type="submit" name="GoAheadAndLogIn" value="Login" id="log_in"></td>
102
      <td>[ <a href="">Forgot my Password</a> ]</td>
103
    </tr>
104
  </table>
105
  </form>
106
  
107
  <form>
108
  <div>
109
    <p>This text should be autosized, while the input controls below should not.</p>
110
    <input id="quicksearch" type="text" name="quicksearch">
111
    <input id="find" type="submit" value="Find">
112
    <a href="">[Help]</a>
113
  </div>
114
  </form>
115
116
</div>
117
118
</body>
119
</html>

Return to Bug 102560