本文整理汇总了C++中do_QueryFrame函数的典型用法代码示例。如果您正苦于以下问题:C++ do_QueryFrame函数的具体用法?C++ do_QueryFrame怎么用?C++ do_QueryFrame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_QueryFrame函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DOMRect
already_AddRefed<DOMRect>
PopupBoxObject::GetOuterScreenRect()
{
nsRefPtr<DOMRect> rect = new DOMRect(mContent);
// Return an empty rectangle if the popup is not open.
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(false));
if (!menuPopupFrame || !menuPopupFrame->IsOpen()) {
return rect.forget();
}
nsView* view = menuPopupFrame->GetView();
if (view) {
nsIWidget* widget = view->GetWidget();
if (widget) {
nsIntRect screenRect;
widget->GetScreenBounds(screenRect);
int32_t pp = menuPopupFrame->PresContext()->AppUnitsPerDevPixel();
rect->SetLayoutRect(ToAppUnits(screenRect, pp));
}
}
return rect.forget();
}
示例2: NS_WARNING
nsresult
nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
nsIFrame* aParent,
const gfxMatrix &aMatrix)
{
// If the flag is set when we get here, it means this clipPath frame
// has already been used painting the current clip, and the document
// has a clip reference loop.
if (mInUse) {
NS_WARNING("Clip loop detected!");
return NS_OK;
}
AutoClipPathReferencer clipRef(this);
mClipParent = aParent;
if (mClipParentMatrix) {
*mClipParentMatrix = aMatrix;
} else {
mClipParentMatrix = new gfxMatrix(aMatrix);
}
bool isTrivial = IsTrivial();
nsAutoSVGRenderMode mode(aContext,
isTrivial ? nsSVGRenderState::CLIP
: nsSVGRenderState::CLIP_MASK);
gfxContext *gfx = aContext->GetGfxContext();
nsSVGClipPathFrame *clipPathFrame =
nsSVGEffects::GetEffectProperties(this).GetClipPathFrame(nsnull);
bool referencedClipIsTrivial;
if (clipPathFrame) {
referencedClipIsTrivial = clipPathFrame->IsTrivial();
gfx->Save();
if (referencedClipIsTrivial) {
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
} else {
gfx->PushGroup(gfxASurface::CONTENT_ALPHA);
}
}
for (nsIFrame* kid = mFrames.FirstChild(); kid;
kid = kid->GetNextSibling()) {
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
if (SVGFrame) {
// The CTM of each frame referencing us can be different.
SVGFrame->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION |
nsISVGChildFrame::TRANSFORM_CHANGED);
bool isOK = true;
nsSVGClipPathFrame *clipPathFrame =
nsSVGEffects::GetEffectProperties(kid).GetClipPathFrame(&isOK);
if (!isOK) {
continue;
}
bool isTrivial;
if (clipPathFrame) {
isTrivial = clipPathFrame->IsTrivial();
gfx->Save();
if (isTrivial) {
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
} else {
gfx->PushGroup(gfxASurface::CONTENT_ALPHA);
}
}
SVGFrame->PaintSVG(aContext, nsnull);
if (clipPathFrame) {
if (!isTrivial) {
gfx->PopGroupToSource();
nsRefPtr<gfxPattern> clipMaskSurface;
gfx->PushGroup(gfxASurface::CONTENT_ALPHA);
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
clipMaskSurface = gfx->PopGroup();
if (clipMaskSurface) {
gfx->Mask(clipMaskSurface);
}
}
gfx->Restore();
}
}
}
if (clipPathFrame) {
if (!referencedClipIsTrivial) {
gfx->PopGroupToSource();
nsRefPtr<gfxPattern> clipMaskSurface;
gfx->PushGroup(gfxASurface::CONTENT_ALPHA);
clipPathFrame->ClipPaint(aContext, aParent, aMatrix);
clipMaskSurface = gfx->PopGroup();
//.........这里部分代码省略.........
示例3: do_QueryFrame
void
DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time)
{
Element* root = nullptr;
nsIFrame* rootFrame = nullptr;
nsRect rootRect;
if (mRoot) {
root = mRoot;
rootFrame = root->GetPrimaryFrame();
if (rootFrame) {
if (rootFrame->GetType() == nsGkAtoms::scrollFrame) {
nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame);
rootRect = nsLayoutUtils::TransformFrameRectToAncestor(
rootFrame,
rootFrame->GetContentRectRelativeToSelf(),
scrollFrame->GetScrolledFrame());
} else {
rootRect = nsLayoutUtils::GetAllInFlowRectsUnion(rootFrame,
nsLayoutUtils::GetContainingBlockForClientRect(rootFrame),
nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
}
}
} else {
nsCOMPtr<nsIPresShell> presShell = aDocument->GetShell();
if (presShell) {
rootFrame = presShell->GetRootScrollFrame();
if (rootFrame) {
nsPresContext* presContext = rootFrame->PresContext();
while (!presContext->IsRootContentDocument()) {
presContext = presContext->GetParentPresContext();
if (!presContext) {
break;
}
rootFrame = presContext->PresShell()->GetRootScrollFrame();
}
root = rootFrame->GetContent()->AsElement();
nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame);
rootRect = scrollFrame->GetScrollPortRect();
}
}
}
nsMargin rootMargin;
NS_FOR_CSS_SIDES(side) {
nscoord basis = side == eSideTop || side == eSideBottom ?
rootRect.height : rootRect.width;
nsCSSValue value = mRootMargin.*nsCSSRect::sides[side];
nsStyleCoord coord;
if (value.IsPixelLengthUnit()) {
coord.SetCoordValue(value.GetPixelLength());
} else if (value.IsPercentLengthUnit()) {
coord.SetPercentValue(value.GetPercentValue());
} else {
MOZ_ASSERT_UNREACHABLE("invalid length unit");
}
rootMargin.Side(side) = nsLayoutUtils::ComputeCBDependentValue(basis, coord);
}
for (auto iter = mObservationTargets.Iter(); !iter.Done(); iter.Next()) {
Element* target = iter.Get()->GetKey();
nsIFrame* targetFrame = target->GetPrimaryFrame();
nsRect targetRect;
Maybe<nsRect> intersectionRect;
if (rootFrame && targetFrame) {
// If mRoot is set we are testing intersection with a container element
// instead of the implicit root.
if (mRoot) {
// Skip further processing of this target if it is not in the same
// Document as the intersection root, e.g. if root is an element of
// the main document and target an element from an embedded iframe.
if (target->GetComposedDoc() != root->GetComposedDoc()) {
continue;
}
// Skip further processing of this target if is not a descendant of the
// intersection root in the containing block chain. E.g. this would be
// the case if the target is in a position:absolute element whose
// containing block is an ancestor of root.
if (!nsLayoutUtils::IsAncestorFrameCrossDoc(rootFrame, targetFrame)) {
continue;
}
}
targetRect = nsLayoutUtils::GetAllInFlowRectsUnion(
targetFrame,
nsLayoutUtils::GetContainingBlockForClientRect(targetFrame),
nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS
);
intersectionRect = Some(targetFrame->GetVisualOverflowRect());
nsIFrame* containerFrame = nsLayoutUtils::GetCrossDocParentFrame(targetFrame);
while (containerFrame && containerFrame != rootFrame) {
if (containerFrame->GetType() == nsGkAtoms::scrollFrame) {
nsIScrollableFrame* scrollFrame = do_QueryFrame(containerFrame);
nsRect subFrameRect = scrollFrame->GetScrollPortRect();
nsRect intersectionRectRelativeToContainer =
nsLayoutUtils::TransformFrameRectToAncestor(targetFrame,
intersectionRect.value(),
containerFrame);
//.........这里部分代码省略.........
示例4: nsHTMLComboboxTextFieldAccessible
void nsHTMLComboboxAccessible::CacheChildren()
{
if (!mWeakShell) {
// This node has been shut down
mAccChildCount = eChildCountUninitialized;
return;
}
if (mAccChildCount == eChildCountUninitialized) {
mAccChildCount = 0;
#ifdef COMBO_BOX_WITH_THREE_CHILDREN
// We no longer create textfield and button accessible, in order to have
// harmonization between IAccessible2, ATK/AT-SPI and OS X
nsHTMLComboboxTextFieldAccessible* textFieldAccessible =
new nsHTMLComboboxTextFieldAccessible(this, mDOMNode, mWeakShell);
SetFirstChild(textFieldAccessible);
if (!textFieldAccessible) {
return;
}
textFieldAccessible->SetParent(this);
textFieldAccessible->Init();
mAccChildCount = 1; // Textfield accessible child successfully added
nsHTMLComboboxButtonAccessible* buttonAccessible =
new nsHTMLComboboxButtonAccessible(mParent, mDOMNode, mWeakShell);
textFieldAccessible->SetNextSibling(buttonAccessible);
if (!buttonAccessible) {
return;
}
buttonAccessible->SetParent(this);
buttonAccessible->Init();
mAccChildCount = 2; // Button accessible child successfully added
#endif
nsIFrame *frame = GetFrame();
if (!frame) {
return;
}
nsIComboboxControlFrame *comboFrame = do_QueryFrame(frame);
if (!comboFrame) {
return;
}
nsIFrame *listFrame = comboFrame->GetDropDown();
if (!listFrame) {
return;
}
if (!mListAccessible) {
mListAccessible =
new nsHTMLComboboxListAccessible(mParent, mDOMNode, mWeakShell);
if (!mListAccessible)
return;
mListAccessible->Init();
}
#ifdef COMBO_BOX_WITH_THREE_CHILDREN
buttonAccessible->SetNextSibling(mListAccessible);
#else
SetFirstChild(mListAccessible);
#endif
mListAccessible->SetParent(this);
mListAccessible->SetNextSibling(nsnull);
++ mAccChildCount; // List accessible child successfully added
}
}
示例5: do_QueryFrame
nsINode*
PopupBoxObject::GetTriggerNode() const
{
nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
return nsMenuPopupFrame::GetTriggerContent(menuPopupFrame);
}
示例6: switch
void
APZEventState::ProcessAPZStateChange(const nsCOMPtr<nsIDocument>& aDocument,
ViewID aViewId,
APZStateChange aChange,
int aArg)
{
switch (aChange)
{
case APZStateChange::TransformBegin:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(true);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
scrollbarMediator->ScrollbarActivityStarted();
}
if (aDocument && mActiveAPZTransforms == 0) {
nsCOMPtr<nsIDocShell> docshell(aDocument->GetDocShell());
if (docshell && sf) {
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
nsdocshell->NotifyAsyncPanZoomStarted();
}
}
mActiveAPZTransforms++;
break;
}
case APZStateChange::TransformEnd:
{
mActiveAPZTransforms--;
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(false);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
scrollbarMediator->ScrollbarActivityStopped();
}
if (aDocument && mActiveAPZTransforms == 0) {
nsCOMPtr<nsIDocShell> docshell(aDocument->GetDocShell());
if (docshell && sf) {
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
nsdocshell->NotifyAsyncPanZoomStopped();
}
}
break;
}
case APZStateChange::StartTouch:
{
mActiveElementManager->HandleTouchStart(aArg);
break;
}
case APZStateChange::StartPanning:
{
mActiveElementManager->HandlePanStart();
break;
}
case APZStateChange::EndTouch:
{
mEndTouchIsClick = aArg;
mActiveElementManager->HandleTouchEnd();
break;
}
default:
// APZStateChange has a 'sentinel' value, and the compiler complains
// if an enumerator is not handled and there is no 'default' case.
break;
}
}
示例7: while
NS_IMETHODIMP
nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
{
// lay us out
nsresult rv = nsBoxFrame::DoLayout(aState);
// lay out all of our currently open popups.
nsPopupFrameList* currEntry = mPopupList;
while (currEntry) {
nsMenuPopupFrame* popupChild = currEntry->mPopupFrame;
if (popupChild && popupChild->IsOpen()) {
// then get its preferred size
nsSize prefSize = popupChild->GetPrefSize(aState);
nsSize minSize = popupChild->GetMinSize(aState);
nsSize maxSize = popupChild->GetMaxSize(aState);
prefSize = BoundsCheck(minSize, prefSize, maxSize);
popupChild->SetPreferredBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
popupChild->SetPopupPosition(nsnull);
// is the new size too small? Make sure we handle scrollbars correctly
nsIBox* child = popupChild->GetChildBox();
nsRect bounds(popupChild->GetRect());
nsIScrollableFrame *scrollframe = do_QueryFrame(child);
if (scrollframe &&
scrollframe->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) {
// if our pref height
if (bounds.height < prefSize.height) {
// layout the child
popupChild->Layout(aState);
nsMargin scrollbars = scrollframe->GetActualScrollbarSizes();
if (bounds.width < prefSize.width + scrollbars.left + scrollbars.right)
{
bounds.width += scrollbars.left + scrollbars.right;
popupChild->SetBounds(aState, bounds);
}
}
}
// layout the child
popupChild->Layout(aState);
// if the width or height changed, readjust the popup position. This is a
// special case for tooltips where the preferred height doesn't include the
// real height for its inline element, but does once it is laid out.
// This is bug 228673 which doesn't have a simple fix.
if (popupChild->GetRect().width > bounds.width ||
popupChild->GetRect().height > bounds.height) {
// the size after layout was larger than the preferred size,
// so set the preferred size accordingly
popupChild->SetPreferredSize(popupChild->GetSize());
popupChild->SetPopupPosition(nsnull);
}
popupChild->AdjustView();
}
currEntry = currEntry->mNextPopup;
}
return rv;
}
示例8: GetInsertionPoint
nsMenuFrame*
nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent)
{
uint32_t charCode;
aKeyEvent->GetCharCode(&charCode);
nsAutoTArray<uint32_t, 10> accessKeys;
nsEvent* nativeEvent = nsContentUtils::GetNativeEvent(aKeyEvent);
nsKeyEvent* nativeKeyEvent = static_cast<nsKeyEvent*>(nativeEvent);
if (nativeKeyEvent)
nsContentUtils::GetAccessKeyCandidates(nativeKeyEvent, accessKeys);
if (accessKeys.IsEmpty() && charCode)
accessKeys.AppendElement(charCode);
if (accessKeys.IsEmpty())
return nullptr; // no character was pressed so just return
// Enumerate over our list of frames.
nsIFrame* immediateParent = nullptr;
GetInsertionPoint(PresContext()->PresShell(), this, nullptr, &immediateParent);
if (!immediateParent)
immediateParent = this;
// Find a most preferred accesskey which should be returned.
nsIFrame* foundMenu = nullptr;
uint32_t foundIndex = accessKeys.NoIndex;
nsIFrame* currFrame = immediateParent->GetFirstPrincipalChild();
while (currFrame) {
nsIContent* current = currFrame->GetContent();
// See if it's a menu item.
if (nsXULPopupManager::IsValidMenuItem(PresContext(), current, false)) {
// Get the shortcut attribute.
nsAutoString shortcutKey;
current->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, shortcutKey);
if (!shortcutKey.IsEmpty()) {
ToLowerCase(shortcutKey);
const PRUnichar* start = shortcutKey.BeginReading();
const PRUnichar* end = shortcutKey.EndReading();
uint32_t ch = UTF16CharEnumerator::NextChar(&start, end);
uint32_t index = accessKeys.IndexOf(ch);
if (index != accessKeys.NoIndex &&
(foundIndex == accessKeys.NoIndex || index < foundIndex)) {
foundMenu = currFrame;
foundIndex = index;
}
}
}
currFrame = currFrame->GetNextSibling();
}
if (foundMenu) {
return do_QueryFrame(foundMenu);
}
// didn't find a matching menu item
#ifdef XP_WIN
// behavior on Windows - this item is on the menu bar, beep and deactivate the menu bar
if (mIsActive) {
nsCOMPtr<nsISound> soundInterface = do_CreateInstance("@mozilla.org/sound;1");
if (soundInterface)
soundInterface->Beep();
}
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
nsIFrame* popup = pm->GetTopPopup(ePopupTypeAny);
if (popup)
pm->HidePopup(popup->GetContent(), true, true, true);
}
SetCurrentMenuItem(nullptr);
SetActive(false);
#endif // #ifdef XP_WIN
return nullptr;
}
示例9: do_QueryFrame
nsSVGTextContainerFrame*
SVGTextContentElement::GetTextContainerFrame()
{
return do_QueryFrame(GetPrimaryFrame(Flush_Layout));
}
示例10: gfxRect
gfxRect
nsSVGMarkerFrame::GetMarkBBoxContribution(const gfxMatrix &aToBBoxUserspace,
PRUint32 aFlags,
nsSVGPathGeometryFrame *aMarkedFrame,
const nsSVGMark *aMark,
float aStrokeWidth)
{
// If the flag is set when we get here, it means this marker frame
// has already been used in calculating the current mark bbox, and
// the document has a marker reference loop.
if (mInUse)
return gfxRect();
AutoMarkerReferencer markerRef(this, aMarkedFrame);
nsSVGMarkerElement *content = static_cast<nsSVGMarkerElement*>(mContent);
const nsSVGViewBoxRect viewBox = content->GetViewBoxRect();
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
return gfxRect();
}
mStrokeWidth = aStrokeWidth;
mX = aMark->x;
mY = aMark->y;
mAutoAngle = aMark->angle;
gfxMatrix markerTM =
content->GetMarkerTransform(mStrokeWidth, mX, mY, mAutoAngle);
gfxMatrix viewBoxTM = content->GetViewBoxTransform();
gfxMatrix tm = viewBoxTM * markerTM * aToBBoxUserspace;
gfxRect bbox;
bool firstChild = true;
for (nsIFrame* kid = mFrames.FirstChild();
kid;
kid = kid->GetNextSibling()) {
nsISVGChildFrame* child = do_QueryFrame(kid);
if (child) {
// When we're being called to obtain the invalidation area, we need to
// pass down all the flags so that stroke is included. However, once DOM
// getBBox() accepts flags, maybe we should strip some of those here?
// We need to include zero width/height vertical/horizontal lines, so we have
// to use UnionEdges, but we must special case the first bbox so that we don't
// include the initial gfxRect(0,0,0,0).
gfxRect childBBox = child->GetBBoxContribution(tm, aFlags);
if (firstChild && (childBBox.Width() > 0 || childBBox.Height() > 0)) {
bbox = childBBox;
firstChild = false;
continue;
}
bbox = bbox.UnionEdges(childBBox);
}
}
return bbox;
}
示例11: switch
void
APZEventState::ProcessAPZStateChange(ViewID aViewId,
APZStateChange aChange,
int aArg)
{
switch (aChange)
{
case APZStateChange::eTransformBegin:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(true);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
scrollbarMediator->ScrollbarActivityStarted();
}
nsIContent* content = nsLayoutUtils::FindContentFor(aViewId);
nsIDocument* doc = content ? content->GetComposedDoc() : nullptr;
nsCOMPtr<nsIDocShell> docshell(doc ? doc->GetDocShell() : nullptr);
if (docshell && sf) {
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
nsdocshell->NotifyAsyncPanZoomStarted();
}
break;
}
case APZStateChange::eTransformEnd:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
sf->SetTransformingByAPZ(false);
}
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
if (scrollbarMediator) {
scrollbarMediator->ScrollbarActivityStopped();
}
nsIContent* content = nsLayoutUtils::FindContentFor(aViewId);
nsIDocument* doc = content ? content->GetComposedDoc() : nullptr;
nsCOMPtr<nsIDocShell> docshell(doc ? doc->GetDocShell() : nullptr);
if (docshell && sf) {
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
nsdocshell->NotifyAsyncPanZoomStopped();
}
break;
}
case APZStateChange::eStartTouch:
{
mActiveElementManager->HandleTouchStart(aArg);
break;
}
case APZStateChange::eStartPanning:
{
// The user started to pan, so we don't want anything to be :active.
mActiveElementManager->ClearActivation();
break;
}
case APZStateChange::eEndTouch:
{
mEndTouchIsClick = aArg;
mActiveElementManager->HandleTouchEnd();
break;
}
case APZStateChange::eSentinel:
// Should never happen, but we want this case branch to stop the compiler
// whining about unhandled values.
MOZ_ASSERT(false);
break;
}
}
示例12: do_QueryFrame
void
nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame)
{
mDropdownFrame = aDropDownFrame;
mListControlFrame = do_QueryFrame(mDropdownFrame);
}
示例13: NS_ERROR
NS_IMETHODIMP
nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// Constraints we try to satisfy:
// 1) Default width of button is the vertical scrollbar size
// 2) If the width of button is bigger than our width, set width of
// button to 0.
// 3) Default height of button is height of display area
// 4) Width of display area is whatever is left over from our width after
// allocating width for the button.
// 5) Height of display area is GetHeightOfARow() on the
// mListControlFrame.
if (!mDisplayFrame || !mButtonFrame || !mDropdownFrame) {
NS_ERROR("Why did the frame constructor allow this to happen? Fix it!!");
return NS_ERROR_UNEXPECTED;
}
// Make sure the displayed text is the same as the selected option, bug 297389.
PRInt32 selectedIndex;
nsAutoString selectedOptionText;
if (!mDroppedDown) {
selectedIndex = mListControlFrame->GetSelectedIndex();
}
else {
// In dropped down mode the "selected index" is the hovered menu item,
// we want the last selected item which is |mDisplayedIndex| in this case.
selectedIndex = mDisplayedIndex;
}
if (selectedIndex != -1) {
mListControlFrame->GetOptionText(selectedIndex, selectedOptionText);
}
if (mDisplayedOptionText != selectedOptionText) {
RedisplayText(selectedIndex);
}
// First reflow our dropdown so that we know how tall we should be.
ReflowDropdown(aPresContext, aReflowState);
// Get the width of the vertical scrollbar. That will be the width of the
// dropdown button.
nscoord buttonWidth;
const nsStyleDisplay *disp = GetStyleDisplay();
if (IsThemed(disp) && !aPresContext->GetTheme()->ThemeNeedsComboboxDropmarker()) {
buttonWidth = 0;
}
else {
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
NS_ASSERTION(scrollable, "List must be a scrollable frame");
buttonWidth =
scrollable->GetDesiredScrollbarSizes(PresContext(),
aReflowState.rendContext).LeftRight();
if (buttonWidth > aReflowState.ComputedWidth()) {
buttonWidth = 0;
}
}
mDisplayWidth = aReflowState.ComputedWidth() - buttonWidth;
nsresult rv = nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState,
aStatus);
NS_ENSURE_SUCCESS(rv, rv);
// Now set the correct width and height on our button. The width we need to
// set always, the height only if we had an auto height.
nsRect buttonRect = mButtonFrame->GetRect();
// If we have a non-intrinsic computed height, our kids should have sized
// themselves properly on their own.
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
// The display frame is going to be the right height and width at this
// point. Use its height as the button height.
nsRect displayRect = mDisplayFrame->GetRect();
buttonRect.height = displayRect.height;
buttonRect.y = displayRect.y;
}
#ifdef DEBUG
else {
nscoord buttonHeight = mButtonFrame->GetSize().height;
nscoord displayHeight = mDisplayFrame->GetSize().height;
// The button and display area should be equal heights, unless the computed
// height on the combobox is too small to fit their borders and padding.
NS_ASSERTION(buttonHeight == displayHeight ||
(aReflowState.ComputedHeight() < buttonHeight &&
buttonHeight ==
mButtonFrame->GetUsedBorderAndPadding().TopBottom()) ||
(aReflowState.ComputedHeight() < displayHeight &&
displayHeight ==
mDisplayFrame->GetUsedBorderAndPadding().TopBottom()),
"Different heights?");
}
#endif
if (GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
// Make sure the right edge of the button frame stays where it is now
buttonRect.x -= buttonWidth - buttonRect.width;
//.........这里部分代码省略.........
示例14: do_QueryFrame
nsTextControlFrame*
nsFileControlFrame::GetTextControlFrame()
{
nsITextControlFrame* tc = do_QueryFrame(mTextContent->GetPrimaryFrame());
return static_cast<nsTextControlFrame*>(tc);
}
示例15: GetParent
NS_IMETHODIMP
nsSubDocumentFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
if (aNameSpaceID != kNameSpaceID_None) {
return NS_OK;
}
// If the noResize attribute changes, dis/allow frame to be resized
if (aAttribute == nsGkAtoms::noresize) {
// Note that we're not doing content type checks, but that's ok -- if
// they'd fail we will just end up with a null framesetFrame.
if (mContent->GetParent()->Tag() == nsGkAtoms::frameset) {
nsIFrame* parentFrame = GetParent();
if (parentFrame) {
// There is no interface for nsHTMLFramesetFrame so QI'ing to
// concrete class, yay!
nsHTMLFramesetFrame* framesetFrame = do_QueryFrame(parentFrame);
if (framesetFrame) {
framesetFrame->RecalculateBorderResize();
}
}
}
}
else if (aAttribute == nsGkAtoms::type) {
if (!mFrameLoader)
return NS_OK;
if (!mContent->IsNodeOfType(nsINode::eXUL)) {
return NS_OK;
}
// Note: This logic duplicates a lot of logic in
// nsFrameLoader::EnsureDocShell. We should fix that.
// Notify our enclosing chrome that our type has changed. We only do this
// if our parent is chrome, since in all other cases we're random content
// subframes and the treeowner shouldn't worry about us.
nsCOMPtr<nsIDocShell> docShell;
mFrameLoader->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
if (!docShellAsItem) {
return NS_OK;
}
nsCOMPtr<nsIDocShellTreeItem> parentItem;
docShellAsItem->GetParent(getter_AddRefs(parentItem));
if (!parentItem) {
return NS_OK;
}
PRInt32 parentType;
parentItem->GetItemType(&parentType);
if (parentType != nsIDocShellTreeItem::typeChrome) {
return NS_OK;
}
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
parentItem->GetTreeOwner(getter_AddRefs(parentTreeOwner));
if (parentTreeOwner) {
nsAutoString value;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, value);
PRBool is_primary = value.LowerCaseEqualsLiteral("content-primary");
#ifdef MOZ_XUL
// when a content panel is no longer primary, hide any open popups it may have
if (!is_primary) {
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm)
pm->HidePopupsInDocShell(docShellAsItem);
}
#endif
parentTreeOwner->ContentShellRemoved(docShellAsItem);
if (value.LowerCaseEqualsLiteral("content") ||
StringBeginsWith(value, NS_LITERAL_STRING("content-"),
nsCaseInsensitiveStringComparator())) {
PRBool is_targetable = is_primary ||
value.LowerCaseEqualsLiteral("content-targetable");
parentTreeOwner->ContentShellAdded(docShellAsItem, is_primary,
is_targetable, value);
}
}
}
return NS_OK;
}