Commit ee1c625e authored by dbates@webkit.org's avatar dbates@webkit.org

2011-05-12 Daniel Bates <dbates@rim.com>

        Reviewed by Adele Peterson.

        Frame's noResize attribute can not be set by JavaScript
        https://bugs.webkit.org/show_bug.cgi?id=14845

        Tests that frame resizing is allowed and disallowed depending on the value of the noResize property.

        Also, tests to ensure that frame resizing is allowed and disallowed when programmatically
        removing and adding the noresize attribute, respectively.

        * fast/frames/frame-inherit-noresize-from-frameset-expected.txt: Added.
        * fast/frames/frame-inherit-noresize-from-frameset.html: Added. See <https://bugs.webkit.org/show_bug.cgi?id=57604>.
        * fast/frames/frame-programmatic-noresize-expected.txt: Added.
        * fast/frames/frame-programmatic-noresize.html: Added.
        * fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize-expected.txt: Added.
        * fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize.html: Added.
        * fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false-expected.txt: Added.
        * fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false.html: Added.
        * fast/frames/resources/frame-programmatic-resize.js: Added.
        (setTestFrameById):
        (deltaWidth):
        (shouldAllowFrameResize):
        (shouldDisallowFrameResize):
        (shouldDisallowFrameResizeAfterProcessingFrame):
        (shouldAllowFrameResizeAfterProcessingFrame):
        (checkTestFrameWidthEquals):
        (resizeTestFrameBy):
        (log):
        (description):
2011-05-12  Daniel Bates  <dbates@rim.com>

        Reviewed by Adele Peterson.

        Frame's noResize attribute can not be set by JavaScript
        https://bugs.webkit.org/show_bug.cgi?id=14845

        Tests: fast/frames/frame-inherit-noresize-from-frameset.html
               fast/frames/frame-programmatic-noresize.html
               fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize.html
               fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false.html

        Implements support to programmatically allow and disallow frame resizing.

        Currently, HTMLFrameElement::parseMappedAttribute() is hardcoded to disallow frame resize (i.e.
        m_noResize = true) when either the noresize DOM attribute is specified (or existed at some
        point in time) or the value of the noResize attribute is modified. Instead we should allow/disallow
        frame resize depending on the presence of the noresize DOM attribute/the value of the noResize
        attribute.

        * html/HTMLFrameElement.cpp:
        (WebCore::HTMLFrameElement::HTMLFrameElement):
        (WebCore::HTMLFrameElement::noResize): Made this a non-inline function since this
        code path isn't performance critical.
        (WebCore::HTMLFrameElement::attach): Removed code to inherit noresize attribute from
        parent <frameset> since this functionality is part of RenderFrameSet::computeEdgeInfo().
        (WebCore::HTMLFrameElement::parseMappedAttribute):
        * html/HTMLFrameElement.h:
        * rendering/RenderFrame.cpp:
        (WebCore::RenderFrame::updateFromElement): Added.
        * rendering/RenderFrame.h:
        * rendering/RenderFrameSet.cpp:
        (WebCore::RenderFrameSet::notifyFrameEdgeInfoChanged): Added.
        * rendering/RenderFrameSet.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86390 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3b4922f9
