[webkit-changes] cvs commit: WebCore/manual-tests
scrollIntoView-horizontal.html scrollIntoView-vertical.html
Vicki
vicki at opensource.apple.com
Tue Jul 19 15:41:48 PDT 2005
vicki 05/07/19 15:41:48
Modified: . ChangeLog
khtml/xml dom_elementimpl.h dom_elementimpl.cpp
khtml/ecma kjs_dom.h kjs_dom.cpp
Added: manual-tests scrollIntoView-horizontal.html
scrollIntoView-vertical.html
Log:
Reviewed by Maciej.
Test cases added:
* manual-tests/scrollIntoView-horizontal.html: Added.
* manual-tests/scrollIntoView-vertical.html: Added.
* khtml/xml/dom_elementimpl.h:
* khtml/xml/dom_elementimpl.cpp:
(ElementImpl::scrollIntoView): Added.
* khtml/ecma/kjs_dom.h:
(KJS::DOMNode::):
(KJS::DOMElement::):
* khtml/ecma/kjs_dom.cpp:
(KJS::DOMElementProtoFunc::tryCall): glue for new scrollIntoView function
Revision Changes Path
1.4443 +17 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4442
retrieving revision 1.4443
diff -u -r1.4442 -r1.4443
--- ChangeLog 19 Jul 2005 21:17:59 -0000 1.4442
+++ ChangeLog 19 Jul 2005 22:41:42 -0000 1.4443
@@ -1,3 +1,20 @@
+2005-07-19 Vicki Murley <vicki at apple.com>
+
+ Reviewed by Maciej.
+
+ Test cases added:
+ * manual-tests/scrollIntoView-horizontal.html: Added.
+ * manual-tests/scrollIntoView-vertical.html: Added.
+
+ * khtml/xml/dom_elementimpl.h:
+ * khtml/xml/dom_elementimpl.cpp:
+ (ElementImpl::scrollIntoView): Added.
+ * khtml/ecma/kjs_dom.h:
+ (KJS::DOMNode::):
+ (KJS::DOMElement::):
+ * khtml/ecma/kjs_dom.cpp:
+ (KJS::DOMElementProtoFunc::tryCall): glue for new scrollIntoView function
+
2005-07-19 Geoffrey Garen <ggaren at apple.com>
- rolled in patch by opendarwin.org at mitzpettel.com for
1.47 +2 -0 WebCore/khtml/xml/dom_elementimpl.h
Index: dom_elementimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_elementimpl.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- dom_elementimpl.h 18 Jul 2005 21:44:28 -0000 1.46
+++ dom_elementimpl.h 19 Jul 2005 22:41:47 -0000 1.47
@@ -178,6 +178,8 @@
void setAttribute(const DOMString &name, const DOMString &value, int &exception) { setAttributeNS(DOMString(), name, value, exception); }
void setAttributeNS(const DOMString &namespaceURI, const DOMString &qualifiedName, const DOMString &value, int &exception);
+ void scrollIntoView (bool alignToTop);
+
void removeAttribute(const DOMString &name, int &exception) { removeAttributeNS(DOMString(), name, exception); }
void removeAttributeNS(const DOMString &namespaceURI, const DOMString &localName, int &exception);
1.70 +17 -0 WebCore/khtml/xml/dom_elementimpl.cpp
Index: dom_elementimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_elementimpl.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- dom_elementimpl.cpp 18 Jul 2005 21:44:28 -0000 1.69
+++ dom_elementimpl.cpp 19 Jul 2005 22:41:47 -0000 1.70
@@ -32,6 +32,7 @@
#include "xml/dom_elementimpl.h"
#include "khtml_part.h"
+#include "khtmlview.h"
#include "html/htmlparser.h"
@@ -287,6 +288,22 @@
return nullAtom;
}
+void ElementImpl::scrollIntoView(bool alignToTop)
+{
+ KHTMLView *v = getDocument()->view();
+ QRect bounds = this->getRect();
+ int x, y, xe, ye;
+ x = bounds.left();
+ y = bounds.top();
+ xe = bounds.right();
+ ye = bounds.bottom();
+
+ if (alignToTop)
+ v->setContentsPos(x, y);
+ else
+ v->ensureVisible(x, y, xe-x, ye-y);
+}
+
const AtomicString& ElementImpl::getAttributeNS(const DOMString &namespaceURI,
const DOMString &localName) const
{
1.44 +2 -2 WebCore/khtml/ecma/kjs_dom.h
Index: kjs_dom.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- kjs_dom.h 19 Jul 2005 19:52:49 -0000 1.43
+++ kjs_dom.h 19 Jul 2005 22:41:47 -0000 1.44
@@ -77,7 +77,7 @@
OnMouseMove, OnMouseOut, OnMouseOver, OnMouseUp, OnMouseWheel, OnMove, OnReset,
OnResize, OnScroll, OnSearch, OnSelect, OnSubmit, OnUnload,
OffsetLeft, OffsetTop, OffsetWidth, OffsetHeight, OffsetParent,
- ClientWidth, ClientHeight, ScrollLeft, ScrollTop, ScrollWidth, ScrollHeight };
+ ClientWidth, ClientHeight, ScrollLeft, ScrollTop, ScrollWidth, ScrollHeight, ScrollIntoView };
protected:
// Constructor for inherited classes; doesn't set up a prototype.
@@ -160,7 +160,7 @@
SetAttributeNode, RemoveAttributeNode, GetElementsByTagName,
GetAttributeNS, SetAttributeNS, RemoveAttributeNS, GetAttributeNodeNS,
SetAttributeNodeNS, GetElementsByTagNameNS, HasAttribute, HasAttributeNS,
- ScrollByLines, ScrollByPages};
+ ScrollByLines, ScrollByPages, ScrollIntoView};
protected:
// Constructor for inherited classes; doesn't set up a prototype.
DOMElement(DOM::ElementImpl *e);
1.81 +5 -0 WebCore/khtml/ecma/kjs_dom.cpp
Index: kjs_dom.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- kjs_dom.cpp 19 Jul 2005 19:52:49 -0000 1.80
+++ kjs_dom.cpp 19 Jul 2005 22:41:47 -0000 1.81
@@ -1131,6 +1131,8 @@
setAttributeNodeNS DOMElement::SetAttributeNodeNS DontDelete|Function 1
getElementsByTagNameNS DOMElement::GetElementsByTagNameNS DontDelete|Function 2
hasAttributeNS DOMElement::HasAttributeNS DontDelete|Function 2
+ scrollIntoView DOMElement::ScrollIntoView DontDelete|Function 1
+
# extension for Safari RSS
scrollByLines DOMElement::ScrollByLines DontDelete|Function 1
scrollByPages DOMElement::ScrollByPages DontDelete|Function 1
@@ -1242,6 +1244,9 @@
return getDOMNodeList(exec, element.getElementsByTagNameNS(args[0].toString(exec).string() ,args[1].toString(exec).string()).get());
case DOMElement::HasAttributeNS: // DOM2
return Boolean(element.hasAttributeNS(args[0].toString(exec).string(),args[1].toString(exec).string()));
+ case DOMElement::ScrollIntoView:
+ (args[0].type() != UndefinedType && args[0].type() != NullType) ? element.scrollIntoView(args[0].toBoolean(exec)) : element.scrollIntoView(true);
+ return Undefined();
case DOMElement::ScrollByLines:
case DOMElement::ScrollByPages:
if (DocumentImpl* doc = element.getDocument()) {
1.1 WebCore/manual-tests/scrollIntoView-horizontal.html
Index: scrollIntoView-horizontal.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
</head>
<body>
<p><b>BUG ID</b> <a href="rdar://problem/3471901">3471901</a> support scrollIntoView method for DOM elements (3474)</p>
<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b>
Following the numbered steps on each button, click each button to scroll the next button into view.</p>
<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
Next button scrolls into view as specified.</p>
<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
Next button does not scroll into view, or the button is scrolled to the wrong positon (top, bottom).
</p>
<input id="topleft" type="button" value="STEP 1: click to horizontally scroll STEP 2 into view" onclick="document.getElementById('topright').scrollIntoView(false);">
<input id="topright" type="button" value="STEP 2: click to scroll STEP 3 to BOTTOM of view" style="position: absolute; left: 1200px;" onclick="document.getElementById('bottomleft').scrollIntoView(false);">
<div style="height: 500px; width: 1200px; border: 1px solid;">here is a big empty div</div>
<input id="bottomleft" type="button" value="STEP 3: click to scroll STEP 4 to TOP of view" style="position: absolute; top: 1200px;" onclick="document.getElementById('bottomright').scrollIntoView(true);">
<input id="bottomright" type="button" value="STEP 4: click to scroll STEP 1 to TOP of view (then you're done)" style="position: absolute; top: 1200px; left: 1200px;" onclick="document.getElementById('topleft').scrollIntoView();">
<div style="height: 500px; width: 1200px; border: 1px solid; position: absolute; top: 1300px;">here is a big empty div</div>
</body>
</html>
1.1 WebCore/manual-tests/scrollIntoView-vertical.html
Index: scrollIntoView-vertical.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
</head>
<body>
<p><b>BUG ID</b> <a href="rdar://problem/3471901">3471901</a> support scrollIntoView method for DOM elements (3474)</p>
<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b>
Following the numbered steps, click each button to scroll the specified colored box into view.</p>
<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b>
A colored box should scroll into view after clicking each button. The text on the button specifies the expected position (top, bottom) of the box scrolled into view.</p>
<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>
Colored box does not scroll into view, or the box is scrolled to the wrong positon (top, bottom).
</p>
<div id="purplebox" style="background-color:purple; width: 300px; height: 100px;">
<input type="button" value="STEP 1: click to scroll yellow box to BOTTOM of view" onclick="document.getElementById('yellowbox').scrollIntoView(false);">
<input type="button" value="STEP 4: click to scroll orange box to TOP of view" onclick="document.getElementById('orangebox').scrollIntoView(true);">
</div>
<div style="height: 500px; width: 500px; border: 1px solid;">here is a big empty div</div>
<div id="greenbox" style="background-color:green; width: 300px; height: 100px;">
<input type="button" value="STEP 3: click to scroll purple box to TOP of view" onclick="document.getElementById('purplebox').scrollIntoView();">
</div>
<div style="height: 500px; width: 500px; border: 1px solid;">here is a big empty div</div>
<div id="yellowbox" style="background-color:yellow; width: 300px; height: 100px;">
<input type="button" value="STEP 2: click to scroll green box to TOP of view" onclick="document.getElementById('greenbox').scrollIntoView(true);">
</div>
<div style="height: 500px; width: 500px; border: 1px solid;">here is a big empty div</div>
<div id="orangebox" style="background-color:orange; width: 300px; height: 100px;">
Test Complete
</div>
<div style="height: 500px; width: 500px; border: 1px solid;">here is a big empty div</div>
</body>
</html>
More information about the webkit-changes
mailing list