Commit 54a20390 authored by tkent@chromium.org's avatar tkent@chromium.org

Revert of Textarea resize-able only to larger; min-height and min-width...

Revert of Textarea resize-able only to larger; min-height and min-width properly set (https://codereview.chromium.org/239983004/)

Reason for revert:
Regression for RTL textareas.


Original issue's description:
> Textarea resize-able only to larger; min-height and min-width properly set
> 
> Textarea does not respect the min-height and min-width property when they are
> set by user. When textarea min-height and min-width is set by the user and
> if we resize textarea it will only resize to value larger than the width and
> heght of textarea and not with value smaller than it's width and height. It
> assumes width and height as min-width and min height and does not take into
> account the actual min-width and min-height set by user. This patch removes
> this bug by initializing the setMinimumSizeForResizing value with min-width
> and min-height.
> 
> BUG=94583
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=173269

BUG=94583,371743
TBR=harpreet.sk@samsung.com, chaffraix@chromium.org

Review URL: https://codereview.chromium.org/336143002

git-svn-id: svn://svn.chromium.org/blink/trunk@176170 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0bb62b7d
Test for resizing the Textarea below it's initial size and with orthogonal containing block.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.getElementById("textInputID").style.width is "64px"
PASS document.getElementById("textInputID").style.height; is "74px"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<pre id="console"></pre>
<div id="res" style="-webkit-writing-mode: vertical-lr; width:800px; height:700px">
<textarea style="-webkit-writing-mode: horizontal-tb; width:400px; height:400px; min-width:10%; min-height:10%" id="textInputID">
Some text
</textarea>
</div>
<script>
description("<b>Test for resizing the Textarea below it's initial size and with orthogonal containing block.</b>");
test();
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
}
function test()
{
if (window.testRunner)
testDragAndMove();
else
log("\n\nThis test needs window.testRunner and window.eventSender to work. To manually test it, drag the textarea below. \nFor test to pass the width and height of textarea should not go below min-width and min-height\n\n");
}
function testDragAndMove()
{
var startX = document.getElementById("textInputID").offsetLeft + 400;
var startY = document.getElementById("textInputID").offsetTop + 400;
eventSender.dragMode = false;
eventSender.mouseMoveTo(startX,startY);
eventSender.mouseDown();
// Then drag it.
eventSender.mouseMoveTo(startX - 395, startY - 395);
eventSender.mouseUp();
// The min-width/min-height includes padding and border and width/height does not include padding and border.
// So when we set say min-width = 200px it means actual minimum width of box to be 194px (as 2px
// paddding and 1px border on all side).
// Also the containing block is orthogonal to the textarea so min-width will be 10% of height of containing block
// and min-height is 10% of width of containing block.
shouldBeEqualToString('document.getElementById("textInputID").style.width', '64px');
shouldBeEqualToString('document.getElementById("textInputID").style.height;', '74px');
}
</script>
</body>
</html>
Test for resizing the Textarea above minimum size set and below it's initial size.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.getElementById("textInputID").style.width is "250px"
PASS document.getElementById("textInputID").style.height; is "250px"
PASS document.getElementById("textInputID").style.width is "250px"
PASS document.getElementById("textInputID").style.height; is "250px"
PASS document.getElementById("textInputID").style.width is "250px"
PASS document.getElementById("textInputID").style.height; is "250px"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<pre id="console"></pre>
<div style="width:800px; height:800px">
<textarea id="textInputID">
Some text
</textarea>
</div>
<script>
description("<b>Test for resizing the Textarea above minimum size set and below it's initial size.</b>");
updateSize();
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
}
function updateSize()
{
if (window.testRunner) {
var textAreaElement = document.getElementById("textInputID");
textAreaElement.style.width = "400px";
textAreaElement.style.height = "400px";
textAreaElement.style.minWidth="200px";
textAreaElement.style.minHeight="200px";
testDragAndMove();
textAreaElement.style.width = "400px";
textAreaElement.style.height = "400px";
textAreaElement.style.minWidth="15vw";
textAreaElement.style.minHeight="15vh";
testDragAndMove();
textAreaElement.style.width = "400px";
textAreaElement.style.height = "400px";
textAreaElement.style.minWidth="10%";
textAreaElement.style.minHeight="10%";
testDragAndMove();
} else
log("\n\nThis test needs window.testRunner and window.eventSender to work. To manually test it, drag the textarea below. \nFor test to pass the width and height of textarea should not go below min-width and min-height\n\n");
}
function testDragAndMove()
{
var startX = document.getElementById("textInputID").offsetLeft + 400;
var startY = document.getElementById("textInputID").offsetTop + 400;
eventSender.dragMode = false;
eventSender.mouseMoveTo(startX,startY);
eventSender.mouseDown();
// Then drag it.
eventSender.mouseMoveTo(startX - 150, startY - 150);
eventSender.mouseUp();
shouldBeEqualToString('document.getElementById("textInputID").style.width', '250px');
shouldBeEqualToString('document.getElementById("textInputID").style.height;', '250px');
}
</script>
</body>
</html>
Test for resizing the Textarea below it's min intrinsic size.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.getElementById("textInputID").style.width is "9px"
PASS document.getElementById("textInputID").style.height; is "9px"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<pre id="console"></pre>
<textarea style="width:400px; height:400px" id="textInputID">
Some text
</textarea>
<script>
description("<b>Test for resizing the Textarea below it's min intrinsic size.</b>");
test();
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
}
function test()
{
if (window.testRunner)
testDragAndMove();
else
log("\n\nThis test needs window.testRunner and window.eventSender to work. To manually test it, drag the textarea below. \nFor test to pass the width and height of textarea should not go below min-width and min-height\n\n");
}
function testDragAndMove()
{
var startX = document.getElementById("textInputID").offsetLeft + 400;
var startY = document.getElementById("textInputID").offsetTop + 400;
eventSender.dragMode = false;
eventSender.mouseMoveTo(startX,startY);
eventSender.mouseDown();
// Then drag it.
eventSender.mouseMoveTo(startX - 395, startY - 395);
eventSender.mouseUp();
// The min-width/min-height includes padding and border and width/height does not include padding and border.
// So when we set say min-width = 200px it means actual minimum width of box to be 194px (as 2px paddding and 1px border on all side).
// Hence the condition check here for 9px as default minimum size for resizing is 15x15.
shouldBeEqualToString('document.getElementById("textInputID").style.width', '9px');
shouldBeEqualToString('document.getElementById("textInputID").style.height;', '9px');
}
</script>
</body>
</html>
Test for resizing the Textarea below the minimum size set.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.getElementById("textInputID").style.width is "194px"
PASS document.getElementById("textInputID").style.height; is "194px"
PASS document.getElementById("textInputID").style.width is "114px"
PASS document.getElementById("textInputID").style.height; is "84px"
PASS document.getElementById("textInputID").style.width is "74px"
PASS document.getElementById("textInputID").style.height; is "74px"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<pre id="console"></pre>
<div style="width:800px; height:800px">
<textarea id="textInputID">
Some text
</textarea>
</div>
<script>
description("<b>Test for resizing the Textarea below the minimum size set.</b>");
updateSize();
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
}
function updateSize()
{
if (window.testRunner) {
var textAreaElement = document.getElementById("textInputID");
textAreaElement.style.width = "400px";
textAreaElement.style.height = "400px";
textAreaElement.style.minWidth="200px";
textAreaElement.style.minHeight="200px";
testDragAndMove("fixed");
textAreaElement.style.width = "400px";
textAreaElement.style.height = "400px";
textAreaElement.style.minWidth="15vw";
textAreaElement.style.minHeight="15vh";
testDragAndMove("relative-viewport");
textAreaElement.style.width = "400px";
textAreaElement.style.height = "400px";
textAreaElement.style.minWidth="10%";
textAreaElement.style.minHeight="10%";
testDragAndMove("percentage");
} else
log("\n\nThis test needs window.testRunner and window.eventSender to work. To manually test it, drag the textarea below. \nFor test to pass the width and height of textarea should not go below min-width and min-height\n\n");
}
function testDragAndMove(type)
{
var startX = document.getElementById("textInputID").offsetLeft + 400;
var startY = document.getElementById("textInputID").offsetTop + 400;
eventSender.dragMode = false;
eventSender.mouseMoveTo(startX,startY);
eventSender.mouseDown();
// Then drag it.
eventSender.mouseMoveTo(startX - 350, startY - 350);
eventSender.mouseUp();
// The min-width/min-height includes padding and border and width/height does not include padding and border.
// So when we set say min-width = 200px it means actual minimum width of box to be 194px (as 2px paddding and 1px border on all side).
// Hence the condition check here for values which are lesser than original value by 6px.
if (type == "fixed") {
shouldBeEqualToString('document.getElementById("textInputID").style.width', '194px');
shouldBeEqualToString('document.getElementById("textInputID").style.height;', '194px');
} else if (type == "relative-viewport") {
shouldBeEqualToString('document.getElementById("textInputID").style.width', '114px');
shouldBeEqualToString('document.getElementById("textInputID").style.height;', '84px');
} else {
shouldBeEqualToString('document.getElementById("textInputID").style.width', '74px');
shouldBeEqualToString('document.getElementById("textInputID").style.height;', '74px');
}
}
</script>
</body>
</html>
...@@ -2442,6 +2442,18 @@ bool Element::isInDescendantTreeOf(const Element* shadowHost) const ...@@ -2442,6 +2442,18 @@ bool Element::isInDescendantTreeOf(const Element* shadowHost) const
return false; return false;
} }
LayoutSize Element::minimumSizeForResizing() const
{
return hasRareData() ? elementRareData()->minimumSizeForResizing() : defaultMinimumSizeForResizing();
}
void Element::setMinimumSizeForResizing(const LayoutSize& size)
{
if (!hasRareData() && size == defaultMinimumSizeForResizing())
return;
ensureElementRareData().setMinimumSizeForResizing(size);
}
RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier)
{ {
if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) if (PseudoElement* element = pseudoElement(pseudoElementSpecifier))
......
...@@ -404,6 +404,9 @@ public: ...@@ -404,6 +404,9 @@ public:
virtual const AtomicString& shadowPseudoId() const; virtual const AtomicString& shadowPseudoId() const;
void setShadowPseudoId(const AtomicString&); void setShadowPseudoId(const AtomicString&);
LayoutSize minimumSizeForResizing() const;
void setMinimumSizeForResizing(const LayoutSize&);
virtual void didBecomeFullscreenElement() { } virtual void didBecomeFullscreenElement() { }
virtual void willStopBeingFullscreenElement() { } virtual void willStopBeingFullscreenElement() { }
......
...@@ -37,6 +37,7 @@ namespace WebCore { ...@@ -37,6 +37,7 @@ namespace WebCore {
struct SameSizeAsElementRareData : NodeRareData { struct SameSizeAsElementRareData : NodeRareData {
short indices[2]; short indices[2];
LayoutSize sizeForResizing;
IntSize scrollOffset; IntSize scrollOffset;
void* pointers[12]; void* pointers[12];
}; };
......
...@@ -97,6 +97,9 @@ public: ...@@ -97,6 +97,9 @@ public:
DatasetDOMStringMap* dataset() const { return m_dataset.get(); } DatasetDOMStringMap* dataset() const { return m_dataset.get(); }
void setDataset(PassOwnPtrWillBeRawPtr<DatasetDOMStringMap> dataset) { m_dataset = dataset; } void setDataset(PassOwnPtrWillBeRawPtr<DatasetDOMStringMap> dataset) { m_dataset = dataset; }
LayoutSize minimumSizeForResizing() const { return m_minimumSizeForResizing; }
void setMinimumSizeForResizing(LayoutSize size) { m_minimumSizeForResizing = size; }
IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; }
void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = size; } void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = size; }
...@@ -125,6 +128,7 @@ public: ...@@ -125,6 +128,7 @@ public:
private: private:
short m_tabindex; short m_tabindex;
LayoutSize m_minimumSizeForResizing;
IntSize m_savedLayerScrollOffset; IntSize m_savedLayerScrollOffset;
OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset; OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset;
...@@ -145,9 +149,15 @@ private: ...@@ -145,9 +149,15 @@ private:
explicit ElementRareData(RenderObject*); explicit ElementRareData(RenderObject*);
}; };
inline IntSize defaultMinimumSizeForResizing()
{
return IntSize(LayoutUnit::max(), LayoutUnit::max());
}
inline ElementRareData::ElementRareData(RenderObject* renderer) inline ElementRareData::ElementRareData(RenderObject* renderer)
: NodeRareData(renderer) : NodeRareData(renderer)
, m_tabindex(0) , m_tabindex(0)
, m_minimumSizeForResizing(defaultMinimumSizeForResizing())
{ {
m_isElementRareData = true; m_isElementRareData = true;
} }
......
...@@ -75,11 +75,6 @@ namespace WebCore { ...@@ -75,11 +75,6 @@ namespace WebCore {
const int ResizerControlExpandRatioForTouch = 2; const int ResizerControlExpandRatioForTouch = 2;
// Default value is set to 15 as the default
// minimum size used by firefox is 15x15.
static const int defaultMinimumWidthForResizing = 15;
static const int defaultMinimumHeightForResizing = 15;
RenderLayerScrollableArea::RenderLayerScrollableArea(RenderLayer& layer) RenderLayerScrollableArea::RenderLayerScrollableArea(RenderLayer& layer)
: m_layer(layer) : m_layer(layer)
, m_inResizeMode(false) , m_inResizeMode(false)
...@@ -715,16 +710,6 @@ static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) ...@@ -715,16 +710,6 @@ static bool overflowDefinesAutomaticScrollbar(EOverflow overflow)
return overflow == OAUTO || overflow == OOVERLAY; return overflow == OAUTO || overflow == OOVERLAY;
} }
IntSize RenderLayerScrollableArea::minimumSizeForResizing()
{
int minimumWidth = intValueForLength(box().style()->logicalMinWidth(), box().containingBlock()->logicalWidth());
int minimumHeight = intValueForLength(box().style()->logicalMinHeight(), box().containingBlock()->logicalHeight());
minimumWidth = std::max(minimumWidth, defaultMinimumWidthForResizing);
minimumHeight = std::max(minimumHeight, defaultMinimumHeightForResizing);
return IntSize(minimumWidth, minimumHeight);
}
void RenderLayerScrollableArea::updateAfterStyleChange(const RenderStyle* oldStyle) void RenderLayerScrollableArea::updateAfterStyleChange(const RenderStyle* oldStyle)
{ {
// List box parts handle the scrollbars by themselves so we have nothing to do. // List box parts handle the scrollbars by themselves so we have nothing to do.
...@@ -1365,6 +1350,8 @@ void RenderLayerScrollableArea::resize(const PlatformEvent& evt, const LayoutSiz ...@@ -1365,6 +1350,8 @@ void RenderLayerScrollableArea::resize(const PlatformEvent& evt, const LayoutSiz
newOffset.setHeight(newOffset.height() / zoomFactor); newOffset.setHeight(newOffset.height() / zoomFactor);
LayoutSize currentSize = LayoutSize(box().width() / zoomFactor, box().height() / zoomFactor); LayoutSize currentSize = LayoutSize(box().width() / zoomFactor, box().height() / zoomFactor);
LayoutSize minimumSize = element->minimumSizeForResizing().shrunkTo(currentSize);
element->setMinimumSizeForResizing(minimumSize);
LayoutSize adjustedOldOffset = LayoutSize(oldOffset.width() / zoomFactor, oldOffset.height() / zoomFactor); LayoutSize adjustedOldOffset = LayoutSize(oldOffset.width() / zoomFactor, oldOffset.height() / zoomFactor);
if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) { if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) {
...@@ -1372,7 +1359,7 @@ void RenderLayerScrollableArea::resize(const PlatformEvent& evt, const LayoutSiz ...@@ -1372,7 +1359,7 @@ void RenderLayerScrollableArea::resize(const PlatformEvent& evt, const LayoutSiz
adjustedOldOffset.setWidth(-adjustedOldOffset.width()); adjustedOldOffset.setWidth(-adjustedOldOffset.width());
} }
LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSizeForResizing()) - currentSize; LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - currentSize;
bool isBoxSizingBorder = box().style()->boxSizing() == BORDER_BOX; bool isBoxSizingBorder = box().style()->boxSizing() == BORDER_BOX;
......
...@@ -203,7 +203,6 @@ private: ...@@ -203,7 +203,6 @@ private:
void setHasVerticalScrollbar(bool hasScrollbar); void setHasVerticalScrollbar(bool hasScrollbar);
void updateScrollCornerStyle(); void updateScrollCornerStyle();
IntSize minimumSizeForResizing();
// See comments on isPointInResizeControl. // See comments on isPointInResizeControl.
IntRect resizerCornerRect(const IntRect&, ResizerHitTestType) const; IntRect resizerCornerRect(const IntRect&, ResizerHitTestType) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment