Bug 563878. Part 5. Rename nsIFrame::GetWindow(Offset) to GetNearestWidget. r=mats

This commit is contained in:
Timothy Nikkel 2010-07-02 14:11:04 -05:00
Родитель 7fefda8964
Коммит 1259443af7
21 изменённых файлов: 58 добавлений и 56 удалений

Просмотреть файл

@ -330,7 +330,7 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
}
nsPoint offset;
*aOutWidget = frame->GetWindowOffset(offset);
*aOutWidget = frame->GetNearestWidget(offset);
NS_ENSURE_TRUE(*aOutWidget, nsIntRect());
rect.MoveBy(offset);

Просмотреть файл

@ -167,7 +167,7 @@ nsCoreUtils::DispatchMouseEvent(PRUint32 aEventType,
if (!rootFrame)
return PR_FALSE;
nsCOMPtr<nsIWidget> rootWidget = rootFrame->GetWindow();
nsCOMPtr<nsIWidget> rootWidget = rootFrame->GetNearestWidget();
if (!rootWidget)
return PR_FALSE;

Просмотреть файл

@ -231,7 +231,7 @@ __try {
// not an extra parent window for just the scrollbars
nsIScrollableFrame *scrollFrame = do_QueryFrame(frame);
if (scrollFrame) {
hwnd = (HWND)scrollFrame->GetScrolledFrame()->GetWindow()->GetNativeData(NS_NATIVE_WINDOW);
hwnd = (HWND)scrollFrame->GetScrolledFrame()->GetNearestWidget()->GetNativeData(NS_NATIVE_WINDOW);
NS_ASSERTION(hwnd, "No window handle for window");
}
}
@ -1735,7 +1735,7 @@ nsAccessibleWrap::GetHWNDFor(nsAccessible *aAccessible)
nsIFrame *frame = aAccessible->GetFrame();
if (frame) {
nsIWidget *window = frame->GetWindow();
nsIWidget *window = frame->GetNearestWidget();
PRBool isVisible;
window->IsVisible(isVisible);
if (isVisible) {
@ -1753,7 +1753,7 @@ nsAccessibleWrap::GetHWNDFor(nsAccessible *aAccessible)
// JAWS doesn't echo the current option as it changes in a closed
// combo box, we need to use an ensure that we never fire an event with
// an HWND for a hidden window.
hWnd = (HWND)frame->GetWindow()->GetNativeData(NS_NATIVE_WINDOW);
hWnd = (HWND)frame->GetNearestWidget()->GetNativeData(NS_NATIVE_WINDOW);
}
}

Просмотреть файл

@ -6143,7 +6143,7 @@ nsContentUtils::LayerManagerForDocument(nsIDocument *aDoc)
nsIFrame* rootFrame = shell->FrameManager()->GetRootFrame();
if (rootFrame) {
nsIWidget* widget =
nsLayoutUtils::GetDisplayRootFrame(rootFrame)->GetWindow();
nsLayoutUtils::GetDisplayRootFrame(rootFrame)->GetNearestWidget();
if (widget) {
nsRefPtr<mozilla::layers::LayerManager> manager = widget->GetLayerManager();
return manager.forget();

Просмотреть файл

@ -142,7 +142,7 @@ nsContentEventHandler::Init(nsQueryContentEvent* aEvent)
nsIFrame* frame = caret->GetGeometry(mSelection, &r);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
aEvent->mReply.mFocusedWidget = frame->GetWindow();
aEvent->mReply.mFocusedWidget = frame->GetNearestWidget();
return NS_OK;
}
@ -762,7 +762,7 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent)
nsIFrame* rootFrame = mPresShell->GetRootFrame();
NS_ENSURE_TRUE(rootFrame, NS_ERROR_FAILURE);
nsIWidget* rootWidget = rootFrame->GetWindow();
nsIWidget* rootWidget = rootFrame->GetNearestWidget();
NS_ENSURE_TRUE(rootWidget, NS_ERROR_FAILURE);
// The root frame's widget might be different, e.g., the event was fired on
@ -773,7 +773,7 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent)
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
rootFrame = nsLayoutUtils::GetFrameFor(view);
NS_ENSURE_TRUE(rootFrame, NS_ERROR_FAILURE);
rootWidget = rootFrame->GetWindow();
rootWidget = rootFrame->GetNearestWidget();
NS_ENSURE_TRUE(rootWidget, NS_ERROR_FAILURE);
}

