Diff
Modified: trunk/LayoutTests/ChangeLog (97201 => 97202)
--- trunk/LayoutTests/ChangeLog 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/LayoutTests/ChangeLog 2011-10-12 00:19:29 UTC (rev 97202)
@@ -1,3 +1,13 @@
+2011-10-11 Fady Samuel <[email protected]>
+
+ Towards making PopupMenuClient more testable
+ https://bugs.webkit.org/show_bug.cgi?id=69631
+
+ Reviewed by Simon Fraser.
+
+ * fast/dom/popup-menu-client-test-expected.txt: Added.
+ * fast/dom/popup-menu-client-test.html: Added.
+
2011-10-11 Kenneth Russell <[email protected]>
[chromium] Check for lost context at beginning of compositor's execution
Added: trunk/LayoutTests/fast/dom/popup-menu-client-test-expected.txt (0 => 97202)
--- trunk/LayoutTests/fast/dom/popup-menu-client-test-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/popup-menu-client-test-expected.txt 2011-10-12 00:19:29 UTC (rev 97202)
@@ -0,0 +1,10 @@
+PASS popupClientPaddingLeft is 4
+PASS popupClientPaddingRight is 2
+FAIL boundingBoxRect.left should be 10. Was 20.
+FAIL boundingBoxRect.top should be 10. Was 20.
+PASS boundingBoxRect.width is boundingClientRect.width
+PASS boundingBoxRect.height is boundingClientRect.height
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/popup-menu-client-test.html (0 => 97202)
--- trunk/LayoutTests/fast/dom/popup-menu-client-test.html (rev 0)
+++ trunk/LayoutTests/fast/dom/popup-menu-client-test.html 2011-10-12 00:19:29 UTC (rev 97202)
@@ -0,0 +1,38 @@
+<html>
+ <head>
+ <body>
+ <div id="console"></div>
+ <select id="selectelement">
+ <option>Element 1</option>
+ <option>Element 2</option>
+ <option>Element 3</option>
+ </select>
+ </body>
+ <script src=""
+ <script>
+ var selectElement = document.getElementById("selectelement");
+ if (window.internals) {
+ // FIXME: This wil fail if the page scale factor != 1.0
+ var pageScaleFactor = 2.0;
+ eventSender.scalePageBy(pageScaleFactor, 0, 0);
+
+ var popupClientPaddingLeft = window.internals.popupClientPaddingLeft(selectElement);
+ var popupClientPaddingRight = window.internals.popupClientPaddingRight(selectElement);
+ var boundingBoxRect = window.internals.popupClientBoundingBoxRect(selectElement);
+ var boundingClientRect = selectElement.getBoundingClientRect();
+ shouldBe("popupClientPaddingLeft", "4");
+ shouldBe("popupClientPaddingRight", "2");
+ shouldBe("boundingBoxRect.left", "boundingClientRect.left");
+ shouldBe("boundingBoxRect.top", "boundingClientRect.top");
+ shouldBe("boundingBoxRect.width", "boundingClientRect.width");
+ shouldBe("boundingBoxRect.height", "boundingClientRect.height");
+ }
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ }
+ successfullyParsed = true;
+ </script>
+ <script src=""
+ </script>
+ </head>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (97201 => 97202)
--- trunk/Source/WebCore/ChangeLog 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/ChangeLog 2011-10-12 00:19:29 UTC (rev 97202)
@@ -1,3 +1,35 @@
+2011-10-11 Fady Samuel <[email protected]>
+
+ Towards making PopupMenuClient more testable
+ https://bugs.webkit.org/show_bug.cgi?id=69631
+
+ Reviewed by Simon Fraser.
+
+ Added some functions to window.internals to allow testing of parts of PopupMenuClient.
+
+ Test: fast/dom/popup-menu-client-test.html
+
+ * platform/PopupMenuClient.h:
+ * rendering/RenderMenuList.cpp:
+ (WebCore::RenderMenuList::showPopup):
+ (WebCore::RenderMenuList::boundingBoxRect):
+ * rendering/RenderMenuList.h:
+ (WebCore::RenderMenuList::RenderMenuList::isPopupMenuClient):
+ * rendering/RenderObject.h:
+ (WebCore::RenderObject::isPopupMenuClient):
+ * rendering/RenderTextControlSingleLine.cpp:
+ (WebCore::RenderTextControlSingleLine::showPopup):
+ (WebCore::RenderTextControlSingleLine::boundingBoxRect):
+ * rendering/RenderTextControlSingleLine.h:
+ (WebCore::RenderTextControlSingleLine::isPopupMenuClient):
+ * testing/Internals.cpp:
+ (WebCore::Internals::toPopupMenuClient):
+ (WebCore::Internals::popupClientPaddingLeft):
+ (WebCore::Internals::popupClientPaddingRight):
+ (WebCore::Internals::popupClientBoundingBoxRect):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2011-10-11 Nate Chapin <[email protected]>
Make CachedResourceClientWalker templates, and
Modified: trunk/Source/WebCore/platform/PopupMenuClient.h (97201 => 97202)
--- trunk/Source/WebCore/platform/PopupMenuClient.h 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/platform/PopupMenuClient.h 2011-10-12 00:19:29 UTC (rev 97202)
@@ -22,6 +22,7 @@
#ifndef PopupMenuClient_h
#define PopupMenuClient_h
+#include "LayoutTypes.h"
#include "PopupMenuStyle.h"
#include "ScrollTypes.h"
#include <wtf/Forward.h>
@@ -49,6 +50,7 @@
virtual bool itemIsEnabled(unsigned listIndex) const = 0;
virtual PopupMenuStyle itemStyle(unsigned listIndex) const = 0;
virtual PopupMenuStyle menuStyle() const = 0;
+ virtual LayoutRect boundingBoxRect() const = 0;
virtual int clientInsetLeft() const = 0;
virtual int clientInsetRight() const = 0;
virtual int clientPaddingLeft() const = 0;
Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (97201 => 97202)
--- trunk/Source/WebCore/rendering/RenderMenuList.cpp 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp 2011-10-12 00:19:29 UTC (rev 97202)
@@ -303,13 +303,7 @@
HTMLSelectElement* select = toSelectElement(static_cast<Element*>(node()));
m_popupIsVisible = true;
- // Compute the top left taking transforms into account, but use
- // the actual width of the element to size the popup.
- FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true);
- LayoutRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
- absBounds.setLocation(roundedIntPoint(absTopLeft));
- m_popup->show(absBounds, document()->view(),
- select->optionToListIndex(select->selectedIndex()));
+ m_popup->show(boundingBoxRect(), document()->view(), select->optionToListIndex(select->selectedIndex()));
}
void RenderMenuList::hidePopup()
@@ -506,6 +500,16 @@
return widget.release();
}
+LayoutRect RenderMenuList::boundingBoxRect() const
+{
+ // Compute the top left taking transforms into account, but use
+ // the actual width of the element to size the popup.
+ FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true);
+ LayoutRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
+ absBounds.setLocation(roundedIntPoint(absTopLeft));
+ return absBounds;
+}
+
int RenderMenuList::clientInsetLeft() const
{
return 0;
Modified: trunk/Source/WebCore/rendering/RenderMenuList.h (97201 => 97202)
--- trunk/Source/WebCore/rendering/RenderMenuList.h 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/rendering/RenderMenuList.h 2011-10-12 00:19:29 UTC (rev 97202)
@@ -39,9 +39,9 @@
class RenderText;
#if ENABLE(NO_LISTBOX_RENDERING)
-class RenderMenuList : public RenderDeprecatedFlexibleBox, private ListPopupMenuClient {
+class RenderMenuList : public RenderDeprecatedFlexibleBox, public ListPopupMenuClient {
#else
-class RenderMenuList : public RenderDeprecatedFlexibleBox, private PopupMenuClient {
+class RenderMenuList : public RenderDeprecatedFlexibleBox, public PopupMenuClient {
#endif
public:
@@ -61,6 +61,7 @@
private:
virtual bool isMenuList() const { return true; }
+ virtual bool isPopupMenuClient() const { return true; }
virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
virtual void removeChild(RenderObject*);
@@ -89,6 +90,7 @@
virtual bool itemIsEnabled(unsigned listIndex) const;
virtual PopupMenuStyle itemStyle(unsigned listIndex) const;
virtual PopupMenuStyle menuStyle() const;
+ virtual LayoutRect boundingBoxRect() const;
virtual int clientInsetLeft() const;
virtual int clientInsetRight() const;
virtual int clientPaddingLeft() const;
Modified: trunk/Source/WebCore/rendering/RenderObject.h (97201 => 97202)
--- trunk/Source/WebCore/rendering/RenderObject.h 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2011-10-12 00:19:29 UTC (rev 97202)
@@ -52,6 +52,7 @@
class InlineFlowBox;
class OverlapTestRequestClient;
class Path;
+class PopupMenuClient;
class Position;
class RenderBoxModelObject;
class RenderInline;
@@ -296,6 +297,7 @@
#if ENABLE(METER_TAG)
virtual bool isMeter() const { return false; }
#endif
+ virtual bool isPopupMenuClient() const { return false; }
#if ENABLE(PROGRESS_TAG)
virtual bool isProgress() const { return false; }
#endif
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (97201 => 97202)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2011-10-12 00:19:29 UTC (rev 97202)
@@ -174,7 +174,7 @@
m_searchPopup->saveRecentSearches(name, m_recentSearches);
}
- m_searchPopup->popupMenu()->show(absoluteBoundingBoxRect(), document()->view(), -1);
+ m_searchPopup->popupMenu()->show(boundingBoxRect(), document()->view(), -1);
}
void RenderTextControlSingleLine::hidePopup()
@@ -613,6 +613,11 @@
return PopupMenuStyle(style()->visitedDependentColor(CSSPropertyColor), style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->font(), style()->visibility() == VISIBLE, style()->display() == NONE, style()->textIndent(), style()->direction(), style()->unicodeBidi() == Override);
}
+LayoutRect RenderTextControlSingleLine::boundingBoxRect() const
+{
+ return absoluteBoundingBoxRect();
+}
+
int RenderTextControlSingleLine::clientInsetLeft() const
{
// Inset the menu by the radius of the cap on the left so that
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (97201 => 97202)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2011-10-12 00:19:29 UTC (rev 97202)
@@ -56,6 +56,7 @@
private:
virtual bool hasControlClip() const;
virtual LayoutRect controlClipRect(const LayoutPoint&) const;
+ virtual bool isPopupMenuClient() const { return true; }
virtual bool isTextField() const { return true; }
virtual void paint(PaintInfo&, const LayoutPoint&);
@@ -100,6 +101,7 @@
virtual bool itemIsEnabled(unsigned listIndex) const;
virtual PopupMenuStyle itemStyle(unsigned listIndex) const;
virtual PopupMenuStyle menuStyle() const;
+ virtual LayoutRect boundingBoxRect() const;
virtual int clientInsetLeft() const;
virtual int clientInsetRight() const;
virtual int clientPaddingLeft() const;
Modified: trunk/Source/WebCore/testing/Internals.cpp (97201 => 97202)
--- trunk/Source/WebCore/testing/Internals.cpp 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/testing/Internals.cpp 2011-10-12 00:19:29 UTC (rev 97202)
@@ -36,6 +36,7 @@
#include "FrameView.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
+#include "HTMLSelectElement.h"
#include "HTMLTextAreaElement.h"
#include "InspectorController.h"
#include "IntRect.h"
@@ -44,7 +45,9 @@
#if ENABLE(GESTURE_EVENTS)
#include "PlatformGestureEvent.h"
#endif
+#include "PopupMenuClient.h"
#include "Range.h"
+#include "RenderMenuList.h"
#include "RenderObject.h"
#include "RenderTreeAsText.h"
#if ENABLE(SMOOTH_SCROLLING)
@@ -435,4 +438,62 @@
frameView->scrollElementToRect(element, IntRect(x, y, w, h));
}
+static const PopupMenuClient* toPopupMenuClient(RenderObject* object)
+{
+ ASSERT(!object || object->isPopupMenuClient());
+ if (!object)
+ return 0;
+
+ // Special case: RenderMenuList uses multiple inheritance and so,
+ // depending on the compiler, we may end up in a situation where
+ // the first vptr does not point to the PopupMenuClient's vtable,
+ // and so we'd end up calling the wrong method. Thus, we first cast to
+ // RenderMenuList and then to PopupMenuClient which will automagically
+ // take into account thunking if necessary (the casting will actually shift
+ // the pointer over to the PopupMenuClient part of the object).
+ if (object->isMenuList())
+ return static_cast<PopupMenuClient*>(toRenderMenuList(object));
+
+ return reinterpret_cast<PopupMenuClient*>(object);
}
+
+int Internals::popupClientPaddingLeft(Element* element, ExceptionCode& ec)
+{
+ if (!element || !element->renderer()) {
+ ec = INVALID_ACCESS_ERR;
+ return 0;
+ }
+ element->document()->updateLayoutIgnorePendingStylesheets();
+ RenderObject* renderer = element->renderer();
+ if (renderer->isPopupMenuClient())
+ return toPopupMenuClient(renderer)->clientPaddingLeft();
+ return 0;
+}
+
+int Internals::popupClientPaddingRight(Element* element, ExceptionCode& ec)
+{
+ if (!element || !element->renderer()) {
+ ec = INVALID_ACCESS_ERR;
+ return 0;
+ }
+ element->document()->updateLayoutIgnorePendingStylesheets();
+ RenderObject* renderer = element->renderer();
+ if (renderer->isPopupMenuClient())
+ return toPopupMenuClient(renderer)->clientPaddingRight();
+ return 0;
+}
+
+PassRefPtr<ClientRect> Internals::popupClientBoundingBoxRect(Element* element, ExceptionCode& ec)
+{
+ if (!element || !element->renderer()) {
+ ec = INVALID_ACCESS_ERR;
+ return ClientRect::create();
+ }
+ element->document()->updateLayoutIgnorePendingStylesheets();
+ RenderObject* renderer = element->renderer();
+ if (renderer->isPopupMenuClient())
+ return ClientRect::create(toPopupMenuClient(renderer)->boundingBoxRect());
+ return ClientRect::create();
+}
+
+}
Modified: trunk/Source/WebCore/testing/Internals.h (97201 => 97202)
--- trunk/Source/WebCore/testing/Internals.h 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/testing/Internals.h 2011-10-12 00:19:29 UTC (rev 97202)
@@ -38,7 +38,9 @@
class Document;
class Element;
class Node;
+class PopupMenuClient;
class Range;
+class RenderObject;
class Internals : public RefCounted<Internals> {
public:
@@ -92,6 +94,10 @@
void setSuggestedValue(Element* inputElement, const String&, ExceptionCode&);
void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionCode&);
+ int popupClientPaddingLeft(Element*, ExceptionCode&);
+ int popupClientPaddingRight(Element*, ExceptionCode&);
+ PassRefPtr<ClientRect> popupClientBoundingBoxRect(Element*, ExceptionCode&);
+
static const char* internalsId;
void paintControlTints(Document*, ExceptionCode&);
Modified: trunk/Source/WebCore/testing/Internals.idl (97201 => 97202)
--- trunk/Source/WebCore/testing/Internals.idl 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebCore/testing/Internals.idl 2011-10-12 00:19:29 UTC (rev 97202)
@@ -67,6 +67,10 @@
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);
+
+ int popupClientPaddingLeft(in Element element) raises (DOMException);
+ int popupClientPaddingRight(in Element element) raises (DOMException);
+ ClientRect popupClientBoundingBoxRect(in Element element) raises (DOMException);
};
}
Modified: trunk/Source/WebKit/chromium/ChangeLog (97201 => 97202)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-10-12 00:19:29 UTC (rev 97202)
@@ -1,3 +1,16 @@
+2011-10-11 Fady Samuel <[email protected]>
+
+ Towards making PopupMenuClient more testable
+ https://bugs.webkit.org/show_bug.cgi?id=69631
+
+ Reviewed by Simon Fraser.
+
+ * src/AutofillPopupMenuClient.cpp:
+ (WebKit::AutofillPopupMenuClient::boundingBoxRect):
+ * src/AutofillPopupMenuClient.h:
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::applyAutofillSuggestions):
+
2011-10-11 Dominic Mazzoni <[email protected]>
WebAccessibilityObject needs titleUIElement
Modified: trunk/Source/WebKit/chromium/src/AutofillPopupMenuClient.cpp (97201 => 97202)
--- trunk/Source/WebKit/chromium/src/AutofillPopupMenuClient.cpp 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebKit/chromium/src/AutofillPopupMenuClient.cpp 2011-10-12 00:19:29 UTC (rev 97202)
@@ -216,6 +216,13 @@
return RenderTheme::defaultTheme()->popupInternalPaddingRight(style);
}
+WebCore::LayoutRect AutofillPopupMenuClient::boundingBoxRect() const
+{
+ if (m_textField)
+ return m_textField->getRect();
+ return WebCore::LayoutRect();
+}
+
void AutofillPopupMenuClient::popupDidHide()
{
WebViewImpl* webView = getWebView();
Modified: trunk/Source/WebKit/chromium/src/AutofillPopupMenuClient.h (97201 => 97202)
--- trunk/Source/WebKit/chromium/src/AutofillPopupMenuClient.h 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebKit/chromium/src/AutofillPopupMenuClient.h 2011-10-12 00:19:29 UTC (rev 97202)
@@ -31,6 +31,7 @@
#ifndef AutofillPopupMenuClient_h
#define AutofillPopupMenuClient_h
+#include "LayoutTypes.h"
#include "PopupMenuClient.h"
namespace WebCore {
@@ -82,6 +83,7 @@
virtual bool itemIsEnabled(unsigned listIndex) const;
virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const;
virtual WebCore::PopupMenuStyle menuStyle() const;
+ virtual WebCore::LayoutRect boundingBoxRect() const;
virtual int clientInsetLeft() const { return 0; }
virtual int clientInsetRight() const { return 0; }
virtual int clientPaddingLeft() const;
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (97201 => 97202)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2011-10-12 00:17:37 UTC (rev 97201)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2011-10-12 00:19:29 UTC (rev 97202)
@@ -2241,7 +2241,7 @@
if (m_autofillPopupShowing) {
refreshAutofillPopup();
} else {
- m_autofillPopup->showInRect(focusedNode->getRect(), focusedNode->ownerDocument()->view(), 0);
+ m_autofillPopup->showInRect(m_autofillPopupClient->boundingBoxRect(), focusedNode->ownerDocument()->view(), 0);
m_autofillPopupShowing = true;
}
}