Bug 1417376 Part 3 - Pass nsPoint parameters by const references instead of values. r=mats

It's good to save some copy constructor calls.

MozReview-Commit-ID: 6TveqwkOvc0

--HG--
extra : rebase_source : 02e678f985c074f6c972cf8478e233aa5e4607db
This commit is contained in:
Ting-Yu Lin 2017-11-15 17:55:36 +08:00
parent 7326c2887e
commit 264402226f
15 changed files with 38 additions and 37 deletions

View File

@ -6179,7 +6179,7 @@ nsLayoutUtils::DrawString(const nsIFrame* aFrame,
void
nsLayoutUtils::DrawUniDirString(const char16_t* aString,
uint32_t aLength,
nsPoint aPoint,
const nsPoint& aPoint,
nsFontMetrics& aFontMetrics,
gfxContext& aContext)
{

View File

@ -1646,7 +1646,7 @@ public:
*/
static void DrawUniDirString(const char16_t* aString,
uint32_t aLength,
nsPoint aPoint,
const nsPoint& aPoint,
nsFontMetrics& aFontMetrics,
gfxContext& aContext);

View File

@ -32,7 +32,7 @@ public:
friend nsIFrame* ::NS_NewBRFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
virtual ContentOffsets CalcContentOffsetsFromFramePoint(nsPoint aPoint) override;
ContentOffsets CalcContentOffsetsFromFramePoint(const nsPoint& aPoint) override;
virtual FrameSearchResult PeekOffsetNoAmount(bool aForward, int32_t* aOffset) override;
virtual FrameSearchResult
@ -217,7 +217,7 @@ BRFrame::GetLogicalBaseline(mozilla::WritingMode aWritingMode) const
return mAscent;
}
nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(nsPoint aPoint)
nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(const nsPoint& aPoint)
{
ContentOffsets offsets;
offsets.content = mContent->GetParent();

View File

@ -455,9 +455,8 @@ nsIFrame::IsVisibleConsideringAncestors(uint32_t aFlags) const
}
void
nsIFrame::FindCloserFrameForSelection(
nsPoint aPoint,
nsIFrame::FrameWithDistance* aCurrentBestFrame)
nsIFrame::FindCloserFrameForSelection(const nsPoint& aPoint,
FrameWithDistance* aCurrentBestFrame)
{
if (nsLayoutUtils::PointIsCloserToRect(aPoint, mRect,
aCurrentBestFrame->mXDistance,
@ -4726,7 +4725,8 @@ struct FrameTarget {
};
// See function implementation for information
static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, nsPoint aPoint,
static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame,
const nsPoint& aPoint,
uint32_t aFlags);
static bool SelfIsSelectable(nsIFrame* aFrame, uint32_t aFlags)
@ -4758,7 +4758,7 @@ static bool SelectionDescendToKids(nsIFrame* aFrame) {
}
static FrameTarget GetSelectionClosestFrameForChild(nsIFrame* aChild,
nsPoint aPoint,
const nsPoint& aPoint,
uint32_t aFlags)
{
nsIFrame* parent = aChild->GetParent();
@ -4808,7 +4808,7 @@ static FrameTarget DrillDownToSelectionFrame(nsIFrame* aFrame,
static FrameTarget GetSelectionClosestFrameForLine(
nsBlockFrame* aParent,
nsBlockFrame::LineIterator aLine,
nsPoint aPoint,
const nsPoint& aPoint,
uint32_t aFlags)
{
nsIFrame *frame = aLine->mFirstChild;
@ -4866,7 +4866,7 @@ static FrameTarget GetSelectionClosestFrameForLine(
// frame tree. Returns a null FrameTarget for frames which are not
// blocks or blocks with no lines except editable one.
static FrameTarget GetSelectionClosestFrameForBlock(nsIFrame* aFrame,
nsPoint aPoint,
const nsPoint& aPoint,
uint32_t aFlags)
{
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(aFrame); // used only for QI
@ -4951,7 +4951,8 @@ static FrameTarget GetSelectionClosestFrameForBlock(nsIFrame* aFrame,
// Cannot handle overlapping frames correctly, so it should receive the output
// of GetFrameForPoint
// Guaranteed to return a valid FrameTarget
static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, nsPoint aPoint,
static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame,
const nsPoint& aPoint,
uint32_t aFlags)
{
{
@ -4981,7 +4982,8 @@ static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, nsPoint aPoint,
return FrameTarget(aFrame, false, false);
}
nsIFrame::ContentOffsets OffsetsForSingleFrame(nsIFrame* aFrame, nsPoint aPoint)
nsIFrame::ContentOffsets OffsetsForSingleFrame(nsIFrame* aFrame,
const nsPoint& aPoint)
{
nsIFrame::ContentOffsets offsets;
FrameContentRange range = GetRangeForFrame(aFrame);
@ -5040,7 +5042,7 @@ static nsIFrame* AdjustFrameForSelectionStyles(nsIFrame* aFrame) {
return adjustedFrame;
}
nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint(nsPoint aPoint,
nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint(const nsPoint& aPoint,
uint32_t aFlags)
{
nsIFrame *adjustedFrame;
@ -5121,7 +5123,7 @@ nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint(nsPoint aPoint,
// to the same visual position?
}
nsIFrame::ContentOffsets nsFrame::CalcContentOffsetsFromFramePoint(nsPoint aPoint)
nsIFrame::ContentOffsets nsFrame::CalcContentOffsetsFromFramePoint(const nsPoint& aPoint)
{
return OffsetsForSingleFrame(this, aPoint);
}

View File

@ -441,7 +441,7 @@ public:
// Helper for GetContentAndOffsetsFromPoint; calculation of content offsets
// in this function assumes there is no child frame that can be targeted.
virtual ContentOffsets CalcContentOffsetsFromFramePoint(nsPoint aPoint);
virtual ContentOffsets CalcContentOffsetsFromFramePoint(const nsPoint& aPoint);
// Box layout methods
nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;

View File

@ -1242,7 +1242,7 @@ nsFrameSelection::HandleClick(nsIContent* aNewFocus,
}
void
nsFrameSelection::HandleDrag(nsIFrame *aFrame, nsPoint aPoint)
nsFrameSelection::HandleDrag(nsIFrame* aFrame, const nsPoint& aPoint)
{
if (!aFrame || !mShell)
return;
@ -1311,8 +1311,8 @@ nsFrameSelection::HandleDrag(nsIFrame *aFrame, nsPoint aPoint)
}
nsresult
nsFrameSelection::StartAutoScrollTimer(nsIFrame *aFrame,
nsPoint aPoint,
nsFrameSelection::StartAutoScrollTimer(nsIFrame* aFrame,
const nsPoint& aPoint,
uint32_t aDelay)
{
int8_t index = GetIndexFromSelectionType(SelectionType::eNormal);

View File

@ -237,7 +237,7 @@ public:
* @param aPoint is relative to aFrame
*/
/*unsafe*/
void HandleDrag(nsIFrame *aFrame, nsPoint aPoint);
void HandleDrag(nsIFrame* aFrame, const nsPoint& aPoint);
/** HandleTableSelection will set selection to a table, cell, etc
* depending on information contained in aFlags
@ -320,8 +320,8 @@ public:
* @param aDelay is the timer's interval.
*/
/*unsafe*/
nsresult StartAutoScrollTimer(nsIFrame *aFrame,
nsPoint aPoint,
nsresult StartAutoScrollTimer(nsIFrame* aFrame,
const nsPoint& aPoint,
uint32_t aDelay);
/** StopAutoScrollTimer stops any active auto scroll timer.

View File

@ -1333,7 +1333,7 @@ ScrollFrameHelper::WantAsyncScroll() const
}
static nsRect
GetOnePixelRangeAroundPoint(nsPoint aPoint, bool aIsHorizontal)
GetOnePixelRangeAroundPoint(const nsPoint& aPoint, bool aIsHorizontal)
{
nsRect allowedRange(aPoint, nsSize());
nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f);

View File

@ -1966,10 +1966,10 @@ public:
* for frame lists other than the primary one.
* @param aPoint point relative to this frame
*/
ContentOffsets GetContentOffsetsFromPoint(nsPoint aPoint,
ContentOffsets GetContentOffsetsFromPoint(const nsPoint& aPoint,
uint32_t aFlags = 0);
virtual ContentOffsets GetContentOffsetsFromPointExternal(nsPoint aPoint,
virtual ContentOffsets GetContentOffsetsFromPointExternal(const nsPoint& aPoint,
uint32_t aFlags = 0)
{ return GetContentOffsetsFromPoint(aPoint, aFlags); }
@ -3906,7 +3906,7 @@ public:
* a pointer to this frame and its distance to aPoint, if this frame
* is indeed closer than the current distance in aCurrentBestFrame.
*/
virtual void FindCloserFrameForSelection(nsPoint aPoint,
virtual void FindCloserFrameForSelection(const nsPoint& aPoint,
FrameWithDistance* aCurrentBestFrame);
/**

View File

@ -7451,7 +7451,7 @@ CountCharsFit(const gfxTextRun* aTextRun, gfxTextRun::Range aRange,
}
nsIFrame::ContentOffsets
nsTextFrame::CalcContentOffsetsFromFramePoint(nsPoint aPoint)
nsTextFrame::CalcContentOffsetsFromFramePoint(const nsPoint& aPoint)
{
return GetCharacterOffsetAtFramePointInternal(aPoint, true);
}
@ -7463,7 +7463,7 @@ nsTextFrame::GetCharacterOffsetAtFramePoint(const nsPoint &aPoint)
}
nsIFrame::ContentOffsets
nsTextFrame::GetCharacterOffsetAtFramePointInternal(nsPoint aPoint,
nsTextFrame::GetCharacterOffsetAtFramePointInternal(const nsPoint& aPoint,
bool aForInsertionPoint)
{
ContentOffsets offsets;

View File

@ -176,7 +176,7 @@ public:
nsFrameState GetDebugStateBits() const override;
#endif
ContentOffsets CalcContentOffsetsFromFramePoint(nsPoint aPoint) override;
ContentOffsets CalcContentOffsetsFromFramePoint(const nsPoint& aPoint) override;
ContentOffsets GetCharacterOffsetAtFramePoint(const nsPoint& aPoint);
/**
@ -871,7 +871,7 @@ protected:
SelectionType aSelectionType);
ContentOffsets GetCharacterOffsetAtFramePointInternal(
nsPoint aPoint,
const nsPoint& aPoint,
bool aForInsertionPoint);
void ClearFrameOffsetCache();

View File

@ -429,7 +429,7 @@ DisplayItemClip::ComputeRegionInClips(DisplayItemClip* aOldClip,
}
void
DisplayItemClip::MoveBy(nsPoint aPoint)
DisplayItemClip::MoveBy(const nsPoint& aPoint)
{
if (!mHaveClipRect)
return;

View File

@ -168,7 +168,7 @@ public:
return mClipRect;
}
void MoveBy(nsPoint aPoint);
void MoveBy(const nsPoint& aPoint);
nsCString ToString() const;

View File

@ -3423,9 +3423,8 @@ SVGTextFrame::HandleAttributeChangeInDescendant(Element* aElement,
}
void
SVGTextFrame::FindCloserFrameForSelection(
nsPoint aPoint,
nsIFrame::FrameWithDistance* aCurrentBestFrame)
SVGTextFrame::FindCloserFrameForSelection(const nsPoint& aPoint,
FrameWithDistance* aCurrentBestFrame)
{
if (GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
return;

View File

@ -243,8 +243,8 @@ public:
/**
* Finds the nsTextFrame for the closest rendered run to the specified point.
*/
virtual void FindCloserFrameForSelection(nsPoint aPoint,
FrameWithDistance* aCurrentBestFrame) override;
virtual void FindCloserFrameForSelection(const nsPoint& aPoint,
FrameWithDistance* aCurrentBestFrame) override;