Bug 1628043 - Have GetFrameForPoint and GetFramesForArea take a const nsIFrame*. r=tnikkel

This allows us to have a single const_cast inside GetFramesForArea, and
avoid several callers of these functions (which, as of bug 1556556,
get a const nsIFrame* from RelativeTo inputs) having to const_cast.

Differential Revision: https://phabricator.services.mozilla.com/D70068

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2020-04-07 18:27:38 +00:00
Родитель 1b587aa1cf
Коммит d24d18b5e5
2 изменённых файлов: 12 добавлений и 9 удалений

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

@ -3141,7 +3141,8 @@ struct AutoNestedPaintCount {
#endif
nsIFrame* nsLayoutUtils::GetFrameForPoint(
nsIFrame* aFrame, nsPoint aPt, EnumSet<FrameForPointOption> aOptions) {
const nsIFrame* aFrame, nsPoint aPt,
EnumSet<FrameForPointOption> aOptions) {
AUTO_PROFILER_LABEL("nsLayoutUtils::GetFrameForPoint", LAYOUT);
nsresult rv;
@ -3152,11 +3153,13 @@ nsIFrame* nsLayoutUtils::GetFrameForPoint(
}
nsresult nsLayoutUtils::GetFramesForArea(
nsIFrame* aFrame, const nsRect& aRect, nsTArray<nsIFrame*>& aOutFrames,
EnumSet<FrameForPointOption> aOptions) {
const nsIFrame* aFrame, const nsRect& aRect,
nsTArray<nsIFrame*>& aOutFrames, EnumSet<FrameForPointOption> aOptions) {
AUTO_PROFILER_LABEL("nsLayoutUtils::GetFramesForArea", LAYOUT);
nsDisplayListBuilder builder(aFrame, nsDisplayListBuilderMode::EventDelivery,
nsIFrame* frame = const_cast<nsIFrame*>(aFrame);
nsDisplayListBuilder builder(frame, nsDisplayListBuilderMode::EventDelivery,
false);
builder.BeginFrame();
nsDisplayList list;
@ -3177,13 +3180,13 @@ nsresult nsLayoutUtils::GetFramesForArea(
builder.SetHitTestIsForVisibility(
aOptions.contains(FrameForPointOption::OnlyVisible));
builder.EnterPresShell(aFrame);
builder.EnterPresShell(frame);
builder.SetVisibleRect(aRect);
builder.SetDirtyRect(aRect);
aFrame->BuildDisplayListForStackingContext(&builder, &list);
builder.LeavePresShell(aFrame, nullptr);
frame->BuildDisplayListForStackingContext(&builder, &list);
builder.LeavePresShell(frame, nullptr);
#ifdef MOZ_DUMP_PAINTING
if (gDumpEventList) {

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

@ -881,7 +881,7 @@ class nsLayoutUtils {
* @param aPt the point, relative to the frame origin
* @param aFlags some combination of FrameForPointOption.
*/
static nsIFrame* GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt,
static nsIFrame* GetFrameForPoint(const nsIFrame* aFrame, nsPoint aPt,
mozilla::EnumSet<FrameForPointOption> = {});
/**
@ -892,7 +892,7 @@ class nsLayoutUtils {
* @param aOutFrames an array to add all the frames found
* @param aFlags some combination of FrameForPointOption.
*/
static nsresult GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect,
static nsresult GetFramesForArea(const nsIFrame* aFrame, const nsRect& aRect,
nsTArray<nsIFrame*>& aOutFrames,
mozilla::EnumSet<FrameForPointOption> = {});