2011-05-12 Daniel Bates <dbates@rim.com>
Reviewed by Adele Peterson.
Frame's noResize attribute can not be set by JavaScript
https://bugs.webkit.org/show_bug.cgi?id=14845
Tests that frame resizing is allowed and disallowed depending on the value of the noResize property.
Also, tests to ensure that frame resizing is allowed and disallowed when programmatically
removing and adding the noresize attribute, respectively.
* fast/frames/frame-inherit-noresize-from-frameset-expected.txt: Added.
* fast/frames/frame-inherit-noresize-from-frameset.html: Added. See <https://bugs.webkit.org/show_bug.cgi?id=57604>.
* fast/frames/frame-programmatic-noresize-expected.txt: Added.
* fast/frames/frame-programmatic-noresize.html: Added.
* fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize-expected.txt: Added.
* fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize.html: Added.
* fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false-expected.txt: Added.
* fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false.html: Added.
* fast/frames/resources/frame-programmatic-resize.js: Added.
(setTestFrameById):
(deltaWidth):
(shouldAllowFrameResize):
(shouldDisallowFrameResize):
(shouldDisallowFrameResizeAfterProcessingFrame):
(shouldAllowFrameResizeAfterProcessingFrame):
(checkTestFrameWidthEquals):
(resizeTestFrameBy):
(log):
(description):
2011-05-12 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
--------
Frame: 'testFrame'
--------
--------
Frame: 'results'
--------
This tests that a frame inherits the noresize attribute of its parent frameset by default. Note, this behavior doesn't seem to conform to any W3C spec or MSDN documentation. See WebKit Bug 57604.
PASS document.getElementById("testFrame").width is 200
<!DOCTYPE html>
<html>
<head>
<script src="resources/frame-programmatic-resize.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
}
window.onload = runTests;
function runTests()
{
if (!window.eventSender)
return; // Cannot run this test without DRT.
description("This tests that a frame inherits the noresize attribute of its parent frameset by default. Note, this behavior doesn't seem to conform to any W3C spec or MSDN documentation. See WebKit Bug 57604.");
setTestFrameById("testFrame");
shouldDisallowFrameResize();
}
</script>
</head>
<frameset cols="200,*" border="10" noresize>
<frame id="testFrame" src="about:blank">
<frame id="results" src="data:text/html,<p id='description'>This test can only be run using DRT.</p><pre id='console'></pre>">
</frameset>
</html>
--------
Frame: 'testFrame'
--------
--------
Frame: 'results'
--------
This tests that frame resizing is allowed and disallowed when programmatically removing and adding the noresize attribute, respectively.
Test disallow frame resize via noResize IDL attribute:
PASS document.getElementById("testFrame").width is 200
Test allow frame resize when noResize IDL attribute has value undefined:
PASS document.getElementById("testFrame").width is 210
Test allow frame resize when noResize IDL attribute has value null:
PASS document.getElementById("testFrame").width is 220
Test disallow frame resize via noresize content attribute:
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 220
Test disallow then allow frame resize via noResize IDL attribute (i.e. increase frame width by 10 pixels):
PASS document.getElementById("testFrame").width is 220
PASS document.getElementById("testFrame").width is 230
Test disallow then allow frame resize via noresize content attribute (i.e. increase frame width by 10 pixels):
PASS document.getElementById("testFrame").width is 230
PASS document.getElementById("testFrame").width is 240
<!DOCTYPE html>
<html>
<head>
<script src="resources/frame-programmatic-resize.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
}
window.onload = runTests;
function runTests()
{
if (!window.eventSender)
return; // Cannot run this test without DRT.
description("This tests that frame resizing is allowed and disallowed when programmatically removing and adding the noresize attribute, respectively.");
setTestFrameById("testFrame");
log("Test disallow frame resize via noResize IDL attribute:");
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { frame.noResize = true });
log("\nTest allow frame resize when noResize IDL attribute has value undefined:");
shouldAllowFrameResizeAfterProcessingFrame(function(frame) { frame.noResize = undefined });
log("\nTest allow frame resize when noResize IDL attribute has value null:");
shouldAllowFrameResizeAfterProcessingFrame(function(frame) { frame.noResize = null });
log("\nTest disallow frame resize via noresize content attribute:");
// Note, noresize is a boolean attribute. That is, its presence indicates true regardless of its value.
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { frame.setAttribute("noresize", "true") });
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { frame.setAttribute("noresize", "false") });
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { frame.setAttribute("noresize", "dummy") });
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { frame.setAttribute("noresize", String()) });
log("\nTest disallow then allow frame resize via noResize IDL attribute (i.e. increase frame width by " + deltaWidth() + " pixels):");
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { frame.noResize = true });
shouldAllowFrameResizeAfterProcessingFrame(function(frame) { frame.noResize = false });
log("\nTest disallow then allow frame resize via noresize content attribute (i.e. increase frame width by " + deltaWidth() + " pixels):");
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { frame.setAttribute("noresize", "true") });
shouldAllowFrameResizeAfterProcessingFrame(function(frame) { frame.removeAttribute("noresize") });
}
</script>
</head>
<frameset cols="200,*" border="10">
<frame id="testFrame" src="about:blank">
<frame id="results" src="data:text/html,<p id='description'>This test can only be run using DRT.</p><pre id='console'></pre>">
</frameset>
</html>
--------
Frame: 'testFrame'
--------
--------
Frame: 'results'
--------
This tests that a frame with a source code-specified noresize attribute can be resized after programmatically removing its noresize attribute.
PASS document.getElementById("testFrame").width is 210
<!DOCTYPE html>
<html>
<head>
<script src="resources/frame-programmatic-resize.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
}
window.onload = runTests;
function runTests()
{
if (!window.eventSender)
return; // Cannot run this test without DRT.
description("This tests that a frame with a source code-specified noresize attribute can be resized after programmatically removing its noresize attribute.");
setTestFrameById("testFrame");
shouldAllowFrameResizeAfterProcessingFrame(function(frame) { frame.removeAttribute("noresize") });
}
</script>
</head>
<frameset cols="200,*" border="10">
<frame id="testFrame" src="about:blank" noresize>
<frame id="results" src="data:text/html,<p id='description'>This test can only be run using DRT.</p><pre id='console'></pre>">
</frameset>
</html>
--------
Frame: 'testFrame'
--------
--------
Frame: 'results'
--------
This tests that a frame with a source code-specified noresize attribute can be resized after setting frame.noResize to false.
PASS document.getElementById("testFrame").width is 210
<!DOCTYPE html>
<html>
<head>
<script src="resources/frame-programmatic-resize.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
}
window.onload = runTests;
function runTests()
{
if (!window.eventSender)
return; // Cannot run this test without DRT.
description("This tests that a frame with a source code-specified noresize attribute can be resized after setting frame.noResize to false.");
setTestFrameById("testFrame");
shouldAllowFrameResizeAfterProcessingFrame(function(frame) { frame.noResize = false });
}
</script>
</head>
<frameset cols="200,*" border="10">
<frame id="testFrame" src="about:blank" noresize>
<frame id="results" src="data:text/html,<p id='description'>This test can only be run using DRT.</p><pre id='console'></pre>">
</frameset>
</html>
var _testFrame;
var _testFrameId; // We keep the id of the test frame to make it easier for a person to interpret the test results.
function setTestFrameById(id)
{
_testFrameId = id;
_testFrame = document.getElementById(id);
}
function deltaWidth()
{
return 10; // A resonable amount to be able to detect that the frame width changed.
}
function shouldAllowFrameResize()
{
shouldAllowFrameResizeAfterProcessingFrame(function(frame) { /* Do nothing. */});
}
function shouldDisallowFrameResize()
{
shouldDisallowFrameResizeAfterProcessingFrame(function(frame) { /* Do nothing. */})
}
function shouldDisallowFrameResizeAfterProcessingFrame(processFrameFunction)
{
var expectedWidth = _testFrame.width;
processFrameFunction(_testFrame);
resizeTestFrameBy(deltaWidth());
checkTestFrameWidthEquals(expectedWidth);
}
function shouldAllowFrameResizeAfterProcessingFrame(processFrameFunction)
{
var expectedWidth = _testFrame.width + deltaWidth();
processFrameFunction(_testFrame);
resizeTestFrameBy(deltaWidth());
checkTestFrameWidthEquals(expectedWidth);
}
function checkTestFrameWidthEquals(expectedWidth)
{
if (_testFrame.width === expectedWidth)
log('PASS document.getElementById("' + _testFrameId + '").width is ' + expectedWidth);
else
log('FAIL document.getElementById("' + _testFrameId + '").width should be ' + expectedWidth + '. Was ' + _testFrame.width + '.');
}
function resizeTestFrameBy(deltaWidthInPixels)
{
var borderWidth = parseInt(_testFrame.parentNode.getAttribute("border"));
var startX = _testFrame.offsetWidth + borderWidth / 2;
var startY = _testFrame.offsetHeight / 2;
var endX = startX + deltaWidthInPixels;
var endY = startY;
eventSender.mouseMoveTo(startX, startY);
eventSender.mouseDown();
eventSender.leapForward(100);
eventSender.mouseMoveTo(endX, endY);
eventSender.mouseUp();
}
function log(message)
{
document.getElementById("results").contentDocument.getElementById("console").appendChild(document.createTextNode(message + "\n"));
}
function description(message)
{
document.getElementById("results").contentDocument.getElementById("description").innerText = message;
}
2011-05-12 Daniel Bates <dbates@rim.com>
Reviewed by Adele Peterson.
Frame's noResize attribute can not be set by JavaScript
https://bugs.webkit.org/show_bug.cgi?id=14845
Tests: fast/frames/frame-inherit-noresize-from-frameset.html
fast/frames/frame-programmatic-noresize.html
fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize.html
fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false.html
Implements support to programmatically allow and disallow frame resizing.
Currently, HTMLFrameElement::parseMappedAttribute() is hardcoded to disallow frame resize (i.e.
m_noResize = true) when either the noresize DOM attribute is specified (or existed at some
point in time) or the value of the noResize attribute is modified. Instead we should allow/disallow
frame resize depending on the presence of the noresize DOM attribute/the value of the noResize
attribute.
* html/HTMLFrameElement.cpp:
(WebCore::HTMLFrameElement::HTMLFrameElement):
(WebCore::HTMLFrameElement::noResize): Made this a non-inline function since this
code path isn't performance critical.
(WebCore::HTMLFrameElement::attach): Removed code to inherit noresize attribute from
parent <frameset> since this functionality is part of RenderFrameSet::computeEdgeInfo().
(WebCore::HTMLFrameElement::parseMappedAttribute):
* html/HTMLFrameElement.h:
* rendering/RenderFrame.cpp:
(WebCore::RenderFrame::updateFromElement): Added.
* rendering/RenderFrame.h:
* rendering/RenderFrameSet.cpp:
(WebCore::RenderFrameSet::notifyFrameEdgeInfoChanged): Added.
* rendering/RenderFrameSet.h:
2011-05-12 Emil A Eklund <eae@chromium.org>
Reviewed by Darin Adler.
......@@ -38,7 +38,6 @@ inline HTMLFrameElement::HTMLFrameElement(const QualifiedName& tagName, Document
: HTMLFrameElementBase(tagName, document)
, m_frameBorder(true)
, m_frameBorderSet(false)
, m_noResize(false)
{
ASSERT(hasTagName(frameTag));
}
......@@ -68,6 +67,11 @@ static inline HTMLFrameSetElement* containingFrameSetElement(Node* node)
return 0;
}
bool HTMLFrameElement::noResize() const
{
return hasAttribute(noresizeAttr);
}
void HTMLFrameElement::attach()
{
HTMLFrameElementBase::attach();
......@@ -75,8 +79,6 @@ void HTMLFrameElement::attach()
if (HTMLFrameSetElement* frameSetElement = containingFrameSetElement(this)) {
if (!m_frameBorderSet)
m_frameBorder = frameSetElement->hasFrameBorder();
if (!m_noResize)
m_noResize = frameSetElement->noResize();
}
}
......@@ -87,10 +89,8 @@ void HTMLFrameElement::parseMappedAttribute(Attribute* attr)
m_frameBorderSet = !attr->isNull();
// FIXME: If we are already attached, this has no effect.
} else if (attr->name() == noresizeAttr) {
m_noResize = true;
// FIXME: If we are already attached, this has no effect.
// FIXME: Since this does not check attr->isNull(), it can
// never reset m_noResize to false if the attribute is removed.
if (renderer())
renderer()->updateFromElement();
} else
HTMLFrameElementBase::parseMappedAttribute(attr);
}
......
......@@ -34,7 +34,7 @@ public:
bool hasFrameBorder() const { return m_frameBorder; }
bool noResize() const { return m_noResize; }
bool noResize() const;
private:
HTMLFrameElement(const QualifiedName&, Document*);
......@@ -52,8 +52,6 @@ private:
bool m_frameBorder;
bool m_frameBorderSet;
bool m_noResize;
};
} // namespace WebCore
......
......@@ -42,6 +42,12 @@ FrameEdgeInfo RenderFrame::edgeInfo() const
return FrameEdgeInfo(element->noResize(), element->hasFrameBorder());
}
void RenderFrame::updateFromElement()
{
if (parent() && parent()->isFrameSet())
toRenderFrameSet(parent())->notifyFrameEdgeInfoChanged();
}
void RenderFrame::viewCleared()
{
HTMLFrameElement* element = static_cast<HTMLFrameElement*>(node());
......
......@@ -40,6 +40,8 @@ private:
virtual const char* renderName() const { return "RenderFrame"; }
virtual bool isFrame() const { return true; }
virtual void updateFromElement();
virtual void viewCleared();
};
......
......@@ -380,6 +380,15 @@ void RenderFrameSet::layOutAxis(GridAxis& axis, const Length* grid, int availabl
}
}
void RenderFrameSet::notifyFrameEdgeInfoChanged()
{
if (needsLayout())
return;
// FIXME: We should only recompute the edge info with respect to the frame that changed
// and its adjacent frame(s) instead of recomputing the edge info for the entire frameset.
computeEdgeInfo();
}
void RenderFrameSet::fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, int r, int c)
{
if (edgeInfo.allowBorder(LeftFrameEdge))
......
......@@ -29,6 +29,7 @@ namespace WebCore {
class HTMLFrameSetElement;
class MouseEvent;
class RenderFrame;
enum FrameEdge { LeftFrameEdge, RightFrameEdge, TopFrameEdge, BottomFrameEdge };
......@@ -70,6 +71,8 @@ public:
bool canResizeRow(const IntPoint&) const;
bool canResizeColumn(const IntPoint&) const;
void notifyFrameEdgeInfoChanged();
private:
static const int noSplit = -1;
......
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