Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Issue 1959583002: Do not open SELECT popup if the SELECT element is not in the viewport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: popup-menu-key-operations.html needs rebaseline Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 1999 Antti Koivisto (koivisto@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * 10 *
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 1869
1870 const ComputedStyle* HTMLSelectElement::itemComputedStyle(Element& element) cons t 1870 const ComputedStyle* HTMLSelectElement::itemComputedStyle(Element& element) cons t
1871 { 1871 {
1872 return element.computedStyle() ? element.computedStyle() : element.ensureCom putedStyle(); 1872 return element.computedStyle() ? element.computedStyle() : element.ensureCom putedStyle();
1873 } 1873 }
1874 1874
1875 IntRect HTMLSelectElement::elementRectRelativeToViewport() const 1875 IntRect HTMLSelectElement::elementRectRelativeToViewport() const
1876 { 1876 {
1877 if (!layoutObject()) 1877 if (!layoutObject())
1878 return IntRect(); 1878 return IntRect();
1879 // Initialize with this frame rectangle relative to the viewport.
1880 IntRect rect = document().view()->convertToRootFrame(document().view()->boun dsRect());
1879 // We don't use absoluteBoundingBoxRect() because it can return an IntRect 1881 // We don't use absoluteBoundingBoxRect() because it can return an IntRect
1880 // larger the actual size by 1px. 1882 // larger the actual size by 1px.
1881 return document().view()->contentsToViewport(roundedIntRect(layoutObject()-> absoluteBoundingBoxFloatRect())); 1883 rect.intersect(document().view()->contentsToViewport(roundedIntRect(layoutOb ject()->absoluteBoundingBoxFloatRect())));
1884 return rect;
1882 } 1885 }
1883 1886
1884 LayoutUnit HTMLSelectElement::clientPaddingLeft() const 1887 LayoutUnit HTMLSelectElement::clientPaddingLeft() const
1885 { 1888 {
1886 if (layoutObject() && layoutObject()->isMenuList()) 1889 if (layoutObject() && layoutObject()->isMenuList())
1887 return toLayoutMenuList(layoutObject())->clientPaddingLeft(); 1890 return toLayoutMenuList(layoutObject())->clientPaddingLeft();
1888 return LayoutUnit(); 1891 return LayoutUnit();
1889 } 1892 }
1890 1893
1891 LayoutUnit HTMLSelectElement::clientPaddingRight() const 1894 LayoutUnit HTMLSelectElement::clientPaddingRight() const
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 } 1947 }
1945 1948
1946 void HTMLSelectElement::showPopup() 1949 void HTMLSelectElement::showPopup()
1947 { 1950 {
1948 if (popupIsVisible()) 1951 if (popupIsVisible())
1949 return; 1952 return;
1950 if (document().frameHost()->chromeClient().hasOpenedPopup()) 1953 if (document().frameHost()->chromeClient().hasOpenedPopup())
1951 return; 1954 return;
1952 if (!layoutObject() || !layoutObject()->isMenuList()) 1955 if (!layoutObject() || !layoutObject()->isMenuList())
1953 return; 1956 return;
1957 if (elementRectRelativeToViewport().isEmpty())
1958 return;
1954 1959
1955 if (!m_popup) 1960 if (!m_popup)
1956 m_popup = document().frameHost()->chromeClient().openPopupMenu(*document ().frame(), *this); 1961 m_popup = document().frameHost()->chromeClient().openPopupMenu(*document ().frame(), *this);
1957 m_popupIsVisible = true; 1962 m_popupIsVisible = true;
1958 1963
1959 LayoutMenuList* menuList = toLayoutMenuList(layoutObject()); 1964 LayoutMenuList* menuList = toLayoutMenuList(layoutObject());
1960 m_popup->show(); 1965 m_popup->show();
1961 if (AXObjectCache* cache = document().existingAXObjectCache()) 1966 if (AXObjectCache* cache = document().existingAXObjectCache())
1962 cache->didShowMenuListPopup(menuList); 1967 cache->didShowMenuListPopup(menuList);
1963 } 1968 }
(...skipping 19 matching lines...) Expand all
1983 m_popupIsVisible = false; 1988 m_popupIsVisible = false;
1984 m_popup = nullptr; 1989 m_popup = nullptr;
1985 } 1990 }
1986 1991
1987 void HTMLSelectElement::resetTypeAheadSessionForTesting() 1992 void HTMLSelectElement::resetTypeAheadSessionForTesting()
1988 { 1993 {
1989 m_typeAhead.resetSession(); 1994 m_typeAhead.resetSession();
1990 } 1995 }
1991 1996
1992 } // namespace blink 1997 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698