Title: [138162] trunk
Revision
138162
Author
commit-qu...@webkit.org
Date
2012-12-19 07:34:36 -0800 (Wed, 19 Dec 2012)

Log Message

Text Autosizing: Work out what to do about form controls
https://bugs.webkit.org/show_bug.cgi?id=102560

Patch by Tim Volodine <timvolod...@chromium.org> on 2012-12-19
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Disallow autosizing of form input controls like buttons, text input fields, selection controls, radio buttons
and check boxes. This is a short term solution to avoid inconsistent autosizing of form controls (which is
worse than not autosizing at all).

Tests: fast/text-autosizing/form-controls-autosizing-button-input-elements.html
       fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html
       fast/text-autosizing/form-controls-autosizing-radio-input-element.html
       fast/text-autosizing/form-controls-autosizing-select-element.html
       fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html

* rendering/TextAutosizer.cpp:
(WebCore):
(WebCore::formInputTags):
(WebCore::TextAutosizer::isAutosizingContainer):
(WebCore::TextAutosizer::contentHeightIsConstrained):
(WebCore::TextAutosizer::containerShouldBeAutosized):
(WebCore::TextAutosizer::containerContainsOneOfTags):
* rendering/TextAutosizer.h:

LayoutTests:

Tests for form input elements autosizing. Added tests to check that various kinds of form elements
don't get autosized, i.e. buttons, textareas, check boxes, radio button and selection menus.

* fast/text-autosizing/form-controls-autosizing-button-input-elements-expected.html: Added.
* fast/text-autosizing/form-controls-autosizing-button-input-elements.html: Added.
* fast/text-autosizing/form-controls-autosizing-checkbox-input-element-expected.html: Added.
* fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html: Added.
* fast/text-autosizing/form-controls-autosizing-radio-input-element-expected.html: Added.
* fast/text-autosizing/form-controls-autosizing-radio-input-element.html: Added.
* fast/text-autosizing/form-controls-autosizing-select-element-expected.html: Added.
* fast/text-autosizing/form-controls-autosizing-select-element.html: Added.
* fast/text-autosizing/form-controls-autosizing-textfield-input-elements-expected.html: Added.
* fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (138161 => 138162)


--- trunk/LayoutTests/ChangeLog	2012-12-19 15:32:32 UTC (rev 138161)
+++ trunk/LayoutTests/ChangeLog	2012-12-19 15:34:36 UTC (rev 138162)
@@ -1,3 +1,24 @@
+2012-12-19  Tim Volodine  <timvolod...@chromium.org>
+
+        Text Autosizing: Work out what to do about form controls
+        https://bugs.webkit.org/show_bug.cgi?id=102560
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Tests for form input elements autosizing. Added tests to check that various kinds of form elements
+        don't get autosized, i.e. buttons, textareas, check boxes, radio button and selection menus.
+
+        * fast/text-autosizing/form-controls-autosizing-button-input-elements-expected.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-button-input-elements.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-checkbox-input-element-expected.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-radio-input-element-expected.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-radio-input-element.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-select-element-expected.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-select-element.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-textfield-input-elements-expected.html: Added.
+        * fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html: Added.
+
 2012-12-19  Csaba Osztrogonác  <o...@webkit.org>
 
         [Qt] Unreviewed gardening, update pixel results.

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-button-input-elements-expected.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-button-input-elements-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-button-input-elements-expected.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+</head>
+<body>
+
+<div style="font-size: 2.5rem">
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the buttons below should be rendered at their default font size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+    tempor incididunt ut labore et dolore magna aliqua.
+</div>
+
+<div>
+    Submit button
+    <input type="submit" value="Find">
+</div>
+<div>
+    Simple button
+    <input type="button" value="Button">
+</div>
+<div>
+    Reset button
+    <input type="reset" value="Reset">
+</div>
+<div>
+    Inline button
+    <button>InlineButton</button>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-button-input-elements.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-button-input-elements.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-button-input-elements.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    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.");
+}
+</script>
+
+</head>
+<body>
+
+<div>
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the buttons below should be rendered at their default font size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+    tempor incididunt ut labore et dolore magna aliqua.
+</div>
+
+<div>
+    Submit button
+    <input type="submit" value="Find">
+</div>
+<div>
+    Simple button
+    <input type="button" value="Button">
+</div>
+<div>
+    Reset button
+    <input type="reset" value="Reset">
+</div>
+<div>
+    Inline button
+    <button>InlineButton</button>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-checkbox-input-element-expected.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-checkbox-input-element-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-checkbox-input-element-expected.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+</head>
+<body>
+
+<div style="font-size: 2.5rem">
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the check boxes below should be rendered at their default size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+<div>
+    Check one or more:
+    <input type="checkbox" name="vehicle" value="Bike">I have a bike<br/>
+    <input type="checkbox" name="vehicle" value="Car">I have a car <br/>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    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.");
+}
+</script>
+
+</head>
+<body>
+
+<div>
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the check boxes below should be rendered at their default size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+<div>
+    Check one or more:
+    <input type="checkbox" name="vehicle" value="Bike">I have a bike<br/>
+    <input type="checkbox" name="vehicle" value="Car">I have a car <br/>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-radio-input-element-expected.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-radio-input-element-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-radio-input-element-expected.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+</head>
+<body>
+
+<div style="font-size: 2.5rem">
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the radio buttons below should be rendered at their default size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+<div>
+    Select one of:<br/>
+    <input type="radio" id="radio1" checked="checked"/>
+    <label for=""
+    <input type="radio" id="radio2"/>
+    <label for=""
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-radio-input-element.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-radio-input-element.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-radio-input-element.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    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.");
+}
+</script>
+
+</head>
+<body>
+
+<div>
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the radio buttons below should be rendered at their default size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+<div>
+    Select one of:<br/>
+    <input type="radio" id="radio1" checked="checked"/>
+    <label for=""
+    <input type="radio" id="radio2"/>
+    <label for=""
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-select-element-expected.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-select-element-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-select-element-expected.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+</head>
+<body>
+
+<div style="font-size: 2.5rem">
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the selection box should be rendered at its default size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+<div>
+    Selection:
+    <select>
+        <option selected value=default>Default</option>
+        <option>Option 1</option>
+        <option>Option 2</option>
+    </select>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-select-element.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-select-element.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-select-element.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    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.");
+}
+</script>
+
+</head>
+<body>
+
+<div>
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the selection box should be rendered at its default size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+<div>
+    Selection:
+    <select>
+        <option selected value=default>Default</option>
+        <option>Option 1</option>
+        <option>Option 2</option>
+    </select>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-textfield-input-elements-expected.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-textfield-input-elements-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-textfield-input-elements-expected.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+</head>
+<body>
+
+<div style="font-size: 2.5rem">
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the input text fields should be rendered at their default font size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+
+<div>
+    Text
+    <input type="text" value="Default text">
+</div>
+<div>
+    Email
+    <input type="email">
+</div>
+<div>
+    Number
+    <input type="number">
+</div>
+<div>
+    Password
+    <input type="password">
+</div>
+<div>
+    URL
+    <input type="url">
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html (0 => 138162)


--- trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html	2012-12-19 15:34:36 UTC (rev 138162)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html style="font-size: 16px">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+  body {
+    width: 800px;
+    margin: 0;
+    overflow-y: hidden;
+  }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    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.");
+}
+</script>
+
+</head>
+<body>
+
+<div>
+    This paragraph should be autosized to 40px computed font-size (16 * 800/320),
+    whereas the input text fields should be rendered at their default font size and
+    the accompanying text below should remain 16px.
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
+    incididunt ut labore et dolore magna aliqua.
+</div>
+
+<div>
+    Text
+    <input type="text" value="Default text">
+</div>
+<div>
+    Email
+    <input type="email">
+</div>
+<div>
+    Number
+    <input type="number">
+</div>
+<div>
+    Password
+    <input type="password">
+</div>
+<div>
+    URL
+    <input type="url">
+</div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (138161 => 138162)


--- trunk/Source/WebCore/ChangeLog	2012-12-19 15:32:32 UTC (rev 138161)
+++ trunk/Source/WebCore/ChangeLog	2012-12-19 15:34:36 UTC (rev 138162)
@@ -1,3 +1,29 @@
+2012-12-19  Tim Volodine  <timvolod...@chromium.org>
+
+        Text Autosizing: Work out what to do about form controls
+        https://bugs.webkit.org/show_bug.cgi?id=102560
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Disallow autosizing of form input controls like buttons, text input fields, selection controls, radio buttons
+        and check boxes. This is a short term solution to avoid inconsistent autosizing of form controls (which is
+        worse than not autosizing at all).
+
+        Tests: fast/text-autosizing/form-controls-autosizing-button-input-elements.html
+               fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html
+               fast/text-autosizing/form-controls-autosizing-radio-input-element.html
+               fast/text-autosizing/form-controls-autosizing-select-element.html
+               fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html
+
+        * rendering/TextAutosizer.cpp:
+        (WebCore):
+        (WebCore::formInputTags):
+        (WebCore::TextAutosizer::isAutosizingContainer):
+        (WebCore::TextAutosizer::contentHeightIsConstrained):
+        (WebCore::TextAutosizer::containerShouldBeAutosized):
+        (WebCore::TextAutosizer::containerContainsOneOfTags):
+        * rendering/TextAutosizer.h:
+
 2012-12-19  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: Add Workspace.setFileContent() method

