diff options
Diffstat (limited to 'layout/generic')
-rw-r--r-- | layout/generic/nsContainerFrame.cpp | 6 | ||||
-rw-r--r-- | layout/generic/nsFrame.cpp | 27 | ||||
-rw-r--r-- | layout/generic/nsGridContainerFrame.cpp | 58 | ||||
-rw-r--r-- | layout/generic/nsIFrame.h | 5 | ||||
-rw-r--r-- | layout/generic/nsSelection.cpp | 24 |
5 files changed, 76 insertions, 44 deletions
diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index abf687c9b..3ff6c9bf1 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -1031,6 +1031,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) { PositionFrameView(aKidFrame); + PositionChildViews(aKidFrame); } // Reflow the child frame @@ -1074,6 +1075,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) { PositionFrameView(aKidFrame); + PositionChildViews(aKidFrame); } // Reflow the child frame @@ -1925,6 +1927,10 @@ nsContainerFrame::RenumberFrameAndDescendants(int32_t* aOrdinal, nsIFrame *f = bullet; do { nsIFrame *parent = f->GetParent(); + if (!parent) { + // We may have an orphan situation in some corner cases. + break; + } parent->ChildIsDirty(f); f = parent; } while (f != listItem); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index bbbb5c332..0d0c7108c 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -5557,6 +5557,19 @@ nsFrame::Reflow(nsPresContext* aPresContext, NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize); } +bool +nsIFrame::IsContentDisabled() const +{ + // FIXME(emilio): Doing this via CSS means callers must ensure the style is up + // to date, and they don't! + if (StyleUserInterface()->mUserInput == StyleUserInput::None) { + return true; + } + + auto* element = nsGenericHTMLElement::FromContentOrNull(GetContent()); + return element && element->IsDisabled(); +} + nsresult nsFrame::CharacterDataChanged(CharacterDataChangeInfo* aInfo) { @@ -8434,9 +8447,13 @@ UnionBorderBoxes(nsIFrame* aFrame, bool aApplyTransform, Maybe<nsRect> clipPropClipRect = aFrame->GetClipPropClipRect(disp, effects, bounds.Size()); - // Iterate over all children except pop-ups. + // Iterate over all children except pop-ups, absolutely positioned children, + // fixed-positioned children and floats. const nsIFrame::ChildListIDs skip(nsIFrame::kPopupList | - nsIFrame::kSelectPopupList); + nsIFrame::kSelectPopupList | + nsIFrame::kAbsoluteList | + nsIFrame::kFixedList | + nsIFrame::kFloatList); for (nsIFrame::ChildListIterator childLists(aFrame); !childLists.IsDone(); childLists.Next()) { if (skip.Contains(childLists.CurrentID())) { @@ -8446,6 +8463,12 @@ UnionBorderBoxes(nsIFrame* aFrame, bool aApplyTransform, nsFrameList children = childLists.CurrentList(); for (nsFrameList::Enumerator e(children); !e.AtEnd(); e.Next()) { nsIFrame* child = e.get(); + + if (child->GetType() == nsGkAtoms::placeholderFrame) { + // Skip placeholders too. + continue; + } + // Note that passing |true| for aApplyTransform when // child->Combines3DTransformWithAncestors() is incorrect if our // aApplyTransform is false... but the opposite would be as diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 959061e33..f771c9d7c 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -4822,14 +4822,14 @@ nsGridContainerFrame::Tracks::StretchFlexibleTracks( : ri->ComputedMaxISize(); } Maybe<nsTArray<TrackSize>> origSizes; + bool applyMinMax = (minSize != 0 || maxSize != NS_UNCONSTRAINEDSIZE) && + aAvailableSize == NS_UNCONSTRAINEDSIZE; // We iterate twice at most. The 2nd time if the grid size changed after // applying a min/max-size (can only occur if aAvailableSize is indefinite). while (true) { float fr = FindUsedFlexFraction(aState, aGridItems, flexTracks, aFunctions, aAvailableSize); if (fr != 0.0f) { - bool applyMinMax = (minSize != 0 || maxSize != NS_UNCONSTRAINEDSIZE) && - aAvailableSize == NS_UNCONSTRAINEDSIZE; for (uint32_t i : flexTracks) { float flexFactor = aFunctions.MaxSizingFor(i).GetFlexFractionValue(); nscoord flexLength = NSToCoordRound(flexFactor * fr); @@ -4841,36 +4841,36 @@ nsGridContainerFrame::Tracks::StretchFlexibleTracks( base = flexLength; } } - if (applyMinMax && origSizes.isSome()) { - // https://drafts.csswg.org/css-grid/#algo-flex-tracks - // "If using this flex fraction would cause the grid to be smaller than - // the grid container’s min-width/height (or larger than the grid - // container’s max-width/height), then redo this step, treating the free - // space as definite [...]" - nscoord newSize = 0; - for (auto& sz : mSizes) { - newSize += sz.mBase; - } - const auto sumOfGridGaps = SumOfGridGaps(); - newSize += sumOfGridGaps; - if (newSize > maxSize) { - aAvailableSize = maxSize; - } else if (newSize < minSize) { - aAvailableSize = minSize; - } - if (aAvailableSize != NS_UNCONSTRAINEDSIZE) { - // Reset min/max-size to ensure 'applyMinMax' becomes false next time. - minSize = 0; - maxSize = NS_UNCONSTRAINEDSIZE; - aAvailableSize = std::max(0, aAvailableSize - sumOfGridGaps); - // Restart with the original track sizes and definite aAvailableSize. + } + if (applyMinMax) { + applyMinMax = false; + // https://drafts.csswg.org/css-grid/#algo-flex-tracks + // "If using this flex fraction would cause the grid to be smaller than + // the grid container’s min-width/height (or larger than the grid + // container’s max-width/height), then redo this step, treating the free + // space as definite [...]" + nscoord newSize = 0; + for (auto& sz : mSizes) { + newSize += sz.mBase; + } + const auto sumOfGridGaps = SumOfGridGaps(); + newSize += sumOfGridGaps; + if (newSize > maxSize) { + aAvailableSize = maxSize; + } else if (newSize < minSize) { + aAvailableSize = minSize; + } + if (aAvailableSize != NS_UNCONSTRAINEDSIZE) { + aAvailableSize = std::max(0, aAvailableSize - sumOfGridGaps); + // Restart with the original track sizes and definite aAvailableSize. + if (origSizes.isSome()) { mSizes = Move(*origSizes); origSizes.reset(); - if (aAvailableSize == 0) { - break; // zero available size wouldn't change any sizes though... - } - continue; + } // else, no mSizes[].mBase were changed above so it's still correct + if (aAvailableSize == 0) { + break; // zero available size wouldn't change any sizes though... } + continue; } } break; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 57f5c460c..93eb95099 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -2436,6 +2436,11 @@ public: nsIWidget* GetNearestWidget(nsPoint& aOffset) const; /** + * Whether the content for this frame is disabled, used for event handling. + */ + bool IsContentDisabled() const; + + /** * Get the "type" of the frame. May return nullptr. * * @see nsGkAtoms diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index ff75ab85d..5ccb2d8bf 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -2882,16 +2882,15 @@ nsFrameSelection::UnselectCells(nsIContent *aTableContent, nsTableCellFrame* cellFrame = tableFrame->GetCellFrameAt(curRowIndex, curColIndex); - int32_t origRowIndex, origColIndex; - cellFrame->GetRowIndex(origRowIndex); - cellFrame->GetColIndex(origColIndex); + uint32_t origRowIndex = cellFrame->RowIndex(); + uint32_t origColIndex = cellFrame->ColIndex(); uint32_t actualRowSpan = tableFrame->GetEffectiveRowSpanAt(origRowIndex, origColIndex); uint32_t actualColSpan = tableFrame->GetEffectiveColSpanAt(curRowIndex, curColIndex); - if (origRowIndex <= maxRowIndex && maxRowIndex >= 0 && + if (origRowIndex <= static_cast<uint32_t>(maxRowIndex) && maxRowIndex >= 0 && origRowIndex + actualRowSpan - 1 >= static_cast<uint32_t>(minRowIndex) && - origColIndex <= maxColIndex && maxColIndex >= 0 && + origColIndex <= static_cast<uint32_t>(maxColIndex) && maxColIndex >= 0 && origColIndex + actualColSpan - 1 >= static_cast<uint32_t>(minColIndex)) { mDomSelections[index]->RemoveRange(range); @@ -2925,33 +2924,32 @@ nsFrameSelection::AddCellsToSelection(nsIContent *aTableContent, return NS_ERROR_FAILURE; nsresult result = NS_OK; - int32_t row = aStartRowIndex; + uint32_t row = aStartRowIndex; while(true) { - int32_t col = aStartColumnIndex; + uint32_t col = aStartColumnIndex; while(true) { nsTableCellFrame* cellFrame = tableFrame->GetCellFrameAt(row, col); // Skip cells that are spanned from previous locations or are already selected if (cellFrame) { - int32_t origRow, origCol; - cellFrame->GetRowIndex(origRow); - cellFrame->GetColIndex(origCol); + uint32_t origRow = cellFrame->RowIndex(); + uint32_t origCol = cellFrame->ColIndex(); if (origRow == row && origCol == col && !cellFrame->IsSelected()) { result = SelectCellElement(cellFrame->GetContent()); if (NS_FAILED(result)) return result; } } // Done when we reach end column - if (col == aEndColumnIndex) break; + if (col == static_cast<uint32_t>(aEndColumnIndex)) break; if (aStartColumnIndex < aEndColumnIndex) col ++; else col--; } - if (row == aEndRowIndex) break; + if (row == static_cast<uint32_t>(aEndRowIndex)) break; if (aStartRowIndex < aEndRowIndex) row++; @@ -3846,7 +3844,7 @@ Selection::AddItem(nsRange* aItem, int32_t* aOutIndex, bool aNoStartSelect) if (mUserInitiated) { AutoTArray<RefPtr<nsRange>, 4> rangesToAdd; - *aOutIndex = -1; + *aOutIndex = int32_t(mRanges.Length()) - 1; nsIDocument* doc = GetParentObject(); bool selectEventsEnabled = |