diff --git a/ChangeLog b/ChangeLog index f798e82b3ec6c7e030408633b41841ab0601d7d4..091b70d016aae79b36149947b7ea724e96a7928f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-09-23 Varun Jain + + Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests + https://bugs.webkit.org/show_bug.cgi?id=68198 + + Reviewed by Dimitri Glazkov. + + * Source/autotools/symbols.filter: + 2011-09-23 Mark Hahnenberg Add static version of JSCell::visitChildren diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 7c38cef6cfd7b86c9f1484a7bd60e4c81e27c150..29ec1ca7bdd19669439c651f5835086d4807cb23 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,15 @@ +2011-09-23 Varun Jain + + Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests + https://bugs.webkit.org/show_bug.cgi?id=68198 + + Reviewed by Dimitri Glazkov. + + * fast/dom/scroll-element-to-rect-centered-expected.txt: Added. + * fast/dom/scroll-element-to-rect-centered.html: Added. + * fast/dom/scroll-element-to-rect-expected.txt: Added. + * fast/dom/scroll-element-to-rect.html: Added. + 2011-09-23 Dean Jackson Add -webkit-filter to CSSPropertyNames diff --git a/LayoutTests/fast/dom/scroll-element-to-rect-centered-expected.txt b/LayoutTests/fast/dom/scroll-element-to-rect-centered-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..872311c7dc2a237ad0ded5d69ce07c153dcc808a --- /dev/null +++ b/LayoutTests/fast/dom/scroll-element-to-rect-centered-expected.txt @@ -0,0 +1,7 @@ +Scrolled element to rect +PASS rect.left is computedLeft +PASS rect.top is computedTop +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/scroll-element-to-rect-centered.html b/LayoutTests/fast/dom/scroll-element-to-rect-centered.html new file mode 100644 index 0000000000000000000000000000000000000000..5c5df82adf7e1abb5e4773a80f1e528fbe88adb8 --- /dev/null +++ b/LayoutTests/fast/dom/scroll-element-to-rect-centered.html @@ -0,0 +1,30 @@ + + + +
+
+
+
+
+ + + + + + + diff --git a/LayoutTests/fast/dom/scroll-element-to-rect-expected.txt b/LayoutTests/fast/dom/scroll-element-to-rect-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..872311c7dc2a237ad0ded5d69ce07c153dcc808a --- /dev/null +++ b/LayoutTests/fast/dom/scroll-element-to-rect-expected.txt @@ -0,0 +1,7 @@ +Scrolled element to rect +PASS rect.left is computedLeft +PASS rect.top is computedTop +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/scroll-element-to-rect.html b/LayoutTests/fast/dom/scroll-element-to-rect.html new file mode 100644 index 0000000000000000000000000000000000000000..77623bae6858266861fd91f201f4bc31cf2d5c1d --- /dev/null +++ b/LayoutTests/fast/dom/scroll-element-to-rect.html @@ -0,0 +1,28 @@ + + + +
+
+
+
+ + + + + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 56810cc5b926c0f325eee8f6740a783afc4b1e26..622b8a0bb33a378b2ca85b07fd706a1d315012bd 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,22 @@ +2011-09-23 Varun Jain + + Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests + https://bugs.webkit.org/show_bug.cgi?id=68198 + + Reviewed by Dimitri Glazkov. + + Tests: fast/dom/scroll-element-to-rect-centered.html + fast/dom/scroll-element-to-rect.html + + * WebCore.exp.in: + * page/FrameView.cpp: + (WebCore::FrameView::scrollElementToRect): + * page/FrameView.h: + * testing/Internals.cpp: + (WebCore::Internals::scrollElementToRect): + * testing/Internals.h: + * testing/Internals.idl: + 2011-09-23 Mihai Parparita Unreviewed, rolling out r95860. diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in index 12c0b8190c579738f6640bd2687913db82f0112e..7381b4efcd965aded2739a4935083950da774f74 100644 --- a/Source/WebCore/WebCore.exp.in +++ b/Source/WebCore/WebCore.exp.in @@ -985,6 +985,7 @@ __ZN7WebCore9FrameView38syncCompositingStateIncludingSubframesEv __ZN7WebCore9FrameView6createEPNS_5FrameE __ZN7WebCore9FrameView6createEPNS_5FrameERKNS_7IntSizeE __ZN7WebCore9FrameView17paintControlTintsEv +__ZN7WebCore9FrameView19scrollElementToRectEPNS_7ElementERKNS_7IntRectE __ZN7WebCore9HTMLNames10listingTagE __ZN7WebCore9HTMLNames11textareaTagE __ZN7WebCore9HTMLNames13blockquoteTagE diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index b0ff8b2465b7e2be466879b35435e316da685b1f..532b3e8b00904248750e662eab5fb2643766c0cb 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -1622,6 +1622,16 @@ void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode) scrollToAnchor(); } +void FrameView::scrollElementToRect(Element* element, const IntRect& rect) +{ + m_frame->document()->updateLayoutIgnorePendingStylesheets(); + + LayoutRect bounds = element->boundsInWindowSpace(); + int centeringOffsetX = (rect.width() - bounds.width()) / 2; + int centeringOffsetY = (rect.height() - bounds.height()) / 2; + scrollBy(IntSize(bounds.x() - centeringOffsetX - rect.x(), bounds.y() - centeringOffsetY - rect.y())); +} + void FrameView::setScrollPosition(const LayoutPoint& scrollPoint) { bool wasInProgrammaticScroll = m_inProgrammaticScroll; diff --git a/Source/WebCore/page/FrameView.h b/Source/WebCore/page/FrameView.h index 93ee91ae9a50ebc97a131d2f5e3788667d21097b..f9face0cc177b270a091d078d984d44915023e92 100644 --- a/Source/WebCore/page/FrameView.h +++ b/Source/WebCore/page/FrameView.h @@ -36,6 +36,7 @@ namespace WebCore { class Color; +class Element; class Event; class FloatSize; class Frame; @@ -260,6 +261,7 @@ public: bool scrollToFragment(const KURL&); bool scrollToAnchor(const String&); void maintainScrollPositionAtAnchor(Node*); + void scrollElementToRect(Element*, const IntRect&); // Methods to convert points and rects between the coordinate space of the renderer, and this view. virtual LayoutRect convertFromRenderer(const RenderObject*, const LayoutRect&) const; diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp index fa92051c49a9c48dfd243c8957ab8c2748024c5f..f9a78a242f0ac4ef50f4b74433aa2e19d0c21bc2 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -37,6 +37,7 @@ #include "HTMLNames.h" #include "HTMLTextAreaElement.h" #include "InspectorController.h" +#include "IntRect.h" #include "MemoryCache.h" #include "NodeRenderingContext.h" #include "Page.h" @@ -376,4 +377,14 @@ void Internals::paintControlTints(Document* document, ExceptionCode& ec) frameView->paintControlTints(); } +void Internals::scrollElementToRect(Element* element, long x, long y, long w, long h, ExceptionCode& ec) +{ + if (!element || !element->document() || !element->document()->view()) { + ec = INVALID_ACCESS_ERR; + return; + } + FrameView* frameView = element->document()->view(); + frameView->scrollElementToRect(element, IntRect(x, y, w, h)); +} + } diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h index 7c456fbf091c63e560d7c2bb0252343784ea07b6..c2c264ff936f52030730847fd5359170c9a2206b 100644 --- a/Source/WebCore/testing/Internals.h +++ b/Source/WebCore/testing/Internals.h @@ -87,6 +87,7 @@ public: bool wasLastChangeUserEdit(Element* textField, ExceptionCode&); String suggestedValue(Element* inputElement, ExceptionCode&); void setSuggestedValue(Element* inputElement, const String&, ExceptionCode&); + void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionCode&); static const char* internalsId; diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl index d8a0a6d06fa5c9146e213981f2bbb2ef25c9cbc8..c267e486a0170a4acc4847f7c56d07da46717814 100644 --- a/Source/WebCore/testing/Internals.idl +++ b/Source/WebCore/testing/Internals.idl @@ -63,6 +63,8 @@ module window { void setSuggestedValue(in Element inputElement, in DOMString value) raises (DOMException); void paintControlTints(in Document document) raises (DOMException); + + void scrollElementToRect(in Element element, in long x, in long y, in long w, in long h) raises (DOMException); }; } diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index cabb3285e85d0c6a1f4890e69123483cc786e027..2d44b51de972908101f8ab310e65f12f5d3c7bcf 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,15 @@ +2011-09-23 Varun Jain + + Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests + https://bugs.webkit.org/show_bug.cgi?id=68198 + + Reviewed by Dimitri Glazkov. + + * public/WebView.h: + (WebKit::WebView::scrollFocusedNodeIntoRect): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::scrollFocusedNodeIntoRect): + 2011-09-23 Mihai Parparita Unreviewed, rolling out r95860. diff --git a/Source/WebKit/chromium/public/WebView.h b/Source/WebKit/chromium/public/WebView.h index 338c2ad945f082a4afea55aecd0a7094dbd1ba89..75e0bb0343e86384b3c4309fa64edaedcb19f596 100644 --- a/Source/WebKit/chromium/public/WebView.h +++ b/Source/WebKit/chromium/public/WebView.h @@ -175,8 +175,8 @@ public: virtual void scrollFocusedNodeIntoView() = 0; // Scrolls the node currently in focus into |rect|, where |rect| is in - // screen space. - virtual void scrollFocusedNodeIntoRect(const WebRect& rect) { } + // window space. + virtual void scrollFocusedNodeIntoRect(const WebRect&) { } // Zoom ---------------------------------------------------------------- diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index eb6a42c2259f91cf569c11900eac54b59bbe2ecb..88b22ed38e6f28b7032e7a55b57a55875adeaa5e 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -1820,17 +1820,12 @@ void WebViewImpl::scrollFocusedNodeIntoView() void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect) { + Frame* frame = page()->mainFrame(); Node* focusedNode = focusedWebCoreNode(); - if (!focusedNode || !focusedNode->isElementNode()) + if (!frame || !frame->view() || !focusedNode || !focusedNode->isElementNode()) return; Element* elementNode = static_cast(focusedNode); - LayoutRect bounds = elementNode->boundsInWindowSpace(); - int centeringOffsetX = (rect.width - bounds.width()) / 2; - int centeringOffsetY = (rect.height - bounds.height()) / 2; - IntSize scrollOffset(bounds.x() - centeringOffsetX, bounds.y() - centeringOffsetY); - Frame* frame = mainFrameImpl()->frame(); - if (frame && frame->view()) - frame->view()->scrollBy(scrollOffset); + frame->view()->scrollElementToRect(elementNode, IntRect(rect.x, rect.y, rect.width, rect.height)); } double WebViewImpl::zoomLevel() diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index d22730f9167f2be71bced5405cac95dbf430894b..d2c44119bc999f7e66c51388715b8034e7235970 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,13 @@ +2011-09-23 Varun Jain + + Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests + https://bugs.webkit.org/show_bug.cgi?id=68198 + + Reviewed by Dimitri Glazkov. + + * win/WebKit2.def: + * win/WebKit2CFLite.def: + 2011-09-23 Chang Shu [WK2] [Qt] Implement MouseDown/MouseUp/MouseMoveTo functions for WebKit2 EventSender diff --git a/Source/WebKit2/win/WebKit2.def b/Source/WebKit2/win/WebKit2.def index 68d893ed6928c69356a85e1242095c12032935c4..fa518e3402a112546190bbbd5212f694594fd102 100644 --- a/Source/WebKit2/win/WebKit2.def +++ b/Source/WebKit2/win/WebKit2.def @@ -162,6 +162,7 @@ EXPORTS ?memoryCache@WebCore@@YAPAVMemoryCache@1@XZ ?page@Document@WebCore@@QBEPAVPage@2@XZ ?paintControlTints@FrameView@WebCore@@AAEXXZ + ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z ?removeShadowRoot@Element@WebCore@@QAEXXZ ?setDisabled@MemoryCache@WebCore@@QAEX_N@Z ?setDOMException@WebCore@@YAXPAVExecState@JSC@@H@Z diff --git a/Source/WebKit2/win/WebKit2CFLite.def b/Source/WebKit2/win/WebKit2CFLite.def index edaecc1dd2c1b1f7d0ab6603d89e00d51ab1ffba..8482b49716c71cb2c32d7c0fbc952f27f41f4d1c 100644 --- a/Source/WebKit2/win/WebKit2CFLite.def +++ b/Source/WebKit2/win/WebKit2CFLite.def @@ -156,6 +156,7 @@ EXPORTS ?memoryCache@WebCore@@YAPAVMemoryCache@1@XZ ?page@Document@WebCore@@QBEPAVPage@2@XZ ?paintControlTints@FrameView@WebCore@@AAEXXZ + ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z ?removeShadowRoot@Element@WebCore@@QAEXXZ ?setDisabled@MemoryCache@WebCore@@QAEX_N@Z ?setDOMException@WebCore@@YAXPAVExecState@JSC@@H@Z diff --git a/Source/autotools/symbols.filter b/Source/autotools/symbols.filter index afc7bce69496ade37f0f30f9eaf5be10f8d0cd7e..7d39c45ac09e4bbe23358bd3b6759a41403a910c 100644 --- a/Source/autotools/symbols.filter +++ b/Source/autotools/symbols.filter @@ -77,6 +77,7 @@ _ZNK7WebCore9TreeScope14getElementByIdERKN3WTF12AtomicStringE; _ZN7WebCore14ScrollableArea28setScrollOffsetFromInternalsERKNS_8IntPointE; _ZN7WebCore10ScrollView23setScrollbarsSuppressedEbb; _ZN7WebCore9FrameView17paintControlTintsEv; +_ZN7WebCore9FrameView19scrollElementToRectEPNS_7ElementERKNS_7IntRectE; local: _Z*; cti*;