Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: Source/WebCore/rendering/TextAutosizer.cpp

Issue 11858022: Merge 138162 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/rendering/TextAutosizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/rendering/TextAutosizer.cpp
===================================================================
--- Source/WebCore/rendering/TextAutosizer.cpp (revision 139475)
+++ Source/WebCore/rendering/TextAutosizer.cpp (working copy)
@@ -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;
}
@@ -251,8 +273,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.
@@ -271,16 +321,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
« no previous file with comments | « Source/WebCore/rendering/TextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698