From 15439c427e330329f5171063768add65d9d3f655 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Thu, 19 Feb 2009 23:57:15 +0000 Subject: Reported crashers indicate that the autofill popup-menu is showing for a detached text field. I am not sure how this could happen as when the text field has to have focus for the autofill popup to show and the popup is closed when it loses focus. This CL is a work-around the crasher. Hopefully someone will trigger the DCHECK and provide more info. BUG=7708 TEST=Exercise the autofill. Review URL: http://codereview.chromium.org/21528 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10063 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/webview_impl.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 7959b6f..77d5442 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -187,7 +187,9 @@ class AutocompletePopupMenuClient : public WebCore::PopupMenuClient { } virtual int clientPaddingLeft() const { #if defined(OS_WIN) - return theme()->popupInternalPaddingLeft(text_field_->computedStyle()); + // Bug http://crbug.com/7708 seems to indicate the style can be NULL. + WebCore::RenderStyle* style = GetTextFieldStyle(); + return style ? theme()->popupInternalPaddingLeft(style) : 0; #else NOTIMPLEMENTED(); return 0; @@ -195,7 +197,9 @@ class AutocompletePopupMenuClient : public WebCore::PopupMenuClient { } virtual int clientPaddingRight() const { #if defined(OS_WIN) - return theme()->popupInternalPaddingRight(text_field_->computedStyle()); + // Bug http://crbug.com/7708 seems to indicate the style can be NULL. + WebCore::RenderStyle* style = GetTextFieldStyle(); + return style ? theme()->popupInternalPaddingRight(style) : 0; #else NOTIMPLEMENTED(); return 0; @@ -263,6 +267,17 @@ class AutocompletePopupMenuClient : public WebCore::PopupMenuClient { WebCore::HTMLInputElement* text_field() const { return text_field_.get(); } + + WebCore::RenderStyle* GetTextFieldStyle() const { + WebCore::RenderStyle* style = text_field_->computedStyle(); + if (!style) { + // It seems we can only have an NULL style in a TextField if the node is + // dettached, in which case we the popup shoud not be showing. + NOTREACHED() << "Please report this in http://crbug.com/7708 and include " + "the page you were visiting."; + } + return style; + } private: RefPtr text_field_; -- cgit v1.1