Bug 807174 - Drop-down list used inside a frameset document renders outside the frame. r=roc
authorMats Palmgren <matspal@gmail.com>
Wed, 31 Oct 2012 06:10:38 +0100
changeset 112004 1858a5369d221c56389335d70a10242269356f87
parent 112003 883af38f81c5baff5d391176a18f595597904b96
child 112005 3781f04d144d29aba4a14813ea18ae2a82e96948
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersroc
bugs807174
milestone19.0a1
Bug 807174 - Drop-down list used inside a frameset document renders outside the frame. r=roc
layout/forms/nsComboboxControlFrame.cpp
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -639,21 +639,22 @@ nsComboboxControlFrame::GetAvailableDrop
   nsRect screen = nsFormControlFrame::GetUsableScreenRect(PresContext());
   if (mLastDropDownBelowScreenY == nscoord_MIN) {
     nsRect thisScreenRect = GetScreenRectInAppUnits();
     mLastDropDownBelowScreenY = thisScreenRect.YMost() + aTranslation->y;
     mLastDropDownAboveScreenY = thisScreenRect.y + aTranslation->y;
   }
 
   nscoord minY;
-  if (!PresContext()->IsChrome()) {
-    nsIFrame* root = PresContext()->PresShell()->GetRootFrame();
+  nsPresContext* pc = PresContext()->GetToplevelContentDocumentPresContext();
+  nsIFrame* root = pc ? pc->PresShell()->GetRootFrame() : nullptr;
+  if (root) {
     minY = root->GetScreenRectInAppUnits().y;
-    if (mLastDropDownBelowScreenY < root->GetScreenRectInAppUnits().y) {
-      // Don't allow the drop-down to be placed above the top of the root frame.
+    if (mLastDropDownBelowScreenY < minY) {
+      // Don't allow the drop-down to be placed above the content area.
       return;
     }
   } else {
     minY = screen.y;
   }
 
   nscoord below = screen.YMost() - mLastDropDownBelowScreenY;
   nscoord above = mLastDropDownAboveScreenY - minY;