Commit 1bf1cb62 authored by tonikitoo@webkit.org's avatar tonikitoo@webkit.org
Browse files

Harden RenderBox::canBeScrolledAndHasScrollableArea logic...

Harden RenderBox::canBeScrolledAndHasScrollableArea logic https://bugs.webkit.org/show_bug.cgi?id=104373

Reviewed by Simon Fraser.
Patch by Antonio Gomes <a1.gomes@sisa.samsung.com>

Source/WebCore:

Previously if a say div has a overflown content on 'y' but is
styled as "overflow-x: auto; overflow-y: hidden", RenderBox::canBeProgramaticallyScrolled
would still return true. It interfers, among other things, with the way
autoscroll works.

Patch fixes it by adding two helper methods to RenderBox class in order to verify a box'
scrollability in a given axis (x or y); They are used when checking if a given box is in
fact programatically scrollable.

Test: fast/events/autoscroll-overflow-hidden-longhands.html

WebKit autoscroll behavior now matches Firefox and Opera12 (pre-blink)
in that sense.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::canBeProgramaticallyScrolled):
* rendering/RenderBox.h:
(WebCore::RenderBox::hasScrollableOverflowX):
(WebCore::RenderBox::hasScrollableOverflowY):

LayoutTests:

Patch adds a test to ensure autoscrolling only happens on a given
axis if it is scrollable in that direction, according to its style.

* fast/events/autoscroll-overflow-hidden-longhands-expected.txt: Added.
* fast/events/autoscroll-overflow-hidden-longhands.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154383 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ce8f1831
2013-08-20 Antonio Gomes <a1.gomes@sisa.samsung.com>
Harden RenderBox::canBeScrolledAndHasScrollableArea logic
https://bugs.webkit.org/show_bug.cgi?id=104373
Reviewed by Simon Fraser.
Patch adds a test to ensure autoscrolling only happens on a given
axis if it is scrollable in that direction, according to its style.
* fast/events/autoscroll-overflow-hidden-longhands-expected.txt: Added.
* fast/events/autoscroll-overflow-hidden-longhands.html: Added.
2013-08-19 Antonio Gomes <a1.gomes@sisa.samsung.com>
 
Text dragging can scroll overflow:hidden boxes
Try to autoscroll this text.
PASSED : the autoscroll did not happen!
<html>
<head>
<script>
function log(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
}
function test()
{
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
setTimeout(autoscrollTestPart1, 0);
}
}
function autoscrollTestPart1()
{
var textInDiv = document.getElementById('textInDiv');
if (window.eventSender) {
var x = textInDiv.offsetLeft + 17;
var y = textInDiv.offsetTop + 7;
eventSender.dragMode = false;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseMoveTo(x, y + 20);
eventSender.mouseMoveTo(x, y + 220);
}
setTimeout(autoscrollTestPart2, 100);
}
function autoscrollTestPart2()
{
if (window.eventSender)
eventSender.mouseUp();
var sd = document.getElementById('nonScrollableDiv');
if (sd.scrollTop == 0)
log("PASSED : the autoscroll did not happen!");
else
log("FAILED : the autoscroll has happened :-(");
if (window.testRunner)
testRunner.notifyDone();
}
</script>
</head>
<body onload="test()">
<div id="nonScrollableDiv" style="height: 100px; overflow-x: auto; overflow-y: hidden; width: 100px">
<div id="tailDiv" style=" height: 1000px; background-color: yellow">
<span id='textInDiv'> Try to autoscroll this text.<br>
</div>
</div>
<div id="console"></div>
</body>
</html>
2013-08-20 Antonio Gomes <a1.gomes@sisa.samsung.com>
Harden RenderBox::canBeScrolledAndHasScrollableArea logic
https://bugs.webkit.org/show_bug.cgi?id=104373
Reviewed by Simon Fraser.
Previously if a say div has a overflown content on 'y' but is
styled as "overflow-x: auto; overflow-y: hidden", RenderBox::canBeProgramaticallyScrolled
would still return true. It interfers, among other things, with the way
autoscroll works.
Patch fixes it by adding two helper methods to RenderBox class in order to verify a box'
scrollability in a given axis (x or y); They are used when checking if a given box is in
fact programatically scrollable.
Test: fast/events/autoscroll-overflow-hidden-longhands.html
WebKit autoscroll behavior now matches Firefox and Opera12 (pre-blink)
in that sense.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::canBeProgramaticallyScrolled):
* rendering/RenderBox.h:
(WebCore::RenderBox::hasScrollableOverflowX):
(WebCore::RenderBox::hasScrollableOverflowY):
2013-08-19 Antonio Gomes <a1.gomes@sisa.samsung.com>
 
Text dragging can scroll overflow:hidden boxes
......@@ -790,7 +790,18 @@ bool RenderBox::canBeScrolledAndHasScrollableArea() const
bool RenderBox::canBeProgramaticallyScrolled() const
{
return (hasOverflowClip() && (scrollsOverflow() || (node() && node()->rendererIsEditable()))) || (node() && node()->isDocumentNode());
Node* node = this->node();
if (node && node->isDocumentNode())
return true;
if (!hasOverflowClip())
return false;
bool hasScrollableOverflow = hasScrollableOverflowX() || hasScrollableOverflowY();
if (scrollsOverflow() && hasScrollableOverflow)
return true;
return node && node->rendererIsEditable();
}
bool RenderBox::usesCompositedScrolling() const
......
......@@ -463,6 +463,9 @@ public:
bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
bool hasScrollableOverflowX() const { return scrollsOverflowX() && scrollWidth() != clientWidth(); }
bool hasScrollableOverflowY() const { return scrollsOverflowY() && scrollHeight() != clientHeight(); }
bool usesCompositedScrolling() const;
bool hasUnsplittableScrollingOverflow() 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