Просмотреть файл

@ -707,7 +707,7 @@ nsMouseWheelTransaction::OverrideSystemScrollSpeed(PRInt32 aScrollLines,
// conditions (e.g., checking the prefs, and also whether the user customized
// the system settings of the mouse wheel scrolling or not), and can limit
// the speed for preventing the unexpected high speed scrolling.
nsCOMPtr<nsIWidget> widget(sTargetFrame->GetWindow());
nsCOMPtr<nsIWidget> widget(sTargetFrame->GetNearestWidget());
NS_ENSURE_TRUE(widget, aScrollLines);
PRInt32 overriddenDelta;
nsresult rv = widget->OverrideSystemMouseScrollSpeed(aScrollLines,
@ -1760,7 +1760,7 @@ nsEventStateManager::FireContextClick()
if (allowedToDispatch) {
// make sure the widget sticks around
nsCOMPtr<nsIWidget> targetWidget(mCurrentTarget->GetWindow());
nsCOMPtr<nsIWidget> targetWidget(mCurrentTarget->GetNearestWidget());
// init the event while mCurrentTarget is still good
nsMouseEvent event(PR_TRUE, NS_CONTEXTMENU,
targetWidget,
@ -1859,7 +1859,7 @@ nsEventStateManager::StopTrackingDragGesture()
void
nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent)
{
NS_ASSERTION(aEvent->widget == mCurrentTarget->GetWindow(),
NS_ASSERTION(aEvent->widget == mCurrentTarget->GetNearestWidget(),
"Incorrect widget in event");
// Set the coordinates in the new event to the coordinates of
@ -1953,7 +1953,7 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
if (!targetContent)
return;
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetWindow();
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
// get the widget from the target frame
nsDragEvent startEvent(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_START, widget);
@ -3094,7 +3094,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
mCurrentTarget->GetContentForEvent(presContext, aEvent,
getter_AddRefs(targetContent));
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetWindow();
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
nsDragEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_DRAGDROP, widget);
nsMouseEvent* mouseEvent = static_cast<nsMouseEvent*>(aEvent);
@ -3246,7 +3246,7 @@ nsEventStateManager::UpdateCursor(nsPresContext* aPresContext,
if (aTargetFrame) {
SetCursor(cursor, container, haveHotspot, hotspotX, hotspotY,
aTargetFrame->GetWindow(), PR_FALSE);
aTargetFrame->GetNearestWidget(), PR_FALSE);
}
if (mLockCursor || NS_STYLE_CURSOR_AUTO != cursor) {
@ -3635,7 +3635,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent)
if (mLastMouseOverFrame &&
nsContentUtils::GetTopLevelWidget(aEvent->widget) !=
nsContentUtils::GetTopLevelWidget(mLastMouseOverFrame->GetWindow())) {
nsContentUtils::GetTopLevelWidget(mLastMouseOverFrame->GetNearestWidget())) {
// the MouseOut event widget doesn't have same top widget with
// mLastMouseOverFrame, it's a spurious event for mLastMouseOverFrame
break;

Просмотреть файл

@ -324,7 +324,7 @@ protected:
* Set the fields of aEvent to reflect the mouse position and modifier keys
* that were set when the user first pressed the mouse button (stored by
* BeginTrackingDragGesture). aEvent->widget must be
* mCurrentTarget->GetWindow().
* mCurrentTarget->GetNearestWidget().
*/
void FillInEventFromGestureDown(nsMouseEvent* aEvent);

Просмотреть файл

@ -486,7 +486,7 @@ nsDOMWindowUtils::GetWidgetForElement(nsIDOMElement* aElement)
frame = presShell->GetRootFrame();
}
if (frame)
return frame->GetWindow();
return frame->GetNearestWidget();
}
return nsnull;
@ -1098,7 +1098,7 @@ nsDOMWindowUtils::SendQueryContentEvent(PRUint32 aType,
// Fire the event on the widget at the point
if (popupFrame) {
targetWidget = popupFrame->GetWindow();
targetWidget = popupFrame->GetNearestWidget();
}
}

Просмотреть файл

@ -2106,12 +2106,12 @@ nsFocusManager::GetSelectionLocation(nsIDocument* aDocument,
nsRect caretRect;
nsIFrame *frame = caret->GetGeometry(domSelection, &caretRect);
if (frame) {
nsPoint caretWindowOffset;
nsIWidget *window = frame->GetWindowOffset(caretWindowOffset);
caretRect.MoveBy(caretWindowOffset);
nsPoint caretWidgetOffset;
nsIWidget *widget = frame->GetNearestWidget(caretWidgetOffset);
caretRect.MoveBy(caretWidgetOffset);
nsPoint newCaretOffset;
nsIWidget *newCaretWindow = newCaretFrame->GetWindowOffset(newCaretOffset);
if (window == newCaretWindow && caretRect.y == newCaretOffset.y &&
nsIWidget *newCaretWidget = newCaretFrame->GetNearestWidget(newCaretOffset);
if (widget == newCaretWidget && caretRect.y == newCaretOffset.y &&
caretRect.x == newCaretOffset.x) {
// The caret is at the start of the new element.
startFrame = newCaretFrame;

Просмотреть файл

@ -1943,7 +1943,7 @@ GetEditorContentWindow(nsIDOMElement *aRoot, nsIWidget **aResult)
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
*aResult = frame->GetWindow();
*aResult = frame->GetNearestWidget();
NS_ENSURE_TRUE(*aResult, NS_ERROR_FAILURE);
NS_ADDREF(*aResult);

Просмотреть файл

@ -431,7 +431,7 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
nsIFrame* referenceFrame = aBuilder->ReferenceFrame();
NS_ASSERTION(referenceFrame == nsLayoutUtils::GetDisplayRootFrame(referenceFrame),
"Reference frame must be a display root for us to use the layer manager");
nsIWidget* window = referenceFrame->GetWindow();
nsIWidget* window = referenceFrame->GetNearestWidget();
if (window) {
layerManager = window->GetLayerManager();
}

Просмотреть файл

@ -1250,7 +1250,7 @@ nsLayoutUtils::PaintFrame(nsIRenderingContext* aRenderingContext, nsIFrame* aFra
PRUint32 flags = nsDisplayList::PAINT_DEFAULT;
if (aFlags & PAINT_WIDGET_LAYERS) {
flags |= nsDisplayList::PAINT_USE_WIDGET_LAYERS;
nsIWidget *widget = aFrame->GetWindow();
nsIWidget *widget = aFrame->GetNearestWidget();
PRInt32 pixelRatio = widget->GetDeviceContext()->AppUnitsPerDevPixel();
nsIntRegion visibleWindowRegion(visibleRegion.ToOutsidePixels(pixelRatio));
nsIntRegion dirtyWindowRegion(aDirtyRegion.ToOutsidePixels(pixelRatio));

Просмотреть файл

@ -2258,7 +2258,7 @@ nsPresContext::HavePendingInputEvent()
case ModeEvent: {
nsIFrame* f = PresShell()->GetRootFrame();
if (f) {
nsIWidget* w = f->GetWindow();
nsIWidget* w = f->GetNearestWidget();
if (w) {
return w->HasPendingInputEvent();
}
@ -2501,7 +2501,7 @@ nsRootPresContext::UpdatePluginGeometry(nsIFrame* aChangedSubtree)
GetPluginGeometryUpdates(aChangedSubtree, &configurations);
if (configurations.IsEmpty())
return;
nsIWidget* widget = FrameManager()->GetRootFrame()->GetWindow();
nsIWidget* widget = FrameManager()->GetRootFrame()->GetNearestWidget();
NS_ASSERTION(widget, "Plugins must have a parent window");
widget->ConfigureChildren(configurations);
DidApplyPluginGeometryUpdates();

Просмотреть файл

@ -6739,7 +6739,7 @@ PresShell::AdjustContextMenuKeyEvent(nsMouseEvent* aEvent)
if (!itemFrame)
itemFrame = popupFrame;
nsCOMPtr<nsIWidget> widget = popupFrame->GetWindow();
nsCOMPtr<nsIWidget> widget = popupFrame->GetNearestWidget();
aEvent->widget = widget;
nsIntPoint widgetPoint = widget->WidgetToScreenOffset();
aEvent->refPoint = itemFrame->GetScreenRect().BottomLeft() - widgetPoint;
@ -6893,11 +6893,11 @@ PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTarge
nsIFrame* caretFrame = caret->GetGeometry(domSelection, &caretCoords);
if (!caretFrame)
return PR_FALSE;
nsPoint windowOffset;
nsIWidget* widget = caretFrame->GetWindowOffset(windowOffset);
nsPoint widgetOffset;
nsIWidget* widget = caretFrame->GetNearestWidget(widgetOffset);
if (!widget)
return PR_FALSE;
caretCoords.MoveBy(windowOffset);
caretCoords.MoveBy(widgetOffset);
nsIView* caretView = nsIView::GetViewFor(widget);
// in case the view used for caret coordinates was something else, we need

Просмотреть файл

@ -228,7 +228,7 @@ nsresult nsTextControlFrame::MaybeBeginSecureKeyboardInput()
{
nsresult rv = NS_OK;
if (IsPasswordTextControl() && !mInSecureKeyboardInputMode) {
nsIWidget* window = GetWindow();
nsIWidget* window = GetNearestWidget();
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
rv = window->BeginSecureKeyboardInput();
mInSecureKeyboardInputMode = NS_SUCCEEDED(rv);
@ -239,7 +239,7 @@ nsresult nsTextControlFrame::MaybeBeginSecureKeyboardInput()
void nsTextControlFrame::MaybeEndSecureKeyboardInput()
{
if (mInSecureKeyboardInputMode) {
nsIWidget* window = GetWindow();
nsIWidget* window = GetNearestWidget();
if (!window)
return;
window->EndSecureKeyboardInput();

Просмотреть файл

@ -3644,13 +3644,13 @@ nsIFrame::AreAncestorViewsVisible() const
}
nsIWidget*
nsIFrame::GetWindow() const
nsIFrame::GetNearestWidget() const
{
return GetClosestView()->GetNearestWidget(nsnull);
}
nsIWidget*
nsIFrame::GetWindowOffset(nsPoint& aOffset) const
nsIFrame::GetNearestWidget(nsPoint& aOffset) const
{
nsPoint offsetToView;
nsPoint offsetToWidget;

Просмотреть файл

@ -1661,7 +1661,8 @@ void nsGfxScrollFrameInner::ScrollVisual(nsIntPoint aPixDelta)
// Only update plugin configurations if we're going to scroll the
// root widget. Otherwise we must be in a popup or some other situation
// where we don't actually support windows plugins.
if (rootPresContext->FrameManager()->GetRootFrame()->GetWindow() == nearestWidget) {
if (rootPresContext->FrameManager()->GetRootFrame()->GetNearestWidget() ==
nearestWidget) {
rootPresContext->GetPluginGeometryUpdates(mOuter, &configurations);
}
@ -1743,7 +1744,7 @@ void nsGfxScrollFrameInner::ScrollVisual(nsIntPoint aPixDelta)
}
nsIFrame* presContextRootFrame = presContext->FrameManager()->GetRootFrame();
if (nearestWidget == presContextRootFrame->GetWindow()) {
if (nearestWidget == presContextRootFrame->GetNearestWidget()) {
nsPoint offsetToPresContext = mOuter->GetOffsetTo(presContextRootFrame);
blitRectsRegion.MoveBy(-nearestWidgetOffset + offsetToPresContext);
repaintRegion.MoveBy(-offsetToDisplayRoot + offsetToPresContext);

Просмотреть файл

@ -1689,19 +1689,20 @@ public:
virtual PRBool AreAncestorViewsVisible() const;
/**
* Returns the window that contains this frame. If this frame has a
* view and the view has a window, then this frames window is
* Returns the nearest widget containing this frame. If this frame has a
* view and the view has a widget, then this frame's widget is
* returned, otherwise this frame's geometric parent is checked
* recursively upwards.
* XXX virtual because gfx callers use it! (themes)
*/
virtual nsIWidget* GetWindow() const;
virtual nsIWidget* GetNearestWidget() const;
/**
* Same as GetWindow() with an offset out param.
* @param the offset of this frame in widget coordinates
* Same as GetNearestWidget() above but uses an outparam to return the offset
* of this frame to the returned widget expressed in appunits of |this| (the
* widget might be in a different document with a different zoom).
*/
virtual nsIWidget* GetWindowOffset(nsPoint& aOffset) const;
virtual nsIWidget* GetNearestWidget(nsPoint& aOffset) const;
/**
* Get the "type" of the frame. May return a NULL atom pointer

Просмотреть файл

@ -734,7 +734,7 @@ nsObjectFrame::CreateWidget(nscoord aWidth,
// XXX this breaks plugins in popups ... do we care?
nsIWidget* parentWidget =
rpc->PresShell()->FrameManager()->GetRootFrame()->GetWindow();
rpc->PresShell()->FrameManager()->GetRootFrame()->GetNearestWidget();
nsWidgetInitData initData;
initData.mWindowType = eWindowType_plugin;
@ -756,7 +756,7 @@ nsObjectFrame::CreateWidget(nscoord aWidth,
// displayed, so don't show the widget. If we show the widget, the
// plugin may appear in the main window. In Web content this would
// only happen with a plugin in a XUL popup.
if (parentWidget == GetWindow()) {
if (parentWidget == GetNearestWidget()) {
mWidget->Show(PR_TRUE);
#ifdef XP_MACOSX
// On Mac, we need to invalidate ourselves since even windowed
@ -2883,7 +2883,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value)
// fixing both the caret and ability to interact issues for a windowless control in a non document aligned windw
// does not seem to be possible without a change to the flash plugin
nsIWidget* win = mObjectFrame->GetWindow();
nsIWidget* win = mObjectFrame->GetNearestWidget();
if (win) {
nsIView *view = nsIView::GetViewFor(win);
NS_ASSERTION(view, "No view for widget");
@ -2911,7 +2911,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value)
return rv;
#elif defined(MOZ_WIDGET_GTK2)
// X11 window managers want the toplevel window for WM_TRANSIENT_FOR.
nsIWidget* win = mObjectFrame->GetWindow();
nsIWidget* win = mObjectFrame->GetNearestWidget();
if (!win)
return NS_ERROR_FAILURE;
GdkWindow* gdkWindow = static_cast<GdkWindow*>(win->GetNativeData(NS_NATIVE_WINDOW));
@ -2924,7 +2924,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value)
return NS_OK;
#elif defined(MOZ_WIDGET_QT)
// X11 window managers want the toplevel window for WM_TRANSIENT_FOR.
nsIWidget* win = mObjectFrame->GetWindow();
nsIWidget* win = mObjectFrame->GetNearestWidget();
if (!win)
return NS_ERROR_FAILURE;
QWidget* widget = static_cast<QWidget*>(win->GetNativeData(NS_NATIVE_WINDOW));
@ -5186,7 +5186,7 @@ static GdkWindow* GetClosestWindow(nsIDOMElement *element)
if (!frame)
return nsnull;
nsIWidget* win = frame->GetWindow();
nsIWidget* win = frame->GetNearestWidget();
if (!win)
return nsnull;
@ -5801,7 +5801,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
mPluginWindow->window = nsnull;
#ifdef MOZ_X11
// Fill in the display field.
nsIWidget* win = mObjectFrame->GetWindow();
nsIWidget* win = mObjectFrame->GetNearestWidget();
NPSetWindowCallbackStruct* ws_info =
static_cast<NPSetWindowCallbackStruct*>(mPluginWindow->ws_info);
if (win) {
@ -5902,7 +5902,7 @@ void* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
// We'll need the top-level Cocoa window for the Cocoa event model.
void* cocoaTopLevelWindow = nsnull;
if (eventModel == NPEventModelCocoa) {
nsIWidget* widget = mObjectFrame->GetWindow();
nsIWidget* widget = mObjectFrame->GetNearestWidget();
if (!widget)
return nsnull;
cocoaTopLevelWindow = widget->GetNativeData(NS_NATIVE_WINDOW);

Просмотреть файл

@ -164,7 +164,7 @@ static NSWindow* NativeWindowForFrame(nsIFrame* aFrame,
if (!aFrame)
return nil;
nsIWidget* widget = aFrame->GetWindow();
nsIWidget* widget = aFrame->GetNearestWidget();
if (!widget)
return nil;

Просмотреть файл

@ -444,8 +444,8 @@ nsNativeTheme::IsSubmenu(nsIFrame* aFrame, PRBool* aLeftOfParent)
if (parent->GetContent() == parentContent) {
if (aLeftOfParent) {
nsIntRect selfBounds, parentBounds;
aFrame->GetWindow()->GetScreenBounds(selfBounds);
parent->GetWindow()->GetScreenBounds(parentBounds);
aFrame->GetNearestWidget()->GetScreenBounds(selfBounds);
parent->GetNearestWidget()->GetScreenBounds(parentBounds);
*aLeftOfParent = selfBounds.x < parentBounds.x;
}
return PR_TRUE;