Bug 987320 - Remove unnecessary null checks for do_QueryFrame arguments. r=bz

This commit is contained in:
Birunthan Mohanathas 2014-03-25 11:36:49 -04:00
parent 8524093d1f
commit bc35004647
13 changed files with 117 additions and 186 deletions

View File

@ -394,11 +394,7 @@ HTMLComboboxAccessible::InvalidateChildren()
void
HTMLComboboxAccessible::CacheChildren()
{
nsIFrame* frame = GetFrame();
if (!frame)
return;
nsIComboboxControlFrame* comboFrame = do_QueryFrame(frame);
nsIComboboxControlFrame* comboFrame = do_QueryFrame(GetFrame());
if (!comboFrame)
return;
@ -506,11 +502,7 @@ HTMLComboboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
if (aIndex != HTMLComboboxAccessible::eAction_Click) {
return NS_ERROR_INVALID_ARG;
}
nsIFrame* frame = GetFrame();
if (!frame) {
return NS_ERROR_FAILURE;
}
nsIComboboxControlFrame* comboFrame = do_QueryFrame(frame);
nsIComboboxControlFrame* comboFrame = do_QueryFrame(GetFrame());
if (!comboFrame) {
return NS_ERROR_FAILURE;
}
@ -602,12 +594,9 @@ nsIFrame*
HTMLComboboxListAccessible::GetFrame() const
{
nsIFrame* frame = HTMLSelectListAccessible::GetFrame();
if (frame) {
nsIComboboxControlFrame* comboBox = do_QueryFrame(frame);
if (comboBox) {
return comboBox->GetDropDown();
}
nsIComboboxControlFrame* comboBox = do_QueryFrame(frame);
if (comboBox) {
return comboBox->GetDropDown();
}
return nullptr;

View File

@ -2003,16 +2003,14 @@ nsFrameLoader::SetClampScrollPosition(bool aClamp)
// When turning clamping on, make sure the current position is clamped.
if (aClamp) {
nsIFrame* frame = GetPrimaryFrameOfOwningContent();
if (frame) {
nsSubDocumentFrame* subdocFrame = do_QueryFrame(frame);
if (subdocFrame) {
nsIFrame* subdocRootFrame = subdocFrame->GetSubdocumentRootFrame();
if (subdocRootFrame) {
nsIScrollableFrame* subdocRootScrollFrame = subdocRootFrame->PresContext()->PresShell()->
GetRootScrollFrameAsScrollable();
if (subdocRootScrollFrame) {
subdocRootScrollFrame->ScrollTo(subdocRootScrollFrame->GetScrollPosition(), nsIScrollableFrame::INSTANT);
}
nsSubDocumentFrame* subdocFrame = do_QueryFrame(frame);
if (subdocFrame) {
nsIFrame* subdocRootFrame = subdocFrame->GetSubdocumentRootFrame();
if (subdocRootFrame) {
nsIScrollableFrame* subdocRootScrollFrame = subdocRootFrame->PresContext()->PresShell()->
GetRootScrollFrameAsScrollable();
if (subdocRootScrollFrame) {
subdocRootScrollFrame->ScrollTo(subdocRootScrollFrame->GetScrollPosition(), nsIScrollableFrame::INSTANT);
}
}
}

View File

@ -179,10 +179,7 @@ bool
HTMLButtonElement::IsDisabledForEvents(uint32_t aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = nullptr;
if (formControlFrame) {
formFrame = do_QueryFrame(formControlFrame);
}
nsIFrame* formFrame = do_QueryFrame(formControlFrame);
return IsElementDisabledForEvents(aMessage, formFrame);
}

View File

@ -5064,26 +5064,23 @@ HTMLInputElement::SetSelectionRange(int32_t aSelectionStart,
ErrorResult& aRv)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
// Default to forward, even if not specified.
// Note that we don't currently support directionless selections, so
// "none" is treated like "forward".
nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eForward;
if (aDirection.WasPassed() && aDirection.Value().EqualsLiteral("backward")) {
dir = nsITextControlFrame::eBackward;
}
if (formControlFrame) {
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
// Default to forward, even if not specified.
// Note that we don't currently support directionless selections, so
// "none" is treated like "forward".
nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eForward;
if (aDirection.WasPassed() && aDirection.Value().EqualsLiteral("backward")) {
dir = nsITextControlFrame::eBackward;
}
aRv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd, dir);
if (!aRv.Failed()) {
aRv = textControlFrame->ScrollSelectionIntoView();
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, NS_LITERAL_STRING("select"),
true, false);
asyncDispatcher->PostDOMEvent();
}
aRv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd, dir);
if (!aRv.Failed()) {
aRv = textControlFrame->ScrollSelectionIntoView();
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, NS_LITERAL_STRING("select"),
true, false);
asyncDispatcher->PostDOMEvent();
}
}
}
@ -5350,16 +5347,13 @@ nsresult
HTMLInputElement::GetSelectionRange(int32_t* aSelectionStart,
int32_t* aSelectionEnd)
{
nsresult rv = NS_ERROR_FAILURE;
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame) {
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame)
rv = textControlFrame->GetSelectionRange(aSelectionStart, aSelectionEnd);
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
return textControlFrame->GetSelectionRange(aSelectionStart, aSelectionEnd);
}
return rv;
return NS_ERROR_FAILURE;
}
static void
@ -5381,15 +5375,12 @@ HTMLInputElement::GetSelectionDirection(nsAString& aDirection, ErrorResult& aRv)
{
nsresult rv = NS_ERROR_FAILURE;
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame) {
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
nsITextControlFrame::SelectionDirection dir;
rv = textControlFrame->GetSelectionRange(nullptr, nullptr, &dir);
if (NS_SUCCEEDED(rv)) {
DirectionToName(dir, aDirection);
}
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
nsITextControlFrame::SelectionDirection dir;
rv = textControlFrame->GetSelectionRange(nullptr, nullptr, &dir);
if (NS_SUCCEEDED(rv)) {
DirectionToName(dir, aDirection);
}
}
@ -5449,11 +5440,9 @@ HTMLInputElement::GetPhonetic(nsAString& aPhonetic)
{
aPhonetic.Truncate();
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame) {
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame)
textControlFrame->GetPhonetic(aPhonetic);
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
textControlFrame->GetPhonetic(aPhonetic);
}
return NS_OK;

