[webkit-changes] cvs commit: WebCore/kwq KWQComboBox.mm
KWQFileButton.mm KWQKHTMLPart.mm KWQListBox.mm
KWQScrollView.h KWQScrollView.mm KWQSlider.mm KWQTextArea.mm
KWQTextField.mm WebCoreBridge.mm KWQNSViewExtras.h KWQNSViewExtras.m
Adele
adele at opensource.apple.com
Tue Oct 25 14:14:57 PDT 2005
adele 05/10/25 14:14:56
Modified: . ChangeLog
WebCore.xcodeproj project.pbxproj
khtml khtml_part.cpp khtmlview.cpp
khtml/rendering render_layer.cpp render_layer.h
khtml/xml dom_elementimpl.cpp
kwq KWQComboBox.mm KWQFileButton.mm KWQKHTMLPart.mm
KWQListBox.mm KWQScrollView.h KWQScrollView.mm
KWQSlider.mm KWQTextArea.mm KWQTextField.mm
WebCoreBridge.mm
Removed: kwq KWQNSViewExtras.h KWQNSViewExtras.m
Log:
Reviewed by Hyatt.
- first step of fix for <rdar://problem/3612121> setting focus, by tabbing, searching, or with JavaScript does not scroll overflow:auto/scroll/overlay to reveal focused element (3480)
This change moves the scrolling code for revealing elements to the RenderLayer, instead of being specific to the view.
* khtml/rendering/render_layer.h: Added scrollRectToVisible. Added getRectToExpose.
Added ScrollAlignment enum so callers can be more specific about exactly where they want to scroll.
(khtml::RenderLayer::scrollToPoint): Added inline function to scroll to a point.
* khtml/rendering/render_layer.cpp:
(khtml::RenderLayer::scrollRectToVisible): Replaces recursive view scrolling functions.
(khtml::RenderLayer::getRectToExpose): Calculates the rectangle to expose based on the alignment parameters.
* khtml/khtml_part.cpp:
(KHTMLPart::gotoAnchor): Changed use of setContentsPosRecursive to scrollToPoint.
(KHTMLPart::setActiveNode): Changed use of ensureVisible to scrollRectToVisible.
* khtml/khtmlview.cpp:
(KHTMLView::doAutoScroll): Changed use of ensureVisible to scrollRectToVisible.
(KHTMLView::focusNextPrevNode): ditto.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::jumpToSelection): Changed use of _KWQ_scrollRectToVisible to scrollRectToVisible.
(KWQKHTMLPart::nextKeyViewInFrame): Changed use of ensureRectVisibleCentered to scrollRectToVisible.
(KWQKHTMLPart::centerSelectionInVisibleArea): ditto.
* khtml/xml/dom_elementimpl.cpp: (ElementImpl::scrollIntoView): Changed use of setContentsPos and ensureVisible to scrollRectToVisible.
* kwq/WebCoreBridge.mm: (-[WebCoreBridge ensureSelectionVisible]): Changed use of ensureRectVisibleCentered to scrollRectToVisible.
* kwq/KWQComboBox.mm: (-[KWQPopUpButton becomeFirstResponder]): Changing use of _KWQ_scrollFrameToVisible to scrollRectToVisible.
* kwq/KWQFileButton.mm: (KWQFileButton::focusChanged): ditto.
* kwq/KWQListBox.mm: (-[KWQTableView becomeFirstResponder]): ditto.
* kwq/KWQSlider.mm: (-[KWQSlider becomeFirstResponder]): ditto.
* kwq/KWQTextArea.mm: (-[KWQTextAreaTextView becomeFirstResponder]): ditto.
* kwq/KWQTextField.mm: (-[KWQTextFieldController setHasFocus:]): ditto.
* kwq/KWQScrollView.h: Removed ensureVisible, and ensureRectVisibleCentered. Added ensureRectVisible which just calls across to AppKit to scroll the NSView.
* kwq/KWQScrollView.mm: (QScrollView::ensureRectVisible): ditto.
* WebCore.xcodeproj/project.pbxproj: Removed KWQNSViewExtras since it is no longer needed.
* kwq/KWQNSViewExtras.h: Removed.
* kwq/KWQNSViewExtras.m: Removed.
Revision Changes Path
1.285 +41 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.284
retrieving revision 1.285
diff -u -r1.284 -r1.285
--- ChangeLog 25 Oct 2005 20:54:22 -0000 1.284
+++ ChangeLog 25 Oct 2005 21:14:25 -0000 1.285
@@ -1,3 +1,44 @@
+2005-10-25 Adele Peterson <adele at apple.com>
+
+ Reviewed by Hyatt.
+
+ - first step of fix for <rdar://problem/3612121> setting focus, by tabbing, searching, or with JavaScript does not scroll overflow:auto/scroll/overlay to reveal focused element (3480)
+ This change moves the scrolling code for revealing elements to the RenderLayer, instead of being specific to the view.
+
+ * khtml/rendering/render_layer.h: Added scrollRectToVisible. Added getRectToExpose.
+ Added ScrollAlignment enum so callers can be more specific about exactly where they want to scroll.
+ (khtml::RenderLayer::scrollToPoint): Added inline function to scroll to a point.
+ * khtml/rendering/render_layer.cpp:
+ (khtml::RenderLayer::scrollRectToVisible): Replaces recursive view scrolling functions.
+ (khtml::RenderLayer::getRectToExpose): Calculates the rectangle to expose based on the alignment parameters.
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::gotoAnchor): Changed use of setContentsPosRecursive to scrollToPoint.
+ (KHTMLPart::setActiveNode): Changed use of ensureVisible to scrollRectToVisible.
+ * khtml/khtmlview.cpp:
+ (KHTMLView::doAutoScroll): Changed use of ensureVisible to scrollRectToVisible.
+ (KHTMLView::focusNextPrevNode): ditto.
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::jumpToSelection): Changed use of _KWQ_scrollRectToVisible to scrollRectToVisible.
+ (KWQKHTMLPart::nextKeyViewInFrame): Changed use of ensureRectVisibleCentered to scrollRectToVisible.
+ (KWQKHTMLPart::centerSelectionInVisibleArea): ditto.
+ * khtml/xml/dom_elementimpl.cpp: (ElementImpl::scrollIntoView): Changed use of setContentsPos and ensureVisible to scrollRectToVisible.
+ * kwq/WebCoreBridge.mm: (-[WebCoreBridge ensureSelectionVisible]): Changed use of ensureRectVisibleCentered to scrollRectToVisible.
+
+ * kwq/KWQComboBox.mm: (-[KWQPopUpButton becomeFirstResponder]): Changing use of _KWQ_scrollFrameToVisible to scrollRectToVisible.
+ * kwq/KWQFileButton.mm: (KWQFileButton::focusChanged): ditto.
+ * kwq/KWQListBox.mm: (-[KWQTableView becomeFirstResponder]): ditto.
+ * kwq/KWQSlider.mm: (-[KWQSlider becomeFirstResponder]): ditto.
+ * kwq/KWQTextArea.mm: (-[KWQTextAreaTextView becomeFirstResponder]): ditto.
+ * kwq/KWQTextField.mm: (-[KWQTextFieldController setHasFocus:]): ditto.
+
+ * kwq/KWQScrollView.h: Removed ensureVisible, and ensureRectVisibleCentered. Added ensureRectVisible which just calls across to AppKit to scroll the NSView.
+ * kwq/KWQScrollView.mm: (QScrollView::ensureRectVisible): ditto.
+
+ * WebCore.xcodeproj/project.pbxproj: Removed KWQNSViewExtras since it is no longer needed.
+ * kwq/KWQNSViewExtras.h: Removed.
+ * kwq/KWQNSViewExtras.m: Removed.
+
2005-10-25 David Hyatt <hyatt at apple.com>
Land box-sizing support and change button to work correctly
1.39 +0 -12 WebCore/WebCore.xcodeproj/project.pbxproj
Index: project.pbxproj
===================================================================
RCS file: /cvs/root/WebCore/WebCore.xcodeproj/project.pbxproj,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- project.pbxproj 25 Oct 2005 20:54:24 -0000 1.38
+++ project.pbxproj 25 Oct 2005 21:14:30 -0000 1.39
@@ -239,7 +239,6 @@
93F1997108245E59001E9ABC /* KWQMapImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F587851802DE375901EA4122 /* KWQMapImpl.h */; };
93F1997208245E59001E9ABC /* KWQMemArray.h in Headers */ = {isa = PBXBuildFile; fileRef = F587867702DE3B8601EA4122 /* KWQMemArray.h */; };
93F1997308245E59001E9ABC /* KWQMovie.h in Headers */ = {isa = PBXBuildFile; fileRef = F587869D02DE3B8601EA4122 /* KWQMovie.h */; };
- 93F1997408245E59001E9ABC /* KWQNSViewExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = F583D50103140623018635CE /* KWQNSViewExtras.h */; };
93F1997508245E59001E9ABC /* KWQNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = F587869E02DE3B8601EA4122 /* KWQNamespace.h */; };
93F1997608245E59001E9ABC /* KWQObject.h in Headers */ = {isa = PBXBuildFile; fileRef = F587869F02DE3B8601EA4122 /* KWQObject.h */; };
93F1997708245E59001E9ABC /* KWQPageState.h in Headers */ = {isa = PBXBuildFile; fileRef = 9394E0A403AA5BBE008635CE /* KWQPageState.h */; };
@@ -537,7 +536,6 @@
93F19AC408245E59001E9ABC /* KWQSignal.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5117BCA02F9FFEF018635CE /* KWQSignal.mm */; };
93F19AC508245E59001E9ABC /* KWQSlot.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5117BCC02F9FFEF018635CE /* KWQSlot.mm */; };
93F19AC608245E59001E9ABC /* WebCoreEncodings.mm in Sources */ = {isa = PBXBuildFile; fileRef = F56234E003026D7301629B47 /* WebCoreEncodings.mm */; };
- 93F19AC708245E59001E9ABC /* KWQNSViewExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = F583D50203140623018635CE /* KWQNSViewExtras.m */; };
93F19AC808245E59001E9ABC /* WebCoreHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = F5517DC3031AB56301A80180 /* WebCoreHistory.m */; };
93F19AC908245E59001E9ABC /* render_layer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F690CFEB031C47F401CA2AC4 /* render_layer.cpp */; };
93F19ACB08245E59001E9ABC /* KWQLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = 93861DE0032C2E52008635CE /* KWQLogging.m */; };
@@ -1041,7 +1039,6 @@
A8212B3C08794A2300677359 /* KWQMapImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F587851802DE375901EA4122 /* KWQMapImpl.h */; };
A8212B3D08794A2300677359 /* KWQMemArray.h in Headers */ = {isa = PBXBuildFile; fileRef = F587867702DE3B8601EA4122 /* KWQMemArray.h */; };
A8212B3E08794A2300677359 /* KWQMovie.h in Headers */ = {isa = PBXBuildFile; fileRef = F587869D02DE3B8601EA4122 /* KWQMovie.h */; };
- A8212B3F08794A2300677359 /* KWQNSViewExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = F583D50103140623018635CE /* KWQNSViewExtras.h */; };
A8212B4008794A2300677359 /* KWQNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = F587869E02DE3B8601EA4122 /* KWQNamespace.h */; };
A8212B4108794A2300677359 /* KWQObject.h in Headers */ = {isa = PBXBuildFile; fileRef = F587869F02DE3B8601EA4122 /* KWQObject.h */; };
A8212B4208794A2300677359 /* KWQPageState.h in Headers */ = {isa = PBXBuildFile; fileRef = 9394E0A403AA5BBE008635CE /* KWQPageState.h */; };
@@ -1371,7 +1368,6 @@
A8212C9508794A2300677359 /* KWQSignal.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5117BCA02F9FFEF018635CE /* KWQSignal.mm */; };
A8212C9608794A2300677359 /* KWQSlot.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5117BCC02F9FFEF018635CE /* KWQSlot.mm */; };
A8212C9708794A2300677359 /* WebCoreEncodings.mm in Sources */ = {isa = PBXBuildFile; fileRef = F56234E003026D7301629B47 /* WebCoreEncodings.mm */; };
- A8212C9808794A2300677359 /* KWQNSViewExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = F583D50203140623018635CE /* KWQNSViewExtras.m */; };
A8212C9908794A2300677359 /* WebCoreHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = F5517DC3031AB56301A80180 /* WebCoreHistory.m */; };
A8212C9A08794A2300677359 /* render_layer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F690CFEB031C47F401CA2AC4 /* render_layer.cpp */; };
A8212C9C08794A2300677359 /* KWQLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = 93861DE0032C2E52008635CE /* KWQLogging.m */; };
@@ -4061,8 +4057,6 @@
F565AE8502ECA583018635CA /* WebCoreSettings.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreSettings.h; sourceTree = "<group>"; };
F565AE8602ECA583018635CA /* WebCoreSettings.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreSettings.mm; sourceTree = "<group>"; };
F57B0EE002EBC78B018635CA /* KWQStyle.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQStyle.mm; sourceTree = "<group>"; };
- F583D50103140623018635CE /* KWQNSViewExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KWQNSViewExtras.h; sourceTree = "<group>"; };
- F583D50203140623018635CE /* KWQNSViewExtras.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = KWQNSViewExtras.m; sourceTree = "<group>"; };
F58784C402DE375801EA4122 /* KWQApplication.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQApplication.mm; sourceTree = "<group>"; };
F58784C502DE375801EA4122 /* KWQArrayImpl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KWQArrayImpl.h; sourceTree = "<group>"; };
F58784C602DE375801EA4122 /* KWQArrayImpl.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQArrayImpl.mm; sourceTree = "<group>"; };
@@ -6276,8 +6270,6 @@
F587850302DE375901EA4122 /* KWQLoader.mm */,
93861DDF032C2E52008635CE /* KWQLogging.h */,
93861DE0032C2E52008635CE /* KWQLogging.m */,
- F583D50103140623018635CE /* KWQNSViewExtras.h */,
- F583D50203140623018635CE /* KWQNSViewExtras.m */,
9394E0A403AA5BBE008635CE /* KWQPageState.h */,
9394E0A503AA5BBE008635CE /* KWQPageState.mm */,
F587852A02DE375901EA4122 /* KWQRefPtr.h */,
@@ -7077,7 +7069,6 @@
93F1997108245E59001E9ABC /* KWQMapImpl.h in Headers */,
93F1997208245E59001E9ABC /* KWQMemArray.h in Headers */,
93F1997308245E59001E9ABC /* KWQMovie.h in Headers */,
- 93F1997408245E59001E9ABC /* KWQNSViewExtras.h in Headers */,
93F1997508245E59001E9ABC /* KWQNamespace.h in Headers */,
93F1997608245E59001E9ABC /* KWQObject.h in Headers */,
93F1997708245E59001E9ABC /* KWQPageState.h in Headers */,
@@ -7420,7 +7411,6 @@
A8212B3C08794A2300677359 /* KWQMapImpl.h in Headers */,
A8212B3D08794A2300677359 /* KWQMemArray.h in Headers */,
A8212B3E08794A2300677359 /* KWQMovie.h in Headers */,
- A8212B3F08794A2300677359 /* KWQNSViewExtras.h in Headers */,
A8212B4008794A2300677359 /* KWQNamespace.h in Headers */,
A8212B4108794A2300677359 /* KWQObject.h in Headers */,
A8212B4208794A2300677359 /* KWQPageState.h in Headers */,
@@ -9445,7 +9435,6 @@
93F19AC408245E59001E9ABC /* KWQSignal.mm in Sources */,
93F19AC508245E59001E9ABC /* KWQSlot.mm in Sources */,
93F19AC608245E59001E9ABC /* WebCoreEncodings.mm in Sources */,
- 93F19AC708245E59001E9ABC /* KWQNSViewExtras.m in Sources */,
93F19AC808245E59001E9ABC /* WebCoreHistory.m in Sources */,
93F19AC908245E59001E9ABC /* render_layer.cpp in Sources */,
93F19ACB08245E59001E9ABC /* KWQLogging.m in Sources */,
@@ -9716,7 +9705,6 @@
A8212C9508794A2300677359 /* KWQSignal.mm in Sources */,
A8212C9608794A2300677359 /* KWQSlot.mm in Sources */,
A8212C9708794A2300677359 /* WebCoreEncodings.mm in Sources */,
- A8212C9808794A2300677359 /* KWQNSViewExtras.m in Sources */,
A8212C9908794A2300677359 /* WebCoreHistory.m in Sources */,
A8212C9A08794A2300677359 /* render_layer.cpp in Sources */,
A8212C9C08794A2300677359 /* KWQLogging.m in Sources */,
1.351 +9 -4 WebCore/khtml/khtml_part.cpp
Index: khtml_part.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtml_part.cpp,v
retrieving revision 1.350
retrieving revision 1.351
diff -u -r1.350 -r1.351
--- khtml_part.cpp 24 Oct 2005 01:39:39 -0000 1.350
+++ khtml_part.cpp 25 Oct 2005 21:14:34 -0000 1.351
@@ -2308,7 +2308,11 @@
// Scroll to actual top left of element with no slop, since some pages expect anchors to be exactly scrolled to.
#if APPLE_CHANGES
// Call recursive version so this will expose correctly from within nested frames.
- d->m_view->setContentsPosRecursive(x, y);
+ if (d->m_doc && d->m_doc->renderer()) {
+ khtml::RenderLayer *layer = d->m_doc->renderer()->enclosingLayer();
+ if (layer)
+ d->m_doc->renderer()->enclosingLayer()->scrollToPoint(x, y);
+ }
#else
d->m_view->setContentsPos(x, y);
#endif
@@ -5403,9 +5407,10 @@
d->m_doc->setFocusNode(node.handle());
// Scroll the view if necessary to ensure that the new focus node is visible
- QRect rect = node.handle()->getRect();
- d->m_view->ensureVisible(rect.right(), rect.bottom());
- d->m_view->ensureVisible(rect.left(), rect.top());
+ QRect rect = node.handle()->getRect();
+ if (node.handle()->renderer() && node.handle()->renderer()->enclosingLayer()) {
+ node.handle()->renderer()->enclosingLayer()->scrollRectToVisible(rect);
+ }
}
DOM::Node KHTMLPart::activeNode() const
1.150 +7 -2 WebCore/khtml/khtmlview.cpp
Index: khtmlview.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtmlview.cpp,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -r1.149 -r1.150
--- khtmlview.cpp 19 Oct 2005 09:15:13 -0000 1.149
+++ khtmlview.cpp 25 Oct 2005 21:14:36 -0000 1.150
@@ -1334,7 +1334,10 @@
if ( (pos.y() < 0) || (pos.y() > visibleHeight()) ||
(pos.x() < 0) || (pos.x() > visibleWidth()) )
{
- ensureVisible( xm, ym, 0, 5 );
+ DocumentImpl *doc = m_part->xmlDocImpl();
+ if (doc && doc->renderer() && doc->renderer()->enclosingLayer()) {
+ doc->renderer()->enclosingLayer()->scrollRectToVisible(QRect(xm, ym, 0, 5));
+ }
}
}
@@ -1494,7 +1497,9 @@
return;
}
else {
- ensureVisible(contentsX(), next ? 0: contentsHeight());
+ if (doc->renderer() && doc->renderer()->enclosingLayer()) {
+ doc->renderer()->enclosingLayer()->scrollRectToVisible(QRect(contentsX(), next ? 0: contentsHeight(), 0, 0));
+ }
}
}
// Set focus node on the document
1.116 +110 -2 WebCore/khtml/rendering/render_layer.cpp
Index: render_layer.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_layer.cpp,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- render_layer.cpp 24 Oct 2005 22:33:54 -0000 1.115
+++ render_layer.cpp 25 Oct 2005 21:14:39 -0000 1.116
@@ -66,6 +66,8 @@
#define LINE_STEP 40
#define PAGE_KEEP 40
+#define MIN_INTERSECT_FOR_REVEAL 32
+
using namespace DOM;
using namespace DOM::EventNames;
using namespace HTMLNames;
@@ -549,8 +551,114 @@
}
}
-void
-RenderLayer::updateScrollPositionFromScrollbars()
+void RenderLayer::scrollRectToVisible(const QRect &rect, ScrollAlignment verticalAlignment, ScrollAlignment horizontalAlignment)
+{
+ RenderLayer* parentLayer = 0;
+ QRect newRect;
+ QScrollView* view = m_object->document()->view();
+ QRect viewRect = QRect(view->contentsX(), view->contentsY(), view->visibleWidth(), view->visibleHeight());
+ if (view) {
+ QRect r = getRectToExpose(viewRect, rect, verticalAlignment, verticalAlignment);
+ view->ensureRectVisible(r);
+ }
+ if (m_object->document() && m_object->document()->ownerElement() && m_object->document()->ownerElement()->renderer()) {
+ parentLayer = m_object->document()->ownerElement()->renderer()->enclosingLayer();
+ newRect = QRect(view->viewport()->x(), view->viewport()->y(), view->viewport()->width(), view->viewport()->height());
+ }
+
+ if (parentLayer)
+ parentLayer->scrollRectToVisible(newRect, verticalAlignment, horizontalAlignment);
+}
+
+QRect RenderLayer::getRectToExpose(const QRect &visibleRect, const QRect &exposeRect, ScrollAlignment verticalAlignment, ScrollAlignment horizontalAlignment) {
+
+ int x, y, w, h;
+ x = exposeRect.x();
+ y = exposeRect.y();
+ w = exposeRect.width();
+ h = exposeRect.height();
+
+ int intersectWidth = visibleRect.intersect(exposeRect).width();
+ if (intersectWidth <= w || (horizontalAlignment != alignDefault)) {
+ switch (horizontalAlignment) {
+ case alignLeft:
+ // The x value is already equal to the left of the exposeRect
+ break;
+ case alignRight:
+ x += exposeRect.width() - visibleRect.width();
+ break; //note- we don't have anything to test this right now.
+ case alignCenter:
+ if (w < visibleRect.width())
+ x -= (visibleRect.width() - w) / 2;
+ else {
+ if (visibleRect.x() >= x && exposeRect.right() >= visibleRect.right()) {
+ // Exposed rect fills the visible rect.
+ // We don't want the view to budge.
+ x = visibleRect.x();
+ }
+ else if (visibleRect.x() < x) {
+ // Scroll so left of visible region shows left of expose rect.
+ // Leave expose origin as it is to make this happen.
+ }
+ else {
+ // Scroll so right of visible region shows right of expose rect.
+ x = exposeRect.right() - visibleRect.width();
+ }
+ }
+ w = visibleRect.width();
+ break;
+ case alignDefault :
+ default :
+ // First check whether enough of the desired rect is already visible horizontally. If so, and we're not forcing centering,
+ // we don't want to scroll horizontally because doing so is surprising.
+ if (intersectWidth >= MIN_INTERSECT_FOR_REVEAL)
+ x = visibleRect.x();
+ else if (w < visibleRect.width()) {
+ x -= (visibleRect.width() - w) / 2;
+ }
+ w = visibleRect.width();
+ }
+ }
+
+ int intersectHeight = visibleRect.intersect(exposeRect).height();
+ if (intersectHeight <= h || (verticalAlignment != alignDefault)) {
+ switch (verticalAlignment) {
+ case alignTop:
+ // The y value is already equal to the top of the exposeRect
+ break;
+ case alignBottom:
+ y += exposeRect.height() - visibleRect.height();
+ break;
+ case alignCenter:
+ if (h < visibleRect.height()) {
+ y -= (visibleRect.height() - h) / 2;
+ } else {
+ if (visibleRect.y() >= y && exposeRect.bottom() >= visibleRect.bottom()) {
+ // Exposed rect fills the visible rect.
+ // We don't want the view to budge.
+ y = visibleRect.y();
+ }
+ else if (visibleRect.y() < y) {
+ // Scroll so top of visible region shows top of expose rect.
+ // Leave expose origin as it is to make this happen.
+ }
+ else {
+ // Scroll so bottom of visible region shows bottom of expose rect.
+ y = exposeRect.bottom() - visibleRect.height();
+ }
+ }
+ case alignDefault :
+ default :
+ if (h < visibleRect.height()) {
+ y -= (visibleRect.height() - h) / 2;
+ }
+ }
+ h = visibleRect.height();
+ }
+ return QRect(x, y, w, h);
+}
+
+void RenderLayer::updateScrollPositionFromScrollbars()
{
bool needUpdate = false;
int newX = m_scrollX;
1.53 +12 -0 WebCore/khtml/rendering/render_layer.h
Index: render_layer.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_layer.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- render_layer.h 24 Oct 2005 22:33:54 -0000 1.52
+++ render_layer.h 25 Oct 2005 21:14:40 -0000 1.53
@@ -50,6 +50,15 @@
#include "render_object.h"
+typedef enum {
+ alignTop,
+ alignBottom,
+ alignLeft,
+ alignRight,
+ alignCenter,
+ alignDefault
+} ScrollAlignment;
+
class QScrollBar;
template <class T> class QPtrVector;
@@ -221,6 +230,9 @@
void scrollToOffset(int x, int y, bool updateScrollbars = true, bool repaint = true);
void scrollToXOffset(int x) { scrollToOffset(x, m_scrollY); }
void scrollToYOffset(int y) { scrollToOffset(m_scrollX, y); }
+ void scrollToPoint(int x, int y) { scrollRectToVisible(QRect(x, y, 0, 0), alignTop, alignLeft); }
+ void scrollRectToVisible(const QRect &r, ScrollAlignment verticalAlignment = alignDefault, ScrollAlignment horizontalAlignment = alignDefault);
+ QRect getRectToExpose(const QRect &visibleRect, const QRect &exposeRect, ScrollAlignment verticalAlignment = alignDefault, ScrollAlignment horizontalAlignment = alignDefault);
void setHasHorizontalScrollbar(bool hasScrollbar);
void setHasVerticalScrollbar(bool hasScrollbar);
QScrollBar* horizontalScrollbar() { return m_hBar; }
1.87 +7 -12 WebCore/khtml/xml/dom_elementimpl.cpp
Index: dom_elementimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_elementimpl.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- dom_elementimpl.cpp 24 Oct 2005 07:24:35 -0000 1.86
+++ dom_elementimpl.cpp 25 Oct 2005 21:14:41 -0000 1.87
@@ -351,18 +351,13 @@
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);
+ QRect bounds = this->getRect();
+ if (m_render && m_render->enclosingLayer()) {
+ if (alignToTop)
+ m_render->enclosingLayer()->scrollRectToVisible(bounds, alignTop);
+ else
+ m_render->enclosingLayer()->scrollRectToVisible(bounds, alignBottom);
+ }
}
const AtomicString& ElementImpl::getAttributeNS(const DOMString &namespaceURI,
1.71 +9 -2 WebCore/kwq/KWQComboBox.mm
Index: KWQComboBox.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQComboBox.mm,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- KWQComboBox.mm 21 Oct 2005 21:27:50 -0000 1.70
+++ KWQComboBox.mm 25 Oct 2005 21:14:43 -0000 1.71
@@ -30,13 +30,17 @@
#import "KWQLineEdit.h"
#import "KWQExceptions.h"
#import "KWQKHTMLPart.h"
-#import "KWQNSViewExtras.h"
#import "KWQFoundationExtras.h"
#import "KWQView.h"
#import "WebCoreBridge.h"
#import "WebCoreTextRenderer.h"
#import "WebCoreTextRendererFactory.h"
+#import "render_form.h"
+
+using khtml::RenderWidget;
+using khtml::RenderLayer;
+
@interface NSCell (KWQComboBoxKnowsAppKitSecrets)
- (NSMutableDictionary *)_textAttributes;
@end
@@ -489,7 +493,10 @@
QWidget *widget = [self widget];
if (widget) {
if (!KWQKHTMLPart::currentEventIsMouseDownInWidget(widget)) {
- [self _KWQ_scrollFrameToVisible];
+ RenderWidget *w = const_cast<RenderWidget *> (static_cast<const RenderWidget *>(widget->eventFilterObject()));
+ RenderLayer *layer = w->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(w->absoluteBoundingBoxRect());
}
QFocusEvent event(QEvent::FocusIn);
const_cast<QObject *>(widget->eventFilterObject())->eventFilter(widget, &event);
1.30 +9 -2 WebCore/kwq/KWQFileButton.mm
Index: KWQFileButton.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQFileButton.mm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- KWQFileButton.mm 3 Oct 2005 21:13:02 -0000 1.29
+++ KWQFileButton.mm 25 Oct 2005 21:14:43 -0000 1.30
@@ -29,9 +29,12 @@
#import <kxmlcore/Assertions.h>
#import "KWQExceptions.h"
#import "KWQKHTMLPart.h"
-#import "KWQNSViewExtras.h"
#import "KWQFoundationExtras.h"
#import "WebCoreBridge.h"
+#import "render_form.h"
+
+using khtml::RenderWidget;
+using khtml::RenderLayer;
@interface KWQFileButtonAdapter : NSObject <WebCoreFileButtonDelegate>
{
@@ -154,7 +157,11 @@
{
if (nowHasFocus) {
if (!KWQKHTMLPart::currentEventIsMouseDownInWidget(this)) {
- [getView() _KWQ_scrollFrameToVisible];
+ RenderWidget *widget = const_cast<RenderWidget *> (static_cast<const RenderWidget *>(eventFilterObject()));
+ RenderLayer *layer = widget->enclosingLayer();
+ layer = layer->renderer()->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(widget->absoluteBoundingBoxRect());
}
QFocusEvent event(QEvent::FocusIn);
const_cast<QObject *>(eventFilterObject())->eventFilter(this, &event);
1.679 +19 -14 WebCore/kwq/KWQKHTMLPart.mm
Index: KWQKHTMLPart.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
retrieving revision 1.678
retrieving revision 1.679
diff -u -r1.678 -r1.679
--- KWQKHTMLPart.mm 12 Oct 2005 06:55:39 -0000 1.678
+++ KWQKHTMLPart.mm 25 Oct 2005 21:14:43 -0000 1.679
@@ -36,7 +36,6 @@
#import "KWQFoundationExtras.h"
#import "KWQKJobClasses.h"
#import "KWQLogging.h"
-#import "KWQNSViewExtras.h"
#import "KWQPageState.h"
#import "KWQPrinter.h"
#import "KWQRegExp.h"
@@ -934,9 +933,9 @@
void KWQKHTMLPart::jumpToSelection()
{
if (d->m_selection.start().isNotNull()) {
- KWQ_BLOCK_EXCEPTIONS;
- [d->m_view->getDocumentView() _KWQ_scrollRectToVisible:NSRect(selectionRect()) forceCentering:NO];
- KWQ_UNBLOCK_EXCEPTIONS;
+ RenderLayer *layer = renderer()->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(selectionRect());
}
}
@@ -1261,16 +1260,18 @@
}
else {
doc->setFocusNode(node);
-
if (node->isEditableBlock()) {
SelectionController sel(Position(node, 0), DOWNSTREAM, Position(node, node->maxDeepOffset()), DOWNSTREAM);
if (((KHTMLPart *)this)->shouldChangeSelection(sel))
setSelection(sel);
}
-
- if (view() && node->renderer() && !node->renderer()->isRoot()) {
- view()->ensureRectVisibleCentered(node->getRect());
+
+ if (node->renderer() && !node->renderer()->isRoot()) {
+ RenderLayer *layer = node->renderer()->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(node->getRect());
}
+
[_bridge makeFirstResponder:[_bridge documentView]];
return [_bridge documentView];
}
@@ -3386,15 +3387,19 @@
case SelectionController::NONE:
break;
case SelectionController::CARET: {
- if (view())
- // passing true forces centering even if selection is already exposed
- view()->ensureRectVisibleCentered(selection().caretRect(), true);
+ if (renderer()) {
+ RenderLayer *layer = renderer()->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(selection().caretRect(), alignCenter, alignCenter);
+ }
break;
}
case SelectionController::RANGE:
- if (view())
- // passing true forces centering even if selection is already exposed
- view()->ensureRectVisibleCentered(selectionRect(), true);
+ if (renderer()) {
+ RenderLayer *layer = renderer()->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(selectionRect(), alignCenter, alignCenter);
+ }
break;
}
}
1.63 +9 -2 WebCore/kwq/KWQListBox.mm
Index: KWQListBox.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQListBox.mm,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- KWQListBox.mm 20 Oct 2005 06:02:26 -0000 1.62
+++ KWQListBox.mm 25 Oct 2005 21:14:46 -0000 1.63
@@ -29,13 +29,17 @@
#import <kxmlcore/Assertions.h>
#import "KWQExceptions.h"
#import "KWQKHTMLPart.h"
-#import "KWQNSViewExtras.h"
#import "KWQView.h"
#import "WebCoreBridge.h"
#import "WebCoreScrollView.h"
#import "WebCoreTextRenderer.h"
#import "WebCoreTextRendererFactory.h"
+#import "render_form.h"
+
+using khtml::RenderWidget;
+using khtml::RenderLayer;
+
@interface NSTableView (KWQListBoxKnowsAppKitSecrets)
- (NSCell *)_accessibilityTableCell:(int)row tableColumn:(NSTableColumn *)tableColumn;
@end
@@ -580,7 +584,10 @@
if (become) {
if (_box && !KWQKHTMLPart::currentEventIsMouseDownInWidget(_box)) {
- [self _KWQ_scrollFrameToVisible];
+ RenderWidget *widget = const_cast<RenderWidget *> (static_cast<const RenderWidget *>(_box->eventFilterObject()));
+ RenderLayer *layer = widget->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(widget->absoluteBoundingBoxRect());
}
[self _KWQ_setKeyboardFocusRingNeedsDisplay];
1.40 +1 -4 WebCore/kwq/KWQScrollView.h
Index: KWQScrollView.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQScrollView.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- KWQScrollView.h 14 Dec 2004 00:10:18 -0000 1.39
+++ KWQScrollView.h 25 Oct 2005 21:14:48 -0000 1.40
@@ -50,7 +50,6 @@
void scrollBy(int dx, int dy);
void setContentsPos(int x, int y);
- void setContentsPosRecursive(int,int);
virtual void setVScrollBarMode(ScrollBarMode vMode);
virtual void setHScrollBarMode(ScrollBarMode hMode);
@@ -89,9 +88,7 @@
void resizeEvent(QResizeEvent *);
- void ensureVisible(int,int);
- void ensureVisible(int,int,int,int);
- void ensureRectVisibleCentered(const QRect &r, bool forceCentering=false);
+ void ensureRectVisible(const QRect &r);
NSView *getDocumentView() const;
1.85 +2 -35 WebCore/kwq/KWQScrollView.mm
Index: KWQScrollView.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQScrollView.mm,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- KWQScrollView.mm 3 Oct 2005 21:13:08 -0000 1.84
+++ KWQScrollView.mm 25 Oct 2005 21:14:48 -0000 1.85
@@ -28,7 +28,6 @@
#import "KWQExceptions.h"
#import "KWQLogging.h"
-#import "KWQNSViewExtras.h"
#import "WebCoreFrameView.h"
/*
@@ -447,43 +446,11 @@
{
}
-void QScrollView::setContentsPosRecursive(int x, int y)
-{
- KWQ_BLOCK_EXCEPTIONS;
- NSPoint tempPoint = { x, y }; // workaround for 4213314
- [getDocumentView() _KWQ_scrollPointRecursive:tempPoint];
- KWQ_UNBLOCK_EXCEPTIONS;
-}
-
-void QScrollView::ensureVisible(int x, int y)
-{
- // Note that the definition of ensureVisible in trolltech documentation says:
- // "Scrolls the content so that the point (x, y) is visible with at least
- // 50-pixel margins (if possible, otherwise centered).", which is
- // not what we're doing here.
- KWQ_BLOCK_EXCEPTIONS;
- NSRect tempRect = { {x, y}, {0, 0} }; // workaround for 4213314
- [getDocumentView() scrollRectToVisible:tempRect];
- KWQ_UNBLOCK_EXCEPTIONS;
-}
-
-void QScrollView::ensureVisible(int x, int y, int xmargin, int ymargin)
-{
- // Note that the definition of ensureVisible in trolltech documentation says:
- // "Scrolls the content so that the point (x, y) is visible with at least the
- // xmargin and ymargin margins (if possible, otherwise centered).", which is
- // not what we're doing here.
- KWQ_BLOCK_EXCEPTIONS;
- NSRect tempRect = { {x, y}, {xmargin, ymargin} }; // workaround for 4213314
- [getDocumentView() scrollRectToVisible:tempRect];
- KWQ_UNBLOCK_EXCEPTIONS;
-}
-
-void QScrollView::ensureRectVisibleCentered(const QRect &rect, bool forceCentering)
+void QScrollView::ensureRectVisible(const QRect &rect)
{
KWQ_BLOCK_EXCEPTIONS;
NSRect tempRect = { {rect.x(), rect.y()}, {rect.width(), rect.height()} }; // workaround for 4213314
- [getDocumentView() _KWQ_scrollRectToVisible:tempRect forceCentering:forceCentering];
+ [getDocumentView() scrollRectToVisible:tempRect];
KWQ_UNBLOCK_EXCEPTIONS;
}
1.13 +8 -2 WebCore/kwq/KWQSlider.mm
Index: KWQSlider.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQSlider.mm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- KWQSlider.mm 21 Oct 2005 22:04:17 -0000 1.12
+++ KWQSlider.mm 25 Oct 2005 21:14:49 -0000 1.13
@@ -29,9 +29,12 @@
#import "KWQLineEdit.h"
#import "KWQExceptions.h"
#import "KWQKHTMLPart.h"
-#import "KWQNSViewExtras.h"
#import "KWQView.h"
#import "WebCoreBridge.h"
+#import "render_form.h"
+
+using khtml::RenderWidget;
+using khtml::RenderLayer;
@interface KWQSlider : NSSlider <KWQWidgetHolder>
{
@@ -100,7 +103,10 @@
BOOL become = [super becomeFirstResponder];
if (become && slider) {
if (!KWQKHTMLPart::currentEventIsMouseDownInWidget(slider)) {
- [self _KWQ_scrollFrameToVisible];
+ RenderWidget *widget = const_cast<RenderWidget *> (static_cast<const RenderWidget *>(slider->eventFilterObject()));
+ RenderLayer *layer = widget->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(widget->absoluteBoundingBoxRect());
}
if (slider) {
1.96 +5 -2 WebCore/kwq/KWQTextArea.mm
Index: KWQTextArea.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQTextArea.mm,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- KWQTextArea.mm 11 Oct 2005 19:16:44 -0000 1.95
+++ KWQTextArea.mm 25 Oct 2005 21:14:49 -0000 1.96
@@ -31,7 +31,6 @@
#import "EventNames.h"
#import <kxmlcore/Assertions.h>
#import "KWQKHTMLPart.h"
-#import "KWQNSViewExtras.h"
#import "KWQTextEdit.h"
#import "render_replaced.h"
#import "WebCoreBridge.h"
@@ -41,6 +40,7 @@
using namespace DOM::EventNames;
using DOM::NodeImpl;
using khtml::RenderWidget;
+using khtml::RenderLayer;
@interface NSTextView (WebCoreKnowsCertainAppKitSecrets)
- (void)setWantsNotificationForMarkedText:(BOOL)wantsNotification;
@@ -964,7 +964,10 @@
if (become) {
if (!KWQKHTMLPart::currentEventIsMouseDownInWidget(widget)) {
- [[self enclosingScrollView] _KWQ_scrollFrameToVisible];
+ RenderWidget *w = const_cast<RenderWidget *> (static_cast<const RenderWidget *>(widget->eventFilterObject()));
+ RenderLayer *layer = w->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(w->absoluteBoundingBoxRect());
}
[self _KWQ_setKeyboardFocusRingNeedsDisplay];
if (widget) {
1.93 +10 -3 WebCore/kwq/KWQTextField.mm
Index: KWQTextField.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQTextField.mm,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- KWQTextField.mm 11 Oct 2005 19:16:45 -0000 1.92
+++ KWQTextField.mm 25 Oct 2005 21:14:50 -0000 1.93
@@ -29,9 +29,12 @@
#import <kxmlcore/Assertions.h>
#import "KWQKHTMLPart.h"
#import "KWQLineEdit.h"
-#import "KWQNSViewExtras.h"
#import "KWQView.h"
#import "WebCoreBridge.h"
+#import "render_form.h"
+
+using khtml::RenderWidget;
+using khtml::RenderLayer;
@interface NSString (KWQTextField)
- (int)_KWQ_numComposedCharacterSequences;
@@ -394,8 +397,12 @@
hasFocusAndSelectionSet = YES;
- if (!KWQKHTMLPart::currentEventIsMouseDownInWidget(widget))
- [field _KWQ_scrollFrameToVisible];
+ if (!KWQKHTMLPart::currentEventIsMouseDownInWidget(widget) && widget) {
+ RenderWidget *w = const_cast<RenderWidget *> (static_cast<const RenderWidget *>(widget->eventFilterObject()));
+ RenderLayer *layer = w->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(w->absoluteBoundingBoxRect());
+ }
if (widget) {
QFocusEvent event(QEvent::FocusIn);
1.421 +4 -3 WebCore/kwq/WebCoreBridge.mm
Index: WebCoreBridge.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.mm,v
retrieving revision 1.420
retrieving revision 1.421
diff -u -r1.420 -r1.421
--- WebCoreBridge.mm 4 Oct 2005 01:59:55 -0000 1.420
+++ WebCoreBridge.mm 25 Oct 2005 21:14:51 -0000 1.421
@@ -119,6 +119,7 @@
using khtml::parseURL;
using khtml::RenderCanvas;
using khtml::RenderImage;
+using khtml::RenderLayer;
using khtml::RenderObject;
using khtml::RenderPart;
using khtml::RenderStyle;
@@ -2105,9 +2106,9 @@
return;
QRect extentRect = renderer->caretRect(extent.offset(), _part->selection().extentAffinity());
- if (!NSContainsRect([documentView visibleRect], NSRect(extentRect))) {
- v->ensureRectVisibleCentered(extentRect, true);
- }
+ RenderLayer *layer = renderer->enclosingLayer();
+ if (layer)
+ layer->scrollRectToVisible(extentRect, alignCenter, alignCenter);
}
// [info draggingLocation] is in window coords
More information about the webkit-changes
mailing list