Modified: trunk/Source/WebCore/rendering/TextAutosizer.cpp (138161 => 138162)


--- trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-12-19 15:32:32 UTC (rev 138161)
+++ trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-12-19 15:34:36 UTC (rev 138162)
@@ -25,6 +25,7 @@
 #include "TextAutosizer.h"
 
 #include "Document.h"
+#include "HTMLElement.h"
 #include "InspectorInstrumentation.h"
 #include "IntSize.h"
 #include "RenderObject.h"
@@ -35,14 +36,30 @@
 #include "StyleInheritedData.h"
 
 #include <algorithm>
+#include <wtf/StdLibExtras.h>
 
 namespace WebCore {
 
+using namespace HTMLNames;
+
 struct TextAutosizingWindowInfo {
     IntSize windowSize;
     IntSize minLayoutSize;
 };
 
+
+static const Vector<QualifiedName>& formInputTags()
+{
+    // Returns the tags for the form input elements.
+    DEFINE_STATIC_LOCAL(Vector<QualifiedName>, formInputTags, ());
+    if (formInputTags.isEmpty()) {
+        formInputTags.append(inputTag);
+        formInputTags.append(buttonTag);
+        formInputTags.append(selectTag);
+    }
+    return formInputTags;
+}
+
 TextAutosizer::TextAutosizer(Document* document)
     : m_document(document)
 {
@@ -192,6 +209,11 @@
         return false;
     if (renderer->isListItem())
         return renderer->isFloating() || renderer->isOutOfFlowPositioned();
+    // Avoid creating containers for text within text controls, buttons, or <select> buttons.
+    Node* parentNode = renderer->parent() ? renderer->parent()->generatingNode() : 0;
+    if (parentNode && parentNode->isElementNode() && formInputTags().contains(toElement(parentNode)->tagQName()))
+        return false;
+
     return true;
 }
 
@@ -242,8 +264,36 @@
     return isAutosizingContainer(object) && isAutosizingCluster(toRenderBlock(object), 0);
 }
 
-static bool contentHeightIsConstrained(const RenderBlock* container)
+bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container)
 {
+    if (containerContainsOneOfTags(container, formInputTags()))
+        return false;
+
+    // Don't autosize block-level text that can't wrap (as it's likely to
+    // expand sideways and break the page's layout).
+    if (!container->style()->autoWrap())
+        return false;
+
+    return !contentHeightIsConstrained(container);
+}
+
+bool TextAutosizer::containerContainsOneOfTags(const RenderBlock* container, const Vector<QualifiedName>& tags)
+{
+    const RenderObject* renderer = container;
+    while (renderer) {
+        const Node* rendererNode = renderer->node();
+        if (rendererNode && rendererNode->isElementNode()) {
+            if (tags.contains(toElement(rendererNode)->tagQName()))
+                return true;
+        }
+        renderer = nextInPreOrderSkippingDescendantsOfContainers(renderer, container);
+    }
+
+    return false;
+}
+
+bool TextAutosizer::contentHeightIsConstrained(const RenderBlock* container)
+{
     // FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box.
     // FIXME: This code needs to take into account vertical writing modes.
     // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in.
@@ -262,16 +312,6 @@
     return false;
 }
 
-bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container)
-{
-    // Don't autosize block-level text that can't wrap (as it's likely to
-    // expand sideways and break the page's layout).
-    if (!container->style()->autoWrap())
-        return false;
-
-    return !contentHeightIsConstrained(container);
-}
-
 bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* blockContainingAllText, float blockWidth)
 {
     // Don't autosize clusters that contain less than 4 lines of text (in

Modified: trunk/Source/WebCore/rendering/TextAutosizer.h (138161 => 138162)


--- trunk/Source/WebCore/rendering/TextAutosizer.h	2012-12-19 15:32:32 UTC (rev 138161)
+++ trunk/Source/WebCore/rendering/TextAutosizer.h	2012-12-19 15:34:36 UTC (rev 138162)
@@ -28,6 +28,7 @@
 
 #if ENABLE(TEXT_AUTOSIZING)
 
+#include "HTMLNames.h"
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
 
@@ -69,6 +70,8 @@
     static bool isAutosizingCluster(const RenderObject*);
 
     static bool containerShouldBeAutosized(const RenderBlock* container);
+    static bool containerContainsOneOfTags(const RenderBlock* cluster, const Vector<QualifiedName>& tags);
+    static bool contentHeightIsConstrained(const RenderBlock* container);
     static bool clusterShouldBeAutosized(const RenderBlock* blockContainingAllText, float blockWidth);
     static void measureDescendantTextWidth(const RenderBlock* container, const RenderBlock* blockContainingAllText, float minTextWidth, float& textWidth);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to