View File

@ -448,10 +448,7 @@ bool
HTMLTextAreaElement::IsDisabledForEvents(uint32_t aMessage)
{
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
nsIFrame* formFrame = nullptr;
if (formControlFrame) {
formFrame = do_QueryFrame(formControlFrame);
}
nsIFrame* formFrame = do_QueryFrame(formControlFrame);
return IsElementDisabledForEvents(aMessage, formFrame);
}
@ -763,16 +760,13 @@ nsresult
HTMLTextAreaElement::GetSelectionRange(int32_t* aSelectionStart,
int32_t* aSelectionEnd)
{
nsresult rv = NS_ERROR_FAILURE;
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame) {
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame)
rv = textControlFrame->GetSelectionRange(aSelectionStart, aSelectionEnd);
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
return textControlFrame->GetSelectionRange(aSelectionStart, aSelectionEnd);
}
return rv;
return NS_ERROR_FAILURE;
}
static void
@ -802,15 +796,12 @@ HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection, ErrorResult& a
{
nsresult rv = NS_ERROR_FAILURE;
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame) {
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
nsITextControlFrame::SelectionDirection dir;
rv = textControlFrame->GetSelectionRange(nullptr, nullptr, &dir);
if (NS_SUCCEEDED(rv)) {
DirectionToName(dir, aDirection);
}
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
nsITextControlFrame::SelectionDirection dir;
rv = textControlFrame->GetSelectionRange(nullptr, nullptr, &dir);
if (NS_SUCCEEDED(rv)) {
DirectionToName(dir, aDirection);
}
}
@ -875,26 +866,23 @@ HTMLTextAreaElement::SetSelectionRange(uint32_t aSelectionStart,
{
nsresult rv = NS_ERROR_FAILURE;
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
// Default to forward, even if not specified.
// Note that we don't currently support directionless selections, so
// "none" is treated like "forward".
nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eForward;
if (aDirection.WasPassed() && aDirection.Value().EqualsLiteral("backward")) {
dir = nsITextControlFrame::eBackward;
}
if (formControlFrame) {
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
if (textControlFrame) {
// Default to forward, even if not specified.
// Note that we don't currently support directionless selections, so
// "none" is treated like "forward".
nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eForward;
if (aDirection.WasPassed() && aDirection.Value().EqualsLiteral("backward")) {
dir = nsITextControlFrame::eBackward;
}
rv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd, dir);
if (NS_SUCCEEDED(rv)) {
rv = textControlFrame->ScrollSelectionIntoView();
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, NS_LITERAL_STRING("select"),
true, false);
asyncDispatcher->PostDOMEvent();
}
rv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd, dir);
if (NS_SUCCEEDED(rv)) {
rv = textControlFrame->ScrollSelectionIntoView();
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, NS_LITERAL_STRING("select"),
true, false);
asyncDispatcher->PostDOMEvent();
}
}

