michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsResizerFrame.h" michael@0: #include "nsIContent.h" michael@0: #include "nsIDocument.h" michael@0: #include "nsIDOMNodeList.h" michael@0: #include "nsGkAtoms.h" michael@0: #include "nsNameSpaceManager.h" michael@0: #include "nsIDOMElementCSSInlineStyle.h" michael@0: #include "nsIDOMCSSStyleDeclaration.h" michael@0: michael@0: #include "nsPresContext.h" michael@0: #include "nsFrameManager.h" michael@0: #include "nsIDocShell.h" michael@0: #include "nsIDocShellTreeOwner.h" michael@0: #include "nsIBaseWindow.h" michael@0: #include "nsPIDOMWindow.h" michael@0: #include "mozilla/MouseEvents.h" michael@0: #include "nsContentUtils.h" michael@0: #include "nsMenuPopupFrame.h" michael@0: #include "nsIScreenManager.h" michael@0: #include "mozilla/dom/Element.h" michael@0: #include "nsError.h" michael@0: #include michael@0: michael@0: using namespace mozilla; michael@0: michael@0: // michael@0: // NS_NewResizerFrame michael@0: // michael@0: // Creates a new Resizer frame and returns it michael@0: // michael@0: nsIFrame* michael@0: NS_NewResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) michael@0: { michael@0: return new (aPresShell) nsResizerFrame(aPresShell, aContext); michael@0: } michael@0: michael@0: NS_IMPL_FRAMEARENA_HELPERS(nsResizerFrame) michael@0: michael@0: nsResizerFrame::nsResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) michael@0: :nsTitleBarFrame(aPresShell, aContext) michael@0: { michael@0: } michael@0: michael@0: nsresult michael@0: nsResizerFrame::HandleEvent(nsPresContext* aPresContext, michael@0: WidgetGUIEvent* aEvent, michael@0: nsEventStatus* aEventStatus) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aEventStatus); michael@0: if (nsEventStatus_eConsumeNoDefault == *aEventStatus) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsWeakFrame weakFrame(this); michael@0: bool doDefault = true; michael@0: michael@0: switch (aEvent->message) { michael@0: case NS_TOUCH_START: michael@0: case NS_MOUSE_BUTTON_DOWN: { michael@0: if (aEvent->eventStructType == NS_TOUCH_EVENT || michael@0: (aEvent->eventStructType == NS_MOUSE_EVENT && michael@0: aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton)) { michael@0: nsCOMPtr window; michael@0: nsIPresShell* presShell = aPresContext->GetPresShell(); michael@0: nsIContent* contentToResize = michael@0: GetContentToResize(presShell, getter_AddRefs(window)); michael@0: if (contentToResize) { michael@0: nsIFrame* frameToResize = contentToResize->GetPrimaryFrame(); michael@0: if (!frameToResize) michael@0: break; michael@0: michael@0: // cache the content rectangle for the frame to resize michael@0: // GetScreenRectInAppUnits returns the border box rectangle, so michael@0: // adjust to get the desired content rectangle. michael@0: nsRect rect = frameToResize->GetScreenRectInAppUnits(); michael@0: switch (frameToResize->StylePosition()->mBoxSizing) { michael@0: case NS_STYLE_BOX_SIZING_CONTENT: michael@0: rect.Deflate(frameToResize->GetUsedPadding()); michael@0: case NS_STYLE_BOX_SIZING_PADDING: michael@0: rect.Deflate(frameToResize->GetUsedBorder()); michael@0: default: michael@0: break; michael@0: } michael@0: michael@0: mMouseDownRect = rect.ToNearestPixels(aPresContext->AppUnitsPerDevPixel()); michael@0: doDefault = false; michael@0: } michael@0: else { michael@0: // If there is no window, then resizing isn't allowed. michael@0: if (!window) michael@0: break; michael@0: michael@0: doDefault = false; michael@0: michael@0: // ask the widget implementation to begin a resize drag if it can michael@0: Direction direction = GetDirection(); michael@0: nsresult rv = aEvent->widget->BeginResizeDrag(aEvent, michael@0: direction.mHorizontal, direction.mVertical); michael@0: // for native drags, don't set the fields below michael@0: if (rv != NS_ERROR_NOT_IMPLEMENTED) michael@0: break; michael@0: michael@0: // if there's no native resize support, we need to do window michael@0: // resizing ourselves michael@0: window->GetPositionAndSize(&mMouseDownRect.x, &mMouseDownRect.y, michael@0: &mMouseDownRect.width, &mMouseDownRect.height); michael@0: } michael@0: michael@0: // remember current mouse coordinates michael@0: nsIntPoint refPoint; michael@0: if (!GetEventPoint(aEvent, refPoint)) michael@0: return NS_OK; michael@0: mMouseDownPoint = refPoint + aEvent->widget->WidgetToScreenOffset(); michael@0: michael@0: // we're tracking michael@0: mTrackingMouseMove = true; michael@0: michael@0: nsIPresShell::SetCapturingContent(GetContent(), CAPTURE_IGNOREALLOWED); michael@0: } michael@0: } michael@0: break; michael@0: michael@0: case NS_TOUCH_END: michael@0: case NS_MOUSE_BUTTON_UP: { michael@0: if (aEvent->eventStructType == NS_TOUCH_EVENT || michael@0: (aEvent->eventStructType == NS_MOUSE_EVENT && michael@0: aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton)) { michael@0: // we're done tracking. michael@0: mTrackingMouseMove = false; michael@0: michael@0: nsIPresShell::SetCapturingContent(nullptr, 0); michael@0: michael@0: doDefault = false; michael@0: } michael@0: } michael@0: break; michael@0: michael@0: case NS_TOUCH_MOVE: michael@0: case NS_MOUSE_MOVE: { michael@0: if (mTrackingMouseMove) michael@0: { michael@0: nsCOMPtr window; michael@0: nsIPresShell* presShell = aPresContext->GetPresShell(); michael@0: nsCOMPtr contentToResize = michael@0: GetContentToResize(presShell, getter_AddRefs(window)); michael@0: michael@0: // check if the returned content really is a menupopup michael@0: nsMenuPopupFrame* menuPopupFrame = nullptr; michael@0: if (contentToResize) { michael@0: menuPopupFrame = do_QueryFrame(contentToResize->GetPrimaryFrame()); michael@0: } michael@0: michael@0: // both MouseMove and direction are negative when pointing to the michael@0: // top and left, and positive when pointing to the bottom and right michael@0: michael@0: // retrieve the offset of the mousemove event relative to the mousedown. michael@0: // The difference is how much the resize needs to be michael@0: nsIntPoint refPoint; michael@0: if (!GetEventPoint(aEvent, refPoint)) michael@0: return NS_OK; michael@0: nsIntPoint screenPoint(refPoint + aEvent->widget->WidgetToScreenOffset()); michael@0: nsIntPoint mouseMove(screenPoint - mMouseDownPoint); michael@0: michael@0: // Determine which direction to resize by checking the dir attribute. michael@0: // For windows and menus, ensure that it can be resized in that direction. michael@0: Direction direction = GetDirection(); michael@0: if (window || menuPopupFrame) { michael@0: if (menuPopupFrame) { michael@0: menuPopupFrame->CanAdjustEdges( michael@0: (direction.mHorizontal == -1) ? NS_SIDE_LEFT : NS_SIDE_RIGHT, michael@0: (direction.mVertical == -1) ? NS_SIDE_TOP : NS_SIDE_BOTTOM, mouseMove); michael@0: } michael@0: } michael@0: else if (!contentToResize) { michael@0: break; // don't do anything if there's nothing to resize michael@0: } michael@0: michael@0: nsIntRect rect = mMouseDownRect; michael@0: michael@0: // Check if there are any size constraints on this window. michael@0: widget::SizeConstraints sizeConstraints; michael@0: if (window) { michael@0: nsCOMPtr widget; michael@0: window->GetMainWidget(getter_AddRefs(widget)); michael@0: sizeConstraints = widget->GetSizeConstraints(); michael@0: } michael@0: michael@0: AdjustDimensions(&rect.x, &rect.width, sizeConstraints.mMinSize.width, michael@0: sizeConstraints.mMaxSize.width, mouseMove.x, direction.mHorizontal); michael@0: AdjustDimensions(&rect.y, &rect.height, sizeConstraints.mMinSize.height, michael@0: sizeConstraints.mMaxSize.height, mouseMove.y, direction.mVertical); michael@0: michael@0: // Don't allow resizing a window or a popup past the edge of the screen, michael@0: // so adjust the rectangle to fit within the available screen area. michael@0: if (window) { michael@0: nsCOMPtr screen; michael@0: nsCOMPtr sm(do_GetService("@mozilla.org/gfx/screenmanager;1")); michael@0: if (sm) { michael@0: nsIntRect frameRect = GetScreenRect(); michael@0: // ScreenForRect requires display pixels, so scale from device pix michael@0: double scale; michael@0: window->GetUnscaledDevicePixelsPerCSSPixel(&scale); michael@0: sm->ScreenForRect(NSToIntRound(frameRect.x / scale), michael@0: NSToIntRound(frameRect.y / scale), 1, 1, michael@0: getter_AddRefs(screen)); michael@0: if (screen) { michael@0: nsIntRect screenRect; michael@0: screen->GetRect(&screenRect.x, &screenRect.y, michael@0: &screenRect.width, &screenRect.height); michael@0: rect.IntersectRect(rect, screenRect); michael@0: } michael@0: } michael@0: } michael@0: else if (menuPopupFrame) { michael@0: nsRect frameRect = menuPopupFrame->GetScreenRectInAppUnits(); michael@0: nsIFrame* rootFrame = aPresContext->PresShell()->FrameManager()->GetRootFrame(); michael@0: nsRect rootScreenRect = rootFrame->GetScreenRectInAppUnits(); michael@0: michael@0: nsPopupLevel popupLevel = menuPopupFrame->PopupLevel(); michael@0: nsRect screenRect = menuPopupFrame->GetConstraintRect(frameRect, rootScreenRect, popupLevel); michael@0: // round using ToInsidePixels as it's better to be a pixel too small michael@0: // than be too large. If the popup is too large it could get flipped michael@0: // to the opposite side of the anchor point while resizing. michael@0: nsIntRect screenRectPixels = screenRect.ToInsidePixels(aPresContext->AppUnitsPerDevPixel()); michael@0: rect.IntersectRect(rect, screenRectPixels); michael@0: } michael@0: michael@0: if (contentToResize) { michael@0: // convert the rectangle into css pixels. When changing the size in a michael@0: // direction, don't allow the new size to be less that the resizer's michael@0: // size. This ensures that content isn't resized too small as to make michael@0: // the resizer invisible. michael@0: nsRect appUnitsRect = rect.ToAppUnits(aPresContext->AppUnitsPerDevPixel()); michael@0: if (appUnitsRect.width < mRect.width && mouseMove.x) michael@0: appUnitsRect.width = mRect.width; michael@0: if (appUnitsRect.height < mRect.height && mouseMove.y) michael@0: appUnitsRect.height = mRect.height; michael@0: nsIntRect cssRect = appUnitsRect.ToInsidePixels(nsPresContext::AppUnitsPerCSSPixel()); michael@0: michael@0: nsIntRect oldRect; michael@0: nsWeakFrame weakFrame(menuPopupFrame); michael@0: if (menuPopupFrame) { michael@0: nsCOMPtr widget = menuPopupFrame->GetWidget(); michael@0: if (widget) michael@0: widget->GetScreenBounds(oldRect); michael@0: michael@0: // convert the new rectangle into outer window coordinates michael@0: nsIntPoint clientOffset = widget->GetClientOffset(); michael@0: rect.x -= clientOffset.x; michael@0: rect.y -= clientOffset.y; michael@0: } michael@0: michael@0: SizeInfo sizeInfo, originalSizeInfo; michael@0: sizeInfo.width.AppendInt(cssRect.width); michael@0: sizeInfo.height.AppendInt(cssRect.height); michael@0: ResizeContent(contentToResize, direction, sizeInfo, &originalSizeInfo); michael@0: MaybePersistOriginalSize(contentToResize, originalSizeInfo); michael@0: michael@0: // Move the popup to the new location unless it is anchored, since michael@0: // the position shouldn't change. nsMenuPopupFrame::SetPopupPosition michael@0: // will instead ensure that the popup's position is anchored at the michael@0: // right place. michael@0: if (weakFrame.IsAlive() && michael@0: (oldRect.x != rect.x || oldRect.y != rect.y) && michael@0: (!menuPopupFrame->IsAnchored() || michael@0: menuPopupFrame->PopupLevel() != ePopupLevelParent)) { michael@0: michael@0: rect.x = aPresContext->DevPixelsToIntCSSPixels(rect.x); michael@0: rect.y = aPresContext->DevPixelsToIntCSSPixels(rect.y); michael@0: menuPopupFrame->MoveTo(rect.x, rect.y, true); michael@0: } michael@0: } michael@0: else { michael@0: window->SetPositionAndSize(rect.x, rect.y, rect.width, rect.height, true); // do the repaint. michael@0: } michael@0: michael@0: doDefault = false; michael@0: } michael@0: } michael@0: break; michael@0: michael@0: case NS_MOUSE_CLICK: { michael@0: WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); michael@0: if (mouseEvent->IsLeftClickEvent()) { michael@0: MouseClicked(aPresContext, mouseEvent); michael@0: } michael@0: break; michael@0: } michael@0: case NS_MOUSE_DOUBLECLICK: michael@0: if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) { michael@0: nsCOMPtr window; michael@0: nsIPresShell* presShell = aPresContext->GetPresShell(); michael@0: nsIContent* contentToResize = michael@0: GetContentToResize(presShell, getter_AddRefs(window)); michael@0: if (contentToResize) { michael@0: nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(contentToResize->GetPrimaryFrame()); michael@0: if (menuPopupFrame) michael@0: break; // Don't restore original sizing for menupopup frames until michael@0: // we handle screen constraints here. (Bug 357725) michael@0: michael@0: RestoreOriginalSize(contentToResize); michael@0: } michael@0: } michael@0: break; michael@0: } michael@0: michael@0: if (!doDefault) michael@0: *aEventStatus = nsEventStatus_eConsumeNoDefault; michael@0: michael@0: if (doDefault && weakFrame.IsAlive()) michael@0: return nsTitleBarFrame::HandleEvent(aPresContext, aEvent, aEventStatus); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsIContent* michael@0: nsResizerFrame::GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWindow) michael@0: { michael@0: *aWindow = nullptr; michael@0: michael@0: nsAutoString elementid; michael@0: mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::element, elementid); michael@0: if (elementid.IsEmpty()) { michael@0: // If the resizer is in a popup, resize the popup's widget, otherwise michael@0: // resize the widget associated with the window. michael@0: nsIFrame* popup = GetParent(); michael@0: while (popup) { michael@0: nsMenuPopupFrame* popupFrame = do_QueryFrame(popup); michael@0: if (popupFrame) { michael@0: return popupFrame->GetContent(); michael@0: } michael@0: popup = popup->GetParent(); michael@0: } michael@0: michael@0: // don't allow resizing windows in content shells michael@0: nsCOMPtr dsti = aPresShell->GetPresContext()->GetDocShell(); michael@0: if (!dsti || dsti->ItemType() != nsIDocShellTreeItem::typeChrome) { michael@0: // don't allow resizers in content shells, except for the viewport michael@0: // scrollbar which doesn't have a parent michael@0: nsIContent* nonNativeAnon = mContent->FindFirstNonChromeOnlyAccessContent(); michael@0: if (!nonNativeAnon || nonNativeAnon->GetParent()) { michael@0: return nullptr; michael@0: } michael@0: } michael@0: michael@0: // get the document and the window - should this be cached? michael@0: nsPIDOMWindow *domWindow = aPresShell->GetDocument()->GetWindow(); michael@0: if (domWindow) { michael@0: nsCOMPtr docShell = domWindow->GetDocShell(); michael@0: if (docShell) { michael@0: nsCOMPtr treeOwner; michael@0: docShell->GetTreeOwner(getter_AddRefs(treeOwner)); michael@0: if (treeOwner) { michael@0: CallQueryInterface(treeOwner, aWindow); michael@0: } michael@0: } michael@0: } michael@0: michael@0: return nullptr; michael@0: } michael@0: michael@0: if (elementid.EqualsLiteral("_parent")) { michael@0: // return the parent, but skip over native anonymous content michael@0: nsIContent* parent = mContent->GetParent(); michael@0: return parent ? parent->FindFirstNonChromeOnlyAccessContent() : nullptr; michael@0: } michael@0: michael@0: return aPresShell->GetDocument()->GetElementById(elementid); michael@0: } michael@0: michael@0: void michael@0: nsResizerFrame::AdjustDimensions(int32_t* aPos, int32_t* aSize, michael@0: int32_t aMinSize, int32_t aMaxSize, michael@0: int32_t aMovement, int8_t aResizerDirection) michael@0: { michael@0: int32_t oldSize = *aSize; michael@0: michael@0: *aSize += aResizerDirection * aMovement; michael@0: // use one as a minimum size or the element could disappear michael@0: if (*aSize < 1) michael@0: *aSize = 1; michael@0: michael@0: // Constrain the size within the minimum and maximum size. michael@0: *aSize = std::max(aMinSize, std::min(aMaxSize, *aSize)); michael@0: michael@0: // For left and top resizers, the window must be moved left by the same michael@0: // amount that the window was resized. michael@0: if (aResizerDirection == -1) michael@0: *aPos += oldSize - *aSize; michael@0: } michael@0: michael@0: /* static */ void michael@0: nsResizerFrame::ResizeContent(nsIContent* aContent, const Direction& aDirection, michael@0: const SizeInfo& aSizeInfo, SizeInfo* aOriginalSizeInfo) michael@0: { michael@0: // for XUL elements, just set the width and height attributes. For michael@0: // other elements, set style.width and style.height michael@0: if (aContent->IsXUL()) { michael@0: if (aOriginalSizeInfo) { michael@0: aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::width, michael@0: aOriginalSizeInfo->width); michael@0: aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::height, michael@0: aOriginalSizeInfo->height); michael@0: } michael@0: // only set the property if the element could have changed in that direction michael@0: if (aDirection.mHorizontal) { michael@0: aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::width, aSizeInfo.width, true); michael@0: } michael@0: if (aDirection.mVertical) { michael@0: aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::height, aSizeInfo.height, true); michael@0: } michael@0: } michael@0: else { michael@0: nsCOMPtr inlineStyleContent = michael@0: do_QueryInterface(aContent); michael@0: if (inlineStyleContent) { michael@0: nsCOMPtr decl; michael@0: inlineStyleContent->GetStyle(getter_AddRefs(decl)); michael@0: michael@0: if (aOriginalSizeInfo) { michael@0: decl->GetPropertyValue(NS_LITERAL_STRING("width"), michael@0: aOriginalSizeInfo->width); michael@0: decl->GetPropertyValue(NS_LITERAL_STRING("height"), michael@0: aOriginalSizeInfo->height); michael@0: } michael@0: michael@0: // only set the property if the element could have changed in that direction michael@0: if (aDirection.mHorizontal) { michael@0: nsAutoString widthstr(aSizeInfo.width); michael@0: if (!widthstr.IsEmpty() && michael@0: !Substring(widthstr, widthstr.Length() - 2, 2).EqualsLiteral("px")) michael@0: widthstr.AppendLiteral("px"); michael@0: decl->SetProperty(NS_LITERAL_STRING("width"), widthstr, EmptyString()); michael@0: } michael@0: if (aDirection.mVertical) { michael@0: nsAutoString heightstr(aSizeInfo.height); michael@0: if (!heightstr.IsEmpty() && michael@0: !Substring(heightstr, heightstr.Length() - 2, 2).EqualsLiteral("px")) michael@0: heightstr.AppendLiteral("px"); michael@0: decl->SetProperty(NS_LITERAL_STRING("height"), heightstr, EmptyString()); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* static */ void michael@0: nsResizerFrame::MaybePersistOriginalSize(nsIContent* aContent, michael@0: const SizeInfo& aSizeInfo) michael@0: { michael@0: nsresult rv; michael@0: michael@0: aContent->GetProperty(nsGkAtoms::_moz_original_size, &rv); michael@0: if (rv != NS_PROPTABLE_PROP_NOT_THERE) michael@0: return; michael@0: michael@0: nsAutoPtr sizeInfo(new SizeInfo(aSizeInfo)); michael@0: rv = aContent->SetProperty(nsGkAtoms::_moz_original_size, sizeInfo.get(), michael@0: nsINode::DeleteProperty); michael@0: if (NS_SUCCEEDED(rv)) michael@0: sizeInfo.forget(); michael@0: } michael@0: michael@0: /* static */ void michael@0: nsResizerFrame::RestoreOriginalSize(nsIContent* aContent) michael@0: { michael@0: nsresult rv; michael@0: SizeInfo* sizeInfo = michael@0: static_cast(aContent->GetProperty(nsGkAtoms::_moz_original_size, michael@0: &rv)); michael@0: if (NS_FAILED(rv)) michael@0: return; michael@0: michael@0: NS_ASSERTION(sizeInfo, "We set a null sizeInfo!?"); michael@0: Direction direction = {1, 1}; michael@0: ResizeContent(aContent, direction, *sizeInfo, nullptr); michael@0: aContent->DeleteProperty(nsGkAtoms::_moz_original_size); michael@0: } michael@0: michael@0: /* returns a Direction struct containing the horizontal and vertical direction michael@0: */ michael@0: nsResizerFrame::Direction michael@0: nsResizerFrame::GetDirection() michael@0: { michael@0: static const nsIContent::AttrValuesArray strings[] = michael@0: {&nsGkAtoms::topleft, &nsGkAtoms::top, &nsGkAtoms::topright, michael@0: &nsGkAtoms::left, &nsGkAtoms::right, michael@0: &nsGkAtoms::bottomleft, &nsGkAtoms::bottom, &nsGkAtoms::bottomright, michael@0: &nsGkAtoms::bottomstart, &nsGkAtoms::bottomend, michael@0: nullptr}; michael@0: michael@0: static const Direction directions[] = michael@0: {{-1, -1}, {0, -1}, {1, -1}, michael@0: {-1, 0}, {1, 0}, michael@0: {-1, 1}, {0, 1}, {1, 1}, michael@0: {-1, 1}, {1, 1} michael@0: }; michael@0: michael@0: if (!GetContent()) michael@0: return directions[0]; // default: topleft michael@0: michael@0: int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, michael@0: nsGkAtoms::dir, michael@0: strings, eCaseMatters); michael@0: if(index < 0) michael@0: return directions[0]; // default: topleft michael@0: else if (index >= 8 && StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) { michael@0: // Directions 8 and higher are RTL-aware directions and should reverse the michael@0: // horizontal component if RTL. michael@0: Direction direction = directions[index]; michael@0: direction.mHorizontal *= -1; michael@0: return direction; michael@0: } michael@0: return directions[index]; michael@0: } michael@0: michael@0: void michael@0: nsResizerFrame::MouseClicked(nsPresContext* aPresContext, michael@0: WidgetMouseEvent* aEvent) michael@0: { michael@0: // Execute the oncommand event handler. michael@0: nsContentUtils::DispatchXULCommand(mContent, michael@0: aEvent && aEvent->mFlags.mIsTrusted); michael@0: }