322 |
322 |
323 painter->restore(); |
323 painter->restore(); |
324 } |
324 } |
325 } |
325 } |
326 |
326 |
327 static bool webframe_scrollOverflow(WebCore::Frame* frame, int dx, int dy) |
327 static bool webframe_scrollOverflow(WebCore::Frame* frame, int dx, int dy, const QPoint& pos) |
328 { |
328 { |
329 if (!frame || !frame->document() || !frame->eventHandler()) |
329 if (!frame || !frame->document() || !frame->eventHandler()) |
330 return false; |
330 return false; |
331 |
331 |
332 Node* node = frame->document()->focusedNode(); |
332 Node* node = frame->document()->elementFromPoint(pos.x(), pos.y()); |
333 if (!node) |
|
334 node = frame->document()->elementFromPoint(frame->eventHandler()->currentMousePosition().x(), |
|
335 frame->eventHandler()->currentMousePosition().y()); |
|
336 if (!node) |
333 if (!node) |
337 return false; |
334 return false; |
338 |
335 |
339 RenderObject* renderer = node->renderer(); |
336 RenderObject* renderer = node->renderer(); |
340 if (!renderer) |
337 if (!renderer) |
1045 |
1046 |
1046 d->frame->view()->scrollBy(IntSize(dx, dy)); |
1047 d->frame->view()->scrollBy(IntSize(dx, dy)); |
1047 } |
1048 } |
1048 |
1049 |
1049 /*! |
1050 /*! |
1050 \since 4.7 |
|
1051 \internal |
1051 \internal |
1052 Scrolls nested frames starting at this frame, \a dx pixels to the right |
1052 Scrolls nested frames starting at this frame, \a dx pixels to the right |
1053 and \a dy pixels downward. Both \a dx and \a dy may be negative. First attempts |
1053 and \a dy pixels downward. Both \a dx and \a dy may be negative. First attempts |
1054 to scroll elements with CSS overflow followed by this frame. If this |
1054 to scroll elements with CSS overflow at position pos, followed by this frame. If this |
1055 frame doesn't scroll, attempts to scroll the parent |
1055 frame doesn't scroll, attempts to scroll the parent |
1056 |
1056 */ |
1057 \sa QWebFrame::scroll |
1057 void QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy, const QPoint& pos) |
1058 */ |
|
1059 bool QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy) |
|
1060 { |
1058 { |
1061 Frame* frame = QWebFramePrivate::core(qFrame); |
1059 Frame* frame = QWebFramePrivate::core(qFrame); |
1062 bool scrolledHorizontal = false; |
1060 |
1063 bool scrolledVertical = false; |
1061 if (!frame || !frame->view()) |
1064 bool scrolledOverflow = webframe_scrollOverflow(frame, dx, dy); |
1062 return; |
1065 |
1063 |
1066 if (!scrolledOverflow) { |
1064 if (!webframe_scrollOverflow(frame, dx, dy, pos)) { |
1067 if (!frame || !frame->view()) |
|
1068 return false; |
|
1069 |
|
1070 do { |
1065 do { |
|
1066 bool scrolledHorizontal = false; |
|
1067 bool scrolledVertical = false; |
|
1068 |
1071 IntSize scrollOffset = frame->view()->scrollOffset(); |
1069 IntSize scrollOffset = frame->view()->scrollOffset(); |
1072 IntPoint maxScrollOffset = frame->view()->maximumScrollPosition(); |
1070 IntPoint maxScrollOffset = frame->view()->maximumScrollPosition(); |
1073 |
1071 |
1074 if (dx > 0) // scroll right |
1072 if (dx > 0) // scroll right |
1075 scrolledHorizontal = scrollOffset.width() < maxScrollOffset.x(); |
1073 scrolledHorizontal = scrollOffset.width() < maxScrollOffset.x(); |
1081 else if (dy < 0) //scroll up |
1079 else if (dy < 0) //scroll up |
1082 scrolledVertical = scrollOffset.height() > 0; |
1080 scrolledVertical = scrollOffset.height() > 0; |
1083 |
1081 |
1084 if (scrolledHorizontal || scrolledVertical) { |
1082 if (scrolledHorizontal || scrolledVertical) { |
1085 frame->view()->scrollBy(IntSize(dx, dy)); |
1083 frame->view()->scrollBy(IntSize(dx, dy)); |
1086 return true; |
1084 return; |
1087 } |
1085 } |
|
1086 |
1088 frame = frame->tree()->parent(); |
1087 frame = frame->tree()->parent(); |
1089 } while (frame && frame->view()); |
1088 } while (frame && frame->view()); |
1090 } |
1089 } |
1091 return (scrolledHorizontal || scrolledVertical || scrolledOverflow); |
|
1092 } |
1090 } |
1093 |
1091 |
1094 /*! |
1092 /*! |
1095 \property QWebFrame::scrollPosition |
1093 \property QWebFrame::scrollPosition |
1096 \since 4.5 |
1094 \since 4.5 |