View File

@ -178,10 +178,6 @@ void
TextTrackManager::UpdateCueDisplay()
{
nsIFrame* frame = mMediaElement->GetPrimaryFrame();
if (!frame) {
return;
}
nsVideoFrame* videoFrame = do_QueryFrame(frame);
if (!videoFrame) {
return;

View File

@ -805,14 +805,11 @@ SVGSVGElement::WillBeOutermostSVG(nsIContent* aParent,
void
SVGSVGElement::InvalidateTransformNotifyFrame()
{
nsIFrame* frame = GetPrimaryFrame();
if (frame) {
nsISVGSVGFrame* svgframe = do_QueryFrame(frame);
// might fail this check if we've failed conditional processing
if (svgframe) {
svgframe->NotifyViewportOrTransformChanged(
nsISVGChildFrame::TRANSFORM_CHANGED);
}
nsISVGSVGFrame* svgframe = do_QueryFrame(GetPrimaryFrame());
// might fail this check if we've failed conditional processing
if (svgframe) {
svgframe->NotifyViewportOrTransformChanged(
nsISVGChildFrame::TRANSFORM_CHANGED);
}
}

View File

@ -801,13 +801,11 @@ nsScrollbarsForWheel::TemporarilyActivateAllPossibleScrollTargets(
nsIScrollableFrame* target =
aESM->ComputeScrollTarget(aTargetFrame, dir->deltaX, dir->deltaY, aEvent,
nsEventStateManager::COMPUTE_DEFAULT_ACTION_TARGET);
if (target) {
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(target);
if (scrollbarOwner) {
nsIFrame* targetFrame = do_QueryFrame(target);
*scrollTarget = targetFrame;
scrollbarOwner->ScrollbarActivityStarted();
}
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(target);
if (scrollbarOwner) {
nsIFrame* targetFrame = do_QueryFrame(target);
*scrollTarget = targetFrame;
scrollbarOwner->ScrollbarActivityStarted();
}
}
}

View File

@ -1700,11 +1700,9 @@ bool
TabChild::RecvNotifyTransformBegin(const ViewID& aViewId)
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStarted();
}
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStarted();
}
return true;
}
@ -1713,11 +1711,9 @@ bool
TabChild::RecvNotifyTransformEnd(const ViewID& aViewId)
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
if (sf) {
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
}
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
}
return true;
}

View File

@ -1259,9 +1259,6 @@ nsIScrollableFrame*
nsLayoutUtils::GetScrollableFrameFor(const nsIFrame *aScrolledFrame)
{
nsIFrame *frame = aScrolledFrame->GetParent();
if (!frame) {
return nullptr;
}
nsIScrollableFrame *sf = do_QueryFrame(frame);
return sf;
}

View File

@ -362,12 +362,10 @@ nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO,
// Finds the SimplePageSequencer frame
nsIPageSequenceFrame* seqFrame = aPO->mPresShell->GetPageSequenceFrame();
if (seqFrame) {
aSeqFrame = do_QueryFrame(seqFrame);
} else {
aSeqFrame = nullptr;
aSeqFrame = do_QueryFrame(seqFrame);
if (!aSeqFrame) {
return NS_ERROR_FAILURE;
}
if (aSeqFrame == nullptr) return NS_ERROR_FAILURE;
// first count the total number of pages
aCount = 0;

View File

@ -136,11 +136,9 @@ nsSVGSwitchFrame::GetFrameForPoint(const nsPoint &aPoint)
"SVG should take this code path");
nsIFrame *kid = GetActiveChildFrame();
if (kid) {
nsISVGChildFrame* svgFrame = do_QueryFrame(kid);
if (svgFrame) {
return svgFrame->GetFrameForPoint(aPoint);
}
nsISVGChildFrame* svgFrame = do_QueryFrame(kid);
if (svgFrame) {
return svgFrame->GetFrameForPoint(aPoint);
}
return nullptr;
@ -152,11 +150,9 @@ nsSVGSwitchFrame::GetCoveredRegion()
nsRect rect;
nsIFrame *kid = GetActiveChildFrame();
if (kid) {
nsISVGChildFrame* child = do_QueryFrame(kid);
if (child) {
rect = child->GetCoveredRegion();
}
nsISVGChildFrame* child = do_QueryFrame(kid);
if (child) {
rect = child->GetCoveredRegion();
}
return rect;
}
@ -193,18 +189,16 @@ nsSVGSwitchFrame::ReflowSVG()
nsOverflowAreas overflowRects;
nsIFrame *child = GetActiveChildFrame();
if (child) {
nsISVGChildFrame* svgChild = do_QueryFrame(child);
if (svgChild) {
NS_ABORT_IF_FALSE(!(child->GetStateBits() & NS_FRAME_IS_NONDISPLAY),
"Check for this explicitly in the |if|, then");
svgChild->ReflowSVG();
nsISVGChildFrame* svgChild = do_QueryFrame(child);
if (svgChild) {
NS_ABORT_IF_FALSE(!(child->GetStateBits() & NS_FRAME_IS_NONDISPLAY),
"Check for this explicitly in the |if|, then");
svgChild->ReflowSVG();
// We build up our child frame overflows here instead of using
// nsLayoutUtils::UnionChildOverflow since SVG frame's all use the same
// frame list, and we're iterating over that list now anyway.
ConsiderChildOverflow(overflowRects, child);
}
// We build up our child frame overflows here instead of using
// nsLayoutUtils::UnionChildOverflow since SVG frame's all use the same
// frame list, and we're iterating over that list now anyway.
ConsiderChildOverflow(overflowRects, child);
}
if (isFirstReflow) {
@ -227,17 +221,15 @@ nsSVGSwitchFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags)
{
nsIFrame* kid = GetActiveChildFrame();
if (kid) {
nsISVGChildFrame* svgKid = do_QueryFrame(kid);
if (svgKid) {
nsIContent *content = kid->GetContent();
gfxMatrix transform = ThebesMatrix(aToBBoxUserspace);
if (content->IsSVG()) {
transform = static_cast<nsSVGElement*>(content)->
PrependLocalTransformsTo(transform);
}
return svgKid->GetBBoxContribution(ToMatrix(transform), aFlags);
nsISVGChildFrame* svgKid = do_QueryFrame(kid);
if (svgKid) {
nsIContent *content = kid->GetContent();
gfxMatrix transform = ThebesMatrix(aToBBoxUserspace);
if (content->IsSVG()) {
transform = static_cast<nsSVGElement*>(content)->
PrependLocalTransformsTo(transform);
}
return svgKid->GetBBoxContribution(ToMatrix(transform), aFlags);
}
return SVGBBox();
}

View File

@ -48,16 +48,12 @@ NS_IMETHODIMP nsContainerBoxObject::GetDocShell(nsIDocShell** aResult)
{
*aResult = nullptr;
nsIFrame *frame = GetFrame(false);
nsSubDocumentFrame *subDocFrame = do_QueryFrame(GetFrame(false));
if (subDocFrame) {
// Ok, the frame for mContent is an nsSubDocumentFrame, it knows how
// to reach the docshell, so ask it...
if (frame) {
nsSubDocumentFrame *subDocFrame = do_QueryFrame(frame);
if (subDocFrame) {
// Ok, the frame for mContent is an nsSubDocumentFrame, it knows how
// to reach the docshell, so ask it...
return subDocFrame->GetDocShell(aResult);
}
return subDocFrame->GetDocShell(aResult);
}
if (!mContent) {