| File: | var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp | 
| Warning: | line 3586, column 7 Value stored to 'createdContainer' is never read | 
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 
| 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ | 
| 3 | /* This Source Code Form is subject to the terms of the Mozilla Public | 
| 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this | 
| 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 
| 6 | |
| 7 | /* base class of all rendering objects */ | 
| 8 | |
| 9 | #include "nsIFrame.h" | 
| 10 | |
| 11 | #include <stdarg.h> | 
| 12 | #include <algorithm> | 
| 13 | |
| 14 | #include "gfx2DGlue.h" | 
| 15 | #include "gfxUtils.h" | 
| 16 | #include "mozilla/Attributes.h" | 
| 17 | #include "mozilla/CaretAssociationHint.h" | 
| 18 | #include "mozilla/ComputedStyle.h" | 
| 19 | #include "mozilla/DebugOnly.h" | 
| 20 | #include "mozilla/DisplayPortUtils.h" | 
| 21 | #include "mozilla/EventForwards.h" | 
| 22 | #include "mozilla/FocusModel.h" | 
| 23 | #include "mozilla/dom/CSSAnimation.h" | 
| 24 | #include "mozilla/dom/CSSTransition.h" | 
| 25 | #include "mozilla/dom/ContentVisibilityAutoStateChangeEvent.h" | 
| 26 | #include "mozilla/dom/DocumentInlines.h" | 
| 27 | #include "mozilla/dom/AncestorIterator.h" | 
| 28 | #include "mozilla/dom/ElementInlines.h" | 
| 29 | #include "mozilla/dom/ImageTracker.h" | 
| 30 | #include "mozilla/dom/Selection.h" | 
| 31 | #include "mozilla/gfx/2D.h" | 
| 32 | #include "mozilla/gfx/PathHelpers.h" | 
| 33 | #include "mozilla/IntegerRange.h" | 
| 34 | #include "mozilla/intl/BidiEmbeddingLevel.h" | 
| 35 | #include "mozilla/Maybe.h" | 
| 36 | #include "mozilla/PresShell.h" | 
| 37 | #include "mozilla/PresShellInlines.h" | 
| 38 | #include "mozilla/ResultExtensions.h" | 
| 39 | #include "mozilla/ScrollContainerFrame.h" | 
| 40 | #include "mozilla/SelectionMovementUtils.h" | 
| 41 | #include "mozilla/Sprintf.h" | 
| 42 | #include "mozilla/StaticAnalysisFunctions.h" | 
| 43 | #include "mozilla/StaticPrefs_layout.h" | 
| 44 | #include "mozilla/StaticPrefs_print.h" | 
| 45 | #include "mozilla/StaticPrefs_ui.h" | 
| 46 | #include "mozilla/SVGMaskFrame.h" | 
| 47 | #include "mozilla/SVGObserverUtils.h" | 
| 48 | #include "mozilla/SVGTextFrame.h" | 
| 49 | #include "mozilla/SVGIntegrationUtils.h" | 
| 50 | #include "mozilla/SVGUtils.h" | 
| 51 | #include "mozilla/TextControlElement.h" | 
| 52 | #include "mozilla/ToString.h" | 
| 53 | #include "mozilla/Try.h" | 
| 54 | #include "mozilla/ViewportUtils.h" | 
| 55 | #include "mozilla/WritingModes.h" | 
| 56 | |
| 57 | #include "nsCOMPtr.h" | 
| 58 | #include "nsFieldSetFrame.h" | 
| 59 | #include "nsFlexContainerFrame.h" | 
| 60 | #include "nsFocusManager.h" | 
| 61 | #include "nsFrameList.h" | 
| 62 | #include "nsTextControlFrame.h" | 
| 63 | #include "nsPlaceholderFrame.h" | 
| 64 | #include "nsIBaseWindow.h" | 
| 65 | #include "nsIContent.h" | 
| 66 | #include "nsIContentInlines.h" | 
| 67 | #include "nsContentUtils.h" | 
| 68 | #include "nsCSSFrameConstructor.h" | 
| 69 | #include "nsCSSProps.h" | 
| 70 | #include "nsCSSPseudoElements.h" | 
| 71 | #include "nsCSSRendering.h" | 
| 72 | #include "nsAtom.h" | 
| 73 | #include "nsString.h" | 
| 74 | #include "nsReadableUtils.h" | 
| 75 | #include "nsTableWrapperFrame.h" | 
| 76 | #include "nsView.h" | 
| 77 | #include "nsViewManager.h" | 
| 78 | #include "nsPresContext.h" | 
| 79 | #include "nsPresContextInlines.h" | 
| 80 | #include "nsStyleConsts.h" | 
| 81 | #include "mozilla/Logging.h" | 
| 82 | #include "nsLayoutUtils.h" | 
| 83 | #include "LayoutLogging.h" | 
| 84 | #include "mozilla/RestyleManager.h" | 
| 85 | #include "nsImageFrame.h" | 
| 86 | #include "nsInlineFrame.h" | 
| 87 | #include "nsFrameSelection.h" | 
| 88 | #include "nsGkAtoms.h" | 
| 89 | #include "nsGridContainerFrame.h" | 
| 90 | #include "nsCSSAnonBoxes.h" | 
| 91 | #include "nsCanvasFrame.h" | 
| 92 | |
| 93 | #include "nsFieldSetFrame.h" | 
| 94 | #include "nsFrameTraversal.h" | 
| 95 | #include "nsRange.h" | 
| 96 | #include "nsNameSpaceManager.h" | 
| 97 | #include "nsIPercentBSizeObserver.h" | 
| 98 | #include "nsStyleStructInlines.h" | 
| 99 | |
| 100 | #include "nsBidiPresUtils.h" | 
| 101 | #include "RubyUtils.h" | 
| 102 | #include "TextOverflow.h" | 
| 103 | #include "nsAnimationManager.h" | 
| 104 | |
| 105 | // For triple-click pref | 
| 106 | #include "imgIRequest.h" | 
| 107 | #include "nsError.h" | 
| 108 | #include "nsContainerFrame.h" | 
| 109 | #include "nsBlockFrame.h" | 
| 110 | #include "nsDisplayList.h" | 
| 111 | #include "nsChangeHint.h" | 
| 112 | #include "nsSubDocumentFrame.h" | 
| 113 | #include "RetainedDisplayListBuilder.h" | 
| 114 | |
| 115 | #include "gfxContext.h" | 
| 116 | #include "nsAbsoluteContainingBlock.h" | 
| 117 | #include "ScrollSnap.h" | 
| 118 | #include "StickyScrollContainer.h" | 
| 119 | #include "nsFontInflationData.h" | 
| 120 | #include "nsRegion.h" | 
| 121 | #include "nsIFrameInlines.h" | 
| 122 | #include "nsStyleChangeList.h" | 
| 123 | #include "nsWindowSizes.h" | 
| 124 | |
| 125 | #ifdef ACCESSIBILITY1 | 
| 126 | # include "nsAccessibilityService.h" | 
| 127 | #endif | 
| 128 | |
| 129 | #include "mozilla/AsyncEventDispatcher.h" | 
| 130 | #include "mozilla/CSSClipPathInstance.h" | 
| 131 | #include "mozilla/EffectCompositor.h" | 
| 132 | #include "mozilla/EffectSet.h" | 
| 133 | #include "mozilla/EventListenerManager.h" | 
| 134 | #include "mozilla/EventStateManager.h" | 
| 135 | #include "mozilla/Preferences.h" | 
| 136 | #include "mozilla/LookAndFeel.h" | 
| 137 | #include "mozilla/MouseEvents.h" | 
| 138 | #include "mozilla/ServoStyleSet.h" | 
| 139 | #include "mozilla/ServoStyleSetInlines.h" | 
| 140 | #include "mozilla/css/ImageLoader.h" | 
| 141 | #include "mozilla/dom/HTMLBodyElement.h" | 
| 142 | #include "mozilla/dom/SVGPathData.h" | 
| 143 | #include "mozilla/dom/TouchEvent.h" | 
| 144 | #include "mozilla/gfx/Tools.h" | 
| 145 | #include "mozilla/layers/WebRenderUserData.h" | 
| 146 | #include "mozilla/layout/ScrollAnchorContainer.h" | 
| 147 | #include "nsPrintfCString.h" | 
| 148 | #include "ActiveLayerTracker.h" | 
| 149 | |
| 150 | #include "nsITheme.h" | 
| 151 | |
| 152 | using namespace mozilla; | 
| 153 | using namespace mozilla::css; | 
| 154 | using namespace mozilla::dom; | 
| 155 | using namespace mozilla::gfx; | 
| 156 | using namespace mozilla::layers; | 
| 157 | using namespace mozilla::layout; | 
| 158 | typedef nsAbsoluteContainingBlock::AbsPosReflowFlags AbsPosReflowFlags; | 
| 159 | using nsStyleTransformMatrix::TransformReferenceBox; | 
| 160 | |
| 161 | nsIFrame* nsILineIterator::LineInfo::GetLastFrameOnLine() const { | 
| 162 | if (!mNumFramesOnLine) { | 
| 163 | return nullptr; // empty line, not illegal | 
| 164 | } | 
| 165 | MOZ_ASSERT(mFirstFrameOnLine)do { static_assert( mozilla::detail::AssertionConditionType< decltype(mFirstFrameOnLine)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(mFirstFrameOnLine))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mFirstFrameOnLine" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 165); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mFirstFrameOnLine" ")"); do { *((volatile int*)__null) = 165; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 166 | nsIFrame* maybeLastFrame = mFirstFrameOnLine; | 
| 167 | for ([[maybe_unused]] int32_t i : IntegerRange(mNumFramesOnLine - 1)) { | 
| 168 | maybeLastFrame = maybeLastFrame->GetNextSibling(); | 
| 169 | if (NS_WARN_IF(!maybeLastFrame)NS_warn_if_impl(!maybeLastFrame, "!maybeLastFrame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 169)) { | 
| 170 | return nullptr; | 
| 171 | } | 
| 172 | } | 
| 173 | return maybeLastFrame; | 
| 174 | } | 
| 175 | |
| 176 | #ifdef HAVE_64BIT_BUILD1 | 
| 177 | static_assert(sizeof(nsIFrame) == 120, "nsIFrame should remain small"); | 
| 178 | #else | 
| 179 | static_assert(sizeof(void*) == 4, "Odd build config?"); | 
| 180 | // FIXME(emilio): Investigate why win32 and android-arm32 have bigger sizes (80) | 
| 181 | // than Linux32 (76). | 
| 182 | static_assert(sizeof(nsIFrame) <= 80, "nsIFrame should remain small"); | 
| 183 | #endif | 
| 184 | |
| 185 | const mozilla::LayoutFrameType nsIFrame::sLayoutFrameTypes[kFrameClassCount] = { | 
| 186 | #define FRAME_ID(class_, type_, ...) mozilla::LayoutFrameType::type_, | 
| 187 | #define ABSTRACT_FRAME_ID(...) | 
| 188 | #include "mozilla/FrameIdList.h" | 
| 189 | #undef FRAME_ID | 
| 190 | #undef ABSTRACT_FRAME_ID | 
| 191 | }; | 
| 192 | |
| 193 | const nsIFrame::ClassFlags nsIFrame::sLayoutFrameClassFlags[kFrameClassCount] = | 
| 194 | { | 
| 195 | #define FRAME_ID(class_, type_, flags_, ...) flags_, | 
| 196 | #define ABSTRACT_FRAME_ID(...) | 
| 197 | #include "mozilla/FrameIdList.h" | 
| 198 | #undef FRAME_ID | 
| 199 | #undef ABSTRACT_FRAME_ID | 
| 200 | }; | 
| 201 | |
| 202 | std::ostream& operator<<(std::ostream& aStream, const nsDirection& aDirection) { | 
| 203 | return aStream << (aDirection == eDirNext ? "eDirNext" : "eDirPrevious"); | 
| 204 | } | 
| 205 | |
| 206 | struct nsContentAndOffset { | 
| 207 | nsIContent* mContent = nullptr; | 
| 208 | int32_t mOffset = 0; | 
| 209 | }; | 
| 210 | |
| 211 | #include "nsILineIterator.h" | 
| 212 | #include "prenv.h" | 
| 213 | |
| 214 | // Utility function to set a nsRect-valued property table entry on aFrame, | 
| 215 | // reusing the existing storage if the property happens to be already set. | 
| 216 | template <typename T> | 
| 217 | static void SetOrUpdateRectValuedProperty( | 
| 218 | nsIFrame* aFrame, FrameProperties::Descriptor<T> aProperty, | 
| 219 | const nsRect& aNewValue) { | 
| 220 | bool found; | 
| 221 | nsRect* rectStorage = aFrame->GetProperty(aProperty, &found); | 
| 222 | if (!found) { | 
| 223 | rectStorage = new nsRect(aNewValue); | 
| 224 | aFrame->AddProperty(aProperty, rectStorage); | 
| 225 | } else { | 
| 226 | *rectStorage = aNewValue; | 
| 227 | } | 
| 228 | } | 
| 229 | |
| 230 | FrameDestroyContext::~FrameDestroyContext() { | 
| 231 | for (auto& content : mozilla::Reversed(mAnonymousContent)) { | 
| 232 | mPresShell->NativeAnonymousContentWillBeRemoved(content); | 
| 233 | content->UnbindFromTree(); | 
| 234 | } | 
| 235 | } | 
| 236 | |
| 237 | // Formerly the nsIFrameDebug interface | 
| 238 | |
| 239 | std::ostream& operator<<(std::ostream& aStream, const nsReflowStatus& aStatus) { | 
| 240 | char complete = 'Y'; | 
| 241 | if (aStatus.IsIncomplete()) { | 
| 242 | complete = 'N'; | 
| 243 | } else if (aStatus.IsOverflowIncomplete()) { | 
| 244 | complete = 'O'; | 
| 245 | } | 
| 246 | |
| 247 | char brk = 'N'; | 
| 248 | if (aStatus.IsInlineBreakBefore()) { | 
| 249 | brk = 'B'; | 
| 250 | } else if (aStatus.IsInlineBreakAfter()) { | 
| 251 | brk = 'A'; | 
| 252 | } | 
| 253 | |
| 254 | aStream << "[" | 
| 255 | << "Complete=" << complete << "," | 
| 256 | << "NIF=" << (aStatus.NextInFlowNeedsReflow() ? 'Y' : 'N') << "," | 
| 257 | << "Break=" << brk << "," | 
| 258 | << "FirstLetter=" << (aStatus.FirstLetterComplete() ? 'Y' : 'N') | 
| 259 | << "]"; | 
| 260 | return aStream; | 
| 261 | } | 
| 262 | |
| 263 | #ifdef DEBUG1 | 
| 264 | |
| 265 | /** | 
| 266 | * Note: the log module is created during library initialization which | 
| 267 | * means that you cannot perform logging before then. | 
| 268 | */ | 
| 269 | mozilla::LazyLogModule nsIFrame::sFrameLogModule("frame"); | 
| 270 | |
| 271 | #endif | 
| 272 | |
| 273 | NS_DECLARE_FRAME_PROPERTY_DELETABLE(AbsoluteContainingBlockProperty,static const mozilla::FramePropertyDescriptor<nsAbsoluteContainingBlock >* AbsoluteContainingBlockProperty() { static const auto descriptor = mozilla::FramePropertyDescriptor<nsAbsoluteContainingBlock >::NewWithDestructor<DeleteValue>(); return &descriptor ; } | 
| 274 | nsAbsoluteContainingBlock)static const mozilla::FramePropertyDescriptor<nsAbsoluteContainingBlock >* AbsoluteContainingBlockProperty() { static const auto descriptor = mozilla::FramePropertyDescriptor<nsAbsoluteContainingBlock >::NewWithDestructor<DeleteValue>(); return &descriptor ; } | 
| 275 | |
| 276 | bool nsIFrame::HasAbsolutelyPositionedChildren() const { | 
| 277 | return IsAbsoluteContainer() && | 
| 278 | GetAbsoluteContainingBlock()->HasAbsoluteFrames(); | 
| 279 | } | 
| 280 | |
| 281 | nsAbsoluteContainingBlock* nsIFrame::GetAbsoluteContainingBlock() const { | 
| 282 | NS_ASSERTION(IsAbsoluteContainer(),do { if (!(IsAbsoluteContainer())) { NS_DebugBreak(NS_DEBUG_ASSERTION , "The frame is not marked as an abspos container correctly", "IsAbsoluteContainer()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 283); MOZ_PretendNoReturn(); } } while (0) | 
| 283 | "The frame is not marked as an abspos container correctly")do { if (!(IsAbsoluteContainer())) { NS_DebugBreak(NS_DEBUG_ASSERTION , "The frame is not marked as an abspos container correctly", "IsAbsoluteContainer()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 283); MOZ_PretendNoReturn(); } } while (0); | 
| 284 | nsAbsoluteContainingBlock* absCB = | 
| 285 | GetProperty(AbsoluteContainingBlockProperty()); | 
| 286 | NS_ASSERTION(absCB,do { if (!(absCB)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "The frame is marked as an abspos container but doesn't have " "the property", "absCB", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 288); MOZ_PretendNoReturn(); } } while (0) | 
| 287 | "The frame is marked as an abspos container but doesn't have "do { if (!(absCB)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "The frame is marked as an abspos container but doesn't have " "the property", "absCB", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 288); MOZ_PretendNoReturn(); } } while (0) | 
| 288 | "the property")do { if (!(absCB)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "The frame is marked as an abspos container but doesn't have " "the property", "absCB", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 288); MOZ_PretendNoReturn(); } } while (0); | 
| 289 | return absCB; | 
| 290 | } | 
| 291 | |
| 292 | void nsIFrame::MarkAsAbsoluteContainingBlock() { | 
| 293 | MOZ_ASSERT(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN))do { static_assert( mozilla::detail::AssertionConditionType< decltype(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN))> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN))) ), 0))) { do { } while (false); MOZ_ReportAssertionFailure("HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 293); AnnotateMozCrashReason("MOZ_ASSERT" "(" "HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)" ")"); do { *((volatile int*)__null) = 293; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 294 | NS_ASSERTION(!GetProperty(AbsoluteContainingBlockProperty()),do { if (!(!GetProperty(AbsoluteContainingBlockProperty()))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Already has an abs-pos containing block property?" , "!GetProperty(AbsoluteContainingBlockProperty())", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 295); MOZ_PretendNoReturn(); } } while (0) | 
| 295 | "Already has an abs-pos containing block property?")do { if (!(!GetProperty(AbsoluteContainingBlockProperty()))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Already has an abs-pos containing block property?" , "!GetProperty(AbsoluteContainingBlockProperty())", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 295); MOZ_PretendNoReturn(); } } while (0); | 
| 296 | NS_ASSERTION(!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN),do { if (!(!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Already has NS_FRAME_HAS_ABSPOS_CHILDREN state bit?" , "!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 297); MOZ_PretendNoReturn(); } } while (0) | 
| 297 | "Already has NS_FRAME_HAS_ABSPOS_CHILDREN state bit?")do { if (!(!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Already has NS_FRAME_HAS_ABSPOS_CHILDREN state bit?" , "!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 297); MOZ_PretendNoReturn(); } } while (0); | 
| 298 | AddStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN); | 
| 299 | SetProperty(AbsoluteContainingBlockProperty(), | 
| 300 | new nsAbsoluteContainingBlock(GetAbsoluteListID())); | 
| 301 | } | 
| 302 | |
| 303 | void nsIFrame::MarkAsNotAbsoluteContainingBlock() { | 
| 304 | NS_ASSERTION(!HasAbsolutelyPositionedChildren(), "Think of the children!")do { if (!(!HasAbsolutelyPositionedChildren())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Think of the children!", "!HasAbsolutelyPositionedChildren()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 304); MOZ_PretendNoReturn(); } } while (0); | 
| 305 | NS_ASSERTION(GetProperty(AbsoluteContainingBlockProperty()),do { if (!(GetProperty(AbsoluteContainingBlockProperty()))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Should have an abs-pos containing block property" , "GetProperty(AbsoluteContainingBlockProperty())", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 306); MOZ_PretendNoReturn(); } } while (0) | 
| 306 | "Should have an abs-pos containing block property")do { if (!(GetProperty(AbsoluteContainingBlockProperty()))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Should have an abs-pos containing block property" , "GetProperty(AbsoluteContainingBlockProperty())", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 306); MOZ_PretendNoReturn(); } } while (0); | 
| 307 | NS_ASSERTION(HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN),do { if (!(HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN))) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Should have NS_FRAME_HAS_ABSPOS_CHILDREN state bit" , "HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 308); MOZ_PretendNoReturn(); } } while (0) | 
| 308 | "Should have NS_FRAME_HAS_ABSPOS_CHILDREN state bit")do { if (!(HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN))) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Should have NS_FRAME_HAS_ABSPOS_CHILDREN state bit" , "HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 308); MOZ_PretendNoReturn(); } } while (0); | 
| 309 | MOZ_ASSERT(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN))do { static_assert( mozilla::detail::AssertionConditionType< decltype(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN))> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN))) ), 0))) { do { } while (false); MOZ_ReportAssertionFailure("HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 309); AnnotateMozCrashReason("MOZ_ASSERT" "(" "HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)" ")"); do { *((volatile int*)__null) = 309; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 310 | RemoveStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN); | 
| 311 | RemoveProperty(AbsoluteContainingBlockProperty()); | 
| 312 | } | 
| 313 | |
| 314 | bool nsIFrame::CheckAndClearPaintedState() { | 
| 315 | bool result = HasAnyStateBits(NS_FRAME_PAINTED_THEBES); | 
| 316 | RemoveStateBits(NS_FRAME_PAINTED_THEBES); | 
| 317 | |
| 318 | for (const auto& childList : ChildLists()) { | 
| 319 | for (nsIFrame* child : childList.mList) { | 
| 320 | if (child->CheckAndClearPaintedState()) { | 
| 321 | result = true; | 
| 322 | } | 
| 323 | } | 
| 324 | } | 
| 325 | return result; | 
| 326 | } | 
| 327 | |
| 328 | nsIFrame* nsIFrame::FindLineContainer() const { | 
| 329 | MOZ_ASSERT(IsLineParticipant())do { static_assert( mozilla::detail::AssertionConditionType< decltype(IsLineParticipant())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(IsLineParticipant()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsLineParticipant()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 329); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsLineParticipant()" ")"); do { *((volatile int*)__null) = 329; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 330 | nsIFrame* parent = GetParent(); | 
| 331 | while (parent && | 
| 332 | (parent->IsLineParticipant() || parent->CanContinueTextRun())) { | 
| 333 | parent = parent->GetParent(); | 
| 334 | } | 
| 335 | return parent; | 
| 336 | } | 
| 337 | |
| 338 | bool nsIFrame::CheckAndClearDisplayListState() { | 
| 339 | bool result = BuiltDisplayList(); | 
| 340 | SetBuiltDisplayList(false); | 
| 341 | |
| 342 | for (const auto& childList : ChildLists()) { | 
| 343 | for (nsIFrame* child : childList.mList) { | 
| 344 | if (child->CheckAndClearDisplayListState()) { | 
| 345 | result = true; | 
| 346 | } | 
| 347 | } | 
| 348 | } | 
| 349 | return result; | 
| 350 | } | 
| 351 | |
| 352 | bool nsIFrame::IsVisibleConsideringAncestors(uint32_t aFlags) const { | 
| 353 | if (!StyleVisibility()->IsVisible()) { | 
| 354 | return false; | 
| 355 | } | 
| 356 | |
| 357 | if (PresShell()->IsUnderHiddenEmbedderElement()) { | 
| 358 | return false; | 
| 359 | } | 
| 360 | |
| 361 | const nsIFrame* frame = this; | 
| 362 | while (frame) { | 
| 363 | nsView* view = frame->GetView(); | 
| 364 | if (view && view->GetVisibility() == ViewVisibility::Hide) { | 
| 365 | return false; | 
| 366 | } | 
| 367 | |
| 368 | if (frame->StyleUIReset()->mMozSubtreeHiddenOnlyVisually) { | 
| 369 | return false; | 
| 370 | } | 
| 371 | |
| 372 | // This method is used to determine if a frame is focusable, because it's | 
| 373 | // called by nsIFrame::IsFocusable. `content-visibility: auto` should not | 
| 374 | // force this frame to be unfocusable, so we only take into account | 
| 375 | // `content-visibility: hidden` here. | 
| 376 | if (this != frame && | 
| 377 | frame->HidesContent(IncludeContentVisibility::Hidden)) { | 
| 378 | return false; | 
| 379 | } | 
| 380 | |
| 381 | if (nsIFrame* parent = frame->GetParent()) { | 
| 382 | frame = parent; | 
| 383 | } else { | 
| 384 | parent = nsLayoutUtils::GetCrossDocParentFrameInProcess(frame); | 
| 385 | if (!parent) { | 
| 386 | break; | 
| 387 | } | 
| 388 | |
| 389 | if ((aFlags & nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY) == 0 && | 
| 390 | parent->PresContext()->IsChrome() && | 
| 391 | !frame->PresContext()->IsChrome()) { | 
| 392 | break; | 
| 393 | } | 
| 394 | |
| 395 | frame = parent; | 
| 396 | } | 
| 397 | } | 
| 398 | |
| 399 | return true; | 
| 400 | } | 
| 401 | |
| 402 | void nsIFrame::FindCloserFrameForSelection( | 
| 403 | const nsPoint& aPoint, FrameWithDistance* aCurrentBestFrame) { | 
| 404 | if (nsLayoutUtils::PointIsCloserToRect(aPoint, mRect, | 
| 405 | aCurrentBestFrame->mXDistance, | 
| 406 | aCurrentBestFrame->mYDistance)) { | 
| 407 | aCurrentBestFrame->mFrame = this; | 
| 408 | } | 
| 409 | } | 
| 410 | |
| 411 | void nsIFrame::ElementStateChanged(mozilla::dom::ElementState aStates) {} | 
| 412 | |
| 413 | void WeakFrame::Clear(mozilla::PresShell* aPresShell) { | 
| 414 | if (aPresShell) { | 
| 415 | aPresShell->RemoveWeakFrame(this); | 
| 416 | } | 
| 417 | mFrame = nullptr; | 
| 418 | } | 
| 419 | |
| 420 | AutoWeakFrame::AutoWeakFrame(const WeakFrame& aOther) | 
| 421 | : mPrev(nullptr), mFrame(nullptr) { | 
| 422 | Init(aOther.GetFrame()); | 
| 423 | } | 
| 424 | |
| 425 | void AutoWeakFrame::Clear(mozilla::PresShell* aPresShell) { | 
| 426 | if (aPresShell) { | 
| 427 | aPresShell->RemoveAutoWeakFrame(this); | 
| 428 | } | 
| 429 | mFrame = nullptr; | 
| 430 | mPrev = nullptr; | 
| 431 | } | 
| 432 | |
| 433 | AutoWeakFrame::~AutoWeakFrame() { | 
| 434 | Clear(mFrame ? mFrame->PresContext()->GetPresShell() : nullptr); | 
| 435 | } | 
| 436 | |
| 437 | void AutoWeakFrame::Init(nsIFrame* aFrame) { | 
| 438 | Clear(mFrame ? mFrame->PresContext()->GetPresShell() : nullptr); | 
| 439 | mFrame = aFrame; | 
| 440 | if (mFrame) { | 
| 441 | mozilla::PresShell* presShell = mFrame->PresContext()->GetPresShell(); | 
| 442 | NS_WARNING_ASSERTION(presShell, "Null PresShell in AutoWeakFrame!")do { if (!(presShell)) { NS_DebugBreak(NS_DEBUG_WARNING, "Null PresShell in AutoWeakFrame!" , "presShell", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 442); } } while (false); | 
| 443 | if (presShell) { | 
| 444 | presShell->AddAutoWeakFrame(this); | 
| 445 | } else { | 
| 446 | mFrame = nullptr; | 
| 447 | } | 
| 448 | } | 
| 449 | } | 
| 450 | |
| 451 | void WeakFrame::Init(nsIFrame* aFrame) { | 
| 452 | Clear(mFrame ? mFrame->PresContext()->GetPresShell() : nullptr); | 
| 453 | mFrame = aFrame; | 
| 454 | if (mFrame) { | 
| 455 | mozilla::PresShell* presShell = mFrame->PresContext()->GetPresShell(); | 
| 456 | MOZ_ASSERT(presShell, "Null PresShell in WeakFrame!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(presShell)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(presShell))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("presShell" " (" "Null PresShell in WeakFrame!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 456); AnnotateMozCrashReason("MOZ_ASSERT" "(" "presShell" ") (" "Null PresShell in WeakFrame!" ")"); do { *((volatile int*)__null ) = 456; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 457 | if (presShell) { | 
| 458 | presShell->AddWeakFrame(this); | 
| 459 | } else { | 
| 460 | mFrame = nullptr; | 
| 461 | } | 
| 462 | } | 
| 463 | } | 
| 464 | |
| 465 | nsIFrame* NS_NewEmptyFrame(PresShell* aPresShell, ComputedStyle* aStyle) { | 
| 466 | return new (aPresShell) nsIFrame(aStyle, aPresShell->GetPresContext()); | 
| 467 | } | 
| 468 | |
| 469 | nsIFrame::~nsIFrame() { | 
| 470 | MOZ_COUNT_DTOR(nsIFrame)do { static_assert(std::is_class_v<nsIFrame>, "Token '" "nsIFrame" "' is not a class type."); static_assert(!std::is_base_of <nsISupports, nsIFrame>::value, "nsISupports classes don't need to call MOZ_COUNT_CTOR or " "MOZ_COUNT_DTOR");; NS_LogDtor((void*)this, "nsIFrame", sizeof (*this)); } while (0); | 
| 471 | |
| 472 | MOZ_ASSERT(GetVisibility() != Visibility::ApproximatelyVisible,do { static_assert( mozilla::detail::AssertionConditionType< decltype(GetVisibility() != Visibility::ApproximatelyVisible) >::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(GetVisibility() != Visibility::ApproximatelyVisible) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("GetVisibility() != Visibility::ApproximatelyVisible" " (" "Visible nsFrame is being destroyed" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 473); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetVisibility() != Visibility::ApproximatelyVisible" ") (" "Visible nsFrame is being destroyed" ")"); do { *((volatile int*)__null) = 473; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) | 
| 473 | "Visible nsFrame is being destroyed")do { static_assert( mozilla::detail::AssertionConditionType< decltype(GetVisibility() != Visibility::ApproximatelyVisible) >::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(GetVisibility() != Visibility::ApproximatelyVisible) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("GetVisibility() != Visibility::ApproximatelyVisible" " (" "Visible nsFrame is being destroyed" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 473); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetVisibility() != Visibility::ApproximatelyVisible" ") (" "Visible nsFrame is being destroyed" ")"); do { *((volatile int*)__null) = 473; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 474 | } | 
| 475 | |
| 476 | NS_IMPL_FRAMEARENA_HELPERS(nsIFrame)void* nsIFrame ::operator new(size_t sz, mozilla::PresShell * aShell) { return aShell->AllocateFrame(nsQueryFrame::nsIFrame_id , sz); } | 
| 477 | |
| 478 | // Dummy operator delete. Will never be called, but must be defined | 
| 479 | // to satisfy some C++ ABIs. | 
| 480 | void nsIFrame::operator delete(void*, size_t) { | 
| 481 | MOZ_CRASH("nsIFrame::operator delete should never be called")do { do { } while (false); MOZ_ReportCrash("" "nsIFrame::operator delete should never be called" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 481); AnnotateMozCrashReason("MOZ_CRASH(" "nsIFrame::operator delete should never be called" ")"); do { *((volatile int*)__null) = 481; __attribute__((nomerge )) ::abort(); } while (false); } while (false); | 
| 482 | } | 
| 483 | |
| 484 | NS_QUERYFRAME_HEAD(nsIFrame)void* nsIFrame ::QueryFrame(FrameIID id) const { switch (id) { | 
| 485 | NS_QUERYFRAME_ENTRY(nsIFrame)case nsIFrame ::kFrameIID: { static_assert( std::is_same_v< nsIFrame, nsIFrame ::Has_NS_DECL_QUERYFRAME_TARGET>, "nsIFrame" " must declare itself as a queryframe target"); return const_cast <nsIFrame*>(static_cast<const nsIFrame*>(this)); } | 
| 486 | NS_QUERYFRAME_TAIL_INHERITANCE_ROOTdefault: break; } do { static_assert( mozilla::detail::AssertionConditionType <decltype(id != GetFrameId())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(id != GetFrameId()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("id != GetFrameId()" " (" "A frame failed to QueryFrame to its *own type*. " "It may be missing NS_DECL_QUERYFRAME, or a " "NS_QUERYFRAME_ENTRY() line with its own type name" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 486); AnnotateMozCrashReason("MOZ_ASSERT" "(" "id != GetFrameId()" ") (" "A frame failed to QueryFrame to its *own type*. " "It may be missing NS_DECL_QUERYFRAME, or a " "NS_QUERYFRAME_ENTRY() line with its own type name" ")"); do { *((volatile int*)__null) = 486; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); return nullptr; } | 
| 487 | |
| 488 | ///////////////////////////////////////////////////////////////////////////// | 
| 489 | // nsIFrame | 
| 490 | |
| 491 | static bool IsFontSizeInflationContainer(nsIFrame* aFrame, | 
| 492 | const nsStyleDisplay* aStyleDisplay) { | 
| 493 | /* | 
| 494 | * Font size inflation is built around the idea that we're inflating | 
| 495 | * the fonts for a pan-and-zoom UI so that when the user scales up a | 
| 496 | * block or other container to fill the width of the device, the fonts | 
| 497 | * will be readable. To do this, we need to pick what counts as a | 
| 498 | * container. | 
| 499 | * | 
| 500 | * From a code perspective, the only hard requirement is that frames | 
| 501 | * that are line participants (nsIFrame::IsLineParticipant) are never | 
| 502 | * containers, since line layout assumes that the inflation is consistent | 
| 503 | * within a line. | 
| 504 | * | 
| 505 | * This is not an imposition, since we obviously want a bunch of text | 
| 506 | * (possibly with inline elements) flowing within a block to count the | 
| 507 | * block (or higher) as its container. | 
| 508 | * | 
| 509 | * We also want form controls, including the text in the anonymous | 
| 510 | * content inside of them, to match each other and the text next to | 
| 511 | * them, so they and their anonymous content should also not be a | 
| 512 | * container. | 
| 513 | * | 
| 514 | * However, because we can't reliably compute sizes across XUL during | 
| 515 | * reflow, any XUL frame with a XUL parent is always a container. | 
| 516 | * | 
| 517 | * There are contexts where it would be nice if some blocks didn't | 
| 518 | * count as a container, so that, for example, an indented quotation | 
| 519 | * didn't end up with a smaller font size. However, it's hard to | 
| 520 | * distinguish these situations where we really do want the indented | 
| 521 | * thing to count as a container, so we don't try, and blocks are | 
| 522 | * always containers. | 
| 523 | */ | 
| 524 | |
| 525 | // The root frame should always be an inflation container. | 
| 526 | if (!aFrame->GetParent()) { | 
| 527 | return true; | 
| 528 | } | 
| 529 | |
| 530 | nsIContent* content = aFrame->GetContent(); | 
| 531 | if (content && content->IsInNativeAnonymousSubtree()) { | 
| 532 | // Native anonymous content shouldn't be a font inflation root, | 
| 533 | // except for the canvas custom content container. | 
| 534 | nsCanvasFrame* canvas = aFrame->PresShell()->GetCanvasFrame(); | 
| 535 | return canvas && canvas->GetCustomContentContainer() == content; | 
| 536 | } | 
| 537 | |
| 538 | LayoutFrameType frameType = aFrame->Type(); | 
| 539 | bool isInline = | 
| 540 | aFrame->GetDisplay().IsInlineFlow() || RubyUtils::IsRubyBox(frameType) || | 
| 541 | (aStyleDisplay->IsFloatingStyle() && | 
| 542 | frameType == LayoutFrameType::Letter) || | 
| 543 | // Given multiple frames for the same node, only the | 
| 544 | // outer one should be considered a container. | 
| 545 | // (Important, e.g., for nsSelectsAreaFrame.) | 
| 546 | (aFrame->GetParent()->GetContent() == content) || | 
| 547 | (content && | 
| 548 | // Form controls shouldn't become inflation containers. | 
| 549 | (content->IsAnyOfHTMLElements(nsGkAtoms::option, nsGkAtoms::optgroup, | 
| 550 | nsGkAtoms::select, nsGkAtoms::input, | 
| 551 | nsGkAtoms::button, nsGkAtoms::textarea))); | 
| 552 | NS_ASSERTION(!aFrame->IsLineParticipant() || isInline ||do { if (!(!aFrame->IsLineParticipant() || isInline || aFrame ->IsBrFrame() || aFrame->IsMathMLFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "line participants must not be containers" , "!aFrame->IsLineParticipant() || isInline || aFrame->IsBrFrame() || aFrame->IsMathMLFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 557); MOZ_PretendNoReturn(); } } while (0) | 
| 553 | // br frames and mathml frames report being linedo { if (!(!aFrame->IsLineParticipant() || isInline || aFrame ->IsBrFrame() || aFrame->IsMathMLFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "line participants must not be containers" , "!aFrame->IsLineParticipant() || isInline || aFrame->IsBrFrame() || aFrame->IsMathMLFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 557); MOZ_PretendNoReturn(); } } while (0) | 
| 554 | // participants even when their position or display isdo { if (!(!aFrame->IsLineParticipant() || isInline || aFrame ->IsBrFrame() || aFrame->IsMathMLFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "line participants must not be containers" , "!aFrame->IsLineParticipant() || isInline || aFrame->IsBrFrame() || aFrame->IsMathMLFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 557); MOZ_PretendNoReturn(); } } while (0) | 
| 555 | // setdo { if (!(!aFrame->IsLineParticipant() || isInline || aFrame ->IsBrFrame() || aFrame->IsMathMLFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "line participants must not be containers" , "!aFrame->IsLineParticipant() || isInline || aFrame->IsBrFrame() || aFrame->IsMathMLFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 557); MOZ_PretendNoReturn(); } } while (0) | 
| 556 | aFrame->IsBrFrame() || aFrame->IsMathMLFrame(),do { if (!(!aFrame->IsLineParticipant() || isInline || aFrame ->IsBrFrame() || aFrame->IsMathMLFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "line participants must not be containers" , "!aFrame->IsLineParticipant() || isInline || aFrame->IsBrFrame() || aFrame->IsMathMLFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 557); MOZ_PretendNoReturn(); } } while (0) | 
| 557 | "line participants must not be containers")do { if (!(!aFrame->IsLineParticipant() || isInline || aFrame ->IsBrFrame() || aFrame->IsMathMLFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "line participants must not be containers" , "!aFrame->IsLineParticipant() || isInline || aFrame->IsBrFrame() || aFrame->IsMathMLFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 557); MOZ_PretendNoReturn(); } } while (0); | 
| 558 | return !isInline; | 
| 559 | } | 
| 560 | |
| 561 | static void MaybeScheduleReflowSVGNonDisplayText(nsIFrame* aFrame) { | 
| 562 | if (!aFrame->IsInSVGTextSubtree()) { | 
| 563 | return; | 
| 564 | } | 
| 565 | |
| 566 | // We need to ensure that any non-display SVGTextFrames get reflowed when a | 
| 567 | // child text frame gets new style. Thus we need to schedule a reflow in | 
| 568 | // |DidSetComputedStyle|. We also need to call it from |DestroyFrom|, | 
| 569 | // because otherwise we won't get notified when style changes to | 
| 570 | // "display:none". | 
| 571 | SVGTextFrame* svgTextFrame = static_cast<SVGTextFrame*>( | 
| 572 | nsLayoutUtils::GetClosestFrameOfType(aFrame, LayoutFrameType::SVGText)); | 
| 573 | nsIFrame* anonBlock = svgTextFrame->PrincipalChildList().FirstChild(); | 
| 574 | |
| 575 | // Note that we must check NS_FRAME_FIRST_REFLOW on our SVGTextFrame's | 
| 576 | // anonymous block frame rather than our aFrame, since NS_FRAME_FIRST_REFLOW | 
| 577 | // may be set on us if we're a new frame that has been inserted after the | 
| 578 | // document's first reflow. (In which case this DidSetComputedStyle call may | 
| 579 | // be happening under frame construction under a Reflow() call.) | 
| 580 | if (!anonBlock || anonBlock->HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) { | 
| 581 | return; | 
| 582 | } | 
| 583 | |
| 584 | if (!svgTextFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) || | 
| 585 | svgTextFrame->HasAnyStateBits(NS_STATE_SVG_TEXT_IN_REFLOW)) { | 
| 586 | return; | 
| 587 | } | 
| 588 | |
| 589 | svgTextFrame->ScheduleReflowSVGNonDisplayText( | 
| 590 | IntrinsicDirty::FrameAncestorsAndDescendants); | 
| 591 | } | 
| 592 | |
| 593 | bool nsIFrame::ShouldPropagateRepaintsToRoot() const { | 
| 594 | if (!IsPrimaryFrame()) { | 
| 595 | // special case for table frames because style images are associated to the | 
| 596 | // table frame, but the table wrapper frame is the primary frame | 
| 597 | if (IsTableFrame()) { | 
| 598 | MOZ_ASSERT(GetParent() && GetParent()->IsTableWrapperFrame())do { static_assert( mozilla::detail::AssertionConditionType< decltype(GetParent() && GetParent()->IsTableWrapperFrame ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(GetParent() && GetParent()->IsTableWrapperFrame ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("GetParent() && GetParent()->IsTableWrapperFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 598); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetParent() && GetParent()->IsTableWrapperFrame()" ")"); do { *((volatile int*)__null) = 598; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 599 | return GetParent()->ShouldPropagateRepaintsToRoot(); | 
| 600 | } | 
| 601 | |
| 602 | return false; | 
| 603 | } | 
| 604 | nsIContent* content = GetContent(); | 
| 605 | Document* document = content->OwnerDoc(); | 
| 606 | return content == document->GetRootElement() || | 
| 607 | content == document->GetBodyElement(); | 
| 608 | } | 
| 609 | |
| 610 | bool nsIFrame::IsRenderedLegend() const { | 
| 611 | if (auto* parent = GetParent(); parent && parent->IsFieldSetFrame()) { | 
| 612 | return static_cast<nsFieldSetFrame*>(parent)->GetLegend() == this; | 
| 613 | } | 
| 614 | return false; | 
| 615 | } | 
| 616 | |
| 617 | void nsIFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, | 
| 618 | nsIFrame* aPrevInFlow) { | 
| 619 | MOZ_ASSERT(nsQueryFrame::FrameIID(mClass) == GetFrameId())do { static_assert( mozilla::detail::AssertionConditionType< decltype(nsQueryFrame::FrameIID(mClass) == GetFrameId())>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(nsQueryFrame::FrameIID(mClass) == GetFrameId()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("nsQueryFrame::FrameIID(mClass) == GetFrameId()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 619); AnnotateMozCrashReason("MOZ_ASSERT" "(" "nsQueryFrame::FrameIID(mClass) == GetFrameId()" ")"); do { *((volatile int*)__null) = 619; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 620 | MOZ_ASSERT(!mContent, "Double-initing a frame?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mContent)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mContent))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mContent" " (" "Double-initing a frame?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 620); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mContent" ") (" "Double-initing a frame?" ")"); do { *((volatile int*)__null ) = 620; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 621 | |
| 622 | mContent = aContent; | 
| 623 | mParent = aParent; | 
| 624 | MOZ_ASSERT(!mParent || PresShell() == mParent->PresShell())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mParent || PresShell() == mParent->PresShell())> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!mParent || PresShell() == mParent->PresShell())) ), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mParent || PresShell() == mParent->PresShell()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 624); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mParent || PresShell() == mParent->PresShell()" ")"); do { *((volatile int*)__null) = 624; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 625 | |
| 626 | if (aPrevInFlow) { | 
| 627 | mWritingMode = aPrevInFlow->GetWritingMode(); | 
| 628 | |
| 629 | // Copy some state bits from prev-in-flow (the bits that should apply | 
| 630 | // throughout a continuation chain). The bits are sorted according to their | 
| 631 | // order in nsFrameStateBits.h. | 
| 632 | |
| 633 | // clang-format off | 
| 634 | AddStateBits(aPrevInFlow->GetStateBits() & | 
| 635 | (NS_FRAME_GENERATED_CONTENT | | 
| 636 | NS_FRAME_OUT_OF_FLOW | | 
| 637 | NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN | | 
| 638 | NS_FRAME_INDEPENDENT_SELECTION | | 
| 639 | NS_FRAME_PART_OF_IBSPLIT | | 
| 640 | NS_FRAME_MAY_BE_TRANSFORMED | | 
| 641 | NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR)); | 
| 642 | // clang-format on | 
| 643 | |
| 644 | // Copy other bits in nsIFrame from prev-in-flow. | 
| 645 | mHasColumnSpanSiblings = aPrevInFlow->HasColumnSpanSiblings(); | 
| 646 | } else { | 
| 647 | PresContext()->ConstructedFrame(); | 
| 648 | } | 
| 649 | |
| 650 | if (GetParent()) { | 
| 651 | if (MOZ_UNLIKELY(mContent == PresContext()->Document()->GetRootElement() &&(__builtin_expect(!!(mContent == PresContext()->Document() ->GetRootElement() && mContent == GetParent()-> GetContent()), 0)) | 
| 652 | mContent == GetParent()->GetContent())(__builtin_expect(!!(mContent == PresContext()->Document() ->GetRootElement() && mContent == GetParent()-> GetContent()), 0))) { | 
| 653 | // Our content is the root element and we have the same content as our | 
| 654 | // parent. That is, we are the internal anonymous frame of the root | 
| 655 | // element. Copy the used mWritingMode from our parent because | 
| 656 | // mDocElementContainingBlock gets its mWritingMode from <body>. | 
| 657 | mWritingMode = GetParent()->GetWritingMode(); | 
| 658 | } | 
| 659 | |
| 660 | // Copy some state bits from our parent (the bits that should apply | 
| 661 | // recursively throughout a subtree). The bits are sorted according to their | 
| 662 | // order in nsFrameStateBits.h. | 
| 663 | |
| 664 | // clang-format off | 
| 665 | AddStateBits(GetParent()->GetStateBits() & | 
| 666 | (NS_FRAME_GENERATED_CONTENT | | 
| 667 | NS_FRAME_INDEPENDENT_SELECTION | | 
| 668 | NS_FRAME_IS_SVG_TEXT | | 
| 669 | NS_FRAME_IN_POPUP | | 
| 670 | NS_FRAME_IS_NONDISPLAY)); | 
| 671 | // clang-format on | 
| 672 | |
| 673 | if (HasAnyStateBits(NS_FRAME_IN_POPUP) && TrackingVisibility()) { | 
| 674 | // Assume all frames in popups are visible. | 
| 675 | IncApproximateVisibleCount(); | 
| 676 | } | 
| 677 | } | 
| 678 | if (aPrevInFlow) { | 
| 679 | mMayHaveOpacityAnimation = aPrevInFlow->MayHaveOpacityAnimation(); | 
| 680 | mMayHaveTransformAnimation = aPrevInFlow->MayHaveTransformAnimation(); | 
| 681 | } else if (mContent) { | 
| 682 | // It's fine to fetch the EffectSet for the style frame here because in the | 
| 683 | // following code we take care of the case where animations may target | 
| 684 | // a different frame. | 
| 685 | EffectSet* effectSet = EffectSet::GetForStyleFrame(this); | 
| 686 | if (effectSet) { | 
| 687 | mMayHaveOpacityAnimation = effectSet->MayHaveOpacityAnimation(); | 
| 688 | |
| 689 | if (effectSet->MayHaveTransformAnimation()) { | 
| 690 | // If we are the inner table frame for display:table content, then | 
| 691 | // transform animations should go on our parent frame (the table wrapper | 
| 692 | // frame). | 
| 693 | // | 
| 694 | // We do this when initializing the child frame (table inner frame), | 
| 695 | // because when initializng the table wrapper frame, we don't yet have | 
| 696 | // access to its children so we can't tell if we have transform | 
| 697 | // animations or not. | 
| 698 | if (SupportsCSSTransforms()) { | 
| 699 | mMayHaveTransformAnimation = true; | 
| 700 | AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED); | 
| 701 | } else if (aParent && nsLayoutUtils::GetStyleFrame(aParent) == this) { | 
| 702 | MOZ_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType< decltype(aParent->SupportsCSSTransforms())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aParent->SupportsCSSTransforms ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aParent->SupportsCSSTransforms()" " (" "Style frames that don't support transforms should have parents" " that do" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 705); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aParent->SupportsCSSTransforms()" ") (" "Style frames that don't support transforms should have parents" " that do" ")"); do { *((volatile int*)__null) = 705; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 703 | aParent->SupportsCSSTransforms(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(aParent->SupportsCSSTransforms())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aParent->SupportsCSSTransforms ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aParent->SupportsCSSTransforms()" " (" "Style frames that don't support transforms should have parents" " that do" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 705); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aParent->SupportsCSSTransforms()" ") (" "Style frames that don't support transforms should have parents" " that do" ")"); do { *((volatile int*)__null) = 705; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 704 | "Style frames that don't support transforms should have parents"do { static_assert( mozilla::detail::AssertionConditionType< decltype(aParent->SupportsCSSTransforms())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aParent->SupportsCSSTransforms ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aParent->SupportsCSSTransforms()" " (" "Style frames that don't support transforms should have parents" " that do" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 705); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aParent->SupportsCSSTransforms()" ") (" "Style frames that don't support transforms should have parents" " that do" ")"); do { *((volatile int*)__null) = 705; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 705 | " that do")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aParent->SupportsCSSTransforms())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aParent->SupportsCSSTransforms ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aParent->SupportsCSSTransforms()" " (" "Style frames that don't support transforms should have parents" " that do" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 705); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aParent->SupportsCSSTransforms()" ") (" "Style frames that don't support transforms should have parents" " that do" ")"); do { *((volatile int*)__null) = 705; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | 
| 706 | aParent->mMayHaveTransformAnimation = true; | 
| 707 | aParent->AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED); | 
| 708 | } | 
| 709 | } | 
| 710 | } | 
| 711 | } | 
| 712 | |
| 713 | const nsStyleDisplay* disp = StyleDisplay(); | 
| 714 | if (disp->HasTransform(this)) { | 
| 715 | // If 'transform' dynamically changes, RestyleManager takes care of | 
| 716 | // updating this bit. | 
| 717 | AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED); | 
| 718 | } | 
| 719 | |
| 720 | if (nsLayoutUtils::FontSizeInflationEnabled(PresContext()) || | 
| 721 | !GetParent() | 
| 722 | #ifdef DEBUG1 | 
| 723 | // We have assertions that check inflation invariants even when | 
| 724 | // font size inflation is not enabled. | 
| 725 | || true | 
| 726 | #endif | 
| 727 | ) { | 
| 728 | if (IsFontSizeInflationContainer(this, disp)) { | 
| 729 | AddStateBits(NS_FRAME_FONT_INFLATION_CONTAINER); | 
| 730 | if (!GetParent() || | 
| 731 | // I'd use NS_FRAME_OUT_OF_FLOW, but it's not set yet. | 
| 732 | disp->IsFloating(this) || disp->IsAbsolutelyPositioned(this) || | 
| 733 | GetParent()->IsFlexContainerFrame() || | 
| 734 | GetParent()->IsGridContainerFrame()) { | 
| 735 | AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT); | 
| 736 | } | 
| 737 | } | 
| 738 | NS_ASSERTION(do { if (!(GetParent() || HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "root frame should always be a container" , "GetParent() || HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 740); MOZ_PretendNoReturn(); } } while (0) | 
| 739 | GetParent() || HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER),do { if (!(GetParent() || HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "root frame should always be a container" , "GetParent() || HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 740); MOZ_PretendNoReturn(); } } while (0) | 
| 740 | "root frame should always be a container")do { if (!(GetParent() || HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "root frame should always be a container" , "GetParent() || HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 740); MOZ_PretendNoReturn(); } } while (0); | 
| 741 | } | 
| 742 | |
| 743 | if (TrackingVisibility() && PresShell()->AssumeAllFramesVisible()) { | 
| 744 | IncApproximateVisibleCount(); | 
| 745 | } | 
| 746 | |
| 747 | DidSetComputedStyle(nullptr); | 
| 748 | |
| 749 | // For a newly created frame, we need to update this frame's visibility state. | 
| 750 | // Usually we update the state when the frame is restyled and has a | 
| 751 | // VisibilityChange change hint but we don't generate any change hints for | 
| 752 | // newly created frames. | 
| 753 | // Note: We don't need to do this for placeholders since placeholders have | 
| 754 | // different styles so that the styles don't have visibility:hidden even if | 
| 755 | // the parent has visibility:hidden style. We also don't need to update the | 
| 756 | // state when creating continuations because its visibility is the same as its | 
| 757 | // prev-in-flow, and the animation code cares only primary frames. | 
| 758 | if (!IsPlaceholderFrame() && !aPrevInFlow) { | 
| 759 | UpdateVisibleDescendantsState(); | 
| 760 | } | 
| 761 | |
| 762 | if (!aPrevInFlow && HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { | 
| 763 | // We aren't going to get a reflow, so nothing else will call | 
| 764 | // InvalidateRenderingObservers, we have to do it here. | 
| 765 | SVGObserverUtils::InvalidateRenderingObservers(this); | 
| 766 | } | 
| 767 | } | 
| 768 | |
| 769 | void nsIFrame::InitPrimaryFrame() { | 
| 770 | MOZ_ASSERT(IsPrimaryFrame())do { static_assert( mozilla::detail::AssertionConditionType< decltype(IsPrimaryFrame())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(IsPrimaryFrame()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsPrimaryFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 770); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsPrimaryFrame()" ")"); do { *((volatile int*)__null) = 770; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 771 | HandlePrimaryFrameStyleChange(nullptr); | 
| 772 | } | 
| 773 | |
| 774 | void nsIFrame::HandlePrimaryFrameStyleChange(ComputedStyle* aOldStyle) { | 
| 775 | const nsStyleDisplay* disp = StyleDisplay(); | 
| 776 | const nsStyleDisplay* oldDisp = | 
| 777 | aOldStyle ? aOldStyle->StyleDisplay() : nullptr; | 
| 778 | |
| 779 | const bool wasQueryContainer = oldDisp && oldDisp->IsQueryContainer(); | 
| 780 | const bool isQueryContainer = disp->IsQueryContainer(); | 
| 781 | if (wasQueryContainer != isQueryContainer) { | 
| 782 | auto* pc = PresContext(); | 
| 783 | if (isQueryContainer) { | 
| 784 | pc->RegisterContainerQueryFrame(this); | 
| 785 | } else { | 
| 786 | pc->UnregisterContainerQueryFrame(this); | 
| 787 | } | 
| 788 | } | 
| 789 | |
| 790 | const auto cv = disp->ContentVisibility(*this); | 
| 791 | if (!oldDisp || oldDisp->ContentVisibility(*this) != cv) { | 
| 792 | if (cv == StyleContentVisibility::Auto) { | 
| 793 | PresShell()->RegisterContentVisibilityAutoFrame(this); | 
| 794 | } else { | 
| 795 | if (auto* element = Element::FromNodeOrNull(GetContent())) { | 
| 796 | element->ClearContentRelevancy(); | 
| 797 | } | 
| 798 | PresShell()->UnregisterContentVisibilityAutoFrame(this); | 
| 799 | } | 
| 800 | PresContext()->SetNeedsToUpdateHiddenByContentVisibilityForAnimations(); | 
| 801 | } | 
| 802 | |
| 803 | HandleLastRememberedSize(); | 
| 804 | } | 
| 805 | |
| 806 | void nsIFrame::Destroy(DestroyContext& aContext) { | 
| 807 | NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),do { if (!(!nsContentUtils::IsSafeToRunScript())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "destroy called on frame while scripts not blocked" , "!nsContentUtils::IsSafeToRunScript()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 808); MOZ_PretendNoReturn(); } } while (0) | 
| 808 | "destroy called on frame while scripts not blocked")do { if (!(!nsContentUtils::IsSafeToRunScript())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "destroy called on frame while scripts not blocked" , "!nsContentUtils::IsSafeToRunScript()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 808); MOZ_PretendNoReturn(); } } while (0); | 
| 809 | NS_ASSERTION(!GetNextSibling() && !GetPrevSibling(),do { if (!(!GetNextSibling() && !GetPrevSibling())) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Frames should be removed before destruction." , "!GetNextSibling() && !GetPrevSibling()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 810); MOZ_PretendNoReturn(); } } while (0) | 
| 810 | "Frames should be removed before destruction.")do { if (!(!GetNextSibling() && !GetPrevSibling())) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Frames should be removed before destruction." , "!GetNextSibling() && !GetPrevSibling()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 810); MOZ_PretendNoReturn(); } } while (0); | 
| 811 | MOZ_ASSERT(!HasAbsolutelyPositionedChildren())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAbsolutelyPositionedChildren())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!HasAbsolutelyPositionedChildren ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!HasAbsolutelyPositionedChildren()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 811); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAbsolutelyPositionedChildren()" ")"); do { *((volatile int*)__null) = 811; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 812 | MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)" " (" "NS_FRAME_PART_OF_IBSPLIT set on non-nsContainerFrame?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 813); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)" ") (" "NS_FRAME_PART_OF_IBSPLIT set on non-nsContainerFrame?" ")"); do { *((volatile int*)__null) = 813; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 813 | "NS_FRAME_PART_OF_IBSPLIT set on non-nsContainerFrame?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)" " (" "NS_FRAME_PART_OF_IBSPLIT set on non-nsContainerFrame?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 813); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)" ") (" "NS_FRAME_PART_OF_IBSPLIT set on non-nsContainerFrame?" ")"); do { *((volatile int*)__null) = 813; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 814 | |
| 815 | MaybeScheduleReflowSVGNonDisplayText(this); | 
| 816 | |
| 817 | SVGObserverUtils::InvalidateDirectRenderingObservers( | 
| 818 | this, SVGObserverUtils::INVALIDATE_DESTROY); | 
| 819 | |
| 820 | const auto* disp = StyleDisplay(); | 
| 821 | if (disp->mPosition == StylePositionProperty::Sticky) { | 
| 822 | if (auto* ssc = | 
| 823 | StickyScrollContainer::GetStickyScrollContainerForFrame(this)) { | 
| 824 | ssc->RemoveFrame(this); | 
| 825 | } | 
| 826 | } | 
| 827 | |
| 828 | if (HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { | 
| 829 | if (nsPlaceholderFrame* placeholder = GetPlaceholderFrame()) { | 
| 830 | placeholder->SetOutOfFlowFrame(nullptr); | 
| 831 | } | 
| 832 | } | 
| 833 | |
| 834 | nsPresContext* pc = PresContext(); | 
| 835 | mozilla::PresShell* ps = pc->GetPresShell(); | 
| 836 | if (IsPrimaryFrame()) { | 
| 837 | if (disp->IsQueryContainer()) { | 
| 838 | pc->UnregisterContainerQueryFrame(this); | 
| 839 | } | 
| 840 | if (disp->ContentVisibility(*this) == StyleContentVisibility::Auto) { | 
| 841 | ps->UnregisterContentVisibilityAutoFrame(this); | 
| 842 | } | 
| 843 | // This needs to happen before we clear our Properties() table. | 
| 844 | ActiveLayerTracker::TransferActivityToContent(this, mContent); | 
| 845 | } | 
| 846 | |
| 847 | ScrollAnchorContainer* anchor = nullptr; | 
| 848 | if (IsScrollAnchor(&anchor)) { | 
| 849 | anchor->InvalidateAnchor(); | 
| 850 | } | 
| 851 | |
| 852 | if (HasCSSAnimations() || HasCSSTransitions() || | 
| 853 | // It's fine to look up the style frame here since if we're destroying the | 
| 854 | // frames for display:table content we should be destroying both wrapper | 
| 855 | // and inner frame. | 
| 856 | EffectSet::GetForStyleFrame(this)) { | 
| 857 | // If no new frame for this element is created by the end of the | 
| 858 | // restyling process, stop animations and transitions for this frame | 
| 859 | RestyleManager::AnimationsWithDestroyedFrame* adf = | 
| 860 | pc->RestyleManager()->GetAnimationsWithDestroyedFrame(); | 
| 861 | // AnimationsWithDestroyedFrame only lives during the restyling process. | 
| 862 | if (adf) { | 
| 863 | adf->Put(mContent, mComputedStyle); | 
| 864 | } | 
| 865 | } | 
| 866 | |
| 867 | // Disable visibility tracking. Note that we have to do this before we clear | 
| 868 | // frame properties and lose track of whether we were previously visible. | 
| 869 | // XXX(seth): It'd be ideal to assert that we're already marked nonvisible | 
| 870 | // here, but it's unfortunately tricky to guarantee in the face of things like | 
| 871 | // frame reconstruction induced by style changes. | 
| 872 | DisableVisibilityTracking(); | 
| 873 | |
| 874 | // Ensure that we're not in the approximately visible list anymore. | 
| 875 | ps->RemoveFrameFromApproximatelyVisibleList(this); | 
| 876 | |
| 877 | ps->NotifyDestroyingFrame(this); | 
| 878 | |
| 879 | if (HasAnyStateBits(NS_FRAME_EXTERNAL_REFERENCE)) { | 
| 880 | ps->ClearFrameRefs(this); | 
| 881 | } | 
| 882 | |
| 883 | nsView* view = GetView(); | 
| 884 | if (view) { | 
| 885 | view->SetFrame(nullptr); | 
| 886 | view->Destroy(); | 
| 887 | } | 
| 888 | |
| 889 | // Make sure that our deleted frame can't be returned from GetPrimaryFrame() | 
| 890 | if (IsPrimaryFrame()) { | 
| 891 | mContent->SetPrimaryFrame(nullptr); | 
| 892 | |
| 893 | // Pass the root of a generated content subtree (e.g. ::after/::before) to | 
| 894 | // aPostDestroyData to unbind it after frame destruction is done. | 
| 895 | if (HasAnyStateBits(NS_FRAME_GENERATED_CONTENT) && | 
| 896 | mContent->IsRootOfNativeAnonymousSubtree()) { | 
| 897 | aContext.AddAnonymousContent(mContent.forget()); | 
| 898 | } | 
| 899 | } | 
| 900 | |
| 901 | // Remove all properties attached to the frame, to ensure any property | 
| 902 | // destructors that need the frame pointer are handled properly. | 
| 903 | RemoveAllProperties(); | 
| 904 | |
| 905 | // Must retrieve the object ID before calling destructors, so the | 
| 906 | // vtable is still valid. | 
| 907 | // | 
| 908 | // Note to future tweakers: having the method that returns the | 
| 909 | // object size call the destructor will not avoid an indirect call; | 
| 910 | // the compiler cannot devirtualize the call to the destructor even | 
| 911 | // if it's from a method defined in the same class. | 
| 912 | |
| 913 | nsQueryFrame::FrameIID id = GetFrameId(); | 
| 914 | this->~nsIFrame(); | 
| 915 | |
| 916 | #ifdef DEBUG1 | 
| 917 | { | 
| 918 | nsIFrame* rootFrame = ps->GetRootFrame(); | 
| 919 | MOZ_ASSERT(rootFrame)do { static_assert( mozilla::detail::AssertionConditionType< decltype(rootFrame)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(rootFrame))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("rootFrame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 919); AnnotateMozCrashReason("MOZ_ASSERT" "(" "rootFrame" ")" ); do { *((volatile int*)__null) = 919; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 920 | if (this != rootFrame) { | 
| 921 | auto* builder = nsLayoutUtils::GetRetainedDisplayListBuilder(rootFrame); | 
| 922 | auto* data = builder ? builder->Data() : nullptr; | 
| 923 | |
| 924 | const bool inData = | 
| 925 | data && (data->IsModified(this) || data->HasProps(this)); | 
| 926 | |
| 927 | if (inData) { | 
| 928 | DL_LOG(LogLevel::Warning, "Frame %p found in retained data", this)do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Warning)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Warning, "Frame %p found in retained data", this) ; } } while (0); | 
| 929 | } | 
| 930 | |
| 931 | MOZ_ASSERT(!inData, "Deleted frame in retained data!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!inData)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!inData))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!inData" " (" "Deleted frame in retained data!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 931); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!inData" ") (" "Deleted frame in retained data!" ")"); do { *((volatile int *)__null) = 931; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); | 
| 932 | } | 
| 933 | } | 
| 934 | #endif | 
| 935 | |
| 936 | // Now that we're totally cleaned out, we need to add ourselves to | 
| 937 | // the presshell's recycler. | 
| 938 | ps->FreeFrame(id, this); | 
| 939 | } | 
| 940 | |
| 941 | std::pair<int32_t, int32_t> nsIFrame::GetOffsets() const { | 
| 942 | return std::make_pair(0, 0); | 
| 943 | } | 
| 944 | |
| 945 | static void CompareLayers( | 
| 946 | const nsStyleImageLayers* aFirstLayers, | 
| 947 | const nsStyleImageLayers* aSecondLayers, | 
| 948 | const std::function<void(imgRequestProxy* aReq)>& aCallback) { | 
| 949 | NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, (*aFirstLayers))for (uint32_t i = ((*aFirstLayers)).mImageCount; (i)-- != 0;) { | 
| 950 | const auto& image = aFirstLayers->mLayers[i].mImage; | 
| 951 | if (!image.IsImageRequestType() || !image.IsResolved()) { | 
| 952 | continue; | 
| 953 | } | 
| 954 | |
| 955 | // aCallback is called when the style image in aFirstLayers is thought to | 
| 956 | // be different with the corresponded one in aSecondLayers | 
| 957 | if (!aSecondLayers || i >= aSecondLayers->mImageCount || | 
| 958 | (!aSecondLayers->mLayers[i].mImage.IsResolved() || | 
| 959 | image.GetImageRequest() != | 
| 960 | aSecondLayers->mLayers[i].mImage.GetImageRequest())) { | 
| 961 | if (imgRequestProxy* req = image.GetImageRequest()) { | 
| 962 | aCallback(req); | 
| 963 | } | 
| 964 | } | 
| 965 | } | 
| 966 | } | 
| 967 | |
| 968 | static void AddAndRemoveImageAssociations( | 
| 969 | ImageLoader& aImageLoader, nsIFrame* aFrame, | 
| 970 | const nsStyleImageLayers* aOldLayers, | 
| 971 | const nsStyleImageLayers* aNewLayers) { | 
| 972 | // If the old context had a background-image image, or mask-image image, | 
| 973 | // and new context does not have the same image, clear the image load | 
| 974 | // notifier (which keeps the image loading, if it still is) for the frame. | 
| 975 | // We want to do this conservatively because some frames paint their | 
| 976 | // backgrounds from some other frame's style data, and we don't want | 
| 977 | // to clear those notifiers unless we have to. (They'll be reset | 
| 978 | // when we paint, although we could miss a notification in that | 
| 979 | // interval.) | 
| 980 | if (aOldLayers && aFrame->HasImageRequest()) { | 
| 981 | CompareLayers(aOldLayers, aNewLayers, [&](imgRequestProxy* aReq) { | 
| 982 | aImageLoader.DisassociateRequestFromFrame(aReq, aFrame); | 
| 983 | }); | 
| 984 | } | 
| 985 | |
| 986 | CompareLayers(aNewLayers, aOldLayers, [&](imgRequestProxy* aReq) { | 
| 987 | aImageLoader.AssociateRequestToFrame(aReq, aFrame); | 
| 988 | }); | 
| 989 | } | 
| 990 | |
| 991 | void nsIFrame::AddDisplayItem(nsDisplayItem* aItem) { | 
| 992 | MOZ_DIAGNOSTIC_ASSERT(!mDisplayItems.Contains(aItem))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mDisplayItems.Contains(aItem))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!mDisplayItems.Contains(aItem )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!mDisplayItems.Contains(aItem)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 992); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "!mDisplayItems.Contains(aItem)" ")"); do { *((volatile int*)__null) = 992; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 993 | mDisplayItems.AppendElement(aItem); | 
| 994 | #ifdef ACCESSIBILITY1 | 
| 995 | if (nsAccessibilityService* accService = GetAccService()) { | 
| 996 | accService->NotifyOfPossibleBoundsChange(PresShell(), mContent); | 
| 997 | } | 
| 998 | #endif | 
| 999 | } | 
| 1000 | |
| 1001 | bool nsIFrame::RemoveDisplayItem(nsDisplayItem* aItem) { | 
| 1002 | return mDisplayItems.RemoveElement(aItem); | 
| 1003 | } | 
| 1004 | |
| 1005 | bool nsIFrame::HasDisplayItems() { return !mDisplayItems.IsEmpty(); } | 
| 1006 | |
| 1007 | bool nsIFrame::HasDisplayItem(nsDisplayItem* aItem) { | 
| 1008 | return mDisplayItems.Contains(aItem); | 
| 1009 | } | 
| 1010 | |
| 1011 | bool nsIFrame::HasDisplayItem(uint32_t aKey) { | 
| 1012 | for (nsDisplayItem* i : mDisplayItems) { | 
| 1013 | if (i->GetPerFrameKey() == aKey) { | 
| 1014 | return true; | 
| 1015 | } | 
| 1016 | } | 
| 1017 | return false; | 
| 1018 | } | 
| 1019 | |
| 1020 | template <typename Condition> | 
| 1021 | static void DiscardDisplayItems(nsIFrame* aFrame, Condition aCondition) { | 
| 1022 | for (nsDisplayItem* i : aFrame->DisplayItems()) { | 
| 1023 | // Only discard items that are invalidated by this frame, as we're only | 
| 1024 | // guaranteed to rebuild those items. Table background items are created by | 
| 1025 | // the relevant table part, but have the cell frame as the primary frame, | 
| 1026 | // and we don't want to remove them if this is the cell. | 
| 1027 | if (aCondition(i) && i->FrameForInvalidation() == aFrame) { | 
| 1028 | i->SetCantBeReused(); | 
| 1029 | } | 
| 1030 | } | 
| 1031 | } | 
| 1032 | |
| 1033 | static void DiscardOldItems(nsIFrame* aFrame) { | 
| 1034 | DiscardDisplayItems(aFrame, | 
| 1035 | [](nsDisplayItem* aItem) { return aItem->IsOldItem(); }); | 
| 1036 | } | 
| 1037 | |
| 1038 | void nsIFrame::RemoveDisplayItemDataForDeletion() { | 
| 1039 | // Destroying a WebRenderUserDataTable can cause destruction of other objects | 
| 1040 | // which can remove frame properties in their destructor. If we delete a frame | 
| 1041 | // property it runs the destructor of the stored object in the middle of | 
| 1042 | // updating the frame property table, so if the destruction of that object | 
| 1043 | // causes another update to the frame property table it would leave the frame | 
| 1044 | // property table in an inconsistent state. So we remove it from the table and | 
| 1045 | // then destroy it. (bug 1530657) | 
| 1046 | WebRenderUserDataTable* userDataTable = | 
| 1047 | TakeProperty(WebRenderUserDataProperty::Key()); | 
| 1048 | if (userDataTable) { | 
| 1049 | for (const auto& data : userDataTable->Values()) { | 
| 1050 | data->RemoveFromTable(); | 
| 1051 | } | 
| 1052 | delete userDataTable; | 
| 1053 | } | 
| 1054 | |
| 1055 | if (!nsLayoutUtils::AreRetainedDisplayListsEnabled()) { | 
| 1056 | // Retained display lists are disabled, no need to update | 
| 1057 | // RetainedDisplayListData. | 
| 1058 | return; | 
| 1059 | } | 
| 1060 | |
| 1061 | auto* builder = nsLayoutUtils::GetRetainedDisplayListBuilder(this); | 
| 1062 | if (!builder) { | 
| 1063 | MOZ_ASSERT(DisplayItems().IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(DisplayItems().IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(DisplayItems().IsEmpty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("DisplayItems().IsEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1063); AnnotateMozCrashReason("MOZ_ASSERT" "(" "DisplayItems().IsEmpty()" ")"); do { *((volatile int*)__null) = 1063; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1064 | MOZ_ASSERT(!IsFrameModified())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!IsFrameModified())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!IsFrameModified()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!IsFrameModified()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1064); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsFrameModified()" ")"); do { *((volatile int*)__null) = 1064; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1065 | return; | 
| 1066 | } | 
| 1067 | |
| 1068 | for (nsDisplayItem* i : DisplayItems()) { | 
| 1069 | if (i->GetDependentFrame() == this && !i->HasDeletedFrame()) { | 
| 1070 | i->Frame()->MarkNeedsDisplayItemRebuild(); | 
| 1071 | } | 
| 1072 | i->RemoveFrame(this); | 
| 1073 | } | 
| 1074 | |
| 1075 | DisplayItems().Clear(); | 
| 1076 | |
| 1077 | nsAutoString name; | 
| 1078 | #ifdef DEBUG_FRAME_DUMP1 | 
| 1079 | if (DL_LOG_TEST(LogLevel::Debug)(__builtin_expect(!!(mozilla::detail::log_test(GetLoggerByProcess (), LogLevel::Debug)), 0))) { | 
| 1080 | GetFrameName(name); | 
| 1081 | } | 
| 1082 | #endif | 
| 1083 | DL_LOGV("Removing display item data for frame %p (%s)", this,do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "Removing display item data for frame %p (%s)" , this, NS_ConvertUTF16toUTF8(name).get()); } } while (0) | 
| 1084 | NS_ConvertUTF16toUTF8(name).get())do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "Removing display item data for frame %p (%s)" , this, NS_ConvertUTF16toUTF8(name).get()); } } while (0); | 
| 1085 | |
| 1086 | auto* data = builder->Data(); | 
| 1087 | if (MayHaveWillChangeBudget()) { | 
| 1088 | // Keep the frame in list, so it can be removed from the will-change budget. | 
| 1089 | data->Flags(this) = RetainedDisplayListData::FrameFlag::HadWillChange; | 
| 1090 | } else { | 
| 1091 | data->Remove(this); | 
| 1092 | } | 
| 1093 | } | 
| 1094 | |
| 1095 | void nsIFrame::MarkNeedsDisplayItemRebuild() { | 
| 1096 | if (!nsLayoutUtils::AreRetainedDisplayListsEnabled() || IsFrameModified() || | 
| 1097 | HasAnyStateBits(NS_FRAME_IN_POPUP)) { | 
| 1098 | // Skip frames that are already marked modified. | 
| 1099 | return; | 
| 1100 | } | 
| 1101 | |
| 1102 | if (Type() == LayoutFrameType::Placeholder) { | 
| 1103 | nsIFrame* oof = static_cast<nsPlaceholderFrame*>(this)->GetOutOfFlowFrame(); | 
| 1104 | if (oof) { | 
| 1105 | oof->MarkNeedsDisplayItemRebuild(); | 
| 1106 | } | 
| 1107 | // Do not mark placeholder frames modified. | 
| 1108 | return; | 
| 1109 | } | 
| 1110 | |
| 1111 | #ifdef ACCESSIBILITY1 | 
| 1112 | if (nsAccessibilityService* accService = GetAccService()) { | 
| 1113 | accService->NotifyOfPossibleBoundsChange(PresShell(), mContent); | 
| 1114 | } | 
| 1115 | #endif | 
| 1116 | |
| 1117 | nsIFrame* rootFrame = PresShell()->GetRootFrame(); | 
| 1118 | |
| 1119 | if (rootFrame->IsFrameModified()) { | 
| 1120 | // The whole frame tree is modified. | 
| 1121 | return; | 
| 1122 | } | 
| 1123 | |
| 1124 | auto* builder = nsLayoutUtils::GetRetainedDisplayListBuilder(this); | 
| 1125 | if (!builder) { | 
| 1126 | MOZ_ASSERT(DisplayItems().IsEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(DisplayItems().IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(DisplayItems().IsEmpty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("DisplayItems().IsEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1126); AnnotateMozCrashReason("MOZ_ASSERT" "(" "DisplayItems().IsEmpty()" ")"); do { *((volatile int*)__null) = 1126; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1127 | return; | 
| 1128 | } | 
| 1129 | |
| 1130 | RetainedDisplayListData* data = builder->Data(); | 
| 1131 | MOZ_ASSERT(data)do { static_assert( mozilla::detail::AssertionConditionType< decltype(data)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(data))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("data", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1131); AnnotateMozCrashReason("MOZ_ASSERT" "(" "data" ")"); do { *((volatile int*)__null) = 1131; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1132 | |
| 1133 | if (data->AtModifiedFrameLimit()) { | 
| 1134 | // This marks the whole frame tree modified. | 
| 1135 | // See |RetainedDisplayListBuilder::ShouldBuildPartial()|. | 
| 1136 | data->AddModifiedFrame(rootFrame); | 
| 1137 | return; | 
| 1138 | } | 
| 1139 | |
| 1140 | nsAutoString name; | 
| 1141 | #ifdef DEBUG_FRAME_DUMP1 | 
| 1142 | if (DL_LOG_TEST(LogLevel::Debug)(__builtin_expect(!!(mozilla::detail::log_test(GetLoggerByProcess (), LogLevel::Debug)), 0))) { | 
| 1143 | GetFrameName(name); | 
| 1144 | } | 
| 1145 | #endif | 
| 1146 | |
| 1147 | DL_LOGV("RDL - Rebuilding display items for frame %p (%s)", this,do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "RDL - Rebuilding display items for frame %p (%s)" , this, NS_ConvertUTF16toUTF8(name).get()); } } while (0) | 
| 1148 | NS_ConvertUTF16toUTF8(name).get())do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "RDL - Rebuilding display items for frame %p (%s)" , this, NS_ConvertUTF16toUTF8(name).get()); } } while (0); | 
| 1149 | |
| 1150 | data->AddModifiedFrame(this); | 
| 1151 | |
| 1152 | MOZ_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType< decltype(PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding ) == 0)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding ) == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding) == 0" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1153); AnnotateMozCrashReason("MOZ_ASSERT" "(" "PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding) == 0" ")"); do { *((volatile int*)__null) = 1153; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1153 | PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding) == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding ) == 0)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding ) == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding) == 0" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1153); AnnotateMozCrashReason("MOZ_ASSERT" "(" "PresContext()->LayoutPhaseCount(nsLayoutPhase::DisplayListBuilding) == 0" ")"); do { *((volatile int*)__null) = 1153; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1154 | |
| 1155 | // Hopefully this is cheap, but we could use a frame state bit to note | 
| 1156 | // the presence of dependencies to speed it up. | 
| 1157 | for (nsDisplayItem* i : DisplayItems()) { | 
| 1158 | if (i->HasDeletedFrame() || i->Frame() == this) { | 
| 1159 | // Ignore the items with deleted frames, and the items with |this| as | 
| 1160 | // the primary frame. | 
| 1161 | continue; | 
| 1162 | } | 
| 1163 | |
| 1164 | if (i->GetDependentFrame() == this) { | 
| 1165 | // For items with |this| as a dependent frame, mark the primary frame | 
| 1166 | // for rebuild. | 
| 1167 | i->Frame()->MarkNeedsDisplayItemRebuild(); | 
| 1168 | } | 
| 1169 | } | 
| 1170 | } | 
| 1171 | |
| 1172 | // Subclass hook for style post processing | 
| 1173 | /* virtual */ | 
| 1174 | void nsIFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) { | 
| 1175 | #ifdef ACCESSIBILITY1 | 
| 1176 | // Don't notify for reconstructed frames here, since the frame is still being | 
| 1177 | // constructed at this point and so LocalAccessible::GetFrame() will return | 
| 1178 | // null. Style changes for reconstructed frames are handled in | 
| 1179 | // DocAccessible::PruneOrInsertSubtree. | 
| 1180 | if (aOldComputedStyle) { | 
| 1181 | if (nsAccessibilityService* accService = GetAccService()) { | 
| 1182 | accService->NotifyOfComputedStyleChange(PresShell(), mContent); | 
| 1183 | } | 
| 1184 | } | 
| 1185 | #endif | 
| 1186 | |
| 1187 | MaybeScheduleReflowSVGNonDisplayText(this); | 
| 1188 | |
| 1189 | Document* doc = PresContext()->Document(); | 
| 1190 | ImageLoader* loader = doc->StyleImageLoader(); | 
| 1191 | // Continuing text frame doesn't initialize its continuation pointer before | 
| 1192 | // reaching here for the first time, so we have to exclude text frames. This | 
| 1193 | // doesn't affect correctness because text can't match selectors. | 
| 1194 | // | 
| 1195 | // FIXME(emilio): We should consider fixing that. | 
| 1196 | // | 
| 1197 | // TODO(emilio): Can we avoid doing some / all of the image stuff when | 
| 1198 | // isNonTextFirstContinuation is false? We should consider doing this just for | 
| 1199 | // primary frames and pseudos, but the first-line reparenting code makes it | 
| 1200 | // all bad, should get around to bug 1465474 eventually :( | 
| 1201 | const bool isNonText = !IsTextFrame(); | 
| 1202 | if (isNonText) { | 
| 1203 | mComputedStyle->StartImageLoads(*doc, aOldComputedStyle); | 
| 1204 | } | 
| 1205 | |
| 1206 | const bool isRootElementStyle = Style()->IsRootElementStyle(); | 
| 1207 | if (isRootElementStyle) { | 
| 1208 | PresShell()->SyncWindowProperties(/* aSync = */ false); | 
| 1209 | } | 
| 1210 | |
| 1211 | const nsStyleImageLayers* oldLayers = | 
| 1212 | aOldComputedStyle ? &aOldComputedStyle->StyleBackground()->mImage | 
| 1213 | : nullptr; | 
| 1214 | const nsStyleImageLayers* newLayers = &StyleBackground()->mImage; | 
| 1215 | AddAndRemoveImageAssociations(*loader, this, oldLayers, newLayers); | 
| 1216 | |
| 1217 | oldLayers = | 
| 1218 | aOldComputedStyle ? &aOldComputedStyle->StyleSVGReset()->mMask : nullptr; | 
| 1219 | newLayers = &StyleSVGReset()->mMask; | 
| 1220 | AddAndRemoveImageAssociations(*loader, this, oldLayers, newLayers); | 
| 1221 | |
| 1222 | const nsStyleDisplay* disp = StyleDisplay(); | 
| 1223 | bool handleStickyChange = false; | 
| 1224 | if (aOldComputedStyle) { | 
| 1225 | // Detect style changes that should trigger a scroll anchor adjustment | 
| 1226 | // suppression. | 
| 1227 | // https://drafts.csswg.org/css-scroll-anchoring/#suppression-triggers | 
| 1228 | bool needAnchorSuppression = false; | 
| 1229 | |
| 1230 | const nsStyleMargin* oldMargin = aOldComputedStyle->StyleMargin(); | 
| 1231 | if (!oldMargin->MarginEquals(*StyleMargin())) { | 
| 1232 | needAnchorSuppression = true; | 
| 1233 | } | 
| 1234 | |
| 1235 | const nsStylePadding* oldPadding = aOldComputedStyle->StylePadding(); | 
| 1236 | if (oldPadding->mPadding != StylePadding()->mPadding) { | 
| 1237 | SetHasPaddingChange(true); | 
| 1238 | needAnchorSuppression = true; | 
| 1239 | } | 
| 1240 | |
| 1241 | const nsStyleDisplay* oldDisp = aOldComputedStyle->StyleDisplay(); | 
| 1242 | if (oldDisp->mOverflowAnchor != disp->mOverflowAnchor) { | 
| 1243 | if (auto* container = ScrollAnchorContainer::FindFor(this)) { | 
| 1244 | container->InvalidateAnchor(); | 
| 1245 | } | 
| 1246 | if (ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(this)) { | 
| 1247 | scrollContainerFrame->Anchor()->InvalidateAnchor(); | 
| 1248 | } | 
| 1249 | } | 
| 1250 | |
| 1251 | if (mInScrollAnchorChain) { | 
| 1252 | const nsStylePosition* pos = StylePosition(); | 
| 1253 | const nsStylePosition* oldPos = aOldComputedStyle->StylePosition(); | 
| 1254 | if (!needAnchorSuppression && | 
| 1255 | (!oldPos->InsetEquals(*pos) || | 
| 1256 | oldPos->GetWidth() != pos->GetWidth() || | 
| 1257 | oldPos->GetMinWidth() != pos->GetMinWidth() || | 
| 1258 | oldPos->GetMaxWidth() != pos->GetMaxWidth() || | 
| 1259 | oldPos->GetHeight() != pos->GetHeight() || | 
| 1260 | oldPos->GetMinHeight() != pos->GetMinHeight() || | 
| 1261 | oldPos->GetMaxHeight() != pos->GetMaxHeight() || | 
| 1262 | oldDisp->mPosition != disp->mPosition || | 
| 1263 | oldDisp->mTransform != disp->mTransform)) { | 
| 1264 | needAnchorSuppression = true; | 
| 1265 | } | 
| 1266 | |
| 1267 | if (needAnchorSuppression && | 
| 1268 | StaticPrefs::layout_css_scroll_anchoring_suppressions_enabled()) { | 
| 1269 | ScrollAnchorContainer::FindFor(this)->SuppressAdjustments(); | 
| 1270 | } | 
| 1271 | } | 
| 1272 | |
| 1273 | if (disp->mPosition != oldDisp->mPosition) { | 
| 1274 | if (!disp->IsRelativelyOrStickyPositionedStyle() && | 
| 1275 | oldDisp->IsRelativelyOrStickyPositionedStyle()) { | 
| 1276 | RemoveProperty(NormalPositionProperty()); | 
| 1277 | } | 
| 1278 | |
| 1279 | handleStickyChange = disp->mPosition == StylePositionProperty::Sticky || | 
| 1280 | oldDisp->mPosition == StylePositionProperty::Sticky; | 
| 1281 | } | 
| 1282 | if (disp->mScrollSnapAlign != oldDisp->mScrollSnapAlign) { | 
| 1283 | ScrollSnapUtils::PostPendingResnapFor(this); | 
| 1284 | } | 
| 1285 | if (isRootElementStyle && | 
| 1286 | disp->mScrollSnapType != oldDisp->mScrollSnapType) { | 
| 1287 | if (ScrollContainerFrame* sf = | 
| 1288 | PresShell()->GetRootScrollContainerFrame()) { | 
| 1289 | sf->PostPendingResnap(); | 
| 1290 | } | 
| 1291 | } | 
| 1292 | if (StyleUIReset()->mMozSubtreeHiddenOnlyVisually && | 
| 1293 | !aOldComputedStyle->StyleUIReset()->mMozSubtreeHiddenOnlyVisually) { | 
| 1294 | PresShell::ClearMouseCapture(this); | 
| 1295 | } | 
| 1296 | } else { // !aOldComputedStyle | 
| 1297 | handleStickyChange = disp->mPosition == StylePositionProperty::Sticky; | 
| 1298 | } | 
| 1299 | |
| 1300 | if (handleStickyChange && !HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) && | 
| 1301 | !GetPrevInFlow()) { | 
| 1302 | // Note that we only add first continuations, but we really only | 
| 1303 | // want to add first continuation-or-ib-split-siblings. But since we don't | 
| 1304 | // yet know if we're a later part of a block-in-inline split, we'll just | 
| 1305 | // add later members of a block-in-inline split here, and then | 
| 1306 | // StickyScrollContainer will remove them later. | 
| 1307 | if (auto* ssc = | 
| 1308 | StickyScrollContainer::GetStickyScrollContainerForFrame(this)) { | 
| 1309 | if (disp->mPosition == StylePositionProperty::Sticky) { | 
| 1310 | ssc->AddFrame(this); | 
| 1311 | } else { | 
| 1312 | ssc->RemoveFrame(this); | 
| 1313 | } | 
| 1314 | } | 
| 1315 | } | 
| 1316 | |
| 1317 | imgIRequest* oldBorderImage = | 
| 1318 | aOldComputedStyle | 
| 1319 | ? aOldComputedStyle->StyleBorder()->GetBorderImageRequest() | 
| 1320 | : nullptr; | 
| 1321 | imgIRequest* newBorderImage = StyleBorder()->GetBorderImageRequest(); | 
| 1322 | // FIXME (Bug 759996): The following is no longer true. | 
| 1323 | // For border-images, we can't be as conservative (we need to set the | 
| 1324 | // new loaders if there has been any change) since the CalcDifference | 
| 1325 | // call depended on the result of GetComputedBorder() and that result | 
| 1326 | // depends on whether the image has loaded, start the image load now | 
| 1327 | // so that we'll get notified when it completes loading and can do a | 
| 1328 | // restyle. Otherwise, the image might finish loading from the | 
| 1329 | // network before we start listening to its notifications, and then | 
| 1330 | // we'll never know that it's finished loading. Likewise, we want to | 
| 1331 | // do this for freshly-created frames to prevent a similar race if the | 
| 1332 | // image loads between reflow (which can depend on whether the image | 
| 1333 | // is loaded) and paint. We also don't really care about any callers who try | 
| 1334 | // to paint borders with a different style, because they won't have the | 
| 1335 | // correct size for the border either. | 
| 1336 | if (oldBorderImage != newBorderImage) { | 
| 1337 | // stop and restart the image loading/notification | 
| 1338 | if (oldBorderImage && HasImageRequest()) { | 
| 1339 | loader->DisassociateRequestFromFrame(oldBorderImage, this); | 
| 1340 | } | 
| 1341 | if (newBorderImage) { | 
| 1342 | loader->AssociateRequestToFrame(newBorderImage, this); | 
| 1343 | } | 
| 1344 | } | 
| 1345 | |
| 1346 | auto GetShapeImageRequest = [](const ComputedStyle* aStyle) -> imgIRequest* { | 
| 1347 | if (!aStyle) { | 
| 1348 | return nullptr; | 
| 1349 | } | 
| 1350 | auto& shape = aStyle->StyleDisplay()->mShapeOutside; | 
| 1351 | if (!shape.IsImage()) { | 
| 1352 | return nullptr; | 
| 1353 | } | 
| 1354 | return shape.AsImage().GetImageRequest(); | 
| 1355 | }; | 
| 1356 | |
| 1357 | imgIRequest* oldShapeImage = GetShapeImageRequest(aOldComputedStyle); | 
| 1358 | imgIRequest* newShapeImage = GetShapeImageRequest(Style()); | 
| 1359 | if (oldShapeImage != newShapeImage) { | 
| 1360 | if (oldShapeImage && HasImageRequest()) { | 
| 1361 | loader->DisassociateRequestFromFrame(oldShapeImage, this); | 
| 1362 | } | 
| 1363 | if (newShapeImage) { | 
| 1364 | loader->AssociateRequestToFrame( | 
| 1365 | newShapeImage, this, | 
| 1366 | ImageLoader::Flags:: | 
| 1367 | RequiresReflowOnFirstFrameCompleteAndLoadEventBlocking); | 
| 1368 | } | 
| 1369 | } | 
| 1370 | |
| 1371 | // SVGObserverUtils::GetEffectProperties() asserts that we only invoke it with | 
| 1372 | // the first continuation so we need to check that in advance. | 
| 1373 | const bool isNonTextFirstContinuation = isNonText && !GetPrevContinuation(); | 
| 1374 | if (isNonTextFirstContinuation) { | 
| 1375 | // Kick off loading of external SVG resources referenced from properties if | 
| 1376 | // any. This currently includes filter, clip-path, and mask. | 
| 1377 | SVGObserverUtils::InitiateResourceDocLoads(this); | 
| 1378 | } | 
| 1379 | |
| 1380 | // If the page contains markup that overrides text direction, and | 
| 1381 | // does not contain any characters that would activate the Unicode | 
| 1382 | // bidi algorithm, we need to call |SetBidiEnabled| on the pres | 
| 1383 | // context before reflow starts. See bug 115921. | 
| 1384 | if (StyleVisibility()->mDirection == StyleDirection::Rtl) { | 
| 1385 | PresContext()->SetBidiEnabled(); | 
| 1386 | } | 
| 1387 | |
| 1388 | // The following part is for caching offset-path:path(). We cache the | 
| 1389 | // flatten gfx path, so we don't have to rebuild and re-flattern it at | 
| 1390 | // each cycle if we have animations on offset-* with a fixed offset-path. | 
| 1391 | const StyleOffsetPath* oldPath = | 
| 1392 | aOldComputedStyle ? &aOldComputedStyle->StyleDisplay()->mOffsetPath | 
| 1393 | : nullptr; | 
| 1394 | const StyleOffsetPath& newPath = StyleDisplay()->mOffsetPath; | 
| 1395 | if (!oldPath || *oldPath != newPath) { | 
| 1396 | // FIXME: Bug 1837042. Cache all basic shapes. | 
| 1397 | if (newPath.IsPath()) { | 
| 1398 | RefPtr<gfx::PathBuilder> builder = MotionPathUtils::GetPathBuilder(); | 
| 1399 | RefPtr<gfx::Path> path = | 
| 1400 | MotionPathUtils::BuildSVGPath(newPath.AsSVGPathData(), builder); | 
| 1401 | if (path) { | 
| 1402 | // The newPath could be path('') (i.e. empty path), so its gfx path | 
| 1403 | // could be nullptr, and so we only set property for a non-empty path. | 
| 1404 | SetProperty(nsIFrame::OffsetPathCache(), path.forget().take()); | 
| 1405 | } else { | 
| 1406 | // May have an old cached path, so we have to delete it. | 
| 1407 | RemoveProperty(nsIFrame::OffsetPathCache()); | 
| 1408 | } | 
| 1409 | } else if (oldPath) { | 
| 1410 | RemoveProperty(nsIFrame::OffsetPathCache()); | 
| 1411 | } | 
| 1412 | } | 
| 1413 | |
| 1414 | if (IsPrimaryFrame()) { | 
| 1415 | MOZ_ASSERT(aOldComputedStyle)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aOldComputedStyle)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aOldComputedStyle))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aOldComputedStyle" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1415); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aOldComputedStyle" ")"); do { *((volatile int*)__null) = 1415; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1416 | HandlePrimaryFrameStyleChange(aOldComputedStyle); | 
| 1417 | } | 
| 1418 | |
| 1419 | RemoveStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS | NS_FRAME_SIMPLE_DISPLAYLIST); | 
| 1420 | |
| 1421 | mMayHaveRoundedCorners = true; | 
| 1422 | } | 
| 1423 | |
| 1424 | void nsIFrame::HandleLastRememberedSize() { | 
| 1425 | MOZ_ASSERT(IsPrimaryFrame())do { static_assert( mozilla::detail::AssertionConditionType< decltype(IsPrimaryFrame())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(IsPrimaryFrame()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsPrimaryFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1425); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsPrimaryFrame()" ")"); do { *((volatile int*)__null) = 1425; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1426 | // Storing a last remembered size requires contain-intrinsic-size. | 
| 1427 | if (!StaticPrefs::layout_css_contain_intrinsic_size_enabled()) { | 
| 1428 | return; | 
| 1429 | } | 
| 1430 | auto* element = Element::FromNodeOrNull(mContent); | 
| 1431 | if (!element) { | 
| 1432 | return; | 
| 1433 | } | 
| 1434 | const WritingMode wm = GetWritingMode(); | 
| 1435 | const nsStylePosition* stylePos = StylePosition(); | 
| 1436 | bool canRememberBSize = stylePos->ContainIntrinsicBSize(wm).HasAuto(); | 
| 1437 | bool canRememberISize = stylePos->ContainIntrinsicISize(wm).HasAuto(); | 
| 1438 | if (!canRememberBSize) { | 
| 1439 | element->RemoveLastRememberedBSize(); | 
| 1440 | } | 
| 1441 | if (!canRememberISize) { | 
| 1442 | element->RemoveLastRememberedISize(); | 
| 1443 | } | 
| 1444 | if ((canRememberBSize || canRememberISize) && !HidesContent()) { | 
| 1445 | bool isNonReplacedInline = IsLineParticipant() && !IsReplaced(); | 
| 1446 | if (!isNonReplacedInline) { | 
| 1447 | PresContext()->Document()->ObserveForLastRememberedSize(*element); | 
| 1448 | return; | 
| 1449 | } | 
| 1450 | } | 
| 1451 | PresContext()->Document()->UnobserveForLastRememberedSize(*element); | 
| 1452 | } | 
| 1453 | |
| 1454 | #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED1 | 
| 1455 | void nsIFrame::AssertNewStyleIsSane(ComputedStyle& aNewStyle) { | 
| 1456 | MOZ_DIAGNOSTIC_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1457 | aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1458 | // ::first-line continuations are weird, this should probably be fixed viado { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1459 | // bug 1465474.do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1460 | (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine &&do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1461 | aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1462 | // ::first-letter continuations are broken, in particular floating ones,do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1463 | // see bug 1490281. The construction code tries to fix this up after thedo { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1464 | // fact, then restyling undoes it...do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1465 | (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText &&do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1466 | aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1467 | (mComputedStyle->GetPseudoType() ==do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1468 | PseudoStyleType::firstLetterContinuation &&do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1469 | aNewStyle.GetPseudoType() == PseudoStyleType::mozText))do { static_assert( mozilla::detail::AssertionConditionType< decltype(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType () || (mComputedStyle->GetPseudoType() == PseudoStyleType:: firstLine && aNewStyle.GetPseudoType() == PseudoStyleType ::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType ::mozText && aNewStyle.GetPseudoType() == PseudoStyleType ::firstLetterContinuation) || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLetterContinuation && aNewStyle .GetPseudoType() == PseudoStyleType::mozText))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType () == PseudoStyleType::firstLine && aNewStyle.GetPseudoType () == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType () == PseudoStyleType::mozText && aNewStyle.GetPseudoType () == PseudoStyleType::firstLetterContinuation) || (mComputedStyle ->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1469); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "aNewStyle.GetPseudoType() == mComputedStyle->GetPseudoType() || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLine && aNewStyle.GetPseudoType() == PseudoStyleType::mozLineFrame) || (mComputedStyle->GetPseudoType() == PseudoStyleType::mozText && aNewStyle.GetPseudoType() == PseudoStyleType::firstLetterContinuation) || (mComputedStyle->GetPseudoType() == PseudoStyleType::firstLetterContinuation && aNewStyle.GetPseudoType() == PseudoStyleType::mozText)" ")"); do { *((volatile int*)__null) = 1469; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1470 | } | 
| 1471 | #endif | 
| 1472 | |
| 1473 | void nsIFrame::ReparentFrameViewTo(nsViewManager* aViewManager, | 
| 1474 | nsView* aNewParentView) { | 
| 1475 | if (HasView()) { | 
| 1476 | if (IsMenuPopupFrame()) { | 
| 1477 | // This view must be parented by the root view, don't reparent it. | 
| 1478 | return; | 
| 1479 | } | 
| 1480 | nsView* view = GetView(); | 
| 1481 | aViewManager->RemoveChild(view); | 
| 1482 | |
| 1483 | // The view will remember the Z-order and other attributes that have been | 
| 1484 | // set on it. | 
| 1485 | nsView* insertBefore = | 
| 1486 | nsLayoutUtils::FindSiblingViewFor(aNewParentView, this); | 
| 1487 | aViewManager->InsertChild(aNewParentView, view, insertBefore, | 
| 1488 | insertBefore != nullptr); | 
| 1489 | } else if (HasAnyStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW)) { | 
| 1490 | for (const auto& childList : ChildLists()) { | 
| 1491 | // Iterate the child frames, and check each child frame to see if it has | 
| 1492 | // a view | 
| 1493 | for (nsIFrame* child : childList.mList) { | 
| 1494 | child->ReparentFrameViewTo(aViewManager, aNewParentView); | 
| 1495 | } | 
| 1496 | } | 
| 1497 | } | 
| 1498 | } | 
| 1499 | |
| 1500 | void nsIFrame::SyncFrameViewProperties(nsView* aView) { | 
| 1501 | if (!aView) { | 
| 1502 | aView = GetView(); | 
| 1503 | if (!aView) { | 
| 1504 | return; | 
| 1505 | } | 
| 1506 | } | 
| 1507 | |
| 1508 | nsViewManager* vm = aView->GetViewManager(); | 
| 1509 | |
| 1510 | // Make sure visibility is correct. This only affects nsSubDocumentFrame. | 
| 1511 | if (!SupportsVisibilityHidden()) { | 
| 1512 | // See if the view should be hidden or visible | 
| 1513 | ComputedStyle* sc = Style(); | 
| 1514 | vm->SetViewVisibility(aView, sc->StyleVisibility()->IsVisible() | 
| 1515 | ? ViewVisibility::Show | 
| 1516 | : ViewVisibility::Hide); | 
| 1517 | } | 
| 1518 | } | 
| 1519 | |
| 1520 | /* virtual */ | 
| 1521 | nsMargin nsIFrame::GetUsedMargin() const { | 
| 1522 | nsMargin margin; | 
| 1523 | if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) || | 
| 1524 | IsInSVGTextSubtree()) { | 
| 1525 | return margin; | 
| 1526 | } | 
| 1527 | |
| 1528 | if (nsMargin* m = GetProperty(UsedMarginProperty())) { | 
| 1529 | margin = *m; | 
| 1530 | } else if (!StyleMargin()->GetMargin(margin)) { | 
| 1531 | // If we get here, our caller probably shouldn't be calling us... | 
| 1532 | NS_ERROR(do { NS_DebugBreak(NS_DEBUG_ASSERTION, "Returning bogus 0-sized margin, because this margin " "depends on layout & isn't cached!", "Error", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1534); MOZ_PretendNoReturn(); } while (0) | 
| 1533 | "Returning bogus 0-sized margin, because this margin "do { NS_DebugBreak(NS_DEBUG_ASSERTION, "Returning bogus 0-sized margin, because this margin " "depends on layout & isn't cached!", "Error", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1534); MOZ_PretendNoReturn(); } while (0) | 
| 1534 | "depends on layout & isn't cached!")do { NS_DebugBreak(NS_DEBUG_ASSERTION, "Returning bogus 0-sized margin, because this margin " "depends on layout & isn't cached!", "Error", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1534); MOZ_PretendNoReturn(); } while (0); | 
| 1535 | } | 
| 1536 | return margin; | 
| 1537 | } | 
| 1538 | |
| 1539 | /* virtual */ | 
| 1540 | nsMargin nsIFrame::GetUsedBorder() const { | 
| 1541 | if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) || | 
| 1542 | IsInSVGTextSubtree()) { | 
| 1543 | return {}; | 
| 1544 | } | 
| 1545 | |
| 1546 | const nsStyleDisplay* disp = StyleDisplay(); | 
| 1547 | if (IsThemed(disp)) { | 
| 1548 | // Theme methods don't use const-ness. | 
| 1549 | auto* mutable_this = const_cast<nsIFrame*>(this); | 
| 1550 | nsPresContext* pc = PresContext(); | 
| 1551 | LayoutDeviceIntMargin widgetBorder = pc->Theme()->GetWidgetBorder( | 
| 1552 | pc->DeviceContext(), mutable_this, disp->EffectiveAppearance()); | 
| 1553 | return LayoutDevicePixel::ToAppUnits(widgetBorder, | 
| 1554 | pc->AppUnitsPerDevPixel()); | 
| 1555 | } | 
| 1556 | |
| 1557 | return StyleBorder()->GetComputedBorder(); | 
| 1558 | } | 
| 1559 | |
| 1560 | /* virtual */ | 
| 1561 | nsMargin nsIFrame::GetUsedPadding() const { | 
| 1562 | nsMargin padding; | 
| 1563 | if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) || | 
| 1564 | IsInSVGTextSubtree()) { | 
| 1565 | return padding; | 
| 1566 | } | 
| 1567 | |
| 1568 | const nsStyleDisplay* disp = StyleDisplay(); | 
| 1569 | if (IsThemed(disp)) { | 
| 1570 | // Theme methods don't use const-ness. | 
| 1571 | nsIFrame* mutable_this = const_cast<nsIFrame*>(this); | 
| 1572 | nsPresContext* pc = PresContext(); | 
| 1573 | LayoutDeviceIntMargin widgetPadding; | 
| 1574 | if (pc->Theme()->GetWidgetPadding(pc->DeviceContext(), mutable_this, | 
| 1575 | disp->EffectiveAppearance(), | 
| 1576 | &widgetPadding)) { | 
| 1577 | return LayoutDevicePixel::ToAppUnits(widgetPadding, | 
| 1578 | pc->AppUnitsPerDevPixel()); | 
| 1579 | } | 
| 1580 | } | 
| 1581 | |
| 1582 | if (nsMargin* p = GetProperty(UsedPaddingProperty())) { | 
| 1583 | padding = *p; | 
| 1584 | } else if (!StylePadding()->GetPadding(padding)) { | 
| 1585 | // If we get here, our caller probably shouldn't be calling us... | 
| 1586 | NS_ERROR(do { NS_DebugBreak(NS_DEBUG_ASSERTION, "Returning bogus 0-sized padding, because this padding " "depends on layout & isn't cached!", "Error", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1588); MOZ_PretendNoReturn(); } while (0) | 
| 1587 | "Returning bogus 0-sized padding, because this padding "do { NS_DebugBreak(NS_DEBUG_ASSERTION, "Returning bogus 0-sized padding, because this padding " "depends on layout & isn't cached!", "Error", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1588); MOZ_PretendNoReturn(); } while (0) | 
| 1588 | "depends on layout & isn't cached!")do { NS_DebugBreak(NS_DEBUG_ASSERTION, "Returning bogus 0-sized padding, because this padding " "depends on layout & isn't cached!", "Error", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1588); MOZ_PretendNoReturn(); } while (0); | 
| 1589 | } | 
| 1590 | return padding; | 
| 1591 | } | 
| 1592 | |
| 1593 | nsIFrame::Sides nsIFrame::GetSkipSides() const { | 
| 1594 | if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==(__builtin_expect(!!(StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Clone), 0)) | 
| 1595 | StyleBoxDecorationBreak::Clone)(__builtin_expect(!!(StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Clone), 0)) && | 
| 1596 | !HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) { | 
| 1597 | return Sides(); | 
| 1598 | } | 
| 1599 | |
| 1600 | // Convert the logical skip sides to physical sides using the frame's | 
| 1601 | // writing mode | 
| 1602 | WritingMode writingMode = GetWritingMode(); | 
| 1603 | LogicalSides logicalSkip = GetLogicalSkipSides(); | 
| 1604 | Sides skip; | 
| 1605 | |
| 1606 | if (logicalSkip.BStart()) { | 
| 1607 | if (writingMode.IsVertical()) { | 
| 1608 | skip |= writingMode.IsVerticalLR() ? SideBits::eLeft : SideBits::eRight; | 
| 1609 | } else { | 
| 1610 | skip |= SideBits::eTop; | 
| 1611 | } | 
| 1612 | } | 
| 1613 | |
| 1614 | if (logicalSkip.BEnd()) { | 
| 1615 | if (writingMode.IsVertical()) { | 
| 1616 | skip |= writingMode.IsVerticalLR() ? SideBits::eRight : SideBits::eLeft; | 
| 1617 | } else { | 
| 1618 | skip |= SideBits::eBottom; | 
| 1619 | } | 
| 1620 | } | 
| 1621 | |
| 1622 | if (logicalSkip.IStart()) { | 
| 1623 | if (writingMode.IsVertical()) { | 
| 1624 | skip |= SideBits::eTop; | 
| 1625 | } else { | 
| 1626 | skip |= writingMode.IsBidiLTR() ? SideBits::eLeft : SideBits::eRight; | 
| 1627 | } | 
| 1628 | } | 
| 1629 | |
| 1630 | if (logicalSkip.IEnd()) { | 
| 1631 | if (writingMode.IsVertical()) { | 
| 1632 | skip |= SideBits::eBottom; | 
| 1633 | } else { | 
| 1634 | skip |= writingMode.IsBidiLTR() ? SideBits::eRight : SideBits::eLeft; | 
| 1635 | } | 
| 1636 | } | 
| 1637 | return skip; | 
| 1638 | } | 
| 1639 | |
| 1640 | nsRect nsIFrame::GetPaddingRectRelativeToSelf() const { | 
| 1641 | nsMargin border = GetUsedBorder().ApplySkipSides(GetSkipSides()); | 
| 1642 | nsRect r(0, 0, mRect.width, mRect.height); | 
| 1643 | r.Deflate(border); | 
| 1644 | return r; | 
| 1645 | } | 
| 1646 | |
| 1647 | nsRect nsIFrame::GetPaddingRect() const { | 
| 1648 | return GetPaddingRectRelativeToSelf() + GetPosition(); | 
| 1649 | } | 
| 1650 | |
| 1651 | WritingMode nsIFrame::WritingModeForLine(WritingMode aSelfWM, | 
| 1652 | nsIFrame* aSubFrame) const { | 
| 1653 | MOZ_ASSERT(aSelfWM == GetWritingMode())do { static_assert( mozilla::detail::AssertionConditionType< decltype(aSelfWM == GetWritingMode())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aSelfWM == GetWritingMode()) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aSelfWM == GetWritingMode()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1653); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aSelfWM == GetWritingMode()" ")"); do { *((volatile int*)__null) = 1653; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1654 | WritingMode writingMode = aSelfWM; | 
| 1655 | |
| 1656 | if (StyleTextReset()->mUnicodeBidi == StyleUnicodeBidi::Plaintext) { | 
| 1657 | mozilla::intl::BidiEmbeddingLevel frameLevel = | 
| 1658 | nsBidiPresUtils::GetFrameBaseLevel(aSubFrame); | 
| 1659 | writingMode.SetDirectionFromBidiLevel(frameLevel); | 
| 1660 | } | 
| 1661 | |
| 1662 | return writingMode; | 
| 1663 | } | 
| 1664 | |
| 1665 | nsRect nsIFrame::GetMarginRect() const { | 
| 1666 | return GetMarginRectRelativeToSelf() + GetPosition(); | 
| 1667 | } | 
| 1668 | |
| 1669 | nsRect nsIFrame::GetMarginRectRelativeToSelf() const { | 
| 1670 | nsMargin m = GetUsedMargin().ApplySkipSides(GetSkipSides()); | 
| 1671 | nsRect r(0, 0, mRect.width, mRect.height); | 
| 1672 | r.Inflate(m); | 
| 1673 | return r; | 
| 1674 | } | 
| 1675 | |
| 1676 | bool nsIFrame::IsTransformed() const { | 
| 1677 | if (!HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED)) { | 
| 1678 | MOZ_ASSERT(!IsCSSTransformed())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!IsCSSTransformed())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!IsCSSTransformed()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!IsCSSTransformed()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1678); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsCSSTransformed()" ")"); do { *((volatile int*)__null) = 1678; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1679 | MOZ_ASSERT(!GetParentSVGTransforms())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!GetParentSVGTransforms())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!GetParentSVGTransforms()))) , 0))) { do { } while (false); MOZ_ReportAssertionFailure("!GetParentSVGTransforms()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1679); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!GetParentSVGTransforms()" ")"); do { *((volatile int*)__null) = 1679; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1680 | return false; | 
| 1681 | } | 
| 1682 | return IsCSSTransformed() || GetParentSVGTransforms(); | 
| 1683 | } | 
| 1684 | |
| 1685 | bool nsIFrame::IsCSSTransformed() const { | 
| 1686 | return HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED) && | 
| 1687 | (StyleDisplay()->HasTransform(this) || HasAnimationOfTransform()); | 
| 1688 | } | 
| 1689 | |
| 1690 | bool nsIFrame::HasAnimationOfTransform() const { | 
| 1691 | if (!MayHaveTransformAnimation()) { | 
| 1692 | MOZ_ASSERT(!IsPrimaryFrame() || !SupportsCSSTransforms() ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(!IsPrimaryFrame() || !SupportsCSSTransforms() || !nsLayoutUtils ::HasAnimationOfTransformAndMotionPath(this))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!IsPrimaryFrame() || !SupportsCSSTransforms () || !nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!IsPrimaryFrame() || !SupportsCSSTransforms() || !nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1693); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsPrimaryFrame() || !SupportsCSSTransforms() || !nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this)" ")"); do { *((volatile int*)__null) = 1693; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 1693 | !nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!IsPrimaryFrame() || !SupportsCSSTransforms() || !nsLayoutUtils ::HasAnimationOfTransformAndMotionPath(this))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!IsPrimaryFrame() || !SupportsCSSTransforms () || !nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!IsPrimaryFrame() || !SupportsCSSTransforms() || !nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1693); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsPrimaryFrame() || !SupportsCSSTransforms() || !nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this)" ")"); do { *((volatile int*)__null) = 1693; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1694 | return false; | 
| 1695 | } | 
| 1696 | return IsPrimaryFrame() && SupportsCSSTransforms() && | 
| 1697 | nsLayoutUtils::HasAnimationOfTransformAndMotionPath(this); | 
| 1698 | } | 
| 1699 | |
| 1700 | bool nsIFrame::ChildrenHavePerspective( | 
| 1701 | const nsStyleDisplay* aStyleDisplay) const { | 
| 1702 | MOZ_ASSERT(aStyleDisplay == StyleDisplay())do { static_assert( mozilla::detail::AssertionConditionType< decltype(aStyleDisplay == StyleDisplay())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aStyleDisplay == StyleDisplay ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aStyleDisplay == StyleDisplay()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1702); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aStyleDisplay == StyleDisplay()" ")"); do { *((volatile int*)__null) = 1702; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 1703 | return aStyleDisplay->HasPerspective(this); | 
| 1704 | } | 
| 1705 | |
| 1706 | bool nsIFrame::HasAnimationOfOpacity(EffectSet* aEffectSet) const { | 
| 1707 | return ((nsLayoutUtils::IsPrimaryStyleFrame(this) || | 
| 1708 | nsLayoutUtils::FirstContinuationOrIBSplitSibling(this) | 
| 1709 | ->IsPrimaryFrame()) && | 
| 1710 | nsLayoutUtils::HasAnimationOfPropertySet( | 
| 1711 | this, nsCSSPropertyIDSet::OpacityProperties(), aEffectSet)); | 
| 1712 | } | 
| 1713 | |
| 1714 | bool nsIFrame::HasOpacityInternal(float aThreshold, | 
| 1715 | const nsStyleDisplay* aStyleDisplay, | 
| 1716 | const nsStyleEffects* aStyleEffects, | 
| 1717 | EffectSet* aEffectSet) const { | 
| 1718 | MOZ_ASSERT(0.0 <= aThreshold && aThreshold <= 1.0, "Invalid argument")do { static_assert( mozilla::detail::AssertionConditionType< decltype(0.0 <= aThreshold && aThreshold <= 1.0 )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(0.0 <= aThreshold && aThreshold <= 1.0 ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "0.0 <= aThreshold && aThreshold <= 1.0" " (" "Invalid argument" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 1718); AnnotateMozCrashReason("MOZ_ASSERT" "(" "0.0 <= aThreshold && aThreshold <= 1.0" ") (" "Invalid argument" ")"); do { *((volatile int*)__null) = 1718; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 1719 | if (aStyleEffects->mOpacity < aThreshold || | 
| 1720 | aStyleDisplay->mWillChange.bits & StyleWillChangeBits::OPACITY) { | 
| 1721 | return true; | 
| 1722 | } | 
| 1723 | |
| 1724 | if (!mMayHaveOpacityAnimation) { | 
| 1725 | return false; | 
| 1726 | } | 
| 1727 | |
| 1728 | return HasAnimationOfOpacity(aEffectSet); | 
| 1729 | } | 
| 1730 | |
| 1731 | bool nsIFrame::DoGetParentSVGTransforms(gfx::Matrix*) const { return false; } | 
| 1732 | |
| 1733 | bool nsIFrame::Extend3DContext(const nsStyleDisplay* aStyleDisplay, | 
| 1734 | const nsStyleEffects* aStyleEffects, | 
| 1735 | mozilla::EffectSet* aEffectSetForOpacity) const { | 
| 1736 | if (!HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED)) { | 
| 1737 | return false; | 
| 1738 | } | 
| 1739 | const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay); | 
| 1740 | if (disp->mTransformStyle != StyleTransformStyle::Preserve3d || | 
| 1741 | !SupportsCSSTransforms()) { | 
| 1742 | return false; | 
| 1743 | } | 
| 1744 | |
| 1745 | // If we're all scroll frame, then all descendants will be clipped, so we | 
| 1746 | // can't preserve 3d. | 
| 1747 | if (IsScrollContainerFrame()) { | 
| 1748 | return false; | 
| 1749 | } | 
| 1750 | |
| 1751 | const nsStyleEffects* effects = StyleEffectsWithOptionalParam(aStyleEffects); | 
| 1752 | if (HasOpacity(disp, effects, aEffectSetForOpacity)) { | 
| 1753 | return false; | 
| 1754 | } | 
| 1755 | |
| 1756 | return ShouldApplyOverflowClipping(disp).isEmpty() && | 
| 1757 | !GetClipPropClipRect(disp, effects, GetSize()) && | 
| 1758 | !SVGIntegrationUtils::UsingEffectsForFrame(this) && | 
| 1759 | !effects->HasMixBlendMode() && | 
| 1760 | disp->mIsolation != StyleIsolation::Isolate; | 
| 1761 | } | 
| 1762 | |
| 1763 | bool nsIFrame::Combines3DTransformWithAncestors() const { | 
| 1764 | // Check these first as they are faster then both calls below and are we are | 
| 1765 | // likely to hit the early return (backface hidden is uncommon and | 
| 1766 | // GetReferenceFrame is a hot caller of this which only calls this if | 
| 1767 | // IsCSSTransformed is false). | 
| 1768 | if (!IsCSSTransformed() && !BackfaceIsHidden()) { | 
| 1769 | return false; | 
| 1770 | } | 
| 1771 | nsIFrame* parent = GetClosestFlattenedTreeAncestorPrimaryFrame(); | 
| 1772 | return parent && parent->Extend3DContext(); | 
| 1773 | } | 
| 1774 | |
| 1775 | bool nsIFrame::In3DContextAndBackfaceIsHidden() const { | 
| 1776 | // While both tests fail most of the time, test BackfaceIsHidden() | 
| 1777 | // first since it's likely to fail faster. | 
| 1778 | return BackfaceIsHidden() && Combines3DTransformWithAncestors(); | 
| 1779 | } | 
| 1780 | |
| 1781 | bool nsIFrame::HasPerspective() const { | 
| 1782 | if (!IsCSSTransformed()) { | 
| 1783 | return false; | 
| 1784 | } | 
| 1785 | nsIFrame* parent = GetClosestFlattenedTreeAncestorPrimaryFrame(); | 
| 1786 | if (!parent) { | 
| 1787 | return false; | 
| 1788 | } | 
| 1789 | return parent->ChildrenHavePerspective(); | 
| 1790 | } | 
| 1791 | |
| 1792 | nsRect nsIFrame::GetContentRectRelativeToSelf() const { | 
| 1793 | nsMargin bp = GetUsedBorderAndPadding().ApplySkipSides(GetSkipSides()); | 
| 1794 | nsRect r(0, 0, mRect.width, mRect.height); | 
| 1795 | r.Deflate(bp); | 
| 1796 | return r; | 
| 1797 | } | 
| 1798 | |
| 1799 | nsRect nsIFrame::GetContentRect() const { | 
| 1800 | return GetContentRectRelativeToSelf() + GetPosition(); | 
| 1801 | } | 
| 1802 | |
| 1803 | bool nsIFrame::ComputeBorderRadii(const BorderRadius& aBorderRadius, | 
| 1804 | const nsSize& aFrameSize, | 
| 1805 | const nsSize& aBorderArea, Sides aSkipSides, | 
| 1806 | nscoord aRadii[8]) { | 
| 1807 | // Percentages are relative to whichever side they're on. | 
| 1808 | for (const auto i : mozilla::AllPhysicalHalfCorners()) { | 
| 1809 | const LengthPercentage& c = aBorderRadius.Get(i); | 
| 1810 | nscoord axis = HalfCornerIsX(i) ? aFrameSize.width : aFrameSize.height; | 
| 1811 | aRadii[i] = std::max(0, c.Resolve(axis)); | 
| 1812 | } | 
| 1813 | |
| 1814 | if (aSkipSides.Top()) { | 
| 1815 | aRadii[eCornerTopLeftX] = 0; | 
| 1816 | aRadii[eCornerTopLeftY] = 0; | 
| 1817 | aRadii[eCornerTopRightX] = 0; | 
| 1818 | aRadii[eCornerTopRightY] = 0; | 
| 1819 | } | 
| 1820 | |
| 1821 | if (aSkipSides.Right()) { | 
| 1822 | aRadii[eCornerTopRightX] = 0; | 
| 1823 | aRadii[eCornerTopRightY] = 0; | 
| 1824 | aRadii[eCornerBottomRightX] = 0; | 
| 1825 | aRadii[eCornerBottomRightY] = 0; | 
| 1826 | } | 
| 1827 | |
| 1828 | if (aSkipSides.Bottom()) { | 
| 1829 | aRadii[eCornerBottomRightX] = 0; | 
| 1830 | aRadii[eCornerBottomRightY] = 0; | 
| 1831 | aRadii[eCornerBottomLeftX] = 0; | 
| 1832 | aRadii[eCornerBottomLeftY] = 0; | 
| 1833 | } | 
| 1834 | |
| 1835 | if (aSkipSides.Left()) { | 
| 1836 | aRadii[eCornerBottomLeftX] = 0; | 
| 1837 | aRadii[eCornerBottomLeftY] = 0; | 
| 1838 | aRadii[eCornerTopLeftX] = 0; | 
| 1839 | aRadii[eCornerTopLeftY] = 0; | 
| 1840 | } | 
| 1841 | |
| 1842 | // css3-background specifies this algorithm for reducing | 
| 1843 | // corner radii when they are too big. | 
| 1844 | bool haveRadius = false; | 
| 1845 | double ratio = 1.0f; | 
| 1846 | for (const auto side : mozilla::AllPhysicalSides()) { | 
| 1847 | uint32_t hc1 = SideToHalfCorner(side, false, true); | 
| 1848 | uint32_t hc2 = SideToHalfCorner(side, true, true); | 
| 1849 | nscoord length = | 
| 1850 | SideIsVertical(side) ? aBorderArea.height : aBorderArea.width; | 
| 1851 | nscoord sum = aRadii[hc1] + aRadii[hc2]; | 
| 1852 | if (sum) { | 
| 1853 | haveRadius = true; | 
| 1854 | // avoid floating point division in the normal case | 
| 1855 | if (length < sum) { | 
| 1856 | ratio = std::min(ratio, double(length) / sum); | 
| 1857 | } | 
| 1858 | } | 
| 1859 | } | 
| 1860 | if (ratio < 1.0) { | 
| 1861 | for (const auto corner : mozilla::AllPhysicalHalfCorners()) { | 
| 1862 | aRadii[corner] *= ratio; | 
| 1863 | } | 
| 1864 | } | 
| 1865 | |
| 1866 | return haveRadius; | 
| 1867 | } | 
| 1868 | |
| 1869 | void nsIFrame::AdjustBorderRadii(nscoord aRadii[8], const nsMargin& aOffsets) { | 
| 1870 | auto AdjustOffset = [](const uint32_t aRadius, const nscoord aOffset) { | 
| 1871 | // Implement the cubic formula to adjust offset when aOffset > 0 and | 
| 1872 | // aRadius / aOffset < 1. | 
| 1873 | // https://drafts.csswg.org/css-shapes/#valdef-shape-box-margin-box | 
| 1874 | if (aOffset > 0) { | 
| 1875 | const double ratio = aRadius / double(aOffset); | 
| 1876 | if (ratio < 1.0) { | 
| 1877 | return nscoord(aOffset * (1.0 + std::pow(ratio - 1, 3))); | 
| 1878 | } | 
| 1879 | } | 
| 1880 | return aOffset; | 
| 1881 | }; | 
| 1882 | |
| 1883 | for (const auto side : mozilla::AllPhysicalSides()) { | 
| 1884 | const nscoord offset = aOffsets.Side(side); | 
| 1885 | const uint32_t hc1 = SideToHalfCorner(side, false, false); | 
| 1886 | const uint32_t hc2 = SideToHalfCorner(side, true, false); | 
| 1887 | if (aRadii[hc1] > 0) { | 
| 1888 | const nscoord offset1 = AdjustOffset(aRadii[hc1], offset); | 
| 1889 | aRadii[hc1] = std::max(0, aRadii[hc1] + offset1); | 
| 1890 | } | 
| 1891 | if (aRadii[hc2] > 0) { | 
| 1892 | const nscoord offset2 = AdjustOffset(aRadii[hc2], offset); | 
| 1893 | aRadii[hc2] = std::max(0, aRadii[hc2] + offset2); | 
| 1894 | } | 
| 1895 | } | 
| 1896 | } | 
| 1897 | |
| 1898 | static inline bool RadiiAreDefinitelyZero(const BorderRadius& aBorderRadius) { | 
| 1899 | for (const auto corner : mozilla::AllPhysicalHalfCorners()) { | 
| 1900 | if (!aBorderRadius.Get(corner).IsDefinitelyZero()) { | 
| 1901 | return false; | 
| 1902 | } | 
| 1903 | } | 
| 1904 | return true; | 
| 1905 | } | 
| 1906 | |
| 1907 | /* virtual */ | 
| 1908 | bool nsIFrame::GetBorderRadii(const nsSize& aFrameSize, | 
| 1909 | const nsSize& aBorderArea, Sides aSkipSides, | 
| 1910 | nscoord aRadii[8]) const { | 
| 1911 | if (!mMayHaveRoundedCorners) { | 
| 1912 | memset(aRadii, 0, sizeof(nscoord) * 8); | 
| 1913 | return false; | 
| 1914 | } | 
| 1915 | |
| 1916 | if (IsThemed()) { | 
| 1917 | // When we're themed, the native theme code draws the border and | 
| 1918 | // background, and therefore it doesn't make sense to tell other | 
| 1919 | // code that's interested in border-radius that we have any radii. | 
| 1920 | // | 
| 1921 | // In an ideal world, we might have a way for the them to tell us an | 
| 1922 | // border radius, but since we don't, we're better off assuming | 
| 1923 | // zero. | 
| 1924 | for (const auto corner : mozilla::AllPhysicalHalfCorners()) { | 
| 1925 | aRadii[corner] = 0; | 
| 1926 | } | 
| 1927 | return false; | 
| 1928 | } | 
| 1929 | |
| 1930 | const auto& radii = StyleBorder()->mBorderRadius; | 
| 1931 | const bool hasRadii = | 
| 1932 | ComputeBorderRadii(radii, aFrameSize, aBorderArea, aSkipSides, aRadii); | 
| 1933 | if (!hasRadii) { | 
| 1934 | // TODO(emilio): Maybe we can just remove this bit and do the | 
| 1935 | // IsDefinitelyZero check unconditionally. That should still avoid most of | 
| 1936 | // the work, though maybe not the cache miss of going through the style and | 
| 1937 | // the border struct. | 
| 1938 | const_cast<nsIFrame*>(this)->mMayHaveRoundedCorners = | 
| 1939 | !RadiiAreDefinitelyZero(radii); | 
| 1940 | } | 
| 1941 | return hasRadii; | 
| 1942 | } | 
| 1943 | |
| 1944 | bool nsIFrame::GetBorderRadii(nscoord aRadii[8]) const { | 
| 1945 | nsSize sz = GetSize(); | 
| 1946 | return GetBorderRadii(sz, sz, GetSkipSides(), aRadii); | 
| 1947 | } | 
| 1948 | |
| 1949 | bool nsIFrame::GetMarginBoxBorderRadii(nscoord aRadii[8]) const { | 
| 1950 | return GetBoxBorderRadii(aRadii, GetUsedMargin()); | 
| 1951 | } | 
| 1952 | |
| 1953 | bool nsIFrame::GetPaddingBoxBorderRadii(nscoord aRadii[8]) const { | 
| 1954 | return GetBoxBorderRadii(aRadii, -GetUsedBorder()); | 
| 1955 | } | 
| 1956 | |
| 1957 | bool nsIFrame::GetContentBoxBorderRadii(nscoord aRadii[8]) const { | 
| 1958 | return GetBoxBorderRadii(aRadii, -GetUsedBorderAndPadding()); | 
| 1959 | } | 
| 1960 | |
| 1961 | bool nsIFrame::GetBoxBorderRadii(nscoord aRadii[8], | 
| 1962 | const nsMargin& aOffsets) const { | 
| 1963 | if (!GetBorderRadii(aRadii)) { | 
| 1964 | return false; | 
| 1965 | } | 
| 1966 | AdjustBorderRadii(aRadii, aOffsets); | 
| 1967 | for (const auto corner : mozilla::AllPhysicalHalfCorners()) { | 
| 1968 | if (aRadii[corner]) { | 
| 1969 | return true; | 
| 1970 | } | 
| 1971 | } | 
| 1972 | return false; | 
| 1973 | } | 
| 1974 | |
| 1975 | bool nsIFrame::GetShapeBoxBorderRadii(nscoord aRadii[8]) const { | 
| 1976 | using Tag = StyleShapeOutside::Tag; | 
| 1977 | auto& shapeOutside = StyleDisplay()->mShapeOutside; | 
| 1978 | auto box = StyleShapeBox::MarginBox; | 
| 1979 | switch (shapeOutside.tag) { | 
| 1980 | case Tag::Image: | 
| 1981 | case Tag::None: | 
| 1982 | return false; | 
| 1983 | case Tag::Box: | 
| 1984 | box = shapeOutside.AsBox(); | 
| 1985 | break; | 
| 1986 | case Tag::Shape: | 
| 1987 | box = shapeOutside.AsShape()._1; | 
| 1988 | break; | 
| 1989 | } | 
| 1990 | |
| 1991 | switch (box) { | 
| 1992 | case StyleShapeBox::ContentBox: | 
| 1993 | return GetContentBoxBorderRadii(aRadii); | 
| 1994 | case StyleShapeBox::PaddingBox: | 
| 1995 | return GetPaddingBoxBorderRadii(aRadii); | 
| 1996 | case StyleShapeBox::BorderBox: | 
| 1997 | return GetBorderRadii(aRadii); | 
| 1998 | case StyleShapeBox::MarginBox: | 
| 1999 | return GetMarginBoxBorderRadii(aRadii); | 
| 2000 | default: | 
| 2001 | MOZ_ASSERT_UNREACHABLE("Unexpected box value")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Unexpected box value" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2001); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Unexpected box value" ")"); do { *((volatile int*)__null) = 2001; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); | 
| 2002 | return false; | 
| 2003 | } | 
| 2004 | } | 
| 2005 | |
| 2006 | nscoord nsIFrame::OneEmInAppUnits() const { | 
| 2007 | return StyleFont() | 
| 2008 | ->mFont.size.ScaledBy(nsLayoutUtils::FontSizeInflationFor(this)) | 
| 2009 | .ToAppUnits(); | 
| 2010 | } | 
| 2011 | |
| 2012 | ComputedStyle* nsIFrame::GetAdditionalComputedStyle(int32_t aIndex) const { | 
| 2013 | MOZ_ASSERT(aIndex >= 0, "invalid index number")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aIndex >= 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aIndex >= 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aIndex >= 0" " (" "invalid index number" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2013); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aIndex >= 0" ") (" "invalid index number" ")"); do { *((volatile int*)__null ) = 2013; __attribute__((nomerge)) ::abort(); } while (false) ; } } while (false); | 
| 2014 | return nullptr; | 
| 2015 | } | 
| 2016 | |
| 2017 | void nsIFrame::SetAdditionalComputedStyle(int32_t aIndex, | 
| 2018 | ComputedStyle* aComputedStyle) { | 
| 2019 | MOZ_ASSERT(aIndex >= 0, "invalid index number")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aIndex >= 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aIndex >= 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aIndex >= 0" " (" "invalid index number" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2019); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aIndex >= 0" ") (" "invalid index number" ")"); do { *((volatile int*)__null ) = 2019; __attribute__((nomerge)) ::abort(); } while (false) ; } } while (false); | 
| 2020 | } | 
| 2021 | |
| 2022 | nscoord nsIFrame::SynthesizeFallbackBaseline( | 
| 2023 | WritingMode aWM, BaselineSharingGroup aBaselineGroup) const { | 
| 2024 | const auto margin = GetLogicalUsedMargin(aWM); | 
| 2025 | NS_ASSERTION(!IsSubtreeDirty(), "frame must not be dirty")do { if (!(!IsSubtreeDirty())) { NS_DebugBreak(NS_DEBUG_ASSERTION , "frame must not be dirty", "!IsSubtreeDirty()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2025); MOZ_PretendNoReturn(); } } while (0); | 
| 2026 | if (aWM.IsCentralBaseline()) { | 
| 2027 | return (BSize(aWM) + GetLogicalUsedMargin(aWM).BEnd(aWM)) / 2; | 
| 2028 | } | 
| 2029 | // Baseline for inverted line content is the top (block-start) margin edge, | 
| 2030 | // as the frame is in effect "flipped" for alignment purposes. | 
| 2031 | if (aWM.IsLineInverted()) { | 
| 2032 | const auto marginStart = margin.BStart(aWM); | 
| 2033 | return aBaselineGroup == BaselineSharingGroup::First | 
| 2034 | ? -marginStart | 
| 2035 | : BSize(aWM) + marginStart; | 
| 2036 | } | 
| 2037 | // Otherwise, the bottom margin edge, per CSS2.1's definition of the | 
| 2038 | // 'baseline' value of 'vertical-align'. | 
| 2039 | const auto marginEnd = margin.BEnd(aWM); | 
| 2040 | return aBaselineGroup == BaselineSharingGroup::First ? BSize(aWM) + marginEnd | 
| 2041 | : -marginEnd; | 
| 2042 | } | 
| 2043 | |
| 2044 | nscoord nsIFrame::GetLogicalBaseline(WritingMode aWM) const { | 
| 2045 | return GetLogicalBaseline(aWM, GetDefaultBaselineSharingGroup(), | 
| 2046 | BaselineExportContext::LineLayout); | 
| 2047 | } | 
| 2048 | |
| 2049 | nscoord nsIFrame::GetLogicalBaseline( | 
| 2050 | WritingMode aWM, BaselineSharingGroup aBaselineGroup, | 
| 2051 | BaselineExportContext aExportContext) const { | 
| 2052 | const auto result = | 
| 2053 | GetNaturalBaselineBOffset(aWM, aBaselineGroup, aExportContext) | 
| 2054 | .valueOrFrom([this, aWM, aBaselineGroup]() { | 
| 2055 | return SynthesizeFallbackBaseline(aWM, aBaselineGroup); | 
| 2056 | }); | 
| 2057 | if (aBaselineGroup == BaselineSharingGroup::Last) { | 
| 2058 | return BSize(aWM) - result; | 
| 2059 | } | 
| 2060 | return result; | 
| 2061 | } | 
| 2062 | |
| 2063 | const nsFrameList& nsIFrame::GetChildList(ChildListID aListID) const { | 
| 2064 | if (IsAbsoluteContainer() && aListID == GetAbsoluteListID()) { | 
| 2065 | return GetAbsoluteContainingBlock()->GetChildList(); | 
| 2066 | } else { | 
| 2067 | return nsFrameList::EmptyList(); | 
| 2068 | } | 
| 2069 | } | 
| 2070 | |
| 2071 | void nsIFrame::GetChildLists(nsTArray<ChildList>* aLists) const { | 
| 2072 | if (IsAbsoluteContainer()) { | 
| 2073 | const nsFrameList& absoluteList = | 
| 2074 | GetAbsoluteContainingBlock()->GetChildList(); | 
| 2075 | absoluteList.AppendIfNonempty(aLists, GetAbsoluteListID()); | 
| 2076 | } | 
| 2077 | } | 
| 2078 | |
| 2079 | AutoTArray<nsIFrame::ChildList, 4> nsIFrame::CrossDocChildLists() { | 
| 2080 | AutoTArray<ChildList, 4> childLists; | 
| 2081 | nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(this); | 
| 2082 | if (subdocumentFrame) { | 
| 2083 | // Descend into the subdocument | 
| 2084 | nsIFrame* root = subdocumentFrame->GetSubdocumentRootFrame(); | 
| 2085 | if (root) { | 
| 2086 | childLists.EmplaceBack( | 
| 2087 | nsFrameList(root, nsLayoutUtils::GetLastSibling(root)), | 
| 2088 | FrameChildListID::Principal); | 
| 2089 | } | 
| 2090 | } | 
| 2091 | |
| 2092 | GetChildLists(&childLists); | 
| 2093 | return childLists; | 
| 2094 | } | 
| 2095 | |
| 2096 | nsIFrame::CaretBlockAxisMetrics nsIFrame::GetCaretBlockAxisMetrics( | 
| 2097 | mozilla::WritingMode aWM, const nsFontMetrics& aFM) const { | 
| 2098 | // Note(dshin): Ultimately, this does something highly similar (But still | 
| 2099 | // different) to `nsLayoutUtils::GetFirstLinePosition`. | 
| 2100 | const auto baseline = GetCaretBaseline(); | 
| 2101 | nscoord ascent = 0, descent = 0; | 
| 2102 | ascent = aFM.MaxAscent(); | 
| 2103 | descent = aFM.MaxDescent(); | 
| 2104 | const nscoord height = ascent + descent; | 
| 2105 | if (aWM.IsVertical() && aWM.IsLineInverted()) { | 
| 2106 | return CaretBlockAxisMetrics{.mOffset = baseline - descent, | 
| 2107 | .mExtent = height}; | 
| 2108 | } | 
| 2109 | return CaretBlockAxisMetrics{.mOffset = baseline - ascent, .mExtent = height}; | 
| 2110 | } | 
| 2111 | |
| 2112 | nscoord nsIFrame::GetFontMetricsDerivedCaretBaseline(nscoord aBSize) const { | 
| 2113 | float inflation = nsLayoutUtils::FontSizeInflationFor(this); | 
| 2114 | RefPtr<nsFontMetrics> fm = | 
| 2115 | nsLayoutUtils::GetFontMetricsForFrame(this, inflation); | 
| 2116 | const WritingMode wm = GetWritingMode(); | 
| 2117 | nscoord lineHeight = ReflowInput::CalcLineHeight( | 
| 2118 | *Style(), PresContext(), GetContent(), aBSize, inflation); | 
| 2119 | return nsLayoutUtils::GetCenteredFontBaseline(fm, lineHeight, | 
| 2120 | wm.IsLineInverted()) + | 
| 2121 | GetLogicalUsedBorderAndPadding(wm).BStart(wm); | 
| 2122 | } | 
| 2123 | |
| 2124 | const nsAtom* nsIFrame::ComputePageValue(const nsAtom* aAutoValue) const { | 
| 2125 | const nsAtom* value = aAutoValue ? aAutoValue : nsGkAtoms::_empty; | 
| 2126 | const nsIFrame* frame = this; | 
| 2127 | // Find what CSS page name value this frame's subtree has, if any. | 
| 2128 | // Starting with this frame, check if a page name other than auto is present, | 
| 2129 | // and record it if so. Then, if the current frame is a container frame, find | 
| 2130 | // the first non-placeholder child and repeat. | 
| 2131 | // This will find the most deeply nested first in-flow child of this frame's | 
| 2132 | // subtree, and return its page name (with auto resolved if applicable, and | 
| 2133 | // subtrees with no page-names returning the empty atom rather than null). | 
| 2134 | do { | 
| 2135 | if (const nsAtom* maybePageName = frame->GetStylePageName()) { | 
| 2136 | value = maybePageName; | 
| 2137 | } | 
| 2138 | // Get the next frame to read from. | 
| 2139 | const nsIFrame* firstNonPlaceholderFrame = nullptr; | 
| 2140 | // If this is a container frame, inspect its in-flow children. | 
| 2141 | if (const nsContainerFrame* containerFrame = do_QueryFrame(frame)) { | 
| 2142 | for (const nsIFrame* childFrame : containerFrame->PrincipalChildList()) { | 
| 2143 | if (!childFrame->IsPlaceholderFrame()) { | 
| 2144 | firstNonPlaceholderFrame = childFrame; | 
| 2145 | break; | 
| 2146 | } | 
| 2147 | } | 
| 2148 | } | 
| 2149 | frame = firstNonPlaceholderFrame; | 
| 2150 | } while (frame); | 
| 2151 | return value; | 
| 2152 | } | 
| 2153 | |
| 2154 | Visibility nsIFrame::GetVisibility() const { | 
| 2155 | if (!HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)) { | 
| 2156 | return Visibility::Untracked; | 
| 2157 | } | 
| 2158 | |
| 2159 | bool isSet = false; | 
| 2160 | uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); | 
| 2161 | |
| 2162 | MOZ_ASSERT(isSet,do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2164); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2164; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2163 | "Should have a VisibilityStateProperty value "do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2164); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2164; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2164 | "if NS_FRAME_VISIBILITY_IS_TRACKED is set")do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2164); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2164; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2165 | |
| 2166 | return visibleCount > 0 ? Visibility::ApproximatelyVisible | 
| 2167 | : Visibility::ApproximatelyNonVisible; | 
| 2168 | } | 
| 2169 | |
| 2170 | void nsIFrame::UpdateVisibilitySynchronously() { | 
| 2171 | mozilla::PresShell* presShell = PresShell(); | 
| 2172 | if (!presShell) { | 
| 2173 | return; | 
| 2174 | } | 
| 2175 | |
| 2176 | if (presShell->AssumeAllFramesVisible()) { | 
| 2177 | presShell->EnsureFrameInApproximatelyVisibleList(this); | 
| 2178 | return; | 
| 2179 | } | 
| 2180 | |
| 2181 | bool visible = StyleVisibility()->IsVisible(); | 
| 2182 | nsIFrame* f = GetParent(); | 
| 2183 | nsRect rect = GetRectRelativeToSelf(); | 
| 2184 | nsIFrame* rectFrame = this; | 
| 2185 | while (f && visible) { | 
| 2186 | if (ScrollContainerFrame* sf = do_QueryFrame(f)) { | 
| 2187 | nsRect transformedRect = | 
| 2188 | nsLayoutUtils::TransformFrameRectToAncestor(rectFrame, rect, f); | 
| 2189 | if (!sf->IsRectNearlyVisible(transformedRect)) { | 
| 2190 | visible = false; | 
| 2191 | break; | 
| 2192 | } | 
| 2193 | |
| 2194 | // In this code we're trying to synchronously update *approximate* | 
| 2195 | // visibility. (In the future we may update precise visibility here as | 
| 2196 | // well, which is why the method name does not contain 'approximate'.) The | 
| 2197 | // IsRectNearlyVisible() check above tells us that the rect we're checking | 
| 2198 | // is approximately visible within the scrollframe, but we still need to | 
| 2199 | // ensure that, even if it was scrolled into view, it'd be visible when we | 
| 2200 | // consider the rest of the document. To do that, we move transformedRect | 
| 2201 | // to be contained in the scrollport as best we can (it might not fit) to | 
| 2202 | // pretend that it was scrolled into view. | 
| 2203 | rect = transformedRect.MoveInsideAndClamp(sf->GetScrollPortRect()); | 
| 2204 | rectFrame = f; | 
| 2205 | } | 
| 2206 | nsIFrame* parent = f->GetParent(); | 
| 2207 | if (!parent) { | 
| 2208 | parent = nsLayoutUtils::GetCrossDocParentFrameInProcess(f); | 
| 2209 | if (parent && parent->PresContext()->IsChrome()) { | 
| 2210 | break; | 
| 2211 | } | 
| 2212 | } | 
| 2213 | f = parent; | 
| 2214 | } | 
| 2215 | |
| 2216 | if (visible) { | 
| 2217 | presShell->EnsureFrameInApproximatelyVisibleList(this); | 
| 2218 | } else { | 
| 2219 | presShell->RemoveFrameFromApproximatelyVisibleList(this); | 
| 2220 | } | 
| 2221 | } | 
| 2222 | |
| 2223 | void nsIFrame::EnableVisibilityTracking() { | 
| 2224 | if (HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)) { | 
| 2225 | return; // Nothing to do. | 
| 2226 | } | 
| 2227 | |
| 2228 | MOZ_ASSERT(!HasProperty(VisibilityStateProperty()),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasProperty(VisibilityStateProperty()))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!HasProperty(VisibilityStateProperty())))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!HasProperty(VisibilityStateProperty())" " (" "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasProperty(VisibilityStateProperty())" ") (" "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set" ")"); do { *((volatile int*)__null) = 2230; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2229 | "Shouldn't have a VisibilityStateProperty value "do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasProperty(VisibilityStateProperty()))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!HasProperty(VisibilityStateProperty())))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!HasProperty(VisibilityStateProperty())" " (" "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasProperty(VisibilityStateProperty())" ") (" "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set" ")"); do { *((volatile int*)__null) = 2230; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2230 | "if NS_FRAME_VISIBILITY_IS_TRACKED is not set")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasProperty(VisibilityStateProperty()))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!HasProperty(VisibilityStateProperty())))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!HasProperty(VisibilityStateProperty())" " (" "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2230); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasProperty(VisibilityStateProperty())" ") (" "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set" ")"); do { *((volatile int*)__null) = 2230; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2231 | |
| 2232 | // Add the state bit so we know to track visibility for this frame, and | 
| 2233 | // initialize the frame property. | 
| 2234 | AddStateBits(NS_FRAME_VISIBILITY_IS_TRACKED); | 
| 2235 | SetProperty(VisibilityStateProperty(), 0); | 
| 2236 | |
| 2237 | mozilla::PresShell* presShell = PresShell(); | 
| 2238 | if (!presShell) { | 
| 2239 | return; | 
| 2240 | } | 
| 2241 | |
| 2242 | // Schedule a visibility update. This method will virtually always be called | 
| 2243 | // when layout has changed anyway, so it's very unlikely that any additional | 
| 2244 | // visibility updates will be triggered by this, but this way we guarantee | 
| 2245 | // that if this frame is currently visible we'll eventually find out. | 
| 2246 | presShell->ScheduleApproximateFrameVisibilityUpdateSoon(); | 
| 2247 | } | 
| 2248 | |
| 2249 | void nsIFrame::DisableVisibilityTracking() { | 
| 2250 | if (!HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)) { | 
| 2251 | return; // Nothing to do. | 
| 2252 | } | 
| 2253 | |
| 2254 | bool isSet = false; | 
| 2255 | uint32_t visibleCount = TakeProperty(VisibilityStateProperty(), &isSet); | 
| 2256 | |
| 2257 | MOZ_ASSERT(isSet,do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2259); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2259; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2258 | "Should have a VisibilityStateProperty value "do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2259); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2259; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2259 | "if NS_FRAME_VISIBILITY_IS_TRACKED is set")do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2259); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2259; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2260 | |
| 2261 | RemoveStateBits(NS_FRAME_VISIBILITY_IS_TRACKED); | 
| 2262 | |
| 2263 | if (visibleCount == 0) { | 
| 2264 | return; // We were nonvisible. | 
| 2265 | } | 
| 2266 | |
| 2267 | // We were visible, so send an OnVisibilityChange() notification. | 
| 2268 | OnVisibilityChange(Visibility::ApproximatelyNonVisible); | 
| 2269 | } | 
| 2270 | |
| 2271 | void nsIFrame::DecApproximateVisibleCount( | 
| 2272 | const Maybe<OnNonvisible>& aNonvisibleAction | 
| 2273 | /* = Nothing() */) { | 
| 2274 | MOZ_ASSERT(HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED))do { static_assert( mozilla::detail::AssertionConditionType< decltype(HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED))> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2274); AnnotateMozCrashReason("MOZ_ASSERT" "(" "HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)" ")"); do { *((volatile int*)__null) = 2274; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2275 | |
| 2276 | bool isSet = false; | 
| 2277 | uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); | 
| 2278 | |
| 2279 | MOZ_ASSERT(isSet,do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2281); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2281; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2280 | "Should have a VisibilityStateProperty value "do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2281); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2281; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2281 | "if NS_FRAME_VISIBILITY_IS_TRACKED is set")do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2281); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2281; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2282 | MOZ_ASSERT(visibleCount > 0,do { static_assert( mozilla::detail::AssertionConditionType< decltype(visibleCount > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(visibleCount > 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("visibleCount > 0" " (" "Frame is already nonvisible and we're " "decrementing its visible count?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2284); AnnotateMozCrashReason("MOZ_ASSERT" "(" "visibleCount > 0" ") (" "Frame is already nonvisible and we're " "decrementing its visible count?" ")"); do { *((volatile int*)__null) = 2284; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2283 | "Frame is already nonvisible and we're "do { static_assert( mozilla::detail::AssertionConditionType< decltype(visibleCount > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(visibleCount > 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("visibleCount > 0" " (" "Frame is already nonvisible and we're " "decrementing its visible count?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2284); AnnotateMozCrashReason("MOZ_ASSERT" "(" "visibleCount > 0" ") (" "Frame is already nonvisible and we're " "decrementing its visible count?" ")"); do { *((volatile int*)__null) = 2284; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2284 | "decrementing its visible count?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(visibleCount > 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(visibleCount > 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("visibleCount > 0" " (" "Frame is already nonvisible and we're " "decrementing its visible count?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2284); AnnotateMozCrashReason("MOZ_ASSERT" "(" "visibleCount > 0" ") (" "Frame is already nonvisible and we're " "decrementing its visible count?" ")"); do { *((volatile int*)__null) = 2284; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2285 | |
| 2286 | visibleCount--; | 
| 2287 | SetProperty(VisibilityStateProperty(), visibleCount); | 
| 2288 | if (visibleCount > 0) { | 
| 2289 | return; | 
| 2290 | } | 
| 2291 | |
| 2292 | // We just became nonvisible, so send an OnVisibilityChange() notification. | 
| 2293 | OnVisibilityChange(Visibility::ApproximatelyNonVisible, aNonvisibleAction); | 
| 2294 | } | 
| 2295 | |
| 2296 | void nsIFrame::IncApproximateVisibleCount() { | 
| 2297 | MOZ_ASSERT(HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED))do { static_assert( mozilla::detail::AssertionConditionType< decltype(HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED))> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2297); AnnotateMozCrashReason("MOZ_ASSERT" "(" "HasAnyStateBits(NS_FRAME_VISIBILITY_IS_TRACKED)" ")"); do { *((volatile int*)__null) = 2297; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2298 | |
| 2299 | bool isSet = false; | 
| 2300 | uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); | 
| 2301 | |
| 2302 | MOZ_ASSERT(isSet,do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2304); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2304; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2303 | "Should have a VisibilityStateProperty value "do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2304); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2304; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2304 | "if NS_FRAME_VISIBILITY_IS_TRACKED is set")do { static_assert( mozilla::detail::AssertionConditionType< decltype(isSet)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(isSet))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("isSet" " (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2304); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isSet" ") (" "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set" ")"); do { *((volatile int*)__null) = 2304; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2305 | |
| 2306 | visibleCount++; | 
| 2307 | SetProperty(VisibilityStateProperty(), visibleCount); | 
| 2308 | if (visibleCount > 1) { | 
| 2309 | return; | 
| 2310 | } | 
| 2311 | |
| 2312 | // We just became visible, so send an OnVisibilityChange() notification. | 
| 2313 | OnVisibilityChange(Visibility::ApproximatelyVisible); | 
| 2314 | } | 
| 2315 | |
| 2316 | void nsIFrame::OnVisibilityChange(Visibility aNewVisibility, | 
| 2317 | const Maybe<OnNonvisible>& aNonvisibleAction | 
| 2318 | /* = Nothing() */) { | 
| 2319 | // XXX(seth): In bug 1218990 we'll implement visibility tracking for CSS | 
| 2320 | // images here. | 
| 2321 | } | 
| 2322 | |
| 2323 | static nsIFrame* GetActiveSelectionFrame(nsPresContext* aPresContext, | 
| 2324 | nsIFrame* aFrame) { | 
| 2325 | nsIContent* capturingContent = PresShell::GetCapturingContent(); | 
| 2326 | if (capturingContent) { | 
| 2327 | nsIFrame* activeFrame = aPresContext->GetPrimaryFrameFor(capturingContent); | 
| 2328 | return activeFrame ? activeFrame : aFrame; | 
| 2329 | } | 
| 2330 | |
| 2331 | return aFrame; | 
| 2332 | } | 
| 2333 | |
| 2334 | int16_t nsIFrame::DetermineDisplaySelection() { | 
| 2335 | int16_t selType = nsISelectionController::SELECTION_OFF; | 
| 2336 | |
| 2337 | nsCOMPtr<nsISelectionController> selCon; | 
| 2338 | nsresult result = | 
| 2339 | GetSelectionController(PresContext(), getter_AddRefs(selCon)); | 
| 2340 | if (NS_SUCCEEDED(result)((bool)(__builtin_expect(!!(!NS_FAILED_impl(result)), 1))) && selCon) { | 
| 2341 | result = selCon->GetDisplaySelection(&selType); | 
| 2342 | if (NS_SUCCEEDED(result)((bool)(__builtin_expect(!!(!NS_FAILED_impl(result)), 1))) && | 
| 2343 | (selType != nsISelectionController::SELECTION_OFF)) { | 
| 2344 | // Check whether style allows selection. | 
| 2345 | if (!IsSelectable(nullptr)) { | 
| 2346 | selType = nsISelectionController::SELECTION_OFF; | 
| 2347 | } | 
| 2348 | } | 
| 2349 | } | 
| 2350 | return selType; | 
| 2351 | } | 
| 2352 | |
| 2353 | static Element* FindElementAncestorForMozSelection(nsIContent* aContent) { | 
| 2354 | NS_ENSURE_TRUE(aContent, nullptr)do { if ((__builtin_expect(!!(!(aContent)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aContent" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2354); return nullptr; } } while (false); | 
| 2355 | while (aContent && aContent->IsInNativeAnonymousSubtree()) { | 
| 2356 | aContent = aContent->GetClosestNativeAnonymousSubtreeRootParentOrHost(); | 
| 2357 | } | 
| 2358 | NS_ASSERTION(aContent, "aContent isn't in non-anonymous tree?")do { if (!(aContent)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "aContent isn't in non-anonymous tree?" , "aContent", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2358); MOZ_PretendNoReturn(); } } while (0); | 
| 2359 | return aContent ? aContent->GetAsElementOrParentElement() : nullptr; | 
| 2360 | } | 
| 2361 | |
| 2362 | already_AddRefed<ComputedStyle> nsIFrame::ComputeSelectionStyle( | 
| 2363 | int16_t aSelectionStatus) const { | 
| 2364 | // Just bail out if not a selection-status that ::selection applies to. | 
| 2365 | if (aSelectionStatus != nsISelectionController::SELECTION_ON && | 
| 2366 | aSelectionStatus != nsISelectionController::SELECTION_DISABLED) { | 
| 2367 | return nullptr; | 
| 2368 | } | 
| 2369 | Element* element = FindElementAncestorForMozSelection(GetContent()); | 
| 2370 | if (!element) { | 
| 2371 | return nullptr; | 
| 2372 | } | 
| 2373 | RefPtr<ComputedStyle> pseudoStyle = | 
| 2374 | PresContext()->StyleSet()->ProbePseudoElementStyle( | 
| 2375 | *element, PseudoStyleType::selection, nullptr, Style()); | 
| 2376 | if (!pseudoStyle) { | 
| 2377 | return nullptr; | 
| 2378 | } | 
| 2379 | // When in high-contrast mode, the style system ends up ignoring the color | 
| 2380 | // declarations, which means that the ::selection style becomes the inherited | 
| 2381 | // color, and default background. That's no good. | 
| 2382 | // When force-color-adjust is set to none allow using the color styles, | 
| 2383 | // as they will not be replaced. | 
| 2384 | if (PresContext()->ForcingColors() && | 
| 2385 | pseudoStyle->StyleText()->mForcedColorAdjust != | 
| 2386 | StyleForcedColorAdjust::None) { | 
| 2387 | return nullptr; | 
| 2388 | } | 
| 2389 | return do_AddRef(pseudoStyle); | 
| 2390 | } | 
| 2391 | |
| 2392 | already_AddRefed<ComputedStyle> nsIFrame::ComputeHighlightSelectionStyle( | 
| 2393 | nsAtom* aHighlightName) { | 
| 2394 | Element* element = FindElementAncestorForMozSelection(GetContent()); | 
| 2395 | if (!element) { | 
| 2396 | return nullptr; | 
| 2397 | } | 
| 2398 | return PresContext()->StyleSet()->ProbePseudoElementStyle( | 
| 2399 | *element, PseudoStyleType::highlight, aHighlightName, Style()); | 
| 2400 | } | 
| 2401 | |
| 2402 | already_AddRefed<ComputedStyle> nsIFrame::ComputeTargetTextStyle() const { | 
| 2403 | const Element* element = FindElementAncestorForMozSelection(GetContent()); | 
| 2404 | if (!element) { | 
| 2405 | return nullptr; | 
| 2406 | } | 
| 2407 | RefPtr pseudoStyle = PresContext()->StyleSet()->ProbePseudoElementStyle( | 
| 2408 | *element, PseudoStyleType::targetText, nullptr, Style()); | 
| 2409 | if (!pseudoStyle) { | 
| 2410 | return nullptr; | 
| 2411 | } | 
| 2412 | if (PresContext()->ForcingColors() && | 
| 2413 | pseudoStyle->StyleText()->mForcedColorAdjust != | 
| 2414 | StyleForcedColorAdjust::None) { | 
| 2415 | return nullptr; | 
| 2416 | } | 
| 2417 | return pseudoStyle.forget(); | 
| 2418 | } | 
| 2419 | |
| 2420 | bool nsIFrame::CanBeDynamicReflowRoot() const { | 
| 2421 | const auto& display = *StyleDisplay(); | 
| 2422 | if (IsLineParticipant() || display.mDisplay.IsRuby() || | 
| 2423 | display.IsInnerTableStyle() || | 
| 2424 | display.DisplayInside() == StyleDisplayInside::Table) { | 
| 2425 | // We have a display type where 'width' and 'height' don't actually set the | 
| 2426 | // width or height (i.e., the size depends on content). | 
| 2427 | MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT))>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT)" " (" "should not have dynamic reflow root bit" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2428); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT)" ") (" "should not have dynamic reflow root bit" ")"); do { * ((volatile int*)__null) = 2428; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) | 
| 2428 | "should not have dynamic reflow root bit")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT))>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT)" " (" "should not have dynamic reflow root bit" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2428); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_DYNAMIC_REFLOW_ROOT)" ") (" "should not have dynamic reflow root bit" ")"); do { * ((volatile int*)__null) = 2428; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); | 
| 2429 | return false; | 
| 2430 | } | 
| 2431 | |
| 2432 | // In general, frames that have contain:layout+size can be reflow roots. | 
| 2433 | // (One exception: table-wrapper frames don't work well as reflow roots, | 
| 2434 | // because their inner-table ReflowInput init path tries to reuse & deref | 
| 2435 | // the wrapper's containing block's reflow input, which may be null if we | 
| 2436 | // initiate reflow from the table-wrapper itself.) | 
| 2437 | // | 
| 2438 | // Changes to `contain` force frame reconstructions, so we used to use | 
| 2439 | // NS_FRAME_REFLOW_ROOT, this bit could be set for the whole lifetime of | 
| 2440 | // this frame. But after the support of `content-visibility: auto` which | 
| 2441 | // is with contain layout + size when it's not relevant to user, and only | 
| 2442 | // with contain layout when it is relevant. The frame does not reconstruct | 
| 2443 | // when the relevancy changes. So we use NS_FRAME_DYNAMIC_REFLOW_ROOT instead. | 
| 2444 | // | 
| 2445 | // We place it above the pref check on purpose, to make sure it works for | 
| 2446 | // containment even with the pref disabled. | 
| 2447 | if (display.IsContainLayout() && GetContainSizeAxes().IsBoth()) { | 
| 2448 | return true; | 
| 2449 | } | 
| 2450 | |
| 2451 | if (!StaticPrefs::layout_dynamic_reflow_roots_enabled()) { | 
| 2452 | return false; | 
| 2453 | } | 
| 2454 | |
| 2455 | // We can't serve as a dynamic reflow root if our used 'width' and 'height' | 
| 2456 | // might be influenced by content. | 
| 2457 | // | 
| 2458 | // FIXME: For display:block, we should probably optimize inline-size: auto. | 
| 2459 | // FIXME: Other flex and grid cases? | 
| 2460 | const auto& pos = *StylePosition(); | 
| 2461 | const auto& width = pos.GetWidth(); | 
| 2462 | const auto& height = pos.GetHeight(); | 
| 2463 | if (!width.IsLengthPercentage() || width.HasPercent() || | 
| 2464 | !height.IsLengthPercentage() || height.HasPercent() || | 
| 2465 | IsIntrinsicKeyword(pos.GetMinWidth()) || | 
| 2466 | IsIntrinsicKeyword(pos.GetMaxWidth()) || | 
| 2467 | IsIntrinsicKeyword(pos.GetMinHeight()) || | 
| 2468 | IsIntrinsicKeyword(pos.GetMaxHeight()) || | 
| 2469 | ((pos.GetMinWidth().IsAuto() || pos.GetMinHeight().IsAuto()) && | 
| 2470 | IsFlexOrGridItem())) { | 
| 2471 | return false; | 
| 2472 | } | 
| 2473 | |
| 2474 | // If our flex-basis is 'auto', it'll defer to 'width' (or 'height') which | 
| 2475 | // we've already checked. Otherwise, it preempts them, so we need to | 
| 2476 | // perform the same "could-this-value-be-influenced-by-content" checks that | 
| 2477 | // we performed for 'width' and 'height' above. | 
| 2478 | if (IsFlexItem()) { | 
| 2479 | const auto& flexBasis = pos.mFlexBasis; | 
| 2480 | if (!flexBasis.IsAuto()) { | 
| 2481 | if (!flexBasis.IsSize() || !flexBasis.AsSize().IsLengthPercentage() || | 
| 2482 | flexBasis.AsSize().HasPercent()) { | 
| 2483 | return false; | 
| 2484 | } | 
| 2485 | } | 
| 2486 | } | 
| 2487 | |
| 2488 | if (!IsFixedPosContainingBlock()) { | 
| 2489 | // We can't treat this frame as a reflow root, since dynamic changes | 
| 2490 | // to absolutely-positioned frames inside of it require that we | 
| 2491 | // reflow the placeholder before we reflow the absolutely positioned | 
| 2492 | // frame. | 
| 2493 | // FIXME: Alternatively, we could sort the reflow roots in | 
| 2494 | // PresShell::ProcessReflowCommands by depth in the tree, from | 
| 2495 | // deepest to least deep. However, for performance (FIXME) we | 
| 2496 | // should really be sorting them in the opposite order! | 
| 2497 | return false; | 
| 2498 | } | 
| 2499 | |
| 2500 | // If we participate in a container's block reflow context, or margins | 
| 2501 | // can collapse through us, we can't be a dynamic reflow root. | 
| 2502 | // (NS_BLOCK_BFC is block specific bit, check first as an optimization, it's | 
| 2503 | // okay because we also check that it is a block frame.) | 
| 2504 | if (!HasAnyStateBits(NS_BLOCK_BFC) && IsBlockFrameOrSubclass()) { | 
| 2505 | return false; | 
| 2506 | } | 
| 2507 | |
| 2508 | // Subgrids are never reflow roots, but 'contain:layout/paint' prevents | 
| 2509 | // creating a subgrid in the first place. | 
| 2510 | if (pos.mGridTemplateColumns.IsSubgrid() || | 
| 2511 | pos.mGridTemplateRows.IsSubgrid()) { | 
| 2512 | // NOTE: we could check that 'display' of our parent's primary frame is | 
| 2513 | // '[inline-]grid' here but that's probably not worth it in practice. | 
| 2514 | if (!display.IsContainLayout() && !display.IsContainPaint()) { | 
| 2515 | return false; | 
| 2516 | } | 
| 2517 | } | 
| 2518 | |
| 2519 | // If we are split, we can't be a dynamic reflow root. Our reflow status may | 
| 2520 | // change after reflow, and our parent is responsible to create or delete our | 
| 2521 | // next-in-flow. | 
| 2522 | if (GetPrevContinuation() || GetNextContinuation()) { | 
| 2523 | return false; | 
| 2524 | } | 
| 2525 | |
| 2526 | return true; | 
| 2527 | } | 
| 2528 | |
| 2529 | /******************************************************** | 
| 2530 | * Refreshes each content's frame | 
| 2531 | *********************************************************/ | 
| 2532 | |
| 2533 | void nsIFrame::DisplayOutlineUnconditional(nsDisplayListBuilder* aBuilder, | 
| 2534 | const nsDisplayListSet& aLists) { | 
| 2535 | // Per https://drafts.csswg.org/css-tables-3/#global-style-overrides: | 
| 2536 | // "All css properties of table-column and table-column-group boxes are | 
| 2537 | // ignored, except when explicitly specified by this specification." | 
| 2538 | // CSS outlines fall into this category, so we skip them on these boxes. | 
| 2539 | MOZ_ASSERT(!IsTableColGroupFrame() && !IsTableColFrame())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!IsTableColGroupFrame() && !IsTableColFrame( ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!IsTableColGroupFrame() && !IsTableColFrame( )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!IsTableColGroupFrame() && !IsTableColFrame()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2539); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsTableColGroupFrame() && !IsTableColFrame()" ")"); do { *((volatile int*)__null) = 2539; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2540 | const auto& outline = *StyleOutline(); | 
| 2541 | |
| 2542 | if (!outline.ShouldPaintOutline()) { | 
| 2543 | return; | 
| 2544 | } | 
| 2545 | |
| 2546 | // Outlines are painted by the table wrapper frame. | 
| 2547 | if (IsTableFrame()) { | 
| 2548 | return; | 
| 2549 | } | 
| 2550 | |
| 2551 | if (HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT) && | 
| 2552 | ScrollableOverflowRect().IsEmpty()) { | 
| 2553 | // Skip parts of IB-splits with an empty overflow rect, see bug 434301. | 
| 2554 | // We may still want to fix some of the overflow area calculations over in | 
| 2555 | // that bug. | 
| 2556 | return; | 
| 2557 | } | 
| 2558 | |
| 2559 | // We don't display outline-style: auto on themed frames that have their own | 
| 2560 | // focus indicators. | 
| 2561 | if (outline.mOutlineStyle.IsAuto()) { | 
| 2562 | auto* disp = StyleDisplay(); | 
| 2563 | if (IsThemed(disp) && PresContext()->Theme()->ThemeDrawsFocusForWidget( | 
| 2564 | this, disp->EffectiveAppearance())) { | 
| 2565 | return; | 
| 2566 | } | 
| 2567 | } | 
| 2568 | |
| 2569 | aLists.Outlines()->AppendNewToTop<nsDisplayOutline>(aBuilder, this); | 
| 2570 | } | 
| 2571 | |
| 2572 | void nsIFrame::DisplayOutline(nsDisplayListBuilder* aBuilder, | 
| 2573 | const nsDisplayListSet& aLists) { | 
| 2574 | if (!IsVisibleForPainting()) { | 
| 2575 | return; | 
| 2576 | } | 
| 2577 | |
| 2578 | DisplayOutlineUnconditional(aBuilder, aLists); | 
| 2579 | } | 
| 2580 | |
| 2581 | void nsIFrame::DisplayInsetBoxShadowUnconditional( | 
| 2582 | nsDisplayListBuilder* aBuilder, nsDisplayList* aList) { | 
| 2583 | // XXXbz should box-shadow for rows/rowgroups/columns/colgroups get painted | 
| 2584 | // just because we're visible? Or should it depend on the cell visibility | 
| 2585 | // when we're not the whole table? | 
| 2586 | const auto* effects = StyleEffects(); | 
| 2587 | if (effects->HasBoxShadowWithInset(true)) { | 
| 2588 | aList->AppendNewToTop<nsDisplayBoxShadowInner>(aBuilder, this); | 
| 2589 | } | 
| 2590 | } | 
| 2591 | |
| 2592 | void nsIFrame::DisplayInsetBoxShadow(nsDisplayListBuilder* aBuilder, | 
| 2593 | nsDisplayList* aList) { | 
| 2594 | if (!IsVisibleForPainting()) { | 
| 2595 | return; | 
| 2596 | } | 
| 2597 | |
| 2598 | DisplayInsetBoxShadowUnconditional(aBuilder, aList); | 
| 2599 | } | 
| 2600 | |
| 2601 | void nsIFrame::DisplayOutsetBoxShadowUnconditional( | 
| 2602 | nsDisplayListBuilder* aBuilder, nsDisplayList* aList) { | 
| 2603 | // XXXbz should box-shadow for rows/rowgroups/columns/colgroups get painted | 
| 2604 | // just because we're visible? Or should it depend on the cell visibility | 
| 2605 | // when we're not the whole table? | 
| 2606 | const auto* effects = StyleEffects(); | 
| 2607 | if (effects->HasBoxShadowWithInset(false)) { | 
| 2608 | aList->AppendNewToTop<nsDisplayBoxShadowOuter>(aBuilder, this); | 
| 2609 | } | 
| 2610 | } | 
| 2611 | |
| 2612 | void nsIFrame::DisplayOutsetBoxShadow(nsDisplayListBuilder* aBuilder, | 
| 2613 | nsDisplayList* aList) { | 
| 2614 | if (!IsVisibleForPainting()) { | 
| 2615 | return; | 
| 2616 | } | 
| 2617 | |
| 2618 | DisplayOutsetBoxShadowUnconditional(aBuilder, aList); | 
| 2619 | } | 
| 2620 | |
| 2621 | void nsIFrame::DisplayCaret(nsDisplayListBuilder* aBuilder, | 
| 2622 | nsDisplayList* aList) { | 
| 2623 | if (!IsVisibleForPainting()) { | 
| 2624 | return; | 
| 2625 | } | 
| 2626 | |
| 2627 | aList->AppendNewToTop<nsDisplayCaret>(aBuilder, this); | 
| 2628 | } | 
| 2629 | |
| 2630 | nscolor nsIFrame::GetCaretColorAt(int32_t aOffset) { | 
| 2631 | return nsLayoutUtils::GetTextColor(this, &nsStyleUI::mCaretColor); | 
| 2632 | } | 
| 2633 | |
| 2634 | auto nsIFrame::ComputeShouldPaintBackground() const -> ShouldPaintBackground { | 
| 2635 | nsPresContext* pc = PresContext(); | 
| 2636 | ShouldPaintBackground settings{pc->GetBackgroundColorDraw(), | 
| 2637 | pc->GetBackgroundImageDraw()}; | 
| 2638 | if (settings.mColor && settings.mImage) { | 
| 2639 | return settings; | 
| 2640 | } | 
| 2641 | |
| 2642 | if (StyleVisibility()->mPrintColorAdjust == StylePrintColorAdjust::Exact) { | 
| 2643 | return {true, true}; | 
| 2644 | } | 
| 2645 | |
| 2646 | return settings; | 
| 2647 | } | 
| 2648 | |
| 2649 | bool nsIFrame::DisplayBackgroundUnconditional(nsDisplayListBuilder* aBuilder, | 
| 2650 | const nsDisplayListSet& aLists) { | 
| 2651 | if (aBuilder->IsForEventDelivery() && !aBuilder->HitTestIsForVisibility()) { | 
| 2652 | // For hit-testing, we generally just need a light-weight data structure | 
| 2653 | // like nsDisplayEventReceiver. But if the hit-testing is for visibility, | 
| 2654 | // then we need to know the opaque region in order to determine whether to | 
| 2655 | // stop or not. | 
| 2656 | aLists.BorderBackground()->AppendNewToTop<nsDisplayEventReceiver>(aBuilder, | 
| 2657 | this); | 
| 2658 | return false; | 
| 2659 | } | 
| 2660 | |
| 2661 | const AppendedBackgroundType result = | 
| 2662 | nsDisplayBackgroundImage::AppendBackgroundItemsToTop( | 
| 2663 | aBuilder, this, | 
| 2664 | GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(this), | 
| 2665 | aLists.BorderBackground()); | 
| 2666 | |
| 2667 | if (result == AppendedBackgroundType::None) { | 
| 2668 | aBuilder->BuildCompositorHitTestInfoIfNeeded(this, | 
| 2669 | aLists.BorderBackground()); | 
| 2670 | } | 
| 2671 | |
| 2672 | return result == AppendedBackgroundType::ThemedBackground; | 
| 2673 | } | 
| 2674 | |
| 2675 | void nsIFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder, | 
| 2676 | const nsDisplayListSet& aLists) { | 
| 2677 | // The visibility check belongs here since child elements have the | 
| 2678 | // opportunity to override the visibility property and display even if | 
| 2679 | // their parent is hidden. | 
| 2680 | if (!IsVisibleForPainting()) { | 
| 2681 | return; | 
| 2682 | } | 
| 2683 | |
| 2684 | DisplayOutsetBoxShadowUnconditional(aBuilder, aLists.BorderBackground()); | 
| 2685 | |
| 2686 | bool bgIsThemed = DisplayBackgroundUnconditional(aBuilder, aLists); | 
| 2687 | DisplayInsetBoxShadowUnconditional(aBuilder, aLists.BorderBackground()); | 
| 2688 | |
| 2689 | // If there's a themed background, we should not create a border item. | 
| 2690 | // It won't be rendered. | 
| 2691 | // Don't paint borders for tables here, since they paint them in a different | 
| 2692 | // order. | 
| 2693 | if (!bgIsThemed && StyleBorder()->HasBorder() && !IsTableFrame()) { | 
| 2694 | aLists.BorderBackground()->AppendNewToTop<nsDisplayBorder>(aBuilder, this); | 
| 2695 | } | 
| 2696 | |
| 2697 | DisplayOutlineUnconditional(aBuilder, aLists); | 
| 2698 | } | 
| 2699 | |
| 2700 | inline static bool IsSVGContentWithCSSClip(const nsIFrame* aFrame) { | 
| 2701 | // The CSS spec says that the 'clip' property only applies to absolutely | 
| 2702 | // positioned elements, whereas the SVG spec says that it applies to SVG | 
| 2703 | // elements regardless of the value of the 'position' property. Here we obey | 
| 2704 | // the CSS spec for outer-<svg> (since that's what we generally do), but | 
| 2705 | // obey the SVG spec for other SVG elements to which 'clip' applies. | 
| 2706 | return aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT) && | 
| 2707 | aFrame->GetContent()->IsAnyOfSVGElements(nsGkAtoms::svg, | 
| 2708 | nsGkAtoms::foreignObject); | 
| 2709 | } | 
| 2710 | |
| 2711 | Maybe<nsRect> nsIFrame::GetClipPropClipRect(const nsStyleDisplay* aDisp, | 
| 2712 | const nsStyleEffects* aEffects, | 
| 2713 | const nsSize& aSize) const { | 
| 2714 | if (aEffects->mClip.IsAuto() || | 
| 2715 | !(aDisp->IsAbsolutelyPositioned(this) || IsSVGContentWithCSSClip(this))) { | 
| 2716 | return Nothing(); | 
| 2717 | } | 
| 2718 | |
| 2719 | auto& clipRect = aEffects->mClip.AsRect(); | 
| 2720 | nsRect rect = clipRect.ToLayoutRect(); | 
| 2721 | if (MOZ_LIKELY(StyleBorder()->mBoxDecorationBreak ==(__builtin_expect(!!(StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Slice), 1)) | 
| 2722 | StyleBoxDecorationBreak::Slice)(__builtin_expect(!!(StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Slice), 1))) { | 
| 2723 | // The clip applies to the joined boxes so it's relative the first | 
| 2724 | // continuation. | 
| 2725 | nscoord y = 0; | 
| 2726 | for (nsIFrame* f = GetPrevContinuation(); f; f = f->GetPrevContinuation()) { | 
| 2727 | y += f->GetRect().height; | 
| 2728 | } | 
| 2729 | rect.MoveBy(nsPoint(0, -y)); | 
| 2730 | } | 
| 2731 | |
| 2732 | if (clipRect.right.IsAuto()) { | 
| 2733 | rect.width = aSize.width - rect.x; | 
| 2734 | } | 
| 2735 | if (clipRect.bottom.IsAuto()) { | 
| 2736 | rect.height = aSize.height - rect.y; | 
| 2737 | } | 
| 2738 | return Some(rect); | 
| 2739 | } | 
| 2740 | |
| 2741 | /** | 
| 2742 | * If the CSS 'overflow' property applies to this frame, and is not | 
| 2743 | * handled by constructing a dedicated nsHTML/XULScrollFrame, set up clipping | 
| 2744 | * for that overflow in aBuilder->ClipState() to clip all containing-block | 
| 2745 | * descendants. | 
| 2746 | */ | 
| 2747 | static void ApplyOverflowClipping( | 
| 2748 | nsDisplayListBuilder* aBuilder, const nsIFrame* aFrame, | 
| 2749 | PhysicalAxes aClipAxes, | 
| 2750 | DisplayListClipState::AutoClipMultiple& aClipState) { | 
| 2751 | // Only 'clip' is handled here (and 'hidden' for table frames, and any | 
| 2752 | // non-'visible' value for blocks in a paginated context). | 
| 2753 | // We allow 'clip' to apply to any kind of frame. This is required by | 
| 2754 | // comboboxes which make their display text (an inline frame) have clipping. | 
| 2755 | MOZ_ASSERT(!aClipAxes.isEmpty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aClipAxes.isEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!aClipAxes.isEmpty()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!aClipAxes.isEmpty()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2755); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aClipAxes.isEmpty()" ")"); do { *((volatile int*)__null) = 2755; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2756 | MOZ_ASSERT(aFrame->ShouldApplyOverflowClipping(aFrame->StyleDisplay()) ==do { static_assert( mozilla::detail::AssertionConditionType< decltype(aFrame->ShouldApplyOverflowClipping(aFrame->StyleDisplay ()) == aClipAxes)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aFrame->ShouldApplyOverflowClipping (aFrame->StyleDisplay()) == aClipAxes))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aFrame->ShouldApplyOverflowClipping(aFrame->StyleDisplay()) == aClipAxes" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2757); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame->ShouldApplyOverflowClipping(aFrame->StyleDisplay()) == aClipAxes" ")"); do { *((volatile int*)__null) = 2757; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 2757 | aClipAxes)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aFrame->ShouldApplyOverflowClipping(aFrame->StyleDisplay ()) == aClipAxes)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aFrame->ShouldApplyOverflowClipping (aFrame->StyleDisplay()) == aClipAxes))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aFrame->ShouldApplyOverflowClipping(aFrame->StyleDisplay()) == aClipAxes" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2757); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame->ShouldApplyOverflowClipping(aFrame->StyleDisplay()) == aClipAxes" ")"); do { *((volatile int*)__null) = 2757; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2758 | |
| 2759 | nsRect clipRect; | 
| 2760 | bool haveRadii = false; | 
| 2761 | nscoord radii[8]; | 
| 2762 | auto* disp = aFrame->StyleDisplay(); | 
| 2763 | // Only deflate the padding if we clip to the content-box in that axis. | 
| 2764 | auto wm = aFrame->GetWritingMode(); | 
| 2765 | bool cbH = (wm.IsVertical() ? disp->mOverflowClipBoxBlock | 
| 2766 | : disp->mOverflowClipBoxInline) == | 
| 2767 | StyleOverflowClipBox::ContentBox; | 
| 2768 | bool cbV = (wm.IsVertical() ? disp->mOverflowClipBoxInline | 
| 2769 | : disp->mOverflowClipBoxBlock) == | 
| 2770 | StyleOverflowClipBox::ContentBox; | 
| 2771 | |
| 2772 | nsMargin boxMargin = -aFrame->GetUsedPadding(); | 
| 2773 | if (!cbH) { | 
| 2774 | boxMargin.left = boxMargin.right = nscoord(0); | 
| 2775 | } | 
| 2776 | if (!cbV) { | 
| 2777 | boxMargin.top = boxMargin.bottom = nscoord(0); | 
| 2778 | } | 
| 2779 | |
| 2780 | auto clipMargin = aFrame->OverflowClipMargin(aClipAxes); | 
| 2781 | |
| 2782 | boxMargin -= aFrame->GetUsedBorder(); | 
| 2783 | boxMargin += nsMargin(clipMargin.height, clipMargin.width, clipMargin.height, | 
| 2784 | clipMargin.width); | 
| 2785 | boxMargin.ApplySkipSides(aFrame->GetSkipSides()); | 
| 2786 | |
| 2787 | nsRect rect(nsPoint(0, 0), aFrame->GetSize()); | 
| 2788 | rect.Inflate(boxMargin); | 
| 2789 | if (MOZ_UNLIKELY(!aClipAxes.contains(PhysicalAxis::Horizontal))(__builtin_expect(!!(!aClipAxes.contains(PhysicalAxis::Horizontal )), 0))) { | 
| 2790 | // NOTE(mats) We shouldn't be clipping at all in this dimension really, | 
| 2791 | // but clipping in just one axis isn't supported by our GFX APIs so we | 
| 2792 | // clip to our visual overflow rect instead. | 
| 2793 | nsRect o = aFrame->InkOverflowRect(); | 
| 2794 | rect.x = o.x; | 
| 2795 | rect.width = o.width; | 
| 2796 | } | 
| 2797 | if (MOZ_UNLIKELY(!aClipAxes.contains(PhysicalAxis::Vertical))(__builtin_expect(!!(!aClipAxes.contains(PhysicalAxis::Vertical )), 0))) { | 
| 2798 | // See the note above. | 
| 2799 | nsRect o = aFrame->InkOverflowRect(); | 
| 2800 | rect.y = o.y; | 
| 2801 | rect.height = o.height; | 
| 2802 | } | 
| 2803 | clipRect = rect + aBuilder->ToReferenceFrame(aFrame); | 
| 2804 | haveRadii = aFrame->GetBoxBorderRadii(radii, boxMargin); | 
| 2805 | aClipState.ClipContainingBlockDescendantsExtra(clipRect, | 
| 2806 | haveRadii ? radii : nullptr); | 
| 2807 | } | 
| 2808 | |
| 2809 | nsSize nsIFrame::OverflowClipMargin(PhysicalAxes aClipAxes) const { | 
| 2810 | nsSize result; | 
| 2811 | if (aClipAxes.isEmpty()) { | 
| 2812 | return result; | 
| 2813 | } | 
| 2814 | const auto& margin = StyleMargin()->mOverflowClipMargin; | 
| 2815 | if (margin.IsZero()) { | 
| 2816 | return result; | 
| 2817 | } | 
| 2818 | nscoord marginAu = margin.ToAppUnits(); | 
| 2819 | if (aClipAxes.contains(PhysicalAxis::Horizontal)) { | 
| 2820 | result.width = marginAu; | 
| 2821 | } | 
| 2822 | if (aClipAxes.contains(PhysicalAxis::Vertical)) { | 
| 2823 | result.height = marginAu; | 
| 2824 | } | 
| 2825 | return result; | 
| 2826 | } | 
| 2827 | |
| 2828 | /** | 
| 2829 | * Returns whether a display item that gets created with the builder's current | 
| 2830 | * state will have a scrolled clip, i.e. a clip that is scrolled by a scroll | 
| 2831 | * frame which does not move the item itself. | 
| 2832 | */ | 
| 2833 | static bool BuilderHasScrolledClip(nsDisplayListBuilder* aBuilder) { | 
| 2834 | const DisplayItemClipChain* currentClip = | 
| 2835 | aBuilder->ClipState().GetCurrentCombinedClipChain(aBuilder); | 
| 2836 | if (!currentClip) { | 
| 2837 | return false; | 
| 2838 | } | 
| 2839 | |
| 2840 | const ActiveScrolledRoot* currentClipASR = currentClip->mASR; | 
| 2841 | const ActiveScrolledRoot* currentASR = aBuilder->CurrentActiveScrolledRoot(); | 
| 2842 | return ActiveScrolledRoot::PickDescendant(currentClipASR, currentASR) != | 
| 2843 | currentASR; | 
| 2844 | } | 
| 2845 | |
| 2846 | class AutoSaveRestoreContainsBlendMode { | 
| 2847 | nsDisplayListBuilder& mBuilder; | 
| 2848 | bool mSavedContainsBlendMode; | 
| 2849 | |
| 2850 | public: | 
| 2851 | explicit AutoSaveRestoreContainsBlendMode(nsDisplayListBuilder& aBuilder) | 
| 2852 | : mBuilder(aBuilder), | 
| 2853 | mSavedContainsBlendMode(aBuilder.ContainsBlendMode()) {} | 
| 2854 | |
| 2855 | ~AutoSaveRestoreContainsBlendMode() { | 
| 2856 | mBuilder.SetContainsBlendMode(mSavedContainsBlendMode); | 
| 2857 | } | 
| 2858 | }; | 
| 2859 | |
| 2860 | static bool IsFrameOrAncestorApzAware(nsIFrame* aFrame) { | 
| 2861 | nsIContent* node = aFrame->GetContent(); | 
| 2862 | if (!node) { | 
| 2863 | return false; | 
| 2864 | } | 
| 2865 | |
| 2866 | do { | 
| 2867 | if (node->IsNodeApzAware()) { | 
| 2868 | return true; | 
| 2869 | } | 
| 2870 | nsIContent* shadowRoot = node->GetShadowRoot(); | 
| 2871 | if (shadowRoot && shadowRoot->IsNodeApzAware()) { | 
| 2872 | return true; | 
| 2873 | } | 
| 2874 | |
| 2875 | // Even if the node owning aFrame doesn't have apz-aware event listeners | 
| 2876 | // itself, its shadow root or display: contents ancestors (which have no | 
| 2877 | // frames) might, so we need to account for them too. | 
| 2878 | } while ((node = node->GetFlattenedTreeParent()) && node->IsElement() && | 
| 2879 | node->AsElement()->IsDisplayContents()); | 
| 2880 | |
| 2881 | return false; | 
| 2882 | } | 
| 2883 | |
| 2884 | static void CheckForApzAwareEventHandlers(nsDisplayListBuilder* aBuilder, | 
| 2885 | nsIFrame* aFrame) { | 
| 2886 | if (aBuilder->GetAncestorHasApzAwareEventHandler()) { | 
| 2887 | return; | 
| 2888 | } | 
| 2889 | |
| 2890 | if (IsFrameOrAncestorApzAware(aFrame)) { | 
| 2891 | aBuilder->SetAncestorHasApzAwareEventHandler(true); | 
| 2892 | } | 
| 2893 | } | 
| 2894 | |
| 2895 | static void UpdateCurrentHitTestInfo(nsDisplayListBuilder* aBuilder, | 
| 2896 | nsIFrame* aFrame) { | 
| 2897 | if (!aBuilder->BuildCompositorHitTestInfo()) { | 
| 2898 | // Compositor hit test info is not used. | 
| 2899 | return; | 
| 2900 | } | 
| 2901 | |
| 2902 | CheckForApzAwareEventHandlers(aBuilder, aFrame); | 
| 2903 | |
| 2904 | const CompositorHitTestInfo info = aFrame->GetCompositorHitTestInfo(aBuilder); | 
| 2905 | aBuilder->SetCompositorHitTestInfo(info); | 
| 2906 | } | 
| 2907 | |
| 2908 | /** | 
| 2909 | * True if aDescendant participates the context aAncestor participating. | 
| 2910 | */ | 
| 2911 | static bool FrameParticipatesIn3DContext(nsIFrame* aAncestor, | 
| 2912 | nsIFrame* aDescendant) { | 
| 2913 | MOZ_ASSERT(aAncestor != aDescendant)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aAncestor != aDescendant)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aAncestor != aDescendant))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aAncestor != aDescendant" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2913); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aAncestor != aDescendant" ")"); do { *((volatile int*)__null) = 2913; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2914 | MOZ_ASSERT(aAncestor->GetContent() != aDescendant->GetContent())do { static_assert( mozilla::detail::AssertionConditionType< decltype(aAncestor->GetContent() != aDescendant->GetContent ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aAncestor->GetContent() != aDescendant->GetContent ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aAncestor->GetContent() != aDescendant->GetContent()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2914); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aAncestor->GetContent() != aDescendant->GetContent()" ")"); do { *((volatile int*)__null) = 2914; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2915 | MOZ_ASSERT(aAncestor->Extend3DContext())do { static_assert( mozilla::detail::AssertionConditionType< decltype(aAncestor->Extend3DContext())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aAncestor->Extend3DContext ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aAncestor->Extend3DContext()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2915); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aAncestor->Extend3DContext()" ")"); do { *((volatile int*)__null) = 2915; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2916 | |
| 2917 | nsIFrame* ancestor = aAncestor->FirstContinuation(); | 
| 2918 | MOZ_ASSERT(ancestor->IsPrimaryFrame())do { static_assert( mozilla::detail::AssertionConditionType< decltype(ancestor->IsPrimaryFrame())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(ancestor->IsPrimaryFrame( )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("ancestor->IsPrimaryFrame()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2918); AnnotateMozCrashReason("MOZ_ASSERT" "(" "ancestor->IsPrimaryFrame()" ")"); do { *((volatile int*)__null) = 2918; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2919 | |
| 2920 | nsIFrame* frame; | 
| 2921 | for (frame = aDescendant->GetClosestFlattenedTreeAncestorPrimaryFrame(); | 
| 2922 | frame && ancestor != frame; | 
| 2923 | frame = frame->GetClosestFlattenedTreeAncestorPrimaryFrame()) { | 
| 2924 | if (!frame->Extend3DContext()) { | 
| 2925 | return false; | 
| 2926 | } | 
| 2927 | } | 
| 2928 | |
| 2929 | MOZ_ASSERT(frame == ancestor)do { static_assert( mozilla::detail::AssertionConditionType< decltype(frame == ancestor)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(frame == ancestor))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("frame == ancestor" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 2929); AnnotateMozCrashReason("MOZ_ASSERT" "(" "frame == ancestor" ")"); do { *((volatile int*)__null) = 2929; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 2930 | return true; | 
| 2931 | } | 
| 2932 | |
| 2933 | static bool ItemParticipatesIn3DContext(nsIFrame* aAncestor, | 
| 2934 | nsDisplayItem* aItem) { | 
| 2935 | auto type = aItem->GetType(); | 
| 2936 | const bool isContainer = type == DisplayItemType::TYPE_WRAP_LIST || | 
| 2937 | type == DisplayItemType::TYPE_CONTAINER; | 
| 2938 | |
| 2939 | if (isContainer && aItem->GetChildren()->Length() == 1) { | 
| 2940 | // If the wraplist has only one child item, use the type of that item. | 
| 2941 | type = aItem->GetChildren()->GetBottom()->GetType(); | 
| 2942 | } | 
| 2943 | |
| 2944 | if (type != DisplayItemType::TYPE_TRANSFORM && | 
| 2945 | type != DisplayItemType::TYPE_PERSPECTIVE) { | 
| 2946 | return false; | 
| 2947 | } | 
| 2948 | nsIFrame* transformFrame = aItem->Frame(); | 
| 2949 | if (aAncestor->GetContent() == transformFrame->GetContent()) { | 
| 2950 | return true; | 
| 2951 | } | 
| 2952 | return FrameParticipatesIn3DContext(aAncestor, transformFrame); | 
| 2953 | } | 
| 2954 | |
| 2955 | static void WrapSeparatorTransform(nsDisplayListBuilder* aBuilder, | 
| 2956 | nsIFrame* aFrame, | 
| 2957 | nsDisplayList* aNonParticipants, | 
| 2958 | nsDisplayList* aParticipants, int aIndex, | 
| 2959 | nsDisplayItem** aSeparator) { | 
| 2960 | if (aNonParticipants->IsEmpty()) { | 
| 2961 | return; | 
| 2962 | } | 
| 2963 | |
| 2964 | nsDisplayTransform* item = MakeDisplayItemWithIndex<nsDisplayTransform>( | 
| 2965 | aBuilder, aFrame, aIndex, aNonParticipants, aBuilder->GetVisibleRect()); | 
| 2966 | |
| 2967 | if (*aSeparator == nullptr && item) { | 
| 2968 | *aSeparator = item; | 
| 2969 | } | 
| 2970 | |
| 2971 | aParticipants->AppendToTop(item); | 
| 2972 | } | 
| 2973 | |
| 2974 | // Try to compute a clip rect to bound the contents of the mask item | 
| 2975 | // that will be built for |aMaskedFrame|. If we're not able to compute | 
| 2976 | // one, return an empty Maybe. | 
| 2977 | // The returned clip rect, if there is one, is relative to |aMaskedFrame|. | 
| 2978 | static Maybe<nsRect> ComputeClipForMaskItem( | 
| 2979 | nsDisplayListBuilder* aBuilder, nsIFrame* aMaskedFrame, | 
| 2980 | const SVGUtils::MaskUsage& aMaskUsage) { | 
| 2981 | const nsStyleSVGReset* svgReset = aMaskedFrame->StyleSVGReset(); | 
| 2982 | |
| 2983 | nsPoint offsetToUserSpace = | 
| 2984 | nsLayoutUtils::ComputeOffsetToUserSpace(aBuilder, aMaskedFrame); | 
| 2985 | int32_t devPixelRatio = aMaskedFrame->PresContext()->AppUnitsPerDevPixel(); | 
| 2986 | gfxPoint devPixelOffsetToUserSpace = | 
| 2987 | nsLayoutUtils::PointToGfxPoint(offsetToUserSpace, devPixelRatio); | 
| 2988 | CSSToLayoutDeviceScale cssToDevScale = | 
| 2989 | aMaskedFrame->PresContext()->CSSToDevPixelScale(); | 
| 2990 | |
| 2991 | nsPoint toReferenceFrame; | 
| 2992 | aBuilder->FindReferenceFrameFor(aMaskedFrame, &toReferenceFrame); | 
| 2993 | |
| 2994 | Maybe<gfxRect> combinedClip; | 
| 2995 | if (aMaskUsage.ShouldApplyBasicShapeOrPath()) { | 
| 2996 | Maybe<Rect> result = | 
| 2997 | CSSClipPathInstance::GetBoundingRectForBasicShapeOrPathClip( | 
| 2998 | aMaskedFrame, svgReset->mClipPath); | 
| 2999 | if (result) { | 
| 3000 | combinedClip = Some(ThebesRect(*result)); | 
| 3001 | } | 
| 3002 | } else if (aMaskUsage.ShouldApplyClipPath()) { | 
| 3003 | gfxRect result = SVGUtils::GetBBox( | 
| 3004 | aMaskedFrame, | 
| 3005 | SVGUtils::eBBoxIncludeClipped | SVGUtils::eBBoxIncludeFill | | 
| 3006 | SVGUtils::eBBoxIncludeMarkers | SVGUtils::eBBoxIncludeStroke | | 
| 3007 | SVGUtils::eDoNotClipToBBoxOfContentInsideClipPath); | 
| 3008 | combinedClip = Some( | 
| 3009 | ThebesRect((CSSRect::FromUnknownRect(ToRect(result)) * cssToDevScale) | 
| 3010 | .ToUnknownRect())); | 
| 3011 | } else { | 
| 3012 | // The code for this case is adapted from ComputeMaskGeometry(). | 
| 3013 | |
| 3014 | nsRect borderArea(toReferenceFrame, aMaskedFrame->GetSize()); | 
| 3015 | borderArea -= offsetToUserSpace; | 
| 3016 | |
| 3017 | // Use an infinite dirty rect to pass into nsCSSRendering:: | 
| 3018 | // GetImageLayerClip() because we don't have an actual dirty rect to | 
| 3019 | // pass in. This is fine because the only time GetImageLayerClip() will | 
| 3020 | // not intersect the incoming dirty rect with something is in the "NoClip" | 
| 3021 | // case, and we handle that specially. | 
| 3022 | nsRect dirtyRect(nscoord_MIN / 2, nscoord_MIN / 2, nscoord_MAX, | 
| 3023 | nscoord_MAX); | 
| 3024 | |
| 3025 | nsIFrame* firstFrame = | 
| 3026 | nsLayoutUtils::FirstContinuationOrIBSplitSibling(aMaskedFrame); | 
| 3027 | nsTArray<SVGMaskFrame*> maskFrames; | 
| 3028 | // XXX check return value? | 
| 3029 | SVGObserverUtils::GetAndObserveMasks(firstFrame, &maskFrames); | 
| 3030 | |
| 3031 | for (uint32_t i = 0; i < maskFrames.Length(); ++i) { | 
| 3032 | gfxRect clipArea; | 
| 3033 | if (maskFrames[i]) { | 
| 3034 | clipArea = maskFrames[i]->GetMaskArea(aMaskedFrame); | 
| 3035 | clipArea = ThebesRect( | 
| 3036 | (CSSRect::FromUnknownRect(ToRect(clipArea)) * cssToDevScale) | 
| 3037 | .ToUnknownRect()); | 
| 3038 | } else { | 
| 3039 | const auto& layer = svgReset->mMask.mLayers[i]; | 
| 3040 | if (layer.mClip == StyleGeometryBox::NoClip) { | 
| 3041 | return Nothing(); | 
| 3042 | } | 
| 3043 | |
| 3044 | nsCSSRendering::ImageLayerClipState clipState; | 
| 3045 | nsCSSRendering::GetImageLayerClip( | 
| 3046 | layer, aMaskedFrame, *aMaskedFrame->StyleBorder(), borderArea, | 
| 3047 | dirtyRect, false /* aWillPaintBorder */, devPixelRatio, &clipState); | 
| 3048 | clipArea = clipState.mDirtyRectInDevPx; | 
| 3049 | } | 
| 3050 | combinedClip = UnionMaybeRects(combinedClip, Some(clipArea)); | 
| 3051 | } | 
| 3052 | } | 
| 3053 | if (combinedClip) { | 
| 3054 | // Convert to user space. | 
| 3055 | *combinedClip += devPixelOffsetToUserSpace; | 
| 3056 | |
| 3057 | // Round the clip out. In FrameLayerBuilder we round clips to nearest | 
| 3058 | // pixels, and if we have a really thin clip here, that can cause the | 
| 3059 | // clip to become empty if we didn't round out here. | 
| 3060 | // The rounding happens in coordinates that are relative to the reference | 
| 3061 | // frame, which matches what FrameLayerBuilder does. | 
| 3062 | combinedClip->RoundOut(); | 
| 3063 | |
| 3064 | // Convert to app units. | 
| 3065 | nsRect result = | 
| 3066 | nsLayoutUtils::RoundGfxRectToAppRect(*combinedClip, devPixelRatio); | 
| 3067 | |
| 3068 | // The resulting clip is relative to the reference frame, but the caller | 
| 3069 | // expects it to be relative to the masked frame, so adjust it. | 
| 3070 | result -= toReferenceFrame; | 
| 3071 | return Some(result); | 
| 3072 | } | 
| 3073 | return Nothing(); | 
| 3074 | } | 
| 3075 | |
| 3076 | struct AutoCheckBuilder { | 
| 3077 | explicit AutoCheckBuilder(nsDisplayListBuilder* aBuilder) | 
| 3078 | : mBuilder(aBuilder) { | 
| 3079 | aBuilder->Check(); | 
| 3080 | } | 
| 3081 | |
| 3082 | ~AutoCheckBuilder() { mBuilder->Check(); } | 
| 3083 | |
| 3084 | nsDisplayListBuilder* mBuilder; | 
| 3085 | }; | 
| 3086 | |
| 3087 | /** | 
| 3088 | * Tries to reuse a top-level stacking context item from the previous paint. | 
| 3089 | * Returns true if an item was reused, otherwise false. | 
| 3090 | */ | 
| 3091 | bool TryToReuseStackingContextItem(nsDisplayListBuilder* aBuilder, | 
| 3092 | nsDisplayList* aList, nsIFrame* aFrame) { | 
| 3093 | if (!aBuilder->IsForPainting() || !aBuilder->IsPartialUpdate() || | 
| 3094 | aBuilder->InInvalidSubtree()) { | 
| 3095 | return false; | 
| 3096 | } | 
| 3097 | |
| 3098 | if (aFrame->IsFrameModified() || aFrame->HasModifiedDescendants()) { | 
| 3099 | return false; | 
| 3100 | } | 
| 3101 | |
| 3102 | auto& items = aFrame->DisplayItems(); | 
| 3103 | auto* res = std::find_if( | 
| 3104 | items.begin(), items.end(), | 
| 3105 | [](nsDisplayItem* aItem) { return aItem->IsPreProcessed(); }); | 
| 3106 | |
| 3107 | if (res == items.end()) { | 
| 3108 | return false; | 
| 3109 | } | 
| 3110 | |
| 3111 | nsDisplayItem* container = *res; | 
| 3112 | MOZ_ASSERT(container->Frame() == aFrame)do { static_assert( mozilla::detail::AssertionConditionType< decltype(container->Frame() == aFrame)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(container->Frame() == aFrame ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "container->Frame() == aFrame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3112); AnnotateMozCrashReason("MOZ_ASSERT" "(" "container->Frame() == aFrame" ")"); do { *((volatile int*)__null) = 3112; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 3113 | DL_LOGD("RDL - Found SC item %p (%s) (frame: %p)", container,do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "RDL - Found SC item %p (%s) (frame: %p)", container, container->Name(), container->Frame()); } } while (0) | 
| 3114 | container->Name(), container->Frame())do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Debug)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Debug, "RDL - Found SC item %p (%s) (frame: %p)", container, container->Name(), container->Frame()); } } while (0); | 
| 3115 | |
| 3116 | aList->AppendToTop(container); | 
| 3117 | aBuilder->ReuseDisplayItem(container); | 
| 3118 | return true; | 
| 3119 | } | 
| 3120 | |
| 3121 | void nsIFrame::BuildDisplayListForStackingContext( | 
| 3122 | nsDisplayListBuilder* aBuilder, nsDisplayList* aList, | 
| 3123 | bool* aCreatedContainerItem) { | 
| 3124 | #ifdef DEBUG1 | 
| 3125 | DL_LOGV("BuildDisplayListForStackingContext (%p) <", this)do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "BuildDisplayListForStackingContext (%p) <" , this); } } while (0); | 
| 3126 | ScopeExit e( | 
| 3127 | [this]() { DL_LOGV("> BuildDisplayListForStackingContext (%p)", this)do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "> BuildDisplayListForStackingContext (%p)" , this); } } while (0); }); | 
| 3128 | #endif | 
| 3129 | |
| 3130 | AutoCheckBuilder check(aBuilder); | 
| 3131 | |
| 3132 | if (aBuilder->IsReusingStackingContextItems() && | 
| 3133 | TryToReuseStackingContextItem(aBuilder, aList, this)) { | 
| 3134 | if (aCreatedContainerItem) { | 
| 3135 | *aCreatedContainerItem = true; | 
| 3136 | } | 
| 3137 | return; | 
| 3138 | } | 
| 3139 | |
| 3140 | if (HasAnyStateBits(NS_FRAME_TOO_DEEP_IN_FRAME_TREE)) { | 
| 3141 | return; | 
| 3142 | } | 
| 3143 | |
| 3144 | const auto& style = *Style(); | 
| 3145 | const nsStyleDisplay* disp = style.StyleDisplay(); | 
| 3146 | const nsStyleEffects* effects = style.StyleEffects(); | 
| 3147 | EffectSet* effectSetForOpacity = | 
| 3148 | EffectSet::GetForFrame(this, nsCSSPropertyIDSet::OpacityProperties()); | 
| 3149 | // We can stop right away if this is a zero-opacity stacking context and | 
| 3150 | // we're painting, and we're not animating opacity. | 
| 3151 | bool needHitTestInfo = aBuilder->BuildCompositorHitTestInfo() && | 
| 3152 | Style()->PointerEvents() != StylePointerEvents::None; | 
| 3153 | bool opacityItemForEventsOnly = false; | 
| 3154 | if (effects->IsTransparent() && aBuilder->IsForPainting() && | 
| 3155 | !(disp->mWillChange.bits & StyleWillChangeBits::OPACITY) && | 
| 3156 | !nsLayoutUtils::HasAnimationOfPropertySet( | 
| 3157 | this, nsCSSPropertyIDSet::OpacityProperties(), effectSetForOpacity)) { | 
| 3158 | if (needHitTestInfo) { | 
| 3159 | opacityItemForEventsOnly = true; | 
| 3160 | } else { | 
| 3161 | return; | 
| 3162 | } | 
| 3163 | } | 
| 3164 | |
| 3165 | if (aBuilder->IsForPainting() && disp->mWillChange.bits) { | 
| 3166 | aBuilder->AddToWillChangeBudget(this, GetSize()); | 
| 3167 | } | 
| 3168 | |
| 3169 | // For preserves3d, use the dirty rect already installed on the | 
| 3170 | // builder, since aDirtyRect maybe distorted for transforms along | 
| 3171 | // the chain. | 
| 3172 | nsRect visibleRect = aBuilder->GetVisibleRect(); | 
| 3173 | nsRect dirtyRect = aBuilder->GetDirtyRect(); | 
| 3174 | |
| 3175 | // We build an opacity item if it's not going to be drawn by SVG content. | 
| 3176 | // We could in principle skip creating an nsDisplayOpacity item if | 
| 3177 | // nsDisplayOpacity::NeedsActiveLayer returns false and usingSVGEffects is | 
| 3178 | // true (the nsDisplayFilter/nsDisplayMasksAndClipPaths could handle the | 
| 3179 | // opacity). Since SVG has perf issues where we sometimes spend a lot of | 
| 3180 | // time creating display list items that might be helpful. We'd need to | 
| 3181 | // restore our mechanism to do that (changed in bug 1482403), and we'd | 
| 3182 | // need to invalidate the frame if the value that would be return from | 
| 3183 | // NeedsActiveLayer was to change, which we don't currently do. | 
| 3184 | const bool useOpacity = | 
| 3185 | HasVisualOpacity(disp, effects, effectSetForOpacity) && | 
| 3186 | !SVGUtils::CanOptimizeOpacity(this); | 
| 3187 | |
| 3188 | const bool isTransformed = IsTransformed(); | 
| 3189 | const bool hasPerspective = isTransformed && HasPerspective(); | 
| 3190 | const bool extend3DContext = | 
| 3191 | Extend3DContext(disp, effects, effectSetForOpacity); | 
| 3192 | const bool combines3DTransformWithAncestors = | 
| 3193 | (extend3DContext || isTransformed) && Combines3DTransformWithAncestors(); | 
| 3194 | |
| 3195 | Maybe<nsDisplayListBuilder::AutoPreserves3DContext> autoPreserves3DContext; | 
| 3196 | if (extend3DContext && !combines3DTransformWithAncestors) { | 
| 3197 | // Start a new preserves3d context to keep informations on | 
| 3198 | // nsDisplayListBuilder. | 
| 3199 | autoPreserves3DContext.emplace(aBuilder); | 
| 3200 | // Save dirty rect on the builder to avoid being distorted for | 
| 3201 | // multiple transforms along the chain. | 
| 3202 | aBuilder->SavePreserves3DRect(); | 
| 3203 | |
| 3204 | // We rebuild everything within preserve-3d and don't try | 
| 3205 | // to retain, so override the dirty rect now. | 
| 3206 | if (aBuilder->IsRetainingDisplayList()) { | 
| 3207 | dirtyRect = visibleRect; | 
| 3208 | aBuilder->SetDisablePartialUpdates(true); | 
| 3209 | } | 
| 3210 | } | 
| 3211 | |
| 3212 | const bool useBlendMode = effects->mMixBlendMode != StyleBlend::Normal; | 
| 3213 | if (useBlendMode) { | 
| 3214 | aBuilder->SetContainsBlendMode(true); | 
| 3215 | } | 
| 3216 | |
| 3217 | // reset blend mode so we can keep track if this stacking context needs have | 
| 3218 | // a nsDisplayBlendContainer. Set the blend mode back when the routine exits | 
| 3219 | // so we keep track if the parent stacking context needs a container too. | 
| 3220 | AutoSaveRestoreContainsBlendMode autoRestoreBlendMode(*aBuilder); | 
| 3221 | aBuilder->SetContainsBlendMode(false); | 
| 3222 | |
| 3223 | // NOTE: When changing this condition make sure to tweak ScrollContainerFrame | 
| 3224 | // as well. | 
| 3225 | bool usingBackdropFilter = effects->HasBackdropFilters() && | 
| 3226 | IsVisibleForPainting() && | 
| 3227 | !style.IsRootElementStyle(); | 
| 3228 | |
| 3229 | nsRect visibleRectOutsideTransform = visibleRect; | 
| 3230 | nsDisplayTransform::PrerenderInfo prerenderInfo; | 
| 3231 | bool inTransform = aBuilder->IsInTransform(); | 
| 3232 | if (isTransformed) { | 
| 3233 | prerenderInfo = nsDisplayTransform::ShouldPrerenderTransformedContent( | 
| 3234 | aBuilder, this, &visibleRect); | 
| 3235 | |
| 3236 | switch (prerenderInfo.mDecision) { | 
| 3237 | case nsDisplayTransform::PrerenderDecision::Full: | 
| 3238 | case nsDisplayTransform::PrerenderDecision::Partial: | 
| 3239 | dirtyRect = visibleRect; | 
| 3240 | break; | 
| 3241 | case nsDisplayTransform::PrerenderDecision::No: { | 
| 3242 | // If we didn't prerender an animated frame in a preserve-3d context, | 
| 3243 | // then we want disable async animations for the rest of the preserve-3d | 
| 3244 | // (especially ancestors). | 
| 3245 | if ((extend3DContext || combines3DTransformWithAncestors) && | 
| 3246 | prerenderInfo.mHasAnimations) { | 
| 3247 | aBuilder->SavePreserves3DAllowAsyncAnimation(false); | 
| 3248 | } | 
| 3249 | |
| 3250 | const nsRect overflow = InkOverflowRectRelativeToSelf(); | 
| 3251 | if (overflow.IsEmpty() && !extend3DContext) { | 
| 3252 | return; | 
| 3253 | } | 
| 3254 | |
| 3255 | // If we're in preserve-3d then grab the dirty rect that was given to | 
| 3256 | // the root and transform using the combined transform. | 
| 3257 | if (combines3DTransformWithAncestors) { | 
| 3258 | visibleRect = dirtyRect = aBuilder->GetPreserves3DRect(); | 
| 3259 | } | 
| 3260 | |
| 3261 | const float appPerDev = PresContext()->AppUnitsPerDevPixel(); | 
| 3262 | uint32_t flags = nsDisplayTransform::kTransformRectFlags & | 
| 3263 | ~nsDisplayTransform::OFFSET_BY_ORIGIN; | 
| 3264 | if (!hasPerspective) { | 
| 3265 | flags &= ~nsDisplayTransform::INCLUDE_PERSPECTIVE; | 
| 3266 | } | 
| 3267 | if (!combines3DTransformWithAncestors) { | 
| 3268 | flags &= ~nsDisplayTransform::INCLUDE_PRESERVE3D_ANCESTORS; | 
| 3269 | } | 
| 3270 | auto transform = nsDisplayTransform::GetResultingTransformMatrix( | 
| 3271 | this, nsPoint(), appPerDev, flags); | 
| 3272 | nsRect untransformedDirtyRect; | 
| 3273 | if (nsDisplayTransform::UntransformRect(dirtyRect, overflow, transform, | 
| 3274 | appPerDev, | 
| 3275 | &untransformedDirtyRect)) { | 
| 3276 | dirtyRect = untransformedDirtyRect; | 
| 3277 | nsDisplayTransform::UntransformRect(visibleRect, overflow, transform, | 
| 3278 | appPerDev, &visibleRect); | 
| 3279 | } else { | 
| 3280 | // This should only happen if the transform is singular, in which case | 
| 3281 | // nothing is visible anyway | 
| 3282 | dirtyRect.SetEmpty(); | 
| 3283 | visibleRect.SetEmpty(); | 
| 3284 | } | 
| 3285 | } | 
| 3286 | } | 
| 3287 | inTransform = true; | 
| 3288 | } else if (IsFixedPosContainingBlock()) { | 
| 3289 | // Restict the building area to the overflow rect for these frames, since | 
| 3290 | // RetainedDisplayListBuilder uses it to know if the size of the stacking | 
| 3291 | // context changed. | 
| 3292 | visibleRect.IntersectRect(visibleRect, InkOverflowRect()); | 
| 3293 | dirtyRect.IntersectRect(dirtyRect, InkOverflowRect()); | 
| 3294 | } | 
| 3295 | |
| 3296 | bool hasOverrideDirtyRect = false; | 
| 3297 | // If we're doing a partial build, we're not invalid and we're capable | 
| 3298 | // of having an override building rect (stacking context and fixed pos | 
| 3299 | // containing block), then we should assume we have one. | 
| 3300 | // Either we have an explicit one, or nothing in our subtree changed and | 
| 3301 | // we have an implicit empty rect. | 
| 3302 | // | 
| 3303 | // These conditions should match |CanStoreDisplayListBuildingRect()| in | 
| 3304 | // RetainedDisplayListBuilder.cpp | 
| 3305 | if (!aBuilder->IsReusingStackingContextItems() && | 
| 3306 | aBuilder->IsPartialUpdate() && !aBuilder->InInvalidSubtree() && | 
| 3307 | !IsFrameModified() && IsFixedPosContainingBlock() && | 
| 3308 | !GetPrevContinuation() && !GetNextContinuation()) { | 
| 3309 | dirtyRect = nsRect(); | 
| 3310 | if (HasOverrideDirtyRegion()) { | 
| 3311 | nsDisplayListBuilder::DisplayListBuildingData* data = | 
| 3312 | GetProperty(nsDisplayListBuilder::DisplayListBuildingRect()); | 
| 3313 | if (data) { | 
| 3314 | dirtyRect = data->mDirtyRect.Intersect(visibleRect); | 
| 3315 | hasOverrideDirtyRect = true; | 
| 3316 | } | 
| 3317 | } | 
| 3318 | } | 
| 3319 | |
| 3320 | bool usingFilter = effects->HasFilters() && !style.IsRootElementStyle(); | 
| 3321 | SVGUtils::MaskUsage maskUsage = SVGUtils::DetermineMaskUsage(this, false); | 
| 3322 | bool usingMask = maskUsage.UsingMaskOrClipPath(); | 
| 3323 | bool usingSVGEffects = usingFilter || usingMask; | 
| 3324 | |
| 3325 | nsRect visibleRectOutsideSVGEffects = visibleRect; | 
| 3326 | nsDisplayList hoistedScrollInfoItemsStorage(aBuilder); | 
| 3327 | if (usingSVGEffects) { | 
| 3328 | dirtyRect = | 
| 3329 | SVGIntegrationUtils::GetRequiredSourceForInvalidArea(this, dirtyRect); | 
| 3330 | visibleRect = | 
| 3331 | SVGIntegrationUtils::GetRequiredSourceForInvalidArea(this, visibleRect); | 
| 3332 | aBuilder->EnterSVGEffectsContents(this, &hoistedScrollInfoItemsStorage); | 
| 3333 | } | 
| 3334 | |
| 3335 | bool useStickyPosition = disp->mPosition == StylePositionProperty::Sticky; | 
| 3336 | |
| 3337 | bool useFixedPosition = | 
| 3338 | disp->mPosition == StylePositionProperty::Fixed && | 
| 3339 | aBuilder->IsPaintingToWindow() && | 
| 3340 | (DisplayPortUtils::IsFixedPosFrameInDisplayPort(this) || | 
| 3341 | BuilderHasScrolledClip(aBuilder)); | 
| 3342 | |
| 3343 | nsDisplayListBuilder::AutoBuildingDisplayList buildingDisplayList( | 
| 3344 | aBuilder, this, visibleRect, dirtyRect, isTransformed); | 
| 3345 | |
| 3346 | UpdateCurrentHitTestInfo(aBuilder, this); | 
| 3347 | |
| 3348 | // Depending on the effects that are applied to this frame, we can create | 
| 3349 | // multiple container display items and wrap them around our contents. | 
| 3350 | // This enum lists all the potential container display items, in the order | 
| 3351 | // outside to inside. | 
| 3352 | enum class ContainerItemType : uint8_t { | 
| 3353 | None = 0, | 
| 3354 | OwnLayerIfNeeded, | 
| 3355 | BlendMode, | 
| 3356 | FixedPosition, | 
| 3357 | OwnLayerForTransformWithRoundedClip, | 
| 3358 | Perspective, | 
| 3359 | Transform, | 
| 3360 | SeparatorTransforms, | 
| 3361 | Opacity, | 
| 3362 | Filter, | 
| 3363 | BlendContainer | 
| 3364 | }; | 
| 3365 | |
| 3366 | nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder); | 
| 3367 | |
| 3368 | auto cssClip = GetClipPropClipRect(disp, effects, GetSize()); | 
| 3369 | auto ApplyClipProp = [&](DisplayListClipState::AutoSaveRestore& aClipState) { | 
| 3370 | if (!cssClip) { | 
| 3371 | return; | 
| 3372 | } | 
| 3373 | nsPoint offset = aBuilder->GetCurrentFrameOffsetToReferenceFrame(); | 
| 3374 | aBuilder->IntersectDirtyRect(*cssClip); | 
| 3375 | aBuilder->IntersectVisibleRect(*cssClip); | 
| 3376 | aClipState.ClipContentDescendants(*cssClip + offset); | 
| 3377 | }; | 
| 3378 | |
| 3379 | // The CSS clip property is effectively inside the transform, but outside the | 
| 3380 | // filters. So if we're not transformed we can apply it just here for | 
| 3381 | // simplicity, instead of on each of the places that handle clipCapturedBy. | 
| 3382 | DisplayListClipState::AutoSaveRestore untransformedCssClip(aBuilder); | 
| 3383 | if (!isTransformed) { | 
| 3384 | ApplyClipProp(untransformedCssClip); | 
| 3385 | } | 
| 3386 | |
| 3387 | // If there is a current clip, then depending on the container items we | 
| 3388 | // create, different things can happen to it. Some container items simply | 
| 3389 | // propagate the clip to their children and aren't clipped themselves. | 
| 3390 | // But other container items, especially those that establish a different | 
| 3391 | // geometry for their contents (e.g. transforms), capture the clip on | 
| 3392 | // themselves and unset the clip for their contents. If we create more than | 
| 3393 | // one of those container items, the clip will be captured on the outermost | 
| 3394 | // one and the inner container items will be unclipped. | 
| 3395 | ContainerItemType clipCapturedBy = ContainerItemType::None; | 
| 3396 | if (useFixedPosition) { | 
| 3397 | clipCapturedBy = ContainerItemType::FixedPosition; | 
| 3398 | } else if (isTransformed) { | 
| 3399 | const DisplayItemClipChain* currentClip = | 
| 3400 | aBuilder->ClipState().GetCurrentCombinedClipChain(aBuilder); | 
| 3401 | if ((hasPerspective || extend3DContext) && | 
| 3402 | (currentClip && currentClip->HasRoundedCorners())) { | 
| 3403 | // If we're creating an nsDisplayTransform item that is going to combine | 
| 3404 | // its transform with its children (preserve-3d or perspective), then we | 
| 3405 | // can't have an intermediate surface. Mask layers force an intermediate | 
| 3406 | // surface, so if we're going to need both then create a separate | 
| 3407 | // wrapping layer for the mask. | 
| 3408 | clipCapturedBy = ContainerItemType::OwnLayerForTransformWithRoundedClip; | 
| 3409 | } else if (hasPerspective) { | 
| 3410 | clipCapturedBy = ContainerItemType::Perspective; | 
| 3411 | } else { | 
| 3412 | clipCapturedBy = ContainerItemType::Transform; | 
| 3413 | } | 
| 3414 | } else if (usingFilter) { | 
| 3415 | clipCapturedBy = ContainerItemType::Filter; | 
| 3416 | } | 
| 3417 | |
| 3418 | DisplayListClipState::AutoSaveRestore clipState(aBuilder); | 
| 3419 | if (clipCapturedBy != ContainerItemType::None) { | 
| 3420 | clipState.Clear(); | 
| 3421 | } | 
| 3422 | |
| 3423 | DisplayListClipState::AutoSaveRestore transformedCssClip(aBuilder); | 
| 3424 | if (isTransformed) { | 
| 3425 | // FIXME(emilio, bug 1525159): In the case we have a both a transform _and_ | 
| 3426 | // filters, this clips the input to the filters as well, which is not | 
| 3427 | // correct (clipping by the `clip` property is supposed to happen after | 
| 3428 | // applying the filter effects, per [1]. | 
| 3429 | // | 
| 3430 | // This is not a regression though, since we used to do that anyway before | 
| 3431 | // bug 1514384, and even without the transform we get it wrong. | 
| 3432 | // | 
| 3433 | // [1]: https://drafts.fxtf.org/css-masking/#placement | 
| 3434 | ApplyClipProp(transformedCssClip); | 
| 3435 | } | 
| 3436 | |
| 3437 | uint32_t numActiveScrollframesEncounteredBefore = | 
| 3438 | aBuilder->GetNumActiveScrollframesEncountered(); | 
| 3439 | |
| 3440 | nsDisplayListCollection set(aBuilder); | 
| 3441 | Maybe<nsRect> clipForMask; | 
| 3442 | { | 
| 3443 | DisplayListClipState::AutoSaveRestore nestedClipState(aBuilder); | 
| 3444 | nsDisplayListBuilder::AutoInTransformSetter inTransformSetter(aBuilder, | 
| 3445 | inTransform); | 
| 3446 | nsDisplayListBuilder::AutoEnterFilter filterASRSetter(aBuilder, | 
| 3447 | usingFilter); | 
| 3448 | nsDisplayListBuilder::AutoInEventsOnly inEventsSetter( | 
| 3449 | aBuilder, opacityItemForEventsOnly); | 
| 3450 | |
| 3451 | // If we have a mask, compute a clip to bound the masked content. | 
| 3452 | // This is necessary in case the content moves with an ancestor | 
| 3453 | // ASR of the mask. | 
| 3454 | // Don't do this if we also have a filter, because then the clip | 
| 3455 | // would be applied before the filter, violating | 
| 3456 | // https://www.w3.org/TR/filter-effects-1/#placement. | 
| 3457 | // Filters are a containing block for fixed and absolute descendants, | 
| 3458 | // so the masked content cannot move with an ancestor ASR. | 
| 3459 | if (usingMask && !usingFilter) { | 
| 3460 | clipForMask = ComputeClipForMaskItem(aBuilder, this, maskUsage); | 
| 3461 | if (clipForMask) { | 
| 3462 | aBuilder->IntersectDirtyRect(*clipForMask); | 
| 3463 | aBuilder->IntersectVisibleRect(*clipForMask); | 
| 3464 | nestedClipState.ClipContentDescendants( | 
| 3465 | *clipForMask + aBuilder->GetCurrentFrameOffsetToReferenceFrame()); | 
| 3466 | } | 
| 3467 | } | 
| 3468 | |
| 3469 | // extend3DContext also guarantees that applyAbsPosClipping and | 
| 3470 | // usingSVGEffects are false We only modify the preserve-3d rect if we are | 
| 3471 | // the top of a preserve-3d heirarchy | 
| 3472 | if (extend3DContext) { | 
| 3473 | // Mark these first so MarkAbsoluteFramesForDisplayList knows if we are | 
| 3474 | // going to be forced to descend into frames. | 
| 3475 | aBuilder->MarkPreserve3DFramesForDisplayList(this); | 
| 3476 | } | 
| 3477 | |
| 3478 | aBuilder->AdjustWindowDraggingRegion(this); | 
| 3479 | |
| 3480 | MarkAbsoluteFramesForDisplayList(aBuilder); | 
| 3481 | aBuilder->Check(); | 
| 3482 | BuildDisplayList(aBuilder, set); | 
| 3483 | SetBuiltDisplayList(true); | 
| 3484 | aBuilder->Check(); | 
| 3485 | aBuilder->DisplayCaret(this, set.Outlines()); | 
| 3486 | |
| 3487 | // Blend modes are a real pain for retained display lists. We build a blend | 
| 3488 | // container item if the built list contains any blend mode items within | 
| 3489 | // the current stacking context. This can change without an invalidation | 
| 3490 | // to the stacking context frame, or the blend mode frame (e.g. by moving | 
| 3491 | // an intermediate frame). | 
| 3492 | // When we gain/remove a blend container item, we need to mark this frame | 
| 3493 | // as invalid and have the full display list for merging to track | 
| 3494 | // the change correctly. | 
| 3495 | // It seems really hard to track this in advance, as the bookkeeping | 
| 3496 | // required to note which stacking contexts have blend descendants | 
| 3497 | // is complex and likely to be buggy. | 
| 3498 | // Instead we're doing the sad thing, detecting it afterwards, and just | 
| 3499 | // repeating display list building if it changed. | 
| 3500 | // We have to repeat building for the entire display list (or at least | 
| 3501 | // the outer stacking context), since we need to mark this frame as invalid | 
| 3502 | // to remove any existing content that isn't wrapped in the blend container, | 
| 3503 | // and then we need to build content infront/behind the blend container | 
| 3504 | // to get correct positioning during merging. | 
| 3505 | if (aBuilder->ContainsBlendMode() && aBuilder->IsRetainingDisplayList()) { | 
| 3506 | if (aBuilder->IsPartialUpdate()) { | 
| 3507 | aBuilder->SetPartialBuildFailed(true); | 
| 3508 | } else { | 
| 3509 | aBuilder->SetDisablePartialUpdates(true); | 
| 3510 | } | 
| 3511 | } | 
| 3512 | } | 
| 3513 | |
| 3514 | if (aBuilder->IsBackgroundOnly()) { | 
| 3515 | set.BlockBorderBackgrounds()->DeleteAll(aBuilder); | 
| 3516 | set.Floats()->DeleteAll(aBuilder); | 
| 3517 | set.Content()->DeleteAll(aBuilder); | 
| 3518 | set.PositionedDescendants()->DeleteAll(aBuilder); | 
| 3519 | set.Outlines()->DeleteAll(aBuilder); | 
| 3520 | } | 
| 3521 | |
| 3522 | if (hasOverrideDirtyRect && | 
| 3523 | StaticPrefs::layout_display_list_show_rebuild_area()) { | 
| 3524 | nsDisplaySolidColor* color = MakeDisplayItem<nsDisplaySolidColor>( | 
| 3525 | aBuilder, this, | 
| 3526 | dirtyRect + aBuilder->GetCurrentFrameOffsetToReferenceFrame(), | 
| 3527 | NS_RGBA(255, 0, 0, 64)((nscolor)(((64) << 24) | ((0) << 16) | ((0) << 8) | (255))), false); | 
| 3528 | if (color) { | 
| 3529 | color->SetOverrideZIndex(INT32_MAX(2147483647)); | 
| 3530 | set.PositionedDescendants()->AppendToTop(color); | 
| 3531 | } | 
| 3532 | } | 
| 3533 | |
| 3534 | nsIContent* content = GetContent(); | 
| 3535 | if (!content) { | 
| 3536 | content = PresContext()->Document()->GetRootElement(); | 
| 3537 | } | 
| 3538 | |
| 3539 | nsDisplayList resultList(aBuilder); | 
| 3540 | set.SerializeWithCorrectZOrder(&resultList, content); | 
| 3541 | |
| 3542 | // Get the ASR to use for the container items that we create here. | 
| 3543 | const ActiveScrolledRoot* containerItemASR = contASRTracker.GetContainerASR(); | 
| 3544 | |
| 3545 | bool createdContainer = false; | 
| 3546 | |
| 3547 | // If adding both a nsDisplayBlendContainer and a nsDisplayBlendMode to the | 
| 3548 | // same list, the nsDisplayBlendContainer should be added first. This only | 
| 3549 | // happens when the element creating this stacking context has mix-blend-mode | 
| 3550 | // and also contains a child which has mix-blend-mode. | 
| 3551 | // The nsDisplayBlendContainer must be added to the list first, so it does not | 
| 3552 | // isolate the containing element blending as well. | 
| 3553 | if (aBuilder->ContainsBlendMode()) { | 
| 3554 | resultList.AppendToTop(nsDisplayBlendContainer::CreateForMixBlendMode( | 
| 3555 | aBuilder, this, &resultList, containerItemASR)); | 
| 3556 | createdContainer = true; | 
| 3557 | } | 
| 3558 | |
| 3559 | if (usingBackdropFilter) { | 
| 3560 | nsRect backdropRect = | 
| 3561 | GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(this); | 
| 3562 | resultList.AppendNewToTop<nsDisplayBackdropFilters>( | 
| 3563 | aBuilder, this, &resultList, backdropRect, this); | 
| 3564 | createdContainer = true; | 
| 3565 | } | 
| 3566 | |
| 3567 | // If there are any SVG effects, wrap the list up in an SVG effects item | 
| 3568 | // (which also handles CSS group opacity). Note that we create an SVG effects | 
| 3569 | // item even if resultList is empty, since a filter can produce graphical | 
| 3570 | // output even if the element being filtered wouldn't otherwise do so. | 
| 3571 | if (usingSVGEffects) { | 
| 3572 | MOZ_ASSERT(usingFilter || usingMask,do { static_assert( mozilla::detail::AssertionConditionType< decltype(usingFilter || usingMask)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(usingFilter || usingMask))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("usingFilter || usingMask" " (" "Beside filter & mask/clip-path, what else effect do we have?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3573); AnnotateMozCrashReason("MOZ_ASSERT" "(" "usingFilter || usingMask" ") (" "Beside filter & mask/clip-path, what else effect do we have?" ")"); do { *((volatile int*)__null) = 3573; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 3573 | "Beside filter & mask/clip-path, what else effect do we have?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(usingFilter || usingMask)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(usingFilter || usingMask))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("usingFilter || usingMask" " (" "Beside filter & mask/clip-path, what else effect do we have?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3573); AnnotateMozCrashReason("MOZ_ASSERT" "(" "usingFilter || usingMask" ") (" "Beside filter & mask/clip-path, what else effect do we have?" ")"); do { *((volatile int*)__null) = 3573; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 3574 | |
| 3575 | if (clipCapturedBy == ContainerItemType::Filter) { | 
| 3576 | clipState.Restore(); | 
| 3577 | } | 
| 3578 | // Revert to the post-filter dirty rect. | 
| 3579 | aBuilder->SetVisibleRect(visibleRectOutsideSVGEffects); | 
| 3580 | |
| 3581 | // Skip all filter effects while generating glyph mask. | 
| 3582 | if (usingFilter && !aBuilder->IsForGenerateGlyphMask()) { | 
| 3583 | /* List now emptied, so add the new list to the top. */ | 
| 3584 | resultList.AppendNewToTop<nsDisplayFilters>(aBuilder, this, &resultList, | 
| 3585 | this, usingBackdropFilter); | 
| 3586 | createdContainer = true; | 
| Value stored to 'createdContainer' is never read | |
| 3587 | } | 
| 3588 | |
| 3589 | if (usingMask) { | 
| 3590 | // The mask should move with aBuilder->CurrentActiveScrolledRoot(), so | 
| 3591 | // that's the ASR we prefer to use for the mask item. However, we can | 
| 3592 | // only do this if the mask if clipped with respect to that ASR, because | 
| 3593 | // an item always needs to have finite bounds with respect to its ASR. | 
| 3594 | // If we weren't able to compute a clip for the mask, we fall back to | 
| 3595 | // using containerItemASR, which is the lowest common ancestor clip of | 
| 3596 | // the mask's contents. That's not entirely correct, but it satisfies | 
| 3597 | // the base requirement of the ASR system (that items have finite bounds | 
| 3598 | // wrt. their ASR). | 
| 3599 | const ActiveScrolledRoot* maskASR = | 
| 3600 | clipForMask.isSome() ? aBuilder->CurrentActiveScrolledRoot() | 
| 3601 | : containerItemASR; | 
| 3602 | /* List now emptied, so add the new list to the top. */ | 
| 3603 | resultList.AppendNewToTop<nsDisplayMasksAndClipPaths>( | 
| 3604 | aBuilder, this, &resultList, maskASR, usingBackdropFilter); | 
| 3605 | createdContainer = true; | 
| 3606 | } | 
| 3607 | |
| 3608 | // TODO(miko): We could probably create a wraplist here and avoid creating | 
| 3609 | // it later in |BuildDisplayListForChild()|. | 
| 3610 | createdContainer = false; | 
| 3611 | |
| 3612 | // Also add the hoisted scroll info items. We need those for APZ scrolling | 
| 3613 | // because nsDisplayMasksAndClipPaths items can't build active layers. | 
| 3614 | aBuilder->ExitSVGEffectsContents(); | 
| 3615 | resultList.AppendToTop(&hoistedScrollInfoItemsStorage); | 
| 3616 | } | 
| 3617 | |
| 3618 | // If the list is non-empty and there is CSS group opacity without SVG | 
| 3619 | // effects, wrap it up in an opacity item. | 
| 3620 | if (useOpacity) { | 
| 3621 | const bool needsActiveOpacityLayer = | 
| 3622 | nsDisplayOpacity::NeedsActiveLayer(aBuilder, this); | 
| 3623 | resultList.AppendNewToTop<nsDisplayOpacity>( | 
| 3624 | aBuilder, this, &resultList, containerItemASR, opacityItemForEventsOnly, | 
| 3625 | needsActiveOpacityLayer, usingBackdropFilter); | 
| 3626 | createdContainer = true; | 
| 3627 | } | 
| 3628 | |
| 3629 | // If we're going to apply a transformation and don't have preserve-3d set, | 
| 3630 | // wrap everything in an nsDisplayTransform. If there's nothing in the list, | 
| 3631 | // don't add anything. | 
| 3632 | // | 
| 3633 | // For the preserve-3d case we want to individually wrap every child in the | 
| 3634 | // list with a separate nsDisplayTransform instead. When the child is already | 
| 3635 | // an nsDisplayTransform, we can skip this step, as the computed transform | 
| 3636 | // will already include our own. | 
| 3637 | // | 
| 3638 | // We also traverse into sublists created by nsDisplayWrapList, so that we | 
| 3639 | // find all the correct children. | 
| 3640 | if (isTransformed && extend3DContext) { | 
| 3641 | // Install dummy nsDisplayTransform as a leaf containing | 
| 3642 | // descendants not participating this 3D rendering context. | 
| 3643 | nsDisplayList nonparticipants(aBuilder); | 
| 3644 | nsDisplayList participants(aBuilder); | 
| 3645 | int index = 1; | 
| 3646 | |
| 3647 | nsDisplayItem* separator = nullptr; | 
| 3648 | |
| 3649 | // TODO: This can be simplified: |participants| is just |resultList|. | 
| 3650 | for (nsDisplayItem* item : resultList.TakeItems()) { | 
| 3651 | if (ItemParticipatesIn3DContext(this, item) && | 
| 3652 | !item->GetClip().HasClip()) { | 
| 3653 | // The frame of this item participates the same 3D context. | 
| 3654 | WrapSeparatorTransform(aBuilder, this, &nonparticipants, &participants, | 
| 3655 | index++, &separator); | 
| 3656 | |
| 3657 | participants.AppendToTop(item); | 
| 3658 | } else { | 
| 3659 | // The frame of the item doesn't participate the current | 
| 3660 | // context, or has no transform. | 
| 3661 | // | 
| 3662 | // For items participating but not transformed, they are add | 
| 3663 | // to nonparticipants to get a separator layer for handling | 
| 3664 | // clips, if there is, on an intermediate surface. | 
| 3665 | // \see ContainerLayer::DefaultComputeEffectiveTransforms(). | 
| 3666 | nonparticipants.AppendToTop(item); | 
| 3667 | } | 
| 3668 | } | 
| 3669 | WrapSeparatorTransform(aBuilder, this, &nonparticipants, &participants, | 
| 3670 | index++, &separator); | 
| 3671 | |
| 3672 | if (separator) { | 
| 3673 | createdContainer = true; | 
| 3674 | } | 
| 3675 | |
| 3676 | resultList.AppendToTop(&participants); | 
| 3677 | } | 
| 3678 | |
| 3679 | if (isTransformed) { | 
| 3680 | transformedCssClip.Restore(); | 
| 3681 | if (clipCapturedBy == ContainerItemType::Transform) { | 
| 3682 | // Restore clip state now so nsDisplayTransform is clipped properly. | 
| 3683 | clipState.Restore(); | 
| 3684 | } | 
| 3685 | // Revert to the dirtyrect coming in from the parent, without our transform | 
| 3686 | // taken into account. | 
| 3687 | aBuilder->SetVisibleRect(visibleRectOutsideTransform); | 
| 3688 | |
| 3689 | if (this != aBuilder->RootReferenceFrame()) { | 
| 3690 | // Revert to the outer reference frame and offset because all display | 
| 3691 | // items we create from now on are outside the transform. | 
| 3692 | nsPoint toOuterReferenceFrame; | 
| 3693 | const nsIFrame* outerReferenceFrame = | 
| 3694 | aBuilder->FindReferenceFrameFor(GetParent(), &toOuterReferenceFrame); | 
| 3695 | toOuterReferenceFrame += GetPosition(); | 
| 3696 | |
| 3697 | buildingDisplayList.SetReferenceFrameAndCurrentOffset( | 
| 3698 | outerReferenceFrame, toOuterReferenceFrame); | 
| 3699 | } | 
| 3700 | |
| 3701 | // We would like to block async animations for ancestors of ones not | 
| 3702 | // prerendered in the preserve-3d tree. Now that we've finished processing | 
| 3703 | // all descendants, update allowAsyncAnimation to take their prerender | 
| 3704 | // state into account | 
| 3705 | // FIXME: We don't block async animations for previous siblings because | 
| 3706 | // their prerender decisions have been made. We may have to figure out a | 
| 3707 | // better way to rollback their prerender decisions. | 
| 3708 | // Alternatively we could not block animations for later siblings, and only | 
| 3709 | // block them for ancestors of a blocked one. | 
| 3710 | if ((extend3DContext || combines3DTransformWithAncestors) && | 
| 3711 | prerenderInfo.CanUseAsyncAnimations() && | 
| 3712 | !aBuilder->GetPreserves3DAllowAsyncAnimation()) { | 
| 3713 | // aBuilder->GetPreserves3DAllowAsyncAnimation() means the inner or | 
| 3714 | // previous silbing frames are allowed/disallowed for async animations. | 
| 3715 | prerenderInfo.mDecision = nsDisplayTransform::PrerenderDecision::No; | 
| 3716 | } | 
| 3717 | |
| 3718 | nsDisplayTransform* transformItem = MakeDisplayItem<nsDisplayTransform>( | 
| 3719 | aBuilder, this, &resultList, visibleRect, prerenderInfo.mDecision, | 
| 3720 | usingBackdropFilter); | 
| 3721 | if (transformItem) { | 
| 3722 | resultList.AppendToTop(transformItem); | 
| 3723 | createdContainer = true; | 
| 3724 | |
| 3725 | if (numActiveScrollframesEncounteredBefore != | 
| 3726 | aBuilder->GetNumActiveScrollframesEncountered()) { | 
| 3727 | transformItem->SetContainsASRs(true); | 
| 3728 | } | 
| 3729 | |
| 3730 | if (hasPerspective) { | 
| 3731 | transformItem->MarkWithAssociatedPerspective(); | 
| 3732 | |
| 3733 | if (clipCapturedBy == ContainerItemType::Perspective) { | 
| 3734 | clipState.Restore(); | 
| 3735 | } | 
| 3736 | resultList.AppendNewToTop<nsDisplayPerspective>(aBuilder, this, | 
| 3737 | &resultList); | 
| 3738 | createdContainer = true; | 
| 3739 | } | 
| 3740 | } | 
| 3741 | } | 
| 3742 | |
| 3743 | if (clipCapturedBy == | 
| 3744 | ContainerItemType::OwnLayerForTransformWithRoundedClip) { | 
| 3745 | clipState.Restore(); | 
| 3746 | resultList.AppendNewToTopWithIndex<nsDisplayOwnLayer>( | 
| 3747 | aBuilder, this, | 
| 3748 | /* aIndex = */ nsDisplayOwnLayer::OwnLayerForTransformWithRoundedClip, | 
| 3749 | &resultList, aBuilder->CurrentActiveScrolledRoot(), | 
| 3750 | nsDisplayOwnLayerFlags::None, ScrollbarData{}, | 
| 3751 | /* aForceActive = */ false, false); | 
| 3752 | createdContainer = true; | 
| 3753 | } | 
| 3754 | |
| 3755 | // If we have sticky positioning, wrap it in a sticky position item. | 
| 3756 | if (useFixedPosition) { | 
| 3757 | if (clipCapturedBy == ContainerItemType::FixedPosition) { | 
| 3758 | clipState.Restore(); | 
| 3759 | } | 
| 3760 | // The ASR for the fixed item should be the ASR of our containing block, | 
| 3761 | // which has been set as the builder's current ASR, unless this frame is | 
| 3762 | // invisible and we hadn't saved display item data for it. In that case, | 
| 3763 | // we need to take the containerItemASR since we might have fixed children. | 
| 3764 | // For WebRender, we want to the know what |containerItemASR| is for the | 
| 3765 | // case where the fixed-pos item is not a "real" fixed-pos item (e.g. it's | 
| 3766 | // nested inside a scrolling transform), so we stash that on the display | 
| 3767 | // item as well. | 
| 3768 | const ActiveScrolledRoot* fixedASR = ActiveScrolledRoot::PickAncestor( | 
| 3769 | containerItemASR, aBuilder->CurrentActiveScrolledRoot()); | 
| 3770 | resultList.AppendNewToTop<nsDisplayFixedPosition>( | 
| 3771 | aBuilder, this, &resultList, fixedASR, containerItemASR); | 
| 3772 | createdContainer = true; | 
| 3773 | } else if (useStickyPosition) { | 
| 3774 | // For position:sticky, the clip needs to be applied both to the sticky | 
| 3775 | // container item and to the contents. The container item needs the clip | 
| 3776 | // because a scrolled clip needs to move independently from the sticky | 
| 3777 | // contents, and the contents need the clip so that they have finite | 
| 3778 | // clipped bounds with respect to the container item's ASR. The latter is | 
| 3779 | // a little tricky in the case where the sticky item has both fixed and | 
| 3780 | // non-fixed descendants, because that means that the sticky container | 
| 3781 | // item's ASR is the ASR of the fixed descendant. | 
| 3782 | // For WebRender display list building, though, we still want to know the | 
| 3783 | // the ASR that the sticky container item would normally have, so we stash | 
| 3784 | // that on the display item as the "container ASR" (i.e. the normal ASR of | 
| 3785 | // the container item, excluding the special behaviour induced by fixed | 
| 3786 | // descendants). | 
| 3787 | const ActiveScrolledRoot* stickyASR = ActiveScrolledRoot::PickAncestor( | 
| 3788 | containerItemASR, aBuilder->CurrentActiveScrolledRoot()); | 
| 3789 | |
| 3790 | auto* stickyItem = MakeDisplayItem<nsDisplayStickyPosition>( | 
| 3791 | aBuilder, this, &resultList, stickyASR, | 
| 3792 | aBuilder->CurrentActiveScrolledRoot(), | 
| 3793 | clipState.IsClippedToDisplayPort()); | 
| 3794 | |
| 3795 | bool shouldFlatten = true; | 
| 3796 | |
| 3797 | StickyScrollContainer* stickyScrollContainer = | 
| 3798 | StickyScrollContainer::GetStickyScrollContainerForFrame(this); | 
| 3799 | if (stickyScrollContainer && stickyScrollContainer->ScrollContainer() | 
| 3800 | ->IsMaybeAsynchronouslyScrolled()) { | 
| 3801 | shouldFlatten = false; | 
| 3802 | } | 
| 3803 | |
| 3804 | stickyItem->SetShouldFlatten(shouldFlatten); | 
| 3805 | |
| 3806 | resultList.AppendToTop(stickyItem); | 
| 3807 | createdContainer = true; | 
| 3808 | |
| 3809 | // If the sticky element is inside a filter, annotate the scroll frame that | 
| 3810 | // scrolls the filter as having out-of-flow content inside a filter (this | 
| 3811 | // inhibits paint skipping). | 
| 3812 | if (aBuilder->GetFilterASR() && aBuilder->GetFilterASR() == stickyASR) { | 
| 3813 | aBuilder->GetFilterASR() | 
| 3814 | ->mScrollContainerFrame->SetHasOutOfFlowContentInsideFilter(); | 
| 3815 | } | 
| 3816 | } | 
| 3817 | |
| 3818 | // If there's blending, wrap up the list in a blend-mode item. Note that | 
| 3819 | // opacity can be applied before blending as the blend color is not affected | 
| 3820 | // by foreground opacity (only background alpha). | 
| 3821 | if (useBlendMode) { | 
| 3822 | DisplayListClipState::AutoSaveRestore blendModeClipState(aBuilder); | 
| 3823 | resultList.AppendNewToTop<nsDisplayBlendMode>(aBuilder, this, &resultList, | 
| 3824 | effects->mMixBlendMode, | 
| 3825 | containerItemASR, false); | 
| 3826 | createdContainer = true; | 
| 3827 | } | 
| 3828 | |
| 3829 | if (aBuilder->IsReusingStackingContextItems()) { | 
| 3830 | if (resultList.IsEmpty()) { | 
| 3831 | return; | 
| 3832 | } | 
| 3833 | |
| 3834 | nsDisplayItem* container = resultList.GetBottom(); | 
| 3835 | if (resultList.Length() > 1 || container->Frame() != this) { | 
| 3836 | container = MakeDisplayItem<nsDisplayContainer>( | 
| 3837 | aBuilder, this, containerItemASR, &resultList); | 
| 3838 | } else { | 
| 3839 | MOZ_ASSERT(resultList.Length() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(resultList.Length() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(resultList.Length() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("resultList.Length() == 1" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3839); AnnotateMozCrashReason("MOZ_ASSERT" "(" "resultList.Length() == 1" ")"); do { *((volatile int*)__null) = 3839; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 3840 | resultList.Clear(); | 
| 3841 | } | 
| 3842 | |
| 3843 | // Mark the outermost display item as reusable. These display items and | 
| 3844 | // their chidren can be reused during the next paint if no ancestor or | 
| 3845 | // descendant frames have been modified. | 
| 3846 | if (!container->IsReusedItem()) { | 
| 3847 | container->SetReusable(); | 
| 3848 | } | 
| 3849 | aList->AppendToTop(container); | 
| 3850 | createdContainer = true; | 
| 3851 | } else { | 
| 3852 | aList->AppendToTop(&resultList); | 
| 3853 | } | 
| 3854 | |
| 3855 | if (aCreatedContainerItem) { | 
| 3856 | *aCreatedContainerItem = createdContainer; | 
| 3857 | } | 
| 3858 | } | 
| 3859 | |
| 3860 | static nsDisplayItem* WrapInWrapList(nsDisplayListBuilder* aBuilder, | 
| 3861 | nsIFrame* aFrame, nsDisplayList* aList, | 
| 3862 | const ActiveScrolledRoot* aContainerASR, | 
| 3863 | bool aBuiltContainerItem = false) { | 
| 3864 | nsDisplayItem* item = aList->GetBottom(); | 
| 3865 | if (!item) { | 
| 3866 | return nullptr; | 
| 3867 | } | 
| 3868 | |
| 3869 | // We need a wrap list if there are multiple items, or if the single | 
| 3870 | // item has a different frame. This can change in a partial build depending | 
| 3871 | // on which items we build, so we need to ensure that we don't transition | 
| 3872 | // to/from a wrap list without invalidating correctly. | 
| 3873 | bool needsWrapList = | 
| 3874 | aList->Length() > 1 || item->Frame() != aFrame || item->GetChildren(); | 
| 3875 | |
| 3876 | // If we have an explicit container item (that can't change without an | 
| 3877 | // invalidation) or we're doing a full build and don't need a wrap list, then | 
| 3878 | // we can skip adding one. | 
| 3879 | if (aBuiltContainerItem || (!aBuilder->IsPartialUpdate() && !needsWrapList)) { | 
| 3880 | MOZ_ASSERT(aList->Length() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aList->Length() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aList->Length() == 1))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aList->Length() == 1" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3880); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aList->Length() == 1" ")"); do { *((volatile int*)__null) = 3880; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 3881 | aList->Clear(); | 
| 3882 | return item; | 
| 3883 | } | 
| 3884 | |
| 3885 | // If we're doing a partial build and we didn't need a wrap list | 
| 3886 | // previously then we can try to work from there. | 
| 3887 | if (aBuilder->IsPartialUpdate() && | 
| 3888 | !aFrame->HasDisplayItem(uint32_t(DisplayItemType::TYPE_CONTAINER))) { | 
| 3889 | // If we now need a wrap list, we must previously have had no display items | 
| 3890 | // or a single one belonging to this frame. Mark the item itself as | 
| 3891 | // discarded so that RetainedDisplayListBuilder uses the ones we just built. | 
| 3892 | // We don't want to mark the frame as modified as that would invalidate | 
| 3893 | // positioned descendants that might be outside of this list, and might not | 
| 3894 | // have been rebuilt this time. | 
| 3895 | if (needsWrapList) { | 
| 3896 | DiscardOldItems(aFrame); | 
| 3897 | } else { | 
| 3898 | MOZ_ASSERT(aList->Length() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aList->Length() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aList->Length() == 1))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aList->Length() == 1" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3898); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aList->Length() == 1" ")"); do { *((volatile int*)__null) = 3898; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 3899 | aList->Clear(); | 
| 3900 | return item; | 
| 3901 | } | 
| 3902 | } | 
| 3903 | |
| 3904 | // The last case we could try to handle is when we previously had a wrap list, | 
| 3905 | // but no longer need it. Unfortunately we can't differentiate this case from | 
| 3906 | // a partial build where other children exist but we just didn't build them | 
| 3907 | // this time. | 
| 3908 | // TODO:RetainedDisplayListBuilder's merge phase has the full list and | 
| 3909 | // could strip them out. | 
| 3910 | |
| 3911 | return MakeDisplayItem<nsDisplayContainer>(aBuilder, aFrame, aContainerASR, | 
| 3912 | aList); | 
| 3913 | } | 
| 3914 | |
| 3915 | /** | 
| 3916 | * Check if a frame should be visited for building display list. | 
| 3917 | */ | 
| 3918 | static bool DescendIntoChild(nsDisplayListBuilder* aBuilder, | 
| 3919 | const nsIFrame* aChild, const nsRect& aVisible, | 
| 3920 | const nsRect& aDirty) { | 
| 3921 | if (aChild->HasAnyStateBits(NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO)) { | 
| 3922 | return true; | 
| 3923 | } | 
| 3924 | |
| 3925 | // If the child is a scrollframe that we want to ignore, then we need | 
| 3926 | // to descend into it because its scrolled child may intersect the dirty | 
| 3927 | // area even if the scrollframe itself doesn't. | 
| 3928 | if (aChild == aBuilder->GetIgnoreScrollFrame()) { | 
| 3929 | return true; | 
| 3930 | } | 
| 3931 | |
| 3932 | // There are cases where the "ignore scroll frame" on the builder is not set | 
| 3933 | // correctly, and so we additionally want to catch cases where the child is | 
| 3934 | // a root scrollframe and we are ignoring scrolling on the viewport. | 
| 3935 | if (aChild == aBuilder->GetPresShellIgnoreScrollFrame()) { | 
| 3936 | return true; | 
| 3937 | } | 
| 3938 | |
| 3939 | nsRect overflow = aChild->InkOverflowRect(); | 
| 3940 | |
| 3941 | // On mobile, there may be a dynamic toolbar. The root content document's | 
| 3942 | // root scroll frame's ink overflow rect does not include the toolbar | 
| 3943 | // height, but if the toolbar is hidden, we still want to be able to target | 
| 3944 | // content underneath the toolbar, so expand the overflow rect here to | 
| 3945 | // allow display list building to descend into the scroll frame. | 
| 3946 | if (aBuilder->IsForEventDelivery() && | 
| 3947 | aChild == aChild->PresShell()->GetRootScrollContainerFrame() && | 
| 3948 | aChild->PresContext()->IsRootContentDocumentCrossProcess() && | 
| 3949 | aChild->PresContext()->HasDynamicToolbar()) { | 
| 3950 | overflow.SizeTo(nsLayoutUtils::ExpandHeightForDynamicToolbar( | 
| 3951 | aChild->PresContext(), overflow.Size())); | 
| 3952 | } | 
| 3953 | |
| 3954 | if (aDirty.Intersects(overflow)) { | 
| 3955 | return true; | 
| 3956 | } | 
| 3957 | |
| 3958 | if (aChild->ForceDescendIntoIfVisible() && aVisible.Intersects(overflow)) { | 
| 3959 | return true; | 
| 3960 | } | 
| 3961 | |
| 3962 | if (aChild->IsTablePart()) { | 
| 3963 | // Relative positioning and transforms can cause table parts to move, but we | 
| 3964 | // will still paint the backgrounds for their ancestor parts under them at | 
| 3965 | // their 'normal' position. That means that we must consider the overflow | 
| 3966 | // rects at both positions. | 
| 3967 | |
| 3968 | // We convert the overflow rect into the nsTableFrame's coordinate | 
| 3969 | // space, applying the normal position offset at each step. Then we | 
| 3970 | // compare that against the builder's cached dirty rect in table | 
| 3971 | // coordinate space. | 
| 3972 | const nsIFrame* f = aChild; | 
| 3973 | nsRect normalPositionOverflowRelativeToTable = overflow; | 
| 3974 | |
| 3975 | while (f->IsTablePart()) { | 
| 3976 | normalPositionOverflowRelativeToTable += f->GetNormalPosition(); | 
| 3977 | f = f->GetParent(); | 
| 3978 | } | 
| 3979 | |
| 3980 | nsDisplayTableBackgroundSet* tableBGs = aBuilder->GetTableBackgroundSet(); | 
| 3981 | if (tableBGs && tableBGs->GetDirtyRect().Intersects( | 
| 3982 | normalPositionOverflowRelativeToTable)) { | 
| 3983 | return true; | 
| 3984 | } | 
| 3985 | } | 
| 3986 | |
| 3987 | return false; | 
| 3988 | } | 
| 3989 | |
| 3990 | void nsIFrame::BuildDisplayListForSimpleChild(nsDisplayListBuilder* aBuilder, | 
| 3991 | nsIFrame* aChild, | 
| 3992 | const nsDisplayListSet& aLists) { | 
| 3993 | // This is the shortcut for frames been handled along the common | 
| 3994 | // path, the most common one of THE COMMON CASE mentioned later. | 
| 3995 | MOZ_ASSERT(aChild->Type() != LayoutFrameType::Placeholder)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aChild->Type() != LayoutFrameType::Placeholder)> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aChild->Type() != LayoutFrameType::Placeholder))) , 0))) { do { } while (false); MOZ_ReportAssertionFailure("aChild->Type() != LayoutFrameType::Placeholder" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3995); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aChild->Type() != LayoutFrameType::Placeholder" ")"); do { *((volatile int*)__null) = 3995; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 3996 | MOZ_ASSERT(!aBuilder->GetSelectedFramesOnly() &&do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aBuilder->GetSelectedFramesOnly() && !aBuilder ->GetIncludeAllOutOfFlows())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!aBuilder->GetSelectedFramesOnly () && !aBuilder->GetIncludeAllOutOfFlows()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!aBuilder->GetSelectedFramesOnly() && !aBuilder->GetIncludeAllOutOfFlows()" " (" "It should be held for painting to window" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3998); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aBuilder->GetSelectedFramesOnly() && !aBuilder->GetIncludeAllOutOfFlows()" ") (" "It should be held for painting to window" ")"); do { * ((volatile int*)__null) = 3998; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) | 
| 3997 | !aBuilder->GetIncludeAllOutOfFlows(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aBuilder->GetSelectedFramesOnly() && !aBuilder ->GetIncludeAllOutOfFlows())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!aBuilder->GetSelectedFramesOnly () && !aBuilder->GetIncludeAllOutOfFlows()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!aBuilder->GetSelectedFramesOnly() && !aBuilder->GetIncludeAllOutOfFlows()" " (" "It should be held for painting to window" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3998); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aBuilder->GetSelectedFramesOnly() && !aBuilder->GetIncludeAllOutOfFlows()" ") (" "It should be held for painting to window" ")"); do { * ((volatile int*)__null) = 3998; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) | 
| 3998 | "It should be held for painting to window")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aBuilder->GetSelectedFramesOnly() && !aBuilder ->GetIncludeAllOutOfFlows())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!aBuilder->GetSelectedFramesOnly () && !aBuilder->GetIncludeAllOutOfFlows()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!aBuilder->GetSelectedFramesOnly() && !aBuilder->GetIncludeAllOutOfFlows()" " (" "It should be held for painting to window" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3998); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aBuilder->GetSelectedFramesOnly() && !aBuilder->GetIncludeAllOutOfFlows()" ") (" "It should be held for painting to window" ")"); do { * ((volatile int*)__null) = 3998; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); | 
| 3999 | MOZ_ASSERT(aChild->HasAnyStateBits(NS_FRAME_SIMPLE_DISPLAYLIST))do { static_assert( mozilla::detail::AssertionConditionType< decltype(aChild->HasAnyStateBits(NS_FRAME_SIMPLE_DISPLAYLIST ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aChild->HasAnyStateBits(NS_FRAME_SIMPLE_DISPLAYLIST )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aChild->HasAnyStateBits(NS_FRAME_SIMPLE_DISPLAYLIST)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 3999); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aChild->HasAnyStateBits(NS_FRAME_SIMPLE_DISPLAYLIST)" ")"); do { *((volatile int*)__null) = 3999; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4000 | |
| 4001 | const nsPoint offset = aChild->GetOffsetTo(this); | 
| 4002 | const nsRect visible = aBuilder->GetVisibleRect() - offset; | 
| 4003 | const nsRect dirty = aBuilder->GetDirtyRect() - offset; | 
| 4004 | |
| 4005 | if (!DescendIntoChild(aBuilder, aChild, visible, dirty)) { | 
| 4006 | DL_LOGV("Skipped frame %p", aChild)do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "Skipped frame %p", aChild); } } while ( 0); | 
| 4007 | return; | 
| 4008 | } | 
| 4009 | |
| 4010 | // Child cannot be transformed since it is not a stacking context. | 
| 4011 | nsDisplayListBuilder::AutoBuildingDisplayList buildingForChild( | 
| 4012 | aBuilder, aChild, visible, dirty, false); | 
| 4013 | |
| 4014 | UpdateCurrentHitTestInfo(aBuilder, aChild); | 
| 4015 | |
| 4016 | aChild->MarkAbsoluteFramesForDisplayList(aBuilder); | 
| 4017 | aBuilder->AdjustWindowDraggingRegion(aChild); | 
| 4018 | aBuilder->Check(); | 
| 4019 | aChild->BuildDisplayList(aBuilder, aLists); | 
| 4020 | aChild->SetBuiltDisplayList(true); | 
| 4021 | aBuilder->Check(); | 
| 4022 | aBuilder->DisplayCaret(aChild, aLists.Outlines()); | 
| 4023 | } | 
| 4024 | |
| 4025 | static bool ShouldSkipFrame(nsDisplayListBuilder* aBuilder, | 
| 4026 | const nsIFrame* aFrame) { | 
| 4027 | // If painting is restricted to just the background of the top level frame, | 
| 4028 | // then we have nothing to do here. | 
| 4029 | if (aBuilder->IsBackgroundOnly()) { | 
| 4030 | return true; | 
| 4031 | } | 
| 4032 | if (aBuilder->IsForGenerateGlyphMask() && | 
| 4033 | (!aFrame->IsTextFrame() && aFrame->IsLeaf())) { | 
| 4034 | return true; | 
| 4035 | } | 
| 4036 | // The placeholder frame should have the same content as the OOF frame. | 
| 4037 | if (aBuilder->GetSelectedFramesOnly() && | 
| 4038 | (aFrame->IsLeaf() && !aFrame->IsSelected())) { | 
| 4039 | return true; | 
| 4040 | } | 
| 4041 | static const nsFrameState skipFlags = | 
| 4042 | (NS_FRAME_TOO_DEEP_IN_FRAME_TREE | NS_FRAME_IS_NONDISPLAY); | 
| 4043 | if (aFrame->HasAnyStateBits(skipFlags)) { | 
| 4044 | return true; | 
| 4045 | } | 
| 4046 | return aFrame->StyleUIReset()->mMozSubtreeHiddenOnlyVisually; | 
| 4047 | } | 
| 4048 | |
| 4049 | void nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder, | 
| 4050 | nsIFrame* aChild, | 
| 4051 | const nsDisplayListSet& aLists, | 
| 4052 | DisplayChildFlags aFlags) { | 
| 4053 | AutoCheckBuilder check(aBuilder); | 
| 4054 | #ifdef DEBUG1 | 
| 4055 | DL_LOGV("BuildDisplayListForChild (%p) <", aChild)do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "BuildDisplayListForChild (%p) <", aChild ); } } while (0); | 
| 4056 | ScopeExit e( | 
| 4057 | [aChild]() { DL_LOGV("> BuildDisplayListForChild (%p)", aChild)do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "> BuildDisplayListForChild (%p)", aChild ); } } while (0); }); | 
| 4058 | #endif | 
| 4059 | |
| 4060 | if (ShouldSkipFrame(aBuilder, aChild)) { | 
| 4061 | return; | 
| 4062 | } | 
| 4063 | |
| 4064 | if (HidesContent()) { | 
| 4065 | return; | 
| 4066 | } | 
| 4067 | |
| 4068 | nsIFrame* child = aChild; | 
| 4069 | auto* placeholder = child->IsPlaceholderFrame() | 
| 4070 | ? static_cast<nsPlaceholderFrame*>(child) | 
| 4071 | : nullptr; | 
| 4072 | nsIFrame* childOrOutOfFlow = | 
| 4073 | placeholder ? placeholder->GetOutOfFlowFrame() : child; | 
| 4074 | |
| 4075 | // If we're generating a display list for printing, include Link items for | 
| 4076 | // frames that correspond to HTML link elements so that we can have active | 
| 4077 | // links in saved PDF output. Note that the state of "within a link" is | 
| 4078 | // set on the display-list builder, such that all descendants of the link | 
| 4079 | // element will generate display-list links. | 
| 4080 | // TODO: we should be able to optimize this so as to avoid creating links | 
| 4081 | // for the same destination that entirely overlap each other, which adds | 
| 4082 | // nothing useful to the final PDF. | 
| 4083 | Maybe<nsDisplayListBuilder::Linkifier> linkifier; | 
| 4084 | if (StaticPrefs::print_save_as_pdf_links_enabled() && | 
| 4085 | aBuilder->IsForPrinting()) { | 
| 4086 | linkifier.emplace(aBuilder, childOrOutOfFlow, aLists.Content()); | 
| 4087 | linkifier->MaybeAppendLink(aBuilder, childOrOutOfFlow); | 
| 4088 | } | 
| 4089 | |
| 4090 | nsIFrame* parent = childOrOutOfFlow->GetParent(); | 
| 4091 | const auto* parentDisplay = parent->StyleDisplay(); | 
| 4092 | const auto overflowClipAxes = | 
| 4093 | parent->ShouldApplyOverflowClipping(parentDisplay); | 
| 4094 | |
| 4095 | const bool isPaintingToWindow = aBuilder->IsPaintingToWindow(); | 
| 4096 | const bool doingShortcut = | 
| 4097 | isPaintingToWindow && | 
| 4098 | child->HasAnyStateBits(NS_FRAME_SIMPLE_DISPLAYLIST) && | 
| 4099 | // Animations may change the stacking context state. | 
| 4100 | // ShouldApplyOverflowClipping is affected by the parent style, which does | 
| 4101 | // not invalidate the NS_FRAME_SIMPLE_DISPLAYLIST bit. | 
| 4102 | !(!overflowClipAxes.isEmpty() || child->MayHaveTransformAnimation() || | 
| 4103 | child->MayHaveOpacityAnimation()); | 
| 4104 | |
| 4105 | if (aBuilder->IsForPainting()) { | 
| 4106 | aBuilder->ClearWillChangeBudgetStatus(child); | 
| 4107 | } | 
| 4108 | |
| 4109 | if (StaticPrefs::layout_css_scroll_anchoring_highlight()) { | 
| 4110 | if (child->FirstContinuation()->IsScrollAnchor()) { | 
| 4111 | nsRect bounds = child->GetContentRectRelativeToSelf() + | 
| 4112 | aBuilder->ToReferenceFrame(child); | 
| 4113 | nsDisplaySolidColor* color = MakeDisplayItem<nsDisplaySolidColor>( | 
| 4114 | aBuilder, child, bounds, NS_RGBA(255, 0, 255, 64)((nscolor)(((64) << 24) | ((255) << 16) | ((0) << 8) | (255)))); | 
| 4115 | if (color) { | 
| 4116 | color->SetOverrideZIndex(INT32_MAX(2147483647)); | 
| 4117 | aLists.PositionedDescendants()->AppendToTop(color); | 
| 4118 | } | 
| 4119 | } | 
| 4120 | } | 
| 4121 | |
| 4122 | if (doingShortcut) { | 
| 4123 | BuildDisplayListForSimpleChild(aBuilder, child, aLists); | 
| 4124 | return; | 
| 4125 | } | 
| 4126 | |
| 4127 | // dirty rect in child-relative coordinates | 
| 4128 | NS_ASSERTION(aBuilder->GetCurrentFrame() == this, "Wrong coord space!")do { if (!(aBuilder->GetCurrentFrame() == this)) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Wrong coord space!", "aBuilder->GetCurrentFrame() == this" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4128); MOZ_PretendNoReturn(); } } while (0); | 
| 4129 | const nsPoint offset = child->GetOffsetTo(this); | 
| 4130 | nsRect visible = aBuilder->GetVisibleRect() - offset; | 
| 4131 | nsRect dirty = aBuilder->GetDirtyRect() - offset; | 
| 4132 | |
| 4133 | nsDisplayListBuilder::OutOfFlowDisplayData* savedOutOfFlowData = nullptr; | 
| 4134 | if (placeholder) { | 
| 4135 | if (placeholder->HasAnyStateBits(PLACEHOLDER_FOR_TOPLAYER)) { | 
| 4136 | // If the out-of-flow frame is in the top layer, the viewport frame | 
| 4137 | // will paint it. Skip it here. Note that, only out-of-flow frames | 
| 4138 | // with this property should be skipped, because non-HTML elements | 
| 4139 | // may stop their children from being out-of-flow. Those frames | 
| 4140 | // should still be handled in the normal in-flow path. | 
| 4141 | return; | 
| 4142 | } | 
| 4143 | |
| 4144 | child = childOrOutOfFlow; | 
| 4145 | if (aBuilder->IsForPainting()) { | 
| 4146 | aBuilder->ClearWillChangeBudgetStatus(child); | 
| 4147 | } | 
| 4148 | |
| 4149 | // If 'child' is a pushed float then it's owned by a block that's not an | 
| 4150 | // ancestor of the placeholder, and it will be painted by that block and | 
| 4151 | // should not be painted through the placeholder. Also recheck | 
| 4152 | // NS_FRAME_TOO_DEEP_IN_FRAME_TREE and NS_FRAME_IS_NONDISPLAY. | 
| 4153 | static const nsFrameState skipFlags = | 
| 4154 | (NS_FRAME_IS_PUSHED_FLOAT | NS_FRAME_TOO_DEEP_IN_FRAME_TREE | | 
| 4155 | NS_FRAME_IS_NONDISPLAY); | 
| 4156 | if (child->HasAnyStateBits(skipFlags) || nsLayoutUtils::IsPopup(child)) { | 
| 4157 | return; | 
| 4158 | } | 
| 4159 | |
| 4160 | MOZ_ASSERT(child->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW))do { static_assert( mozilla::detail::AssertionConditionType< decltype(child->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW))> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(child->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("child->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4160); AnnotateMozCrashReason("MOZ_ASSERT" "(" "child->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)" ")"); do { *((volatile int*)__null) = 4160; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4161 | savedOutOfFlowData = nsDisplayListBuilder::GetOutOfFlowData(child); | 
| 4162 | |
| 4163 | if (aBuilder->GetIncludeAllOutOfFlows()) { | 
| 4164 | visible = child->InkOverflowRect(); | 
| 4165 | dirty = child->InkOverflowRect(); | 
| 4166 | } else if (savedOutOfFlowData) { | 
| 4167 | visible = | 
| 4168 | savedOutOfFlowData->GetVisibleRectForFrame(aBuilder, child, &dirty); | 
| 4169 | } else { | 
| 4170 | // The out-of-flow frame did not intersect the dirty area. We may still | 
| 4171 | // need to traverse into it, since it may contain placeholders we need | 
| 4172 | // to enter to reach other out-of-flow frames that are visible. | 
| 4173 | visible.SetEmpty(); | 
| 4174 | dirty.SetEmpty(); | 
| 4175 | } | 
| 4176 | } | 
| 4177 | |
| 4178 | NS_ASSERTION(!child->IsPlaceholderFrame(),do { if (!(!child->IsPlaceholderFrame())) { NS_DebugBreak( NS_DEBUG_ASSERTION, "Should have dealt with placeholders already" , "!child->IsPlaceholderFrame()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4179); MOZ_PretendNoReturn(); } } while (0) | 
| 4179 | "Should have dealt with placeholders already")do { if (!(!child->IsPlaceholderFrame())) { NS_DebugBreak( NS_DEBUG_ASSERTION, "Should have dealt with placeholders already" , "!child->IsPlaceholderFrame()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4179); MOZ_PretendNoReturn(); } } while (0); | 
| 4180 | |
| 4181 | if (!DescendIntoChild(aBuilder, child, visible, dirty)) { | 
| 4182 | DL_LOGV("Skipped frame %p", child)do { const ::mozilla::LogModule* moz_real_module = GetLoggerByProcess (); if ((__builtin_expect(!!(mozilla::detail::log_test(moz_real_module , LogLevel::Verbose)), 0))) { mozilla::detail::log_print(moz_real_module , LogLevel::Verbose, "Skipped frame %p", child); } } while (0 ); | 
| 4183 | return; | 
| 4184 | } | 
| 4185 | |
| 4186 | const bool isSVG = child->HasAnyStateBits(NS_FRAME_SVG_LAYOUT); | 
| 4187 | |
| 4188 | // This flag is raised if the control flow strays off the common path. | 
| 4189 | // The common path is the most common one of THE COMMON CASE mentioned later. | 
| 4190 | bool awayFromCommonPath = !isPaintingToWindow; | 
| 4191 | |
| 4192 | // true if this is a real or pseudo stacking context | 
| 4193 | bool pseudoStackingContext = | 
| 4194 | aFlags.contains(DisplayChildFlag::ForcePseudoStackingContext); | 
| 4195 | |
| 4196 | if (!pseudoStackingContext && !isSVG && | 
| 4197 | aFlags.contains(DisplayChildFlag::Inline) && | 
| 4198 | !child->IsLineParticipant()) { | 
| 4199 | // child is a non-inline frame in an inline context, i.e., | 
| 4200 | // it acts like inline-block or inline-table. Therefore it is a | 
| 4201 | // pseudo-stacking-context. | 
| 4202 | pseudoStackingContext = true; | 
| 4203 | } | 
| 4204 | |
| 4205 | const nsStyleDisplay* ourDisp = StyleDisplay(); | 
| 4206 | // Don't paint our children if the theme object is a leaf. | 
| 4207 | if (IsThemed(ourDisp) && !PresContext()->Theme()->WidgetIsContainer( | 
| 4208 | ourDisp->EffectiveAppearance())) { | 
| 4209 | return; | 
| 4210 | } | 
| 4211 | |
| 4212 | // Since we're now sure that we're adding this frame to the display list | 
| 4213 | // (which means we're painting it, modulo occlusion), mark it as visible | 
| 4214 | // within the displayport. | 
| 4215 | if (isPaintingToWindow && child->TrackingVisibility() && | 
| 4216 | child->IsVisibleForPainting()) { | 
| 4217 | child->PresShell()->EnsureFrameInApproximatelyVisibleList(child); | 
| 4218 | awayFromCommonPath = true; | 
| 4219 | } | 
| 4220 | |
| 4221 | // Child is composited if it's transformed, partially transparent, or has | 
| 4222 | // SVG effects or a blend mode.. | 
| 4223 | const nsStyleDisplay* disp = child->StyleDisplay(); | 
| 4224 | const nsStyleEffects* effects = child->StyleEffects(); | 
| 4225 | |
| 4226 | const bool isPositioned = disp->IsPositionedStyle(); | 
| 4227 | const bool isStackingContext = | 
| 4228 | aFlags.contains(DisplayChildFlag::ForceStackingContext) || | 
| 4229 | child->IsStackingContext(disp, effects); | 
| 4230 | |
| 4231 | if (pseudoStackingContext || isStackingContext || isPositioned || | 
| 4232 | placeholder || (!isSVG && disp->IsFloating(child)) || | 
| 4233 | (isSVG && effects->mClip.IsRect() && IsSVGContentWithCSSClip(child))) { | 
| 4234 | pseudoStackingContext = true; | 
| 4235 | awayFromCommonPath = true; | 
| 4236 | } | 
| 4237 | |
| 4238 | NS_ASSERTION(!isStackingContext || pseudoStackingContext,do { if (!(!isStackingContext || pseudoStackingContext)) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Stacking contexts must also be pseudo-stacking-contexts" , "!isStackingContext || pseudoStackingContext", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4239); MOZ_PretendNoReturn(); } } while (0) | 
| 4239 | "Stacking contexts must also be pseudo-stacking-contexts")do { if (!(!isStackingContext || pseudoStackingContext)) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Stacking contexts must also be pseudo-stacking-contexts" , "!isStackingContext || pseudoStackingContext", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4239); MOZ_PretendNoReturn(); } } while (0); | 
| 4240 | |
| 4241 | nsDisplayListBuilder::AutoBuildingDisplayList buildingForChild( | 
| 4242 | aBuilder, child, visible, dirty); | 
| 4243 | |
| 4244 | UpdateCurrentHitTestInfo(aBuilder, child); | 
| 4245 | |
| 4246 | DisplayListClipState::AutoClipMultiple clipState(aBuilder); | 
| 4247 | nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter asrSetter(aBuilder); | 
| 4248 | |
| 4249 | if (savedOutOfFlowData) { | 
| 4250 | aBuilder->SetBuildingInvisibleItems(false); | 
| 4251 | |
| 4252 | clipState.SetClipChainForContainingBlockDescendants( | 
| 4253 | savedOutOfFlowData->mContainingBlockClipChain); | 
| 4254 | asrSetter.SetCurrentActiveScrolledRoot( | 
| 4255 | savedOutOfFlowData->mContainingBlockActiveScrolledRoot); | 
| 4256 | asrSetter.SetCurrentScrollParentId(savedOutOfFlowData->mScrollParentId); | 
| 4257 | MOZ_ASSERT(awayFromCommonPath,do { static_assert( mozilla::detail::AssertionConditionType< decltype(awayFromCommonPath)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(awayFromCommonPath))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("awayFromCommonPath" " (" "It is impossible when savedOutOfFlowData is true" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4258); AnnotateMozCrashReason("MOZ_ASSERT" "(" "awayFromCommonPath" ") (" "It is impossible when savedOutOfFlowData is true" ")" ); do { *((volatile int*)__null) = 4258; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 4258 | "It is impossible when savedOutOfFlowData is true")do { static_assert( mozilla::detail::AssertionConditionType< decltype(awayFromCommonPath)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(awayFromCommonPath))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("awayFromCommonPath" " (" "It is impossible when savedOutOfFlowData is true" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4258); AnnotateMozCrashReason("MOZ_ASSERT" "(" "awayFromCommonPath" ") (" "It is impossible when savedOutOfFlowData is true" ")" ); do { *((volatile int*)__null) = 4258; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4259 | } else if (HasAnyStateBits(NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO) && | 
| 4260 | placeholder) { | 
| 4261 | NS_ASSERTION(visible.IsEmpty(), "should have empty visible rect")do { if (!(visible.IsEmpty())) { NS_DebugBreak(NS_DEBUG_ASSERTION , "should have empty visible rect", "visible.IsEmpty()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4261); MOZ_PretendNoReturn(); } } while (0); | 
| 4262 | // Every item we build from now until we descent into an out of flow that | 
| 4263 | // does have saved out of flow data should be invisible. This state gets | 
| 4264 | // restored when AutoBuildingDisplayList gets out of scope. | 
| 4265 | aBuilder->SetBuildingInvisibleItems(true); | 
| 4266 | |
| 4267 | // If we have nested out-of-flow frames and the outer one isn't visible | 
| 4268 | // then we won't have stored clip data for it. We can just clear the clip | 
| 4269 | // instead since we know we won't render anything, and the inner out-of-flow | 
| 4270 | // frame will setup the correct clip for itself. | 
| 4271 | clipState.SetClipChainForContainingBlockDescendants(nullptr); | 
| 4272 | } | 
| 4273 | |
| 4274 | // Setup clipping for the parent's overflow:clip, | 
| 4275 | // or overflow:hidden on elements that don't support scrolling (and therefore | 
| 4276 | // don't create nsHTML/XULScrollFrame). This clipping needs to not clip | 
| 4277 | // anything directly rendered by the parent, only the rendering of its | 
| 4278 | // children. | 
| 4279 | // Don't use overflowClip to restrict the dirty rect, since some of the | 
| 4280 | // descendants may not be clipped by it. Even if we end up with unnecessary | 
| 4281 | // display items, they'll be pruned during ComputeVisibility. | 
| 4282 | // | 
| 4283 | // FIXME(emilio): Why can't we handle this more similarly to `clip` (on the | 
| 4284 | // parent, rather than on the children)? Would ClipContentDescendants do what | 
| 4285 | // we want? | 
| 4286 | if (!overflowClipAxes.isEmpty()) { | 
| 4287 | ApplyOverflowClipping(aBuilder, parent, overflowClipAxes, clipState); | 
| 4288 | awayFromCommonPath = true; | 
| 4289 | } | 
| 4290 | |
| 4291 | nsDisplayList list(aBuilder); | 
| 4292 | nsDisplayList extraPositionedDescendants(aBuilder); | 
| 4293 | const ActiveScrolledRoot* wrapListASR; | 
| 4294 | bool builtContainerItem = false; | 
| 4295 | if (isStackingContext) { | 
| 4296 | // True stacking context. | 
| 4297 | // For stacking contexts, BuildDisplayListForStackingContext handles | 
| 4298 | // clipping and MarkAbsoluteFramesForDisplayList. | 
| 4299 | nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder); | 
| 4300 | child->BuildDisplayListForStackingContext(aBuilder, &list, | 
| 4301 | &builtContainerItem); | 
| 4302 | wrapListASR = contASRTracker.GetContainerASR(); | 
| 4303 | if (!aBuilder->IsReusingStackingContextItems() && | 
| 4304 | aBuilder->GetCaretFrame() == child) { | 
| 4305 | builtContainerItem = false; | 
| 4306 | } | 
| 4307 | } else { | 
| 4308 | Maybe<nsRect> clipPropClip = | 
| 4309 | child->GetClipPropClipRect(disp, effects, child->GetSize()); | 
| 4310 | if (clipPropClip) { | 
| 4311 | aBuilder->IntersectVisibleRect(*clipPropClip); | 
| 4312 | aBuilder->IntersectDirtyRect(*clipPropClip); | 
| 4313 | clipState.ClipContentDescendants(*clipPropClip + | 
| 4314 | aBuilder->ToReferenceFrame(child)); | 
| 4315 | awayFromCommonPath = true; | 
| 4316 | } | 
| 4317 | |
| 4318 | child->MarkAbsoluteFramesForDisplayList(aBuilder); | 
| 4319 | child->SetBuiltDisplayList(true); | 
| 4320 | |
| 4321 | // Some SVG frames might change opacity without invalidating the frame, so | 
| 4322 | // exclude them from the fast-path. | 
| 4323 | if (!awayFromCommonPath && !child->IsSVGFrame()) { | 
| 4324 | // The shortcut is available for the child for next time. | 
| 4325 | child->AddStateBits(NS_FRAME_SIMPLE_DISPLAYLIST); | 
| 4326 | } | 
| 4327 | |
| 4328 | if (!pseudoStackingContext) { | 
| 4329 | // THIS IS THE COMMON CASE. | 
| 4330 | // Not a pseudo or real stacking context. Do the simple thing and | 
| 4331 | // return early. | 
| 4332 | aBuilder->AdjustWindowDraggingRegion(child); | 
| 4333 | aBuilder->Check(); | 
| 4334 | child->BuildDisplayList(aBuilder, aLists); | 
| 4335 | aBuilder->Check(); | 
| 4336 | aBuilder->DisplayCaret(child, aLists.Outlines()); | 
| 4337 | return; | 
| 4338 | } | 
| 4339 | |
| 4340 | // A pseudo-stacking context (e.g., a positioned element with z-index auto). | 
| 4341 | // We allow positioned descendants of the child to escape to our parent | 
| 4342 | // stacking context's positioned descendant list, because they might be | 
| 4343 | // z-index:non-auto | 
| 4344 | nsDisplayListCollection pseudoStack(aBuilder); | 
| 4345 | |
| 4346 | aBuilder->AdjustWindowDraggingRegion(child); | 
| 4347 | nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder); | 
| 4348 | aBuilder->Check(); | 
| 4349 | child->BuildDisplayList(aBuilder, pseudoStack); | 
| 4350 | aBuilder->Check(); | 
| 4351 | if (aBuilder->DisplayCaret(child, pseudoStack.Outlines())) { | 
| 4352 | builtContainerItem = false; | 
| 4353 | } | 
| 4354 | wrapListASR = contASRTracker.GetContainerASR(); | 
| 4355 | |
| 4356 | list.AppendToTop(pseudoStack.BorderBackground()); | 
| 4357 | list.AppendToTop(pseudoStack.BlockBorderBackgrounds()); | 
| 4358 | list.AppendToTop(pseudoStack.Floats()); | 
| 4359 | list.AppendToTop(pseudoStack.Content()); | 
| 4360 | list.AppendToTop(pseudoStack.Outlines()); | 
| 4361 | extraPositionedDescendants.AppendToTop(pseudoStack.PositionedDescendants()); | 
| 4362 | } | 
| 4363 | |
| 4364 | buildingForChild.RestoreBuildingInvisibleItemsValue(); | 
| 4365 | |
| 4366 | if (!list.IsEmpty()) { | 
| 4367 | if (isPositioned || isStackingContext) { | 
| 4368 | // Genuine stacking contexts, and positioned pseudo-stacking-contexts, | 
| 4369 | // go in this level. | 
| 4370 | nsDisplayItem* item = WrapInWrapList(aBuilder, child, &list, wrapListASR, | 
| 4371 | builtContainerItem); | 
| 4372 | if (isSVG) { | 
| 4373 | aLists.Content()->AppendToTop(item); | 
| 4374 | } else { | 
| 4375 | aLists.PositionedDescendants()->AppendToTop(item); | 
| 4376 | } | 
| 4377 | } else if (!isSVG && disp->IsFloating(child)) { | 
| 4378 | aLists.Floats()->AppendToTop( | 
| 4379 | WrapInWrapList(aBuilder, child, &list, wrapListASR)); | 
| 4380 | } else { | 
| 4381 | aLists.Content()->AppendToTop(&list); | 
| 4382 | } | 
| 4383 | } | 
| 4384 | // We delay placing the positioned descendants of positioned frames to here, | 
| 4385 | // because in the absence of z-index this is the correct order for them. | 
| 4386 | // This doesn't affect correctness because the positioned descendants list | 
| 4387 | // is sorted by z-order and content in BuildDisplayListForStackingContext, | 
| 4388 | // but it means that sort routine needs to do less work. | 
| 4389 | aLists.PositionedDescendants()->AppendToTop(&extraPositionedDescendants); | 
| 4390 | } | 
| 4391 | |
| 4392 | void nsIFrame::MarkAbsoluteFramesForDisplayList( | 
| 4393 | nsDisplayListBuilder* aBuilder) { | 
| 4394 | if (IsAbsoluteContainer()) { | 
| 4395 | aBuilder->MarkFramesForDisplayList( | 
| 4396 | this, GetAbsoluteContainingBlock()->GetChildList()); | 
| 4397 | } | 
| 4398 | } | 
| 4399 | |
| 4400 | nsresult nsIFrame::GetContentForEvent(const WidgetEvent* aEvent, | 
| 4401 | nsIContent** aContent) { | 
| 4402 | nsIFrame* f = nsLayoutUtils::GetNonGeneratedAncestor(this); | 
| 4403 | *aContent = f->GetContent(); | 
| 4404 | NS_IF_ADDREF(*aContent)ns_if_addref(*aContent); | 
| 4405 | return NS_OK; | 
| 4406 | } | 
| 4407 | |
| 4408 | void nsIFrame::FireDOMEvent(const nsAString& aDOMEventName, | 
| 4409 | nsIContent* aContent) { | 
| 4410 | nsIContent* target = aContent ? aContent : GetContent(); | 
| 4411 | |
| 4412 | if (target) { | 
| 4413 | RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( | 
| 4414 | target, aDOMEventName, CanBubble::eYes, ChromeOnlyDispatch::eNo); | 
| 4415 | DebugOnly<nsresult> rv = asyncDispatcher->PostDOMEvent(); | 
| 4416 | NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncEventDispatcher failed to dispatch")do { if (!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1 ))))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "AsyncEventDispatcher failed to dispatch" , "NS_SUCCEEDED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4416); MOZ_PretendNoReturn(); } } while (0); | 
| 4417 | } | 
| 4418 | } | 
| 4419 | |
| 4420 | nsresult nsIFrame::HandleEvent(nsPresContext* aPresContext, | 
| 4421 | WidgetGUIEvent* aEvent, | 
| 4422 | nsEventStatus* aEventStatus) { | 
| 4423 | if (aEvent->mMessage == eMouseMove) { | 
| 4424 | // XXX If the second argument of HandleDrag() is WidgetMouseEvent, | 
| 4425 | // the implementation becomes simpler. | 
| 4426 | return HandleDrag(aPresContext, aEvent, aEventStatus); | 
| 4427 | } | 
| 4428 | |
| 4429 | if ((aEvent->mClass == eMouseEventClass && | 
| 4430 | aEvent->AsMouseEvent()->mButton == MouseButton::ePrimary) || | 
| 4431 | aEvent->mClass == eTouchEventClass) { | 
| 4432 | if (aEvent->mMessage == eMouseDown || aEvent->mMessage == eTouchStart) { | 
| 4433 | HandlePress(aPresContext, aEvent, aEventStatus); | 
| 4434 | } else if (aEvent->mMessage == eMouseUp || aEvent->mMessage == eTouchEnd) { | 
| 4435 | HandleRelease(aPresContext, aEvent, aEventStatus); | 
| 4436 | } | 
| 4437 | return NS_OK; | 
| 4438 | } | 
| 4439 | |
| 4440 | // When secondary buttion is down, we need to move selection to make users | 
| 4441 | // possible to paste something at click point quickly. | 
| 4442 | // When middle button is down, we need to just move selection and focus at | 
| 4443 | // the clicked point. Note that even if middle click paste is not enabled, | 
| 4444 | // Chrome moves selection at middle mouse button down. So, we should follow | 
| 4445 | // the behavior for the compatibility. | 
| 4446 | if (aEvent->mMessage == eMouseDown) { | 
| 4447 | WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); | 
| 4448 | if (mouseEvent && (mouseEvent->mButton == MouseButton::eSecondary || | 
| 4449 | mouseEvent->mButton == MouseButton::eMiddle)) { | 
| 4450 | if (*aEventStatus == nsEventStatus_eConsumeNoDefault) { | 
| 4451 | return NS_OK; | 
| 4452 | } | 
| 4453 | return MoveCaretToEventPoint(aPresContext, mouseEvent, aEventStatus); | 
| 4454 | } | 
| 4455 | } | 
| 4456 | |
| 4457 | return NS_OK; | 
| 4458 | } | 
| 4459 | |
| 4460 | nsresult nsIFrame::GetDataForTableSelection( | 
| 4461 | const nsFrameSelection* aFrameSelection, mozilla::PresShell* aPresShell, | 
| 4462 | WidgetMouseEvent* aMouseEvent, nsIContent** aParentContent, | 
| 4463 | int32_t* aContentOffset, TableSelectionMode* aTarget) { | 
| 4464 | if (!aFrameSelection || !aPresShell || !aMouseEvent || !aParentContent || | 
| 4465 | !aContentOffset || !aTarget) { | 
| 4466 | return NS_ERROR_NULL_POINTER; | 
| 4467 | } | 
| 4468 | |
| 4469 | *aParentContent = nullptr; | 
| 4470 | *aContentOffset = 0; | 
| 4471 | *aTarget = TableSelectionMode::None; | 
| 4472 | |
| 4473 | int16_t displaySelection = aPresShell->GetSelectionFlags(); | 
| 4474 | |
| 4475 | bool selectingTableCells = aFrameSelection->IsInTableSelectionMode(); | 
| 4476 | |
| 4477 | // DISPLAY_ALL means we're in an editor. | 
| 4478 | // If already in cell selection mode, | 
| 4479 | // continue selecting with mouse drag or end on mouse up, | 
| 4480 | // or when using shift key to extend block of cells | 
| 4481 | // (Mouse down does normal selection unless Ctrl/Cmd is pressed) | 
| 4482 | bool doTableSelection = | 
| 4483 | displaySelection == nsISelectionDisplay::DISPLAY_ALL && | 
| 4484 | selectingTableCells && | 
| 4485 | (aMouseEvent->mMessage == eMouseMove || | 
| 4486 | (aMouseEvent->mMessage == eMouseUp && | 
| 4487 | aMouseEvent->mButton == MouseButton::ePrimary) || | 
| 4488 | aMouseEvent->IsShift()); | 
| 4489 | |
| 4490 | if (!doTableSelection) { | 
| 4491 | // In Browser, special 'table selection' key must be pressed for table | 
| 4492 | // selection or when just Shift is pressed and we're already in table/cell | 
| 4493 | // selection mode | 
| 4494 | #ifdef XP_MACOSX | 
| 4495 | doTableSelection = aMouseEvent->IsMeta() || | 
| 4496 | (aMouseEvent->IsShift() && selectingTableCells); | 
| 4497 | #else | 
| 4498 | doTableSelection = aMouseEvent->IsControl() || | 
| 4499 | (aMouseEvent->IsShift() && selectingTableCells); | 
| 4500 | #endif | 
| 4501 | } | 
| 4502 | if (!doTableSelection) { | 
| 4503 | return NS_OK; | 
| 4504 | } | 
| 4505 | |
| 4506 | // Get the cell frame or table frame (or parent) of the current content node | 
| 4507 | nsIFrame* frame = this; | 
| 4508 | bool foundCell = false; | 
| 4509 | bool foundTable = false; | 
| 4510 | |
| 4511 | // Get the limiting node to stop parent frame search | 
| 4512 | nsIContent* limiter = aFrameSelection->GetLimiter(); | 
| 4513 | |
| 4514 | // If our content node is an ancestor of the limiting node, | 
| 4515 | // we should stop the search right now. | 
| 4516 | if (limiter && limiter->IsInclusiveDescendantOf(GetContent())) { | 
| 4517 | return NS_OK; | 
| 4518 | } | 
| 4519 | |
| 4520 | // We don't initiate row/col selection from here now, | 
| 4521 | // but we may in future | 
| 4522 | // bool selectColumn = false; | 
| 4523 | // bool selectRow = false; | 
| 4524 | |
| 4525 | while (frame) { | 
| 4526 | // Check for a table cell by querying to a known CellFrame interface | 
| 4527 | nsITableCellLayout* cellElement = do_QueryFrame(frame); | 
| 4528 | if (cellElement) { | 
| 4529 | foundCell = true; | 
| 4530 | // TODO: If we want to use proximity to top or left border | 
| 4531 | // for row and column selection, this is the place to do it | 
| 4532 | break; | 
| 4533 | } else { | 
| 4534 | // If not a cell, check for table | 
| 4535 | // This will happen when starting frame is the table or child of a table, | 
| 4536 | // such as a row (we were inbetween cells or in table border) | 
| 4537 | nsTableWrapperFrame* tableFrame = do_QueryFrame(frame); | 
| 4538 | if (tableFrame) { | 
| 4539 | foundTable = true; | 
| 4540 | // TODO: How can we select row when along left table edge | 
| 4541 | // or select column when along top edge? | 
| 4542 | break; | 
| 4543 | } else { | 
| 4544 | frame = frame->GetParent(); | 
| 4545 | // Stop if we have hit the selection's limiting content node | 
| 4546 | if (frame && frame->GetContent() == limiter) { | 
| 4547 | break; | 
| 4548 | } | 
| 4549 | } | 
| 4550 | } | 
| 4551 | } | 
| 4552 | // We aren't in a cell or table | 
| 4553 | if (!foundCell && !foundTable) { | 
| 4554 | return NS_OK; | 
| 4555 | } | 
| 4556 | |
| 4557 | nsIContent* tableOrCellContent = frame->GetContent(); | 
| 4558 | if (!tableOrCellContent) { | 
| 4559 | return NS_ERROR_FAILURE; | 
| 4560 | } | 
| 4561 | |
| 4562 | nsCOMPtr<nsIContent> parentContent = tableOrCellContent->GetParent(); | 
| 4563 | if (!parentContent) { | 
| 4564 | return NS_ERROR_FAILURE; | 
| 4565 | } | 
| 4566 | |
| 4567 | const int32_t offset = | 
| 4568 | parentContent->ComputeIndexOf_Deprecated(tableOrCellContent); | 
| 4569 | // Not likely? | 
| 4570 | if (offset < 0) { | 
| 4571 | return NS_ERROR_FAILURE; | 
| 4572 | } | 
| 4573 | |
| 4574 | // Everything is OK -- set the return values | 
| 4575 | parentContent.forget(aParentContent); | 
| 4576 | |
| 4577 | *aContentOffset = offset; | 
| 4578 | |
| 4579 | #if 0 | 
| 4580 | if (selectRow) | 
| 4581 | *aTarget = TableSelectionMode::Row; | 
| 4582 | else if (selectColumn) | 
| 4583 | *aTarget = TableSelectionMode::Column; | 
| 4584 | else | 
| 4585 | #endif | 
| 4586 | if (foundCell) { | 
| 4587 | *aTarget = TableSelectionMode::Cell; | 
| 4588 | } else if (foundTable) { | 
| 4589 | *aTarget = TableSelectionMode::Table; | 
| 4590 | } | 
| 4591 | |
| 4592 | return NS_OK; | 
| 4593 | } | 
| 4594 | |
| 4595 | static bool IsEditingHost(const nsIFrame* aFrame) { | 
| 4596 | nsIContent* content = aFrame->GetContent(); | 
| 4597 | return content && content->IsEditingHost(); | 
| 4598 | } | 
| 4599 | |
| 4600 | static StyleUserSelect UsedUserSelect(const nsIFrame* aFrame) { | 
| 4601 | if (aFrame->IsGeneratedContentFrame()) { | 
| 4602 | return StyleUserSelect::None; | 
| 4603 | } | 
| 4604 | |
| 4605 | // Per https://drafts.csswg.org/css-ui-4/#content-selection: | 
| 4606 | // | 
| 4607 | // The used value is the same as the computed value, except: | 
| 4608 | // | 
| 4609 | // 1 - on editable elements where the used value is always 'contain' | 
| 4610 | // regardless of the computed value | 
| 4611 | // 2 - when the computed value is auto, in which case the used value is one | 
| 4612 | // of the other values... | 
| 4613 | // | 
| 4614 | // See https://github.com/w3c/csswg-drafts/issues/3344 to see why we do this | 
| 4615 | // at used-value time instead of at computed-value time. | 
| 4616 | |
| 4617 | if (aFrame->IsTextInputFrame() || IsEditingHost(aFrame)) { | 
| 4618 | // We don't implement 'contain' itself, but we make 'text' behave as | 
| 4619 | // 'contain' for contenteditable and <input> / <textarea> elements anyway so | 
| 4620 | // this is ok. | 
| 4621 | return StyleUserSelect::Text; | 
| 4622 | } | 
| 4623 | |
| 4624 | auto style = aFrame->Style()->UserSelect(); | 
| 4625 | if (style != StyleUserSelect::Auto) { | 
| 4626 | return style; | 
| 4627 | } | 
| 4628 | |
| 4629 | auto* parent = nsLayoutUtils::GetParentOrPlaceholderFor(aFrame); | 
| 4630 | return parent ? UsedUserSelect(parent) : StyleUserSelect::Text; | 
| 4631 | } | 
| 4632 | |
| 4633 | bool nsIFrame::IsSelectable(StyleUserSelect* aSelectStyle) const { | 
| 4634 | auto style = UsedUserSelect(this); | 
| 4635 | if (aSelectStyle) { | 
| 4636 | *aSelectStyle = style; | 
| 4637 | } | 
| 4638 | return style != StyleUserSelect::None; | 
| 4639 | } | 
| 4640 | |
| 4641 | bool nsIFrame::ShouldHaveLineIfEmpty() const { | 
| 4642 | switch (Style()->GetPseudoType()) { | 
| 4643 | case PseudoStyleType::NotPseudo: | 
| 4644 | break; | 
| 4645 | case PseudoStyleType::scrolledContent: | 
| 4646 | return GetParent()->ShouldHaveLineIfEmpty(); | 
| 4647 | case PseudoStyleType::mozTextControlEditingRoot: | 
| 4648 | return true; | 
| 4649 | case PseudoStyleType::buttonContent: | 
| 4650 | // HTML quirk. | 
| 4651 | return GetContent()->IsHTMLElement(nsGkAtoms::input); | 
| 4652 | default: | 
| 4653 | return false; | 
| 4654 | } | 
| 4655 | return IsEditingHost(this); | 
| 4656 | } | 
| 4657 | |
| 4658 | /** | 
| 4659 | * Handles the Mouse Press Event for the frame | 
| 4660 | */ | 
| 4661 | NS_IMETHODIMPnsresult | 
| 4662 | nsIFrame::HandlePress(nsPresContext* aPresContext, WidgetGUIEvent* aEvent, | 
| 4663 | nsEventStatus* aEventStatus) { | 
| 4664 | NS_ENSURE_ARG_POINTER(aEventStatus)do { if ((__builtin_expect(!!(!(aEventStatus)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aEventStatus" ") failed" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4664); return NS_ERROR_INVALID_POINTER; } } while (false); | 
| 4665 | if (nsEventStatus_eConsumeNoDefault == *aEventStatus) { | 
| 4666 | return NS_OK; | 
| 4667 | } | 
| 4668 | |
| 4669 | NS_ENSURE_ARG_POINTER(aEvent)do { if ((__builtin_expect(!!(!(aEvent)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aEvent" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4669); return NS_ERROR_INVALID_POINTER; } } while (false); | 
| 4670 | if (aEvent->mClass == eTouchEventClass) { | 
| 4671 | return NS_OK; | 
| 4672 | } | 
| 4673 | |
| 4674 | return MoveCaretToEventPoint(aPresContext, aEvent->AsMouseEvent(), | 
| 4675 | aEventStatus); | 
| 4676 | } | 
| 4677 | |
| 4678 | nsresult nsIFrame::MoveCaretToEventPoint(nsPresContext* aPresContext, | 
| 4679 | WidgetMouseEvent* aMouseEvent, | 
| 4680 | nsEventStatus* aEventStatus) { | 
| 4681 | MOZ_ASSERT(aPresContext)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPresContext)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aPresContext))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aPresContext", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4681); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPresContext" ")"); do { *((volatile int*)__null) = 4681; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4682 | MOZ_ASSERT(aMouseEvent)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aMouseEvent)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aMouseEvent))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aMouseEvent", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4682); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aMouseEvent" ")"); do { *((volatile int*)__null) = 4682; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4683 | MOZ_ASSERT(aMouseEvent->mMessage == eMouseDown)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aMouseEvent->mMessage == eMouseDown)>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(aMouseEvent->mMessage == eMouseDown))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aMouseEvent->mMessage == eMouseDown" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4683); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aMouseEvent->mMessage == eMouseDown" ")"); do { *((volatile int*)__null) = 4683; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4684 | MOZ_ASSERT(aEventStatus)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aEventStatus)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aEventStatus))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aEventStatus", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aEventStatus" ")"); do { *((volatile int*)__null) = 4684; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4685 | MOZ_ASSERT(nsEventStatus_eConsumeNoDefault != *aEventStatus)do { static_assert( mozilla::detail::AssertionConditionType< decltype(nsEventStatus_eConsumeNoDefault != *aEventStatus)> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(nsEventStatus_eConsumeNoDefault != *aEventStatus))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("nsEventStatus_eConsumeNoDefault != *aEventStatus" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4685); AnnotateMozCrashReason("MOZ_ASSERT" "(" "nsEventStatus_eConsumeNoDefault != *aEventStatus" ")"); do { *((volatile int*)__null) = 4685; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4686 | |
| 4687 | mozilla::PresShell* presShell = aPresContext->GetPresShell(); | 
| 4688 | if (!presShell) { | 
| 4689 | return NS_ERROR_FAILURE; | 
| 4690 | } | 
| 4691 | |
| 4692 | // We often get out of sync state issues with mousedown events that | 
| 4693 | // get interrupted by alerts/dialogs. | 
| 4694 | // Check with the ESM to see if we should process this one | 
| 4695 | if (!aPresContext->EventStateManager()->EventStatusOK(aMouseEvent)) { | 
| 4696 | return NS_OK; | 
| 4697 | } | 
| 4698 | |
| 4699 | const nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo( | 
| 4700 | aMouseEvent, RelativeTo{this}); | 
| 4701 | |
| 4702 | // When not using `alt`, and clicking on a draggable, but non-editable | 
| 4703 | // element, don't do anything, and let d&d handle the event. | 
| 4704 | // | 
| 4705 | // See bug 48876, bug 388659 and bug 55921 for context here. | 
| 4706 | // | 
| 4707 | // FIXME(emilio): The .Contains(pt) check looks a bit fishy. When would it be | 
| 4708 | // false given we're the event target? If it is needed, why not checking the | 
| 4709 | // actual draggable node rect instead? | 
| 4710 | if (!aMouseEvent->IsAlt() && GetRectRelativeToSelf().Contains(pt)) { | 
| 4711 | for (nsIContent* content = mContent; content; | 
| 4712 | content = content->GetFlattenedTreeParent()) { | 
| 4713 | if (nsContentUtils::ContentIsDraggable(content) && | 
| 4714 | !content->IsEditable()) { | 
| 4715 | return NS_OK; | 
| 4716 | } | 
| 4717 | } | 
| 4718 | } | 
| 4719 | |
| 4720 | // If we are in Navigator and the click is in a draggable node, we don't want | 
| 4721 | // to start selection because we don't want to interfere with a potential | 
| 4722 | // drag of said node and steal all its glory. | 
| 4723 | const bool isEditor = | 
| 4724 | presShell->GetSelectionFlags() == nsISelectionDisplay::DISPLAY_ALL; | 
| 4725 | |
| 4726 | // Don't do something if it's middle button down event. | 
| 4727 | const bool isPrimaryButtonDown = | 
| 4728 | aMouseEvent->mButton == MouseButton::ePrimary; | 
| 4729 | |
| 4730 | // check whether style allows selection | 
| 4731 | // if not, don't tell selection the mouse event even occurred. | 
| 4732 | StyleUserSelect selectStyle; | 
| 4733 | // check for select: none | 
| 4734 | if (!IsSelectable(&selectStyle)) { | 
| 4735 | return NS_OK; | 
| 4736 | } | 
| 4737 | |
| 4738 | if (isPrimaryButtonDown) { | 
| 4739 | // If the mouse is dragged outside the nearest enclosing scrollable area | 
| 4740 | // while making a selection, the area will be scrolled. To do this, capture | 
| 4741 | // the mouse on the nearest scroll container frame. If there isn't a scroll | 
| 4742 | // container frame, or something else is already capturing the mouse, | 
| 4743 | // there's no reason to capture. | 
| 4744 | if (!PresShell::GetCapturingContent()) { | 
| 4745 | ScrollContainerFrame* scrollContainerFrame = | 
| 4746 | nsLayoutUtils::GetNearestScrollContainerFrame( | 
| 4747 | this, nsLayoutUtils::SCROLLABLE_SAME_DOC | | 
| 4748 | nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN); | 
| 4749 | if (scrollContainerFrame) { | 
| 4750 | nsIFrame* capturingFrame = scrollContainerFrame; | 
| 4751 | PresShell::SetCapturingContent(capturingFrame->GetContent(), | 
| 4752 | CaptureFlags::IgnoreAllowedState); | 
| 4753 | } | 
| 4754 | } | 
| 4755 | } | 
| 4756 | |
| 4757 | // XXX This is screwy; it really should use the selection frame, not the | 
| 4758 | // event frame | 
| 4759 | const nsFrameSelection* frameselection = | 
| 4760 | selectStyle == StyleUserSelect::Text ? GetConstFrameSelection() | 
| 4761 | : presShell->ConstFrameSelection(); | 
| 4762 | |
| 4763 | if (!frameselection || frameselection->GetDisplaySelection() == | 
| 4764 | nsISelectionController::SELECTION_OFF) { | 
| 4765 | return NS_OK; // nothing to do we cannot affect selection from here | 
| 4766 | } | 
| 4767 | |
| 4768 | #ifdef XP_MACOSX | 
| 4769 | // If Control key is pressed on macOS, it should be treated as right click. | 
| 4770 | // So, don't change selection. | 
| 4771 | if (aMouseEvent->IsControl()) { | 
| 4772 | return NS_OK; | 
| 4773 | } | 
| 4774 | const bool control = aMouseEvent->IsMeta(); | 
| 4775 | #else | 
| 4776 | const bool control = aMouseEvent->IsControl(); | 
| 4777 | #endif | 
| 4778 | |
| 4779 | RefPtr<nsFrameSelection> fc = const_cast<nsFrameSelection*>(frameselection); | 
| 4780 | if (isPrimaryButtonDown && aMouseEvent->mClickCount > 1) { | 
| 4781 | // These methods aren't const but can't actually delete anything, | 
| 4782 | // so no need for AutoWeakFrame. | 
| 4783 | fc->SetDragState(true); | 
| 4784 | return HandleMultiplePress(aPresContext, aMouseEvent, aEventStatus, | 
| 4785 | control); | 
| 4786 | } | 
| 4787 | |
| 4788 | ContentOffsets offsets = GetContentOffsetsFromPoint(pt, SKIP_HIDDEN); | 
| 4789 | |
| 4790 | if (!offsets.content) { | 
| 4791 | return NS_ERROR_FAILURE; | 
| 4792 | } | 
| 4793 | |
| 4794 | const bool isSecondaryButton = | 
| 4795 | aMouseEvent->mButton == MouseButton::eSecondary; | 
| 4796 | if (isSecondaryButton && | 
| 4797 | !MovingCaretToEventPointAllowedIfSecondaryButtonEvent( | 
| 4798 | *frameselection, *aMouseEvent, *offsets.content, | 
| 4799 | // When we collapse selection in nsFrameSelection::TakeFocus, | 
| 4800 | // we always collapse selection to the start offset. Therefore, | 
| 4801 | // we can ignore the end offset here. E.g., when an <img> is clicked, | 
| 4802 | // set the primary offset to after it, but the the secondary offset | 
| 4803 | // may be before it, see OffsetsForSingleFrame for the detail. | 
| 4804 | offsets.StartOffset())) { | 
| 4805 | return NS_OK; | 
| 4806 | } | 
| 4807 | |
| 4808 | if (aMouseEvent->mMessage == eMouseDown && | 
| 4809 | aMouseEvent->mButton == MouseButton::eMiddle && | 
| 4810 | !offsets.content->IsEditable()) { | 
| 4811 | // However, some users don't like the Chrome compatible behavior of | 
| 4812 | // middle mouse click. They want to keep selection after starting | 
| 4813 | // autoscroll. However, the selection change is important for middle | 
| 4814 | // mouse past. Therefore, we should allow users to take the traditional | 
| 4815 | // behavior back by themselves unless middle click paste is enabled or | 
| 4816 | // autoscrolling is disabled. | 
| 4817 | if (!Preferences::GetBool("middlemouse.paste", false) && | 
| 4818 | Preferences::GetBool("general.autoScroll", false) && | 
| 4819 | Preferences::GetBool("general.autoscroll.prevent_to_collapse_selection_" | 
| 4820 | "by_middle_mouse_down", | 
| 4821 | false)) { | 
| 4822 | return NS_OK; | 
| 4823 | } | 
| 4824 | } | 
| 4825 | |
| 4826 | if (isPrimaryButtonDown) { | 
| 4827 | // Let Ctrl/Cmd + left mouse down do table selection instead of drag | 
| 4828 | // initiation. | 
| 4829 | nsCOMPtr<nsIContent> parentContent; | 
| 4830 | int32_t contentOffset; | 
| 4831 | TableSelectionMode target; | 
| 4832 | nsresult rv = GetDataForTableSelection( | 
| 4833 | frameselection, presShell, aMouseEvent, getter_AddRefs(parentContent), | 
| 4834 | &contentOffset, &target); | 
| 4835 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && parentContent) { | 
| 4836 | fc->SetDragState(true); | 
| 4837 | return fc->HandleTableSelection(parentContent, contentOffset, target, | 
| 4838 | aMouseEvent); | 
| 4839 | } | 
| 4840 | } | 
| 4841 | |
| 4842 | fc->SetDelayedCaretData(0); | 
| 4843 | |
| 4844 | if (isPrimaryButtonDown) { | 
| 4845 | // Check if any part of this frame is selected, and if the user clicked | 
| 4846 | // inside the selected region, and if it's the left button. If so, we delay | 
| 4847 | // starting a new selection since the user may be trying to drag the | 
| 4848 | // selected region to some other app. | 
| 4849 | |
| 4850 | if (GetContent() && GetContent()->IsMaybeSelected()) { | 
| 4851 | bool inSelection = false; | 
| 4852 | UniquePtr<SelectionDetails> details = frameselection->LookUpSelection( | 
| 4853 | offsets.content, 0, offsets.EndOffset(), false); | 
| 4854 | |
| 4855 | // | 
| 4856 | // If there are any details, check to see if the user clicked | 
| 4857 | // within any selected region of the frame. | 
| 4858 | // | 
| 4859 | |
| 4860 | for (SelectionDetails* curDetail = details.get(); curDetail; | 
| 4861 | curDetail = curDetail->mNext.get()) { | 
| 4862 | // | 
| 4863 | // If the user clicked inside a selection, then just | 
| 4864 | // return without doing anything. We will handle placing | 
| 4865 | // the caret later on when the mouse is released. We ignore | 
| 4866 | // the spellcheck, find and url formatting selections. | 
| 4867 | // | 
| 4868 | if (curDetail->mSelectionType != SelectionType::eSpellCheck && | 
| 4869 | curDetail->mSelectionType != SelectionType::eFind && | 
| 4870 | curDetail->mSelectionType != SelectionType::eURLSecondary && | 
| 4871 | curDetail->mSelectionType != SelectionType::eURLStrikeout && | 
| 4872 | curDetail->mSelectionType != SelectionType::eHighlight && | 
| 4873 | curDetail->mSelectionType != SelectionType::eTargetText && | 
| 4874 | curDetail->mStart <= offsets.StartOffset() && | 
| 4875 | offsets.EndOffset() <= curDetail->mEnd) { | 
| 4876 | inSelection = true; | 
| 4877 | } | 
| 4878 | } | 
| 4879 | |
| 4880 | if (inSelection) { | 
| 4881 | fc->SetDragState(false); | 
| 4882 | fc->SetDelayedCaretData(aMouseEvent); | 
| 4883 | return NS_OK; | 
| 4884 | } | 
| 4885 | } | 
| 4886 | |
| 4887 | fc->SetDragState(true); | 
| 4888 | } | 
| 4889 | |
| 4890 | // Do not touch any nsFrame members after this point without adding | 
| 4891 | // weakFrame checks. | 
| 4892 | const nsFrameSelection::FocusMode focusMode = [&]() { | 
| 4893 | // If "Shift" and "Ctrl" are both pressed, "Shift" is given precedence. This | 
| 4894 | // mimics the old behaviour. | 
| 4895 | const bool isShift = | 
| 4896 | aMouseEvent->IsShift() && | 
| 4897 | // If Shift + secondary button press shoud open context menu without a | 
| 4898 | // contextmenu event, user wants to open context menu like as a | 
| 4899 | // secondary button press without Shift key. | 
| 4900 | !(isSecondaryButton && | 
| 4901 | StaticPrefs::dom_event_contextmenu_shift_suppresses_event()); | 
| 4902 | if (isShift) { | 
| 4903 | // If clicked in a link when focused content is editable, we should | 
| 4904 | // collapse selection in the link for compatibility with Blink. | 
| 4905 | if (isEditor) { | 
| 4906 | for (Element* element : mContent->InclusiveAncestorsOfType<Element>()) { | 
| 4907 | if (element->IsLink()) { | 
| 4908 | return nsFrameSelection::FocusMode::kCollapseToNewPoint; | 
| 4909 | } | 
| 4910 | } | 
| 4911 | } | 
| 4912 | return nsFrameSelection::FocusMode::kExtendSelection; | 
| 4913 | } | 
| 4914 | |
| 4915 | if (isPrimaryButtonDown && control) { | 
| 4916 | return nsFrameSelection::FocusMode::kMultiRangeSelection; | 
| 4917 | } | 
| 4918 | |
| 4919 | return nsFrameSelection::FocusMode::kCollapseToNewPoint; | 
| 4920 | }(); | 
| 4921 | |
| 4922 | nsresult rv = fc->HandleClick( | 
| 4923 | MOZ_KnownLive(offsets.content)(offsets.content) /* bug 1636889 */, offsets.StartOffset(), | 
| 4924 | offsets.EndOffset(), focusMode, offsets.associate); | 
| 4925 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 4926 | return rv; | 
| 4927 | } | 
| 4928 | |
| 4929 | // We don't handle mouse button up if it's middle button. | 
| 4930 | if (isPrimaryButtonDown && offsets.offset != offsets.secondaryOffset) { | 
| 4931 | fc->MaintainSelection(); | 
| 4932 | } | 
| 4933 | |
| 4934 | if (isPrimaryButtonDown && isEditor && !aMouseEvent->IsShift() && | 
| 4935 | (offsets.EndOffset() - offsets.StartOffset()) == 1) { | 
| 4936 | // A single node is selected and we aren't extending an existing selection, | 
| 4937 | // which means the user clicked directly on an object (either | 
| 4938 | // `user-select: all` or a non-text node without children). Therefore, | 
| 4939 | // disable selection extension during mouse moves. | 
| 4940 | // XXX This is a bit hacky; shouldn't editor be able to deal with this? | 
| 4941 | fc->SetDragState(false); | 
| 4942 | } | 
| 4943 | |
| 4944 | return NS_OK; | 
| 4945 | } | 
| 4946 | |
| 4947 | bool nsIFrame::MovingCaretToEventPointAllowedIfSecondaryButtonEvent( | 
| 4948 | const nsFrameSelection& aFrameSelection, | 
| 4949 | WidgetMouseEvent& aSecondaryButtonEvent, | 
| 4950 | const nsIContent& aContentAtEventPoint, int32_t aOffsetAtEventPoint) const { | 
| 4951 | MOZ_ASSERT(aSecondaryButtonEvent.mButton == MouseButton::eSecondary)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aSecondaryButtonEvent.mButton == MouseButton::eSecondary )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aSecondaryButtonEvent.mButton == MouseButton::eSecondary ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "aSecondaryButtonEvent.mButton == MouseButton::eSecondary", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4951); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aSecondaryButtonEvent.mButton == MouseButton::eSecondary" ")"); do { *((volatile int*)__null) = 4951; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4952 | |
| 4953 | if (NS_WARN_IF(aOffsetAtEventPoint < 0)NS_warn_if_impl(aOffsetAtEventPoint < 0, "aOffsetAtEventPoint < 0" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4953)) { | 
| 4954 | return false; | 
| 4955 | } | 
| 4956 | |
| 4957 | const bool contentIsEditable = aContentAtEventPoint.IsEditable(); | 
| 4958 | const TextControlElement* const contentAsTextControl = | 
| 4959 | TextControlElement::FromNodeOrNull( | 
| 4960 | aContentAtEventPoint.IsTextControlElement() | 
| 4961 | ? &aContentAtEventPoint | 
| 4962 | : aContentAtEventPoint.GetClosestNativeAnonymousSubtreeRoot()); | 
| 4963 | const Selection& selection = aFrameSelection.NormalSelection(); | 
| 4964 | const bool selectionIsCollapsed = | 
| 4965 | selection.AreNormalAndCrossShadowBoundaryRangesCollapsed(); | 
| 4966 | // If right click in a selection range, we should not collapse | 
| 4967 | // selection. | 
| 4968 | if (!selectionIsCollapsed && nsContentUtils::IsPointInSelection( | 
| 4969 | selection, aContentAtEventPoint, | 
| 4970 | static_cast<uint32_t>(aOffsetAtEventPoint), | 
| 4971 | true /* aAllowCrossShadowBoundary */)) { | 
| 4972 | return false; | 
| 4973 | } | 
| 4974 | const bool wantToPreventMoveCaret = | 
| 4975 | StaticPrefs:: | 
| 4976 | ui_mouse_right_click_move_caret_stop_if_in_focused_editable_node() && | 
| 4977 | selectionIsCollapsed && (contentIsEditable || contentAsTextControl); | 
| 4978 | const bool wantToPreventCollapseSelection = | 
| 4979 | StaticPrefs:: | 
| 4980 | ui_mouse_right_click_collapse_selection_stop_if_non_collapsed_selection() && | 
| 4981 | !selectionIsCollapsed; | 
| 4982 | if (wantToPreventMoveCaret || wantToPreventCollapseSelection) { | 
| 4983 | // If currently selection is limited in an editing host, we should not | 
| 4984 | // collapse selection nor move caret if the clicked point is in the | 
| 4985 | // ancestor limiter. Otherwise, this mouse click moves focus from the | 
| 4986 | // editing host to different one or blur the editing host. In this case, | 
| 4987 | // we need to update selection because keeping current selection in the | 
| 4988 | // editing host looks like it's not blurred. | 
| 4989 | // FIXME: If the active editing host is the document element, editor | 
| 4990 | // does not set ancestor limiter properly. Fix it in the editor side. | 
| 4991 | if (nsIContent* ancestorLimiter = selection.GetAncestorLimiter()) { | 
| 4992 | MOZ_ASSERT(ancestorLimiter->IsEditable())do { static_assert( mozilla::detail::AssertionConditionType< decltype(ancestorLimiter->IsEditable())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(ancestorLimiter->IsEditable ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("ancestorLimiter->IsEditable()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 4992); AnnotateMozCrashReason("MOZ_ASSERT" "(" "ancestorLimiter->IsEditable()" ")"); do { *((volatile int*)__null) = 4992; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 4993 | return !aContentAtEventPoint.IsInclusiveDescendantOf(ancestorLimiter); | 
| 4994 | } | 
| 4995 | } | 
| 4996 | // If selection is editable and `stop_if_in_focused_editable_node` pref is | 
| 4997 | // set to true, user does not want to move caret to right click place if | 
| 4998 | // clicked in the focused text control element. | 
| 4999 | if (wantToPreventMoveCaret && contentAsTextControl && | 
| 5000 | contentAsTextControl == nsFocusManager::GetFocusedElementStatic()) { | 
| 5001 | return false; | 
| 5002 | } | 
| 5003 | // If currently selection is not limited in an editing host, we should | 
| 5004 | // collapse selection only when this click moves focus to an editing | 
| 5005 | // host because we need to update selection in this case. | 
| 5006 | if (wantToPreventCollapseSelection && !contentIsEditable) { | 
| 5007 | return false; | 
| 5008 | } | 
| 5009 | |
| 5010 | return !StaticPrefs:: | 
| 5011 | ui_mouse_right_click_collapse_selection_stop_if_non_editable_node() || | 
| 5012 | // The user does not want to collapse selection into non-editable | 
| 5013 | // content by a right button click. | 
| 5014 | contentIsEditable || | 
| 5015 | // Treat clicking in a text control as always clicked on editable | 
| 5016 | // content because we want a hack only for clicking in normal text | 
| 5017 | // nodes which is outside any editing hosts. | 
| 5018 | contentAsTextControl; | 
| 5019 | } | 
| 5020 | |
| 5021 | nsresult nsIFrame::SelectByTypeAtPoint(nsPresContext* aPresContext, | 
| 5022 | const nsPoint& aPoint, | 
| 5023 | nsSelectionAmount aBeginAmountType, | 
| 5024 | nsSelectionAmount aEndAmountType, | 
| 5025 | uint32_t aSelectFlags) { | 
| 5026 | NS_ENSURE_ARG_POINTER(aPresContext)do { if ((__builtin_expect(!!(!(aPresContext)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aPresContext" ") failed" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5026); return NS_ERROR_INVALID_POINTER; } } while (false); | 
| 5027 | |
| 5028 | // No point in selecting if selection is turned off | 
| 5029 | if (DetermineDisplaySelection() == nsISelectionController::SELECTION_OFF) { | 
| 5030 | return NS_OK; | 
| 5031 | } | 
| 5032 | |
| 5033 | ContentOffsets offsets = GetContentOffsetsFromPoint( | 
| 5034 | aPoint, SKIP_HIDDEN | IGNORE_NATIVE_ANONYMOUS_SUBTREE); | 
| 5035 | if (!offsets.content) { | 
| 5036 | return NS_ERROR_FAILURE; | 
| 5037 | } | 
| 5038 | |
| 5039 | uint32_t offset; | 
| 5040 | nsIFrame* frame = SelectionMovementUtils::GetFrameForNodeOffset( | 
| 5041 | offsets.content, offsets.offset, offsets.associate, &offset); | 
| 5042 | if (!frame) { | 
| 5043 | return NS_ERROR_FAILURE; | 
| 5044 | } | 
| 5045 | return frame->PeekBackwardAndForward( | 
| 5046 | aBeginAmountType, aEndAmountType, static_cast<int32_t>(offset), | 
| 5047 | aBeginAmountType != eSelectWord, aSelectFlags); | 
| 5048 | } | 
| 5049 | |
| 5050 | /** | 
| 5051 | * Multiple Mouse Press -- line or paragraph selection -- for the frame. | 
| 5052 | * Wouldn't it be nice if this didn't have to be hardwired into Frame code? | 
| 5053 | */ | 
| 5054 | NS_IMETHODIMPnsresult | 
| 5055 | nsIFrame::HandleMultiplePress(nsPresContext* aPresContext, | 
| 5056 | WidgetGUIEvent* aEvent, | 
| 5057 | nsEventStatus* aEventStatus, bool aControlHeld) { | 
| 5058 | NS_ENSURE_ARG_POINTER(aEvent)do { if ((__builtin_expect(!!(!(aEvent)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aEvent" ") failed", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5058); return NS_ERROR_INVALID_POINTER; } } while (false); | 
| 5059 | NS_ENSURE_ARG_POINTER(aEventStatus)do { if ((__builtin_expect(!!(!(aEventStatus)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aEventStatus" ") failed" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5059); return NS_ERROR_INVALID_POINTER; } } while (false); | 
| 5060 | |
| 5061 | if (nsEventStatus_eConsumeNoDefault == *aEventStatus || | 
| 5062 | DetermineDisplaySelection() == nsISelectionController::SELECTION_OFF) { | 
| 5063 | return NS_OK; | 
| 5064 | } | 
| 5065 | |
| 5066 | // Find out whether we're doing line or paragraph selection. | 
| 5067 | // If browser.triple_click_selects_paragraph is true, triple-click selects | 
| 5068 | // paragraph. Otherwise, triple-click selects line, and quadruple-click | 
| 5069 | // selects paragraph (on platforms that support quadruple-click). | 
| 5070 | nsSelectionAmount beginAmount, endAmount; | 
| 5071 | WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); | 
| 5072 | if (!mouseEvent) { | 
| 5073 | return NS_OK; | 
| 5074 | } | 
| 5075 | |
| 5076 | if (mouseEvent->mClickCount == 4) { | 
| 5077 | beginAmount = endAmount = eSelectParagraph; | 
| 5078 | } else if (mouseEvent->mClickCount == 3) { | 
| 5079 | if (Preferences::GetBool("browser.triple_click_selects_paragraph")) { | 
| 5080 | beginAmount = endAmount = eSelectParagraph; | 
| 5081 | } else { | 
| 5082 | beginAmount = eSelectBeginLine; | 
| 5083 | endAmount = eSelectEndLine; | 
| 5084 | } | 
| 5085 | } else if (mouseEvent->mClickCount == 2) { | 
| 5086 | // We only want inline frames; PeekBackwardAndForward dislikes blocks | 
| 5087 | beginAmount = endAmount = eSelectWord; | 
| 5088 | } else { | 
| 5089 | return NS_OK; | 
| 5090 | } | 
| 5091 | |
| 5092 | nsPoint relPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo( | 
| 5093 | mouseEvent, RelativeTo{this}); | 
| 5094 | return SelectByTypeAtPoint(aPresContext, relPoint, beginAmount, endAmount, | 
| 5095 | (aControlHeld ? SELECT_ACCUMULATE : 0)); | 
| 5096 | } | 
| 5097 | |
| 5098 | nsresult nsIFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, | 
| 5099 | nsSelectionAmount aAmountForward, | 
| 5100 | int32_t aStartPos, bool aJumpLines, | 
| 5101 | uint32_t aSelectFlags) { | 
| 5102 | nsIFrame* baseFrame = this; | 
| 5103 | int32_t baseOffset = aStartPos; | 
| 5104 | nsresult rv; | 
| 5105 | |
| 5106 | PeekOffsetOptions peekOffsetOptions{PeekOffsetOption::StopAtScroller}; | 
| 5107 | if (aJumpLines) { | 
| 5108 | peekOffsetOptions += PeekOffsetOption::JumpLines; | 
| 5109 | } | 
| 5110 | |
| 5111 | if (aAmountBack == eSelectWord) { | 
| 5112 | // To avoid selecting the previous word when at start of word, | 
| 5113 | // first move one character forward. | 
| 5114 | PeekOffsetStruct pos(eSelectCharacter, eDirNext, aStartPos, nsPoint(0, 0), | 
| 5115 | peekOffsetOptions); | 
| 5116 | rv = PeekOffset(&pos); | 
| 5117 | if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) { | 
| 5118 | baseFrame = pos.mResultFrame; | 
| 5119 | baseOffset = pos.mContentOffset; | 
| 5120 | } | 
| 5121 | } | 
| 5122 | |
| 5123 | // Search backward for a boundary. | 
| 5124 | PeekOffsetStruct startpos(aAmountBack, eDirPrevious, baseOffset, | 
| 5125 | nsPoint(0, 0), peekOffsetOptions); | 
| 5126 | rv = baseFrame->PeekOffset(&startpos); | 
| 5127 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 5128 | return rv; | 
| 5129 | } | 
| 5130 | |
| 5131 | // If the backward search stayed within the same frame, search forward from | 
| 5132 | // that position for the end boundary; but if it crossed out to a sibling or | 
| 5133 | // ancestor, start from the original position. | 
| 5134 | if (startpos.mResultFrame == baseFrame) { | 
| 5135 | baseOffset = startpos.mContentOffset; | 
| 5136 | } else { | 
| 5137 | baseFrame = this; | 
| 5138 | baseOffset = aStartPos; | 
| 5139 | } | 
| 5140 | |
| 5141 | PeekOffsetStruct endpos(aAmountForward, eDirNext, baseOffset, nsPoint(0, 0), | 
| 5142 | peekOffsetOptions); | 
| 5143 | rv = baseFrame->PeekOffset(&endpos); | 
| 5144 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 5145 | return rv; | 
| 5146 | } | 
| 5147 | |
| 5148 | // Keep frameSelection alive. | 
| 5149 | RefPtr<nsFrameSelection> frameSelection = GetFrameSelection(); | 
| 5150 | |
| 5151 | const nsFrameSelection::FocusMode focusMode = | 
| 5152 | (aSelectFlags & SELECT_ACCUMULATE) | 
| 5153 | ? nsFrameSelection::FocusMode::kMultiRangeSelection | 
| 5154 | : nsFrameSelection::FocusMode::kCollapseToNewPoint; | 
| 5155 | rv = frameSelection->HandleClick( | 
| 5156 | MOZ_KnownLive(startpos.mResultContent)(startpos.mResultContent) /* bug 1636889 */, | 
| 5157 | startpos.mContentOffset, startpos.mContentOffset, focusMode, | 
| 5158 | CaretAssociationHint::After); | 
| 5159 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 5160 | return rv; | 
| 5161 | } | 
| 5162 | |
| 5163 | rv = frameSelection->HandleClick( | 
| 5164 | MOZ_KnownLive(endpos.mResultContent)(endpos.mResultContent) /* bug 1636889 */, | 
| 5165 | endpos.mContentOffset, endpos.mContentOffset, | 
| 5166 | nsFrameSelection::FocusMode::kExtendSelection, | 
| 5167 | CaretAssociationHint::Before); | 
| 5168 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 5169 | return rv; | 
| 5170 | } | 
| 5171 | if (aAmountBack == eSelectWord) { | 
| 5172 | frameSelection->SetClickSelectionType(ClickSelectionType::Double); | 
| 5173 | } else if (aAmountBack == eSelectParagraph) { | 
| 5174 | frameSelection->SetClickSelectionType(ClickSelectionType::Triple); | 
| 5175 | } | 
| 5176 | |
| 5177 | // maintain selection | 
| 5178 | return frameSelection->MaintainSelection(aAmountBack); | 
| 5179 | } | 
| 5180 | |
| 5181 | NS_IMETHODIMPnsresult nsIFrame::HandleDrag(nsPresContext* aPresContext, | 
| 5182 | WidgetGUIEvent* aEvent, | 
| 5183 | nsEventStatus* aEventStatus) { | 
| 5184 | MOZ_ASSERT(aEvent->mClass == eMouseEventClass,do { static_assert( mozilla::detail::AssertionConditionType< decltype(aEvent->mClass == eMouseEventClass)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(! !(aEvent->mClass == eMouseEventClass))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aEvent->mClass == eMouseEventClass" " (" "HandleDrag can only handle mouse event" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5185); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aEvent->mClass == eMouseEventClass" ") (" "HandleDrag can only handle mouse event" ")"); do { *( (volatile int*)__null) = 5185; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) | 
| 5185 | "HandleDrag can only handle mouse event")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aEvent->mClass == eMouseEventClass)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(! !(aEvent->mClass == eMouseEventClass))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aEvent->mClass == eMouseEventClass" " (" "HandleDrag can only handle mouse event" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5185); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aEvent->mClass == eMouseEventClass" ") (" "HandleDrag can only handle mouse event" ")"); do { *( (volatile int*)__null) = 5185; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); | 
| 5186 | |
| 5187 | NS_ENSURE_ARG_POINTER(aEventStatus)do { if ((__builtin_expect(!!(!(aEventStatus)), 0))) { NS_DebugBreak (NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "aEventStatus" ") failed" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5187); return NS_ERROR_INVALID_POINTER; } } while (false); | 
| 5188 | |
| 5189 | RefPtr<nsFrameSelection> frameselection = GetFrameSelection(); | 
| 5190 | if (!frameselection) { | 
| 5191 | return NS_OK; | 
| 5192 | } | 
| 5193 | |
| 5194 | bool mouseDown = frameselection->GetDragState(); | 
| 5195 | if (!mouseDown) { | 
| 5196 | return NS_OK; | 
| 5197 | } | 
| 5198 | |
| 5199 | nsIFrame* scrollbar = | 
| 5200 | nsLayoutUtils::GetClosestFrameOfType(this, LayoutFrameType::Scrollbar); | 
| 5201 | if (!scrollbar) { | 
| 5202 | // XXX Do we really need to exclude non-selectable content here? | 
| 5203 | // GetContentOffsetsFromPoint can handle it just fine, although some | 
| 5204 | // other stuff might not like it. | 
| 5205 | // NOTE: DetermineDisplaySelection() returns SELECTION_OFF for | 
| 5206 | // non-selectable frames. | 
| 5207 | if (DetermineDisplaySelection() == nsISelectionController::SELECTION_OFF) { | 
| 5208 | return NS_OK; | 
| 5209 | } | 
| 5210 | } | 
| 5211 | |
| 5212 | frameselection->StopAutoScrollTimer(); | 
| 5213 | |
| 5214 | // Check if we are dragging in a table cell | 
| 5215 | nsCOMPtr<nsIContent> parentContent; | 
| 5216 | int32_t contentOffset; | 
| 5217 | TableSelectionMode target; | 
| 5218 | WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); | 
| 5219 | mozilla::PresShell* presShell = aPresContext->PresShell(); | 
| 5220 | nsresult result; | 
| 5221 | result = GetDataForTableSelection(frameselection, presShell, mouseEvent, | 
| 5222 | getter_AddRefs(parentContent), | 
| 5223 | &contentOffset, &target); | 
| 5224 | |
| 5225 | AutoWeakFrame weakThis = this; | 
| 5226 | if (NS_SUCCEEDED(result)((bool)(__builtin_expect(!!(!NS_FAILED_impl(result)), 1))) && parentContent) { | 
| 5227 | result = frameselection->HandleTableSelection(parentContent, contentOffset, | 
| 5228 | target, mouseEvent); | 
| 5229 | if (NS_WARN_IF(NS_FAILED(result))NS_warn_if_impl(((bool)(__builtin_expect(!!(NS_FAILED_impl(result )), 0))), "NS_FAILED(result)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5229)) { | 
| 5230 | return result; | 
| 5231 | } | 
| 5232 | } else { | 
| 5233 | nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent, | 
| 5234 | RelativeTo{this}); | 
| 5235 | frameselection->HandleDrag(this, pt); | 
| 5236 | } | 
| 5237 | |
| 5238 | // The frameselection object notifies selection listeners synchronously above | 
| 5239 | // which might have killed us. | 
| 5240 | if (!weakThis.IsAlive()) { | 
| 5241 | return NS_OK; | 
| 5242 | } | 
| 5243 | |
| 5244 | // Get the nearest scroll container frame. | 
| 5245 | ScrollContainerFrame* scrollContainerFrame = | 
| 5246 | nsLayoutUtils::GetNearestScrollContainerFrame( | 
| 5247 | this, nsLayoutUtils::SCROLLABLE_SAME_DOC | | 
| 5248 | nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN); | 
| 5249 | |
| 5250 | if (scrollContainerFrame) { | 
| 5251 | nsIFrame* capturingFrame = scrollContainerFrame->GetScrolledFrame(); | 
| 5252 | if (capturingFrame) { | 
| 5253 | nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo( | 
| 5254 | mouseEvent, RelativeTo{capturingFrame}); | 
| 5255 | frameselection->StartAutoScrollTimer(capturingFrame, pt, 30); | 
| 5256 | } | 
| 5257 | } | 
| 5258 | |
| 5259 | return NS_OK; | 
| 5260 | } | 
| 5261 | |
| 5262 | /** | 
| 5263 | * This static method handles part of the nsIFrame::HandleRelease in a way | 
| 5264 | * which doesn't rely on the nsFrame object to stay alive. | 
| 5265 | */ | 
| 5266 | MOZ_CAN_RUN_SCRIPT_BOUNDARY static nsresult HandleFrameSelection( | 
| 5267 | nsFrameSelection* aFrameSelection, nsIFrame::ContentOffsets& aOffsets, | 
| 5268 | bool aHandleTableSel, int32_t aContentOffsetForTableSel, | 
| 5269 | TableSelectionMode aTargetForTableSel, | 
| 5270 | nsIContent* aParentContentForTableSel, WidgetGUIEvent* aEvent, | 
| 5271 | const nsEventStatus* aEventStatus) { | 
| 5272 | if (!aFrameSelection) { | 
| 5273 | return NS_OK; | 
| 5274 | } | 
| 5275 | |
| 5276 | nsresult rv = NS_OK; | 
| 5277 | |
| 5278 | if (nsEventStatus_eConsumeNoDefault != *aEventStatus) { | 
| 5279 | if (!aHandleTableSel) { | 
| 5280 | if (!aOffsets.content || !aFrameSelection->HasDelayedCaretData()) { | 
| 5281 | return NS_ERROR_FAILURE; | 
| 5282 | } | 
| 5283 | |
| 5284 | // We are doing this to simulate what we would have done on HandlePress. | 
| 5285 | // We didn't do it there to give the user an opportunity to drag | 
| 5286 | // the text, but since they didn't drag, we want to place the | 
| 5287 | // caret. | 
| 5288 | // However, we'll use the mouse position from the release, since: | 
| 5289 | // * it's easier | 
| 5290 | // * that's the normal click position to use (although really, in | 
| 5291 | // the normal case, small movements that don't count as a drag | 
| 5292 | // can do selection) | 
| 5293 | aFrameSelection->SetDragState(true); | 
| 5294 | |
| 5295 | const nsFrameSelection::FocusMode focusMode = | 
| 5296 | aFrameSelection->IsShiftDownInDelayedCaretData() | 
| 5297 | ? nsFrameSelection::FocusMode::kExtendSelection | 
| 5298 | : nsFrameSelection::FocusMode::kCollapseToNewPoint; | 
| 5299 | rv = aFrameSelection->HandleClick( | 
| 5300 | MOZ_KnownLive(aOffsets.content)(aOffsets.content) /* bug 1636889 */, | 
| 5301 | aOffsets.StartOffset(), aOffsets.EndOffset(), focusMode, | 
| 5302 | aOffsets.associate); | 
| 5303 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 5304 | return rv; | 
| 5305 | } | 
| 5306 | } else if (aParentContentForTableSel) { | 
| 5307 | aFrameSelection->SetDragState(false); | 
| 5308 | rv = aFrameSelection->HandleTableSelection( | 
| 5309 | aParentContentForTableSel, aContentOffsetForTableSel, | 
| 5310 | aTargetForTableSel, aEvent->AsMouseEvent()); | 
| 5311 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 5312 | return rv; | 
| 5313 | } | 
| 5314 | } | 
| 5315 | aFrameSelection->SetDelayedCaretData(0); | 
| 5316 | } | 
| 5317 | |
| 5318 | aFrameSelection->SetDragState(false); | 
| 5319 | aFrameSelection->StopAutoScrollTimer(); | 
| 5320 | |
| 5321 | return NS_OK; | 
| 5322 | } | 
| 5323 | |
| 5324 | NS_IMETHODIMPnsresult nsIFrame::HandleRelease(nsPresContext* aPresContext, | 
| 5325 | WidgetGUIEvent* aEvent, | 
| 5326 | nsEventStatus* aEventStatus) { | 
| 5327 | if (aEvent->mClass != eMouseEventClass) { | 
| 5328 | return NS_OK; | 
| 5329 | } | 
| 5330 | |
| 5331 | nsIFrame* activeFrame = GetActiveSelectionFrame(aPresContext, this); | 
| 5332 | |
| 5333 | nsCOMPtr<nsIContent> captureContent = PresShell::GetCapturingContent(); | 
| 5334 | |
| 5335 | bool selectionOff = | 
| 5336 | (DetermineDisplaySelection() == nsISelectionController::SELECTION_OFF); | 
| 5337 | |
| 5338 | RefPtr<nsFrameSelection> frameselection; | 
| 5339 | ContentOffsets offsets; | 
| 5340 | nsCOMPtr<nsIContent> parentContent; | 
| 5341 | int32_t contentOffsetForTableSel = 0; | 
| 5342 | TableSelectionMode targetForTableSel = TableSelectionMode::None; | 
| 5343 | bool handleTableSelection = true; | 
| 5344 | |
| 5345 | if (!selectionOff) { | 
| 5346 | frameselection = GetFrameSelection(); | 
| 5347 | if (nsEventStatus_eConsumeNoDefault != *aEventStatus && frameselection) { | 
| 5348 | // Check if the frameselection recorded the mouse going down. | 
| 5349 | // If not, the user must have clicked in a part of the selection. | 
| 5350 | // Place the caret before continuing! | 
| 5351 | |
| 5352 | if (frameselection->MouseDownRecorded()) { | 
| 5353 | nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo( | 
| 5354 | aEvent, RelativeTo{this}); | 
| 5355 | offsets = GetContentOffsetsFromPoint(pt, SKIP_HIDDEN); | 
| 5356 | handleTableSelection = false; | 
| 5357 | } else { | 
| 5358 | GetDataForTableSelection(frameselection, PresShell(), | 
| 5359 | aEvent->AsMouseEvent(), | 
| 5360 | getter_AddRefs(parentContent), | 
| 5361 | &contentOffsetForTableSel, &targetForTableSel); | 
| 5362 | } | 
| 5363 | } | 
| 5364 | } | 
| 5365 | |
| 5366 | // We might be capturing in some other document and the event just happened to | 
| 5367 | // trickle down here. Make sure that document's frame selection is notified. | 
| 5368 | // Note, this may cause the current nsFrame object to be deleted, bug 336592. | 
| 5369 | RefPtr<nsFrameSelection> frameSelection; | 
| 5370 | if (activeFrame != this && activeFrame->DetermineDisplaySelection() != | 
| 5371 | nsISelectionController::SELECTION_OFF) { | 
| 5372 | frameSelection = activeFrame->GetFrameSelection(); | 
| 5373 | } | 
| 5374 | |
| 5375 | // Also check the selection of the capturing content which might be in a | 
| 5376 | // different document. | 
| 5377 | if (!frameSelection && captureContent) { | 
| 5378 | if (Document* doc = captureContent->GetComposedDoc()) { | 
| 5379 | mozilla::PresShell* capturingPresShell = doc->GetPresShell(); | 
| 5380 | if (capturingPresShell && | 
| 5381 | capturingPresShell != PresContext()->GetPresShell()) { | 
| 5382 | frameSelection = capturingPresShell->FrameSelection(); | 
| 5383 | } | 
| 5384 | } | 
| 5385 | } | 
| 5386 | |
| 5387 | if (frameSelection) { | 
| 5388 | AutoWeakFrame wf(this); | 
| 5389 | frameSelection->SetDragState(false); | 
| 5390 | frameSelection->StopAutoScrollTimer(); | 
| 5391 | if (wf.IsAlive()) { | 
| 5392 | ScrollContainerFrame* scrollContainerFrame = | 
| 5393 | nsLayoutUtils::GetNearestScrollContainerFrame( | 
| 5394 | this, nsLayoutUtils::SCROLLABLE_SAME_DOC | | 
| 5395 | nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN); | 
| 5396 | if (scrollContainerFrame) { | 
| 5397 | // Perform any additional scrolling needed to maintain CSS snap point | 
| 5398 | // requirements when autoscrolling is over. | 
| 5399 | scrollContainerFrame->ScrollSnap(); | 
| 5400 | } | 
| 5401 | } | 
| 5402 | } | 
| 5403 | |
| 5404 | // Do not call any methods of the current object after this point!!! | 
| 5405 | // The object is perhaps dead! | 
| 5406 | |
| 5407 | return selectionOff ? NS_OK | 
| 5408 | : HandleFrameSelection( | 
| 5409 | frameselection, offsets, handleTableSelection, | 
| 5410 | contentOffsetForTableSel, targetForTableSel, | 
| 5411 | parentContent, aEvent, aEventStatus); | 
| 5412 | } | 
| 5413 | |
| 5414 | struct MOZ_STACK_CLASS FrameContentRange { | 
| 5415 | FrameContentRange(nsIContent* aContent, int32_t aStart, int32_t aEnd) | 
| 5416 | : content(aContent), start(aStart), end(aEnd) {} | 
| 5417 | nsCOMPtr<nsIContent> content; | 
| 5418 | int32_t start; | 
| 5419 | int32_t end; | 
| 5420 | }; | 
| 5421 | |
| 5422 | // Retrieve the content offsets of a frame | 
| 5423 | static FrameContentRange GetRangeForFrame(const nsIFrame* aFrame) { | 
| 5424 | nsIContent* content = aFrame->GetContent(); | 
| 5425 | if (!content) { | 
| 5426 | NS_WARNING("Frame has no content")NS_DebugBreak(NS_DEBUG_WARNING, "Frame has no content", nullptr , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5426); | 
| 5427 | return FrameContentRange(nullptr, -1, -1); | 
| 5428 | } | 
| 5429 | |
| 5430 | LayoutFrameType type = aFrame->Type(); | 
| 5431 | if (type == LayoutFrameType::Text) { | 
| 5432 | auto [offset, offsetEnd] = aFrame->GetOffsets(); | 
| 5433 | return FrameContentRange(content, offset, offsetEnd); | 
| 5434 | } | 
| 5435 | |
| 5436 | if (type == LayoutFrameType::Br) { | 
| 5437 | nsIContent* parent = content->GetParent(); | 
| 5438 | const int32_t beginOffset = parent->ComputeIndexOf_Deprecated(content); | 
| 5439 | return FrameContentRange(parent, beginOffset, beginOffset); | 
| 5440 | } | 
| 5441 | |
| 5442 | while (content->IsRootOfNativeAnonymousSubtree()) { | 
| 5443 | content = content->GetParent(); | 
| 5444 | } | 
| 5445 | |
| 5446 | MOZ_ASSERT(!content->IsBeingRemoved())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!content->IsBeingRemoved())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!content->IsBeingRemoved( )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!content->IsBeingRemoved()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5446); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!content->IsBeingRemoved()" ")"); do { *((volatile int*)__null) = 5446; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 5447 | nsIContent* parent = content->GetParent(); | 
| 5448 | if (aFrame->IsBlockOutside() || !parent) { | 
| 5449 | return FrameContentRange(content, 0, content->GetChildCount()); | 
| 5450 | } | 
| 5451 | |
| 5452 | // TODO(emilio): Revise this in presence of Shadow DOM / display: contents, | 
| 5453 | // it's likely that we don't want to just walk the light tree, and we need to | 
| 5454 | // change the representation of FrameContentRange. | 
| 5455 | Maybe<uint32_t> index = parent->ComputeIndexOf(content); | 
| 5456 | MOZ_ASSERT(index.isSome())do { static_assert( mozilla::detail::AssertionConditionType< decltype(index.isSome())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(index.isSome()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("index.isSome()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5456); AnnotateMozCrashReason("MOZ_ASSERT" "(" "index.isSome()" ")"); do { *((volatile int*)__null) = 5456; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 5457 | return FrameContentRange(parent, static_cast<int32_t>(*index), | 
| 5458 | static_cast<int32_t>(*index + 1)); | 
| 5459 | } | 
| 5460 | |
| 5461 | // The FrameTarget represents the closest frame to a point that can be selected | 
| 5462 | // The frame is the frame represented, frameEdge says whether one end of the | 
| 5463 | // frame is the result (in which case different handling is needed), and | 
| 5464 | // afterFrame says which end is represented if frameEdge is true | 
| 5465 | struct FrameTarget { | 
| 5466 | explicit operator bool() const { return !!frame; } | 
| 5467 | |
| 5468 | nsIFrame* frame = nullptr; | 
| 5469 | bool frameEdge = false; | 
| 5470 | bool afterFrame = false; | 
| 5471 | }; | 
| 5472 | |
| 5473 | // See function implementation for information | 
| 5474 | static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, | 
| 5475 | const nsPoint& aPoint, | 
| 5476 | uint32_t aFlags); | 
| 5477 | |
| 5478 | static bool SelfIsSelectable(nsIFrame* aFrame, nsIFrame* aParentFrame, | 
| 5479 | uint32_t aFlags) { | 
| 5480 | // We should not move selection into a native anonymous subtree when handling | 
| 5481 | // selection outside it. | 
| 5482 | if ((aFlags & nsIFrame::IGNORE_NATIVE_ANONYMOUS_SUBTREE) && | 
| 5483 | aParentFrame->GetClosestNativeAnonymousSubtreeRoot() != | 
| 5484 | aFrame->GetClosestNativeAnonymousSubtreeRoot()) { | 
| 5485 | return false; | 
| 5486 | } | 
| 5487 | if ((aFlags & nsIFrame::SKIP_HIDDEN) && | 
| 5488 | !aFrame->StyleVisibility()->IsVisible()) { | 
| 5489 | return false; | 
| 5490 | } | 
| 5491 | if (aFrame->IsGeneratedContentFrame()) { | 
| 5492 | return false; | 
| 5493 | } | 
| 5494 | if (aFrame->Style()->UserSelect() == StyleUserSelect::None) { | 
| 5495 | return false; | 
| 5496 | } | 
| 5497 | if (aFrame->IsEmpty() && | 
| 5498 | (!aFrame->IsTextFrame() || !aFrame->ContentIsEditable())) { | 
| 5499 | // FIXME(emilio): Historically we haven't treated empty frames as | 
| 5500 | // selectable, but also we had special-cases so that editable empty text | 
| 5501 | // frames returned false from IsEmpty(). Sort this out (probably by | 
| 5502 | // removing the IsEmpty() condition altogether). | 
| 5503 | return false; | 
| 5504 | } | 
| 5505 | return true; | 
| 5506 | } | 
| 5507 | |
| 5508 | static bool FrameContentCanHaveParentSelectionRange(nsIFrame* aFrame) { | 
| 5509 | // If we are only near (not directly over) then don't traverse | 
| 5510 | // frames with independent selection (e.g. text and list controls, see bug | 
| 5511 | // 268497). Note that this prevents any of the users of this method from | 
| 5512 | // entering form controls. | 
| 5513 | // XXX We might want some way to allow using the up-arrow to go into a form | 
| 5514 | // control, but the focus didn't work right anyway; it'd probably be enough | 
| 5515 | // if the left and right arrows could enter textboxes (which I don't believe | 
| 5516 | // they can at the moment) | 
| 5517 | if (aFrame->IsTextInputFrame() || aFrame->IsListControlFrame()) { | 
| 5518 | MOZ_ASSERT(aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION))do { static_assert( mozilla::detail::AssertionConditionType< decltype(aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5518); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" ")"); do { *((volatile int*)__null) = 5518; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 5519 | return false; | 
| 5520 | } | 
| 5521 | |
| 5522 | // Failure in this assertion means a new type of frame forms the root of an | 
| 5523 | // NS_FRAME_INDEPENDENT_SELECTION subtree. In such case, the condition above | 
| 5524 | // should be changed to handle it. | 
| 5525 | MOZ_ASSERT_IF(do { if (aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION )) { do { static_assert( mozilla::detail::AssertionConditionType <decltype(aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5527); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" ")"); do { *((volatile int*)__null) = 5527; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) | 
| 5526 | aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION),do { if (aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION )) { do { static_assert( mozilla::detail::AssertionConditionType <decltype(aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5527); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" ")"); do { *((volatile int*)__null) = 5527; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false) | 
| 5527 | aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION))do { if (aFrame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION )) { do { static_assert( mozilla::detail::AssertionConditionType <decltype(aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 5527); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame->GetParent()->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)" ")"); do { *((volatile int*)__null) = 5527; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); } } while ( false); | 
| 5528 | |
| 5529 | return !aFrame->IsGeneratedContentFrame(); | 
| 5530 | } | 
| 5531 | |
| 5532 | static bool SelectionDescendToKids(nsIFrame* aFrame) { | 
| 5533 | if (!FrameContentCanHaveParentSelectionRange(aFrame)) { | 
| 5534 | return false; | 
| 5535 | } | 
| 5536 | auto style = aFrame->Style()->UserSelect(); | 
| 5537 | return style != StyleUserSelect::All && style != StyleUserSelect::None; | 
| 5538 | } | 
| 5539 | |
| 5540 | static FrameTarget GetSelectionClosestFrameForChild(nsIFrame* aChild, | 
| 5541 | const nsPoint& aPoint, | 
| 5542 | uint32_t aFlags) { | 
| 5543 | nsIFrame* parent = aChild->GetParent(); | 
| 5544 | if (SelectionDescendToKids(aChild)) { | 
| 5545 | nsPoint pt = aPoint - aChild->GetOffsetTo(parent); | 
| 5546 | return GetSelectionClosestFrame(aChild, pt, aFlags); | 
| 5547 | } | 
| 5548 | return FrameTarget{aChild, false, false}; | 
| 5549 | } | 
| 5550 | |
| 5551 | // When the cursor needs to be at the beginning of a block, it shouldn't be | 
| 5552 | // before the first child. A click on a block whose first child is a block | 
| 5553 | // should put the cursor in the child. The cursor shouldn't be between the | 
| 5554 | // blocks, because that's not where it's expected. | 
| 5555 | // Note that this method is guaranteed to succeed. | 
| 5556 | static FrameTarget DrillDownToSelectionFrame(nsIFrame* aFrame, bool aEndFrame, | 
| 5557 | uint32_t aFlags) { | 
| 5558 | if (SelectionDescendToKids(aFrame)) { | 
| 5559 | nsIFrame* result = nullptr; | 
| 5560 | nsIFrame* frame = aFrame->PrincipalChildList().FirstChild(); | 
| 5561 | if (!aEndFrame) { | 
| 5562 | while (frame && !SelfIsSelectable(frame, aFrame, aFlags)) { | 
| 5563 | frame = frame->GetNextSibling(); | 
| 5564 | } | 
| 5565 | if (frame) { | 
| 5566 | result = frame; | 
| 5567 | } | 
| 5568 | } else { | 
| 5569 | // Because the frame tree is singly linked, to find the last frame, | 
| 5570 | // we have to iterate through all the frames | 
| 5571 | // XXX I have a feeling this could be slow for long blocks, although | 
| 5572 | // I can't find any slowdowns | 
| 5573 | while (frame) { | 
| 5574 | if (SelfIsSelectable(frame, aFrame, aFlags)) { | 
| 5575 | result = frame; | 
| 5576 | } | 
| 5577 | frame = frame->GetNextSibling(); | 
| 5578 | } | 
| 5579 | } | 
| 5580 | if (result) { | 
| 5581 | return DrillDownToSelectionFrame(result, aEndFrame, aFlags); | 
| 5582 | } | 
| 5583 | } | 
| 5584 | // If the current frame has no targetable children, target the current frame | 
| 5585 | return FrameTarget{aFrame, true, aEndFrame}; | 
| 5586 | } | 
| 5587 | |
| 5588 | // This method finds the closest valid FrameTarget on a given line; if there is | 
| 5589 | // no valid FrameTarget on the line, it returns a null FrameTarget | 
| 5590 | static FrameTarget GetSelectionClosestFrameForLine( | 
| 5591 | nsBlockFrame* aParent, nsBlockFrame::LineIterator aLine, | 
| 5592 | const nsPoint& aPoint, uint32_t aFlags) { | 
| 5593 | // Account for end of lines (any iterator from the block is valid) | 
| 5594 | if (aLine == aParent->LinesEnd()) { | 
| 5595 | return DrillDownToSelectionFrame(aParent, true, aFlags); | 
| 5596 | } | 
| 5597 | nsIFrame* frame = aLine->mFirstChild; | 
| 5598 | nsIFrame* closestFromIStart = nullptr; | 
| 5599 | nsIFrame* closestFromIEnd = nullptr; | 
| 5600 | nscoord closestIStart = aLine->IStart(), closestIEnd = aLine->IEnd(); | 
| 5601 | WritingMode wm = aLine->mWritingMode; | 
| 5602 | LogicalPoint pt(wm, aPoint, aLine->mContainerSize); | 
| 5603 | bool canSkipBr = false; | 
| 5604 | bool lastFrameWasEditable = false; | 
| 5605 | for (int32_t n = aLine->GetChildCount(); n; | 
| 5606 | --n, frame = frame->GetNextSibling()) { | 
| 5607 | // Skip brFrames. Can only skip if the line contains at least | 
| 5608 | // one selectable and non-empty frame before. Also, avoid skipping brs if | 
| 5609 | // the previous thing had a different editableness than us, since then we | 
| 5610 | // may end up not being able to select after it if the br is the last thing | 
| 5611 | // on the line. | 
| 5612 | if (!SelfIsSelectable(frame, aParent, aFlags) || | 
| 5613 | (canSkipBr && frame->IsBrFrame() && | 
| 5614 | lastFrameWasEditable == frame->GetContent()->IsEditable())) { | 
| 5615 | continue; | 
| 5616 | } | 
| 5617 | canSkipBr = true; | 
| 5618 | lastFrameWasEditable = | 
| 5619 | frame->GetContent() && frame->GetContent()->IsEditable(); | 
| 5620 | LogicalRect frameRect = | 
| 5621 | LogicalRect(wm, frame->GetRect(), aLine->mContainerSize); | 
| 5622 | if (pt.I(wm) >= frameRect.IStart(wm)) { | 
| 5623 | if (pt.I(wm) < frameRect.IEnd(wm)) { | 
| 5624 | return GetSelectionClosestFrameForChild(frame, aPoint, aFlags); | 
| 5625 | } | 
| 5626 | if (frameRect.IEnd(wm) >= closestIStart) { | 
| 5627 | closestFromIStart = frame; | 
| 5628 | closestIStart = frameRect.IEnd(wm); | 
| 5629 | } | 
| 5630 | } else { | 
| 5631 | if (frameRect.IStart(wm) <= closestIEnd) { | 
| 5632 | closestFromIEnd = frame; | 
| 5633 | closestIEnd = frameRect.IStart(wm); | 
| 5634 | } | 
| 5635 | } | 
| 5636 | } | 
| 5637 | if (!closestFromIStart && !closestFromIEnd) { | 
| 5638 | // We should only get here if there are no selectable frames on a line | 
| 5639 | // XXX Do we need more elaborate handling here? | 
| 5640 | return FrameTarget(); | 
| 5641 | } | 
| 5642 | if (closestFromIStart && | 
| 5643 | (!closestFromIEnd || | 
| 5644 | (abs(pt.I(wm) - closestIStart) <= abs(pt.I(wm) - closestIEnd)))) { | 
| 5645 | return GetSelectionClosestFrameForChild(closestFromIStart, aPoint, aFlags); | 
| 5646 | } | 
| 5647 | return GetSelectionClosestFrameForChild(closestFromIEnd, aPoint, aFlags); | 
| 5648 | } | 
| 5649 | |
| 5650 | // This method is for the special handling we do for block frames; they're | 
| 5651 | // special because they represent paragraphs and because they are organized | 
| 5652 | // into lines, which have bounds that are not stored elsewhere in the | 
| 5653 | // frame tree. Returns a null FrameTarget for frames which are not | 
| 5654 | // blocks or blocks with no lines except editable one. | 
| 5655 | static FrameTarget GetSelectionClosestFrameForBlock(nsIFrame* aFrame, | 
| 5656 | const nsPoint& aPoint, | 
| 5657 | uint32_t aFlags) { | 
| 5658 | nsBlockFrame* bf = do_QueryFrame(aFrame); | 
| 5659 | if (!bf) { | 
| 5660 | return FrameTarget(); | 
| 5661 | } | 
| 5662 | |
| 5663 | // This code searches for the correct line | 
| 5664 | nsBlockFrame::LineIterator end = bf->LinesEnd(); | 
| 5665 | nsBlockFrame::LineIterator curLine = bf->LinesBegin(); | 
| 5666 | nsBlockFrame::LineIterator closestLine = end; | 
| 5667 | |
| 5668 | if (curLine != end) { | 
| 5669 | // Convert aPoint into a LogicalPoint in the writing-mode of this block | 
| 5670 | WritingMode wm = curLine->mWritingMode; | 
| 5671 | LogicalPoint pt(wm, aPoint, curLine->mContainerSize); | 
| 5672 | do { | 
| 5673 | // Check to see if our point lies within the line's block-direction bounds | 
| 5674 | nscoord BCoord = pt.B(wm) - curLine->BStart(); | 
| 5675 | nscoord BSize = curLine->BSize(); | 
| 5676 | if (BCoord >= 0 && BCoord < BSize) { | 
| 5677 | closestLine = curLine; | 
| 5678 | break; // We found the line; stop looking | 
| 5679 | } | 
| 5680 | if (BCoord < 0) { | 
| 5681 | break; | 
| 5682 | } | 
| 5683 | ++curLine; | 
| 5684 | } while (curLine != end); | 
| 5685 | |
| 5686 | if (closestLine == end) { | 
| 5687 | nsBlockFrame::LineIterator prevLine = curLine.prev(); | 
| 5688 | nsBlockFrame::LineIterator nextLine = curLine; | 
| 5689 | // Avoid empty lines | 
| 5690 | while (nextLine != end && nextLine->IsEmpty()) { | 
| 5691 | ++nextLine; | 
| 5692 | } | 
| 5693 | while (prevLine != end && prevLine->IsEmpty()) { | 
| 5694 | --prevLine; | 
| 5695 | } | 
| 5696 | |
| 5697 | // This hidden pref dictates whether a point above or below all lines | 
| 5698 | // comes up with a line or the beginning or end of the frame; 0 on | 
| 5699 | // Windows, 1 on other platforms by default at the writing of this code | 
| 5700 | int32_t dragOutOfFrame = | 
| 5701 | Preferences::GetInt("browser.drag_out_of_frame_style"); | 
| 5702 | |
| 5703 | if (prevLine == end) { | 
| 5704 | if (dragOutOfFrame == 1 || nextLine == end) { | 
| 5705 | return DrillDownToSelectionFrame(aFrame, false, aFlags); | 
| 5706 | } | 
| 5707 | closestLine = nextLine; | 
| 5708 | } else if (nextLine == end) { | 
| 5709 | if (dragOutOfFrame == 1) { | 
| 5710 | return DrillDownToSelectionFrame(aFrame, true, aFlags); | 
| 5711 | } | 
| 5712 | closestLine = prevLine; | 
| 5713 | } else { // Figure out which line is closer | 
| 5714 | if (pt.B(wm) - prevLine->BEnd() < nextLine->BStart() - pt.B(wm)) { | 
| 5715 | closestLine = prevLine; | 
| 5716 | } else { | 
| 5717 | closestLine = nextLine; | 
| 5718 | } | 
| 5719 | } | 
| 5720 | } | 
| 5721 | } | 
| 5722 | |
| 5723 | do { | 
| 5724 | if (auto target = | 
| 5725 | GetSelectionClosestFrameForLine(bf, closestLine, aPoint, aFlags)) { | 
| 5726 | return target; | 
| 5727 | } | 
| 5728 | ++closestLine; | 
| 5729 | } while (closestLine != end); | 
| 5730 | |
| 5731 | // Fall back to just targeting the last targetable place | 
| 5732 | return DrillDownToSelectionFrame(aFrame, true, aFlags); | 
| 5733 | } | 
| 5734 | |
| 5735 | // Use frame edge for grid, flex, table, and non-editable images. Choose the | 
| 5736 | // edge based on the point position past the frame rect. If past the middle, | 
| 5737 | // caret should be at end, otherwise at start. This behavior matches Blink. | 
| 5738 | // | 
| 5739 | // TODO(emilio): Can we use this code path for other replaced elements other | 
| 5740 | // than images? Or even all other frames? We only get there when we didn't find | 
| 5741 | // selectable children... At least one XUL test fails if we make this apply to | 
| 5742 | // XUL labels. Also, editable images need _not_ to use the frame edge, see | 
| 5743 | // below. | 
| 5744 | static bool UseFrameEdge(nsIFrame* aFrame) { | 
| 5745 | if (aFrame->IsFlexOrGridContainer() || aFrame->IsTableFrame()) { | 
| 5746 | return true; | 
| 5747 | } | 
| 5748 | const nsImageFrame* image = do_QueryFrame(aFrame); | 
| 5749 | if (image && !aFrame->GetContent()->IsEditable()) { | 
| 5750 | // Editable images are a special-case because editing relies on clicking on | 
| 5751 | // an editable image selecting it, for it to show resizers. | 
| 5752 | return true; | 
| 5753 | } | 
| 5754 | return false; | 
| 5755 | } | 
| 5756 | |
| 5757 | static FrameTarget LastResortFrameTargetForFrame(nsIFrame* aFrame, | 
| 5758 | const nsPoint& aPoint) { | 
| 5759 | if (!UseFrameEdge(aFrame)) { | 
| 5760 | return {aFrame, false, false}; | 
| 5761 | } | 
| 5762 | const auto& rect = aFrame->GetRectRelativeToSelf(); | 
| 5763 | nscoord reference; | 
| 5764 | nscoord middle; | 
| 5765 | if (aFrame->GetWritingMode().IsVertical()) { | 
| 5766 | reference = aPoint.y; | 
| 5767 | middle = rect.Height() / 2; | 
| 5768 | } else { | 
| 5769 | reference = aPoint.x; | 
| 5770 | middle = rect.Width() / 2; | 
| 5771 | } | 
| 5772 | const bool afterFrame = reference > middle; | 
| 5773 | return {aFrame, true, afterFrame}; | 
| 5774 | } | 
| 5775 | |
| 5776 | // GetSelectionClosestFrame is the helper function that calculates the closest | 
| 5777 | // frame to the given point. | 
| 5778 | // It doesn't completely account for offset styles, so needs to be used in | 
| 5779 | // restricted environments. | 
| 5780 | // Cannot handle overlapping frames correctly, so it should receive the output | 
| 5781 | // of GetFrameForPoint | 
| 5782 | // Guaranteed to return a valid FrameTarget. | 
| 5783 | // aPoint is relative to aFrame. | 
| 5784 | static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, | 
| 5785 | const nsPoint& aPoint, | 
| 5786 | uint32_t aFlags) { | 
| 5787 | // Handle blocks; if the frame isn't a block, the method fails | 
| 5788 | if (auto target = GetSelectionClosestFrameForBlock(aFrame, aPoint, aFlags)) { | 
| 5789 | return target; | 
| 5790 | } | 
| 5791 | |
| 5792 | if (aFlags & nsIFrame::IGNORE_NATIVE_ANONYMOUS_SUBTREE && | 
| 5793 | !FrameContentCanHaveParentSelectionRange(aFrame)) { | 
| 5794 | return LastResortFrameTargetForFrame(aFrame, aPoint); | 
| 5795 | } | 
| 5796 | |
| 5797 | if (nsIFrame* kid = aFrame->PrincipalChildList().FirstChild()) { | 
| 5798 | // Go through all the child frames to find the closest one | 
| 5799 | nsIFrame::FrameWithDistance closest = {nullptr, nscoord_MAX, nscoord_MAX}; | 
| 5800 | for (; kid; kid = kid->GetNextSibling()) { | 
| 5801 | if (!SelfIsSelectable(kid, aFrame, aFlags)) { | 
| 5802 | continue; | 
| 5803 | } | 
| 5804 | |
| 5805 | kid->FindCloserFrameForSelection(aPoint, &closest); | 
| 5806 | } | 
| 5807 | if (closest.mFrame) { | 
| 5808 | if (closest.mFrame->IsInSVGTextSubtree()) { | 
| 5809 | return FrameTarget{closest.mFrame, false, false}; | 
| 5810 | } | 
| 5811 | return GetSelectionClosestFrameForChild(closest.mFrame, aPoint, aFlags); | 
| 5812 | } | 
| 5813 | } | 
| 5814 | |
| 5815 | return LastResortFrameTargetForFrame(aFrame, aPoint); | 
| 5816 | } | 
| 5817 | |
| 5818 | static nsIFrame::ContentOffsets OffsetsForSingleFrame(nsIFrame* aFrame, | 
| 5819 | const nsPoint& aPoint) { | 
| 5820 | nsIFrame::ContentOffsets offsets; | 
| 5821 | FrameContentRange range = GetRangeForFrame(aFrame); | 
| 5822 | offsets.content = range.content; | 
| 5823 | // If there are continuations (meaning it's not one rectangle), this is the | 
| 5824 | // best this function can do | 
| 5825 | if (aFrame->GetNextContinuation() || aFrame->GetPrevContinuation()) { | 
| 5826 | offsets.offset = range.start; | 
| 5827 | offsets.secondaryOffset = range.end; | 
| 5828 | offsets.associate = CaretAssociationHint::After; | 
| 5829 | return offsets; | 
| 5830 | } | 
| 5831 | |
| 5832 | // Figure out whether the offsets should be over, after, or before the frame | 
| 5833 | nsRect rect(nsPoint(0, 0), aFrame->GetSize()); | 
| 5834 | |
| 5835 | bool isBlock = !aFrame->StyleDisplay()->IsInlineFlow(); | 
| 5836 | bool isRtl = (aFrame->StyleVisibility()->mDirection == StyleDirection::Rtl); | 
| 5837 | if ((isBlock && rect.y < aPoint.y) || | 
| 5838 | (!isBlock && ((isRtl && rect.x + rect.width / 2 > aPoint.x) || | 
| 5839 | (!isRtl && rect.x + rect.width / 2 < aPoint.x)))) { | 
| 5840 | offsets.offset = range.end; | 
| 5841 | if (rect.Contains(aPoint)) { | 
| 5842 | offsets.secondaryOffset = range.start; | 
| 5843 | } else { | 
| 5844 | offsets.secondaryOffset = range.end; | 
| 5845 | } | 
| 5846 | } else { | 
| 5847 | offsets.offset = range.start; | 
| 5848 | if (rect.Contains(aPoint)) { | 
| 5849 | offsets.secondaryOffset = range.end; | 
| 5850 | } else { | 
| 5851 | offsets.secondaryOffset = range.start; | 
| 5852 | } | 
| 5853 | } | 
| 5854 | offsets.associate = offsets.offset == range.start | 
| 5855 | ? CaretAssociationHint::After | 
| 5856 | : CaretAssociationHint::Before; | 
| 5857 | return offsets; | 
| 5858 | } | 
| 5859 | |
| 5860 | static nsIFrame* AdjustFrameForSelectionStyles(nsIFrame* aFrame) { | 
| 5861 | nsIFrame* adjustedFrame = aFrame; | 
| 5862 | for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent()) { | 
| 5863 | // These are the conditions that make all children not able to handle | 
| 5864 | // a cursor. | 
| 5865 | auto userSelect = frame->Style()->UserSelect(); | 
| 5866 | if (userSelect != StyleUserSelect::Auto && | 
| 5867 | userSelect != StyleUserSelect::All) { | 
| 5868 | break; | 
| 5869 | } | 
| 5870 | if (userSelect == StyleUserSelect::All || | 
| 5871 | frame->IsGeneratedContentFrame()) { | 
| 5872 | adjustedFrame = frame; | 
| 5873 | } | 
| 5874 | } | 
| 5875 | return adjustedFrame; | 
| 5876 | } | 
| 5877 | |
| 5878 | nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint( | 
| 5879 | const nsPoint& aPoint, uint32_t aFlags) { | 
| 5880 | nsIFrame* adjustedFrame; | 
| 5881 | if (aFlags & IGNORE_SELECTION_STYLE) { | 
| 5882 | adjustedFrame = this; | 
| 5883 | } else { | 
| 5884 | // This section of code deals with special selection styles. Note that | 
| 5885 | // -moz-all exists, even though it doesn't need to be explicitly handled. | 
| 5886 | // | 
| 5887 | // The offset is forced not to end up in generated content; content offsets | 
| 5888 | // cannot represent content outside of the document's content tree. | 
| 5889 | |
| 5890 | adjustedFrame = AdjustFrameForSelectionStyles(this); | 
| 5891 | |
| 5892 | // `user-select: all` needs special handling, because clicking on it should | 
| 5893 | // lead to the whole frame being selected. | 
| 5894 | if (adjustedFrame->Style()->UserSelect() == StyleUserSelect::All) { | 
| 5895 | nsPoint adjustedPoint = aPoint + GetOffsetTo(adjustedFrame); | 
| 5896 | return OffsetsForSingleFrame(adjustedFrame, adjustedPoint); | 
| 5897 | } | 
| 5898 | |
| 5899 | // For other cases, try to find a closest frame starting from the parent of | 
| 5900 | // the unselectable frame | 
| 5901 | if (adjustedFrame != this) { | 
| 5902 | adjustedFrame = adjustedFrame->GetParent(); | 
| 5903 | } | 
| 5904 | } | 
| 5905 | |
| 5906 | nsPoint adjustedPoint = aPoint + GetOffsetTo(adjustedFrame); | 
| 5907 | |
| 5908 | FrameTarget closest = | 
| 5909 | GetSelectionClosestFrame(adjustedFrame, adjustedPoint, aFlags); | 
| 5910 | |
| 5911 | // If the correct offset is at one end of a frame, use offset-based | 
| 5912 | // calculation method | 
| 5913 | if (closest.frameEdge) { | 
| 5914 | ContentOffsets offsets; | 
| 5915 | FrameContentRange range = GetRangeForFrame(closest.frame); | 
| 5916 | offsets.content = range.content; | 
| 5917 | if (closest.afterFrame) { | 
| 5918 | offsets.offset = range.end; | 
| 5919 | } else { | 
| 5920 | offsets.offset = range.start; | 
| 5921 | } | 
| 5922 | offsets.secondaryOffset = offsets.offset; | 
| 5923 | offsets.associate = offsets.offset == range.start | 
| 5924 | ? CaretAssociationHint::After | 
| 5925 | : CaretAssociationHint::Before; | 
| 5926 | return offsets; | 
| 5927 | } | 
| 5928 | |
| 5929 | nsPoint pt; | 
| 5930 | if (closest.frame != this) { | 
| 5931 | if (closest.frame->IsInSVGTextSubtree()) { | 
| 5932 | pt = nsLayoutUtils::TransformAncestorPointToFrame( | 
| 5933 | RelativeTo{closest.frame}, aPoint, RelativeTo{this}); | 
| 5934 | } else { | 
| 5935 | pt = aPoint - closest.frame->GetOffsetTo(this); | 
| 5936 | } | 
| 5937 | } else { | 
| 5938 | pt = aPoint; | 
| 5939 | } | 
| 5940 | return closest.frame->CalcContentOffsetsFromFramePoint(pt); | 
| 5941 | |
| 5942 | // XXX should I add some kind of offset standardization? | 
| 5943 | // consider <b>xxxxx</b><i>zzzzz</i>; should any click between the last | 
| 5944 | // x and first z put the cursor in the same logical position in addition | 
| 5945 | // to the same visual position? | 
| 5946 | } | 
| 5947 | |
| 5948 | nsIFrame::ContentOffsets nsIFrame::CalcContentOffsetsFromFramePoint( | 
| 5949 | const nsPoint& aPoint) { | 
| 5950 | return OffsetsForSingleFrame(this, aPoint); | 
| 5951 | } | 
| 5952 | |
| 5953 | bool nsIFrame::AssociateImage(const StyleImage& aImage) { | 
| 5954 | imgRequestProxy* req = aImage.GetImageRequest(); | 
| 5955 | if (!req) { | 
| 5956 | return false; | 
| 5957 | } | 
| 5958 | |
| 5959 | mozilla::css::ImageLoader* loader = | 
| 5960 | PresContext()->Document()->StyleImageLoader(); | 
| 5961 | |
| 5962 | loader->AssociateRequestToFrame(req, this); | 
| 5963 | return true; | 
| 5964 | } | 
| 5965 | |
| 5966 | void nsIFrame::DisassociateImage(const StyleImage& aImage) { | 
| 5967 | imgRequestProxy* req = aImage.GetImageRequest(); | 
| 5968 | if (!req) { | 
| 5969 | return; | 
| 5970 | } | 
| 5971 | |
| 5972 | mozilla::css::ImageLoader* loader = | 
| 5973 | PresContext()->Document()->StyleImageLoader(); | 
| 5974 | |
| 5975 | loader->DisassociateRequestFromFrame(req, this); | 
| 5976 | } | 
| 5977 | |
| 5978 | StyleImageRendering nsIFrame::UsedImageRendering() const { | 
| 5979 | ComputedStyle* style; | 
| 5980 | if (IsCanvasFrame()) { | 
| 5981 | // XXXdholbert Maybe we should use FindCanvasBackground here (instead of | 
| 5982 | // FindBackground), since we're inside an IsCanvasFrame check? Though then | 
| 5983 | // we'd also have to copypaste or abstract-away the multi-part root-frame | 
| 5984 | // lookup that the canvas-flavored API requires. | 
| 5985 | style = nsCSSRendering::FindBackground(this); | 
| 5986 | } else { | 
| 5987 | style = Style(); | 
| 5988 | } | 
| 5989 | return style->StyleVisibility()->mImageRendering; | 
| 5990 | } | 
| 5991 | |
| 5992 | // The touch-action CSS property applies to: all elements except: non-replaced | 
| 5993 | // inline elements, table rows, row groups, table columns, and column groups. | 
| 5994 | StyleTouchAction nsIFrame::UsedTouchAction() const { | 
| 5995 | if (IsLineParticipant()) { | 
| 5996 | return StyleTouchAction::AUTO; | 
| 5997 | } | 
| 5998 | auto& disp = *StyleDisplay(); | 
| 5999 | if (disp.IsInternalTableStyleExceptCell()) { | 
| 6000 | return StyleTouchAction::AUTO; | 
| 6001 | } | 
| 6002 | return disp.mTouchAction; | 
| 6003 | } | 
| 6004 | |
| 6005 | nsIFrame::Cursor nsIFrame::GetCursor(const nsPoint&) { | 
| 6006 | StyleCursorKind kind = StyleUI()->Cursor().keyword; | 
| 6007 | if (kind == StyleCursorKind::Auto) { | 
| 6008 | // If this is editable, I-beam cursor is better for most elements. | 
| 6009 | kind = (mContent && mContent->IsEditable()) ? StyleCursorKind::Text | 
| 6010 | : StyleCursorKind::Default; | 
| 6011 | } | 
| 6012 | if (kind == StyleCursorKind::Text && GetWritingMode().IsVertical()) { | 
| 6013 | // Per CSS UI spec, UA may treat value 'text' as | 
| 6014 | // 'vertical-text' for vertical text. | 
| 6015 | kind = StyleCursorKind::VerticalText; | 
| 6016 | } | 
| 6017 | |
| 6018 | return Cursor{kind, AllowCustomCursorImage::Yes}; | 
| 6019 | } | 
| 6020 | |
| 6021 | // Resize and incremental reflow | 
| 6022 | |
| 6023 | /* virtual */ | 
| 6024 | void nsIFrame::MarkIntrinsicISizesDirty() { | 
| 6025 | // If we're a flex item, clear our flex-item-specific cached measurements | 
| 6026 | // (which likely depended on our now-stale intrinsic isize). | 
| 6027 | if (IsFlexItem()) { | 
| 6028 | nsFlexContainerFrame::MarkCachedFlexMeasurementsDirty(this); | 
| 6029 | } | 
| 6030 | |
| 6031 | if (HasAnyStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT)) { | 
| 6032 | nsFontInflationData::MarkFontInflationDataTextDirty(this); | 
| 6033 | } | 
| 6034 | |
| 6035 | RemoveProperty(nsGridContainerFrame::CachedBAxisMeasurement::Prop()); | 
| 6036 | } | 
| 6037 | |
| 6038 | void nsIFrame::MarkSubtreeDirty() { | 
| 6039 | if (HasAnyStateBits(NS_FRAME_IS_DIRTY)) { | 
| 6040 | return; | 
| 6041 | } | 
| 6042 | // Unconditionally mark given frame dirty. | 
| 6043 | AddStateBits(NS_FRAME_IS_DIRTY); | 
| 6044 | |
| 6045 | // Mark all descendants dirty, unless: | 
| 6046 | // - Already dirty. | 
| 6047 | // - TableColGroup | 
| 6048 | AutoTArray<nsIFrame*, 32> stack; | 
| 6049 | for (const auto& childLists : ChildLists()) { | 
| 6050 | for (nsIFrame* kid : childLists.mList) { | 
| 6051 | stack.AppendElement(kid); | 
| 6052 | } | 
| 6053 | } | 
| 6054 | while (!stack.IsEmpty()) { | 
| 6055 | nsIFrame* f = stack.PopLastElement(); | 
| 6056 | if (f->HasAnyStateBits(NS_FRAME_IS_DIRTY) || f->IsTableColGroupFrame()) { | 
| 6057 | continue; | 
| 6058 | } | 
| 6059 | |
| 6060 | f->AddStateBits(NS_FRAME_IS_DIRTY); | 
| 6061 | |
| 6062 | for (const auto& childLists : f->ChildLists()) { | 
| 6063 | for (nsIFrame* kid : childLists.mList) { | 
| 6064 | stack.AppendElement(kid); | 
| 6065 | } | 
| 6066 | } | 
| 6067 | } | 
| 6068 | } | 
| 6069 | |
| 6070 | /* virtual */ | 
| 6071 | void nsIFrame::AddInlineMinISize(const IntrinsicSizeInput& aInput, | 
| 6072 | InlineMinISizeData* aData) { | 
| 6073 | // Note: we are one of the children that mPercentageBasisForChildren was | 
| 6074 | // prepared for (i.e. our parent frame prepares the percentage basis for us, | 
| 6075 | // not for our own children). Hence it's fine that we're resolving our | 
| 6076 | // percentages sizes against this basis in IntrinsicForContainer(). | 
| 6077 | nscoord isize = nsLayoutUtils::IntrinsicForContainer( | 
| 6078 | aInput.mContext, this, IntrinsicISizeType::MinISize, | 
| 6079 | aInput.mPercentageBasisForChildren); | 
| 6080 | aData->DefaultAddInlineMinISize(this, isize); | 
| 6081 | } | 
| 6082 | |
| 6083 | /* virtual */ | 
| 6084 | void nsIFrame::AddInlinePrefISize(const IntrinsicSizeInput& aInput, | 
| 6085 | nsIFrame::InlinePrefISizeData* aData) { | 
| 6086 | // Note: we are one of the children that mPercentageBasisForChildren was | 
| 6087 | // prepared for (i.e. our parent frame prepares the percentage basis for us, | 
| 6088 | // not for our own children). Hence it's fine that we're resolving our | 
| 6089 | // percentages sizes against this basis in IntrinsicForContainer(). | 
| 6090 | nscoord isize = nsLayoutUtils::IntrinsicForContainer( | 
| 6091 | aInput.mContext, this, IntrinsicISizeType::PrefISize, | 
| 6092 | aInput.mPercentageBasisForChildren); | 
| 6093 | aData->DefaultAddInlinePrefISize(isize); | 
| 6094 | } | 
| 6095 | |
| 6096 | void nsIFrame::InlineMinISizeData::DefaultAddInlineMinISize(nsIFrame* aFrame, | 
| 6097 | nscoord aISize, | 
| 6098 | bool aAllowBreak) { | 
| 6099 | auto parent = aFrame->GetParent(); | 
| 6100 | MOZ_ASSERT(parent, "Must have a parent if we get here!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(parent)>::isValid, "invalid assertion condition") ; if ((__builtin_expect(!!(!(!!(parent))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("parent" " (" "Must have a parent if we get here!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6100); AnnotateMozCrashReason("MOZ_ASSERT" "(" "parent" ") (" "Must have a parent if we get here!" ")"); do { *((volatile int *)__null) = 6100; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 6101 | const bool mayBreak = aAllowBreak && !aFrame->CanContinueTextRun() && | 
| 6102 | !parent->Style()->ShouldSuppressLineBreak() && | 
| 6103 | parent->StyleText()->WhiteSpaceCanWrap(parent); | 
| 6104 | if (mayBreak) { | 
| 6105 | OptionallyBreak(); | 
| 6106 | } | 
| 6107 | mTrailingWhitespace = 0; | 
| 6108 | mSkipWhitespace = false; | 
| 6109 | mCurrentLine += aISize; | 
| 6110 | mAtStartOfLine = false; | 
| 6111 | if (mayBreak) { | 
| 6112 | OptionallyBreak(); | 
| 6113 | } | 
| 6114 | } | 
| 6115 | |
| 6116 | void nsIFrame::InlinePrefISizeData::DefaultAddInlinePrefISize(nscoord aISize) { | 
| 6117 | mCurrentLine = NSCoordSaturatingAdd(mCurrentLine, aISize); | 
| 6118 | mTrailingWhitespace = 0; | 
| 6119 | mSkipWhitespace = false; | 
| 6120 | mLineIsEmpty = false; | 
| 6121 | } | 
| 6122 | |
| 6123 | void nsIFrame::InlineMinISizeData::ForceBreak() { | 
| 6124 | mCurrentLine -= mTrailingWhitespace; | 
| 6125 | mPrevLines = std::max(mPrevLines, mCurrentLine); | 
| 6126 | mCurrentLine = mTrailingWhitespace = 0; | 
| 6127 | |
| 6128 | for (const FloatInfo& floatInfo : mFloats) { | 
| 6129 | mPrevLines = std::max(floatInfo.ISize(), mPrevLines); | 
| 6130 | } | 
| 6131 | mFloats.Clear(); | 
| 6132 | mSkipWhitespace = true; | 
| 6133 | } | 
| 6134 | |
| 6135 | void nsIFrame::InlineMinISizeData::OptionallyBreak(nscoord aHyphenWidth) { | 
| 6136 | // If we can fit more content into a smaller width by staying on this | 
| 6137 | // line (because we're still at a negative offset due to negative | 
| 6138 | // text-indent or negative margin), don't break. Otherwise, do the | 
| 6139 | // same as ForceBreak. it doesn't really matter when we accumulate | 
| 6140 | // floats. | 
| 6141 | if (mCurrentLine + aHyphenWidth < 0 || mAtStartOfLine) { | 
| 6142 | return; | 
| 6143 | } | 
| 6144 | mCurrentLine += aHyphenWidth; | 
| 6145 | ForceBreak(); | 
| 6146 | } | 
| 6147 | |
| 6148 | void nsIFrame::InlinePrefISizeData::ForceBreak(UsedClear aClearType) { | 
| 6149 | // If this force break is not clearing any float, we can leave all the | 
| 6150 | // floats to the next force break. | 
| 6151 | if (!mFloats.IsEmpty() && aClearType != UsedClear::None) { | 
| 6152 | // Preferred isize accumulated for floats that have already | 
| 6153 | // been cleared past | 
| 6154 | nscoord floatsDone = 0; | 
| 6155 | // Preferred isize accumulated for floats that have not yet | 
| 6156 | // been cleared past | 
| 6157 | nscoord floatsCurLeft = 0, floatsCurRight = 0; | 
| 6158 | |
| 6159 | for (const FloatInfo& floatInfo : mFloats) { | 
| 6160 | const nsStyleDisplay* floatDisp = floatInfo.Frame()->StyleDisplay(); | 
| 6161 | auto cbWM = floatInfo.Frame()->GetParent()->GetWritingMode(); | 
| 6162 | UsedClear clearType = floatDisp->UsedClear(cbWM); | 
| 6163 | if (clearType == UsedClear::Left || clearType == UsedClear::Right || | 
| 6164 | clearType == UsedClear::Both) { | 
| 6165 | nscoord floatsCur = NSCoordSaturatingAdd(floatsCurLeft, floatsCurRight); | 
| 6166 | if (floatsCur > floatsDone) { | 
| 6167 | floatsDone = floatsCur; | 
| 6168 | } | 
| 6169 | if (clearType != UsedClear::Right) { | 
| 6170 | floatsCurLeft = 0; | 
| 6171 | } | 
| 6172 | if (clearType != UsedClear::Left) { | 
| 6173 | floatsCurRight = 0; | 
| 6174 | } | 
| 6175 | } | 
| 6176 | |
| 6177 | UsedFloat floatStyle = floatDisp->UsedFloat(cbWM); | 
| 6178 | nscoord& floatsCur = | 
| 6179 | floatStyle == UsedFloat::Left ? floatsCurLeft : floatsCurRight; | 
| 6180 | nscoord floatISize = floatInfo.ISize(); | 
| 6181 | // Negative-width floats don't change the available space so they | 
| 6182 | // shouldn't change our intrinsic line isize either. | 
| 6183 | floatsCur = NSCoordSaturatingAdd(floatsCur, std::max(0, floatISize)); | 
| 6184 | } | 
| 6185 | |
| 6186 | nscoord floatsCur = NSCoordSaturatingAdd(floatsCurLeft, floatsCurRight); | 
| 6187 | if (floatsCur > floatsDone) { | 
| 6188 | floatsDone = floatsCur; | 
| 6189 | } | 
| 6190 | |
| 6191 | mCurrentLine = NSCoordSaturatingAdd(mCurrentLine, floatsDone); | 
| 6192 | |
| 6193 | if (aClearType == UsedClear::Both) { | 
| 6194 | mFloats.Clear(); | 
| 6195 | } else { | 
| 6196 | // If the break type does not clear all floats, it means there may | 
| 6197 | // be some floats whose isize should contribute to the intrinsic | 
| 6198 | // isize of the next line. The code here scans the current mFloats | 
| 6199 | // and keeps floats which are not cleared by this break. Note that | 
| 6200 | // floats may be cleared directly or indirectly. See below. | 
| 6201 | nsTArray<FloatInfo> newFloats; | 
| 6202 | MOZ_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType< decltype(aClearType == UsedClear::Left || aClearType == UsedClear ::Right)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aClearType == UsedClear::Left || aClearType == UsedClear ::Right))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aClearType == UsedClear::Left || aClearType == UsedClear::Right" " (" "Other values should have been handled in other branches" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6204); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aClearType == UsedClear::Left || aClearType == UsedClear::Right" ") (" "Other values should have been handled in other branches" ")"); do { *((volatile int*)__null) = 6204; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6203 | aClearType == UsedClear::Left || aClearType == UsedClear::Right,do { static_assert( mozilla::detail::AssertionConditionType< decltype(aClearType == UsedClear::Left || aClearType == UsedClear ::Right)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aClearType == UsedClear::Left || aClearType == UsedClear ::Right))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aClearType == UsedClear::Left || aClearType == UsedClear::Right" " (" "Other values should have been handled in other branches" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6204); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aClearType == UsedClear::Left || aClearType == UsedClear::Right" ") (" "Other values should have been handled in other branches" ")"); do { *((volatile int*)__null) = 6204; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6204 | "Other values should have been handled in other branches")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aClearType == UsedClear::Left || aClearType == UsedClear ::Right)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aClearType == UsedClear::Left || aClearType == UsedClear ::Right))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aClearType == UsedClear::Left || aClearType == UsedClear::Right" " (" "Other values should have been handled in other branches" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6204); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aClearType == UsedClear::Left || aClearType == UsedClear::Right" ") (" "Other values should have been handled in other branches" ")"); do { *((volatile int*)__null) = 6204; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 6205 | UsedFloat clearFloatType = | 
| 6206 | aClearType == UsedClear::Left ? UsedFloat::Left : UsedFloat::Right; | 
| 6207 | // Iterate the array in reverse so that we can stop when there are | 
| 6208 | // no longer any floats we need to keep. See below. | 
| 6209 | for (FloatInfo& floatInfo : Reversed(mFloats)) { | 
| 6210 | const nsStyleDisplay* floatDisp = floatInfo.Frame()->StyleDisplay(); | 
| 6211 | auto cbWM = floatInfo.Frame()->GetParent()->GetWritingMode(); | 
| 6212 | if (floatDisp->UsedFloat(cbWM) != clearFloatType) { | 
| 6213 | newFloats.AppendElement(floatInfo); | 
| 6214 | } else { | 
| 6215 | // This is a float on the side that this break directly clears | 
| 6216 | // which means we're not keeping it in mFloats. However, if | 
| 6217 | // this float clears floats on the opposite side (via a value | 
| 6218 | // of either 'both' or one of 'left'/'right'), any remaining | 
| 6219 | // (earlier) floats on that side would be indirectly cleared | 
| 6220 | // as well. Thus, we should break out of this loop and stop | 
| 6221 | // considering earlier floats to be kept in mFloats. | 
| 6222 | UsedClear clearType = floatDisp->UsedClear(cbWM); | 
| 6223 | if (clearType != aClearType && clearType != UsedClear::None) { | 
| 6224 | break; | 
| 6225 | } | 
| 6226 | } | 
| 6227 | } | 
| 6228 | newFloats.Reverse(); | 
| 6229 | mFloats = std::move(newFloats); | 
| 6230 | } | 
| 6231 | } | 
| 6232 | |
| 6233 | mCurrentLine = | 
| 6234 | NSCoordSaturatingSubtract(mCurrentLine, mTrailingWhitespace, nscoord_MAX); | 
| 6235 | mPrevLines = std::max(mPrevLines, mCurrentLine); | 
| 6236 | mCurrentLine = mTrailingWhitespace = 0; | 
| 6237 | mSkipWhitespace = true; | 
| 6238 | mLineIsEmpty = true; | 
| 6239 | } | 
| 6240 | |
| 6241 | static nscoord ResolveMargin(const StyleMargin& aStyle, | 
| 6242 | nscoord aPercentageBasis) { | 
| 6243 | if (!aStyle.IsLengthPercentage()) { | 
| 6244 | return nscoord(0); | 
| 6245 | } | 
| 6246 | return nsLayoutUtils::ResolveToLength<false>(aStyle.AsLengthPercentage(), | 
| 6247 | aPercentageBasis); | 
| 6248 | } | 
| 6249 | |
| 6250 | static nscoord ResolvePadding(const LengthPercentage& aStyle, | 
| 6251 | nscoord aPercentageBasis) { | 
| 6252 | return nsLayoutUtils::ResolveToLength<true>(aStyle, aPercentageBasis); | 
| 6253 | } | 
| 6254 | |
| 6255 | static nsIFrame::IntrinsicSizeOffsetData IntrinsicSizeOffsets( | 
| 6256 | nsIFrame* aFrame, nscoord aPercentageBasis, bool aForISize) { | 
| 6257 | nsIFrame::IntrinsicSizeOffsetData result; | 
| 6258 | WritingMode wm = aFrame->GetWritingMode(); | 
| 6259 | bool verticalAxis = aForISize == wm.IsVertical(); | 
| 6260 | const auto* styleMargin = aFrame->StyleMargin(); | 
| 6261 | if (verticalAxis) { | 
| 6262 | result.margin += | 
| 6263 | ResolveMargin(styleMargin->GetMargin(eSideTop), aPercentageBasis); | 
| 6264 | result.margin += | 
| 6265 | ResolveMargin(styleMargin->GetMargin(eSideBottom), aPercentageBasis); | 
| 6266 | } else { | 
| 6267 | result.margin += | 
| 6268 | ResolveMargin(styleMargin->GetMargin(eSideLeft), aPercentageBasis); | 
| 6269 | result.margin += | 
| 6270 | ResolveMargin(styleMargin->GetMargin(eSideRight), aPercentageBasis); | 
| 6271 | } | 
| 6272 | |
| 6273 | const auto& padding = aFrame->StylePadding()->mPadding; | 
| 6274 | if (verticalAxis) { | 
| 6275 | result.padding += ResolvePadding(padding.Get(eSideTop), aPercentageBasis); | 
| 6276 | result.padding += | 
| 6277 | ResolvePadding(padding.Get(eSideBottom), aPercentageBasis); | 
| 6278 | } else { | 
| 6279 | result.padding += ResolvePadding(padding.Get(eSideLeft), aPercentageBasis); | 
| 6280 | result.padding += ResolvePadding(padding.Get(eSideRight), aPercentageBasis); | 
| 6281 | } | 
| 6282 | |
| 6283 | const nsStyleBorder* styleBorder = aFrame->StyleBorder(); | 
| 6284 | if (verticalAxis) { | 
| 6285 | result.border += styleBorder->GetComputedBorderWidth(eSideTop); | 
| 6286 | result.border += styleBorder->GetComputedBorderWidth(eSideBottom); | 
| 6287 | } else { | 
| 6288 | result.border += styleBorder->GetComputedBorderWidth(eSideLeft); | 
| 6289 | result.border += styleBorder->GetComputedBorderWidth(eSideRight); | 
| 6290 | } | 
| 6291 | |
| 6292 | const nsStyleDisplay* disp = aFrame->StyleDisplay(); | 
| 6293 | if (aFrame->IsThemed(disp)) { | 
| 6294 | nsPresContext* presContext = aFrame->PresContext(); | 
| 6295 | |
| 6296 | LayoutDeviceIntMargin border = presContext->Theme()->GetWidgetBorder( | 
| 6297 | presContext->DeviceContext(), aFrame, disp->EffectiveAppearance()); | 
| 6298 | result.border = presContext->DevPixelsToAppUnits( | 
| 6299 | verticalAxis ? border.TopBottom() : border.LeftRight()); | 
| 6300 | |
| 6301 | LayoutDeviceIntMargin padding; | 
| 6302 | if (presContext->Theme()->GetWidgetPadding( | 
| 6303 | presContext->DeviceContext(), aFrame, disp->EffectiveAppearance(), | 
| 6304 | &padding)) { | 
| 6305 | result.padding = presContext->DevPixelsToAppUnits( | 
| 6306 | verticalAxis ? padding.TopBottom() : padding.LeftRight()); | 
| 6307 | } | 
| 6308 | } | 
| 6309 | return result; | 
| 6310 | } | 
| 6311 | |
| 6312 | /* virtual */ nsIFrame::IntrinsicSizeOffsetData nsIFrame::IntrinsicISizeOffsets( | 
| 6313 | nscoord aPercentageBasis) { | 
| 6314 | return IntrinsicSizeOffsets(this, aPercentageBasis, true); | 
| 6315 | } | 
| 6316 | |
| 6317 | nsIFrame::IntrinsicSizeOffsetData nsIFrame::IntrinsicBSizeOffsets( | 
| 6318 | nscoord aPercentageBasis) { | 
| 6319 | return IntrinsicSizeOffsets(this, aPercentageBasis, false); | 
| 6320 | } | 
| 6321 | |
| 6322 | /* virtual */ | 
| 6323 | IntrinsicSize nsIFrame::GetIntrinsicSize() { | 
| 6324 | // Defaults to no intrinsic size. | 
| 6325 | return IntrinsicSize(); | 
| 6326 | } | 
| 6327 | |
| 6328 | AspectRatio nsIFrame::GetAspectRatio() const { | 
| 6329 | // Per spec, 'aspect-ratio' property applies to all elements except inline | 
| 6330 | // boxes and internal ruby or table boxes. | 
| 6331 | // https://drafts.csswg.org/css-sizing-4/#aspect-ratio | 
| 6332 | // For those frame types that don't support aspect-ratio, they must not have | 
| 6333 | // the natural ratio, so this early return is fine. | 
| 6334 | if (!SupportsAspectRatio()) { | 
| 6335 | return AspectRatio(); | 
| 6336 | } | 
| 6337 | |
| 6338 | const StyleAspectRatio& aspectRatio = StylePosition()->mAspectRatio; | 
| 6339 | // If aspect-ratio is zero or infinite, it's a degenerate ratio and behaves | 
| 6340 | // as auto. | 
| 6341 | // https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-ratio | 
| 6342 | if (!aspectRatio.BehavesAsAuto()) { | 
| 6343 | // Non-auto. Return the preferred aspect ratio from the aspect-ratio style. | 
| 6344 | return aspectRatio.ratio.AsRatio().ToLayoutRatio(UseBoxSizing::Yes); | 
| 6345 | } | 
| 6346 | |
| 6347 | // The rest of the cases are when aspect-ratio has 'auto'. | 
| 6348 | if (auto intrinsicRatio = GetIntrinsicRatio()) { | 
| 6349 | return intrinsicRatio; | 
| 6350 | } | 
| 6351 | |
| 6352 | if (aspectRatio.HasRatio()) { | 
| 6353 | // If it's a degenerate ratio, this returns 0. Just the same as the auto | 
| 6354 | // case. | 
| 6355 | return aspectRatio.ratio.AsRatio().ToLayoutRatio(UseBoxSizing::No); | 
| 6356 | } | 
| 6357 | |
| 6358 | return AspectRatio(); | 
| 6359 | } | 
| 6360 | |
| 6361 | /* virtual */ | 
| 6362 | AspectRatio nsIFrame::GetIntrinsicRatio() const { return AspectRatio(); } | 
| 6363 | |
| 6364 | static bool ShouldApplyAutomaticMinimumOnInlineAxis( | 
| 6365 | WritingMode aWM, const nsStyleDisplay* aDisplay, | 
| 6366 | const nsStylePosition* aPosition) { | 
| 6367 | // Apply the automatic minimum size for aspect ratio: | 
| 6368 | // Note: The replaced elements shouldn't be here, so we only check the scroll | 
| 6369 | // container. | 
| 6370 | // https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum | 
| 6371 | return !aDisplay->IsScrollableOverflow() && aPosition->MinISize(aWM).IsAuto(); | 
| 6372 | } | 
| 6373 | |
| 6374 | /* virtual */ | 
| 6375 | nsIFrame::SizeComputationResult nsIFrame::ComputeSize( | 
| 6376 | gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize, | 
| 6377 | nscoord aAvailableISize, const LogicalSize& aMargin, | 
| 6378 | const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides, | 
| 6379 | ComputeSizeFlags aFlags) { | 
| 6380 | MOZ_ASSERT(!GetIntrinsicRatio(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!GetIntrinsicRatio())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!GetIntrinsicRatio()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!GetIntrinsicRatio()" " (" "Please override this method and call " "nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6382); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!GetIntrinsicRatio()" ") (" "Please override this method and call " "nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead." ")"); do { *((volatile int*)__null) = 6382; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6381 | "Please override this method and call "do { static_assert( mozilla::detail::AssertionConditionType< decltype(!GetIntrinsicRatio())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!GetIntrinsicRatio()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!GetIntrinsicRatio()" " (" "Please override this method and call " "nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6382); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!GetIntrinsicRatio()" ") (" "Please override this method and call " "nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead." ")"); do { *((volatile int*)__null) = 6382; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6382 | "nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead.")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!GetIntrinsicRatio())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!GetIntrinsicRatio()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!GetIntrinsicRatio()" " (" "Please override this method and call " "nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6382); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!GetIntrinsicRatio()" ") (" "Please override this method and call " "nsContainerFrame::ComputeSizeWithIntrinsicDimensions instead." ")"); do { *((volatile int*)__null) = 6382; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 6383 | LogicalSize result = | 
| 6384 | ComputeAutoSize(aRenderingContext, aWM, aCBSize, aAvailableISize, aMargin, | 
| 6385 | aBorderPadding, aSizeOverrides, aFlags); | 
| 6386 | const nsStylePosition* stylePos = StylePosition(); | 
| 6387 | const nsStyleDisplay* disp = StyleDisplay(); | 
| 6388 | auto aspectRatioUsage = AspectRatioUsage::None; | 
| 6389 | |
| 6390 | const auto boxSizingAdjust = stylePos->mBoxSizing == StyleBoxSizing::Border | 
| 6391 | ? aBorderPadding | 
| 6392 | : LogicalSize(aWM); | 
| 6393 | nscoord boxSizingToMarginEdgeISize = aMargin.ISize(aWM) + | 
| 6394 | aBorderPadding.ISize(aWM) - | 
| 6395 | boxSizingAdjust.ISize(aWM); | 
| 6396 | |
| 6397 | const auto& aspectRatio = aSizeOverrides.mAspectRatio | 
| 6398 | ? *aSizeOverrides.mAspectRatio | 
| 6399 | : GetAspectRatio(); | 
| 6400 | const auto& styleISize = aSizeOverrides.mStyleISize | 
| 6401 | ? *aSizeOverrides.mStyleISize | 
| 6402 | : stylePos->ISize(aWM); | 
| 6403 | // For bsize, we consider overrides *and then* we resolve 'stretch' to a | 
| 6404 | // nscoord value, for convenience (so that we can assume that either | 
| 6405 | // isAutoBSize is true, or styleBSize is of type LengthPercentage()). | 
| 6406 | const auto& styleBSize = [&] { | 
| 6407 | const auto& styleBSizeConsideringOverrides = | 
| 6408 | (aSizeOverrides.mStyleBSize) ? *aSizeOverrides.mStyleBSize | 
| 6409 | : stylePos->BSize(aWM); | 
| 6410 | if (styleBSizeConsideringOverrides.BehavesLikeStretchOnBlockAxis() && | 
| 6411 | aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE) { | 
| 6412 | // We've got a 'stretch' BSize; resolve it to a length: | 
| 6413 | nscoord stretchBSize = nsLayoutUtils::ComputeStretchBSize( | 
| 6414 | aCBSize.BSize(aWM), aMargin.BSize(aWM), aBorderPadding.BSize(aWM), | 
| 6415 | stylePos->mBoxSizing); | 
| 6416 | return StyleSize::LengthPercentage( | 
| 6417 | LengthPercentage::FromAppUnits(stretchBSize)); | 
| 6418 | } | 
| 6419 | return styleBSizeConsideringOverrides; | 
| 6420 | }(); | 
| 6421 | |
| 6422 | auto parentFrame = GetParent(); | 
| 6423 | auto alignCB = parentFrame; | 
| 6424 | bool isGridItem = IsGridItem(); | 
| 6425 | const bool isSubgrid = IsSubgrid(); | 
| 6426 | if (parentFrame && parentFrame->IsTableWrapperFrame() && IsTableFrame()) { | 
| 6427 | // An inner table frame is sized as a grid item if its table wrapper is, | 
| 6428 | // because they actually have the same CB (the wrapper's CB). | 
| 6429 | // @see ReflowInput::InitCBReflowInput | 
| 6430 | auto tableWrapper = GetParent(); | 
| 6431 | auto grandParent = tableWrapper->GetParent(); | 
| 6432 | isGridItem = grandParent->IsGridContainerFrame() && | 
| 6433 | !tableWrapper->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW); | 
| 6434 | if (isGridItem) { | 
| 6435 | // When resolving justify/align-self below, we want to use the grid | 
| 6436 | // container's justify/align-items value and WritingMode. | 
| 6437 | alignCB = grandParent; | 
| 6438 | } | 
| 6439 | } | 
| 6440 | |
| 6441 | // flexItemMainAxis is set if this frame is a flex item in a modern flexbox | 
| 6442 | // layout. It indicates which logical axis (in this frame's own WM) | 
| 6443 | // corresponds to its flex container's main axis. | 
| 6444 | Maybe<LogicalAxis> flexItemMainAxis; | 
| 6445 | if (IsFlexItem() && !parentFrame->HasAnyStateBits( | 
| 6446 | NS_STATE_FLEX_IS_EMULATING_LEGACY_WEBKIT_BOX)) { | 
| 6447 | flexItemMainAxis = Some(nsFlexContainerFrame::IsItemInlineAxisMainAxis(this) | 
| 6448 | ? LogicalAxis::Inline | 
| 6449 | : LogicalAxis::Block); | 
| 6450 | } | 
| 6451 | |
| 6452 | const bool isOrthogonal = aWM.IsOrthogonalTo(alignCB->GetWritingMode()); | 
| 6453 | const bool isAutoISize = styleISize.IsAuto(); | 
| 6454 | const bool isAutoBSize = | 
| 6455 | nsLayoutUtils::IsAutoBSize(styleBSize, aCBSize.BSize(aWM)); | 
| 6456 | |
| 6457 | MOZ_ASSERT(isAutoBSize || styleBSize.IsLengthPercentage(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(isAutoBSize || styleBSize.IsLengthPercentage())>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(isAutoBSize || styleBSize.IsLengthPercentage()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("isAutoBSize || styleBSize.IsLengthPercentage()" " (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6460); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isAutoBSize || styleBSize.IsLengthPercentage()" ") (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" ); do { *((volatile int*)__null) = 6460; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6458 | "We should have resolved away any non-'auto'-like flavors "do { static_assert( mozilla::detail::AssertionConditionType< decltype(isAutoBSize || styleBSize.IsLengthPercentage())>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(isAutoBSize || styleBSize.IsLengthPercentage()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("isAutoBSize || styleBSize.IsLengthPercentage()" " (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6460); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isAutoBSize || styleBSize.IsLengthPercentage()" ") (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" ); do { *((volatile int*)__null) = 6460; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6459 | "of styleBSize into a LengthPercentage. (If this fails, we "do { static_assert( mozilla::detail::AssertionConditionType< decltype(isAutoBSize || styleBSize.IsLengthPercentage())>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(isAutoBSize || styleBSize.IsLengthPercentage()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("isAutoBSize || styleBSize.IsLengthPercentage()" " (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6460); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isAutoBSize || styleBSize.IsLengthPercentage()" ") (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" ); do { *((volatile int*)__null) = 6460; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6460 | "might run afoul of some AsLengthPercentage() call below.)")do { static_assert( mozilla::detail::AssertionConditionType< decltype(isAutoBSize || styleBSize.IsLengthPercentage())>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(isAutoBSize || styleBSize.IsLengthPercentage()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("isAutoBSize || styleBSize.IsLengthPercentage()" " (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6460); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isAutoBSize || styleBSize.IsLengthPercentage()" ") (" "We should have resolved away any non-'auto'-like flavors " "of styleBSize into a LengthPercentage. (If this fails, we " "might run afoul of some AsLengthPercentage() call below.)" ")" ); do { *((volatile int*)__null) = 6460; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 6461 | |
| 6462 | // Compute inline-axis size | 
| 6463 | const bool isSubgriddedInInlineAxis = | 
| 6464 | isSubgrid && static_cast<nsGridContainerFrame*>(this)->IsColSubgrid(); | 
| 6465 | |
| 6466 | // Per https://drafts.csswg.org/css-grid/#subgrid-box-alignment, if we are | 
| 6467 | // subgridded in the inline-axis, ignore our style inline-size, and stretch to | 
| 6468 | // fill the CB. | 
| 6469 | const bool shouldComputeISize = !isAutoISize && !isSubgriddedInInlineAxis; | 
| 6470 | if (shouldComputeISize) { | 
| 6471 | auto iSizeResult = | 
| 6472 | ComputeISizeValue(aRenderingContext, aWM, aCBSize, boxSizingAdjust, | 
| 6473 | boxSizingToMarginEdgeISize, styleISize, styleBSize, | 
| 6474 | aspectRatio, aFlags); | 
| 6475 | result.ISize(aWM) = iSizeResult.mISize; | 
| 6476 | aspectRatioUsage = iSizeResult.mAspectRatioUsage; | 
| 6477 | } else if (MOZ_UNLIKELY(isGridItem)(__builtin_expect(!!(isGridItem), 0)) && !IsTrueOverflowContainer()) { | 
| 6478 | // 'auto' inline-size for grid-level box - fill the CB for 'stretch' / | 
| 6479 | // 'normal' and clamp it to the CB if requested: | 
| 6480 | bool isStretchAligned = false; | 
| 6481 | bool mayUseAspectRatio = aspectRatio && !isAutoBSize; | 
| 6482 | if (!aFlags.contains(ComputeSizeFlag::ShrinkWrap) && | 
| 6483 | !StyleMargin()->HasInlineAxisAuto(aWM) && | 
| 6484 | !alignCB->IsMasonry(isOrthogonal ? LogicalAxis::Block | 
| 6485 | : LogicalAxis::Inline)) { | 
| 6486 | auto inlineAxisAlignment = | 
| 6487 | isOrthogonal ? StylePosition()->UsedAlignSelf(alignCB->Style())._0 | 
| 6488 | : StylePosition()->UsedJustifySelf(alignCB->Style())._0; | 
| 6489 | isStretchAligned = inlineAxisAlignment == StyleAlignFlags::STRETCH || | 
| 6490 | (inlineAxisAlignment == StyleAlignFlags::NORMAL && | 
| 6491 | !mayUseAspectRatio); | 
| 6492 | } | 
| 6493 | |
| 6494 | // Apply the preferred aspect ratio for alignments other than *stretch* and | 
| 6495 | // *normal without aspect ratio*. | 
| 6496 | // The spec says all other values should size the items as fit-content, and | 
| 6497 | // the intrinsic size should respect the preferred aspect ratio, so we also | 
| 6498 | // apply aspect ratio for all other values. | 
| 6499 | // https://drafts.csswg.org/css-grid/#grid-item-sizing | 
| 6500 | if (!isStretchAligned && mayUseAspectRatio) { | 
| 6501 | result.ISize(aWM) = ComputeISizeValueFromAspectRatio( | 
| 6502 | aWM, aCBSize, boxSizingAdjust, styleBSize.AsLengthPercentage(), | 
| 6503 | aspectRatio); | 
| 6504 | aspectRatioUsage = AspectRatioUsage::ToComputeISize; | 
| 6505 | } | 
| 6506 | |
| 6507 | if (isStretchAligned || | 
| 6508 | aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize)) { | 
| 6509 | auto iSizeToFillCB = | 
| 6510 | std::max(nscoord(0), aCBSize.ISize(aWM) - aBorderPadding.ISize(aWM) - | 
| 6511 | aMargin.ISize(aWM)); | 
| 6512 | if (isStretchAligned || result.ISize(aWM) > iSizeToFillCB) { | 
| 6513 | result.ISize(aWM) = iSizeToFillCB; | 
| 6514 | } | 
| 6515 | } | 
| 6516 | } else if (aspectRatio && !isAutoBSize) { | 
| 6517 | // Note: if both the inline size and the block size are auto, the block axis | 
| 6518 | // is the ratio-dependent axis by default. That means we only need to | 
| 6519 | // transfer the resolved inline size via aspect-ratio to block axis later in | 
| 6520 | // this method, but not the other way around. | 
| 6521 | // | 
| 6522 | // In this branch, we transfer the non-auto block size via aspect-ration to | 
| 6523 | // inline axis. | 
| 6524 | result.ISize(aWM) = ComputeISizeValueFromAspectRatio( | 
| 6525 | aWM, aCBSize, boxSizingAdjust, styleBSize.AsLengthPercentage(), | 
| 6526 | aspectRatio); | 
| 6527 | aspectRatioUsage = AspectRatioUsage::ToComputeISize; | 
| 6528 | } | 
| 6529 | |
| 6530 | // Calculate and apply transferred min & max size contraints. | 
| 6531 | // https://drafts.csswg.org/css-sizing-4/#aspect-ratio-size-transfers | 
| 6532 | // | 
| 6533 | // Note: The basic principle is that sizing constraints transfer through the | 
| 6534 | // aspect-ratio to the other side to preserve the aspect ratio to the extent | 
| 6535 | // that they can without violating any sizes specified explicitly on that | 
| 6536 | // affected axis. | 
| 6537 | // | 
| 6538 | // FIXME: The spec words may not be correct, so we may have to update this | 
| 6539 | // tentative solution once this spec issue gets resolved. Here, we clamp the | 
| 6540 | // flex base size by the transferred min and max sizes, and don't include | 
| 6541 | // the transferred min & max sizes into its used min & max sizes. So this | 
| 6542 | // lets us match other browsers' current behaviors. | 
| 6543 | // https://github.com/w3c/csswg-drafts/issues/6071 | 
| 6544 | // | 
| 6545 | // Note: This may make more sense if we clamp the flex base size in | 
| 6546 | // FlexItem::ResolveFlexBaseSizeFromAspectRatio(). However, the result should | 
| 6547 | // be identical. FlexItem::ResolveFlexBaseSizeFromAspectRatio() only handles | 
| 6548 | // the case of the definite cross size, and the definite cross size is clamped | 
| 6549 | // by the min & max cross sizes below in this function. This means its flex | 
| 6550 | // base size has been clamped by the transferred min & max size already after | 
| 6551 | // generating the flex items. So here we make the code more general for both | 
| 6552 | // definite cross size and indefinite cross size. | 
| 6553 | const bool isDefiniteISize = styleISize.IsLengthPercentage(); | 
| 6554 | const auto& minBSizeCoord = stylePos->MinBSize(aWM); | 
| 6555 | const auto& maxBSizeCoord = stylePos->MaxBSize(aWM); | 
| 6556 | const bool isAutoMinBSize = | 
| 6557 | nsLayoutUtils::IsAutoBSize(minBSizeCoord, aCBSize.BSize(aWM)); | 
| 6558 | const bool isAutoMaxBSize = | 
| 6559 | nsLayoutUtils::IsAutoBSize(maxBSizeCoord, aCBSize.BSize(aWM)); | 
| 6560 | if (aspectRatio && !isDefiniteISize) { | 
| 6561 | // Note: the spec mentions that | 
| 6562 | // 1. This transferred minimum is capped by any definite preferred or | 
| 6563 | // maximum size in the destination axis. | 
| 6564 | // 2. This transferred maximum is floored by any definite preferred or | 
| 6565 | // minimum size in the destination axis. | 
| 6566 | // | 
| 6567 | // https://drafts.csswg.org/css-sizing-4/#aspect-ratio-size-transfers | 
| 6568 | // | 
| 6569 | // The spec requires us to clamp these by the specified size (it calls it | 
| 6570 | // the preferred size). However, we actually don't need to worry about that, | 
| 6571 | // because we are here only if the inline size is indefinite. | 
| 6572 | // | 
| 6573 | // We do not need to clamp the transferred minimum and maximum as long as we | 
| 6574 | // always apply the transferred min/max size before the explicit min/max | 
| 6575 | // size; the result will be identical. | 
| 6576 | const nscoord transferredMinISize = | 
| 6577 | isAutoMinBSize ? 0 | 
| 6578 | : ComputeISizeValueFromAspectRatio( | 
| 6579 | aWM, aCBSize, boxSizingAdjust, | 
| 6580 | minBSizeCoord.AsLengthPercentage(), aspectRatio); | 
| 6581 | const nscoord transferredMaxISize = | 
| 6582 | isAutoMaxBSize ? nscoord_MAX | 
| 6583 | : ComputeISizeValueFromAspectRatio( | 
| 6584 | aWM, aCBSize, boxSizingAdjust, | 
| 6585 | maxBSizeCoord.AsLengthPercentage(), aspectRatio); | 
| 6586 | |
| 6587 | result.ISize(aWM) = | 
| 6588 | CSSMinMax(result.ISize(aWM), transferredMinISize, transferredMaxISize); | 
| 6589 | } | 
| 6590 | |
| 6591 | // Flex items ignore their min & max sizing properties in their flex | 
| 6592 | // container's main-axis. (Those properties get applied later in the flexbox | 
| 6593 | // algorithm.) | 
| 6594 | const bool isFlexItemInlineAxisMainAxis = | 
| 6595 | flexItemMainAxis && *flexItemMainAxis == LogicalAxis::Inline; | 
| 6596 | // Grid items that are subgridded in inline-axis also ignore their min & max | 
| 6597 | // sizing properties in that axis. | 
| 6598 | const bool shouldIgnoreMinMaxISize = | 
| 6599 | isFlexItemInlineAxisMainAxis || isSubgriddedInInlineAxis; | 
| 6600 | const auto& maxISizeCoord = stylePos->MaxISize(aWM); | 
| 6601 | nscoord maxISize = NS_UNCONSTRAINEDSIZE; | 
| 6602 | if (!maxISizeCoord.IsNone() && !shouldIgnoreMinMaxISize) { | 
| 6603 | maxISize = ComputeISizeValue(aRenderingContext, aWM, aCBSize, | 
| 6604 | boxSizingAdjust, boxSizingToMarginEdgeISize, | 
| 6605 | maxISizeCoord, styleBSize, aspectRatio, aFlags) | 
| 6606 | .mISize; | 
| 6607 | result.ISize(aWM) = std::min(maxISize, result.ISize(aWM)); | 
| 6608 | } | 
| 6609 | |
| 6610 | const nscoord bSizeAsPercentageBasis = ComputeBSizeValueAsPercentageBasis( | 
| 6611 | styleBSize, minBSizeCoord, maxBSizeCoord, aCBSize.BSize(aWM), | 
| 6612 | boxSizingAdjust.BSize(aWM)); | 
| 6613 | const IntrinsicSizeInput input( | 
| 6614 | aRenderingContext, Some(aCBSize.ConvertTo(GetWritingMode(), aWM)), | 
| 6615 | Some(LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, bSizeAsPercentageBasis) | 
| 6616 | .ConvertTo(GetWritingMode(), aWM))); | 
| 6617 | const auto& minISizeCoord = stylePos->MinISize(aWM); | 
| 6618 | nscoord minISize; | 
| 6619 | if (!minISizeCoord.IsAuto() && !shouldIgnoreMinMaxISize) { | 
| 6620 | minISize = ComputeISizeValue(aRenderingContext, aWM, aCBSize, | 
| 6621 | boxSizingAdjust, boxSizingToMarginEdgeISize, | 
| 6622 | minISizeCoord, styleBSize, aspectRatio, aFlags) | 
| 6623 | .mISize; | 
| 6624 | } else if (MOZ_UNLIKELY((__builtin_expect(!!(aFlags.contains(ComputeSizeFlag::IApplyAutoMinSize )), 0)) | 
| 6625 | aFlags.contains(ComputeSizeFlag::IApplyAutoMinSize))(__builtin_expect(!!(aFlags.contains(ComputeSizeFlag::IApplyAutoMinSize )), 0))) { | 
| 6626 | // This implements "Implied Minimum Size of Grid Items". | 
| 6627 | // https://drafts.csswg.org/css-grid/#min-size-auto | 
| 6628 | minISize = std::min(maxISize, GetMinISize(input)); | 
| 6629 | if (styleISize.IsLengthPercentage()) { | 
| 6630 | minISize = std::min(minISize, result.ISize(aWM)); | 
| 6631 | } else if (aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize)) { | 
| 6632 | // "if the grid item spans only grid tracks that have a fixed max track | 
| 6633 | // sizing function, its automatic minimum size in that dimension is | 
| 6634 | // further clamped to less than or equal to the size necessary to fit | 
| 6635 | // its margin box within the resulting grid area (flooring at zero)" | 
| 6636 | // https://drafts.csswg.org/css-grid/#min-size-auto | 
| 6637 | auto maxMinISize = | 
| 6638 | std::max(nscoord(0), aCBSize.ISize(aWM) - aBorderPadding.ISize(aWM) - | 
| 6639 | aMargin.ISize(aWM)); | 
| 6640 | minISize = std::min(minISize, maxMinISize); | 
| 6641 | } | 
| 6642 | } else if (aspectRatioUsage == AspectRatioUsage::ToComputeISize && | 
| 6643 | ShouldApplyAutomaticMinimumOnInlineAxis(aWM, disp, stylePos)) { | 
| 6644 | // This means we successfully applied aspect-ratio and now need to check | 
| 6645 | // if we need to apply the automatic content-based minimum size: | 
| 6646 | // https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum | 
| 6647 | MOZ_ASSERT(!HasReplacedSizing(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasReplacedSizing())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!HasReplacedSizing()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!HasReplacedSizing()" " (" "aspect-ratio minimums should not apply to replaced elements" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6648); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasReplacedSizing()" ") (" "aspect-ratio minimums should not apply to replaced elements" ")"); do { *((volatile int*)__null) = 6648; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6648 | "aspect-ratio minimums should not apply to replaced elements")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasReplacedSizing())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!HasReplacedSizing()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("!HasReplacedSizing()" " (" "aspect-ratio minimums should not apply to replaced elements" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6648); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasReplacedSizing()" ") (" "aspect-ratio minimums should not apply to replaced elements" ")"); do { *((volatile int*)__null) = 6648; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 6649 | // The inline size computed by aspect-ratio shouldn't less than the | 
| 6650 | // min-content size, which should be capped by its maximum inline size. | 
| 6651 | minISize = std::min(GetMinISize(input), maxISize); | 
| 6652 | } else { | 
| 6653 | // Treat "min-width: auto" as 0. | 
| 6654 | // NOTE: Technically, "auto" is supposed to behave like "min-content" on | 
| 6655 | // flex items. However, we don't need to worry about that here, because | 
| 6656 | // flex items' min-sizes are intentionally ignored until the flex | 
| 6657 | // container explicitly considers them during space distribution. | 
| 6658 | minISize = 0; | 
| 6659 | } | 
| 6660 | result.ISize(aWM) = std::max(minISize, result.ISize(aWM)); | 
| 6661 | |
| 6662 | // Compute block-axis size | 
| 6663 | // (but not if we have auto bsize -- then, we'll just stick with the bsize | 
| 6664 | // that we already calculated in the initial ComputeAutoSize() call. However, | 
| 6665 | // if we have a valid preferred aspect ratio, we still have to compute the | 
| 6666 | // block size because aspect ratio affects the intrinsic content size.) | 
| 6667 | const bool isSubgriddedInBlockAxis = | 
| 6668 | isSubgrid && static_cast<nsGridContainerFrame*>(this)->IsRowSubgrid(); | 
| 6669 | |
| 6670 | // Per https://drafts.csswg.org/css-grid/#subgrid-box-alignment, if we are | 
| 6671 | // subgridded in the block-axis, ignore our style block-size, and stretch to | 
| 6672 | // fill the CB. | 
| 6673 | const bool shouldComputeBSize = !isAutoBSize && !isSubgriddedInBlockAxis; | 
| 6674 | if (shouldComputeBSize) { | 
| 6675 | result.BSize(aWM) = nsLayoutUtils::ComputeBSizeValue( | 
| 6676 | aCBSize.BSize(aWM), boxSizingAdjust.BSize(aWM), | 
| 6677 | styleBSize.AsLengthPercentage()); | 
| 6678 | } else if (MOZ_UNLIKELY(isGridItem)(__builtin_expect(!!(isGridItem), 0)) && styleBSize.IsAuto() && | 
| 6679 | !aFlags.contains(ComputeSizeFlag::IsGridMeasuringReflow) && | 
| 6680 | !IsTrueOverflowContainer() && | 
| 6681 | !alignCB->IsMasonry(isOrthogonal ? LogicalAxis::Inline | 
| 6682 | : LogicalAxis::Block)) { | 
| 6683 | auto cbSize = aCBSize.BSize(aWM); | 
| 6684 | if (cbSize != NS_UNCONSTRAINEDSIZE) { | 
| 6685 | // 'auto' block-size for grid-level box - fill the CB for 'stretch' / | 
| 6686 | // 'normal' and clamp it to the CB if requested: | 
| 6687 | bool isStretchAligned = false; | 
| 6688 | bool mayUseAspectRatio = | 
| 6689 | aspectRatio && result.ISize(aWM) != NS_UNCONSTRAINEDSIZE; | 
| 6690 | if (!StyleMargin()->HasBlockAxisAuto(aWM)) { | 
| 6691 | auto blockAxisAlignment = | 
| 6692 | isOrthogonal ? StylePosition()->UsedJustifySelf(alignCB->Style())._0 | 
| 6693 | : StylePosition()->UsedAlignSelf(alignCB->Style())._0; | 
| 6694 | isStretchAligned = blockAxisAlignment == StyleAlignFlags::STRETCH || | 
| 6695 | (blockAxisAlignment == StyleAlignFlags::NORMAL && | 
| 6696 | !mayUseAspectRatio); | 
| 6697 | } | 
| 6698 | |
| 6699 | // Apply the preferred aspect ratio for alignments other than *stretch* | 
| 6700 | // and *normal without aspect ratio*. | 
| 6701 | // The spec says all other values should size the items as fit-content, | 
| 6702 | // and the intrinsic size should respect the preferred aspect ratio, so | 
| 6703 | // we also apply aspect ratio for all other values. | 
| 6704 | // https://drafts.csswg.org/css-grid/#grid-item-sizing | 
| 6705 | if (!isStretchAligned && mayUseAspectRatio) { | 
| 6706 | result.BSize(aWM) = aspectRatio.ComputeRatioDependentSize( | 
| 6707 | LogicalAxis::Block, aWM, result.ISize(aWM), boxSizingAdjust); | 
| 6708 | MOZ_ASSERT(aspectRatioUsage == AspectRatioUsage::None)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aspectRatioUsage == AspectRatioUsage::None)>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(aspectRatioUsage == AspectRatioUsage::None))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aspectRatioUsage == AspectRatioUsage::None" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6708); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aspectRatioUsage == AspectRatioUsage::None" ")"); do { *((volatile int*)__null) = 6708; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 6709 | aspectRatioUsage = AspectRatioUsage::ToComputeBSize; | 
| 6710 | } | 
| 6711 | |
| 6712 | if (isStretchAligned || | 
| 6713 | aFlags.contains(ComputeSizeFlag::BClampMarginBoxMinSize)) { | 
| 6714 | auto bSizeToFillCB = nsLayoutUtils::ComputeStretchContentBoxBSize( | 
| 6715 | cbSize, aMargin.BSize(aWM), aBorderPadding.BSize(aWM)); | 
| 6716 | if (isStretchAligned || (result.BSize(aWM) != NS_UNCONSTRAINEDSIZE && | 
| 6717 | result.BSize(aWM) > bSizeToFillCB)) { | 
| 6718 | result.BSize(aWM) = bSizeToFillCB; | 
| 6719 | } | 
| 6720 | } | 
| 6721 | } | 
| 6722 | } else if (aspectRatio) { | 
| 6723 | // If both inline and block dimensions are auto, the block axis is the | 
| 6724 | // ratio-dependent axis by default. | 
| 6725 | // If we have a super large inline size, aspect-ratio should still be | 
| 6726 | // applied (so aspectRatioUsage flag is set as expected). That's why we | 
| 6727 | // apply aspect-ratio unconditionally for auto block size here. | 
| 6728 | result.BSize(aWM) = aspectRatio.ComputeRatioDependentSize( | 
| 6729 | LogicalAxis::Block, aWM, result.ISize(aWM), boxSizingAdjust); | 
| 6730 | MOZ_ASSERT(aspectRatioUsage == AspectRatioUsage::None)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aspectRatioUsage == AspectRatioUsage::None)>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(aspectRatioUsage == AspectRatioUsage::None))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aspectRatioUsage == AspectRatioUsage::None" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6730); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aspectRatioUsage == AspectRatioUsage::None" ")"); do { *((volatile int*)__null) = 6730; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 6731 | aspectRatioUsage = AspectRatioUsage::ToComputeBSize; | 
| 6732 | } | 
| 6733 | |
| 6734 | if (result.BSize(aWM) != NS_UNCONSTRAINEDSIZE) { | 
| 6735 | // Flex items ignore their min & max sizing properties in their flex | 
| 6736 | // container's main-axis. (Those properties get applied later in the flexbox | 
| 6737 | // algorithm.) | 
| 6738 | const bool isFlexItemBlockAxisMainAxis = | 
| 6739 | flexItemMainAxis && *flexItemMainAxis == LogicalAxis::Block; | 
| 6740 | // Grid items that are subgridded in block-axis also ignore their min & max | 
| 6741 | // sizing properties in that axis. | 
| 6742 | const bool shouldIgnoreMinMaxBSize = | 
| 6743 | isFlexItemBlockAxisMainAxis || isSubgriddedInBlockAxis; | 
| 6744 | if (!isAutoMaxBSize && !shouldIgnoreMinMaxBSize) { | 
| 6745 | nscoord maxBSize = nsLayoutUtils::ComputeBSizeValueHandlingStretch( | 
| 6746 | aCBSize.BSize(aWM), aMargin.BSize(aWM), aBorderPadding.BSize(aWM), | 
| 6747 | boxSizingAdjust.BSize(aWM), maxBSizeCoord); | 
| 6748 | result.BSize(aWM) = std::min(maxBSize, result.BSize(aWM)); | 
| 6749 | } | 
| 6750 | |
| 6751 | if (!isAutoMinBSize && !shouldIgnoreMinMaxBSize) { | 
| 6752 | nscoord minBSize = nsLayoutUtils::ComputeBSizeValueHandlingStretch( | 
| 6753 | aCBSize.BSize(aWM), aMargin.BSize(aWM), aBorderPadding.BSize(aWM), | 
| 6754 | boxSizingAdjust.BSize(aWM), minBSizeCoord); | 
| 6755 | result.BSize(aWM) = std::max(minBSize, result.BSize(aWM)); | 
| 6756 | } | 
| 6757 | } | 
| 6758 | |
| 6759 | if (IsThemed(disp)) { | 
| 6760 | nsPresContext* pc = PresContext(); | 
| 6761 | const LayoutDeviceIntSize widget = pc->Theme()->GetMinimumWidgetSize( | 
| 6762 | pc, this, disp->EffectiveAppearance()); | 
| 6763 | |
| 6764 | // Convert themed widget's physical dimensions to logical coords | 
| 6765 | LogicalSize size(aWM, LayoutDeviceIntSize::ToAppUnits( | 
| 6766 | widget, pc->AppUnitsPerDevPixel())); | 
| 6767 | |
| 6768 | // GetMinimumWidgetSize() returns border-box; we need content-box. | 
| 6769 | size -= aBorderPadding; | 
| 6770 | |
| 6771 | if (size.BSize(aWM) > result.BSize(aWM)) { | 
| 6772 | result.BSize(aWM) = size.BSize(aWM); | 
| 6773 | } | 
| 6774 | if (size.ISize(aWM) > result.ISize(aWM)) { | 
| 6775 | result.ISize(aWM) = size.ISize(aWM); | 
| 6776 | } | 
| 6777 | } | 
| 6778 | |
| 6779 | result.ISize(aWM) = std::max(0, result.ISize(aWM)); | 
| 6780 | result.BSize(aWM) = std::max(0, result.BSize(aWM)); | 
| 6781 | |
| 6782 | return {result, aspectRatioUsage}; | 
| 6783 | } | 
| 6784 | |
| 6785 | nscoord nsIFrame::ComputeBSizeValueAsPercentageBasis( | 
| 6786 | const StyleSize& aStyleBSize, const StyleSize& aStyleMinBSize, | 
| 6787 | const StyleMaxSize& aStyleMaxBSize, nscoord aCBBSize, | 
| 6788 | nscoord aContentEdgeToBoxSizingBSize) { | 
| 6789 | if (nsLayoutUtils::IsAutoBSize(aStyleBSize, aCBBSize)) { | 
| 6790 | return NS_UNCONSTRAINEDSIZE; | 
| 6791 | } | 
| 6792 | |
| 6793 | // TODO(dholbert): This is a temporary hack, to be fixed up in bug 1933604. | 
| 6794 | // We don't know have aMargin or aBorderPadding args available, | 
| 6795 | // so we use these dummy zero-valued variables as placeholders in | 
| 6796 | // our call to ComputeBSizeValueHandlingStretch. (This might mean we | 
| 6797 | // end up resolving 'stretch' to something slighlty-too-large for the | 
| 6798 | // purposes of this call, if there's actually nonzero margin/border/padding). | 
| 6799 | const nscoord dummyMargin = 0; | 
| 6800 | const nscoord dummyBorderPadding = 0; | 
| 6801 | |
| 6802 | const nscoord bSize = nsLayoutUtils::ComputeBSizeValueHandlingStretch( | 
| 6803 | aCBBSize, dummyMargin, dummyBorderPadding, aContentEdgeToBoxSizingBSize, | 
| 6804 | aStyleBSize); | 
| 6805 | |
| 6806 | const nscoord minBSize = | 
| 6807 | nsLayoutUtils::IsAutoBSize(aStyleMinBSize, aCBBSize) | 
| 6808 | ? 0 | 
| 6809 | : nsLayoutUtils::ComputeBSizeValueHandlingStretch( | 
| 6810 | aCBBSize, dummyMargin, dummyBorderPadding, | 
| 6811 | aContentEdgeToBoxSizingBSize, aStyleMinBSize); | 
| 6812 | |
| 6813 | const nscoord maxBSize = | 
| 6814 | nsLayoutUtils::IsAutoBSize(aStyleMaxBSize, aCBBSize) | 
| 6815 | ? NS_UNCONSTRAINEDSIZE | 
| 6816 | : nsLayoutUtils::ComputeBSizeValueHandlingStretch( | 
| 6817 | aCBBSize, dummyMargin, dummyBorderPadding, | 
| 6818 | aContentEdgeToBoxSizingBSize, aStyleMaxBSize); | 
| 6819 | |
| 6820 | return CSSMinMax(bSize, minBSize, maxBSize); | 
| 6821 | } | 
| 6822 | |
| 6823 | nsRect nsIFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const { | 
| 6824 | return InkOverflowRect(); | 
| 6825 | } | 
| 6826 | |
| 6827 | /* virtual */ | 
| 6828 | nsresult nsIFrame::GetPrefWidthTightBounds(gfxContext* aContext, nscoord* aX, | 
| 6829 | nscoord* aXMost) { | 
| 6830 | return NS_ERROR_NOT_IMPLEMENTED; | 
| 6831 | } | 
| 6832 | |
| 6833 | /* virtual */ | 
| 6834 | LogicalSize nsIFrame::ComputeAutoSize( | 
| 6835 | gfxContext* aRenderingContext, WritingMode aWM, | 
| 6836 | const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize, | 
| 6837 | const mozilla::LogicalSize& aMargin, | 
| 6838 | const mozilla::LogicalSize& aBorderPadding, | 
| 6839 | const StyleSizeOverrides& aSizeOverrides, ComputeSizeFlags aFlags) { | 
| 6840 | if (IsAbsolutelyPositionedWithDefiniteContainingBlock()) { | 
| 6841 | return ComputeAbsolutePosAutoSize(aRenderingContext, aWM, aCBSize, | 
| 6842 | aAvailableISize, aMargin, aBorderPadding, | 
| 6843 | aSizeOverrides, aFlags); | 
| 6844 | } | 
| 6845 | |
| 6846 | // Use basic shrink-wrapping as a default implementation. | 
| 6847 | LogicalSize result(aWM, 0xdeadbeef, NS_UNCONSTRAINEDSIZE); | 
| 6848 | |
| 6849 | // don't bother setting it if the result won't be used | 
| 6850 | const auto& styleISize = aSizeOverrides.mStyleISize | 
| 6851 | ? *aSizeOverrides.mStyleISize | 
| 6852 | : StylePosition()->ISize(aWM); | 
| 6853 | if (styleISize.IsAuto()) { | 
| 6854 | nscoord availBased = nsLayoutUtils::ComputeStretchContentBoxISize( | 
| 6855 | aAvailableISize, aMargin.ISize(aWM), aBorderPadding.ISize(aWM)); | 
| 6856 | const auto* stylePos = StylePosition(); | 
| 6857 | const auto& styleBSize = aSizeOverrides.mStyleBSize | 
| 6858 | ? *aSizeOverrides.mStyleBSize | 
| 6859 | : stylePos->BSize(aWM); | 
| 6860 | const LogicalSize contentEdgeToBoxSizing = | 
| 6861 | stylePos->mBoxSizing == StyleBoxSizing::Border ? aBorderPadding | 
| 6862 | : LogicalSize(aWM); | 
| 6863 | const nscoord bSize = ComputeBSizeValueAsPercentageBasis( | 
| 6864 | styleBSize, stylePos->MinBSize(aWM), stylePos->MaxBSize(aWM), | 
| 6865 | aCBSize.BSize(aWM), contentEdgeToBoxSizing.BSize(aWM)); | 
| 6866 | const IntrinsicSizeInput input( | 
| 6867 | aRenderingContext, Some(aCBSize.ConvertTo(GetWritingMode(), aWM)), | 
| 6868 | Some(LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, bSize) | 
| 6869 | .ConvertTo(GetWritingMode(), aWM))); | 
| 6870 | result.ISize(aWM) = ShrinkISizeToFit(input, availBased, aFlags); | 
| 6871 | } | 
| 6872 | return result; | 
| 6873 | } | 
| 6874 | |
| 6875 | bool nsIFrame::IsAbsolutelyPositionedWithDefiniteContainingBlock() const { | 
| 6876 | // TODO(dshin, Bug 1927861): Even if an absolute container should have a | 
| 6877 | // definite size, in a continuation context, the full extent of the containing | 
| 6878 | // block is not known. | 
| 6879 | return MOZ_UNLIKELY(IsAbsolutelyPositioned())(__builtin_expect(!!(IsAbsolutelyPositioned()), 0)) && !GetPrevInFlow(); | 
| 6880 | } | 
| 6881 | |
| 6882 | LogicalSize nsIFrame::ComputeAbsolutePosAutoSize( | 
| 6883 | gfxContext* aRenderingContext, WritingMode aWM, | 
| 6884 | const mozilla::LogicalSize& aCBSize, nscoord aAvailableISize, | 
| 6885 | const mozilla::LogicalSize& aMargin, | 
| 6886 | const mozilla::LogicalSize& aBorderPadding, | 
| 6887 | const StyleSizeOverrides& aSizeOverrides, const ComputeSizeFlags& aFlags) { | 
| 6888 | MOZ_ASSERT(IsAbsolutelyPositionedWithDefiniteContainingBlock(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(IsAbsolutelyPositionedWithDefiniteContainingBlock()) >::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(IsAbsolutelyPositionedWithDefiniteContainingBlock()) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsAbsolutelyPositionedWithDefiniteContainingBlock()" " (" "Asking for absolute auto size when not absolute" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6889); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsAbsolutelyPositionedWithDefiniteContainingBlock()" ") (" "Asking for absolute auto size when not absolute" ")") ; do { *((volatile int*)__null) = 6889; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 6889 | "Asking for absolute auto size when not absolute")do { static_assert( mozilla::detail::AssertionConditionType< decltype(IsAbsolutelyPositionedWithDefiniteContainingBlock()) >::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(IsAbsolutelyPositionedWithDefiniteContainingBlock()) )), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsAbsolutelyPositionedWithDefiniteContainingBlock()" " (" "Asking for absolute auto size when not absolute" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6889); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsAbsolutelyPositionedWithDefiniteContainingBlock()" ") (" "Asking for absolute auto size when not absolute" ")") ; do { *((volatile int*)__null) = 6889; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 6890 | // Ideally, this is an assertion, but the containing block could just be | 
| 6891 | // really big. | 
| 6892 | NS_WARNING_ASSERTION(aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE &&do { if (!(aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE && aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE)) { NS_DebugBreak (NS_DEBUG_WARNING, "Absolute containing block size not definite?" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE && aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6894); } } while (false) | 
| 6893 | aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE,do { if (!(aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE && aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE)) { NS_DebugBreak (NS_DEBUG_WARNING, "Absolute containing block size not definite?" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE && aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6894); } } while (false) | 
| 6894 | "Absolute containing block size not definite?")do { if (!(aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE && aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE)) { NS_DebugBreak (NS_DEBUG_WARNING, "Absolute containing block size not definite?" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE && aCBSize.BSize(aWM) != NS_UNCONSTRAINEDSIZE" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 6894); } } while (false); | 
| 6895 | LogicalSize result(aWM, static_cast<nscoord>(0xdeadbeef), | 
| 6896 | NS_UNCONSTRAINEDSIZE); | 
| 6897 | |
| 6898 | const auto* stylePos = StylePosition(); | 
| 6899 | const auto& styleISize = aSizeOverrides.mStyleISize | 
| 6900 | ? *aSizeOverrides.mStyleISize | 
| 6901 | : stylePos->ISize(aWM); | 
| 6902 | const auto& styleBSize = aSizeOverrides.mStyleBSize | 
| 6903 | ? *aSizeOverrides.mStyleBSize | 
| 6904 | : stylePos->BSize(aWM); | 
| 6905 | const auto iStartOffsetIsAuto = | 
| 6906 | stylePos->GetInset(LogicalSide::IStart, aWM).IsAuto(); | 
| 6907 | const auto iEndOffsetIsAuto = | 
| 6908 | stylePos->GetInset(LogicalSide::IEnd, aWM).IsAuto(); | 
| 6909 | const auto bStartOffsetIsAuto = | 
| 6910 | stylePos->GetInset(LogicalSide::BStart, aWM).IsAuto(); | 
| 6911 | const auto bEndOffsetIsAuto = | 
| 6912 | stylePos->GetInset(LogicalSide::BEnd, aWM).IsAuto(); | 
| 6913 | const auto boxSizingAdjust = stylePos->mBoxSizing == StyleBoxSizing::Border | 
| 6914 | ? aBorderPadding | 
| 6915 | : LogicalSize(aWM); | 
| 6916 | auto shouldStretch = [](StyleSelfAlignment aAlignment, const nsIFrame* aFrame, | 
| 6917 | bool aStartIsAuto, bool aEndIsAuto) { | 
| 6918 | if (aStartIsAuto || aEndIsAuto) { | 
| 6919 | // Note(dshin, bug 1930427): This is not part of the current spec [1]; | 
| 6920 | // however, no one implements the new inset behaviour [2], and the old | 
| 6921 | // behaviour [3] ends up computing the static size if both or one inset is | 
| 6922 | // auto. | 
| 6923 | // | 
| 6924 | // [1]: https://drafts.csswg.org/css-position-3/#abspos-auto-size | 
| 6925 | // [2]: https://drafts.csswg.org/css-position-3/#resolving-insets | 
| 6926 | // [3]: https://drafts.csswg.org/css-position-3/#abspos-old | 
| 6927 | return false; | 
| 6928 | } | 
| 6929 | // Don't care about flag bits for auto-sizing. | 
| 6930 | aAlignment &= ~StyleSelfAlignment::FLAG_BITS; | 
| 6931 | |
| 6932 | if (aAlignment == StyleSelfAlignment::STRETCH) { | 
| 6933 | return true; | 
| 6934 | } | 
| 6935 | |
| 6936 | if (aAlignment == StyleSelfAlignment::NORMAL) { | 
| 6937 | // Some replaced elements behave as semi-replaced elements - we want them | 
| 6938 | // to stretch (See bug 1740580). | 
| 6939 | return !aFrame->HasReplacedSizing() && !aFrame->IsTableWrapperFrame(); | 
| 6940 | } | 
| 6941 | |
| 6942 | return false; | 
| 6943 | }; | 
| 6944 | |
| 6945 | // i.e. Absolute containing block | 
| 6946 | const auto* parent = GetParent(); | 
| 6947 | const auto parentWM = parent->GetWritingMode(); | 
| 6948 | // Self alignment properties translate `auto` to normal for this purpose. | 
| 6949 | // https://drafts.csswg.org/css-align-3/#valdef-justify-self-auto | 
| 6950 | const auto inlineAlignSelf = parentWM.IsOrthogonalTo(aWM) | 
| 6951 | ? stylePos->UsedAlignSelf(nullptr)._0 | 
| 6952 | : stylePos->UsedJustifySelf(nullptr)._0; | 
| 6953 | const auto blockAlignSelf = parentWM.IsOrthogonalTo(aWM) | 
| 6954 | ? stylePos->UsedJustifySelf(nullptr)._0 | 
| 6955 | : stylePos->UsedAlignSelf(nullptr)._0; | 
| 6956 | const auto iShouldStretch = shouldStretch( | 
| 6957 | inlineAlignSelf, this, iStartOffsetIsAuto, iEndOffsetIsAuto); | 
| 6958 | const auto bShouldStretch = | 
| 6959 | shouldStretch(blockAlignSelf, this, bStartOffsetIsAuto, bEndOffsetIsAuto); | 
| 6960 | const auto iSizeIsAuto = styleISize.IsAuto(); | 
| 6961 | // Note(dshin, bug 1789477): `auto` in the context of abs-element uses | 
| 6962 | // stretch-fit sizing, given specific alignment conditions [1]. Effectively, | 
| 6963 | // `auto` is `stretch`. `nsLayoutUtils::IsAutoBSize` is not the right tool | 
| 6964 | // here, since the mapping is explicit, and it's incorrect to e.g. map | 
| 6965 | // `fit-content` to `stretch`. | 
| 6966 | // `-moz-available` behaves like `auto` in general, so map the same way. | 
| 6967 | // When Bug 567039 brings `-moz-available` into alignment with `stretch`, this | 
| 6968 | // special check can be removed. TODO(dshin): we're probably duplicating the | 
| 6969 | // `stretch` logic here, since `stretch` is `stretch-fit` sizing [2]. | 
| 6970 | // | 
| 6971 | // [1]: https://drafts.csswg.org/css-position/#abspos-auto-size | 
| 6972 | // [2]: https://drafts.csswg.org/css-sizing-4/#valdef-width-stretch | 
| 6973 | const auto bSizeIsAuto = styleBSize.IsAuto() || styleBSize.IsMozAvailable(); | 
| 6974 | if (bSizeIsAuto && bShouldStretch) { | 
| 6975 | result.BSize(aWM) = nsLayoutUtils::ComputeStretchContentBoxBSize( | 
| 6976 | aCBSize.BSize(aWM), aMargin.BSize(aWM), aBorderPadding.BSize(aWM)); | 
| 6977 | } | 
| 6978 | if (iSizeIsAuto) { | 
| 6979 | if (iShouldStretch) { | 
| 6980 | // inline-size to make our margin-box fill the containing block: | 
| 6981 | result.ISize(aWM) = nsLayoutUtils::ComputeStretchContentBoxISize( | 
| 6982 | aCBSize.ISize(aWM), aMargin.ISize(aWM), aBorderPadding.ISize(aWM)); | 
| 6983 | } else { | 
| 6984 | // inline-size to make our margin-box fill aAvailableISize: | 
| 6985 | nscoord availBased = nsLayoutUtils::ComputeStretchContentBoxISize( | 
| 6986 | aAvailableISize, aMargin.ISize(aWM), aBorderPadding.ISize(aWM)); | 
| 6987 | |
| 6988 | const nscoord bSize = ComputeBSizeValueAsPercentageBasis( | 
| 6989 | styleBSize.IsAuto() && result.BSize(aWM) != NS_UNCONSTRAINEDSIZE | 
| 6990 | ? StyleSize::LengthPercentage( | 
| 6991 | StyleLengthPercentage::FromAppUnits(result.BSize(aWM))) | 
| 6992 | : styleBSize, | 
| 6993 | stylePos->MinBSize(aWM), stylePos->MaxBSize(aWM), aCBSize.BSize(aWM), | 
| 6994 | boxSizingAdjust.BSize(aWM)); | 
| 6995 | |
| 6996 | const IntrinsicSizeInput input( | 
| 6997 | aRenderingContext, Some(aCBSize.ConvertTo(GetWritingMode(), aWM)), | 
| 6998 | Some(LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, bSize) | 
| 6999 | .ConvertTo(GetWritingMode(), aWM))); | 
| 7000 | result.ISize(aWM) = ShrinkISizeToFit(input, availBased, aFlags); | 
| 7001 | } | 
| 7002 | } | 
| 7003 | |
| 7004 | const auto& aspectRatio = aSizeOverrides.mAspectRatio | 
| 7005 | ? *aSizeOverrides.mAspectRatio | 
| 7006 | : GetAspectRatio(); | 
| 7007 | if (aspectRatio) { | 
| 7008 | auto aspectRatioUsage = AspectRatioUsage::None; | 
| 7009 | if (iSizeIsAuto != bSizeIsAuto) { | 
| 7010 | // Auto axis is dependent. | 
| 7011 | if (iSizeIsAuto) { | 
| 7012 | aspectRatioUsage = AspectRatioUsage::ToComputeBSize; | 
| 7013 | } else { | 
| 7014 | aspectRatioUsage = AspectRatioUsage::ToComputeISize; | 
| 7015 | } | 
| 7016 | } else if (iSizeIsAuto) { | 
| 7017 | // Both axes are `auto`. | 
| 7018 | if (iShouldStretch != bShouldStretch) { | 
| 7019 | // If an axis has stretch, that behaves like a definite size. | 
| 7020 | aspectRatioUsage = iShouldStretch ? AspectRatioUsage::ToComputeBSize | 
| 7021 | : AspectRatioUsage::ToComputeISize; | 
| 7022 | } else if (!iShouldStretch) { | 
| 7023 | // If one axis has `auto` inset, that is the ratio dependent axis, | 
| 7024 | // otherwise the block axis is. | 
| 7025 | const bool inlineInsetHasAuto = | 
| 7026 | stylePos->GetInset(LogicalSide::IStart, aWM).IsAuto() || | 
| 7027 | stylePos->GetInset(LogicalSide::IEnd, aWM).IsAuto(); | 
| 7028 | const bool blockInsetHasAuto = | 
| 7029 | stylePos->GetInset(LogicalSide::BStart, aWM).IsAuto() || | 
| 7030 | stylePos->GetInset(LogicalSide::BEnd, aWM).IsAuto(); | 
| 7031 | aspectRatioUsage = inlineInsetHasAuto && !blockInsetHasAuto | 
| 7032 | ? AspectRatioUsage::ToComputeISize | 
| 7033 | : AspectRatioUsage::ToComputeBSize; | 
| 7034 | } | 
| 7035 | } | 
| 7036 | |
| 7037 | if (aspectRatioUsage == AspectRatioUsage::ToComputeBSize && | 
| 7038 | !bShouldStretch) { | 
| 7039 | result.BSize(aWM) = aspectRatio.ComputeRatioDependentSize( | 
| 7040 | LogicalAxis::Block, aWM, result.ISize(aWM), boxSizingAdjust); | 
| 7041 | } else if (aspectRatioUsage == AspectRatioUsage::ToComputeISize && | 
| 7042 | !iShouldStretch && result.BSize(aWM) != NS_UNCONSTRAINEDSIZE) { | 
| 7043 | result.ISize(aWM) = aspectRatio.ComputeRatioDependentSize( | 
| 7044 | LogicalAxis::Inline, aWM, result.BSize(aWM), boxSizingAdjust); | 
| 7045 | } | 
| 7046 | } | 
| 7047 | |
| 7048 | return result; | 
| 7049 | } | 
| 7050 | |
| 7051 | nscoord nsIFrame::ShrinkISizeToFit(const IntrinsicSizeInput& aInput, | 
| 7052 | nscoord aISizeInCB, | 
| 7053 | ComputeSizeFlags aFlags) { | 
| 7054 | // If we're a container for font size inflation, then shrink | 
| 7055 | // wrapping inside of us should not apply font size inflation. | 
| 7056 | AutoMaybeDisableFontInflation an(this); | 
| 7057 | |
| 7058 | nscoord result; | 
| 7059 | nscoord minISize = GetMinISize(aInput); | 
| 7060 | if (minISize > aISizeInCB) { | 
| 7061 | const bool clamp = aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize); | 
| 7062 | result = MOZ_UNLIKELY(clamp)(__builtin_expect(!!(clamp), 0)) ? aISizeInCB : minISize; | 
| 7063 | } else { | 
| 7064 | nscoord prefISize = GetPrefISize(aInput); | 
| 7065 | if (prefISize > aISizeInCB) { | 
| 7066 | result = aISizeInCB; | 
| 7067 | } else { | 
| 7068 | result = prefISize; | 
| 7069 | } | 
| 7070 | } | 
| 7071 | return result; | 
| 7072 | } | 
| 7073 | |
| 7074 | nscoord nsIFrame::IntrinsicISizeFromInline(const IntrinsicSizeInput& aInput, | 
| 7075 | IntrinsicISizeType aType) { | 
| 7076 | MOZ_ASSERT(!IsContainerForFontSizeInflation(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!IsContainerForFontSizeInflation())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!IsContainerForFontSizeInflation ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!IsContainerForFontSizeInflation()" " (" "Should not be a container for font size inflation!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7077); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsContainerForFontSizeInflation()" ") (" "Should not be a container for font size inflation!" ")" ); do { *((volatile int*)__null) = 7077; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 7077 | "Should not be a container for font size inflation!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!IsContainerForFontSizeInflation())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!IsContainerForFontSizeInflation ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!IsContainerForFontSizeInflation()" " (" "Should not be a container for font size inflation!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7077); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!IsContainerForFontSizeInflation()" ") (" "Should not be a container for font size inflation!" ")" ); do { *((volatile int*)__null) = 7077; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7078 | |
| 7079 | if (aType == IntrinsicISizeType::MinISize) { | 
| 7080 | InlineMinISizeData data; | 
| 7081 | AddInlineMinISize(aInput, &data); | 
| 7082 | data.ForceBreak(); | 
| 7083 | return data.mPrevLines; | 
| 7084 | } | 
| 7085 | |
| 7086 | InlinePrefISizeData data; | 
| 7087 | AddInlinePrefISize(aInput, &data); | 
| 7088 | data.ForceBreak(); | 
| 7089 | return data.mPrevLines; | 
| 7090 | } | 
| 7091 | |
| 7092 | nscoord nsIFrame::ComputeISizeValueFromAspectRatio( | 
| 7093 | WritingMode aWM, const LogicalSize& aCBSize, | 
| 7094 | const LogicalSize& aContentEdgeToBoxSizing, const LengthPercentage& aBSize, | 
| 7095 | const AspectRatio& aAspectRatio) const { | 
| 7096 | MOZ_ASSERT(aAspectRatio, "Must have a valid AspectRatio!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aAspectRatio)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aAspectRatio))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aAspectRatio" " (" "Must have a valid AspectRatio!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7096); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aAspectRatio" ") (" "Must have a valid AspectRatio!" ")"); do { *((volatile int*)__null) = 7096; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7097 | const nscoord bSize = nsLayoutUtils::ComputeBSizeValue( | 
| 7098 | aCBSize.BSize(aWM), aContentEdgeToBoxSizing.BSize(aWM), aBSize); | 
| 7099 | return aAspectRatio.ComputeRatioDependentSize(LogicalAxis::Inline, aWM, bSize, | 
| 7100 | aContentEdgeToBoxSizing); | 
| 7101 | } | 
| 7102 | |
| 7103 | nsIFrame::ISizeComputationResult nsIFrame::ComputeISizeValue( | 
| 7104 | gfxContext* aRenderingContext, const WritingMode aWM, | 
| 7105 | const LogicalSize& aCBSize, const LogicalSize& aContentEdgeToBoxSizing, | 
| 7106 | nscoord aBoxSizingToMarginEdge, ExtremumLength aSize, | 
| 7107 | Maybe<nscoord> aAvailableISizeOverride, const StyleSize& aStyleBSize, | 
| 7108 | const AspectRatio& aAspectRatio, ComputeSizeFlags aFlags) { | 
| 7109 | auto GetAvailableISize = [&]() { | 
| 7110 | return aCBSize.ISize(aWM) - aBoxSizingToMarginEdge - | 
| 7111 | aContentEdgeToBoxSizing.ISize(aWM); | 
| 7112 | }; | 
| 7113 | |
| 7114 | // If 'this' is a container for font size inflation, then shrink | 
| 7115 | // wrapping inside of it should not apply font size inflation. | 
| 7116 | AutoMaybeDisableFontInflation an(this); | 
| 7117 | // If we have an aspect-ratio and a definite block size, we should use them to | 
| 7118 | // resolve the sizes with intrinsic keywords. | 
| 7119 | // https://github.com/w3c/csswg-drafts/issues/5032 | 
| 7120 | Maybe<nscoord> iSizeFromAspectRatio = [&]() -> Maybe<nscoord> { | 
| 7121 | if (aSize == ExtremumLength::MozAvailable || | 
| 7122 | aSize == ExtremumLength::Stretch) { | 
| 7123 | return Nothing(); | 
| 7124 | } | 
| 7125 | if (!aAspectRatio) { | 
| 7126 | return Nothing(); | 
| 7127 | } | 
| 7128 | if (nsLayoutUtils::IsAutoBSize(aStyleBSize, aCBSize.BSize(aWM))) { | 
| 7129 | return Nothing(); | 
| 7130 | } | 
| 7131 | return Some(ComputeISizeValueFromAspectRatio( | 
| 7132 | aWM, aCBSize, aContentEdgeToBoxSizing, aStyleBSize.AsLengthPercentage(), | 
| 7133 | aAspectRatio)); | 
| 7134 | }(); | 
| 7135 | |
| 7136 | const auto* stylePos = StylePosition(); | 
| 7137 | const nscoord bSize = ComputeBSizeValueAsPercentageBasis( | 
| 7138 | aStyleBSize, stylePos->MinBSize(aWM), stylePos->MaxBSize(aWM), | 
| 7139 | aCBSize.BSize(aWM), aContentEdgeToBoxSizing.BSize(aWM)); | 
| 7140 | const IntrinsicSizeInput input( | 
| 7141 | aRenderingContext, Some(aCBSize.ConvertTo(GetWritingMode(), aWM)), | 
| 7142 | Some(LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, bSize) | 
| 7143 | .ConvertTo(GetWritingMode(), aWM))); | 
| 7144 | nscoord result; | 
| 7145 | switch (aSize) { | 
| 7146 | case ExtremumLength::MaxContent: | 
| 7147 | result = | 
| 7148 | iSizeFromAspectRatio ? *iSizeFromAspectRatio : GetPrefISize(input); | 
| 7149 | NS_ASSERTION(result >= 0, "inline-size less than zero")do { if (!(result >= 0)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "inline-size less than zero", "result >= 0", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7149); MOZ_PretendNoReturn(); } } while (0); | 
| 7150 | return {result, iSizeFromAspectRatio ? AspectRatioUsage::ToComputeISize | 
| 7151 | : AspectRatioUsage::None}; | 
| 7152 | case ExtremumLength::MinContent: | 
| 7153 | result = | 
| 7154 | iSizeFromAspectRatio ? *iSizeFromAspectRatio : GetMinISize(input); | 
| 7155 | NS_ASSERTION(result >= 0, "inline-size less than zero")do { if (!(result >= 0)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "inline-size less than zero", "result >= 0", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7155); MOZ_PretendNoReturn(); } } while (0); | 
| 7156 | if (MOZ_UNLIKELY((__builtin_expect(!!(aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize )), 0)) | 
| 7157 | aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize))(__builtin_expect(!!(aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize )), 0))) { | 
| 7158 | result = std::min(GetAvailableISize(), result); | 
| 7159 | } | 
| 7160 | return {result, iSizeFromAspectRatio ? AspectRatioUsage::ToComputeISize | 
| 7161 | : AspectRatioUsage::None}; | 
| 7162 | case ExtremumLength::FitContentFunction: | 
| 7163 | case ExtremumLength::FitContent: { | 
| 7164 | nscoord pref = NS_UNCONSTRAINEDSIZE; | 
| 7165 | nscoord min = 0; | 
| 7166 | if (iSizeFromAspectRatio) { | 
| 7167 | // The min-content and max-content size are identical and equal to the | 
| 7168 | // size computed from the block size and the aspect ratio. | 
| 7169 | pref = min = *iSizeFromAspectRatio; | 
| 7170 | } else { | 
| 7171 | pref = GetPrefISize(input); | 
| 7172 | min = GetMinISize(input); | 
| 7173 | } | 
| 7174 | |
| 7175 | const nscoord fill = aAvailableISizeOverride ? *aAvailableISizeOverride | 
| 7176 | : GetAvailableISize(); | 
| 7177 | if (MOZ_UNLIKELY((__builtin_expect(!!(aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize )), 0)) | 
| 7178 | aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize))(__builtin_expect(!!(aFlags.contains(ComputeSizeFlag::IClampMarginBoxMinSize )), 0))) { | 
| 7179 | min = std::min(min, fill); | 
| 7180 | } | 
| 7181 | result = std::max(min, std::min(pref, fill)); | 
| 7182 | NS_ASSERTION(result >= 0, "inline-size less than zero")do { if (!(result >= 0)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "inline-size less than zero", "result >= 0", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7182); MOZ_PretendNoReturn(); } } while (0); | 
| 7183 | return {result}; | 
| 7184 | } | 
| 7185 | case ExtremumLength::MozAvailable: | 
| 7186 | case ExtremumLength::Stretch: | 
| 7187 | return {GetAvailableISize()}; | 
| 7188 | } | 
| 7189 | MOZ_ASSERT_UNREACHABLE("Unknown extremum length?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Unknown extremum length?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7189); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Unknown extremum length?" ")"); do { *((volatile int*)__null) = 7189; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); | 
| 7190 | return {}; | 
| 7191 | } | 
| 7192 | |
| 7193 | nscoord nsIFrame::ComputeISizeValue(const WritingMode aWM, | 
| 7194 | const LogicalSize& aCBSize, | 
| 7195 | const LogicalSize& aContentEdgeToBoxSizing, | 
| 7196 | const LengthPercentage& aSize) const { | 
| 7197 | LAYOUT_WARN_IF_FALSE(do { if ((__builtin_expect(!!(mozilla::detail::log_test(sLayoutLog , mozilla::LogLevel::Warning)), 0)) && !(aCBSize.ISize (aWM) != NS_UNCONSTRAINEDSIZE)) { mozilla::detail::LayoutLogWarning ("have unconstrained inline-size; this should only result from " "very large sizes, not attempts at intrinsic inline-size " "calculation" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7201); } } while (0) | 
| 7198 | aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE,do { if ((__builtin_expect(!!(mozilla::detail::log_test(sLayoutLog , mozilla::LogLevel::Warning)), 0)) && !(aCBSize.ISize (aWM) != NS_UNCONSTRAINEDSIZE)) { mozilla::detail::LayoutLogWarning ("have unconstrained inline-size; this should only result from " "very large sizes, not attempts at intrinsic inline-size " "calculation" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7201); } } while (0) | 
| 7199 | "have unconstrained inline-size; this should only result from "do { if ((__builtin_expect(!!(mozilla::detail::log_test(sLayoutLog , mozilla::LogLevel::Warning)), 0)) && !(aCBSize.ISize (aWM) != NS_UNCONSTRAINEDSIZE)) { mozilla::detail::LayoutLogWarning ("have unconstrained inline-size; this should only result from " "very large sizes, not attempts at intrinsic inline-size " "calculation" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7201); } } while (0) | 
| 7200 | "very large sizes, not attempts at intrinsic inline-size "do { if ((__builtin_expect(!!(mozilla::detail::log_test(sLayoutLog , mozilla::LogLevel::Warning)), 0)) && !(aCBSize.ISize (aWM) != NS_UNCONSTRAINEDSIZE)) { mozilla::detail::LayoutLogWarning ("have unconstrained inline-size; this should only result from " "very large sizes, not attempts at intrinsic inline-size " "calculation" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7201); } } while (0) | 
| 7201 | "calculation")do { if ((__builtin_expect(!!(mozilla::detail::log_test(sLayoutLog , mozilla::LogLevel::Warning)), 0)) && !(aCBSize.ISize (aWM) != NS_UNCONSTRAINEDSIZE)) { mozilla::detail::LayoutLogWarning ("have unconstrained inline-size; this should only result from " "very large sizes, not attempts at intrinsic inline-size " "calculation" , "aCBSize.ISize(aWM) != NS_UNCONSTRAINEDSIZE", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7201); } } while (0); | 
| 7202 | NS_ASSERTION(aCBSize.ISize(aWM) >= 0, "inline-size less than zero")do { if (!(aCBSize.ISize(aWM) >= 0)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "inline-size less than zero", "aCBSize.ISize(aWM) >= 0", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7202); MOZ_PretendNoReturn(); } } while (0); | 
| 7203 | |
| 7204 | nscoord result = aSize.Resolve(aCBSize.ISize(aWM)); | 
| 7205 | // The result of a calc() expression might be less than 0; we | 
| 7206 | // should clamp at runtime (below). (Percentages and coords that | 
| 7207 | // are less than 0 have already been dropped by the parser.) | 
| 7208 | result -= aContentEdgeToBoxSizing.ISize(aWM); | 
| 7209 | return std::max(0, result); | 
| 7210 | } | 
| 7211 | |
| 7212 | void nsIFrame::DidReflow(nsPresContext* aPresContext, | 
| 7213 | const ReflowInput* aReflowInput) { | 
| 7214 | NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, ("nsIFrame::DidReflow"))do { if ((int(((mozilla::LogModule*)(nsIFrame::sFrameLogModule ))->Level()) & (0x1))) { TraceMsg ("nsIFrame::DidReflow" ); } } while (0); | 
| 7215 | |
| 7216 | if (IsHiddenByContentVisibilityOfInFlowParentForLayout()) { | 
| 7217 | RemoveStateBits(NS_FRAME_IN_REFLOW); | 
| 7218 | return; | 
| 7219 | } | 
| 7220 | |
| 7221 | SVGObserverUtils::InvalidateDirectRenderingObservers( | 
| 7222 | this, SVGObserverUtils::INVALIDATE_REFLOW); | 
| 7223 | |
| 7224 | RemoveStateBits(NS_FRAME_IN_REFLOW | NS_FRAME_FIRST_REFLOW | | 
| 7225 | NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN); | 
| 7226 | |
| 7227 | // Clear bits that were used in ReflowInput::InitResizeFlags (see | 
| 7228 | // comment there for why we can't clear it there). | 
| 7229 | SetHasBSizeChange(false); | 
| 7230 | SetHasPaddingChange(false); | 
| 7231 | |
| 7232 | // Notify the percent bsize observer if there is a percent bsize. | 
| 7233 | // The observer may be able to initiate another reflow with a computed | 
| 7234 | // bsize. This happens in the case where a table cell has no computed | 
| 7235 | // bsize but can fabricate one when the cell bsize is known. | 
| 7236 | if (aReflowInput && aReflowInput->mPercentBSizeObserver && !GetPrevInFlow()) { | 
| 7237 | const auto& bsize = | 
| 7238 | aReflowInput->mStylePosition->BSize(aReflowInput->GetWritingMode()); | 
| 7239 | if (bsize.HasPercent()) { | 
| 7240 | aReflowInput->mPercentBSizeObserver->NotifyPercentBSize(*aReflowInput); | 
| 7241 | } | 
| 7242 | } | 
| 7243 | |
| 7244 | aPresContext->ReflowedFrame(); | 
| 7245 | } | 
| 7246 | |
| 7247 | void nsIFrame::FinishReflowWithAbsoluteFrames(nsPresContext* aPresContext, | 
| 7248 | ReflowOutput& aDesiredSize, | 
| 7249 | const ReflowInput& aReflowInput, | 
| 7250 | nsReflowStatus& aStatus, | 
| 7251 | bool aConstrainBSize) { | 
| 7252 | ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowInput, aStatus, | 
| 7253 | aConstrainBSize); | 
| 7254 | |
| 7255 | FinishAndStoreOverflow(&aDesiredSize, aReflowInput.mStyleDisplay); | 
| 7256 | } | 
| 7257 | |
| 7258 | void nsIFrame::ReflowAbsoluteFrames(nsPresContext* aPresContext, | 
| 7259 | ReflowOutput& aDesiredSize, | 
| 7260 | const ReflowInput& aReflowInput, | 
| 7261 | nsReflowStatus& aStatus, | 
| 7262 | bool aConstrainBSize) { | 
| 7263 | if (HasAbsolutelyPositionedChildren()) { | 
| 7264 | nsAbsoluteContainingBlock* absoluteContainer = GetAbsoluteContainingBlock(); | 
| 7265 | |
| 7266 | // Let the absolutely positioned container reflow any absolutely positioned | 
| 7267 | // child frames that need to be reflowed | 
| 7268 | |
| 7269 | // The containing block for the abs pos kids is formed by our padding edge. | 
| 7270 | nsMargin usedBorder = GetUsedBorder(); | 
| 7271 | nscoord containingBlockWidth = | 
| 7272 | std::max(0, aDesiredSize.Width() - usedBorder.LeftRight()); | 
| 7273 | nscoord containingBlockHeight = | 
| 7274 | std::max(0, aDesiredSize.Height() - usedBorder.TopBottom()); | 
| 7275 | nsContainerFrame* container = do_QueryFrame(this); | 
| 7276 | NS_ASSERTION(container,do { if (!(container)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Abs-pos children only supported on container frames for now" , "container", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7277); MOZ_PretendNoReturn(); } } while (0) | 
| 7277 | "Abs-pos children only supported on container frames for now")do { if (!(container)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Abs-pos children only supported on container frames for now" , "container", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7277); MOZ_PretendNoReturn(); } } while (0); | 
| 7278 | |
| 7279 | nsRect containingBlock(0, 0, containingBlockWidth, containingBlockHeight); | 
| 7280 | AbsPosReflowFlags flags = | 
| 7281 | AbsPosReflowFlags::CBWidthAndHeightChanged; // XXX could be optimized | 
| 7282 | if (aConstrainBSize) { | 
| 7283 | flags |= AbsPosReflowFlags::ConstrainHeight; | 
| 7284 | } | 
| 7285 | absoluteContainer->Reflow(container, aPresContext, aReflowInput, aStatus, | 
| 7286 | containingBlock, flags, | 
| 7287 | &aDesiredSize.mOverflowAreas); | 
| 7288 | } | 
| 7289 | } | 
| 7290 | |
| 7291 | /* virtual */ | 
| 7292 | bool nsIFrame::CanContinueTextRun() const { | 
| 7293 | // By default, a frame will *not* allow a text run to be continued | 
| 7294 | // through it. | 
| 7295 | return false; | 
| 7296 | } | 
| 7297 | |
| 7298 | void nsIFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, | 
| 7299 | const ReflowInput& aReflowInput, | 
| 7300 | nsReflowStatus& aStatus) { | 
| 7301 | MarkInReflow(); | 
| 7302 | DO_GLOBAL_REFLOW_COUNT("nsFrame")aPresContext->CountReflows(("nsFrame"), (nsIFrame*)this);; | 
| 7303 | MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aStatus.IsEmpty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aStatus.IsEmpty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aStatus.IsEmpty()" " (" "Caller should pass a fresh reflow status!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7303); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aStatus.IsEmpty()" ") (" "Caller should pass a fresh reflow status!" ")"); do { *((volatile int*)__null) = 7303; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); | 
| 7304 | aDesiredSize.ClearSize(); | 
| 7305 | } | 
| 7306 | |
| 7307 | bool nsIFrame::IsContentDisabled() const { | 
| 7308 | // FIXME(emilio): Doing this via CSS means callers must ensure the style is up | 
| 7309 | // to date, and they don't! | 
| 7310 | if (StyleUI()->UserInput() == StyleUserInput::None) { | 
| 7311 | return true; | 
| 7312 | } | 
| 7313 | |
| 7314 | auto* element = nsGenericHTMLElement::FromNodeOrNull(GetContent()); | 
| 7315 | return element && element->IsDisabled(); | 
| 7316 | } | 
| 7317 | |
| 7318 | bool nsIFrame::IsContentRelevant() const { | 
| 7319 | MOZ_ASSERT(StyleDisplay()->ContentVisibility(*this) ==do { static_assert( mozilla::detail::AssertionConditionType< decltype(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7320); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" ")"); do { *((volatile int*)__null) = 7320; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 7320 | StyleContentVisibility::Auto)do { static_assert( mozilla::detail::AssertionConditionType< decltype(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7320); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" ")"); do { *((volatile int*)__null) = 7320; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7321 | |
| 7322 | auto* element = Element::FromNodeOrNull(GetContent()); | 
| 7323 | MOZ_ASSERT(element)do { static_assert( mozilla::detail::AssertionConditionType< decltype(element)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(element))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("element", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7323); AnnotateMozCrashReason("MOZ_ASSERT" "(" "element" ")" ); do { *((volatile int*)__null) = 7323; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7324 | |
| 7325 | Maybe<ContentRelevancy> relevancy = element->GetContentRelevancy(); | 
| 7326 | return relevancy.isSome() && !relevancy->isEmpty(); | 
| 7327 | } | 
| 7328 | |
| 7329 | bool nsIFrame::HidesContent( | 
| 7330 | const EnumSet<IncludeContentVisibility>& aInclude) const { | 
| 7331 | auto effectiveContentVisibility = StyleDisplay()->ContentVisibility(*this); | 
| 7332 | if (aInclude.contains(IncludeContentVisibility::Hidden) && | 
| 7333 | effectiveContentVisibility == StyleContentVisibility::Hidden) { | 
| 7334 | return true; | 
| 7335 | } | 
| 7336 | |
| 7337 | if (aInclude.contains(IncludeContentVisibility::Auto) && | 
| 7338 | effectiveContentVisibility == StyleContentVisibility::Auto) { | 
| 7339 | return !IsContentRelevant(); | 
| 7340 | } | 
| 7341 | |
| 7342 | return false; | 
| 7343 | } | 
| 7344 | |
| 7345 | bool nsIFrame::HidesContentForLayout() const { | 
| 7346 | return HidesContent() && !PresShell()->IsForcingLayoutForHiddenContent(this); | 
| 7347 | } | 
| 7348 | |
| 7349 | bool nsIFrame::IsHiddenByContentVisibilityOfInFlowParentForLayout() const { | 
| 7350 | const auto* parent = GetInFlowParent(); | 
| 7351 | // The anonymous children owned by parent are important for properly sizing | 
| 7352 | // their parents. | 
| 7353 | return parent && parent->HidesContentForLayout() && | 
| 7354 | !(parent->HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES) && | 
| 7355 | Style()->IsAnonBox()); | 
| 7356 | } | 
| 7357 | |
| 7358 | nsIFrame* nsIFrame::GetClosestContentVisibilityAncestor( | 
| 7359 | const EnumSet<IncludeContentVisibility>& aInclude) const { | 
| 7360 | auto* parent = GetInFlowParent(); | 
| 7361 | bool isAnonymousBlock = Style()->IsAnonBox() && parent && | 
| 7362 | parent->HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES); | 
| 7363 | for (nsIFrame* cur = parent; cur; cur = cur->GetInFlowParent()) { | 
| 7364 | if (!isAnonymousBlock && cur->HidesContent(aInclude)) { | 
| 7365 | return cur; | 
| 7366 | } | 
| 7367 | |
| 7368 | // Anonymous boxes are not hidden by the content-visibility of their first | 
| 7369 | // non-anonymous ancestor, but can be hidden by ancestors further up the | 
| 7370 | // tree. | 
| 7371 | isAnonymousBlock = false; | 
| 7372 | } | 
| 7373 | |
| 7374 | return nullptr; | 
| 7375 | } | 
| 7376 | |
| 7377 | bool nsIFrame::IsHiddenByContentVisibilityOnAnyAncestor( | 
| 7378 | const EnumSet<IncludeContentVisibility>& aInclude) const { | 
| 7379 | return !!GetClosestContentVisibilityAncestor(aInclude); | 
| 7380 | } | 
| 7381 | |
| 7382 | bool nsIFrame::HasSelectionInSubtree() { | 
| 7383 | if (IsSelected()) { | 
| 7384 | return true; | 
| 7385 | } | 
| 7386 | |
| 7387 | RefPtr<nsFrameSelection> frameSelection = GetFrameSelection(); | 
| 7388 | if (!frameSelection) { | 
| 7389 | return false; | 
| 7390 | } | 
| 7391 | |
| 7392 | const Selection& selection = frameSelection->NormalSelection(); | 
| 7393 | |
| 7394 | for (uint32_t i = 0; i < selection.RangeCount(); i++) { | 
| 7395 | auto* range = selection.GetRangeAt(i); | 
| 7396 | MOZ_ASSERT(range)do { static_assert( mozilla::detail::AssertionConditionType< decltype(range)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(range))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("range", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7396); AnnotateMozCrashReason("MOZ_ASSERT" "(" "range" ")") ; do { *((volatile int*)__null) = 7396; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7397 | |
| 7398 | const auto* commonAncestorNode = | 
| 7399 | range->GetRegisteredClosestCommonInclusiveAncestor(); | 
| 7400 | if (commonAncestorNode && | 
| 7401 | commonAncestorNode->IsInclusiveDescendantOf(GetContent())) { | 
| 7402 | return true; | 
| 7403 | } | 
| 7404 | } | 
| 7405 | |
| 7406 | return false; | 
| 7407 | } | 
| 7408 | |
| 7409 | bool nsIFrame::UpdateIsRelevantContent( | 
| 7410 | const ContentRelevancy& aRelevancyToUpdate) { | 
| 7411 | MOZ_ASSERT(StyleDisplay()->ContentVisibility(*this) ==do { static_assert( mozilla::detail::AssertionConditionType< decltype(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7412); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" ")"); do { *((volatile int*)__null) = 7412; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 7412 | StyleContentVisibility::Auto)do { static_assert( mozilla::detail::AssertionConditionType< decltype(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto)>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility ::Auto))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7412); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StyleDisplay()->ContentVisibility(*this) == StyleContentVisibility::Auto" ")"); do { *((volatile int*)__null) = 7412; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7413 | |
| 7414 | auto* element = Element::FromNodeOrNull(GetContent()); | 
| 7415 | MOZ_ASSERT(element)do { static_assert( mozilla::detail::AssertionConditionType< decltype(element)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(element))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("element", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7415); AnnotateMozCrashReason("MOZ_ASSERT" "(" "element" ")" ); do { *((volatile int*)__null) = 7415; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7416 | |
| 7417 | ContentRelevancy newRelevancy; | 
| 7418 | Maybe<ContentRelevancy> oldRelevancy = element->GetContentRelevancy(); | 
| 7419 | if (oldRelevancy.isSome()) { | 
| 7420 | newRelevancy = *oldRelevancy; | 
| 7421 | } | 
| 7422 | |
| 7423 | auto setRelevancyValue = [&](ContentRelevancyReason reason, bool value) { | 
| 7424 | if (value) { | 
| 7425 | newRelevancy += reason; | 
| 7426 | } else { | 
| 7427 | newRelevancy -= reason; | 
| 7428 | } | 
| 7429 | }; | 
| 7430 | |
| 7431 | if (!oldRelevancy || | 
| 7432 | aRelevancyToUpdate.contains(ContentRelevancyReason::Visible)) { | 
| 7433 | Maybe<bool> visible = element->GetVisibleForContentVisibility(); | 
| 7434 | if (visible.isSome()) { | 
| 7435 | setRelevancyValue(ContentRelevancyReason::Visible, *visible); | 
| 7436 | } | 
| 7437 | } | 
| 7438 | |
| 7439 | if (!oldRelevancy || | 
| 7440 | aRelevancyToUpdate.contains(ContentRelevancyReason::FocusInSubtree)) { | 
| 7441 | setRelevancyValue(ContentRelevancyReason::FocusInSubtree, | 
| 7442 | element->State().HasAtLeastOneOfStates( | 
| 7443 | ElementState::FOCUS_WITHIN | ElementState::FOCUS)); | 
| 7444 | } | 
| 7445 | |
| 7446 | if (!oldRelevancy || | 
| 7447 | aRelevancyToUpdate.contains(ContentRelevancyReason::Selected)) { | 
| 7448 | setRelevancyValue(ContentRelevancyReason::Selected, | 
| 7449 | HasSelectionInSubtree()); | 
| 7450 | } | 
| 7451 | |
| 7452 | // If the proximity to the viewport has not been determined yet, | 
| 7453 | // and neither the element nor its contents are focused or selected, | 
| 7454 | // we should wait for the determination of the proximity. Otherwise, | 
| 7455 | // there might be a redundant contentvisibilityautostatechange event. | 
| 7456 | // See https://github.com/w3c/csswg-drafts/issues/9803 | 
| 7457 | bool isProximityToViewportDetermined = | 
| 7458 | oldRelevancy ? true : element->GetVisibleForContentVisibility().isSome(); | 
| 7459 | if (!isProximityToViewportDetermined && newRelevancy.isEmpty()) { | 
| 7460 | return false; | 
| 7461 | } | 
| 7462 | |
| 7463 | bool overallRelevancyChanged = | 
| 7464 | !oldRelevancy || oldRelevancy->isEmpty() != newRelevancy.isEmpty(); | 
| 7465 | if (!oldRelevancy || *oldRelevancy != newRelevancy) { | 
| 7466 | element->SetContentRelevancy(newRelevancy); | 
| 7467 | } | 
| 7468 | |
| 7469 | if (!overallRelevancyChanged) { | 
| 7470 | return false; | 
| 7471 | } | 
| 7472 | |
| 7473 | HandleLastRememberedSize(); | 
| 7474 | PresContext()->SetNeedsToUpdateHiddenByContentVisibilityForAnimations(); | 
| 7475 | PresShell()->FrameNeedsReflow( | 
| 7476 | this, IntrinsicDirty::FrameAncestorsAndDescendants, NS_FRAME_IS_DIRTY); | 
| 7477 | InvalidateFrame(); | 
| 7478 | |
| 7479 | ContentVisibilityAutoStateChangeEventInit init; | 
| 7480 | init.mSkipped = newRelevancy.isEmpty(); | 
| 7481 | RefPtr<ContentVisibilityAutoStateChangeEvent> event = | 
| 7482 | ContentVisibilityAutoStateChangeEvent::Constructor( | 
| 7483 | element, u"contentvisibilityautostatechange"_ns, init); | 
| 7484 | |
| 7485 | // Per | 
| 7486 | // https://drafts.csswg.org/css-contain/#content-visibility-auto-state-changed | 
| 7487 | // "This event is dispatched by posting a task at the time when the state | 
| 7488 | // change occurs." | 
| 7489 | RefPtr<AsyncEventDispatcher> asyncDispatcher = | 
| 7490 | new AsyncEventDispatcher(element, event.forget()); | 
| 7491 | DebugOnly<nsresult> rv = asyncDispatcher->PostDOMEvent(); | 
| 7492 | NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncEventDispatcher failed to dispatch")do { if (!(((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1 ))))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "AsyncEventDispatcher failed to dispatch" , "NS_SUCCEEDED(rv)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7492); MOZ_PretendNoReturn(); } } while (0); | 
| 7493 | return true; | 
| 7494 | } | 
| 7495 | |
| 7496 | nsresult nsIFrame::CharacterDataChanged(const CharacterDataChangeInfo&) { | 
| 7497 | MOZ_ASSERT_UNREACHABLE("should only be called for text frames")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "should only be called for text frames" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7497); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "should only be called for text frames" ")"); do { *((volatile int*)__null) = 7497; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7498 | return NS_OK; | 
| 7499 | } | 
| 7500 | |
| 7501 | nsresult nsIFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, | 
| 7502 | int32_t aModType) { | 
| 7503 | return NS_OK; | 
| 7504 | } | 
| 7505 | |
| 7506 | nsIFrame* nsIFrame::GetPrevContinuation() const { return nullptr; } | 
| 7507 | |
| 7508 | void nsIFrame::SetPrevContinuation(nsIFrame*) { | 
| 7509 | MOZ_ASSERT_UNREACHABLE("Not splittable!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7509); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")"); do { *((volatile int*)__null) = 7509; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7510 | } | 
| 7511 | |
| 7512 | nsIFrame* nsIFrame::GetNextContinuation() const { return nullptr; } | 
| 7513 | |
| 7514 | void nsIFrame::SetNextContinuation(nsIFrame*) { | 
| 7515 | MOZ_ASSERT_UNREACHABLE("Not splittable!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7515); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")"); do { *((volatile int*)__null) = 7515; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7516 | } | 
| 7517 | |
| 7518 | nsIFrame* nsIFrame::GetPrevInFlow() const { return nullptr; } | 
| 7519 | |
| 7520 | void nsIFrame::SetPrevInFlow(nsIFrame*) { | 
| 7521 | MOZ_ASSERT_UNREACHABLE("Not splittable!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7521); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")"); do { *((volatile int*)__null) = 7521; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7522 | } | 
| 7523 | |
| 7524 | nsIFrame* nsIFrame::GetNextInFlow() const { return nullptr; } | 
| 7525 | |
| 7526 | void nsIFrame::SetNextInFlow(nsIFrame*) { | 
| 7527 | MOZ_ASSERT_UNREACHABLE("Not splittable!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7527); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Not splittable!" ")"); do { *((volatile int*)__null) = 7527; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7528 | } | 
| 7529 | |
| 7530 | nsIFrame* nsIFrame::GetTailContinuation() { | 
| 7531 | nsIFrame* frame = this; | 
| 7532 | while (frame->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) { | 
| 7533 | frame = frame->GetPrevContinuation(); | 
| 7534 | NS_ASSERTION(frame, "first continuation can't be overflow container")do { if (!(frame)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "first continuation can't be overflow container" , "frame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7534); MOZ_PretendNoReturn(); } } while (0); | 
| 7535 | } | 
| 7536 | for (nsIFrame* next = frame->GetNextContinuation(); | 
| 7537 | next && !next->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER); | 
| 7538 | next = frame->GetNextContinuation()) { | 
| 7539 | frame = next; | 
| 7540 | } | 
| 7541 | |
| 7542 | MOZ_ASSERT(frame, "illegal state in continuation chain.")do { static_assert( mozilla::detail::AssertionConditionType< decltype(frame)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(frame))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("frame" " (" "illegal state in continuation chain." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7542); AnnotateMozCrashReason("MOZ_ASSERT" "(" "frame" ") (" "illegal state in continuation chain." ")"); do { *((volatile int*)__null) = 7542; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7543 | return frame; | 
| 7544 | } | 
| 7545 | |
| 7546 | // Associated view object | 
| 7547 | void nsIFrame::SetView(nsView* aView) { | 
| 7548 | if (aView) { | 
| 7549 | aView->SetFrame(this); | 
| 7550 | |
| 7551 | #ifdef DEBUG1 | 
| 7552 | LayoutFrameType frameType = Type(); | 
| 7553 | NS_ASSERTION(frameType == LayoutFrameType::SubDocument ||do { if (!(frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType ::MenuPopup)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Only specific frame types can have an nsView" , "frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType::MenuPopup" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7556); MOZ_PretendNoReturn(); } } while (0) | 
| 7554 | frameType == LayoutFrameType::Viewport ||do { if (!(frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType ::MenuPopup)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Only specific frame types can have an nsView" , "frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType::MenuPopup" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7556); MOZ_PretendNoReturn(); } } while (0) | 
| 7555 | frameType == LayoutFrameType::MenuPopup,do { if (!(frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType ::MenuPopup)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Only specific frame types can have an nsView" , "frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType::MenuPopup" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7556); MOZ_PretendNoReturn(); } } while (0) | 
| 7556 | "Only specific frame types can have an nsView")do { if (!(frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType ::MenuPopup)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Only specific frame types can have an nsView" , "frameType == LayoutFrameType::SubDocument || frameType == LayoutFrameType::Viewport || frameType == LayoutFrameType::MenuPopup" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7556); MOZ_PretendNoReturn(); } } while (0); | 
| 7557 | #endif | 
| 7558 | |
| 7559 | // Store the view on the frame. | 
| 7560 | SetViewInternal(aView); | 
| 7561 | |
| 7562 | // Set the frame state bit that says the frame has a view | 
| 7563 | AddStateBits(NS_FRAME_HAS_VIEW); | 
| 7564 | |
| 7565 | // Let all of the ancestors know they have a descendant with a view. | 
| 7566 | for (nsIFrame* f = GetParent(); | 
| 7567 | f && !f->HasAnyStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW); | 
| 7568 | f = f->GetParent()) { | 
| 7569 | f->AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW); | 
| 7570 | } | 
| 7571 | } else { | 
| 7572 | MOZ_ASSERT_UNREACHABLE("Destroying a view while the frame is alive?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Destroying a view while the frame is alive?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7572); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Destroying a view while the frame is alive?" ")"); do { *((volatile int*)__null) = 7572; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7573 | RemoveStateBits(NS_FRAME_HAS_VIEW); | 
| 7574 | SetViewInternal(nullptr); | 
| 7575 | } | 
| 7576 | } | 
| 7577 | |
| 7578 | template <nsPoint (nsIFrame::*PositionGetter)() const> | 
| 7579 | static nsPoint OffsetCalculator(const nsIFrame* aThis, const nsIFrame* aOther) { | 
| 7580 | MOZ_ASSERT(aOther, "Must have frame for destination coordinate system!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aOther)>::isValid, "invalid assertion condition") ; if ((__builtin_expect(!!(!(!!(aOther))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aOther" " (" "Must have frame for destination coordinate system!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7580); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aOther" ") (" "Must have frame for destination coordinate system!" ")"); do { *((volatile int*)__null) = 7580; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); | 
| 7581 | |
| 7582 | NS_ASSERTION(aThis->PresContext() == aOther->PresContext(),do { if (!(aThis->PresContext() == aOther->PresContext( ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "GetOffsetTo called on frames in different documents" , "aThis->PresContext() == aOther->PresContext()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7583); MOZ_PretendNoReturn(); } } while (0) | 
| 7583 | "GetOffsetTo called on frames in different documents")do { if (!(aThis->PresContext() == aOther->PresContext( ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "GetOffsetTo called on frames in different documents" , "aThis->PresContext() == aOther->PresContext()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7583); MOZ_PretendNoReturn(); } } while (0); | 
| 7584 | |
| 7585 | nsPoint offset(0, 0); | 
| 7586 | const nsIFrame* f; | 
| 7587 | for (f = aThis; f != aOther && f; f = f->GetParent()) { | 
| 7588 | offset += (f->*PositionGetter)(); | 
| 7589 | } | 
| 7590 | |
| 7591 | if (f != aOther) { | 
| 7592 | // Looks like aOther wasn't an ancestor of |this|. So now we have | 
| 7593 | // the root-frame-relative position of |this| in |offset|. Convert back | 
| 7594 | // to the coordinates of aOther | 
| 7595 | while (aOther) { | 
| 7596 | offset -= (aOther->*PositionGetter)(); | 
| 7597 | aOther = aOther->GetParent(); | 
| 7598 | } | 
| 7599 | } | 
| 7600 | |
| 7601 | return offset; | 
| 7602 | } | 
| 7603 | |
| 7604 | nsPoint nsIFrame::GetOffsetTo(const nsIFrame* aOther) const { | 
| 7605 | return OffsetCalculator<&nsIFrame::GetPosition>(this, aOther); | 
| 7606 | } | 
| 7607 | |
| 7608 | nsPoint nsIFrame::GetOffsetToIgnoringScrolling(const nsIFrame* aOther) const { | 
| 7609 | return OffsetCalculator<&nsIFrame::GetPositionIgnoringScrolling>(this, | 
| 7610 | aOther); | 
| 7611 | } | 
| 7612 | |
| 7613 | nsPoint nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther) const { | 
| 7614 | return GetOffsetToCrossDoc(aOther, PresContext()->AppUnitsPerDevPixel()); | 
| 7615 | } | 
| 7616 | |
| 7617 | nsPoint nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther, | 
| 7618 | const int32_t aAPD) const { | 
| 7619 | MOZ_ASSERT(aOther, "Must have frame for destination coordinate system!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aOther)>::isValid, "invalid assertion condition") ; if ((__builtin_expect(!!(!(!!(aOther))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aOther" " (" "Must have frame for destination coordinate system!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7619); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aOther" ") (" "Must have frame for destination coordinate system!" ")"); do { *((volatile int*)__null) = 7619; __attribute__((nomerge)) :: abort(); } while (false); } } while (false); | 
| 7620 | MOZ_DIAGNOSTIC_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType< decltype(PresContext()->GetRootPresContext() == aOther-> PresContext()->GetRootPresContext())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(PresContext()->GetRootPresContext () == aOther->PresContext()->GetRootPresContext()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" " (" "trying to get the offset between frames in different document " "hierarchies?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7624); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" ") (" "trying to get the offset between frames in different document " "hierarchies?" ")"); do { *((volatile int*)__null) = 7624; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 7621 | PresContext()->GetRootPresContext() ==do { static_assert( mozilla::detail::AssertionConditionType< decltype(PresContext()->GetRootPresContext() == aOther-> PresContext()->GetRootPresContext())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(PresContext()->GetRootPresContext () == aOther->PresContext()->GetRootPresContext()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" " (" "trying to get the offset between frames in different document " "hierarchies?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7624); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" ") (" "trying to get the offset between frames in different document " "hierarchies?" ")"); do { *((volatile int*)__null) = 7624; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 7622 | aOther->PresContext()->GetRootPresContext(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(PresContext()->GetRootPresContext() == aOther-> PresContext()->GetRootPresContext())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(PresContext()->GetRootPresContext () == aOther->PresContext()->GetRootPresContext()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" " (" "trying to get the offset between frames in different document " "hierarchies?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7624); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" ") (" "trying to get the offset between frames in different document " "hierarchies?" ")"); do { *((volatile int*)__null) = 7624; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 7623 | "trying to get the offset between frames in different document "do { static_assert( mozilla::detail::AssertionConditionType< decltype(PresContext()->GetRootPresContext() == aOther-> PresContext()->GetRootPresContext())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(PresContext()->GetRootPresContext () == aOther->PresContext()->GetRootPresContext()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" " (" "trying to get the offset between frames in different document " "hierarchies?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7624); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" ") (" "trying to get the offset between frames in different document " "hierarchies?" ")"); do { *((volatile int*)__null) = 7624; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 7624 | "hierarchies?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(PresContext()->GetRootPresContext() == aOther-> PresContext()->GetRootPresContext())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(PresContext()->GetRootPresContext () == aOther->PresContext()->GetRootPresContext()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" " (" "trying to get the offset between frames in different document " "hierarchies?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7624); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "PresContext()->GetRootPresContext() == aOther->PresContext()->GetRootPresContext()" ") (" "trying to get the offset between frames in different document " "hierarchies?" ")"); do { *((volatile int*)__null) = 7624; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7625 | |
| 7626 | const nsIFrame* root = nullptr; | 
| 7627 | // offset will hold the final offset | 
| 7628 | // docOffset holds the currently accumulated offset at the current APD, it | 
| 7629 | // will be converted and added to offset when the current APD changes. | 
| 7630 | nsPoint offset(0, 0), docOffset(0, 0); | 
| 7631 | const nsIFrame* f = this; | 
| 7632 | int32_t currAPD = PresContext()->AppUnitsPerDevPixel(); | 
| 7633 | while (f && f != aOther) { | 
| 7634 | docOffset += f->GetPosition(); | 
| 7635 | nsIFrame* parent = f->GetParent(); | 
| 7636 | if (parent) { | 
| 7637 | f = parent; | 
| 7638 | } else { | 
| 7639 | nsPoint newOffset(0, 0); | 
| 7640 | root = f; | 
| 7641 | f = nsLayoutUtils::GetCrossDocParentFrameInProcess(f, &newOffset); | 
| 7642 | int32_t newAPD = f ? f->PresContext()->AppUnitsPerDevPixel() : 0; | 
| 7643 | if (!f || newAPD != currAPD) { | 
| 7644 | // Convert docOffset to the right APD and add it to offset. | 
| 7645 | offset += docOffset.ScaleToOtherAppUnits(currAPD, aAPD); | 
| 7646 | docOffset.x = docOffset.y = 0; | 
| 7647 | } | 
| 7648 | currAPD = newAPD; | 
| 7649 | docOffset += newOffset; | 
| 7650 | } | 
| 7651 | } | 
| 7652 | if (f == aOther) { | 
| 7653 | offset += docOffset.ScaleToOtherAppUnits(currAPD, aAPD); | 
| 7654 | } else { | 
| 7655 | // Looks like aOther wasn't an ancestor of |this|. So now we have | 
| 7656 | // the root-document-relative position of |this| in |offset|. Subtract the | 
| 7657 | // root-document-relative position of |aOther| from |offset|. | 
| 7658 | // This call won't try to recurse again because root is an ancestor of | 
| 7659 | // aOther. | 
| 7660 | nsPoint negOffset = aOther->GetOffsetToCrossDoc(root, aAPD); | 
| 7661 | offset -= negOffset; | 
| 7662 | } | 
| 7663 | |
| 7664 | return offset; | 
| 7665 | } | 
| 7666 | |
| 7667 | CSSIntRect nsIFrame::GetScreenRect() const { | 
| 7668 | return CSSIntRect::FromAppUnitsToNearest(GetScreenRectInAppUnits()); | 
| 7669 | } | 
| 7670 | |
| 7671 | nsRect nsIFrame::GetScreenRectInAppUnits() const { | 
| 7672 | nsPresContext* presContext = PresContext(); | 
| 7673 | nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame(); | 
| 7674 | nsPoint rootScreenPos(0, 0); | 
| 7675 | nsPoint rootFrameOffsetInParent(0, 0); | 
| 7676 | nsIFrame* rootFrameParent = nsLayoutUtils::GetCrossDocParentFrameInProcess( | 
| 7677 | rootFrame, &rootFrameOffsetInParent); | 
| 7678 | if (rootFrameParent) { | 
| 7679 | nsRect parentScreenRectAppUnits = | 
| 7680 | rootFrameParent->GetScreenRectInAppUnits(); | 
| 7681 | nsPresContext* parentPresContext = rootFrameParent->PresContext(); | 
| 7682 | double parentScale = double(presContext->AppUnitsPerDevPixel()) / | 
| 7683 | parentPresContext->AppUnitsPerDevPixel(); | 
| 7684 | nsPoint rootPt = | 
| 7685 | parentScreenRectAppUnits.TopLeft() + rootFrameOffsetInParent; | 
| 7686 | rootScreenPos.x = NS_round(parentScale * rootPt.x); | 
| 7687 | rootScreenPos.y = NS_round(parentScale * rootPt.y); | 
| 7688 | } else { | 
| 7689 | nsCOMPtr<nsIWidget> rootWidget = | 
| 7690 | presContext->PresShell()->GetViewManager()->GetRootWidget(); | 
| 7691 | if (rootWidget) { | 
| 7692 | LayoutDeviceIntPoint rootDevPx = rootWidget->WidgetToScreenOffset(); | 
| 7693 | rootScreenPos.x = presContext->DevPixelsToAppUnits(rootDevPx.x); | 
| 7694 | rootScreenPos.y = presContext->DevPixelsToAppUnits(rootDevPx.y); | 
| 7695 | } | 
| 7696 | } | 
| 7697 | |
| 7698 | return nsRect(rootScreenPos + GetOffsetTo(rootFrame), GetSize()); | 
| 7699 | } | 
| 7700 | |
| 7701 | // Returns the offset from this frame to the closest geometric parent that | 
| 7702 | // has a view. Also returns the containing view or null in case of error | 
| 7703 | void nsIFrame::GetOffsetFromView(nsPoint& aOffset, nsView** aView) const { | 
| 7704 | MOZ_ASSERT(nullptr != aView, "null OUT parameter pointer")do { static_assert( mozilla::detail::AssertionConditionType< decltype(nullptr != aView)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(nullptr != aView))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("nullptr != aView" " (" "null OUT parameter pointer" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7704); AnnotateMozCrashReason("MOZ_ASSERT" "(" "nullptr != aView" ") (" "null OUT parameter pointer" ")"); do { *((volatile int *)__null) = 7704; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7705 | nsIFrame* frame = const_cast<nsIFrame*>(this); | 
| 7706 | |
| 7707 | *aView = nullptr; | 
| 7708 | aOffset.MoveTo(0, 0); | 
| 7709 | do { | 
| 7710 | aOffset += frame->GetPosition(); | 
| 7711 | frame = frame->GetParent(); | 
| 7712 | } while (frame && !frame->HasView()); | 
| 7713 | |
| 7714 | if (frame) { | 
| 7715 | *aView = frame->GetView(); | 
| 7716 | } | 
| 7717 | } | 
| 7718 | |
| 7719 | nsIWidget* nsIFrame::GetNearestWidget() const { | 
| 7720 | return GetClosestView()->GetNearestWidget(nullptr); | 
| 7721 | } | 
| 7722 | |
| 7723 | nsIWidget* nsIFrame::GetNearestWidget(nsPoint& aOffset) const { | 
| 7724 | nsPoint offsetToView; | 
| 7725 | nsPoint offsetToWidget; | 
| 7726 | nsIWidget* widget = | 
| 7727 | GetClosestView(&offsetToView)->GetNearestWidget(&offsetToWidget); | 
| 7728 | aOffset = offsetToView + offsetToWidget; | 
| 7729 | return widget; | 
| 7730 | } | 
| 7731 | |
| 7732 | Matrix4x4Flagged nsIFrame::GetTransformMatrix(ViewportType aViewportType, | 
| 7733 | RelativeTo aStopAtAncestor, | 
| 7734 | nsIFrame** aOutAncestor, | 
| 7735 | uint32_t aFlags) const { | 
| 7736 | MOZ_ASSERT(aOutAncestor, "Need a place to put the ancestor!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aOutAncestor)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aOutAncestor))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aOutAncestor" " (" "Need a place to put the ancestor!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7736); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aOutAncestor" ") (" "Need a place to put the ancestor!" ")"); do { *((volatile int*)__null) = 7736; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 7737 | |
| 7738 | /* If we're transformed, we want to hand back the combination | 
| 7739 | * transform/translate matrix that will apply our current transform, then | 
| 7740 | * shift us to our parent. | 
| 7741 | */ | 
| 7742 | const bool isTransformed = IsTransformed(); | 
| 7743 | const nsIFrame* zoomedContentRoot = nullptr; | 
| 7744 | if (aStopAtAncestor.mViewportType == ViewportType::Visual) { | 
| 7745 | zoomedContentRoot = ViewportUtils::IsZoomedContentRoot(this); | 
| 7746 | if (zoomedContentRoot) { | 
| 7747 | MOZ_ASSERT(aViewportType != ViewportType::Visual)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aViewportType != ViewportType::Visual)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(! !(aViewportType != ViewportType::Visual))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aViewportType != ViewportType::Visual" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7747); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aViewportType != ViewportType::Visual" ")"); do { *((volatile int*)__null) = 7747; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7748 | } | 
| 7749 | } | 
| 7750 | |
| 7751 | if (isTransformed || zoomedContentRoot) { | 
| 7752 | MOZ_ASSERT(GetParent())do { static_assert( mozilla::detail::AssertionConditionType< decltype(GetParent())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(GetParent()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("GetParent()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7752); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetParent()" ")"); do { *((volatile int*)__null) = 7752; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7753 | Matrix4x4Flagged result; | 
| 7754 | int32_t scaleFactor = | 
| 7755 | ((aFlags & IN_CSS_UNITS) ? AppUnitsPerCSSPixel() | 
| 7756 | : PresContext()->AppUnitsPerDevPixel()); | 
| 7757 | |
| 7758 | /* Compute the delta to the parent, which we need because we are converting | 
| 7759 | * coordinates to our parent. | 
| 7760 | */ | 
| 7761 | if (isTransformed) { | 
| 7762 | // Note: this converts from Matrix4x4 to Matrix4x4Flagged. | 
| 7763 | result = nsDisplayTransform::GetResultingTransformMatrix( | 
| 7764 | this, nsPoint(), scaleFactor, | 
| 7765 | nsDisplayTransform::INCLUDE_PERSPECTIVE); | 
| 7766 | } | 
| 7767 | |
| 7768 | // The offset from a zoomed content root to its parent (e.g. from | 
| 7769 | // a canvas frame to a scroll frame) is in layout coordinates, so | 
| 7770 | // apply it before applying any layout-to-visual transform. | 
| 7771 | *aOutAncestor = GetParent(); | 
| 7772 | nsPoint delta = GetPosition(); | 
| 7773 | /* Combine the raw transform with a translation to our parent. */ | 
| 7774 | result.PostTranslate(NSAppUnitsToFloatPixels(delta.x, scaleFactor), | 
| 7775 | NSAppUnitsToFloatPixels(delta.y, scaleFactor), 0.0f); | 
| 7776 | |
| 7777 | if (zoomedContentRoot) { | 
| 7778 | Matrix4x4Flagged layoutToVisual; | 
| 7779 | if (aFlags & nsIFrame::IN_CSS_UNITS) { | 
| 7780 | layoutToVisual = ViewportUtils::GetVisualToLayoutTransform( | 
| 7781 | zoomedContentRoot->GetContent()) | 
| 7782 | .Inverse() | 
| 7783 | .ToUnknownMatrix(); | 
| 7784 | } else { | 
| 7785 | layoutToVisual = | 
| 7786 | ViewportUtils::GetVisualToLayoutTransform<LayoutDevicePixel>( | 
| 7787 | zoomedContentRoot->GetContent()) | 
| 7788 | .Inverse() | 
| 7789 | .ToUnknownMatrix(); | 
| 7790 | } | 
| 7791 | result = result * layoutToVisual; | 
| 7792 | } | 
| 7793 | |
| 7794 | return result; | 
| 7795 | } | 
| 7796 | |
| 7797 | // We are not transformed, so the returned transform is just going to be a | 
| 7798 | // translation up to whatever ancestor we decide to stop at. | 
| 7799 | |
| 7800 | nsPoint crossdocOffset; | 
| 7801 | *aOutAncestor = | 
| 7802 | nsLayoutUtils::GetCrossDocParentFrameInProcess(this, &crossdocOffset); | 
| 7803 | |
| 7804 | /* Otherwise, we're not transformed. In that case, we'll walk up the frame | 
| 7805 | * tree until we either hit the root frame or something that may be | 
| 7806 | * transformed. We'll then change coordinates into that frame, since we're | 
| 7807 | * guaranteed that nothing in-between can be transformed. First, however, | 
| 7808 | * we have to check to see if we have a parent. If not, we'll set the | 
| 7809 | * outparam to null (indicating that there's nothing left) and will hand back | 
| 7810 | * the identity matrix. | 
| 7811 | */ | 
| 7812 | if (!*aOutAncestor) { | 
| 7813 | return Matrix4x4Flagged(); | 
| 7814 | } | 
| 7815 | |
| 7816 | /* Keep iterating while the frame can't possibly be transformed. */ | 
| 7817 | const nsIFrame* current = this; | 
| 7818 | auto shouldStopAt = [](const nsIFrame* aCurrent, RelativeTo& aStopAtAncestor, | 
| 7819 | nsIFrame* aOutAncestor, uint32_t aFlags) { | 
| 7820 | return aOutAncestor->IsTransformed() || | 
| 7821 | ((aStopAtAncestor.mViewportType == ViewportType::Visual) && | 
| 7822 | ViewportUtils::IsZoomedContentRoot(aOutAncestor)) || | 
| 7823 | ((aFlags & STOP_AT_STACKING_CONTEXT_AND_DISPLAY_PORT) && | 
| 7824 | (aOutAncestor->IsStackingContext() || | 
| 7825 | DisplayPortUtils::FrameHasDisplayPort(aOutAncestor, aCurrent))); | 
| 7826 | }; | 
| 7827 | |
| 7828 | // We run the GetOffsetToCrossDoc code here as an optimization, instead of | 
| 7829 | // walking the parent chain here and then asking GetOffsetToCrossDoc to walk | 
| 7830 | // the same parent chain and compute the offset. | 
| 7831 | const int32_t finalAPD = PresContext()->AppUnitsPerDevPixel(); | 
| 7832 | // offset accumulates the offset at finalAPD. | 
| 7833 | nsPoint offset = GetPosition(); | 
| 7834 | |
| 7835 | int32_t currAPD = (*aOutAncestor)->PresContext()->AppUnitsPerDevPixel(); | 
| 7836 | // docOffset accumulates the current offset at currAPD, and then flushes to | 
| 7837 | // offset at finalAPD when the APD changes or we finish. | 
| 7838 | nsPoint docOffset = crossdocOffset; | 
| 7839 | MOZ_ASSERT(crossdocOffset == nsPoint(0, 0) || !GetParent())do { static_assert( mozilla::detail::AssertionConditionType< decltype(crossdocOffset == nsPoint(0, 0) || !GetParent())> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(crossdocOffset == nsPoint(0, 0) || !GetParent()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("crossdocOffset == nsPoint(0, 0) || !GetParent()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7839); AnnotateMozCrashReason("MOZ_ASSERT" "(" "crossdocOffset == nsPoint(0, 0) || !GetParent()" ")"); do { *((volatile int*)__null) = 7839; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7840 | |
| 7841 | while (*aOutAncestor != aStopAtAncestor.mFrame && | 
| 7842 | !shouldStopAt(current, aStopAtAncestor, *aOutAncestor, aFlags)) { | 
| 7843 | docOffset += (*aOutAncestor)->GetPosition(); | 
| 7844 | |
| 7845 | nsIFrame* parent = (*aOutAncestor)->GetParent(); | 
| 7846 | if (!parent) { | 
| 7847 | crossdocOffset.x = crossdocOffset.y = 0; | 
| 7848 | parent = nsLayoutUtils::GetCrossDocParentFrameInProcess(*aOutAncestor, | 
| 7849 | &crossdocOffset); | 
| 7850 | |
| 7851 | int32_t newAPD = | 
| 7852 | parent ? parent->PresContext()->AppUnitsPerDevPixel() : currAPD; | 
| 7853 | if (!parent || newAPD != currAPD) { | 
| 7854 | // Convert docOffset to finalAPD and add it to offset. | 
| 7855 | offset += docOffset.ScaleToOtherAppUnits(currAPD, finalAPD); | 
| 7856 | docOffset.x = docOffset.y = 0; | 
| 7857 | } | 
| 7858 | currAPD = newAPD; | 
| 7859 | docOffset += crossdocOffset; | 
| 7860 | |
| 7861 | if (!parent) { | 
| 7862 | break; | 
| 7863 | } | 
| 7864 | } | 
| 7865 | |
| 7866 | current = *aOutAncestor; | 
| 7867 | *aOutAncestor = parent; | 
| 7868 | } | 
| 7869 | offset += docOffset.ScaleToOtherAppUnits(currAPD, finalAPD); | 
| 7870 | |
| 7871 | NS_ASSERTION(*aOutAncestor, "Somehow ended up with a null ancestor...?")do { if (!(*aOutAncestor)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "Somehow ended up with a null ancestor...?", "*aOutAncestor" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7871); MOZ_PretendNoReturn(); } } while (0); | 
| 7872 | |
| 7873 | int32_t scaleFactor = | 
| 7874 | ((aFlags & IN_CSS_UNITS) ? AppUnitsPerCSSPixel() | 
| 7875 | : PresContext()->AppUnitsPerDevPixel()); | 
| 7876 | return Matrix4x4Flagged::Translation2d( | 
| 7877 | NSAppUnitsToFloatPixels(offset.x, scaleFactor), | 
| 7878 | NSAppUnitsToFloatPixels(offset.y, scaleFactor)); | 
| 7879 | } | 
| 7880 | |
| 7881 | static void InvalidateRenderingObservers(nsIFrame* aDisplayRoot, | 
| 7882 | nsIFrame* aFrame, | 
| 7883 | bool aFrameChanged = true) { | 
| 7884 | MOZ_ASSERT(aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame))do { static_assert( mozilla::detail::AssertionConditionType< decltype(aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7884); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame)" ")"); do { *((volatile int*)__null) = 7884; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7885 | SVGObserverUtils::InvalidateDirectRenderingObservers(aFrame); | 
| 7886 | nsIFrame* parent = aFrame; | 
| 7887 | while (parent != aDisplayRoot && | 
| 7888 | (parent = nsLayoutUtils::GetCrossDocParentFrameInProcess(parent)) && | 
| 7889 | !parent->HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) { | 
| 7890 | SVGObserverUtils::InvalidateDirectRenderingObservers(parent); | 
| 7891 | } | 
| 7892 | |
| 7893 | if (!aFrameChanged) { | 
| 7894 | return; | 
| 7895 | } | 
| 7896 | |
| 7897 | aFrame->MarkNeedsDisplayItemRebuild(); | 
| 7898 | } | 
| 7899 | |
| 7900 | static void SchedulePaintInternal( | 
| 7901 | nsIFrame* aDisplayRoot, nsIFrame* aFrame, | 
| 7902 | nsIFrame::PaintType aType = nsIFrame::PAINT_DEFAULT) { | 
| 7903 | MOZ_ASSERT(aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame))do { static_assert( mozilla::detail::AssertionConditionType< decltype(aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7903); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDisplayRoot == nsLayoutUtils::GetDisplayRootFrame(aFrame)" ")"); do { *((volatile int*)__null) = 7903; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 7904 | nsPresContext* pres = aDisplayRoot->PresContext()->GetRootPresContext(); | 
| 7905 | |
| 7906 | // No need to schedule a paint for an external document since they aren't | 
| 7907 | // painted directly. | 
| 7908 | if (!pres || (pres->Document() && pres->Document()->IsResourceDoc())) { | 
| 7909 | return; | 
| 7910 | } | 
| 7911 | if (!pres->GetContainerWeak()) { | 
| 7912 | NS_WARNING("Shouldn't call SchedulePaint in a detached pres context")NS_DebugBreak(NS_DEBUG_WARNING, "Shouldn't call SchedulePaint in a detached pres context" , nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 7912); | 
| 7913 | return; | 
| 7914 | } | 
| 7915 | |
| 7916 | pres->PresShell()->ScheduleViewManagerFlush(); | 
| 7917 | |
| 7918 | if (aType == nsIFrame::PAINT_DEFAULT) { | 
| 7919 | aDisplayRoot->AddStateBits(NS_FRAME_UPDATE_LAYER_TREE); | 
| 7920 | } | 
| 7921 | } | 
| 7922 | |
| 7923 | static void InvalidateFrameInternal(nsIFrame* aFrame, bool aHasDisplayItem, | 
| 7924 | bool aRebuildDisplayItems) { | 
| 7925 | if (aHasDisplayItem) { | 
| 7926 | aFrame->AddStateBits(NS_FRAME_NEEDS_PAINT); | 
| 7927 | } | 
| 7928 | |
| 7929 | if (aRebuildDisplayItems) { | 
| 7930 | aFrame->MarkNeedsDisplayItemRebuild(); | 
| 7931 | } | 
| 7932 | SVGObserverUtils::InvalidateDirectRenderingObservers(aFrame); | 
| 7933 | bool needsSchedulePaint = false; | 
| 7934 | if (nsLayoutUtils::IsPopup(aFrame)) { | 
| 7935 | needsSchedulePaint = true; | 
| 7936 | } else { | 
| 7937 | nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrameInProcess(aFrame); | 
| 7938 | while (parent && | 
| 7939 | !parent->HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) { | 
| 7940 | if (aHasDisplayItem && !parent->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { | 
| 7941 | parent->AddStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT); | 
| 7942 | } | 
| 7943 | SVGObserverUtils::InvalidateDirectRenderingObservers(parent); | 
| 7944 | |
| 7945 | // If we're inside a popup, then we need to make sure that we | 
| 7946 | // call schedule paint so that the NS_FRAME_UPDATE_LAYER_TREE | 
| 7947 | // flag gets added to the popup display root frame. | 
| 7948 | if (nsLayoutUtils::IsPopup(parent)) { | 
| 7949 | needsSchedulePaint = true; | 
| 7950 | break; | 
| 7951 | } | 
| 7952 | parent = nsLayoutUtils::GetCrossDocParentFrameInProcess(parent); | 
| 7953 | } | 
| 7954 | if (!parent) { | 
| 7955 | needsSchedulePaint = true; | 
| 7956 | } | 
| 7957 | } | 
| 7958 | if (!aHasDisplayItem) { | 
| 7959 | return; | 
| 7960 | } | 
| 7961 | if (needsSchedulePaint) { | 
| 7962 | nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(aFrame); | 
| 7963 | SchedulePaintInternal(displayRoot, aFrame); | 
| 7964 | } | 
| 7965 | if (aFrame->HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { | 
| 7966 | aFrame->RemoveProperty(nsIFrame::InvalidationRect()); | 
| 7967 | aFrame->RemoveStateBits(NS_FRAME_HAS_INVALID_RECT); | 
| 7968 | } | 
| 7969 | } | 
| 7970 | |
| 7971 | void nsIFrame::InvalidateFrameSubtree(bool aRebuildDisplayItems /* = true */) { | 
| 7972 | InvalidateFrame(0, aRebuildDisplayItems); | 
| 7973 | |
| 7974 | if (HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT)) { | 
| 7975 | return; | 
| 7976 | } | 
| 7977 | |
| 7978 | AddStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT); | 
| 7979 | |
| 7980 | for (const auto& childList : CrossDocChildLists()) { | 
| 7981 | for (nsIFrame* child : childList.mList) { | 
| 7982 | // Don't explicitly rebuild display items for our descendants, | 
| 7983 | // since we should be marked and it implicitly includes all | 
| 7984 | // descendants. | 
| 7985 | child->InvalidateFrameSubtree(false); | 
| 7986 | } | 
| 7987 | } | 
| 7988 | } | 
| 7989 | |
| 7990 | void nsIFrame::ClearInvalidationStateBits() { | 
| 7991 | if (HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) { | 
| 7992 | for (const auto& childList : CrossDocChildLists()) { | 
| 7993 | for (nsIFrame* child : childList.mList) { | 
| 7994 | child->ClearInvalidationStateBits(); | 
| 7995 | } | 
| 7996 | } | 
| 7997 | } | 
| 7998 | |
| 7999 | RemoveStateBits(NS_FRAME_NEEDS_PAINT | NS_FRAME_DESCENDANT_NEEDS_PAINT | | 
| 8000 | NS_FRAME_ALL_DESCENDANTS_NEED_PAINT); | 
| 8001 | } | 
| 8002 | |
| 8003 | bool HasRetainedDataFor(const nsIFrame* aFrame, uint32_t aDisplayItemKey) { | 
| 8004 | if (RefPtr<WebRenderUserData> data = | 
| 8005 | GetWebRenderUserData<WebRenderFallbackData>(aFrame, | 
| 8006 | aDisplayItemKey)) { | 
| 8007 | return true; | 
| 8008 | } | 
| 8009 | |
| 8010 | return false; | 
| 8011 | } | 
| 8012 | |
| 8013 | void nsIFrame::InvalidateFrame(uint32_t aDisplayItemKey, | 
| 8014 | bool aRebuildDisplayItems /* = true */) { | 
| 8015 | bool hasDisplayItem = | 
| 8016 | !aDisplayItemKey || HasRetainedDataFor(this, aDisplayItemKey); | 
| 8017 | InvalidateFrameInternal(this, hasDisplayItem, aRebuildDisplayItems); | 
| 8018 | } | 
| 8019 | |
| 8020 | void nsIFrame::InvalidateFrameWithRect(const nsRect& aRect, | 
| 8021 | uint32_t aDisplayItemKey, | 
| 8022 | bool aRebuildDisplayItems /* = true */) { | 
| 8023 | if (aRect.IsEmpty()) { | 
| 8024 | return; | 
| 8025 | } | 
| 8026 | bool hasDisplayItem = | 
| 8027 | !aDisplayItemKey || HasRetainedDataFor(this, aDisplayItemKey); | 
| 8028 | bool alreadyInvalid = false; | 
| 8029 | if (!HasAnyStateBits(NS_FRAME_NEEDS_PAINT)) { | 
| 8030 | InvalidateFrameInternal(this, hasDisplayItem, aRebuildDisplayItems); | 
| 8031 | } else { | 
| 8032 | alreadyInvalid = true; | 
| 8033 | } | 
| 8034 | |
| 8035 | if (!hasDisplayItem) { | 
| 8036 | return; | 
| 8037 | } | 
| 8038 | |
| 8039 | nsRect* rect; | 
| 8040 | if (HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { | 
| 8041 | rect = GetProperty(InvalidationRect()); | 
| 8042 | MOZ_ASSERT(rect)do { static_assert( mozilla::detail::AssertionConditionType< decltype(rect)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(rect))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("rect", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8042); AnnotateMozCrashReason("MOZ_ASSERT" "(" "rect" ")"); do { *((volatile int*)__null) = 8042; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8043 | } else { | 
| 8044 | if (alreadyInvalid) { | 
| 8045 | return; | 
| 8046 | } | 
| 8047 | rect = new nsRect(); | 
| 8048 | AddProperty(InvalidationRect(), rect); | 
| 8049 | AddStateBits(NS_FRAME_HAS_INVALID_RECT); | 
| 8050 | } | 
| 8051 | |
| 8052 | *rect = rect->Union(aRect); | 
| 8053 | } | 
| 8054 | |
| 8055 | bool nsIFrame::IsInvalid(nsRect& aRect) { | 
| 8056 | if (!HasAnyStateBits(NS_FRAME_NEEDS_PAINT)) { | 
| 8057 | return false; | 
| 8058 | } | 
| 8059 | |
| 8060 | if (HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { | 
| 8061 | nsRect* rect = GetProperty(InvalidationRect()); | 
| 8062 | NS_ASSERTION(do { if (!(rect)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Must have an invalid rect if NS_FRAME_HAS_INVALID_RECT is set!" , "rect", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8063); MOZ_PretendNoReturn(); } } while (0) | 
| 8063 | rect, "Must have an invalid rect if NS_FRAME_HAS_INVALID_RECT is set!")do { if (!(rect)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Must have an invalid rect if NS_FRAME_HAS_INVALID_RECT is set!" , "rect", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8063); MOZ_PretendNoReturn(); } } while (0); | 
| 8064 | aRect = *rect; | 
| 8065 | } else { | 
| 8066 | aRect.SetEmpty(); | 
| 8067 | } | 
| 8068 | return true; | 
| 8069 | } | 
| 8070 | |
| 8071 | void nsIFrame::SchedulePaint(PaintType aType, bool aFrameChanged) { | 
| 8072 | if (PresShell()->IsPaintingSuppressed()) { | 
| 8073 | // We can't have any display items yet, and when we unsuppress we will | 
| 8074 | // invalidate the root frame. | 
| 8075 | return; | 
| 8076 | } | 
| 8077 | nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(this); | 
| 8078 | InvalidateRenderingObservers(displayRoot, this, aFrameChanged); | 
| 8079 | SchedulePaintInternal(displayRoot, this, aType); | 
| 8080 | } | 
| 8081 | |
| 8082 | void nsIFrame::SchedulePaintWithoutInvalidatingObservers(PaintType aType) { | 
| 8083 | nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(this); | 
| 8084 | SchedulePaintInternal(displayRoot, this, aType); | 
| 8085 | } | 
| 8086 | |
| 8087 | void nsIFrame::InvalidateLayer(DisplayItemType aDisplayItemKey, | 
| 8088 | const nsIntRect* aDamageRect, | 
| 8089 | const nsRect* aFrameDamageRect, | 
| 8090 | uint32_t aFlags /* = 0 */) { | 
| 8091 | NS_ASSERTION(aDisplayItemKey > DisplayItemType::TYPE_ZERO, "Need a key")do { if (!(aDisplayItemKey > DisplayItemType::TYPE_ZERO)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Need a key", "aDisplayItemKey > DisplayItemType::TYPE_ZERO" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8091); MOZ_PretendNoReturn(); } } while (0); | 
| 8092 | |
| 8093 | nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(this); | 
| 8094 | InvalidateRenderingObservers(displayRoot, this, false); | 
| 8095 | |
| 8096 | // Check if frame supports WebRender's async update | 
| 8097 | if ((aFlags & UPDATE_IS_ASYNC) && | 
| 8098 | WebRenderUserData::SupportsAsyncUpdate(this)) { | 
| 8099 | // WebRender does not use layer, then return nullptr. | 
| 8100 | return; | 
| 8101 | } | 
| 8102 | |
| 8103 | if (aFrameDamageRect && aFrameDamageRect->IsEmpty()) { | 
| 8104 | return; | 
| 8105 | } | 
| 8106 | |
| 8107 | // In the bug 930056, dialer app startup but not shown on the | 
| 8108 | // screen because sometimes we don't have any retainned data | 
| 8109 | // for remote type displayitem and thus Repaint event is not | 
| 8110 | // triggered. So, always invalidate in this case. | 
| 8111 | DisplayItemType displayItemKey = aDisplayItemKey; | 
| 8112 | if (aDisplayItemKey == DisplayItemType::TYPE_REMOTE) { | 
| 8113 | displayItemKey = DisplayItemType::TYPE_ZERO; | 
| 8114 | } | 
| 8115 | |
| 8116 | if (aFrameDamageRect) { | 
| 8117 | InvalidateFrameWithRect(*aFrameDamageRect, | 
| 8118 | static_cast<uint32_t>(displayItemKey)); | 
| 8119 | } else { | 
| 8120 | InvalidateFrame(static_cast<uint32_t>(displayItemKey)); | 
| 8121 | } | 
| 8122 | } | 
| 8123 | |
| 8124 | static nsRect ComputeEffectsRect(nsIFrame* aFrame, const nsRect& aOverflowRect, | 
| 8125 | const nsSize& aNewSize) { | 
| 8126 | nsRect r = aOverflowRect; | 
| 8127 | |
| 8128 | if (aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { | 
| 8129 | // For SVG frames, we only need to account for filters. | 
| 8130 | // TODO: We could also take account of clipPath and mask to reduce the | 
| 8131 | // ink overflow, but that's not essential. | 
| 8132 | if (aFrame->StyleEffects()->HasFilters()) { | 
| 8133 | SetOrUpdateRectValuedProperty(aFrame, nsIFrame::PreEffectsBBoxProperty(), | 
| 8134 | r); | 
| 8135 | r = SVGUtils::GetPostFilterInkOverflowRect(aFrame, aOverflowRect); | 
| 8136 | } | 
| 8137 | return r; | 
| 8138 | } | 
| 8139 | |
| 8140 | // box-shadow | 
| 8141 | r.UnionRect(r, nsLayoutUtils::GetBoxShadowRectForFrame(aFrame, aNewSize)); | 
| 8142 | |
| 8143 | // border-image-outset. | 
| 8144 | // We need to include border-image-outset because it can cause the | 
| 8145 | // border image to be drawn beyond the border box. | 
| 8146 | |
| 8147 | // (1) It's important we not check whether there's a border-image | 
| 8148 | // since the style hint for a change in border image doesn't cause | 
| 8149 | // reflow, and that's probably more important than optimizing the | 
| 8150 | // overflow areas for the silly case of border-image-outset without | 
| 8151 | // border-image | 
| 8152 | // (2) It's important that we not check whether the border-image | 
| 8153 | // is actually loaded, since that would require us to reflow when | 
| 8154 | // the image loads. | 
| 8155 | const nsStyleBorder* styleBorder = aFrame->StyleBorder(); | 
| 8156 | nsMargin outsetMargin = styleBorder->GetImageOutset(); | 
| 8157 | |
| 8158 | if (outsetMargin != nsMargin(0, 0, 0, 0)) { | 
| 8159 | nsRect outsetRect(nsPoint(0, 0), aNewSize); | 
| 8160 | outsetRect.Inflate(outsetMargin); | 
| 8161 | r.UnionRect(r, outsetRect); | 
| 8162 | } | 
| 8163 | |
| 8164 | // Note that we don't remove the outlineInnerRect if a frame loses outline | 
| 8165 | // style. That would require an extra property lookup for every frame, | 
| 8166 | // or a new frame state bit to track whether a property had been stored, | 
| 8167 | // or something like that. It's not worth doing that here. At most it's | 
| 8168 | // only one heap-allocated rect per frame and it will be cleaned up when | 
| 8169 | // the frame dies. | 
| 8170 | |
| 8171 | if (SVGIntegrationUtils::UsingOverflowAffectingEffects(aFrame)) { | 
| 8172 | SetOrUpdateRectValuedProperty(aFrame, nsIFrame::PreEffectsBBoxProperty(), | 
| 8173 | r); | 
| 8174 | r = SVGIntegrationUtils::ComputePostEffectsInkOverflowRect(aFrame, r); | 
| 8175 | } | 
| 8176 | |
| 8177 | return r; | 
| 8178 | } | 
| 8179 | |
| 8180 | void nsIFrame::SetPosition(const nsPoint& aPt) { | 
| 8181 | if (mRect.TopLeft() == aPt) { | 
| 8182 | return; | 
| 8183 | } | 
| 8184 | mRect.MoveTo(aPt); | 
| 8185 | MarkNeedsDisplayItemRebuild(); | 
| 8186 | } | 
| 8187 | |
| 8188 | void nsIFrame::MovePositionBy(const nsPoint& aTranslation) { | 
| 8189 | nsPoint position = GetNormalPosition() + aTranslation; | 
| 8190 | |
| 8191 | const nsMargin* computedOffsets = nullptr; | 
| 8192 | if (IsRelativelyOrStickyPositioned()) { | 
| 8193 | computedOffsets = GetProperty(nsIFrame::ComputedOffsetProperty()); | 
| 8194 | } | 
| 8195 | ReflowInput::ApplyRelativePositioning( | 
| 8196 | this, computedOffsets ? *computedOffsets : nsMargin(), &position); | 
| 8197 | SetPosition(position); | 
| 8198 | } | 
| 8199 | |
| 8200 | nsRect nsIFrame::GetNormalRect() const { | 
| 8201 | // It might be faster to first check | 
| 8202 | // StyleDisplay()->IsRelativelyPositionedStyle(). | 
| 8203 | bool hasProperty; | 
| 8204 | nsPoint normalPosition = GetProperty(NormalPositionProperty(), &hasProperty); | 
| 8205 | if (hasProperty) { | 
| 8206 | return nsRect(normalPosition, GetSize()); | 
| 8207 | } | 
| 8208 | return GetRect(); | 
| 8209 | } | 
| 8210 | |
| 8211 | nsRect nsIFrame::GetBoundingClientRect() { | 
| 8212 | return nsLayoutUtils::GetAllInFlowRectsUnion( | 
| 8213 | this, nsLayoutUtils::GetContainingBlockForClientRect(this), | 
| 8214 | nsLayoutUtils::GetAllInFlowRectsFlag::AccountForTransforms); | 
| 8215 | } | 
| 8216 | |
| 8217 | nsPoint nsIFrame::GetPositionIgnoringScrolling() const { | 
| 8218 | return GetParent() ? GetParent()->GetPositionOfChildIgnoringScrolling(this) | 
| 8219 | : GetPosition(); | 
| 8220 | } | 
| 8221 | |
| 8222 | nsRect nsIFrame::GetOverflowRect(OverflowType aType) const { | 
| 8223 | // Note that in some cases the overflow area might not have been | 
| 8224 | // updated (yet) to reflect any outline set on the frame or the area | 
| 8225 | // of child frames. That's OK because any reflow that updates these | 
| 8226 | // areas will invalidate the appropriate area, so any (mis)uses of | 
| 8227 | // this method will be fixed up. | 
| 8228 | |
| 8229 | if (mOverflow.mType == OverflowStorageType::Large) { | 
| 8230 | // there is an overflow rect, and it's not stored as deltas but as | 
| 8231 | // a separately-allocated rect | 
| 8232 | return GetOverflowAreasProperty()->Overflow(aType); | 
| 8233 | } | 
| 8234 | |
| 8235 | if (aType == OverflowType::Ink && | 
| 8236 | mOverflow.mType != OverflowStorageType::None) { | 
| 8237 | return InkOverflowFromDeltas(); | 
| 8238 | } | 
| 8239 | |
| 8240 | return GetRectRelativeToSelf(); | 
| 8241 | } | 
| 8242 | |
| 8243 | OverflowAreas nsIFrame::GetOverflowAreas() const { | 
| 8244 | if (mOverflow.mType == OverflowStorageType::Large) { | 
| 8245 | // there is an overflow rect, and it's not stored as deltas but as | 
| 8246 | // a separately-allocated rect | 
| 8247 | return *GetOverflowAreasProperty(); | 
| 8248 | } | 
| 8249 | |
| 8250 | return OverflowAreas(InkOverflowFromDeltas(), | 
| 8251 | nsRect(nsPoint(0, 0), GetSize())); | 
| 8252 | } | 
| 8253 | |
| 8254 | OverflowAreas nsIFrame::GetOverflowAreasRelativeToSelf() const { | 
| 8255 | if (IsTransformed()) { | 
| 8256 | if (OverflowAreas* preTransformOverflows = | 
| 8257 | GetProperty(PreTransformOverflowAreasProperty())) { | 
| 8258 | return *preTransformOverflows; | 
| 8259 | } | 
| 8260 | } | 
| 8261 | return GetOverflowAreas(); | 
| 8262 | } | 
| 8263 | |
| 8264 | OverflowAreas nsIFrame::GetOverflowAreasRelativeToParent() const { | 
| 8265 | return GetOverflowAreas() + GetPosition(); | 
| 8266 | } | 
| 8267 | |
| 8268 | OverflowAreas nsIFrame::GetActualAndNormalOverflowAreasRelativeToParent() | 
| 8269 | const { | 
| 8270 | if (MOZ_LIKELY(!IsRelativelyOrStickyPositioned())(__builtin_expect(!!(!IsRelativelyOrStickyPositioned()), 1))) { | 
| 8271 | return GetOverflowAreasRelativeToParent(); | 
| 8272 | } | 
| 8273 | |
| 8274 | const OverflowAreas overflows = GetOverflowAreas(); | 
| 8275 | OverflowAreas actualAndNormalOverflows = overflows + GetNormalPosition(); | 
| 8276 | if (IsRelativelyPositioned()) { | 
| 8277 | actualAndNormalOverflows.UnionWith(overflows + GetPosition()); | 
| 8278 | } else { | 
| 8279 | // For sticky positioned elements, we only use the normal position for the | 
| 8280 | // scrollable overflow. This avoids circular dependencies between sticky | 
| 8281 | // positioned elements and their scroll container. (The scroll position and | 
| 8282 | // the scroll container's size impact the sticky position, so we don't want | 
| 8283 | // the sticky position to impact them.) | 
| 8284 | MOZ_ASSERT(IsStickyPositioned())do { static_assert( mozilla::detail::AssertionConditionType< decltype(IsStickyPositioned())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(IsStickyPositioned()))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("IsStickyPositioned()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8284); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsStickyPositioned()" ")"); do { *((volatile int*)__null) = 8284; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8285 | actualAndNormalOverflows.UnionWith( | 
| 8286 | OverflowAreas(overflows.InkOverflow() + GetPosition(), nsRect())); | 
| 8287 | } | 
| 8288 | return actualAndNormalOverflows; | 
| 8289 | } | 
| 8290 | |
| 8291 | nsRect nsIFrame::ScrollableOverflowRectRelativeToParent() const { | 
| 8292 | return ScrollableOverflowRect() + GetPosition(); | 
| 8293 | } | 
| 8294 | |
| 8295 | nsRect nsIFrame::InkOverflowRectRelativeToParent() const { | 
| 8296 | return InkOverflowRect() + GetPosition(); | 
| 8297 | } | 
| 8298 | |
| 8299 | nsRect nsIFrame::ScrollableOverflowRectRelativeToSelf() const { | 
| 8300 | if (IsTransformed()) { | 
| 8301 | if (OverflowAreas* preTransformOverflows = | 
| 8302 | GetProperty(PreTransformOverflowAreasProperty())) { | 
| 8303 | return preTransformOverflows->ScrollableOverflow(); | 
| 8304 | } | 
| 8305 | } | 
| 8306 | return ScrollableOverflowRect(); | 
| 8307 | } | 
| 8308 | |
| 8309 | nsRect nsIFrame::InkOverflowRectRelativeToSelf() const { | 
| 8310 | if (IsTransformed()) { | 
| 8311 | if (OverflowAreas* preTransformOverflows = | 
| 8312 | GetProperty(PreTransformOverflowAreasProperty())) { | 
| 8313 | return preTransformOverflows->InkOverflow(); | 
| 8314 | } | 
| 8315 | } | 
| 8316 | return InkOverflowRect(); | 
| 8317 | } | 
| 8318 | |
| 8319 | nsRect nsIFrame::PreEffectsInkOverflowRect() const { | 
| 8320 | nsRect* r = GetProperty(nsIFrame::PreEffectsBBoxProperty()); | 
| 8321 | return r ? *r : InkOverflowRectRelativeToSelf(); | 
| 8322 | } | 
| 8323 | |
| 8324 | bool nsIFrame::UpdateOverflow() { | 
| 8325 | MOZ_ASSERT(FrameMaintainsOverflow(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(FrameMaintainsOverflow())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(FrameMaintainsOverflow()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("FrameMaintainsOverflow()" " (" "Non-display SVG do not maintain ink overflow rects" ")" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8326); AnnotateMozCrashReason("MOZ_ASSERT" "(" "FrameMaintainsOverflow()" ") (" "Non-display SVG do not maintain ink overflow rects" ")" ); do { *((volatile int*)__null) = 8326; __attribute__((nomerge )) ::abort(); } while (false); } } while (false) | 
| 8326 | "Non-display SVG do not maintain ink overflow rects")do { static_assert( mozilla::detail::AssertionConditionType< decltype(FrameMaintainsOverflow())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(FrameMaintainsOverflow()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("FrameMaintainsOverflow()" " (" "Non-display SVG do not maintain ink overflow rects" ")" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8326); AnnotateMozCrashReason("MOZ_ASSERT" "(" "FrameMaintainsOverflow()" ") (" "Non-display SVG do not maintain ink overflow rects" ")" ); do { *((volatile int*)__null) = 8326; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8327 | |
| 8328 | nsRect rect(nsPoint(0, 0), GetSize()); | 
| 8329 | OverflowAreas overflowAreas(rect, rect); | 
| 8330 | |
| 8331 | if (!ComputeCustomOverflow(overflowAreas)) { | 
| 8332 | // If updating overflow wasn't supported by this frame, then it should | 
| 8333 | // have scheduled any necessary reflows. We can return false to say nothing | 
| 8334 | // changed, and wait for reflow to correct it. | 
| 8335 | return false; | 
| 8336 | } | 
| 8337 | |
| 8338 | UnionChildOverflow(overflowAreas); | 
| 8339 | |
| 8340 | if (FinishAndStoreOverflow(overflowAreas, GetSize())) { | 
| 8341 | if (nsView* view = GetView()) { | 
| 8342 | // Make sure the frame's view is properly sized. | 
| 8343 | nsViewManager* vm = view->GetViewManager(); | 
| 8344 | vm->ResizeView(view, overflowAreas.InkOverflow()); | 
| 8345 | } | 
| 8346 | |
| 8347 | return true; | 
| 8348 | } | 
| 8349 | |
| 8350 | // Frames that combine their 3d transform with their ancestors | 
| 8351 | // only compute a pre-transform overflow rect, and then contribute | 
| 8352 | // to the normal overflow rect of the preserve-3d root. Always return | 
| 8353 | // true here so that we propagate changes up to the root for final | 
| 8354 | // calculation. | 
| 8355 | return Combines3DTransformWithAncestors(); | 
| 8356 | } | 
| 8357 | |
| 8358 | /* virtual */ | 
| 8359 | bool nsIFrame::ComputeCustomOverflow(OverflowAreas& aOverflowAreas) { | 
| 8360 | return true; | 
| 8361 | } | 
| 8362 | |
| 8363 | bool nsIFrame::DoesClipChildrenInBothAxes() const { | 
| 8364 | if (IsScrollContainerOrSubclass()) { | 
| 8365 | return true; | 
| 8366 | } | 
| 8367 | const nsStyleDisplay* display = StyleDisplay(); | 
| 8368 | if (display->IsContainPaint() && SupportsContainLayoutAndPaint()) { | 
| 8369 | return true; | 
| 8370 | } | 
| 8371 | return display->mOverflowX == StyleOverflow::Clip && | 
| 8372 | display->mOverflowY == StyleOverflow::Clip; | 
| 8373 | } | 
| 8374 | |
| 8375 | /* virtual */ | 
| 8376 | void nsIFrame::UnionChildOverflow(OverflowAreas& aOverflowAreas, | 
| 8377 | bool aAsIfScrolled) { | 
| 8378 | if (aAsIfScrolled || !DoesClipChildrenInBothAxes()) { | 
| 8379 | nsLayoutUtils::UnionChildOverflow(this, aOverflowAreas); | 
| 8380 | } | 
| 8381 | } | 
| 8382 | |
| 8383 | // Return true if this form control element's preferred size property (but not | 
| 8384 | // percentage max size property) contains a percentage value that should be | 
| 8385 | // resolved against zero when calculating its min-content contribution in the | 
| 8386 | // corresponding axis. | 
| 8387 | // | 
| 8388 | // For proper replaced elements, the percentage value in both their max size | 
| 8389 | // property or preferred size property should be resolved against zero. This is | 
| 8390 | // handled in IsPercentageResolvedAgainstZero(). | 
| 8391 | inline static bool FormControlShrinksForPercentSize(const nsIFrame* aFrame) { | 
| 8392 | if (!aFrame->IsReplaced()) { | 
| 8393 | // Quick test to reject most frames. | 
| 8394 | return false; | 
| 8395 | } | 
| 8396 | |
| 8397 | switch (aFrame->Type()) { | 
| 8398 | case LayoutFrameType::Meter: | 
| 8399 | case LayoutFrameType::Progress: | 
| 8400 | case LayoutFrameType::Range: | 
| 8401 | case LayoutFrameType::TextInput: | 
| 8402 | case LayoutFrameType::ColorControl: | 
| 8403 | case LayoutFrameType::ComboboxControl: | 
| 8404 | case LayoutFrameType::ListControl: | 
| 8405 | case LayoutFrameType::CheckboxRadio: | 
| 8406 | case LayoutFrameType::FileControl: | 
| 8407 | case LayoutFrameType::ImageControl: | 
| 8408 | return true; | 
| 8409 | default: | 
| 8410 | // Buttons (GfxButtonControl / HTMLButtonControl) don't have this | 
| 8411 | // shrinking behavior. (Note that color inputs do, even though they | 
| 8412 | // inherit from button, so we can't use do_QueryFrame here.) | 
| 8413 | return false; | 
| 8414 | } | 
| 8415 | } | 
| 8416 | |
| 8417 | bool nsIFrame::IsPercentageResolvedAgainstZero( | 
| 8418 | const StyleSize& aStyleSize, const StyleMaxSize& aStyleMaxSize) const { | 
| 8419 | const bool sizeHasPercent = aStyleSize.HasPercent(); | 
| 8420 | return ((sizeHasPercent || aStyleMaxSize.HasPercent()) && | 
| 8421 | HasReplacedSizing()) || | 
| 8422 | (sizeHasPercent && FormControlShrinksForPercentSize(this)); | 
| 8423 | } | 
| 8424 | |
| 8425 | // Summary of the Cyclic-Percentage Intrinsic Size Contribution Rules: | 
| 8426 | // | 
| 8427 | // Element Type | Replaced | Non-replaced | 
| 8428 | // Contribution Type | min-content max-content | min-content max-content | 
| 8429 | // --------------------------------------------------------------------------- | 
| 8430 | // min size | zero zero | zero zero | 
| 8431 | // max & preferred size | zero initial | initial initial | 
| 8432 | // | 
| 8433 | // https://drafts.csswg.org/css-sizing-3/#cyclic-percentage-contribution | 
| 8434 | bool nsIFrame::IsPercentageResolvedAgainstZero(const LengthPercentage& aSize, | 
| 8435 | SizeProperty aProperty) const { | 
| 8436 | // Early return to avoid calling the virtual function, IsFrameOfType(). | 
| 8437 | if (aProperty == SizeProperty::MinSize) { | 
| 8438 | return true; | 
| 8439 | } | 
| 8440 | |
| 8441 | const bool hasPercentOnReplaced = aSize.HasPercent() && HasReplacedSizing(); | 
| 8442 | if (aProperty == SizeProperty::MaxSize) { | 
| 8443 | return hasPercentOnReplaced; | 
| 8444 | } | 
| 8445 | |
| 8446 | MOZ_ASSERT(aProperty == SizeProperty::Size)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aProperty == SizeProperty::Size)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aProperty == SizeProperty::Size ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "aProperty == SizeProperty::Size", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8446); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aProperty == SizeProperty::Size" ")"); do { *((volatile int*)__null) = 8446; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8447 | return hasPercentOnReplaced || | 
| 8448 | (aSize.HasPercent() && FormControlShrinksForPercentSize(this)); | 
| 8449 | } | 
| 8450 | |
| 8451 | bool nsIFrame::IsBlockWrapper() const { | 
| 8452 | auto pseudoType = Style()->GetPseudoType(); | 
| 8453 | return pseudoType == PseudoStyleType::mozBlockInsideInlineWrapper || | 
| 8454 | pseudoType == PseudoStyleType::buttonContent || | 
| 8455 | pseudoType == PseudoStyleType::cellContent || | 
| 8456 | pseudoType == PseudoStyleType::columnSpanWrapper; | 
| 8457 | } | 
| 8458 | |
| 8459 | bool nsIFrame::IsBlockFrameOrSubclass() const { | 
| 8460 | const nsBlockFrame* thisAsBlock = do_QueryFrame(this); | 
| 8461 | return !!thisAsBlock; | 
| 8462 | } | 
| 8463 | |
| 8464 | bool nsIFrame::IsImageFrameOrSubclass() const { | 
| 8465 | const nsImageFrame* asImage = do_QueryFrame(this); | 
| 8466 | return !!asImage; | 
| 8467 | } | 
| 8468 | |
| 8469 | bool nsIFrame::IsScrollContainerOrSubclass() const { | 
| 8470 | const bool result = IsScrollContainerFrame() || IsListControlFrame(); | 
| 8471 | MOZ_ASSERT(result == !!QueryFrame(ScrollContainerFrame::kFrameIID))do { static_assert( mozilla::detail::AssertionConditionType< decltype(result == !!QueryFrame(ScrollContainerFrame::kFrameIID ))>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(result == !!QueryFrame(ScrollContainerFrame::kFrameIID )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("result == !!QueryFrame(ScrollContainerFrame::kFrameIID)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8471); AnnotateMozCrashReason("MOZ_ASSERT" "(" "result == !!QueryFrame(ScrollContainerFrame::kFrameIID)" ")"); do { *((volatile int*)__null) = 8471; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8472 | return result; | 
| 8473 | } | 
| 8474 | |
| 8475 | bool nsIFrame::IsSubgrid() const { | 
| 8476 | return IsGridContainerFrame() && | 
| 8477 | static_cast<const nsGridContainerFrame*>(this)->IsSubgrid(); | 
| 8478 | } | 
| 8479 | |
| 8480 | static nsIFrame* GetNearestBlockContainer(nsIFrame* frame) { | 
| 8481 | while (!frame->IsBlockContainer()) { | 
| 8482 | frame = frame->GetParent(); | 
| 8483 | NS_ASSERTION(do { if (!(frame)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "How come we got to the root frame without seeing a containing block?" , "frame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8485); MOZ_PretendNoReturn(); } } while (0) | 
| 8484 | frame,do { if (!(frame)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "How come we got to the root frame without seeing a containing block?" , "frame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8485); MOZ_PretendNoReturn(); } } while (0) | 
| 8485 | "How come we got to the root frame without seeing a containing block?")do { if (!(frame)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "How come we got to the root frame without seeing a containing block?" , "frame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8485); MOZ_PretendNoReturn(); } } while (0); | 
| 8486 | } | 
| 8487 | return frame; | 
| 8488 | } | 
| 8489 | |
| 8490 | bool nsIFrame::IsBlockContainer() const { | 
| 8491 | // The block wrappers we use to wrap blocks inside inlines aren't | 
| 8492 | // described in the CSS spec. We need to make them not be containing | 
| 8493 | // blocks. | 
| 8494 | // Since the parent of such a block is either a normal block or | 
| 8495 | // another such pseudo, this shouldn't cause anything bad to happen. | 
| 8496 | // Also the anonymous blocks inside table cells are not containing blocks. | 
| 8497 | // | 
| 8498 | // If we ever start skipping table row groups from being containing blocks, | 
| 8499 | // you need to remove the StickyScrollContainer hack referencing bug 1421660. | 
| 8500 | return !IsLineParticipant() && !IsBlockWrapper() && !IsSubgrid() && | 
| 8501 | // Table rows are not containing blocks either | 
| 8502 | !IsTableRowFrame(); | 
| 8503 | } | 
| 8504 | |
| 8505 | nsIFrame* nsIFrame::GetContainingBlock( | 
| 8506 | uint32_t aFlags, const nsStyleDisplay* aStyleDisplay) const { | 
| 8507 | MOZ_ASSERT(aStyleDisplay == StyleDisplay())do { static_assert( mozilla::detail::AssertionConditionType< decltype(aStyleDisplay == StyleDisplay())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aStyleDisplay == StyleDisplay ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aStyleDisplay == StyleDisplay()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8507); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aStyleDisplay == StyleDisplay()" ")"); do { *((volatile int*)__null) = 8507; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8508 | |
| 8509 | // Keep this in sync with MightBeContainingBlockFor in ReflowInput.cpp. | 
| 8510 | |
| 8511 | if (!GetParent()) { | 
| 8512 | return nullptr; | 
| 8513 | } | 
| 8514 | // MathML frames might have absolute positioning style, but they would | 
| 8515 | // still be in-flow. So we have to check to make sure that the frame | 
| 8516 | // is really out-of-flow too. | 
| 8517 | nsIFrame* f; | 
| 8518 | if (IsAbsolutelyPositioned(aStyleDisplay)) { | 
| 8519 | f = GetParent(); // the parent is always the containing block | 
| 8520 | } else { | 
| 8521 | f = GetNearestBlockContainer(GetParent()); | 
| 8522 | } | 
| 8523 | |
| 8524 | if (aFlags & SKIP_SCROLLED_FRAME && f && | 
| 8525 | f->Style()->GetPseudoType() == PseudoStyleType::scrolledContent) { | 
| 8526 | f = f->GetParent(); | 
| 8527 | } | 
| 8528 | return f; | 
| 8529 | } | 
| 8530 | |
| 8531 | #ifdef DEBUG_FRAME_DUMP1 | 
| 8532 | |
| 8533 | Maybe<uint32_t> nsIFrame::ContentIndexInContainer(const nsIFrame* aFrame) { | 
| 8534 | if (nsIContent* content = aFrame->GetContent()) { | 
| 8535 | return content->ComputeIndexInParentContent(); | 
| 8536 | } | 
| 8537 | return Nothing(); | 
| 8538 | } | 
| 8539 | |
| 8540 | nsAutoCString nsIFrame::ListTag() const { | 
| 8541 | nsAutoString tmp; | 
| 8542 | GetFrameName(tmp); | 
| 8543 | |
| 8544 | nsAutoCString tag; | 
| 8545 | tag += NS_ConvertUTF16toUTF8(tmp); | 
| 8546 | tag += nsPrintfCString("@%p", static_cast<const void*>(this)); | 
| 8547 | return tag; | 
| 8548 | } | 
| 8549 | |
| 8550 | std::string nsIFrame::ConvertToString(const LogicalRect& aRect, | 
| 8551 | const WritingMode aWM, ListFlags aFlags) { | 
| 8552 | if (aFlags.contains(ListFlag::DisplayInCSSPixels)) { | 
| 8553 | // Abuse CSSRect to store all LogicalRect's dimensions in CSS pixels. | 
| 8554 | return ToString(mozilla::CSSRect(CSSPixel::FromAppUnits(aRect.IStart(aWM)), | 
| 8555 | CSSPixel::FromAppUnits(aRect.BStart(aWM)), | 
| 8556 | CSSPixel::FromAppUnits(aRect.ISize(aWM)), | 
| 8557 | CSSPixel::FromAppUnits(aRect.BSize(aWM)))); | 
| 8558 | } | 
| 8559 | return ToString(aRect); | 
| 8560 | } | 
| 8561 | |
| 8562 | std::string nsIFrame::ConvertToString(const LogicalSize& aSize, | 
| 8563 | const WritingMode aWM, ListFlags aFlags) { | 
| 8564 | if (aFlags.contains(ListFlag::DisplayInCSSPixels)) { | 
| 8565 | // Abuse CSSSize to store all LogicalSize's dimensions in CSS pixels. | 
| 8566 | return ToString(CSSSize(CSSPixel::FromAppUnits(aSize.ISize(aWM)), | 
| 8567 | CSSPixel::FromAppUnits(aSize.BSize(aWM)))); | 
| 8568 | } | 
| 8569 | return ToString(aSize); | 
| 8570 | } | 
| 8571 | |
| 8572 | // Debugging | 
| 8573 | void nsIFrame::ListGeneric(nsACString& aTo, const char* aPrefix, | 
| 8574 | ListFlags aFlags) const { | 
| 8575 | aTo += aPrefix; | 
| 8576 | aTo += ListTag(); | 
| 8577 | if (HasView()) { | 
| 8578 | aTo += nsPrintfCString(" [view=%p]", static_cast<void*>(GetView())); | 
| 8579 | } | 
| 8580 | if (GetParent()) { | 
| 8581 | aTo += nsPrintfCString(" parent=%p", static_cast<void*>(GetParent())); | 
| 8582 | } | 
| 8583 | if (GetNextSibling()) { | 
| 8584 | aTo += nsPrintfCString(" next=%p", static_cast<void*>(GetNextSibling())); | 
| 8585 | } | 
| 8586 | if (GetPrevContinuation()) { | 
| 8587 | bool fluid = GetPrevInFlow() == GetPrevContinuation(); | 
| 8588 | aTo += nsPrintfCString(" prev-%s=%p", fluid ? "in-flow" : "continuation", | 
| 8589 | static_cast<void*>(GetPrevContinuation())); | 
| 8590 | } | 
| 8591 | if (GetNextContinuation()) { | 
| 8592 | bool fluid = GetNextInFlow() == GetNextContinuation(); | 
| 8593 | aTo += nsPrintfCString(" next-%s=%p", fluid ? "in-flow" : "continuation", | 
| 8594 | static_cast<void*>(GetNextContinuation())); | 
| 8595 | } | 
| 8596 | if (const nsAtom* const autoPageValue = | 
| 8597 | GetProperty(AutoPageValueProperty())) { | 
| 8598 | aTo += " AutoPage="; | 
| 8599 | aTo += nsAtomCString(autoPageValue); | 
| 8600 | } | 
| 8601 | if (const nsIFrame::PageValues* const pageValues = | 
| 8602 | GetProperty(PageValuesProperty())) { | 
| 8603 | aTo += " PageValues={"; | 
| 8604 | if (pageValues->mStartPageValue) { | 
| 8605 | aTo += nsAtomCString(pageValues->mStartPageValue); | 
| 8606 | } else { | 
| 8607 | aTo += "<null>"; | 
| 8608 | } | 
| 8609 | aTo += ", "; | 
| 8610 | if (pageValues->mEndPageValue) { | 
| 8611 | aTo += nsAtomCString(pageValues->mEndPageValue); | 
| 8612 | } else { | 
| 8613 | aTo += "<null>"; | 
| 8614 | } | 
| 8615 | aTo += "}"; | 
| 8616 | } | 
| 8617 | void* IBsibling = GetProperty(IBSplitSibling()); | 
| 8618 | if (IBsibling) { | 
| 8619 | aTo += nsPrintfCString(" IBSplitSibling=%p", IBsibling); | 
| 8620 | } | 
| 8621 | void* IBprevsibling = GetProperty(IBSplitPrevSibling()); | 
| 8622 | if (IBprevsibling) { | 
| 8623 | aTo += nsPrintfCString(" IBSplitPrevSibling=%p", IBprevsibling); | 
| 8624 | } | 
| 8625 | if (nsLayoutUtils::FontSizeInflationEnabled(PresContext())) { | 
| 8626 | if (HasAnyStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT)) { | 
| 8627 | aTo += nsPrintfCString(" FFR"); | 
| 8628 | if (nsFontInflationData* data = | 
| 8629 | nsFontInflationData::FindFontInflationDataFor(this)) { | 
| 8630 | aTo += nsPrintfCString( | 
| 8631 | ",enabled=%s,UIS=%s", data->InflationEnabled() ? "yes" : "no", | 
| 8632 | ConvertToString(data->UsableISize(), aFlags).c_str()); | 
| 8633 | } | 
| 8634 | } | 
| 8635 | if (HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER)) { | 
| 8636 | aTo += nsPrintfCString(" FIC"); | 
| 8637 | } | 
| 8638 | aTo += nsPrintfCString(" FI=%f", nsLayoutUtils::FontSizeInflationFor(this)); | 
| 8639 | } | 
| 8640 | aTo += nsPrintfCString(" %s", ConvertToString(mRect, aFlags).c_str()); | 
| 8641 | |
| 8642 | mozilla::WritingMode wm = GetWritingMode(); | 
| 8643 | if (wm.IsVertical() || wm.IsBidiRTL()) { | 
| 8644 | aTo += | 
| 8645 | nsPrintfCString(" wm=%s logical-size=(%s)", ToString(wm).c_str(), | 
| 8646 | ConvertToString(GetLogicalSize(), wm, aFlags).c_str()); | 
| 8647 | } | 
| 8648 | |
| 8649 | nsIFrame* parent = GetParent(); | 
| 8650 | if (parent) { | 
| 8651 | WritingMode pWM = parent->GetWritingMode(); | 
| 8652 | if (pWM.IsVertical() || pWM.IsBidiRTL()) { | 
| 8653 | nsSize containerSize = parent->mRect.Size(); | 
| 8654 | LogicalRect lr(pWM, mRect, containerSize); | 
| 8655 | aTo += nsPrintfCString(" parent-wm=%s cs=(%s) logical-rect=%s", | 
| 8656 | ToString(pWM).c_str(), | 
| 8657 | ConvertToString(containerSize, aFlags).c_str(), | 
| 8658 | ConvertToString(lr, pWM, aFlags).c_str()); | 
| 8659 | } | 
| 8660 | } | 
| 8661 | nsIFrame* f = const_cast<nsIFrame*>(this); | 
| 8662 | if (f->HasOverflowAreas()) { | 
| 8663 | nsRect io = f->InkOverflowRect(); | 
| 8664 | if (!io.IsEqualEdges(mRect)) { | 
| 8665 | aTo += nsPrintfCString(" ink-overflow=%s", | 
| 8666 | ConvertToString(io, aFlags).c_str()); | 
| 8667 | } | 
| 8668 | nsRect so = f->ScrollableOverflowRect(); | 
| 8669 | if (!so.IsEqualEdges(mRect)) { | 
| 8670 | aTo += nsPrintfCString(" scr-overflow=%s", | 
| 8671 | ConvertToString(so, aFlags).c_str()); | 
| 8672 | } | 
| 8673 | } | 
| 8674 | if (OverflowAreas* preTransformOverflows = | 
| 8675 | f->GetProperty(PreTransformOverflowAreasProperty())) { | 
| 8676 | nsRect io = preTransformOverflows->InkOverflow(); | 
| 8677 | if (!io.IsEqualEdges(mRect) && | 
| 8678 | (!f->HasOverflowAreas() || !io.IsEqualEdges(f->InkOverflowRect()))) { | 
| 8679 | aTo += nsPrintfCString(" pre-transform-ink-overflow=%s", | 
| 8680 | ConvertToString(io, aFlags).c_str()); | 
| 8681 | } | 
| 8682 | nsRect so = preTransformOverflows->ScrollableOverflow(); | 
| 8683 | if (!so.IsEqualEdges(mRect) && | 
| 8684 | (!f->HasOverflowAreas() || | 
| 8685 | !so.IsEqualEdges(f->ScrollableOverflowRect()))) { | 
| 8686 | aTo += nsPrintfCString(" pre-transform-scr-overflow=%s", | 
| 8687 | ConvertToString(so, aFlags).c_str()); | 
| 8688 | } | 
| 8689 | } | 
| 8690 | bool hasNormalPosition; | 
| 8691 | nsPoint normalPosition = GetNormalPosition(&hasNormalPosition); | 
| 8692 | if (hasNormalPosition) { | 
| 8693 | aTo += nsPrintfCString(" normal-position=%s", | 
| 8694 | ConvertToString(normalPosition, aFlags).c_str()); | 
| 8695 | } | 
| 8696 | if (HasProperty(BidiDataProperty())) { | 
| 8697 | FrameBidiData bidi = GetBidiData(); | 
| 8698 | aTo += nsPrintfCString(" bidi(%d,%d,%d)", bidi.baseLevel.Value(), | 
| 8699 | bidi.embeddingLevel.Value(), | 
| 8700 | bidi.precedingControl.Value()); | 
| 8701 | } | 
| 8702 | if (IsTransformed()) { | 
| 8703 | aTo += nsPrintfCString(" transformed"); | 
| 8704 | } | 
| 8705 | if (ChildrenHavePerspective()) { | 
| 8706 | aTo += nsPrintfCString(" perspective"); | 
| 8707 | } | 
| 8708 | if (Extend3DContext()) { | 
| 8709 | aTo += nsPrintfCString(" extend-3d"); | 
| 8710 | } | 
| 8711 | if (Combines3DTransformWithAncestors()) { | 
| 8712 | aTo += nsPrintfCString(" combines-3d-transform-with-ancestors"); | 
| 8713 | } | 
| 8714 | if (mContent) { | 
| 8715 | aTo += nsPrintfCString(" [content=%p", static_cast<void*>(mContent)); | 
| 8716 | if (IsPrimaryFrame() && DisplayPortUtils::HasDisplayPort(mContent)) { | 
| 8717 | // Anon boxes and continuations point to the same content - Just print on | 
| 8718 | // primary frame. | 
| 8719 | aTo += ",displayport"_ns; | 
| 8720 | } | 
| 8721 | aTo += "]"_ns; | 
| 8722 | } | 
| 8723 | aTo += nsPrintfCString(" [cs=%p", static_cast<void*>(mComputedStyle)); | 
| 8724 | if (mComputedStyle) { | 
| 8725 | auto pseudoType = mComputedStyle->GetPseudoType(); | 
| 8726 | aTo += ToString(pseudoType).c_str(); | 
| 8727 | } | 
| 8728 | aTo += "]"; | 
| 8729 | |
| 8730 | auto contentVisibility = StyleDisplay()->ContentVisibility(*this); | 
| 8731 | if (contentVisibility != StyleContentVisibility::Visible) { | 
| 8732 | aTo += nsPrintfCString(" [content-visibility="); | 
| 8733 | if (contentVisibility == StyleContentVisibility::Auto) { | 
| 8734 | aTo += "auto, "_ns; | 
| 8735 | } else if (contentVisibility == StyleContentVisibility::Hidden) { | 
| 8736 | aTo += "hidden, "_ns; | 
| 8737 | } | 
| 8738 | |
| 8739 | if (HidesContent()) { | 
| 8740 | aTo += "HidesContent=hidden"_ns; | 
| 8741 | } else { | 
| 8742 | aTo += "HidesContent=visibile"_ns; | 
| 8743 | } | 
| 8744 | aTo += "]"; | 
| 8745 | } | 
| 8746 | |
| 8747 | if (IsFrameModified()) { | 
| 8748 | aTo += nsPrintfCString(" modified"); | 
| 8749 | } | 
| 8750 | |
| 8751 | if (HasModifiedDescendants()) { | 
| 8752 | aTo += nsPrintfCString(" has-modified-descendants"); | 
| 8753 | } | 
| 8754 | } | 
| 8755 | |
| 8756 | void nsIFrame::List(FILE* out, const char* aPrefix, ListFlags aFlags) const { | 
| 8757 | nsCString str; | 
| 8758 | ListGeneric(str, aPrefix, aFlags); | 
| 8759 | fprintf_stderr(out, "%s\n", str.get()); | 
| 8760 | } | 
| 8761 | |
| 8762 | void nsIFrame::ListTextRuns(FILE* out) const { | 
| 8763 | nsTHashSet<const void*> seen; | 
| 8764 | ListTextRuns(out, seen); | 
| 8765 | } | 
| 8766 | |
| 8767 | void nsIFrame::ListTextRuns(FILE* out, nsTHashSet<const void*>& aSeen) const { | 
| 8768 | for (const auto& childList : ChildLists()) { | 
| 8769 | for (const nsIFrame* kid : childList.mList) { | 
| 8770 | kid->ListTextRuns(out, aSeen); | 
| 8771 | } | 
| 8772 | } | 
| 8773 | } | 
| 8774 | |
| 8775 | void nsIFrame::ListMatchedRules(FILE* out, const char* aPrefix) const { | 
| 8776 | nsTArray<const StyleLockedDeclarationBlock*> rawDecls; | 
| 8777 | Servo_ComputedValues_GetMatchingDeclarations(Style(), &rawDecls); | 
| 8778 | for (const StyleLockedDeclarationBlock* rawRule : rawDecls) { | 
| 8779 | nsAutoCString ruleText; | 
| 8780 | Servo_DeclarationBlock_GetCssText(rawRule, &ruleText); | 
| 8781 | fprintf_stderr(out, "%s%s\n", aPrefix, ruleText.get()); | 
| 8782 | } | 
| 8783 | } | 
| 8784 | |
| 8785 | void nsIFrame::ListWithMatchedRules(FILE* out, const char* aPrefix) const { | 
| 8786 | fprintf_stderr(out, "%s%s\n", aPrefix, ListTag().get()); | 
| 8787 | |
| 8788 | nsCString rulePrefix; | 
| 8789 | rulePrefix += aPrefix; | 
| 8790 | rulePrefix += " "; | 
| 8791 | ListMatchedRules(out, rulePrefix.get()); | 
| 8792 | } | 
| 8793 | |
| 8794 | nsresult nsIFrame::GetFrameName(nsAString& aResult) const { | 
| 8795 | return MakeFrameName(u"Frame"_ns, aResult); | 
| 8796 | } | 
| 8797 | |
| 8798 | nsresult nsIFrame::MakeFrameName(const nsAString& aType, | 
| 8799 | nsAString& aResult) const { | 
| 8800 | aResult = aType; | 
| 8801 | if (mContent && !mContent->IsText()) { | 
| 8802 | nsAutoString buf; | 
| 8803 | mContent->NodeInfo()->NameAtom()->ToString(buf); | 
| 8804 | if (nsAtom* id = mContent->GetID()) { | 
| 8805 | buf.AppendLiteral(" id="); | 
| 8806 | buf.Append(nsDependentAtomString(id)); | 
| 8807 | } | 
| 8808 | if (IsSubDocumentFrame()) { | 
| 8809 | nsAutoString src; | 
| 8810 | mContent->AsElement()->GetAttr(nsGkAtoms::src, src); | 
| 8811 | buf.AppendLiteral(" src="); | 
| 8812 | buf.Append(src); | 
| 8813 | } | 
| 8814 | aResult.Append('('); | 
| 8815 | aResult.Append(buf); | 
| 8816 | aResult.Append(')'); | 
| 8817 | } | 
| 8818 | aResult.Append('('); | 
| 8819 | Maybe<uint32_t> index = ContentIndexInContainer(this); | 
| 8820 | if (index.isSome()) { | 
| 8821 | aResult.AppendInt(*index); | 
| 8822 | } else { | 
| 8823 | aResult.AppendInt(-1); | 
| 8824 | } | 
| 8825 | aResult.Append(')'); | 
| 8826 | return NS_OK; | 
| 8827 | } | 
| 8828 | |
| 8829 | void nsIFrame::DumpFrameTree() const { | 
| 8830 | PresShell()->GetRootFrame()->List(stderrstderr); | 
| 8831 | } | 
| 8832 | |
| 8833 | void nsIFrame::DumpFrameTreeInCSSPixels() const { | 
| 8834 | PresShell()->GetRootFrame()->List(stderrstderr, "", ListFlag::DisplayInCSSPixels); | 
| 8835 | } | 
| 8836 | |
| 8837 | void nsIFrame::DumpFrameTreeLimited() const { List(stderrstderr); } | 
| 8838 | void nsIFrame::DumpFrameTreeLimitedInCSSPixels() const { | 
| 8839 | List(stderrstderr, "", ListFlag::DisplayInCSSPixels); | 
| 8840 | } | 
| 8841 | |
| 8842 | #endif | 
| 8843 | |
| 8844 | bool nsIFrame::IsVisibleForPainting() const { | 
| 8845 | return StyleVisibility()->IsVisible(); | 
| 8846 | } | 
| 8847 | |
| 8848 | bool nsIFrame::IsVisibleOrCollapsedForPainting() const { | 
| 8849 | return StyleVisibility()->IsVisibleOrCollapsed(); | 
| 8850 | } | 
| 8851 | |
| 8852 | /* virtual */ | 
| 8853 | bool nsIFrame::IsEmpty() { | 
| 8854 | return IsHiddenByContentVisibilityOfInFlowParentForLayout(); | 
| 8855 | } | 
| 8856 | |
| 8857 | bool nsIFrame::CachedIsEmpty() { | 
| 8858 | MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_IS_DIRTY) ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" " (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8861); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" ") (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")"); do { *((volatile int*)__null) = 8861 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) | 
| 8859 | IsHiddenByContentVisibilityOfInFlowParentForLayout(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" " (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8861); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" ") (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")"); do { *((volatile int*)__null) = 8861 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) | 
| 8860 | "Must only be called on reflowed lines or those hidden by "do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" " (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8861); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" ") (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")"); do { *((volatile int*)__null) = 8861 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) | 
| 8861 | "content-visibility.")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ())>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" " (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8861); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_IS_DIRTY) || IsHiddenByContentVisibilityOfInFlowParentForLayout()" ") (" "Must only be called on reflowed lines or those hidden by " "content-visibility." ")"); do { *((volatile int*)__null) = 8861 ; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 8862 | return IsEmpty(); | 
| 8863 | } | 
| 8864 | |
| 8865 | /* virtual */ | 
| 8866 | bool nsIFrame::IsSelfEmpty() { | 
| 8867 | return IsHiddenByContentVisibilityOfInFlowParentForLayout(); | 
| 8868 | } | 
| 8869 | |
| 8870 | nsresult nsIFrame::GetSelectionController(nsPresContext* aPresContext, | 
| 8871 | nsISelectionController** aSelCon) { | 
| 8872 | if (!aPresContext || !aSelCon) { | 
| 8873 | return NS_ERROR_INVALID_ARG; | 
| 8874 | } | 
| 8875 | |
| 8876 | nsIFrame* frame = this; | 
| 8877 | while (frame && frame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)) { | 
| 8878 | if (nsTextControlFrame* tcf = do_QueryFrame(frame)) { | 
| 8879 | return tcf->GetOwnedSelectionController(aSelCon); | 
| 8880 | } | 
| 8881 | frame = frame->GetParent(); | 
| 8882 | } | 
| 8883 | |
| 8884 | *aSelCon = do_AddRef(aPresContext->PresShell()).take(); | 
| 8885 | return NS_OK; | 
| 8886 | } | 
| 8887 | |
| 8888 | already_AddRefed<nsFrameSelection> nsIFrame::GetFrameSelection() { | 
| 8889 | RefPtr<nsFrameSelection> fs = | 
| 8890 | const_cast<nsFrameSelection*>(GetConstFrameSelection()); | 
| 8891 | return fs.forget(); | 
| 8892 | } | 
| 8893 | |
| 8894 | const nsFrameSelection* nsIFrame::GetConstFrameSelection() const { | 
| 8895 | nsIFrame* frame = const_cast<nsIFrame*>(this); | 
| 8896 | while (frame && frame->HasAnyStateBits(NS_FRAME_INDEPENDENT_SELECTION)) { | 
| 8897 | if (nsTextControlFrame* tcf = do_QueryFrame(frame)) { | 
| 8898 | return tcf->GetOwnedFrameSelection(); | 
| 8899 | } | 
| 8900 | frame = frame->GetParent(); | 
| 8901 | } | 
| 8902 | |
| 8903 | return PresShell()->ConstFrameSelection(); | 
| 8904 | } | 
| 8905 | |
| 8906 | bool nsIFrame::IsFrameSelected() const { | 
| 8907 | NS_ASSERTION(!GetContent() || GetContent()->IsMaybeSelected(),do { if (!(!GetContent() || GetContent()->IsMaybeSelected( ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "use the public IsSelected() instead" , "!GetContent() || GetContent()->IsMaybeSelected()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8908); MOZ_PretendNoReturn(); } } while (0) | 
| 8908 | "use the public IsSelected() instead")do { if (!(!GetContent() || GetContent()->IsMaybeSelected( ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "use the public IsSelected() instead" , "!GetContent() || GetContent()->IsMaybeSelected()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8908); MOZ_PretendNoReturn(); } } while (0); | 
| 8909 | if (StaticPrefs::dom_shadowdom_selection_across_boundary_enabled()) { | 
| 8910 | if (const ShadowRoot* shadowRoot = | 
| 8911 | GetContent()->GetShadowRootForSelection()) { | 
| 8912 | return shadowRoot->IsSelected(0, shadowRoot->GetChildCount()); | 
| 8913 | } | 
| 8914 | } | 
| 8915 | return GetContent()->IsSelected(0, GetContent()->GetChildCount()); | 
| 8916 | } | 
| 8917 | |
| 8918 | nsresult nsIFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) { | 
| 8919 | MOZ_ASSERT(outPoint != nullptr, "Null parameter")do { static_assert( mozilla::detail::AssertionConditionType< decltype(outPoint != nullptr)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(outPoint != nullptr))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("outPoint != nullptr" " (" "Null parameter" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8919); AnnotateMozCrashReason("MOZ_ASSERT" "(" "outPoint != nullptr" ") (" "Null parameter" ")"); do { *((volatile int*)__null) = 8919; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 8920 | nsRect contentRect = GetContentRectRelativeToSelf(); | 
| 8921 | nsPoint pt = contentRect.TopLeft(); | 
| 8922 | if (mContent) { | 
| 8923 | nsIContent* newContent = mContent->GetParent(); | 
| 8924 | if (newContent) { | 
| 8925 | const int32_t newOffset = newContent->ComputeIndexOf_Deprecated(mContent); | 
| 8926 | |
| 8927 | // Find the direction of the frame from the EmbeddingLevelProperty, | 
| 8928 | // which is the resolved bidi level set in | 
| 8929 | // nsBidiPresUtils::ResolveParagraph (odd levels = right-to-left). | 
| 8930 | // If the embedding level isn't set, just use the CSS direction | 
| 8931 | // property. | 
| 8932 | bool hasBidiData; | 
| 8933 | FrameBidiData bidiData = GetProperty(BidiDataProperty(), &hasBidiData); | 
| 8934 | bool isRTL = hasBidiData | 
| 8935 | ? bidiData.embeddingLevel.IsRTL() | 
| 8936 | : StyleVisibility()->mDirection == StyleDirection::Rtl; | 
| 8937 | if ((!isRTL && inOffset > newOffset) || | 
| 8938 | (isRTL && inOffset <= newOffset)) { | 
| 8939 | pt = contentRect.TopRight(); | 
| 8940 | } | 
| 8941 | } | 
| 8942 | } | 
| 8943 | *outPoint = pt; | 
| 8944 | return NS_OK; | 
| 8945 | } | 
| 8946 | |
| 8947 | nsresult nsIFrame::GetCharacterRectsInRange(int32_t aInOffset, int32_t aLength, | 
| 8948 | nsTArray<nsRect>& aOutRect) { | 
| 8949 | /* no text */ | 
| 8950 | return NS_ERROR_FAILURE; | 
| 8951 | } | 
| 8952 | |
| 8953 | nsresult nsIFrame::GetChildFrameContainingOffset(int32_t inContentOffset, | 
| 8954 | bool inHint, | 
| 8955 | int32_t* outFrameContentOffset, | 
| 8956 | nsIFrame** outChildFrame) { | 
| 8957 | MOZ_ASSERT(outChildFrame && outFrameContentOffset, "Null parameter")do { static_assert( mozilla::detail::AssertionConditionType< decltype(outChildFrame && outFrameContentOffset)>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(outChildFrame && outFrameContentOffset))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("outChildFrame && outFrameContentOffset" " (" "Null parameter" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8957); AnnotateMozCrashReason("MOZ_ASSERT" "(" "outChildFrame && outFrameContentOffset" ") (" "Null parameter" ")"); do { *((volatile int*)__null) = 8957; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 8958 | *outFrameContentOffset = (int32_t)inHint; | 
| 8959 | // the best frame to reflect any given offset would be a visible frame if | 
| 8960 | // possible i.e. we are looking for a valid frame to place the blinking caret | 
| 8961 | nsRect rect = GetRect(); | 
| 8962 | if (!rect.width || !rect.height) { | 
| 8963 | // if we have a 0 width or height then lets look for another frame that | 
| 8964 | // possibly has the same content. If we have no frames in flow then just | 
| 8965 | // let us return 'this' frame | 
| 8966 | nsIFrame* nextFlow = GetNextInFlow(); | 
| 8967 | if (nextFlow) { | 
| 8968 | return nextFlow->GetChildFrameContainingOffset( | 
| 8969 | inContentOffset, inHint, outFrameContentOffset, outChildFrame); | 
| 8970 | } | 
| 8971 | } | 
| 8972 | *outChildFrame = this; | 
| 8973 | return NS_OK; | 
| 8974 | } | 
| 8975 | |
| 8976 | // | 
| 8977 | // What I've pieced together about this routine: | 
| 8978 | // Starting with a block frame (from which a line frame can be gotten) | 
| 8979 | // and a line number, drill down and get the first/last selectable | 
| 8980 | // frame on that line, depending on aPos->mDirection. | 
| 8981 | // aOutSideLimit != 0 means ignore aLineStart, instead work from | 
| 8982 | // the end (if > 0) or beginning (if < 0). | 
| 8983 | // | 
| 8984 | static nsresult GetNextPrevLineFromBlockFrame(PeekOffsetStruct* aPos, | 
| 8985 | nsIFrame* aBlockFrame, | 
| 8986 | int32_t aLineStart, | 
| 8987 | int8_t aOutSideLimit) { | 
| 8988 | MOZ_ASSERT(aPos)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPos)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(aPos))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("aPos", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8988); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPos" ")"); do { *((volatile int*)__null) = 8988; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8989 | MOZ_ASSERT(aBlockFrame)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aBlockFrame)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aBlockFrame))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aBlockFrame", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 8989); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aBlockFrame" ")"); do { *((volatile int*)__null) = 8989; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 8990 | |
| 8991 | nsPresContext* pc = aBlockFrame->PresContext(); | 
| 8992 | |
| 8993 | // magic numbers: aLineStart will be -1 for end of block, 0 will be start of | 
| 8994 | // block. | 
| 8995 | |
| 8996 | aPos->mResultFrame = nullptr; | 
| 8997 | aPos->mResultContent = nullptr; | 
| 8998 | aPos->mAttach = aPos->mDirection == eDirNext ? CaretAssociationHint::After | 
| 8999 | : CaretAssociationHint::Before; | 
| 9000 | |
| 9001 | AutoAssertNoDomMutations guard; | 
| 9002 | nsILineIterator* it = aBlockFrame->GetLineIterator(); | 
| 9003 | if (!it) { | 
| 9004 | return NS_ERROR_FAILURE; | 
| 9005 | } | 
| 9006 | int32_t searchingLine = aLineStart; | 
| 9007 | int32_t countLines = it->GetNumLines(); | 
| 9008 | if (aOutSideLimit > 0) { // start at end | 
| 9009 | searchingLine = countLines; | 
| 9010 | } else if (aOutSideLimit < 0) { // start at beginning | 
| 9011 | searchingLine = -1; //"next" will be 0 | 
| 9012 | } else if ((aPos->mDirection == eDirPrevious && searchingLine == 0) || | 
| 9013 | (aPos->mDirection == eDirNext && | 
| 9014 | searchingLine >= (countLines - 1))) { | 
| 9015 | // Not found. | 
| 9016 | return NS_ERROR_FAILURE; | 
| 9017 | } | 
| 9018 | nsIFrame* resultFrame = nullptr; | 
| 9019 | nsIFrame* farStoppingFrame = nullptr; // we keep searching until we find a | 
| 9020 | // "this" frame then we go to next line | 
| 9021 | nsIFrame* nearStoppingFrame = nullptr; // if we are backing up from edge, | 
| 9022 | // stop here | 
| 9023 | bool isBeforeFirstFrame, isAfterLastFrame; | 
| 9024 | bool found = false; | 
| 9025 | |
| 9026 | const bool forceInEditableRegion = | 
| 9027 | aPos->mOptions.contains(PeekOffsetOption::ForceEditableRegion); | 
| 9028 | while (!found) { | 
| 9029 | if (aPos->mDirection == eDirPrevious) { | 
| 9030 | searchingLine--; | 
| 9031 | } else { | 
| 9032 | searchingLine++; | 
| 9033 | } | 
| 9034 | if ((aPos->mDirection == eDirPrevious && searchingLine < 0) || | 
| 9035 | (aPos->mDirection == eDirNext && searchingLine >= countLines)) { | 
| 9036 | // we need to jump to new block frame. | 
| 9037 | return NS_ERROR_FAILURE; | 
| 9038 | } | 
| 9039 | { | 
| 9040 | auto line = it->GetLine(searchingLine).unwrap(); | 
| 9041 | if (!line.mNumFramesOnLine) { | 
| 9042 | continue; | 
| 9043 | } | 
| 9044 | nsIFrame* firstFrame = nullptr; | 
| 9045 | nsIFrame* lastFrame = nullptr; | 
| 9046 | nsIFrame* frame = line.mFirstFrameOnLine; | 
| 9047 | int32_t i = line.mNumFramesOnLine; | 
| 9048 | do { | 
| 9049 | // If the caller wants a frame for a inclusive ancestor of the ancestor | 
| 9050 | // limiter, ignore frames for outside the limiter. | 
| 9051 | if (aPos->FrameContentIsInAncestorLimiter(frame)) { | 
| 9052 | if (!firstFrame) { | 
| 9053 | firstFrame = frame; | 
| 9054 | } | 
| 9055 | lastFrame = frame; | 
| 9056 | } | 
| 9057 | if (i == 1) { | 
| 9058 | break; | 
| 9059 | } | 
| 9060 | frame = frame->GetNextSibling(); | 
| 9061 | if (!frame) { | 
| 9062 | NS_ERROR("GetLine promised more frames than could be found")do { NS_DebugBreak(NS_DEBUG_ASSERTION, "GetLine promised more frames than could be found" , "Error", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9062); MOZ_PretendNoReturn(); } while (0); | 
| 9063 | return NS_ERROR_FAILURE; | 
| 9064 | } | 
| 9065 | } while (--i); | 
| 9066 | if (!lastFrame) { | 
| 9067 | // If we're looking for an editable content frame, but all frames in the | 
| 9068 | // line are not in the specified editing host, return error because we | 
| 9069 | // must reach the editing host boundary. | 
| 9070 | return NS_ERROR_FAILURE; | 
| 9071 | } | 
| 9072 | nsIFrame::GetLastLeaf(&lastFrame); | 
| 9073 | |
| 9074 | if (aPos->mDirection == eDirNext) { | 
| 9075 | nearStoppingFrame = firstFrame; | 
| 9076 | farStoppingFrame = lastFrame; | 
| 9077 | } else { | 
| 9078 | nearStoppingFrame = lastFrame; | 
| 9079 | farStoppingFrame = firstFrame; | 
| 9080 | } | 
| 9081 | } | 
| 9082 | nsPoint offset; | 
| 9083 | nsView* view; // used for call of get offset from view | 
| 9084 | aBlockFrame->GetOffsetFromView(offset, &view); | 
| 9085 | nsPoint newDesiredPos = | 
| 9086 | aPos->mDesiredCaretPos - | 
| 9087 | offset; // get desired position into blockframe coords | 
| 9088 | // TODO: nsILineIterator::FindFrameAt should take optional editing host | 
| 9089 | // parameter and if it's set, it should return the nearest editable frame | 
| 9090 | // for the editing host when the frame at the desired position is not | 
| 9091 | // editable. | 
| 9092 | nsresult rv = it->FindFrameAt(searchingLine, newDesiredPos, &resultFrame, | 
| 9093 | &isBeforeFirstFrame, &isAfterLastFrame); | 
| 9094 | if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) { | 
| 9095 | continue; | 
| 9096 | } | 
| 9097 | |
| 9098 | if (resultFrame) { | 
| 9099 | // If ancestor limiter is specified and we reached outside content of it, | 
| 9100 | // return error because we reached its element boundary. | 
| 9101 | if (!aPos->FrameContentIsInAncestorLimiter(resultFrame)) { | 
| 9102 | return NS_ERROR_FAILURE; | 
| 9103 | } | 
| 9104 | // check to see if this is ANOTHER blockframe inside the other one if so | 
| 9105 | // then call into its lines | 
| 9106 | if (resultFrame->CanProvideLineIterator()) { | 
| 9107 | aPos->mResultFrame = resultFrame; | 
| 9108 | return NS_OK; | 
| 9109 | } | 
| 9110 | // resultFrame is not a block frame | 
| 9111 | Maybe<nsFrameIterator> frameIterator; | 
| 9112 | frameIterator.emplace( | 
| 9113 | pc, resultFrame, nsFrameIterator::Type::PostOrder, | 
| 9114 | false, // aVisual | 
| 9115 | aPos->mOptions.contains(PeekOffsetOption::StopAtScroller), | 
| 9116 | false, // aFollowOOFs | 
| 9117 | false // aSkipPopupChecks | 
| 9118 | ); | 
| 9119 | |
| 9120 | auto FoundValidFrame = [forceInEditableRegion, aPos]( | 
| 9121 | const nsIFrame::ContentOffsets& aOffsets, | 
| 9122 | const nsIFrame* aFrame) { | 
| 9123 | if (!aOffsets.content) { | 
| 9124 | return false; | 
| 9125 | } | 
| 9126 | if (!aFrame->IsSelectable(nullptr)) { | 
| 9127 | return false; | 
| 9128 | } | 
| 9129 | if (aPos->mAncestorLimiter && | 
| 9130 | !aOffsets.content->IsInclusiveDescendantOf( | 
| 9131 | aPos->mAncestorLimiter)) { | 
| 9132 | return false; | 
| 9133 | } | 
| 9134 | if (forceInEditableRegion && !aOffsets.content->IsEditable()) { | 
| 9135 | return false; | 
| 9136 | } | 
| 9137 | return true; | 
| 9138 | }; | 
| 9139 | |
| 9140 | nsIFrame* storeOldResultFrame = resultFrame; | 
| 9141 | while (!found) { | 
| 9142 | nsPoint point; | 
| 9143 | nsRect tempRect = resultFrame->GetRect(); | 
| 9144 | nsPoint offset; | 
| 9145 | nsView* view; // used for call of get offset from view | 
| 9146 | resultFrame->GetOffsetFromView(offset, &view); | 
| 9147 | if (!view) { | 
| 9148 | return NS_ERROR_FAILURE; | 
| 9149 | } | 
| 9150 | if (resultFrame->GetWritingMode().IsVertical()) { | 
| 9151 | point.y = aPos->mDesiredCaretPos.y; | 
| 9152 | point.x = tempRect.width + offset.x; | 
| 9153 | } else { | 
| 9154 | point.y = tempRect.height + offset.y; | 
| 9155 | point.x = aPos->mDesiredCaretPos.x; | 
| 9156 | } | 
| 9157 | |
| 9158 | if (!resultFrame->HasView()) { | 
| 9159 | nsView* view; | 
| 9160 | nsPoint offset; | 
| 9161 | resultFrame->GetOffsetFromView(offset, &view); | 
| 9162 | nsIFrame::ContentOffsets offsets = | 
| 9163 | resultFrame->GetContentOffsetsFromPoint( | 
| 9164 | point - offset, nsIFrame::IGNORE_NATIVE_ANONYMOUS_SUBTREE); | 
| 9165 | aPos->mResultContent = offsets.content; | 
| 9166 | aPos->mContentOffset = offsets.offset; | 
| 9167 | aPos->mAttach = offsets.associate; | 
| 9168 | if (FoundValidFrame(offsets, resultFrame)) { | 
| 9169 | found = true; | 
| 9170 | break; | 
| 9171 | } | 
| 9172 | } | 
| 9173 | |
| 9174 | if (aPos->mDirection == eDirPrevious && | 
| 9175 | resultFrame == farStoppingFrame) { | 
| 9176 | break; | 
| 9177 | } | 
| 9178 | if (aPos->mDirection == eDirNext && resultFrame == nearStoppingFrame) { | 
| 9179 | break; | 
| 9180 | } | 
| 9181 | // always try previous on THAT line if that fails go the other way | 
| 9182 | resultFrame = frameIterator->Traverse(/* aForward = */ false); | 
| 9183 | if (!resultFrame) { | 
| 9184 | return NS_ERROR_FAILURE; | 
| 9185 | } | 
| 9186 | } | 
| 9187 | |
| 9188 | if (!found) { | 
| 9189 | resultFrame = storeOldResultFrame; | 
| 9190 | frameIterator.reset(); | 
| 9191 | frameIterator.emplace( | 
| 9192 | pc, resultFrame, nsFrameIterator::Type::Leaf, | 
| 9193 | false, // aVisual | 
| 9194 | aPos->mOptions.contains(PeekOffsetOption::StopAtScroller), | 
| 9195 | false, // aFollowOOFs | 
| 9196 | false // aSkipPopupChecks | 
| 9197 | ); | 
| 9198 | MOZ_ASSERT(frameIterator)do { static_assert( mozilla::detail::AssertionConditionType< decltype(frameIterator)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(frameIterator))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("frameIterator", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9198); AnnotateMozCrashReason("MOZ_ASSERT" "(" "frameIterator" ")"); do { *((volatile int*)__null) = 9198; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 9199 | } | 
| 9200 | while (!found) { | 
| 9201 | nsPoint point = aPos->mDesiredCaretPos; | 
| 9202 | nsView* view; | 
| 9203 | nsPoint offset; | 
| 9204 | resultFrame->GetOffsetFromView(offset, &view); | 
| 9205 | nsIFrame::ContentOffsets offsets = | 
| 9206 | resultFrame->GetContentOffsetsFromPoint( | 
| 9207 | point - offset, nsIFrame::IGNORE_NATIVE_ANONYMOUS_SUBTREE); | 
| 9208 | aPos->mResultContent = offsets.content; | 
| 9209 | aPos->mContentOffset = offsets.offset; | 
| 9210 | aPos->mAttach = offsets.associate; | 
| 9211 | if (FoundValidFrame(offsets, resultFrame)) { | 
| 9212 | found = true; | 
| 9213 | aPos->mAttach = resultFrame == farStoppingFrame | 
| 9214 | ? CaretAssociationHint::Before | 
| 9215 | : CaretAssociationHint::After; | 
| 9216 | break; | 
| 9217 | } | 
| 9218 | if (aPos->mDirection == eDirPrevious && | 
| 9219 | resultFrame == nearStoppingFrame) { | 
| 9220 | break; | 
| 9221 | } | 
| 9222 | if (aPos->mDirection == eDirNext && resultFrame == farStoppingFrame) { | 
| 9223 | break; | 
| 9224 | } | 
| 9225 | // previous didnt work now we try "next" | 
| 9226 | nsIFrame* tempFrame = frameIterator->Traverse(/* aForward = */ true); | 
| 9227 | if (!tempFrame) { | 
| 9228 | break; | 
| 9229 | } | 
| 9230 | resultFrame = tempFrame; | 
| 9231 | } | 
| 9232 | aPos->mResultFrame = resultFrame; | 
| 9233 | } else { | 
| 9234 | // we need to jump to new block frame. | 
| 9235 | aPos->mAmount = eSelectLine; | 
| 9236 | aPos->mStartOffset = 0; | 
| 9237 | aPos->mAttach = aPos->mDirection == eDirNext | 
| 9238 | ? CaretAssociationHint::Before | 
| 9239 | : CaretAssociationHint::After; | 
| 9240 | if (aPos->mDirection == eDirPrevious) { | 
| 9241 | aPos->mStartOffset = -1; // start from end | 
| 9242 | } | 
| 9243 | return aBlockFrame->PeekOffset(aPos); | 
| 9244 | } | 
| 9245 | } | 
| 9246 | return NS_OK; | 
| 9247 | } | 
| 9248 | |
| 9249 | nsIFrame::CaretPosition nsIFrame::GetExtremeCaretPosition(bool aStart) { | 
| 9250 | CaretPosition result; | 
| 9251 | |
| 9252 | FrameTarget targetFrame = DrillDownToSelectionFrame(this, !aStart, 0); | 
| 9253 | FrameContentRange range = GetRangeForFrame(targetFrame.frame); | 
| 9254 | result.mResultContent = range.content; | 
| 9255 | result.mContentOffset = aStart ? range.start : range.end; | 
| 9256 | return result; | 
| 9257 | } | 
| 9258 | |
| 9259 | // If this is a preformatted text frame, see if it ends with a newline | 
| 9260 | static nsContentAndOffset FindLineBreakInText(nsIFrame* aFrame, | 
| 9261 | nsDirection aDirection) { | 
| 9262 | nsContentAndOffset result; | 
| 9263 | |
| 9264 | if (aFrame->IsGeneratedContentFrame() || | 
| 9265 | !aFrame->HasSignificantTerminalNewline()) { | 
| 9266 | return result; | 
| 9267 | } | 
| 9268 | |
| 9269 | int32_t endOffset = aFrame->GetOffsets().second; | 
| 9270 | result.mContent = aFrame->GetContent(); | 
| 9271 | result.mOffset = endOffset - (aDirection == eDirPrevious ? 0 : 1); | 
| 9272 | return result; | 
| 9273 | } | 
| 9274 | |
| 9275 | // Find the first (or last) descendant of the given frame | 
| 9276 | // which is either a block-level frame or a BRFrame, or some other kind of break | 
| 9277 | // which stops the line. | 
| 9278 | static nsContentAndOffset FindLineBreakingFrame(nsIFrame* aFrame, | 
| 9279 | nsDirection aDirection) { | 
| 9280 | nsContentAndOffset result; | 
| 9281 | |
| 9282 | if (aFrame->IsGeneratedContentFrame()) { | 
| 9283 | return result; | 
| 9284 | } | 
| 9285 | |
| 9286 | // Treat form controls and other replaced inline level elements as inline | 
| 9287 | // leaves. | 
| 9288 | if (aFrame->IsReplaced() && aFrame->IsInlineOutside() && | 
| 9289 | !aFrame->IsBrFrame() && !aFrame->IsTextFrame()) { | 
| 9290 | return result; | 
| 9291 | } | 
| 9292 | |
| 9293 | // Check the frame itself | 
| 9294 | // Fall through block-in-inline split frames because their mContent is | 
| 9295 | // the content of the inline frames they were created from. The | 
| 9296 | // first/last child of such frames is the real block frame we're | 
| 9297 | // looking for. | 
| 9298 | if ((aFrame->IsBlockOutside() && | 
| 9299 | !aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) || | 
| 9300 | aFrame->IsBrFrame()) { | 
| 9301 | nsIContent* content = aFrame->GetContent(); | 
| 9302 | result.mContent = content->GetParent(); | 
| 9303 | // In some cases (bug 310589, bug 370174) we end up here with a null | 
| 9304 | // content. This probably shouldn't ever happen, but since it sometimes | 
| 9305 | // does, we want to avoid crashing here. | 
| 9306 | NS_ASSERTION(result.mContent, "Unexpected orphan content")do { if (!(result.mContent)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "Unexpected orphan content", "result.mContent", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9306); MOZ_PretendNoReturn(); } } while (0); | 
| 9307 | if (result.mContent) { | 
| 9308 | result.mOffset = result.mContent->ComputeIndexOf_Deprecated(content) + | 
| 9309 | (aDirection == eDirPrevious ? 1 : 0); | 
| 9310 | } | 
| 9311 | return result; | 
| 9312 | } | 
| 9313 | |
| 9314 | result = FindLineBreakInText(aFrame, aDirection); | 
| 9315 | if (result.mContent) { | 
| 9316 | return result; | 
| 9317 | } | 
| 9318 | |
| 9319 | // Iterate over children and call ourselves recursively | 
| 9320 | if (aDirection == eDirPrevious) { | 
| 9321 | nsIFrame* child = aFrame->PrincipalChildList().LastChild(); | 
| 9322 | while (child && !result.mContent) { | 
| 9323 | result = FindLineBreakingFrame(child, aDirection); | 
| 9324 | child = child->GetPrevSibling(); | 
| 9325 | } | 
| 9326 | } else { // eDirNext | 
| 9327 | nsIFrame* child = aFrame->PrincipalChildList().FirstChild(); | 
| 9328 | while (child && !result.mContent) { | 
| 9329 | result = FindLineBreakingFrame(child, aDirection); | 
| 9330 | child = child->GetNextSibling(); | 
| 9331 | } | 
| 9332 | } | 
| 9333 | return result; | 
| 9334 | } | 
| 9335 | |
| 9336 | nsresult nsIFrame::PeekOffsetForParagraph(PeekOffsetStruct* aPos) { | 
| 9337 | nsIFrame* frame = this; | 
| 9338 | nsContentAndOffset blockFrameOrBR; | 
| 9339 | blockFrameOrBR.mContent = nullptr; | 
| 9340 | bool reachedLimit = frame->IsBlockOutside() || IsEditingHost(frame); | 
| 9341 | |
| 9342 | auto traverse = [&aPos](nsIFrame* current) { | 
| 9343 | return aPos->mDirection == eDirPrevious ? current->GetPrevSibling() | 
| 9344 | : current->GetNextSibling(); | 
| 9345 | }; | 
| 9346 | |
| 9347 | // Go through containing frames until reaching a block frame. | 
| 9348 | // In each step, search the previous (or next) siblings for the closest | 
| 9349 | // "stop frame" (a block frame or a BRFrame). | 
| 9350 | // If found, set it to be the selection boundary and abort. | 
| 9351 | while (!reachedLimit) { | 
| 9352 | nsIFrame* parent = frame->GetParent(); | 
| 9353 | // Treat a frame associated with the root content as if it were a block | 
| 9354 | // frame. | 
| 9355 | if (!frame->mContent || !frame->mContent->GetParent()) { | 
| 9356 | reachedLimit = true; | 
| 9357 | break; | 
| 9358 | } | 
| 9359 | |
| 9360 | if (aPos->mDirection == eDirNext) { | 
| 9361 | // Try to find our own line-break before looking at our siblings. | 
| 9362 | blockFrameOrBR = FindLineBreakInText(frame, eDirNext); | 
| 9363 | } | 
| 9364 | |
| 9365 | nsIFrame* sibling = traverse(frame); | 
| 9366 | while (sibling && !blockFrameOrBR.mContent) { | 
| 9367 | blockFrameOrBR = FindLineBreakingFrame(sibling, aPos->mDirection); | 
| 9368 | sibling = traverse(sibling); | 
| 9369 | } | 
| 9370 | if (blockFrameOrBR.mContent) { | 
| 9371 | aPos->mResultContent = blockFrameOrBR.mContent; | 
| 9372 | aPos->mContentOffset = blockFrameOrBR.mOffset; | 
| 9373 | break; | 
| 9374 | } | 
| 9375 | frame = parent; | 
| 9376 | reachedLimit = frame && (frame->IsBlockOutside() || IsEditingHost(frame)); | 
| 9377 | } | 
| 9378 | |
| 9379 | if (reachedLimit) { // no "stop frame" found | 
| 9380 | aPos->mResultContent = frame->GetContent(); | 
| 9381 | if (ShadowRoot* shadowRoot = | 
| 9382 | aPos->mResultContent->GetShadowRootForSelection()) { | 
| 9383 | // Even if there's no children for this node, | 
| 9384 | // the elements inside the shadow root is still | 
| 9385 | // selectable | 
| 9386 | aPos->mResultContent = shadowRoot; | 
| 9387 | } | 
| 9388 | if (aPos->mDirection == eDirPrevious) { | 
| 9389 | aPos->mContentOffset = 0; | 
| 9390 | } else if (aPos->mResultContent) { | 
| 9391 | aPos->mContentOffset = aPos->mResultContent->GetChildCount(); | 
| 9392 | } | 
| 9393 | } | 
| 9394 | return NS_OK; | 
| 9395 | } | 
| 9396 | |
| 9397 | // Determine movement direction relative to frame | 
| 9398 | static bool IsMovingInFrameDirection(const nsIFrame* frame, | 
| 9399 | nsDirection aDirection, bool aVisual) { | 
| 9400 | bool isReverseDirection = | 
| 9401 | aVisual && nsBidiPresUtils::IsReversedDirectionFrame(frame); | 
| 9402 | return aDirection == (isReverseDirection ? eDirPrevious : eDirNext); | 
| 9403 | } | 
| 9404 | |
| 9405 | // Determines "are we looking for a boundary between whitespace and | 
| 9406 | // non-whitespace (in the direction we're moving in)". It is true when moving | 
| 9407 | // forward and looking for a beginning of a word, or when moving backwards and | 
| 9408 | // looking for an end of a word. | 
| 9409 | static bool ShouldWordSelectionEatSpace(const PeekOffsetStruct& aPos) { | 
| 9410 | if (aPos.mWordMovementType != eDefaultBehavior) { | 
| 9411 | // aPos->mWordMovementType possible values: | 
| 9412 | // eEndWord: eat the space if we're moving backwards | 
| 9413 | // eStartWord: eat the space if we're moving forwards | 
| 9414 | return (aPos.mWordMovementType == eEndWord) == | 
| 9415 | (aPos.mDirection == eDirPrevious); | 
| 9416 | } | 
| 9417 | // Use the hidden preference which is based on operating system | 
| 9418 | // behavior. This pref only affects whether moving forward by word | 
| 9419 | // should go to the end of this word or start of the next word. When | 
| 9420 | // going backwards, the start of the word is always used, on every | 
| 9421 | // operating system. | 
| 9422 | return aPos.mDirection == eDirNext && | 
| 9423 | StaticPrefs::layout_word_select_eat_space_to_next_word(); | 
| 9424 | } | 
| 9425 | |
| 9426 | enum class OffsetIsAtLineEdge : bool { No, Yes }; | 
| 9427 | |
| 9428 | static void SetPeekResultFromFrame(PeekOffsetStruct& aPos, nsIFrame* aFrame, | 
| 9429 | int32_t aOffset, | 
| 9430 | OffsetIsAtLineEdge aAtLineEdge) { | 
| 9431 | FrameContentRange range = GetRangeForFrame(aFrame); | 
| 9432 | aPos.mResultFrame = aFrame; | 
| 9433 | aPos.mResultContent = range.content; | 
| 9434 | // Output offset is relative to content, not frame | 
| 9435 | aPos.mContentOffset = | 
| 9436 | aOffset < 0 ? range.end + aOffset + 1 : range.start + aOffset; | 
| 9437 | if (aAtLineEdge == OffsetIsAtLineEdge::Yes) { | 
| 9438 | aPos.mAttach = aPos.mContentOffset == range.start | 
| 9439 | ? CaretAssociationHint::After | 
| 9440 | : CaretAssociationHint::Before; | 
| 9441 | } | 
| 9442 | } | 
| 9443 | |
| 9444 | void nsIFrame::SelectablePeekReport::TransferTo(PeekOffsetStruct& aPos) const { | 
| 9445 | return SetPeekResultFromFrame(aPos, mFrame, mOffset, OffsetIsAtLineEdge::No); | 
| 9446 | } | 
| 9447 | |
| 9448 | nsIFrame::SelectablePeekReport::SelectablePeekReport( | 
| 9449 | const mozilla::GenericErrorResult<nsresult>&& aErr) { | 
| 9450 | MOZ_ASSERT(NS_FAILED(aErr.operator nsresult()))do { static_assert( mozilla::detail::AssertionConditionType< decltype(((bool)(__builtin_expect(!!(NS_FAILED_impl(aErr.operator nsresult())), 0))))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(((bool)(__builtin_expect(!!( NS_FAILED_impl(aErr.operator nsresult())), 0)))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("((bool)(__builtin_expect(!!(NS_FAILED_impl(aErr.operator nsresult())), 0)))" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9450); AnnotateMozCrashReason("MOZ_ASSERT" "(" "((bool)(__builtin_expect(!!(NS_FAILED_impl(aErr.operator nsresult())), 0)))" ")"); do { *((volatile int*)__null) = 9450; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 9451 | // Return an empty report | 
| 9452 | } | 
| 9453 | |
| 9454 | nsresult nsIFrame::PeekOffsetForCharacter(PeekOffsetStruct* aPos, | 
| 9455 | int32_t aOffset) { | 
| 9456 | SelectablePeekReport current{this, aOffset}; | 
| 9457 | |
| 9458 | nsIFrame::FrameSearchResult peekSearchState = CONTINUE; | 
| 9459 | |
| 9460 | const bool forceEditableRegion = | 
| 9461 | aPos->mOptions.contains(PeekOffsetOption::ForceEditableRegion); | 
| 9462 | |
| 9463 | while (peekSearchState != FOUND) { | 
| 9464 | const bool movingInFrameDirection = IsMovingInFrameDirection( | 
| 9465 | current.mFrame, aPos->mDirection, | 
| 9466 | aPos->mOptions.contains(PeekOffsetOption::Visual)); | 
| 9467 | |
| 9468 | if (current.mJumpedLine) { | 
| 9469 | // If we jumped lines, it's as if we found a character, but we still need | 
| 9470 | // to eat non-renderable content on the new line. | 
| 9471 | peekSearchState = current.PeekOffsetNoAmount(movingInFrameDirection); | 
| 9472 | } else { | 
| 9473 | PeekOffsetCharacterOptions options; | 
| 9474 | options.mRespectClusters = aPos->mAmount == eSelectCluster; | 
| 9475 | peekSearchState = | 
| 9476 | current.PeekOffsetCharacter(movingInFrameDirection, options); | 
| 9477 | if (peekSearchState == FOUND && forceEditableRegion && | 
| 9478 | !current.mFrame->ContentIsEditable()) { | 
| 9479 | // Treat non-editable content as unselectable. Note that we may need to | 
| 9480 | // set mJumpedLine propery even if it's not editable. Therefore, we | 
| 9481 | // cannot skip the above call. | 
| 9482 | peekSearchState = CONTINUE_UNSELECTABLE; | 
| 9483 | } | 
| 9484 | } | 
| 9485 | |
| 9486 | current.mMovedOverNonSelectableText |= | 
| 9487 | peekSearchState == CONTINUE_UNSELECTABLE; | 
| 9488 | |
| 9489 | if (peekSearchState != FOUND) { | 
| 9490 | SelectablePeekReport next = current.mFrame->GetFrameFromDirection(*aPos); | 
| 9491 | if (next.Failed()) { | 
| 9492 | return NS_ERROR_FAILURE; | 
| 9493 | } | 
| 9494 | next.mJumpedLine |= current.mJumpedLine; | 
| 9495 | next.mMovedOverNonSelectableText |= current.mMovedOverNonSelectableText; | 
| 9496 | next.mHasSelectableFrame |= current.mHasSelectableFrame; | 
| 9497 | current = next; | 
| 9498 | } | 
| 9499 | |
| 9500 | // Found frame, but because we moved over non selectable text we want | 
| 9501 | // the offset to be at the frame edge. Note that if we are extending the | 
| 9502 | // selection, this doesn't matter. | 
| 9503 | if (peekSearchState == FOUND && current.mMovedOverNonSelectableText && | 
| 9504 | (!aPos->mOptions.contains(PeekOffsetOption::Extend) || | 
| 9505 | current.mHasSelectableFrame)) { | 
| 9506 | auto [start, end] = current.mFrame->GetOffsets(); | 
| 9507 | current.mOffset = aPos->mDirection == eDirNext ? 0 : end - start; | 
| 9508 | } | 
| 9509 | } | 
| 9510 | |
| 9511 | // Set outputs | 
| 9512 | current.TransferTo(*aPos); | 
| 9513 | // If we're dealing with a text frame and moving backward positions us at | 
| 9514 | // the end of that line, decrease the offset by one to make sure that | 
| 9515 | // we're placed before the linefeed character on the previous line. | 
| 9516 | if (current.mOffset < 0 && current.mJumpedLine && | 
| 9517 | aPos->mDirection == eDirPrevious && | 
| 9518 | current.mFrame->HasSignificantTerminalNewline() && | 
| 9519 | !current.mIgnoredBrFrame) { | 
| 9520 | --aPos->mContentOffset; | 
| 9521 | } | 
| 9522 | return NS_OK; | 
| 9523 | } | 
| 9524 | |
| 9525 | nsresult nsIFrame::PeekOffsetForWord(PeekOffsetStruct* aPos, int32_t aOffset) { | 
| 9526 | SelectablePeekReport current{this, aOffset}; | 
| 9527 | bool shouldStopAtHardBreak = | 
| 9528 | aPos->mWordMovementType == eDefaultBehavior && | 
| 9529 | StaticPrefs::layout_word_select_eat_space_to_next_word(); | 
| 9530 | bool wordSelectEatSpace = ShouldWordSelectionEatSpace(*aPos); | 
| 9531 | |
| 9532 | PeekWordState state; | 
| 9533 | while (true) { | 
| 9534 | bool movingInFrameDirection = IsMovingInFrameDirection( | 
| 9535 | current.mFrame, aPos->mDirection, | 
| 9536 | aPos->mOptions.contains(PeekOffsetOption::Visual)); | 
| 9537 | |
| 9538 | FrameSearchResult searchResult = current.mFrame->PeekOffsetWord( | 
| 9539 | movingInFrameDirection, wordSelectEatSpace, | 
| 9540 | aPos->mOptions.contains(PeekOffsetOption::IsKeyboardSelect), | 
| 9541 | ¤t.mOffset, &state, | 
| 9542 | !aPos->mOptions.contains(PeekOffsetOption::PreserveSpaces)); | 
| 9543 | if (searchResult == FOUND) { | 
| 9544 | break; | 
| 9545 | } | 
| 9546 | |
| 9547 | SelectablePeekReport next = [&]() { | 
| 9548 | PeekOffsetOptions options = aPos->mOptions; | 
| 9549 | if (state.mSawInlineCharacter) { | 
| 9550 | // If we've already found a character, we don't want to stop at | 
| 9551 | // placeholder frame boundary if there is in the word. | 
| 9552 | options += PeekOffsetOption::StopAtPlaceholder; | 
| 9553 | } | 
| 9554 | return current.mFrame->GetFrameFromDirection(aPos->mDirection, options); | 
| 9555 | }(); | 
| 9556 | if (next.Failed()) { | 
| 9557 | // If we've crossed the line boundary, check to make sure that we | 
| 9558 | // have not consumed a trailing newline as whitespace if it's | 
| 9559 | // significant. | 
| 9560 | if (next.mJumpedLine && wordSelectEatSpace && | 
| 9561 | current.mFrame->HasSignificantTerminalNewline() && | 
| 9562 | current.mFrame->StyleText()->mWhiteSpaceCollapse != | 
| 9563 | StyleWhiteSpaceCollapse::PreserveBreaks) { | 
| 9564 | current.mOffset -= 1; | 
| 9565 | } | 
| 9566 | break; | 
| 9567 | } | 
| 9568 | |
| 9569 | if ((next.mJumpedLine || next.mFoundPlaceholder) && !wordSelectEatSpace && | 
| 9570 | state.mSawBeforeType) { | 
| 9571 | // We can't jump lines if we're looking for whitespace following | 
| 9572 | // non-whitespace, and we already encountered non-whitespace. | 
| 9573 | break; | 
| 9574 | } | 
| 9575 | |
| 9576 | if (shouldStopAtHardBreak && next.mJumpedHardBreak) { | 
| 9577 | /** | 
| 9578 | * Prev, always: Jump and stop right there | 
| 9579 | * Next, saw inline: just stop | 
| 9580 | * Next, no inline: Jump and consume whitespaces | 
| 9581 | */ | 
| 9582 | if (aPos->mDirection == eDirPrevious) { | 
| 9583 | // Try moving to the previous line if exists | 
| 9584 | current.TransferTo(*aPos); | 
| 9585 | current.mFrame->PeekOffsetForCharacter(aPos, current.mOffset); | 
| 9586 | return NS_OK; | 
| 9587 | } | 
| 9588 | if (state.mSawInlineCharacter || current.mJumpedHardBreak) { | 
| 9589 | if (current.mFrame->HasSignificantTerminalNewline()) { | 
| 9590 | current.mOffset -= 1; | 
| 9591 | } | 
| 9592 | current.TransferTo(*aPos); | 
| 9593 | return NS_OK; | 
| 9594 | } | 
| 9595 | // Mark the state as whitespace and continue | 
| 9596 | state.Update(false, true); | 
| 9597 | } | 
| 9598 | |
| 9599 | if (next.mJumpedLine) { | 
| 9600 | state.mContext.Truncate(); | 
| 9601 | } | 
| 9602 | current = next; | 
| 9603 | // Jumping a line is equivalent to encountering whitespace | 
| 9604 | // This affects only when it already met an actual character | 
| 9605 | if (wordSelectEatSpace && next.mJumpedLine) { | 
| 9606 | state.SetSawBeforeType(); | 
| 9607 | } | 
| 9608 | } | 
| 9609 | |
| 9610 | // Set outputs | 
| 9611 | current.TransferTo(*aPos); | 
| 9612 | return NS_OK; | 
| 9613 | } | 
| 9614 | |
| 9615 | static nsIFrame* GetFirstSelectableDescendantWithLineIterator( | 
| 9616 | const PeekOffsetStruct& aPeekOffsetStruct, nsIFrame* aParentFrame) { | 
| 9617 | const bool forceEditableRegion = aPeekOffsetStruct.mOptions.contains( | 
| 9618 | PeekOffsetOption::ForceEditableRegion); | 
| 9619 | auto FoundValidFrame = [aPeekOffsetStruct, | 
| 9620 | forceEditableRegion](const nsIFrame* aFrame) { | 
| 9621 | if (!aFrame->IsSelectable(nullptr)) { | 
| 9622 | return false; | 
| 9623 | } | 
| 9624 | if (!aPeekOffsetStruct.FrameContentIsInAncestorLimiter(aFrame)) { | 
| 9625 | return false; | 
| 9626 | } | 
| 9627 | if (forceEditableRegion && !aFrame->ContentIsEditable()) { | 
| 9628 | return false; | 
| 9629 | } | 
| 9630 | return true; | 
| 9631 | }; | 
| 9632 | |
| 9633 | for (nsIFrame* child : aParentFrame->PrincipalChildList()) { | 
| 9634 | // some children may not be selectable, e.g. :before / :after pseudoelements | 
| 9635 | // content with user-select: none, or contenteditable="false" | 
| 9636 | // we need to skip them | 
| 9637 | if (child->CanProvideLineIterator() && FoundValidFrame(child)) { | 
| 9638 | return child; | 
| 9639 | } | 
| 9640 | if (nsIFrame* nested = GetFirstSelectableDescendantWithLineIterator( | 
| 9641 | aPeekOffsetStruct, child)) { | 
| 9642 | return nested; | 
| 9643 | } | 
| 9644 | } | 
| 9645 | return nullptr; | 
| 9646 | } | 
| 9647 | |
| 9648 | nsresult nsIFrame::PeekOffsetForLine(PeekOffsetStruct* aPos) { | 
| 9649 | nsIFrame* blockFrame = this; | 
| 9650 | nsresult result = NS_ERROR_FAILURE; | 
| 9651 | |
| 9652 | // outer loop | 
| 9653 | // moving to a next block when no more blocks are available in a subtree | 
| 9654 | AutoAssertNoDomMutations guard; | 
| 9655 | while (NS_FAILED(result)((bool)(__builtin_expect(!!(NS_FAILED_impl(result)), 0)))) { | 
| 9656 | auto [newBlock, lineFrame] = blockFrame->GetContainingBlockForLine( | 
| 9657 | aPos->mOptions.contains(PeekOffsetOption::StopAtScroller)); | 
| 9658 | if (!newBlock) { | 
| 9659 | return NS_ERROR_FAILURE; | 
| 9660 | } | 
| 9661 | // FYI: If the editing host is an inline element, the block frame content | 
| 9662 | // may be either not editable or editable but belonging to different editing | 
| 9663 | // host. | 
| 9664 | blockFrame = newBlock; | 
| 9665 | nsILineIterator* iter = blockFrame->GetLineIterator(); | 
| 9666 | int32_t thisLine = iter->FindLineContaining(lineFrame); | 
| 9667 | if (NS_WARN_IF(thisLine < 0)NS_warn_if_impl(thisLine < 0, "thisLine < 0", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9667)) { | 
| 9668 | return NS_ERROR_FAILURE; | 
| 9669 | } | 
| 9670 | |
| 9671 | int8_t edgeCase = 0; // no edge case. This should look at thisLine | 
| 9672 | |
| 9673 | // this part will find a frame or a block frame. If it's a block frame | 
| 9674 | // it will "drill down" to find a viable frame or it will return an | 
| 9675 | // error. | 
| 9676 | nsIFrame* lastFrame = this; | 
| 9677 | |
| 9678 | // inner loop - crawling the frames within a specific block subtree | 
| 9679 | while (true) { | 
| 9680 | result = | 
| 9681 | GetNextPrevLineFromBlockFrame(aPos, blockFrame, thisLine, edgeCase); | 
| 9682 | // we came back to same spot! keep going | 
| 9683 | if (NS_SUCCEEDED(result)((bool)(__builtin_expect(!!(!NS_FAILED_impl(result)), 1))) && | 
| 9684 | (!aPos->mResultFrame || aPos->mResultFrame == lastFrame)) { | 
| 9685 | aPos->mResultFrame = nullptr; | 
| 9686 | lastFrame = nullptr; | 
| 9687 | if (aPos->mDirection == eDirPrevious) { | 
| 9688 | thisLine--; | 
| 9689 | } else { | 
| 9690 | thisLine++; | 
| 9691 | } | 
| 9692 | continue; | 
| 9693 | } | 
| 9694 | |
| 9695 | if (NS_FAILED(result)((bool)(__builtin_expect(!!(NS_FAILED_impl(result)), 0)))) { | 
| 9696 | break; | 
| 9697 | } | 
| 9698 | |
| 9699 | lastFrame = aPos->mResultFrame; // set last frame | 
| 9700 | /* SPECIAL CHECK FOR NAVIGATION INTO TABLES | 
| 9701 | * when we hit a frame which doesn't have line iterator, we need to | 
| 9702 | * drill down and find a child with the line iterator to prevent the | 
| 9703 | * crawling process to prematurely finish. Note that this is only sound if | 
| 9704 | * we're guaranteed to not have multiple children implementing | 
| 9705 | * LineIterator. | 
| 9706 | * | 
| 9707 | * So far known cases are: | 
| 9708 | * 1) table wrapper (drill down into table row group) | 
| 9709 | * 2) table cell (drill down into its only anon child) | 
| 9710 | */ | 
| 9711 | const bool shouldDrillIntoChildren = | 
| 9712 | aPos->mResultFrame->IsTableWrapperFrame() || | 
| 9713 | aPos->mResultFrame->IsTableCellFrame(); | 
| 9714 | |
| 9715 | if (shouldDrillIntoChildren) { | 
| 9716 | nsIFrame* child = GetFirstSelectableDescendantWithLineIterator( | 
| 9717 | *aPos, aPos->mResultFrame); | 
| 9718 | if (child) { | 
| 9719 | aPos->mResultFrame = child; | 
| 9720 | } | 
| 9721 | } | 
| 9722 | |
| 9723 | if (!aPos->mResultFrame->CanProvideLineIterator()) { | 
| 9724 | // no more selectable content at this level | 
| 9725 | break; | 
| 9726 | } | 
| 9727 | |
| 9728 | if (aPos->mResultFrame == blockFrame) { | 
| 9729 | // Make sure block element is not the same as the one we had before. | 
| 9730 | break; | 
| 9731 | } | 
| 9732 | |
| 9733 | // we've struck another block element with selectable content! | 
| 9734 | if (aPos->mDirection == eDirPrevious) { | 
| 9735 | edgeCase = 1; // far edge, search from end backwards | 
| 9736 | } else { | 
| 9737 | edgeCase = -1; // near edge search from beginning onwards | 
| 9738 | } | 
| 9739 | thisLine = 0; // this line means nothing now. | 
| 9740 | // everything else means something so keep looking "inside" the | 
| 9741 | // block | 
| 9742 | blockFrame = aPos->mResultFrame; | 
| 9743 | } | 
| 9744 | } | 
| 9745 | return result; | 
| 9746 | } | 
| 9747 | |
| 9748 | nsresult nsIFrame::PeekOffsetForLineEdge(PeekOffsetStruct* aPos) { | 
| 9749 | // Adjusted so that the caret can't get confused when content changes | 
| 9750 | nsIFrame* frame = AdjustFrameForSelectionStyles(this); | 
| 9751 | Element* editingHost = frame->GetContent()->GetEditingHost(); | 
| 9752 | |
| 9753 | auto [blockFrame, lineFrame] = frame->GetContainingBlockForLine( | 
| 9754 | aPos->mOptions.contains(PeekOffsetOption::StopAtScroller)); | 
| 9755 | if (!blockFrame) { | 
| 9756 | return NS_ERROR_FAILURE; | 
| 9757 | } | 
| 9758 | AutoAssertNoDomMutations guard; | 
| 9759 | nsILineIterator* it = blockFrame->GetLineIterator(); | 
| 9760 | int32_t thisLine = it->FindLineContaining(lineFrame); | 
| 9761 | if (thisLine < 0) { | 
| 9762 | return NS_ERROR_FAILURE; | 
| 9763 | } | 
| 9764 | |
| 9765 | nsIFrame* baseFrame = nullptr; | 
| 9766 | bool endOfLine = eSelectEndLine == aPos->mAmount; | 
| 9767 | |
| 9768 | if (aPos->mOptions.contains(PeekOffsetOption::Visual) && | 
| 9769 | PresContext()->BidiEnabled()) { | 
| 9770 | nsIFrame* firstFrame; | 
| 9771 | bool isReordered; | 
| 9772 | nsIFrame* lastFrame; | 
| 9773 | MOZ_TRY(do { auto mozTryTempResult_ = ::mozilla::ToResult(it->CheckLineOrder (thisLine, &isReordered, &firstFrame, &lastFrame) ); if ((__builtin_expect(!!(mozTryTempResult_.isErr()), 0))) { return mozTryTempResult_.propagateErr(); } } while (0) | 
| 9774 | it->CheckLineOrder(thisLine, &isReordered, &firstFrame, &lastFrame))do { auto mozTryTempResult_ = ::mozilla::ToResult(it->CheckLineOrder (thisLine, &isReordered, &firstFrame, &lastFrame) ); if ((__builtin_expect(!!(mozTryTempResult_.isErr()), 0))) { return mozTryTempResult_.propagateErr(); } } while (0); | 
| 9775 | baseFrame = endOfLine ? lastFrame : firstFrame; | 
| 9776 | } else { | 
| 9777 | auto line = it->GetLine(thisLine).unwrap(); | 
| 9778 | |
| 9779 | nsIFrame* frame = line.mFirstFrameOnLine; | 
| 9780 | bool lastFrameWasEditable = false; | 
| 9781 | for (int32_t count = line.mNumFramesOnLine; count; | 
| 9782 | --count, frame = frame->GetNextSibling()) { | 
| 9783 | if (frame->IsGeneratedContentFrame()) { | 
| 9784 | continue; | 
| 9785 | } | 
| 9786 | // When jumping to the end of the line with the "end" key, | 
| 9787 | // try to skip over brFrames | 
| 9788 | if (endOfLine && line.mNumFramesOnLine > 1 && frame->IsBrFrame() && | 
| 9789 | lastFrameWasEditable == frame->GetContent()->IsEditable()) { | 
| 9790 | continue; | 
| 9791 | } | 
| 9792 | lastFrameWasEditable = | 
| 9793 | frame->GetContent() && frame->GetContent()->IsEditable(); | 
| 9794 | baseFrame = frame; | 
| 9795 | if (!endOfLine) { | 
| 9796 | break; | 
| 9797 | } | 
| 9798 | } | 
| 9799 | } | 
| 9800 | if (!baseFrame) { | 
| 9801 | return NS_ERROR_FAILURE; | 
| 9802 | } | 
| 9803 | // Make sure we are not leaving our inline editing host if exists | 
| 9804 | if (editingHost) { | 
| 9805 | if (nsIFrame* frame = editingHost->GetPrimaryFrame()) { | 
| 9806 | if (frame->IsInlineOutside() && | 
| 9807 | !editingHost->Contains(baseFrame->GetContent())) { | 
| 9808 | baseFrame = frame; | 
| 9809 | if (endOfLine) { | 
| 9810 | baseFrame = baseFrame->LastContinuation(); | 
| 9811 | } | 
| 9812 | } | 
| 9813 | } | 
| 9814 | } | 
| 9815 | FrameTarget targetFrame = DrillDownToSelectionFrame( | 
| 9816 | baseFrame, endOfLine, nsIFrame::IGNORE_NATIVE_ANONYMOUS_SUBTREE); | 
| 9817 | SetPeekResultFromFrame(*aPos, targetFrame.frame, endOfLine ? -1 : 0, | 
| 9818 | OffsetIsAtLineEdge::Yes); | 
| 9819 | if (endOfLine && targetFrame.frame->HasSignificantTerminalNewline()) { | 
| 9820 | // Do not position the caret after the terminating newline if we're | 
| 9821 | // trying to move to the end of line (see bug 596506) | 
| 9822 | --aPos->mContentOffset; | 
| 9823 | } | 
| 9824 | if (!aPos->mResultContent) { | 
| 9825 | return NS_ERROR_FAILURE; | 
| 9826 | } | 
| 9827 | return NS_OK; | 
| 9828 | } | 
| 9829 | |
| 9830 | nsresult nsIFrame::PeekOffset(PeekOffsetStruct* aPos) { | 
| 9831 | MOZ_ASSERT(aPos)do { static_assert( mozilla::detail::AssertionConditionType< decltype(aPos)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(aPos))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("aPos", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9831); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aPos" ")"); do { *((volatile int*)__null) = 9831; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 9832 | |
| 9833 | if (NS_WARN_IF(HasAnyStateBits(NS_FRAME_IS_DIRTY))NS_warn_if_impl(HasAnyStateBits(NS_FRAME_IS_DIRTY), "HasAnyStateBits(NS_FRAME_IS_DIRTY)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9833)) { | 
| 9834 | // FIXME(Bug 1654362): <caption> currently can remain dirty. | 
| 9835 | return NS_ERROR_UNEXPECTED; | 
| 9836 | } | 
| 9837 | |
| 9838 | // Translate content offset to be relative to frame | 
| 9839 | int32_t offset = aPos->mStartOffset - GetRangeForFrame(this).start; | 
| 9840 | |
| 9841 | switch (aPos->mAmount) { | 
| 9842 | case eSelectCharacter: | 
| 9843 | case eSelectCluster: | 
| 9844 | return PeekOffsetForCharacter(aPos, offset); | 
| 9845 | case eSelectWordNoSpace: | 
| 9846 | // eSelectWordNoSpace means that we should not be eating any whitespace | 
| 9847 | // when moving to the adjacent word. This means that we should set aPos-> | 
| 9848 | // mWordMovementType to eEndWord if we're moving forwards, and to | 
| 9849 | // eStartWord if we're moving backwards. | 
| 9850 | if (aPos->mDirection == eDirPrevious) { | 
| 9851 | aPos->mWordMovementType = eStartWord; | 
| 9852 | } else { | 
| 9853 | aPos->mWordMovementType = eEndWord; | 
| 9854 | } | 
| 9855 | // Intentionally fall through the eSelectWord case. | 
| 9856 | [[fallthrough]]; | 
| 9857 | case eSelectWord: | 
| 9858 | return PeekOffsetForWord(aPos, offset); | 
| 9859 | case eSelectLine: | 
| 9860 | return PeekOffsetForLine(aPos); | 
| 9861 | case eSelectBeginLine: | 
| 9862 | case eSelectEndLine: | 
| 9863 | return PeekOffsetForLineEdge(aPos); | 
| 9864 | case eSelectParagraph: | 
| 9865 | return PeekOffsetForParagraph(aPos); | 
| 9866 | default: { | 
| 9867 | NS_ASSERTION(false, "Invalid amount")do { if (!(false)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Invalid amount" , "false", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9867); MOZ_PretendNoReturn(); } } while (0); | 
| 9868 | return NS_ERROR_FAILURE; | 
| 9869 | } | 
| 9870 | } | 
| 9871 | } | 
| 9872 | |
| 9873 | nsIFrame::FrameSearchResult nsIFrame::PeekOffsetNoAmount(bool aForward, | 
| 9874 | int32_t* aOffset) { | 
| 9875 | NS_ASSERTION(aOffset && *aOffset <= 1, "aOffset out of range")do { if (!(aOffset && *aOffset <= 1)) { NS_DebugBreak (NS_DEBUG_ASSERTION, "aOffset out of range", "aOffset && *aOffset <= 1" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9875); MOZ_PretendNoReturn(); } } while (0); | 
| 9876 | // Sure, we can stop right here. | 
| 9877 | return FOUND; | 
| 9878 | } | 
| 9879 | |
| 9880 | nsIFrame::FrameSearchResult nsIFrame::PeekOffsetCharacter( | 
| 9881 | bool aForward, int32_t* aOffset, PeekOffsetCharacterOptions aOptions) { | 
| 9882 | NS_ASSERTION(aOffset && *aOffset <= 1, "aOffset out of range")do { if (!(aOffset && *aOffset <= 1)) { NS_DebugBreak (NS_DEBUG_ASSERTION, "aOffset out of range", "aOffset && *aOffset <= 1" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9882); MOZ_PretendNoReturn(); } } while (0); | 
| 9883 | int32_t startOffset = *aOffset; | 
| 9884 | // A negative offset means "end of frame", which in our case means offset 1. | 
| 9885 | if (startOffset < 0) { | 
| 9886 | startOffset = 1; | 
| 9887 | } | 
| 9888 | if (aForward == (startOffset == 0)) { | 
| 9889 | // We're before the frame and moving forward, or after it and moving | 
| 9890 | // backwards: skip to the other side and we're done. | 
| 9891 | *aOffset = 1 - startOffset; | 
| 9892 | return FOUND; | 
| 9893 | } | 
| 9894 | return CONTINUE; | 
| 9895 | } | 
| 9896 | |
| 9897 | nsIFrame::FrameSearchResult nsIFrame::PeekOffsetWord( | 
| 9898 | bool aForward, bool aWordSelectEatSpace, bool aIsKeyboardSelect, | 
| 9899 | int32_t* aOffset, PeekWordState* aState, bool /*aTrimSpaces*/) { | 
| 9900 | NS_ASSERTION(aOffset && *aOffset <= 1, "aOffset out of range")do { if (!(aOffset && *aOffset <= 1)) { NS_DebugBreak (NS_DEBUG_ASSERTION, "aOffset out of range", "aOffset && *aOffset <= 1" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9900); MOZ_PretendNoReturn(); } } while (0); | 
| 9901 | int32_t startOffset = *aOffset; | 
| 9902 | // This isn't text, so truncate the context | 
| 9903 | aState->mContext.Truncate(); | 
| 9904 | if (startOffset < 0) { | 
| 9905 | startOffset = 1; | 
| 9906 | } | 
| 9907 | if (aForward == (startOffset == 0)) { | 
| 9908 | // We're before the frame and moving forward, or after it and moving | 
| 9909 | // backwards. If we're looking for non-whitespace, we found it (without | 
| 9910 | // skipping this frame). | 
| 9911 | if (!aState->mAtStart) { | 
| 9912 | if (aState->mLastCharWasPunctuation) { | 
| 9913 | // We're not punctuation, so this is a punctuation boundary. | 
| 9914 | if (BreakWordBetweenPunctuation(aState, aForward, false, false, | 
| 9915 | aIsKeyboardSelect)) { | 
| 9916 | return FOUND; | 
| 9917 | } | 
| 9918 | } else { | 
| 9919 | // This is not a punctuation boundary. | 
| 9920 | if (aWordSelectEatSpace && aState->mSawBeforeType) { | 
| 9921 | return FOUND; | 
| 9922 | } | 
| 9923 | } | 
| 9924 | } | 
| 9925 | // Otherwise skip to the other side and note that we encountered | 
| 9926 | // non-whitespace. | 
| 9927 | *aOffset = 1 - startOffset; | 
| 9928 | aState->Update(false, // not punctuation | 
| 9929 | false // not whitespace | 
| 9930 | ); | 
| 9931 | if (!aWordSelectEatSpace) { | 
| 9932 | aState->SetSawBeforeType(); | 
| 9933 | } | 
| 9934 | } | 
| 9935 | return CONTINUE; | 
| 9936 | } | 
| 9937 | |
| 9938 | // static | 
| 9939 | bool nsIFrame::BreakWordBetweenPunctuation(const PeekWordState* aState, | 
| 9940 | bool aForward, bool aPunctAfter, | 
| 9941 | bool aWhitespaceAfter, | 
| 9942 | bool aIsKeyboardSelect) { | 
| 9943 | NS_ASSERTION(aPunctAfter != aState->mLastCharWasPunctuation,do { if (!(aPunctAfter != aState->mLastCharWasPunctuation) ) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Call this only at punctuation boundaries" , "aPunctAfter != aState->mLastCharWasPunctuation", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9944); MOZ_PretendNoReturn(); } } while (0) | 
| 9944 | "Call this only at punctuation boundaries")do { if (!(aPunctAfter != aState->mLastCharWasPunctuation) ) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Call this only at punctuation boundaries" , "aPunctAfter != aState->mLastCharWasPunctuation", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 9944); MOZ_PretendNoReturn(); } } while (0); | 
| 9945 | if (aState->mLastCharWasWhitespace) { | 
| 9946 | // We always stop between whitespace and punctuation | 
| 9947 | return true; | 
| 9948 | } | 
| 9949 | if (!StaticPrefs::layout_word_select_stop_at_punctuation()) { | 
| 9950 | // When this pref is false, we never stop at a punctuation boundary unless | 
| 9951 | // it's followed by whitespace (in the relevant direction). | 
| 9952 | return aWhitespaceAfter; | 
| 9953 | } | 
| 9954 | if (!aIsKeyboardSelect) { | 
| 9955 | // mouse caret movement (e.g. word selection) always stops at every | 
| 9956 | // punctuation boundary | 
| 9957 | return true; | 
| 9958 | } | 
| 9959 | bool afterPunct = aForward ? aState->mLastCharWasPunctuation : aPunctAfter; | 
| 9960 | if (!afterPunct) { | 
| 9961 | // keyboard caret movement only stops after punctuation (in content order) | 
| 9962 | return false; | 
| 9963 | } | 
| 9964 | // Stop only if we've seen some non-punctuation since the last whitespace; | 
| 9965 | // don't stop after punctuation that follows whitespace. | 
| 9966 | return aState->mSeenNonPunctuationSinceWhitespace; | 
| 9967 | } | 
| 9968 | |
| 9969 | std::pair<nsIFrame*, nsIFrame*> nsIFrame::GetContainingBlockForLine( | 
| 9970 | bool aLockScroll) const { | 
| 9971 | const nsIFrame* parentFrame = this; | 
| 9972 | const nsIFrame* frame; | 
| 9973 | while (parentFrame) { | 
| 9974 | frame = parentFrame; | 
| 9975 | if (frame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { | 
| 9976 | // if we are searching for a frame that is not in flow we will not find | 
| 9977 | // it. we must instead look for its placeholder | 
| 9978 | if (frame->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER)) { | 
| 9979 | // abspos continuations don't have placeholders, get the fif | 
| 9980 | frame = frame->FirstInFlow(); | 
| 9981 | } | 
| 9982 | frame = frame->GetPlaceholderFrame(); | 
| 9983 | if (!frame) { | 
| 9984 | return std::pair(nullptr, nullptr); | 
| 9985 | } | 
| 9986 | } | 
| 9987 | parentFrame = frame->GetParent(); | 
| 9988 | if (parentFrame) { | 
| 9989 | if (aLockScroll && parentFrame->IsScrollContainerFrame()) { | 
| 9990 | return std::pair(nullptr, nullptr); | 
| 9991 | } | 
| 9992 | if (parentFrame->CanProvideLineIterator()) { | 
| 9993 | return std::pair(const_cast<nsIFrame*>(parentFrame), | 
| 9994 | const_cast<nsIFrame*>(frame)); | 
| 9995 | } | 
| 9996 | } | 
| 9997 | } | 
| 9998 | return std::pair(nullptr, nullptr); | 
| 9999 | } | 
| 10000 | |
| 10001 | Result<bool, nsresult> nsIFrame::IsVisuallyAtLineEdge( | 
| 10002 | nsILineIterator* aLineIterator, int32_t aLine, nsDirection aDirection) { | 
| 10003 | auto line = aLineIterator->GetLine(aLine).unwrap(); | 
| 10004 | |
| 10005 | const bool lineIsRTL = aLineIterator->IsLineIteratorFlowRTL(); | 
| 10006 | |
| 10007 | nsIFrame *firstFrame = nullptr, *lastFrame = nullptr; | 
| 10008 | bool isReordered = false; | 
| 10009 | MOZ_TRY(aLineIterator->CheckLineOrder(aLine, &isReordered, &firstFrame,do { auto mozTryTempResult_ = ::mozilla::ToResult(aLineIterator ->CheckLineOrder(aLine, &isReordered, &firstFrame, &lastFrame)); if ((__builtin_expect(!!(mozTryTempResult_ .isErr()), 0))) { return mozTryTempResult_.propagateErr(); } } while (0) | 
| 10010 | &lastFrame))do { auto mozTryTempResult_ = ::mozilla::ToResult(aLineIterator ->CheckLineOrder(aLine, &isReordered, &firstFrame, &lastFrame)); if ((__builtin_expect(!!(mozTryTempResult_ .isErr()), 0))) { return mozTryTempResult_.propagateErr(); } } while (0); | 
| 10011 | if (!firstFrame || !lastFrame) { | 
| 10012 | return true; // XXX: Why true? We check whether `this` is at the edge... | 
| 10013 | } | 
| 10014 | |
| 10015 | nsIFrame* leftmostFrame = lineIsRTL ? lastFrame : firstFrame; | 
| 10016 | nsIFrame* rightmostFrame = lineIsRTL ? firstFrame : lastFrame; | 
| 10017 | auto FrameIsRTL = [](nsIFrame* aFrame) { | 
| 10018 | return nsBidiPresUtils::FrameDirection(aFrame) == | 
| 10019 | mozilla::intl::BidiDirection::RTL; | 
| 10020 | }; | 
| 10021 | if (!lineIsRTL == (aDirection == eDirPrevious)) { | 
| 10022 | nsIFrame* maybeLeftmostFrame = leftmostFrame; | 
| 10023 | for ([[maybe_unused]] int32_t i : IntegerRange(line.mNumFramesOnLine)) { | 
| 10024 | if (maybeLeftmostFrame == this) { | 
| 10025 | return true; | 
| 10026 | } | 
| 10027 | // If left edge of the line starts with placeholder frames, we can ignore | 
| 10028 | // them and should keep checking the following frames. | 
| 10029 | if (!maybeLeftmostFrame->IsPlaceholderFrame()) { | 
| 10030 | if ((FrameIsRTL(maybeLeftmostFrame) == lineIsRTL) == | 
| 10031 | (aDirection == eDirPrevious)) { | 
| 10032 | nsIFrame::GetFirstLeaf(&maybeLeftmostFrame); | 
| 10033 | } else { | 
| 10034 | nsIFrame::GetLastLeaf(&maybeLeftmostFrame); | 
| 10035 | } | 
| 10036 | return maybeLeftmostFrame == this; | 
| 10037 | } | 
| 10038 | maybeLeftmostFrame = nsBidiPresUtils::GetFrameToRightOf( | 
| 10039 | maybeLeftmostFrame, line.mFirstFrameOnLine, line.mNumFramesOnLine); | 
| 10040 | if (!maybeLeftmostFrame) { | 
| 10041 | return false; | 
| 10042 | } | 
| 10043 | } | 
| 10044 | return false; | 
| 10045 | } | 
| 10046 | |
| 10047 | nsIFrame* maybeRightmostFrame = rightmostFrame; | 
| 10048 | for ([[maybe_unused]] int32_t i : IntegerRange(line.mNumFramesOnLine)) { | 
| 10049 | if (maybeRightmostFrame == this) { | 
| 10050 | return true; | 
| 10051 | } | 
| 10052 | // If the line ends with placehlder frames, we can ignore them and should | 
| 10053 | // keep checking the preceding frames. | 
| 10054 | if (!maybeRightmostFrame->IsPlaceholderFrame()) { | 
| 10055 | if ((FrameIsRTL(maybeRightmostFrame) == lineIsRTL) == | 
| 10056 | (aDirection == eDirPrevious)) { | 
| 10057 | nsIFrame::GetFirstLeaf(&maybeRightmostFrame); | 
| 10058 | } else { | 
| 10059 | nsIFrame::GetLastLeaf(&maybeRightmostFrame); | 
| 10060 | } | 
| 10061 | return maybeRightmostFrame == this; | 
| 10062 | } | 
| 10063 | maybeRightmostFrame = nsBidiPresUtils::GetFrameToLeftOf( | 
| 10064 | maybeRightmostFrame, line.mFirstFrameOnLine, line.mNumFramesOnLine); | 
| 10065 | if (!maybeRightmostFrame) { | 
| 10066 | return false; | 
| 10067 | } | 
| 10068 | } | 
| 10069 | return false; | 
| 10070 | } | 
| 10071 | |
| 10072 | Result<bool, nsresult> nsIFrame::IsLogicallyAtLineEdge( | 
| 10073 | nsILineIterator* aLineIterator, int32_t aLine, nsDirection aDirection) { | 
| 10074 | auto line = aLineIterator->GetLine(aLine).unwrap(); | 
| 10075 | if (!line.mNumFramesOnLine) { | 
| 10076 | return false; | 
| 10077 | } | 
| 10078 | MOZ_ASSERT(line.mFirstFrameOnLine)do { static_assert( mozilla::detail::AssertionConditionType< decltype(line.mFirstFrameOnLine)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(line.mFirstFrameOnLine))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("line.mFirstFrameOnLine" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10078); AnnotateMozCrashReason("MOZ_ASSERT" "(" "line.mFirstFrameOnLine" ")"); do { *((volatile int*)__null) = 10078; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 10079 | |
| 10080 | if (aDirection == eDirPrevious) { | 
| 10081 | nsIFrame* maybeFirstFrame = line.mFirstFrameOnLine; | 
| 10082 | for ([[maybe_unused]] int32_t i : IntegerRange(line.mNumFramesOnLine)) { | 
| 10083 | if (maybeFirstFrame == this) { | 
| 10084 | return true; | 
| 10085 | } | 
| 10086 | // If the line starts with placeholder frames, we can ignore them and | 
| 10087 | // should keep checking the following frames. | 
| 10088 | if (!maybeFirstFrame->IsPlaceholderFrame()) { | 
| 10089 | nsIFrame::GetFirstLeaf(&maybeFirstFrame); | 
| 10090 | return maybeFirstFrame == this; | 
| 10091 | } | 
| 10092 | maybeFirstFrame = maybeFirstFrame->GetNextSibling(); | 
| 10093 | if (!maybeFirstFrame) { | 
| 10094 | return false; | 
| 10095 | } | 
| 10096 | } | 
| 10097 | return false; | 
| 10098 | } | 
| 10099 | |
| 10100 | // eDirNext | 
| 10101 | nsIFrame* maybeLastFrame = line.GetLastFrameOnLine(); | 
| 10102 | for ([[maybe_unused]] int32_t i : IntegerRange(line.mNumFramesOnLine)) { | 
| 10103 | if (maybeLastFrame == this) { | 
| 10104 | return true; | 
| 10105 | } | 
| 10106 | // If the line ends with placehlder frames, we can ignore them and should | 
| 10107 | // keep checking the preceding frames. | 
| 10108 | if (!maybeLastFrame->IsPlaceholderFrame()) { | 
| 10109 | nsIFrame::GetLastLeaf(&maybeLastFrame); | 
| 10110 | return maybeLastFrame == this; | 
| 10111 | } | 
| 10112 | maybeLastFrame = maybeLastFrame->GetPrevSibling(); | 
| 10113 | } | 
| 10114 | return false; | 
| 10115 | } | 
| 10116 | |
| 10117 | nsIFrame::SelectablePeekReport nsIFrame::GetFrameFromDirection( | 
| 10118 | nsDirection aDirection, const PeekOffsetOptions& aOptions) { | 
| 10119 | SelectablePeekReport result; | 
| 10120 | |
| 10121 | nsPresContext* presContext = PresContext(); | 
| 10122 | const bool needsVisualTraversal = | 
| 10123 | aOptions.contains(PeekOffsetOption::Visual) && presContext->BidiEnabled(); | 
| 10124 | const bool followOofs = | 
| 10125 | !aOptions.contains(PeekOffsetOption::StopAtPlaceholder); | 
| 10126 | nsFrameIterator frameIterator( | 
| 10127 | presContext, this, nsFrameIterator::Type::Leaf, needsVisualTraversal, | 
| 10128 | aOptions.contains(PeekOffsetOption::StopAtScroller), followOofs, | 
| 10129 | false // aSkipPopupChecks | 
| 10130 | ); | 
| 10131 | |
| 10132 | // Find the prev/next selectable frame | 
| 10133 | bool selectable = false; | 
| 10134 | nsIFrame* traversedFrame = this; | 
| 10135 | AutoAssertNoDomMutations guard; | 
| 10136 | const nsIContent* const nativeAnonymousSubtreeContent = | 
| 10137 | GetClosestNativeAnonymousSubtreeRoot(); | 
| 10138 | while (!selectable) { | 
| 10139 | auto [blockFrame, lineFrame] = traversedFrame->GetContainingBlockForLine( | 
| 10140 | aOptions.contains(PeekOffsetOption::StopAtScroller)); | 
| 10141 | if (!blockFrame) { | 
| 10142 | return result; | 
| 10143 | } | 
| 10144 | |
| 10145 | nsILineIterator* it = blockFrame->GetLineIterator(); | 
| 10146 | int32_t thisLine = it->FindLineContaining(lineFrame); | 
| 10147 | if (thisLine < 0) { | 
| 10148 | return result; | 
| 10149 | } | 
| 10150 | |
| 10151 | bool atLineEdge; | 
| 10152 | MOZ_TRY_VAR(do { auto mozTryVarTempResult_ = (needsVisualTraversal ? traversedFrame ->IsVisuallyAtLineEdge(it, thisLine, aDirection) : traversedFrame ->IsLogicallyAtLineEdge(it, thisLine, aDirection)); if ((__builtin_expect (!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_ .propagateErr(); } (atLineEdge) = mozTryVarTempResult_.unwrap (); } while (0) | 
| 10153 | atLineEdge,do { auto mozTryVarTempResult_ = (needsVisualTraversal ? traversedFrame ->IsVisuallyAtLineEdge(it, thisLine, aDirection) : traversedFrame ->IsLogicallyAtLineEdge(it, thisLine, aDirection)); if ((__builtin_expect (!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_ .propagateErr(); } (atLineEdge) = mozTryVarTempResult_.unwrap (); } while (0) | 
| 10154 | needsVisualTraversaldo { auto mozTryVarTempResult_ = (needsVisualTraversal ? traversedFrame ->IsVisuallyAtLineEdge(it, thisLine, aDirection) : traversedFrame ->IsLogicallyAtLineEdge(it, thisLine, aDirection)); if ((__builtin_expect (!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_ .propagateErr(); } (atLineEdge) = mozTryVarTempResult_.unwrap (); } while (0) | 
| 10155 | ? traversedFrame->IsVisuallyAtLineEdge(it, thisLine, aDirection)do { auto mozTryVarTempResult_ = (needsVisualTraversal ? traversedFrame ->IsVisuallyAtLineEdge(it, thisLine, aDirection) : traversedFrame ->IsLogicallyAtLineEdge(it, thisLine, aDirection)); if ((__builtin_expect (!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_ .propagateErr(); } (atLineEdge) = mozTryVarTempResult_.unwrap (); } while (0) | 
| 10156 | : traversedFrame->IsLogicallyAtLineEdge(it, thisLine, aDirection))do { auto mozTryVarTempResult_ = (needsVisualTraversal ? traversedFrame ->IsVisuallyAtLineEdge(it, thisLine, aDirection) : traversedFrame ->IsLogicallyAtLineEdge(it, thisLine, aDirection)); if ((__builtin_expect (!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_ .propagateErr(); } (atLineEdge) = mozTryVarTempResult_.unwrap (); } while (0); | 
| 10157 | if (atLineEdge) { | 
| 10158 | result.mJumpedLine = true; | 
| 10159 | if (!aOptions.contains(PeekOffsetOption::JumpLines)) { | 
| 10160 | return result; // we are done. cannot jump lines | 
| 10161 | } | 
| 10162 | int32_t lineToCheckWrap = | 
| 10163 | aDirection == eDirPrevious ? thisLine - 1 : thisLine; | 
| 10164 | if (lineToCheckWrap < 0 || | 
| 10165 | !it->GetLine(lineToCheckWrap).unwrap().mIsWrapped) { | 
| 10166 | result.mJumpedHardBreak = true; | 
| 10167 | } | 
| 10168 | } | 
| 10169 | |
| 10170 | traversedFrame = frameIterator.Traverse(aDirection == eDirNext); | 
| 10171 | if (!traversedFrame) { | 
| 10172 | return result; | 
| 10173 | } | 
| 10174 | |
| 10175 | if (aOptions.contains(PeekOffsetOption::StopAtPlaceholder) && | 
| 10176 | traversedFrame->IsPlaceholderFrame()) { | 
| 10177 | // XXX If the placeholder frame does not have meaningful content, the user | 
| 10178 | // may want to select as a word around the out-of-flow cotent. However, | 
| 10179 | // non-text frame resets context in nsIFrame::PeekOffsetWord(). Therefore, | 
| 10180 | // next text frame considers the new word starts from its edge. So, it's | 
| 10181 | // not enough to implement such behavior with adding a check here whether | 
| 10182 | // the real frame may change the word with its contents if it were not | 
| 10183 | // out-of-flow. | 
| 10184 | result.mFoundPlaceholder = true; | 
| 10185 | return result; | 
| 10186 | } | 
| 10187 | |
| 10188 | auto IsSelectable = | 
| 10189 | [aOptions, nativeAnonymousSubtreeContent](const nsIFrame* aFrame) { | 
| 10190 | if (!aFrame->IsSelectable(nullptr)) { | 
| 10191 | return false; | 
| 10192 | } | 
| 10193 | // If the new frame is in a native anonymous subtree, we should treat | 
| 10194 | // it as not selectable unless the frame and found frame are in same | 
| 10195 | // subtree. | 
| 10196 | if (aFrame->GetClosestNativeAnonymousSubtreeRoot() != | 
| 10197 | nativeAnonymousSubtreeContent) { | 
| 10198 | return false; | 
| 10199 | } | 
| 10200 | return !aOptions.contains(PeekOffsetOption::ForceEditableRegion) || | 
| 10201 | aFrame->GetContent()->IsEditable(); | 
| 10202 | }; | 
| 10203 | |
| 10204 | // Skip br frames, but only if we can select something before hitting the | 
| 10205 | // end of the line or a non-selectable region. | 
| 10206 | if (atLineEdge && aDirection == eDirPrevious && | 
| 10207 | traversedFrame->IsBrFrame()) { | 
| 10208 | for (nsIFrame* current = traversedFrame->GetPrevSibling(); current; | 
| 10209 | current = current->GetPrevSibling()) { | 
| 10210 | if (!current->IsBlockOutside() && IsSelectable(current)) { | 
| 10211 | if (!current->IsBrFrame()) { | 
| 10212 | result.mIgnoredBrFrame = true; | 
| 10213 | } | 
| 10214 | break; | 
| 10215 | } | 
| 10216 | } | 
| 10217 | if (result.mIgnoredBrFrame) { | 
| 10218 | continue; | 
| 10219 | } | 
| 10220 | } | 
| 10221 | |
| 10222 | selectable = IsSelectable(traversedFrame); | 
| 10223 | if (!selectable) { | 
| 10224 | if (traversedFrame->IsSelectable(nullptr)) { | 
| 10225 | result.mHasSelectableFrame = true; | 
| 10226 | } | 
| 10227 | result.mMovedOverNonSelectableText = true; | 
| 10228 | } | 
| 10229 | } // while (!selectable) | 
| 10230 | |
| 10231 | result.mOffset = (aDirection == eDirNext) ? 0 : -1; | 
| 10232 | |
| 10233 | if (aOptions.contains(PeekOffsetOption::Visual) && | 
| 10234 | nsBidiPresUtils::IsReversedDirectionFrame(traversedFrame)) { | 
| 10235 | // The new frame is reverse-direction, go to the other end | 
| 10236 | result.mOffset = -1 - result.mOffset; | 
| 10237 | } | 
| 10238 | result.mFrame = traversedFrame; | 
| 10239 | return result; | 
| 10240 | } | 
| 10241 | |
| 10242 | nsIFrame::SelectablePeekReport nsIFrame::GetFrameFromDirection( | 
| 10243 | const PeekOffsetStruct& aPos) { | 
| 10244 | return GetFrameFromDirection(aPos.mDirection, aPos.mOptions); | 
| 10245 | } | 
| 10246 | |
| 10247 | nsView* nsIFrame::GetClosestView(nsPoint* aOffset) const { | 
| 10248 | nsPoint offset(0, 0); | 
| 10249 | for (const nsIFrame* f = this; f; f = f->GetParent()) { | 
| 10250 | if (f->HasView()) { | 
| 10251 | if (aOffset) { | 
| 10252 | *aOffset = offset; | 
| 10253 | } | 
| 10254 | return f->GetView(); | 
| 10255 | } | 
| 10256 | offset += f->GetPosition(); | 
| 10257 | } | 
| 10258 | |
| 10259 | MOZ_ASSERT_UNREACHABLE("No view on any parent?  How did that happen?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "No view on any parent? How did that happen?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10259); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "No view on any parent? How did that happen?" ")"); do { *((volatile int*)__null) = 10259; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 10260 | return nullptr; | 
| 10261 | } | 
| 10262 | |
| 10263 | /* virtual */ | 
| 10264 | void nsIFrame::ChildIsDirty(nsIFrame* aChild) { | 
| 10265 | MOZ_ASSERT_UNREACHABLE(do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "should never be called on a frame that doesn't " "inherit from nsContainerFrame" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10267); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "should never be called on a frame that doesn't " "inherit from nsContainerFrame" ")"); do { *((volatile int*) __null) = 10267; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false) | 
| 10266 | "should never be called on a frame that doesn't "do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "should never be called on a frame that doesn't " "inherit from nsContainerFrame" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10267); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "should never be called on a frame that doesn't " "inherit from nsContainerFrame" ")"); do { *((volatile int*) __null) = 10267; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false) | 
| 10267 | "inherit from nsContainerFrame")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "should never be called on a frame that doesn't " "inherit from nsContainerFrame" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10267); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "should never be called on a frame that doesn't " "inherit from nsContainerFrame" ")"); do { *((volatile int*) __null) = 10267; __attribute__((nomerge)) ::abort(); } while ( false); } } while (false); | 
| 10268 | } | 
| 10269 | |
| 10270 | #ifdef ACCESSIBILITY1 | 
| 10271 | a11y::AccType nsIFrame::AccessibleType() { | 
| 10272 | if (IsTableCaption() && !GetRect().IsEmpty()) { | 
| 10273 | return a11y::eHTMLCaptionType; | 
| 10274 | } | 
| 10275 | return a11y::eNoType; | 
| 10276 | } | 
| 10277 | #endif | 
| 10278 | |
| 10279 | bool nsIFrame::ClearOverflowRects() { | 
| 10280 | if (mOverflow.mType == OverflowStorageType::None) { | 
| 10281 | return false; | 
| 10282 | } | 
| 10283 | if (mOverflow.mType == OverflowStorageType::Large) { | 
| 10284 | RemoveProperty(OverflowAreasProperty()); | 
| 10285 | } | 
| 10286 | mOverflow.mType = OverflowStorageType::None; | 
| 10287 | return true; | 
| 10288 | } | 
| 10289 | |
| 10290 | bool nsIFrame::SetOverflowAreas(const OverflowAreas& aOverflowAreas) { | 
| 10291 | if (mOverflow.mType == OverflowStorageType::Large) { | 
| 10292 | OverflowAreas* overflow = GetOverflowAreasProperty(); | 
| 10293 | bool changed = *overflow != aOverflowAreas; | 
| 10294 | *overflow = aOverflowAreas; | 
| 10295 | |
| 10296 | // Don't bother with converting to the deltas form if we already | 
| 10297 | // have a property. | 
| 10298 | return changed; | 
| 10299 | } | 
| 10300 | |
| 10301 | const nsRect& vis = aOverflowAreas.InkOverflow(); | 
| 10302 | uint32_t l = -vis.x, // left edge: positive delta is leftwards | 
| 10303 | t = -vis.y, // top: positive is upwards | 
| 10304 | r = vis.XMost() - mRect.width, // right: positive is rightwards | 
| 10305 | b = vis.YMost() - mRect.height; // bottom: positive is downwards | 
| 10306 | if (aOverflowAreas.ScrollableOverflow().IsEqualEdges( | 
| 10307 | nsRect(nsPoint(0, 0), GetSize())) && | 
| 10308 | l <= InkOverflowDeltas::kMax && t <= InkOverflowDeltas::kMax && | 
| 10309 | r <= InkOverflowDeltas::kMax && b <= InkOverflowDeltas::kMax && | 
| 10310 | // we have to check these against zero because we *never* want to | 
| 10311 | // set a frame as having no overflow in this function. This is | 
| 10312 | // because FinishAndStoreOverflow calls this function prior to | 
| 10313 | // SetRect based on whether the overflow areas match aNewSize. | 
| 10314 | // In the case where the overflow areas exactly match mRect but | 
| 10315 | // do not match aNewSize, we need to store overflow in a property | 
| 10316 | // so that our eventual SetRect/SetSize will know that it has to | 
| 10317 | // reset our overflow areas. | 
| 10318 | (l | t | r | b) != 0) { | 
| 10319 | InkOverflowDeltas oldDeltas = mOverflow.mInkOverflowDeltas; | 
| 10320 | // It's a "small" overflow area so we store the deltas for each edge | 
| 10321 | // directly in the frame, rather than allocating a separate rect. | 
| 10322 | // If they're all zero, that's fine; we're setting things to | 
| 10323 | // no-overflow. | 
| 10324 | mOverflow.mInkOverflowDeltas.mLeft = l; | 
| 10325 | mOverflow.mInkOverflowDeltas.mTop = t; | 
| 10326 | mOverflow.mInkOverflowDeltas.mRight = r; | 
| 10327 | mOverflow.mInkOverflowDeltas.mBottom = b; | 
| 10328 | // There was no scrollable overflow before, and there isn't now. | 
| 10329 | return oldDeltas != mOverflow.mInkOverflowDeltas; | 
| 10330 | } else { | 
| 10331 | bool changed = | 
| 10332 | !aOverflowAreas.ScrollableOverflow().IsEqualEdges( | 
| 10333 | nsRect(nsPoint(0, 0), GetSize())) || | 
| 10334 | !aOverflowAreas.InkOverflow().IsEqualEdges(InkOverflowFromDeltas()); | 
| 10335 | |
| 10336 | // it's a large overflow area that we need to store as a property | 
| 10337 | mOverflow.mType = OverflowStorageType::Large; | 
| 10338 | AddProperty(OverflowAreasProperty(), new OverflowAreas(aOverflowAreas)); | 
| 10339 | return changed; | 
| 10340 | } | 
| 10341 | } | 
| 10342 | |
| 10343 | enum class ApplyTransform : bool { No, Yes }; | 
| 10344 | |
| 10345 | /** | 
| 10346 | * Compute the outline inner rect (so without outline-width and outline-offset) | 
| 10347 | * of aFrame, maybe iterating over its descendants, in aFrame's coordinate space | 
| 10348 | * or its post-transform coordinate space (depending on aApplyTransform). | 
| 10349 | */ | 
| 10350 | static nsRect ComputeOutlineInnerRect( | 
| 10351 | nsIFrame* aFrame, ApplyTransform aApplyTransform, bool& aOutValid, | 
| 10352 | const nsSize* aSizeOverride = nullptr, | 
| 10353 | const OverflowAreas* aOverflowOverride = nullptr) { | 
| 10354 | const nsRect bounds(nsPoint(0, 0), | 
| 10355 | aSizeOverride ? *aSizeOverride : aFrame->GetSize()); | 
| 10356 | |
| 10357 | // The SVG container frames besides SVGTextFrame do not maintain | 
| 10358 | // an accurate mRect. It will make the outline be larger than | 
| 10359 | // we expect, we need to make them narrow to their children's outline. | 
| 10360 | // aOutValid is set to false if the returned nsRect is not valid | 
| 10361 | // and should not be included in the outline rectangle. | 
| 10362 | aOutValid = !aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || | 
| 10363 | !aFrame->IsSVGContainerFrame() || aFrame->IsSVGTextFrame(); | 
| 10364 | |
| 10365 | nsRect u; | 
| 10366 | |
| 10367 | if (!aFrame->FrameMaintainsOverflow()) { | 
| 10368 | return u; | 
| 10369 | } | 
| 10370 | |
| 10371 | // Start from our border-box, transformed. See comment below about | 
| 10372 | // transform of children. | 
| 10373 | bool doTransform = | 
| 10374 | aApplyTransform == ApplyTransform::Yes && aFrame->IsTransformed(); | 
| 10375 | TransformReferenceBox boundsRefBox(nullptr, bounds); | 
| 10376 | if (doTransform) { | 
| 10377 | u = nsDisplayTransform::TransformRect(bounds, aFrame, boundsRefBox); | 
| 10378 | } else { | 
| 10379 | u = bounds; | 
| 10380 | } | 
| 10381 | |
| 10382 | if (aOutValid && !StaticPrefs::layout_outline_include_overflow()) { | 
| 10383 | return u; | 
| 10384 | } | 
| 10385 | |
| 10386 | // Only iterate through the children if the overflow areas suggest | 
| 10387 | // that we might need to, and if the frame doesn't clip its overflow | 
| 10388 | // anyway. | 
| 10389 | if (aOverflowOverride) { | 
| 10390 | if (!doTransform && bounds.IsEqualEdges(aOverflowOverride->InkOverflow()) && | 
| 10391 | bounds.IsEqualEdges(aOverflowOverride->ScrollableOverflow())) { | 
| 10392 | return u; | 
| 10393 | } | 
| 10394 | } else { | 
| 10395 | if (!doTransform && bounds.IsEqualEdges(aFrame->InkOverflowRect()) && | 
| 10396 | bounds.IsEqualEdges(aFrame->ScrollableOverflowRect())) { | 
| 10397 | return u; | 
| 10398 | } | 
| 10399 | } | 
| 10400 | const nsStyleDisplay* disp = aFrame->StyleDisplay(); | 
| 10401 | LayoutFrameType fType = aFrame->Type(); | 
| 10402 | if (fType == LayoutFrameType::ScrollContainer || | 
| 10403 | fType == LayoutFrameType::ListControl || | 
| 10404 | fType == LayoutFrameType::SVGOuterSVG) { | 
| 10405 | return u; | 
| 10406 | } | 
| 10407 | |
| 10408 | auto overflowClipAxes = aFrame->ShouldApplyOverflowClipping(disp); | 
| 10409 | auto overflowClipMargin = aFrame->OverflowClipMargin(overflowClipAxes); | 
| 10410 | if (overflowClipAxes == kPhysicalAxesBoth && overflowClipMargin == nsSize()) { | 
| 10411 | return u; | 
| 10412 | } | 
| 10413 | |
| 10414 | const nsStyleEffects* effects = aFrame->StyleEffects(); | 
| 10415 | Maybe<nsRect> clipPropClipRect = | 
| 10416 | aFrame->GetClipPropClipRect(disp, effects, bounds.Size()); | 
| 10417 | |
| 10418 | // Iterate over all children except pop-up, absolutely-positioned, | 
| 10419 | // float, and overflow ones. | 
| 10420 | const FrameChildListIDs skip = { | 
| 10421 | FrameChildListID::Absolute, FrameChildListID::Fixed, | 
| 10422 | FrameChildListID::Float, FrameChildListID::Overflow}; | 
| 10423 | for (const auto& [list, listID] : aFrame->ChildLists()) { | 
| 10424 | if (skip.contains(listID)) { | 
| 10425 | continue; | 
| 10426 | } | 
| 10427 | |
| 10428 | for (nsIFrame* child : list) { | 
| 10429 | if (child->IsPlaceholderFrame()) { | 
| 10430 | continue; | 
| 10431 | } | 
| 10432 | |
| 10433 | // Note that passing ApplyTransform::Yes when | 
| 10434 | // child->Combines3DTransformWithAncestors() returns true is incorrect if | 
| 10435 | // our aApplyTransform is No... but the opposite would be as well. | 
| 10436 | // This is because elements within a preserve-3d scene are always | 
| 10437 | // transformed up to the top of the scene. This means we don't have a | 
| 10438 | // mechanism for getting a transform up to an intermediate point within | 
| 10439 | // the scene. We choose to over-transform rather than under-transform | 
| 10440 | // because this is consistent with other overflow areas. | 
| 10441 | bool validRect = true; | 
| 10442 | nsRect childRect = | 
| 10443 | ComputeOutlineInnerRect(child, ApplyTransform::Yes, validRect) + | 
| 10444 | child->GetPosition(); | 
| 10445 | |
| 10446 | if (!validRect) { | 
| 10447 | continue; | 
| 10448 | } | 
| 10449 | |
| 10450 | if (clipPropClipRect) { | 
| 10451 | // Intersect with the clip before transforming. | 
| 10452 | childRect.IntersectRect(childRect, *clipPropClipRect); | 
| 10453 | } | 
| 10454 | |
| 10455 | // Note that we transform each child separately according to | 
| 10456 | // aFrame's transform, and then union, which gives a different | 
| 10457 | // (smaller) result from unioning and then transforming the | 
| 10458 | // union. This doesn't match the way we handle overflow areas | 
| 10459 | // with 2-D transforms, though it does match the way we handle | 
| 10460 | // overflow areas in preserve-3d 3-D scenes. | 
| 10461 | if (doTransform && !child->Combines3DTransformWithAncestors()) { | 
| 10462 | childRect = | 
| 10463 | nsDisplayTransform::TransformRect(childRect, aFrame, boundsRefBox); | 
| 10464 | } | 
| 10465 | |
| 10466 | // If a SVGContainer has a non-SVGContainer child, we assign | 
| 10467 | // its child's outline to this SVGContainer directly. | 
| 10468 | if (!aOutValid && validRect) { | 
| 10469 | u = childRect; | 
| 10470 | aOutValid = true; | 
| 10471 | } else { | 
| 10472 | u = u.UnionEdges(childRect); | 
| 10473 | } | 
| 10474 | } | 
| 10475 | } | 
| 10476 | |
| 10477 | if (!overflowClipAxes.isEmpty()) { | 
| 10478 | OverflowAreas::ApplyOverflowClippingOnRect(u, bounds, overflowClipAxes, | 
| 10479 | overflowClipMargin); | 
| 10480 | } | 
| 10481 | return u; | 
| 10482 | } | 
| 10483 | |
| 10484 | static void ComputeAndIncludeOutlineArea(nsIFrame* aFrame, | 
| 10485 | OverflowAreas& aOverflowAreas, | 
| 10486 | const nsSize& aNewSize) { | 
| 10487 | const nsStyleOutline* outline = aFrame->StyleOutline(); | 
| 10488 | if (!outline->ShouldPaintOutline()) { | 
| 10489 | return; | 
| 10490 | } | 
| 10491 | |
| 10492 | // When the outline property is set on a :-moz-block-inside-inline-wrapper | 
| 10493 | // pseudo-element, it inherited that outline from the inline that was broken | 
| 10494 | // because it contained a block. In that case, we don't want a really wide | 
| 10495 | // outline if the block inside the inline is narrow, so union the actual | 
| 10496 | // contents of the anonymous blocks. | 
| 10497 | nsIFrame* frameForArea = aFrame; | 
| 10498 | do { | 
| 10499 | PseudoStyleType pseudoType = frameForArea->Style()->GetPseudoType(); | 
| 10500 | if (pseudoType != PseudoStyleType::mozBlockInsideInlineWrapper) { | 
| 10501 | break; | 
| 10502 | } | 
| 10503 | // If we're done, we really want it and all its later siblings. | 
| 10504 | frameForArea = frameForArea->PrincipalChildList().FirstChild(); | 
| 10505 | NS_ASSERTION(frameForArea, "anonymous block with no children?")do { if (!(frameForArea)) { NS_DebugBreak(NS_DEBUG_ASSERTION, "anonymous block with no children?", "frameForArea", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10505); MOZ_PretendNoReturn(); } } while (0); | 
| 10506 | } while (frameForArea); | 
| 10507 | |
| 10508 | // Find the union of the border boxes of all descendants, or in | 
| 10509 | // the block-in-inline case, all descendants we care about. | 
| 10510 | // | 
| 10511 | // Note that the interesting perspective-related cases are taken | 
| 10512 | // care of by the code that handles those issues for overflow | 
| 10513 | // calling FinishAndStoreOverflow again, which in turn calls this | 
| 10514 | // function again. We still need to deal with preserve-3d a bit. | 
| 10515 | nsRect innerRect; | 
| 10516 | bool validRect = false; | 
| 10517 | if (frameForArea == aFrame) { | 
| 10518 | innerRect = ComputeOutlineInnerRect(aFrame, ApplyTransform::No, validRect, | 
| 10519 | &aNewSize, &aOverflowAreas); | 
| 10520 | } else { | 
| 10521 | for (; frameForArea; frameForArea = frameForArea->GetNextSibling()) { | 
| 10522 | nsRect r = | 
| 10523 | ComputeOutlineInnerRect(frameForArea, ApplyTransform::Yes, validRect); | 
| 10524 | |
| 10525 | // Adjust for offsets transforms up to aFrame's pre-transform | 
| 10526 | // (i.e., normal) coordinate space; see comments in | 
| 10527 | // UnionBorderBoxes for some of the subtlety here. | 
| 10528 | for (nsIFrame *f = frameForArea, *parent = f->GetParent(); | 
| 10529 | /* see middle of loop */; f = parent, parent = f->GetParent()) { | 
| 10530 | r += f->GetPosition(); | 
| 10531 | if (parent == aFrame) { | 
| 10532 | break; | 
| 10533 | } | 
| 10534 | if (parent->IsTransformed() && !f->Combines3DTransformWithAncestors()) { | 
| 10535 | TransformReferenceBox refBox(parent); | 
| 10536 | r = nsDisplayTransform::TransformRect(r, parent, refBox); | 
| 10537 | } | 
| 10538 | } | 
| 10539 | |
| 10540 | innerRect.UnionRect(innerRect, r); | 
| 10541 | } | 
| 10542 | } | 
| 10543 | |
| 10544 | // Keep this code in sync with nsDisplayOutline::GetInnerRect. | 
| 10545 | if (innerRect == aFrame->GetRectRelativeToSelf()) { | 
| 10546 | aFrame->RemoveProperty(nsIFrame::OutlineInnerRectProperty()); | 
| 10547 | } else { | 
| 10548 | SetOrUpdateRectValuedProperty(aFrame, nsIFrame::OutlineInnerRectProperty(), | 
| 10549 | innerRect); | 
| 10550 | } | 
| 10551 | |
| 10552 | nsRect outerRect(innerRect); | 
| 10553 | outerRect.Inflate(outline->EffectiveOffsetFor(outerRect)); | 
| 10554 | |
| 10555 | if (outline->mOutlineStyle.IsAuto()) { | 
| 10556 | nsPresContext* pc = aFrame->PresContext(); | 
| 10557 | |
| 10558 | pc->Theme()->GetWidgetOverflow(pc->DeviceContext(), aFrame, | 
| 10559 | StyleAppearance::FocusOutline, &outerRect); | 
| 10560 | } else { | 
| 10561 | const nscoord width = outline->GetOutlineWidth(); | 
| 10562 | outerRect.Inflate(width); | 
| 10563 | } | 
| 10564 | |
| 10565 | nsRect& vo = aOverflowAreas.InkOverflow(); | 
| 10566 | vo = vo.UnionEdges(innerRect.Union(outerRect)); | 
| 10567 | } | 
| 10568 | |
| 10569 | bool nsIFrame::FinishAndStoreOverflow(OverflowAreas& aOverflowAreas, | 
| 10570 | nsSize aNewSize, nsSize* aOldSize, | 
| 10571 | const nsStyleDisplay* aStyleDisplay) { | 
| 10572 | MOZ_ASSERT(FrameMaintainsOverflow(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(FrameMaintainsOverflow())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(FrameMaintainsOverflow()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("FrameMaintainsOverflow()" " (" "Don't call - overflow rects not maintained on these SVG frames" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10573); AnnotateMozCrashReason("MOZ_ASSERT" "(" "FrameMaintainsOverflow()" ") (" "Don't call - overflow rects not maintained on these SVG frames" ")"); do { *((volatile int*)__null) = 10573; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false) | 
| 10573 | "Don't call - overflow rects not maintained on these SVG frames")do { static_assert( mozilla::detail::AssertionConditionType< decltype(FrameMaintainsOverflow())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(FrameMaintainsOverflow()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("FrameMaintainsOverflow()" " (" "Don't call - overflow rects not maintained on these SVG frames" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10573); AnnotateMozCrashReason("MOZ_ASSERT" "(" "FrameMaintainsOverflow()" ") (" "Don't call - overflow rects not maintained on these SVG frames" ")"); do { *((volatile int*)__null) = 10573; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 10574 | |
| 10575 | const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay); | 
| 10576 | bool hasTransform = IsTransformed(); | 
| 10577 | |
| 10578 | nsRect bounds(nsPoint(0, 0), aNewSize); | 
| 10579 | // Store the passed in overflow area if we are a preserve-3d frame or we have | 
| 10580 | // a transform, and it's not just the frame bounds. | 
| 10581 | if (hasTransform || Combines3DTransformWithAncestors()) { | 
| 10582 | if (!aOverflowAreas.InkOverflow().IsEqualEdges(bounds) || | 
| 10583 | !aOverflowAreas.ScrollableOverflow().IsEqualEdges(bounds)) { | 
| 10584 | OverflowAreas* initial = GetProperty(nsIFrame::InitialOverflowProperty()); | 
| 10585 | if (!initial) { | 
| 10586 | AddProperty(nsIFrame::InitialOverflowProperty(), | 
| 10587 | new OverflowAreas(aOverflowAreas)); | 
| 10588 | } else if (initial != &aOverflowAreas) { | 
| 10589 | *initial = aOverflowAreas; | 
| 10590 | } | 
| 10591 | } else { | 
| 10592 | RemoveProperty(nsIFrame::InitialOverflowProperty()); | 
| 10593 | } | 
| 10594 | #ifdef DEBUG1 | 
| 10595 | SetProperty(nsIFrame::DebugInitialOverflowPropertyApplied(), true); | 
| 10596 | #endif | 
| 10597 | } else { | 
| 10598 | #ifdef DEBUG1 | 
| 10599 | RemoveProperty(nsIFrame::DebugInitialOverflowPropertyApplied()); | 
| 10600 | #endif | 
| 10601 | } | 
| 10602 | |
| 10603 | nsSize oldSize = mRect.Size(); | 
| 10604 | bool sizeChanged = ((aOldSize ? *aOldSize : oldSize) != aNewSize); | 
| 10605 | |
| 10606 | // Our frame size may not have been computed and set yet, but code under | 
| 10607 | // functions such as ComputeEffectsRect (which we're about to call) use the | 
| 10608 | // values that are stored in our frame rect to compute their results. We | 
| 10609 | // need the results from those functions to be based on the frame size that | 
| 10610 | // we *will* have, so we temporarily set our frame size here before calling | 
| 10611 | // those functions. | 
| 10612 | // | 
| 10613 | // XXX Someone should document here why we revert the frame size before we | 
| 10614 | // return rather than just leaving it set. | 
| 10615 | // | 
| 10616 | // We pass false here to avoid invalidating display items for this temporary | 
| 10617 | // change. We sometimes reflow frames multiple times, with the final size | 
| 10618 | // being the same as the initial. The single call to SetSize after reflow is | 
| 10619 | // done will take care of invalidating display items if the size has actually | 
| 10620 | // changed. | 
| 10621 | SetSize(aNewSize, false); | 
| 10622 | |
| 10623 | const auto overflowClipAxes = ShouldApplyOverflowClipping(disp); | 
| 10624 | |
| 10625 | if (ChildrenHavePerspective(disp) && sizeChanged) { | 
| 10626 | RecomputePerspectiveChildrenOverflow(this); | 
| 10627 | |
| 10628 | if (overflowClipAxes != kPhysicalAxesBoth) { | 
| 10629 | aOverflowAreas.SetAllTo(bounds); | 
| 10630 | DebugOnly<bool> ok = ComputeCustomOverflow(aOverflowAreas); | 
| 10631 | |
| 10632 | // ComputeCustomOverflow() should not return false, when | 
| 10633 | // FrameMaintainsOverflow() returns true. | 
| 10634 | MOZ_ASSERT(ok, "FrameMaintainsOverflow() != ComputeCustomOverflow()")do { static_assert( mozilla::detail::AssertionConditionType< decltype(ok)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(ok))), 0))) { do { } while (false ); MOZ_ReportAssertionFailure("ok" " (" "FrameMaintainsOverflow() != ComputeCustomOverflow()" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10634); AnnotateMozCrashReason("MOZ_ASSERT" "(" "ok" ") (" "FrameMaintainsOverflow() != ComputeCustomOverflow()" ")"); do { *((volatile int*)__null) = 10634; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 10635 | |
| 10636 | UnionChildOverflow(aOverflowAreas); | 
| 10637 | } | 
| 10638 | } | 
| 10639 | |
| 10640 | // This is now called FinishAndStoreOverflow() instead of | 
| 10641 | // StoreOverflow() because frame-generic ways of adding overflow | 
| 10642 | // can happen here, e.g. CSS2 outline and native theme. | 
| 10643 | // If the overflow area width or height is nscoord_MAX, then a saturating | 
| 10644 | // union may have encountered an overflow, so the overflow may not contain the | 
| 10645 | // frame border-box. Don't warn in that case. | 
| 10646 | // Don't warn for SVG either, since SVG doesn't need the overflow area | 
| 10647 | // to contain the frame bounds. | 
| 10648 | #ifdef DEBUG1 | 
| 10649 | for (const auto otype : AllOverflowTypes()) { | 
| 10650 | const nsRect& r = aOverflowAreas.Overflow(otype); | 
| 10651 | NS_ASSERTION(aNewSize.width == 0 || aNewSize.height == 0 ||do { if (!(aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits (NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize )))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Computed overflow area must contain frame bounds" , "aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize))" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10655); MOZ_PretendNoReturn(); } } while (0) | 
| 10652 | r.width == nscoord_MAX || r.height == nscoord_MAX ||do { if (!(aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits (NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize )))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Computed overflow area must contain frame bounds" , "aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize))" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10655); MOZ_PretendNoReturn(); } } while (0) | 
| 10653 | HasAnyStateBits(NS_FRAME_SVG_LAYOUT) ||do { if (!(aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits (NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize )))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Computed overflow area must contain frame bounds" , "aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize))" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10655); MOZ_PretendNoReturn(); } } while (0) | 
| 10654 | r.Contains(nsRect(nsPoint(), aNewSize)),do { if (!(aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits (NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize )))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Computed overflow area must contain frame bounds" , "aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize))" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10655); MOZ_PretendNoReturn(); } } while (0) | 
| 10655 | "Computed overflow area must contain frame bounds")do { if (!(aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits (NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize )))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Computed overflow area must contain frame bounds" , "aNewSize.width == 0 || aNewSize.height == 0 || r.width == nscoord_MAX || r.height == nscoord_MAX || HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || r.Contains(nsRect(nsPoint(), aNewSize))" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10655); MOZ_PretendNoReturn(); } } while (0); | 
| 10656 | } | 
| 10657 | #endif | 
| 10658 | |
| 10659 | // Overflow area must always include the frame's top-left and bottom-right, | 
| 10660 | // even if the frame rect is empty (so we can scroll to those positions). | 
| 10661 | const bool shouldIncludeBounds = [&] { | 
| 10662 | if (aNewSize.width == 0 && IsInlineFrame()) { | 
| 10663 | // Pending a real fix for bug 426879, don't do this for inline frames with | 
| 10664 | // zero width. | 
| 10665 | return false; | 
| 10666 | } | 
| 10667 | if (HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { | 
| 10668 | // Do not do this for SVG either, since it will usually massively increase | 
| 10669 | // the area unnecessarily (except for SVG that applies clipping, since | 
| 10670 | // that's the pre-existing behavior, and breaks pre-rendering otherwise). | 
| 10671 | // FIXME(bug 1770704): This check most likely wants to be removed or check | 
| 10672 | // for specific frame types at least. | 
| 10673 | return !overflowClipAxes.isEmpty(); | 
| 10674 | } | 
| 10675 | return true; | 
| 10676 | }(); | 
| 10677 | |
| 10678 | if (shouldIncludeBounds) { | 
| 10679 | for (const auto otype : AllOverflowTypes()) { | 
| 10680 | nsRect& o = aOverflowAreas.Overflow(otype); | 
| 10681 | o = o.UnionEdges(bounds); | 
| 10682 | } | 
| 10683 | } | 
| 10684 | |
| 10685 | // If we clip our children, clear accumulated overflow area in the affected | 
| 10686 | // dimension(s). The children are actually clipped to the padding-box, but | 
| 10687 | // since the overflow area should include the entire border-box, just set it | 
| 10688 | // to the border-box size here. | 
| 10689 | if (!overflowClipAxes.isEmpty()) { | 
| 10690 | aOverflowAreas.ApplyClipping(bounds, overflowClipAxes, | 
| 10691 | OverflowClipMargin(overflowClipAxes)); | 
| 10692 | } | 
| 10693 | |
| 10694 | ComputeAndIncludeOutlineArea(this, aOverflowAreas, aNewSize); | 
| 10695 | |
| 10696 | // Nothing in here should affect scrollable overflow. | 
| 10697 | aOverflowAreas.InkOverflow() = | 
| 10698 | ComputeEffectsRect(this, aOverflowAreas.InkOverflow(), aNewSize); | 
| 10699 | |
| 10700 | // Absolute position clipping | 
| 10701 | const nsStyleEffects* effects = StyleEffects(); | 
| 10702 | Maybe<nsRect> clipPropClipRect = GetClipPropClipRect(disp, effects, aNewSize); | 
| 10703 | if (clipPropClipRect) { | 
| 10704 | for (const auto otype : AllOverflowTypes()) { | 
| 10705 | nsRect& o = aOverflowAreas.Overflow(otype); | 
| 10706 | o.IntersectRect(o, *clipPropClipRect); | 
| 10707 | } | 
| 10708 | } | 
| 10709 | |
| 10710 | /* If we're transformed, transform the overflow rect by the current | 
| 10711 | * transformation. */ | 
| 10712 | if (hasTransform) { | 
| 10713 | SetProperty(nsIFrame::PreTransformOverflowAreasProperty(), | 
| 10714 | new OverflowAreas(aOverflowAreas)); | 
| 10715 | |
| 10716 | if (Combines3DTransformWithAncestors()) { | 
| 10717 | /* If we're a preserve-3d leaf frame, then our pre-transform overflow | 
| 10718 | * should be correct. Our post-transform overflow is empty though, because | 
| 10719 | * we only contribute to the overflow area of the preserve-3d root frame. | 
| 10720 | * If we're an intermediate frame then the pre-transform overflow should | 
| 10721 | * contain all our non-preserve-3d children, which is what we want. Again | 
| 10722 | * we have no post-transform overflow. | 
| 10723 | */ | 
| 10724 | aOverflowAreas.SetAllTo(nsRect()); | 
| 10725 | } else { | 
| 10726 | TransformReferenceBox refBox(this); | 
| 10727 | for (const auto otype : AllOverflowTypes()) { | 
| 10728 | nsRect& o = aOverflowAreas.Overflow(otype); | 
| 10729 | o = nsDisplayTransform::TransformRect(o, this, refBox); | 
| 10730 | } | 
| 10731 | |
| 10732 | /* If we're the root of the 3d context, then we want to include the | 
| 10733 | * overflow areas of all the participants. This won't have happened yet as | 
| 10734 | * the code above set their overflow area to empty. Manually collect these | 
| 10735 | * overflow areas now. | 
| 10736 | */ | 
| 10737 | if (Extend3DContext(disp, effects)) { | 
| 10738 | ComputePreserve3DChildrenOverflow(aOverflowAreas); | 
| 10739 | } | 
| 10740 | } | 
| 10741 | } else { | 
| 10742 | RemoveProperty(nsIFrame::PreTransformOverflowAreasProperty()); | 
| 10743 | } | 
| 10744 | |
| 10745 | /* Revert the size change in case some caller is depending on this. */ | 
| 10746 | SetSize(oldSize, false); | 
| 10747 | |
| 10748 | bool anyOverflowChanged; | 
| 10749 | if (aOverflowAreas != OverflowAreas(bounds, bounds)) { | 
| 10750 | anyOverflowChanged = SetOverflowAreas(aOverflowAreas); | 
| 10751 | } else { | 
| 10752 | anyOverflowChanged = ClearOverflowRects(); | 
| 10753 | } | 
| 10754 | |
| 10755 | if (anyOverflowChanged) { | 
| 10756 | SVGObserverUtils::InvalidateDirectRenderingObservers(this); | 
| 10757 | if (nsBlockFrame* block = do_QueryFrame(this)) { | 
| 10758 | // NOTE(emilio): we need to use BeforeReflow::Yes, because we want to | 
| 10759 | // invalidate in cases where we _used_ to have an overflow marker and no | 
| 10760 | // longer do. | 
| 10761 | if (TextOverflow::CanHaveOverflowMarkers( | 
| 10762 | block, TextOverflow::BeforeReflow::Yes)) { | 
| 10763 | DiscardDisplayItems(this, [](nsDisplayItem* aItem) { | 
| 10764 | return aItem->GetType() == DisplayItemType::TYPE_TEXT_OVERFLOW; | 
| 10765 | }); | 
| 10766 | SchedulePaint(PAINT_DEFAULT); | 
| 10767 | } | 
| 10768 | } | 
| 10769 | } | 
| 10770 | return anyOverflowChanged; | 
| 10771 | } | 
| 10772 | |
| 10773 | void nsIFrame::RecomputePerspectiveChildrenOverflow( | 
| 10774 | const nsIFrame* aStartFrame) { | 
| 10775 | for (const auto& childList : ChildLists()) { | 
| 10776 | for (nsIFrame* child : childList.mList) { | 
| 10777 | if (!child->FrameMaintainsOverflow()) { | 
| 10778 | continue; // frame does not maintain overflow rects | 
| 10779 | } | 
| 10780 | if (child->HasPerspective()) { | 
| 10781 | OverflowAreas* overflow = | 
| 10782 | child->GetProperty(nsIFrame::InitialOverflowProperty()); | 
| 10783 | nsRect bounds(nsPoint(0, 0), child->GetSize()); | 
| 10784 | if (overflow) { | 
| 10785 | OverflowAreas overflowCopy = *overflow; | 
| 10786 | child->FinishAndStoreOverflow(overflowCopy, bounds.Size()); | 
| 10787 | } else { | 
| 10788 | OverflowAreas boundsOverflow; | 
| 10789 | boundsOverflow.SetAllTo(bounds); | 
| 10790 | child->FinishAndStoreOverflow(boundsOverflow, bounds.Size()); | 
| 10791 | } | 
| 10792 | } else if (child->GetContent() == aStartFrame->GetContent() || | 
| 10793 | child->GetClosestFlattenedTreeAncestorPrimaryFrame() == | 
| 10794 | aStartFrame) { | 
| 10795 | // If a frame is using perspective, then the size used to compute | 
| 10796 | // perspective-origin is the size of the frame belonging to its parent | 
| 10797 | // style. We must find any descendant frames using our size | 
| 10798 | // (by recursing into frames that have the same containing block) | 
| 10799 | // to update their overflow rects too. | 
| 10800 | child->RecomputePerspectiveChildrenOverflow(aStartFrame); | 
| 10801 | } | 
| 10802 | } | 
| 10803 | } | 
| 10804 | } | 
| 10805 | |
| 10806 | void nsIFrame::ComputePreserve3DChildrenOverflow( | 
| 10807 | OverflowAreas& aOverflowAreas) { | 
| 10808 | // Find all descendants that participate in the 3d context, and include their | 
| 10809 | // overflow. These descendants have an empty overflow, so won't have been | 
| 10810 | // included in the normal overflow calculation. Any children that don't | 
| 10811 | // participate have normal overflow, so will have been included already. | 
| 10812 | |
| 10813 | nsRect childVisual; | 
| 10814 | nsRect childScrollable; | 
| 10815 | for (const auto& childList : ChildLists()) { | 
| 10816 | for (nsIFrame* child : childList.mList) { | 
| 10817 | // If this child participates in the 3d context, then take the | 
| 10818 | // pre-transform region (which contains all descendants that aren't | 
| 10819 | // participating in the 3d context) and transform it into the 3d context | 
| 10820 | // root coordinate space. | 
| 10821 | if (child->Combines3DTransformWithAncestors()) { | 
| 10822 | OverflowAreas childOverflow = child->GetOverflowAreasRelativeToSelf(); | 
| 10823 | TransformReferenceBox refBox(child); | 
| 10824 | for (const auto otype : AllOverflowTypes()) { | 
| 10825 | nsRect& o = childOverflow.Overflow(otype); | 
| 10826 | o = nsDisplayTransform::TransformRect(o, child, refBox); | 
| 10827 | } | 
| 10828 | |
| 10829 | aOverflowAreas.UnionWith(childOverflow); | 
| 10830 | |
| 10831 | // If this child also extends the 3d context, then recurse into it | 
| 10832 | // looking for more participants. | 
| 10833 | if (child->Extend3DContext()) { | 
| 10834 | child->ComputePreserve3DChildrenOverflow(aOverflowAreas); | 
| 10835 | } | 
| 10836 | } | 
| 10837 | } | 
| 10838 | } | 
| 10839 | } | 
| 10840 | |
| 10841 | bool nsIFrame::ZIndexApplies() const { | 
| 10842 | return StyleDisplay()->IsPositionedStyle() || IsFlexOrGridItem() || | 
| 10843 | IsMenuPopupFrame(); | 
| 10844 | } | 
| 10845 | |
| 10846 | Maybe<int32_t> nsIFrame::ZIndex() const { | 
| 10847 | if (!ZIndexApplies()) { | 
| 10848 | return Nothing(); | 
| 10849 | } | 
| 10850 | const auto& zIndex = StylePosition()->mZIndex; | 
| 10851 | if (zIndex.IsAuto()) { | 
| 10852 | return Nothing(); | 
| 10853 | } | 
| 10854 | return Some(zIndex.AsInteger()); | 
| 10855 | } | 
| 10856 | |
| 10857 | bool nsIFrame::IsScrollAnchor(ScrollAnchorContainer** aOutContainer) { | 
| 10858 | if (!mInScrollAnchorChain) { | 
| 10859 | return false; | 
| 10860 | } | 
| 10861 | |
| 10862 | nsIFrame* f = this; | 
| 10863 | |
| 10864 | // FIXME(emilio, bug 1629280): We should find a non-null anchor if we have the | 
| 10865 | // flag set, but bug 1629280 makes it so that we cannot really assert it / | 
| 10866 | // make this just a `while (true)`, and uncomment the below assertion. | 
| 10867 | while (auto* container = ScrollAnchorContainer::FindFor(f)) { | 
| 10868 | // MOZ_ASSERT(f->IsInScrollAnchorChain()); | 
| 10869 | if (nsIFrame* anchor = container->AnchorNode()) { | 
| 10870 | if (anchor != this) { | 
| 10871 | return false; | 
| 10872 | } | 
| 10873 | if (aOutContainer) { | 
| 10874 | *aOutContainer = container; | 
| 10875 | } | 
| 10876 | return true; | 
| 10877 | } | 
| 10878 | |
| 10879 | f = container->Frame(); | 
| 10880 | } | 
| 10881 | |
| 10882 | return false; | 
| 10883 | } | 
| 10884 | |
| 10885 | bool nsIFrame::IsInScrollAnchorChain() const { return mInScrollAnchorChain; } | 
| 10886 | |
| 10887 | void nsIFrame::SetInScrollAnchorChain(bool aInChain) { | 
| 10888 | mInScrollAnchorChain = aInChain; | 
| 10889 | } | 
| 10890 | |
| 10891 | uint32_t nsIFrame::GetDepthInFrameTree() const { | 
| 10892 | uint32_t result = 0; | 
| 10893 | for (nsContainerFrame* ancestor = GetParent(); ancestor; | 
| 10894 | ancestor = ancestor->GetParent()) { | 
| 10895 | result++; | 
| 10896 | } | 
| 10897 | return result; | 
| 10898 | } | 
| 10899 | |
| 10900 | /** | 
| 10901 | * This function takes a frame that is part of a block-in-inline split, | 
| 10902 | * and _if_ that frame is an anonymous block created by an ib split it | 
| 10903 | * returns the block's preceding inline. This is needed because the | 
| 10904 | * split inline's style is the parent of the anonymous block's style. | 
| 10905 | * | 
| 10906 | * If aFrame is not an anonymous block, null is returned. | 
| 10907 | */ | 
| 10908 | static nsIFrame* GetIBSplitSiblingForAnonymousBlock(const nsIFrame* aFrame) { | 
| 10909 | MOZ_ASSERT(aFrame, "Must have a non-null frame!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aFrame)>::isValid, "invalid assertion condition") ; if ((__builtin_expect(!!(!(!!(aFrame))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aFrame" " (" "Must have a non-null frame!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10909); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame" ") (" "Must have a non-null frame!" ")"); do { *((volatile int*)__null ) = 10909; __attribute__((nomerge)) ::abort(); } while (false ); } } while (false); | 
| 10910 | NS_ASSERTION(aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT),do { if (!(aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "GetIBSplitSibling should only be called on ib-split frames" , "aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10911); MOZ_PretendNoReturn(); } } while (0) | 
| 10911 | "GetIBSplitSibling should only be called on ib-split frames")do { if (!(aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT ))) { NS_DebugBreak(NS_DEBUG_ASSERTION, "GetIBSplitSibling should only be called on ib-split frames" , "aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10911); MOZ_PretendNoReturn(); } } while (0); | 
| 10912 | |
| 10913 | if (aFrame->Style()->GetPseudoType() != | 
| 10914 | PseudoStyleType::mozBlockInsideInlineWrapper) { | 
| 10915 | // it's not an anonymous block | 
| 10916 | return nullptr; | 
| 10917 | } | 
| 10918 | |
| 10919 | // Find the first continuation of the frame. (Ugh. This ends up | 
| 10920 | // being O(N^2) when it is called O(N) times.) | 
| 10921 | aFrame = aFrame->FirstContinuation(); | 
| 10922 | |
| 10923 | /* | 
| 10924 | * Now look up the nsGkAtoms::IBSplitPrevSibling | 
| 10925 | * property. | 
| 10926 | */ | 
| 10927 | nsIFrame* ibSplitSibling = | 
| 10928 | aFrame->GetProperty(nsIFrame::IBSplitPrevSibling()); | 
| 10929 | NS_ASSERTION(ibSplitSibling, "Broken frame tree?")do { if (!(ibSplitSibling)) { NS_DebugBreak(NS_DEBUG_ASSERTION , "Broken frame tree?", "ibSplitSibling", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10929); MOZ_PretendNoReturn(); } } while (0); | 
| 10930 | return ibSplitSibling; | 
| 10931 | } | 
| 10932 | |
| 10933 | /** | 
| 10934 | * Get the parent, corrected for the mangled frame tree resulting from | 
| 10935 | * having a block within an inline. The result only differs from the | 
| 10936 | * result of |GetParent| when |GetParent| returns an anonymous block | 
| 10937 | * that was created for an element that was 'display: inline' because | 
| 10938 | * that element contained a block. | 
| 10939 | * | 
| 10940 | * Also skip anonymous scrolled-content parents; inherit directly from the | 
| 10941 | * outer scroll frame. | 
| 10942 | * | 
| 10943 | * Also skip NAC parents if the child frame is NAC. | 
| 10944 | */ | 
| 10945 | static nsIFrame* GetCorrectedParent(const nsIFrame* aFrame) { | 
| 10946 | nsIFrame* parent = aFrame->GetParent(); | 
| 10947 | if (!parent) { | 
| 10948 | return nullptr; | 
| 10949 | } | 
| 10950 | |
| 10951 | // For a table caption we want the _inner_ table frame (unless it's anonymous) | 
| 10952 | // as the style parent. | 
| 10953 | if (aFrame->IsTableCaption()) { | 
| 10954 | nsIFrame* innerTable = parent->PrincipalChildList().FirstChild(); | 
| 10955 | if (!innerTable->Style()->IsAnonBox()) { | 
| 10956 | return innerTable; | 
| 10957 | } | 
| 10958 | } | 
| 10959 | |
| 10960 | // Table wrappers are always anon boxes; if we're in here for an outer | 
| 10961 | // table, that actually means its the _inner_ table that wants to | 
| 10962 | // know its parent. So get the pseudo of the inner in that case. | 
| 10963 | auto pseudo = aFrame->Style()->GetPseudoType(); | 
| 10964 | if (pseudo == PseudoStyleType::tableWrapper) { | 
| 10965 | pseudo = | 
| 10966 | aFrame->PrincipalChildList().FirstChild()->Style()->GetPseudoType(); | 
| 10967 | } | 
| 10968 | |
| 10969 | // Prevent a NAC pseudo-element from inheriting from its NAC parent, and | 
| 10970 | // inherit from the NAC generator element instead. | 
| 10971 | if (pseudo != PseudoStyleType::NotPseudo) { | 
| 10972 | MOZ_ASSERT(aFrame->GetContent())do { static_assert( mozilla::detail::AssertionConditionType< decltype(aFrame->GetContent())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aFrame->GetContent()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aFrame->GetContent()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10972); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aFrame->GetContent()" ")"); do { *((volatile int*)__null) = 10972; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 10973 | Element* element = Element::FromNode(aFrame->GetContent()); | 
| 10974 | // Make sure to avoid doing the fixup for non-element-backed pseudos like | 
| 10975 | // ::first-line and such. | 
| 10976 | if (element && !element->IsRootOfNativeAnonymousSubtree() && | 
| 10977 | element->GetPseudoElementType() == aFrame->Style()->GetPseudoType()) { | 
| 10978 | while (parent->GetContent() && | 
| 10979 | !parent->GetContent()->IsRootOfNativeAnonymousSubtree()) { | 
| 10980 | parent = parent->GetInFlowParent(); | 
| 10981 | } | 
| 10982 | parent = parent->GetInFlowParent(); | 
| 10983 | } | 
| 10984 | } | 
| 10985 | |
| 10986 | return nsIFrame::CorrectStyleParentFrame(parent, pseudo); | 
| 10987 | } | 
| 10988 | |
| 10989 | /* static */ | 
| 10990 | nsIFrame* nsIFrame::CorrectStyleParentFrame(nsIFrame* aProspectiveParent, | 
| 10991 | PseudoStyleType aChildPseudo) { | 
| 10992 | MOZ_ASSERT(aProspectiveParent, "Must have a prospective parent")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aProspectiveParent)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aProspectiveParent))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("aProspectiveParent" " (" "Must have a prospective parent" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 10992); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aProspectiveParent" ") (" "Must have a prospective parent" ")"); do { *((volatile int*)__null) = 10992; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 10993 | |
| 10994 | if (aChildPseudo != PseudoStyleType::NotPseudo) { | 
| 10995 | // Non-inheriting anon boxes have no style parent frame at all. | 
| 10996 | if (PseudoStyle::IsNonInheritingAnonBox(aChildPseudo)) { | 
| 10997 | return nullptr; | 
| 10998 | } | 
| 10999 | |
| 11000 | // Other anon boxes are parented to their actual parent already, except | 
| 11001 | // for non-elements. Those should not be treated as an anon box. | 
| 11002 | if (PseudoStyle::IsAnonBox(aChildPseudo) && | 
| 11003 | !nsCSSAnonBoxes::IsNonElement(aChildPseudo)) { | 
| 11004 | NS_ASSERTION(aChildPseudo != PseudoStyleType::mozBlockInsideInlineWrapper,do { if (!(aChildPseudo != PseudoStyleType::mozBlockInsideInlineWrapper )) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Should have dealt with kids that have " "NS_FRAME_PART_OF_IBSPLIT elsewhere", "aChildPseudo != PseudoStyleType::mozBlockInsideInlineWrapper" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11006); MOZ_PretendNoReturn(); } } while (0) | 
| 11005 | "Should have dealt with kids that have "do { if (!(aChildPseudo != PseudoStyleType::mozBlockInsideInlineWrapper )) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Should have dealt with kids that have " "NS_FRAME_PART_OF_IBSPLIT elsewhere", "aChildPseudo != PseudoStyleType::mozBlockInsideInlineWrapper" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11006); MOZ_PretendNoReturn(); } } while (0) | 
| 11006 | "NS_FRAME_PART_OF_IBSPLIT elsewhere")do { if (!(aChildPseudo != PseudoStyleType::mozBlockInsideInlineWrapper )) { NS_DebugBreak(NS_DEBUG_ASSERTION, "Should have dealt with kids that have " "NS_FRAME_PART_OF_IBSPLIT elsewhere", "aChildPseudo != PseudoStyleType::mozBlockInsideInlineWrapper" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11006); MOZ_PretendNoReturn(); } } while (0); | 
| 11007 | return aProspectiveParent; | 
| 11008 | } | 
| 11009 | } | 
| 11010 | |
| 11011 | // Otherwise, walk up out of all anon boxes. For placeholder frames, walk out | 
| 11012 | // of all pseudo-elements as well. Otherwise ReparentComputedStyle could | 
| 11013 | // cause style data to be out of sync with the frame tree. | 
| 11014 | nsIFrame* parent = aProspectiveParent; | 
| 11015 | do { | 
| 11016 | if (parent->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) { | 
| 11017 | nsIFrame* sibling = GetIBSplitSiblingForAnonymousBlock(parent); | 
| 11018 | |
| 11019 | if (sibling) { | 
| 11020 | // |parent| was a block in an {ib} split; use the inline as | 
| 11021 | // |the style parent. | 
| 11022 | parent = sibling; | 
| 11023 | } | 
| 11024 | } | 
| 11025 | |
| 11026 | if (!parent->Style()->IsPseudoOrAnonBox()) { | 
| 11027 | return parent; | 
| 11028 | } | 
| 11029 | |
| 11030 | if (!parent->Style()->IsAnonBox() && aChildPseudo != PseudoStyleType::MAX) { | 
| 11031 | // nsPlaceholderFrame passes in PseudoStyleType::MAX for | 
| 11032 | // aChildPseudo (even though that's not a valid pseudo-type) just to | 
| 11033 | // trigger this behavior of walking up to the nearest non-pseudo | 
| 11034 | // ancestor. | 
| 11035 | return parent; | 
| 11036 | } | 
| 11037 | |
| 11038 | parent = parent->GetInFlowParent(); | 
| 11039 | } while (parent); | 
| 11040 | |
| 11041 | if (aProspectiveParent->Style()->GetPseudoType() == | 
| 11042 | PseudoStyleType::viewportScroll) { | 
| 11043 | // aProspectiveParent is the scrollframe for a viewport | 
| 11044 | // and the kids are the anonymous scrollbars | 
| 11045 | return aProspectiveParent; | 
| 11046 | } | 
| 11047 | |
| 11048 | // We can get here if the root element is absolutely positioned. | 
| 11049 | // We can't test for this very accurately, but it can only happen | 
| 11050 | // when the prospective parent is a canvas frame. | 
| 11051 | NS_ASSERTION(aProspectiveParent->IsCanvasFrame(),do { if (!(aProspectiveParent->IsCanvasFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Should have found a parent before this" , "aProspectiveParent->IsCanvasFrame()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11052); MOZ_PretendNoReturn(); } } while (0) | 
| 11052 | "Should have found a parent before this")do { if (!(aProspectiveParent->IsCanvasFrame())) { NS_DebugBreak (NS_DEBUG_ASSERTION, "Should have found a parent before this" , "aProspectiveParent->IsCanvasFrame()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11052); MOZ_PretendNoReturn(); } } while (0); | 
| 11053 | return nullptr; | 
| 11054 | } | 
| 11055 | |
| 11056 | ComputedStyle* nsIFrame::DoGetParentComputedStyle( | 
| 11057 | nsIFrame** aProviderFrame) const { | 
| 11058 | *aProviderFrame = nullptr; | 
| 11059 | |
| 11060 | // Handle display:contents and the root frame, when there's no parent frame | 
| 11061 | // to inherit from. | 
| 11062 | if (MOZ_LIKELY(mContent)(__builtin_expect(!!(mContent), 1))) { | 
| 11063 | Element* parentElement = mContent->GetFlattenedTreeParentElement(); | 
| 11064 | if (MOZ_LIKELY(parentElement)(__builtin_expect(!!(parentElement), 1))) { | 
| 11065 | auto pseudo = Style()->GetPseudoType(); | 
| 11066 | if (pseudo == PseudoStyleType::NotPseudo || !mContent->IsElement() || | 
| 11067 | (!PseudoStyle::IsAnonBox(pseudo) && | 
| 11068 | // Ensure that we don't return the display:contents style | 
| 11069 | // of the parent content for pseudos that have the same content | 
| 11070 | // as their primary frame (like -moz-list-bullets do): | 
| 11071 | IsPrimaryFrame()) || | 
| 11072 | /* if next is true then it's really a request for the table frame's | 
| 11073 | parent context, see nsTable[Outer]Frame::GetParentComputedStyle. */ | 
| 11074 | pseudo == PseudoStyleType::tableWrapper) { | 
| 11075 | // In some edge cases involving display: contents, we may end up here | 
| 11076 | // for something that's pending to be reframed. In this case we return | 
| 11077 | // the wrong style from here (because we've already lost track of it!), | 
| 11078 | // but it's not a big deal as we're going to be reframed anyway. | 
| 11079 | if (MOZ_LIKELY(parentElement->HasServoData())(__builtin_expect(!!(parentElement->HasServoData()), 1)) && | 
| 11080 | Servo_Element_IsDisplayContents(parentElement)) { | 
| 11081 | RefPtr<ComputedStyle> style = | 
| 11082 | ServoStyleSet::ResolveServoStyle(*parentElement); | 
| 11083 | // NOTE(emilio): we return a weak reference because the element also | 
| 11084 | // holds the style context alive. This is a bit silly (we could've | 
| 11085 | // returned a weak ref directly), but it's probably not worth | 
| 11086 | // optimizing, given this function has just one caller which is rare, | 
| 11087 | // and this path is rare itself. | 
| 11088 | return style; | 
| 11089 | } | 
| 11090 | } | 
| 11091 | } else { | 
| 11092 | if (Style()->GetPseudoType() == PseudoStyleType::NotPseudo) { | 
| 11093 | // We're a frame for the root. We have no style parent. | 
| 11094 | return nullptr; | 
| 11095 | } | 
| 11096 | } | 
| 11097 | } | 
| 11098 | |
| 11099 | if (!HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { | 
| 11100 | /* | 
| 11101 | * If this frame is an anonymous block created when an inline with a block | 
| 11102 | * inside it got split, then the parent style is on its preceding inline. We | 
| 11103 | * can get to it using GetIBSplitSiblingForAnonymousBlock. | 
| 11104 | */ | 
| 11105 | if (HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) { | 
| 11106 | nsIFrame* ibSplitSibling = GetIBSplitSiblingForAnonymousBlock(this); | 
| 11107 | if (ibSplitSibling) { | 
| 11108 | return (*aProviderFrame = ibSplitSibling)->Style(); | 
| 11109 | } | 
| 11110 | } | 
| 11111 | |
| 11112 | // If this frame is one of the blocks that split an inline, we must | 
| 11113 | // return the "special" inline parent, i.e., the parent that this | 
| 11114 | // frame would have if we didn't mangle the frame structure. | 
| 11115 | *aProviderFrame = GetCorrectedParent(this); | 
| 11116 | return *aProviderFrame ? (*aProviderFrame)->Style() : nullptr; | 
| 11117 | } | 
| 11118 | |
| 11119 | // We're an out-of-flow frame. For out-of-flow frames, we must | 
| 11120 | // resolve underneath the placeholder's parent. The placeholder is | 
| 11121 | // reached from the first-in-flow. | 
| 11122 | nsPlaceholderFrame* placeholder = FirstInFlow()->GetPlaceholderFrame(); | 
| 11123 | if (!placeholder) { | 
| 11124 | MOZ_ASSERT_UNREACHABLE("no placeholder frame for out-of-flow frame")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "no placeholder frame for out-of-flow frame" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11124); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "no placeholder frame for out-of-flow frame" ")"); do { *((volatile int*)__null) = 11124; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 11125 | *aProviderFrame = GetCorrectedParent(this); | 
| 11126 | return *aProviderFrame ? (*aProviderFrame)->Style() : nullptr; | 
| 11127 | } | 
| 11128 | return placeholder->GetParentComputedStyleForOutOfFlow(aProviderFrame); | 
| 11129 | } | 
| 11130 | |
| 11131 | void nsIFrame::GetLastLeaf(nsIFrame** aFrame) { | 
| 11132 | if (!aFrame || !*aFrame || | 
| 11133 | // Don't enter into native anoymous subtree from the root like <input> or | 
| 11134 | // <textarea>. | 
| 11135 | (*aFrame)->ContentIsRootOfNativeAnonymousSubtree()) { | 
| 11136 | return; | 
| 11137 | } | 
| 11138 | for (nsIFrame* maybeLastLeaf = (*aFrame)->PrincipalChildList().LastChild(); | 
| 11139 | maybeLastLeaf;) { | 
| 11140 | nsIFrame* lastChildNotInSubTree = nullptr; | 
| 11141 | for (nsIFrame* child = maybeLastLeaf; child; | 
| 11142 | child = child->GetPrevSibling()) { | 
| 11143 | // ignore anonymous elements, e.g. mozTableAdd* mozTableRemove* | 
| 11144 | // see bug 278197 comment #12 #13 for details | 
| 11145 | if (!child->ContentIsRootOfNativeAnonymousSubtree()) { | 
| 11146 | lastChildNotInSubTree = child; | 
| 11147 | break; | 
| 11148 | } | 
| 11149 | } | 
| 11150 | if (!lastChildNotInSubTree) { | 
| 11151 | return; | 
| 11152 | } | 
| 11153 | *aFrame = lastChildNotInSubTree; | 
| 11154 | maybeLastLeaf = lastChildNotInSubTree->PrincipalChildList().LastChild(); | 
| 11155 | } | 
| 11156 | } | 
| 11157 | |
| 11158 | void nsIFrame::GetFirstLeaf(nsIFrame** aFrame) { | 
| 11159 | if (!aFrame || !*aFrame) { | 
| 11160 | return; | 
| 11161 | } | 
| 11162 | nsIFrame* child = *aFrame; | 
| 11163 | while (true) { | 
| 11164 | child = child->PrincipalChildList().FirstChild(); | 
| 11165 | if (!child) { | 
| 11166 | return; // nothing to do | 
| 11167 | } | 
| 11168 | *aFrame = child; | 
| 11169 | } | 
| 11170 | } | 
| 11171 | |
| 11172 | bool nsIFrame::IsFocusableDueToScrollFrame() { | 
| 11173 | if (!IsScrollContainerFrame()) { | 
| 11174 | if (nsFieldSetFrame* fieldset = do_QueryFrame(this)) { | 
| 11175 | // TODO: Do we have similar special-cases like this where we can have | 
| 11176 | // anonymous scrollable boxes hanging off a primary frame? | 
| 11177 | if (nsIFrame* inner = fieldset->GetInner()) { | 
| 11178 | return inner->IsFocusableDueToScrollFrame(); | 
| 11179 | } | 
| 11180 | } | 
| 11181 | return false; | 
| 11182 | } | 
| 11183 | if (!mContent->IsHTMLElement()) { | 
| 11184 | return false; | 
| 11185 | } | 
| 11186 | if (mContent->IsRootOfNativeAnonymousSubtree()) { | 
| 11187 | return false; | 
| 11188 | } | 
| 11189 | if (!mContent->GetParent()) { | 
| 11190 | return false; | 
| 11191 | } | 
| 11192 | if (mContent->AsElement()->HasAttr(nsGkAtoms::tabindex)) { | 
| 11193 | return false; | 
| 11194 | } | 
| 11195 | // Elements with scrollable view are focusable with script & tabbable | 
| 11196 | // Otherwise you couldn't scroll them with keyboard, which is an accessibility | 
| 11197 | // issue (e.g. Section 508 rules) However, we don't make them to be focusable | 
| 11198 | // with the mouse, because the extra focus outlines are considered | 
| 11199 | // unnecessarily ugly. When clicked on, the selection position within the | 
| 11200 | // element will be enough to make them keyboard scrollable. | 
| 11201 | auto* scrollContainer = static_cast<ScrollContainerFrame*>(this); | 
| 11202 | if (scrollContainer->GetScrollStyles().IsHiddenInBothDirections()) { | 
| 11203 | return false; | 
| 11204 | } | 
| 11205 | if (scrollContainer->GetScrollRange().IsEqualEdges(nsRect())) { | 
| 11206 | return false; | 
| 11207 | } | 
| 11208 | return true; | 
| 11209 | } | 
| 11210 | |
| 11211 | Focusable nsIFrame::IsFocusable(IsFocusableFlags aFlags) { | 
| 11212 | // cannot focus content in print preview mode. Only the root can be focused, | 
| 11213 | // but that's handled elsewhere. | 
| 11214 | if (PresContext()->Type() == nsPresContext::eContext_PrintPreview) { | 
| 11215 | return {}; | 
| 11216 | } | 
| 11217 | |
| 11218 | if (!mContent || !mContent->IsElement()) { | 
| 11219 | return {}; | 
| 11220 | } | 
| 11221 | |
| 11222 | if (!(aFlags & IsFocusableFlags::IgnoreVisibility) && | 
| 11223 | !IsVisibleConsideringAncestors()) { | 
| 11224 | return {}; | 
| 11225 | } | 
| 11226 | |
| 11227 | const StyleUserFocus uf = StyleUI()->UserFocus(); | 
| 11228 | if (uf == StyleUserFocus::None) { | 
| 11229 | return {}; | 
| 11230 | } | 
| 11231 | MOZ_ASSERT(!StyleUI()->IsInert(), "inert implies -moz-user-focus: none")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!StyleUI()->IsInert())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!StyleUI()->IsInert()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!StyleUI()->IsInert()" " (" "inert implies -moz-user-focus: none" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11231); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!StyleUI()->IsInert()" ") (" "inert implies -moz-user-focus: none" ")"); do { *((volatile int*)__null) = 11231; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 11232 | |
| 11233 | const PseudoStyleType pseudo = Style()->GetPseudoType(); | 
| 11234 | if (pseudo == PseudoStyleType::anonymousItem) { | 
| 11235 | return {}; | 
| 11236 | } | 
| 11237 | |
| 11238 | Focusable focusable; | 
| 11239 | if (auto* xul = nsXULElement::FromNode(mContent)) { | 
| 11240 | // As a legacy special-case, -moz-user-focus controls focusability and | 
| 11241 | // tabability of XUL elements in some circumstances (which default to | 
| 11242 | // -moz-user-focus: ignore). | 
| 11243 | auto focusability = xul->GetXULFocusability(aFlags); | 
| 11244 | focusable.mFocusable = | 
| 11245 | focusability.mForcedFocusable.valueOr(uf == StyleUserFocus::Normal); | 
| 11246 | if (focusable) { | 
| 11247 | focusable.mTabIndex = focusability.mForcedTabIndexIfFocusable.valueOr(0); | 
| 11248 | } | 
| 11249 | } else { | 
| 11250 | focusable = mContent->IsFocusableWithoutStyle(aFlags); | 
| 11251 | } | 
| 11252 | |
| 11253 | if (focusable) { | 
| 11254 | return focusable; | 
| 11255 | } | 
| 11256 | |
| 11257 | // If we're focusing with the mouse we never focus scroll areas. | 
| 11258 | if (!(aFlags & IsFocusableFlags::WithMouse) && | 
| 11259 | IsFocusableDueToScrollFrame()) { | 
| 11260 | return {true, 0}; | 
| 11261 | } | 
| 11262 | |
| 11263 | // FIXME(emilio): some callers rely on somewhat broken return values | 
| 11264 | // (focusable = false, but non-negative tab-index) from | 
| 11265 | // IsFocusableWithoutStyle (for image maps in particular). | 
| 11266 | return focusable; | 
| 11267 | } | 
| 11268 | |
| 11269 | /** | 
| 11270 | * @return true if this text frame ends with a newline character which is | 
| 11271 | * treated as preformatted. It should return false if this is not a text frame. | 
| 11272 | */ | 
| 11273 | bool nsIFrame::HasSignificantTerminalNewline() const { return false; } | 
| 11274 | |
| 11275 | static StyleVerticalAlignKeyword ConvertSVGDominantBaselineToVerticalAlign( | 
| 11276 | StyleDominantBaseline aDominantBaseline) { | 
| 11277 | // Most of these are approximate mappings. | 
| 11278 | switch (aDominantBaseline) { | 
| 11279 | case StyleDominantBaseline::Hanging: | 
| 11280 | case StyleDominantBaseline::TextBeforeEdge: | 
| 11281 | return StyleVerticalAlignKeyword::TextTop; | 
| 11282 | case StyleDominantBaseline::TextAfterEdge: | 
| 11283 | case StyleDominantBaseline::Ideographic: | 
| 11284 | return StyleVerticalAlignKeyword::TextBottom; | 
| 11285 | case StyleDominantBaseline::Central: | 
| 11286 | case StyleDominantBaseline::Middle: | 
| 11287 | case StyleDominantBaseline::Mathematical: | 
| 11288 | return StyleVerticalAlignKeyword::Middle; | 
| 11289 | case StyleDominantBaseline::Auto: | 
| 11290 | case StyleDominantBaseline::Alphabetic: | 
| 11291 | return StyleVerticalAlignKeyword::Baseline; | 
| 11292 | default: | 
| 11293 | MOZ_ASSERT_UNREACHABLE("unexpected aDominantBaseline value")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "unexpected aDominantBaseline value" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11293); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "unexpected aDominantBaseline value" ")"); do { *((volatile int*)__null) = 11293; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 11294 | return StyleVerticalAlignKeyword::Baseline; | 
| 11295 | } | 
| 11296 | } | 
| 11297 | |
| 11298 | Maybe<StyleVerticalAlignKeyword> nsIFrame::VerticalAlignEnum() const { | 
| 11299 | if (IsInSVGTextSubtree()) { | 
| 11300 | StyleDominantBaseline dominantBaseline = StyleSVG()->mDominantBaseline; | 
| 11301 | return Some(ConvertSVGDominantBaselineToVerticalAlign(dominantBaseline)); | 
| 11302 | } | 
| 11303 | |
| 11304 | const auto& verticalAlign = StyleDisplay()->mVerticalAlign; | 
| 11305 | if (verticalAlign.IsKeyword()) { | 
| 11306 | return Some(verticalAlign.AsKeyword()); | 
| 11307 | } | 
| 11308 | |
| 11309 | return Nothing(); | 
| 11310 | } | 
| 11311 | |
| 11312 | void nsIFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame, | 
| 11313 | ServoRestyleState& aRestyleState) { | 
| 11314 | #ifdef DEBUG1 | 
| 11315 | nsIFrame* parent = aChildFrame->GetInFlowParent(); | 
| 11316 | if (aChildFrame->IsTableFrame()) { | 
| 11317 | parent = parent->GetParent(); | 
| 11318 | } | 
| 11319 | if (parent->IsLineFrame()) { | 
| 11320 | parent = parent->GetParent(); | 
| 11321 | } | 
| 11322 | MOZ_ASSERT(nsLayoutUtils::FirstContinuationOrIBSplitSibling(parent) == this,do { static_assert( mozilla::detail::AssertionConditionType< decltype(nsLayoutUtils::FirstContinuationOrIBSplitSibling(parent ) == this)>::isValid, "invalid assertion condition"); if ( (__builtin_expect(!!(!(!!(nsLayoutUtils::FirstContinuationOrIBSplitSibling (parent) == this))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("nsLayoutUtils::FirstContinuationOrIBSplitSibling(parent) == this" " (" "This should only be used for children!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11323); AnnotateMozCrashReason("MOZ_ASSERT" "(" "nsLayoutUtils::FirstContinuationOrIBSplitSibling(parent) == this" ") (" "This should only be used for children!" ")"); do { *( (volatile int*)__null) = 11323; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) | 
| 11323 | "This should only be used for children!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(nsLayoutUtils::FirstContinuationOrIBSplitSibling(parent ) == this)>::isValid, "invalid assertion condition"); if ( (__builtin_expect(!!(!(!!(nsLayoutUtils::FirstContinuationOrIBSplitSibling (parent) == this))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("nsLayoutUtils::FirstContinuationOrIBSplitSibling(parent) == this" " (" "This should only be used for children!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11323); AnnotateMozCrashReason("MOZ_ASSERT" "(" "nsLayoutUtils::FirstContinuationOrIBSplitSibling(parent) == this" ") (" "This should only be used for children!" ")"); do { *( (volatile int*)__null) = 11323; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); | 
| 11324 | #endif // DEBUG | 
| 11325 | MOZ_ASSERT(!GetContent() || !aChildFrame->GetContent() ||do { static_assert( mozilla::detail::AssertionConditionType< decltype(!GetContent() || !aChildFrame->GetContent() || aChildFrame ->GetContent() == GetContent())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!GetContent() || !aChildFrame ->GetContent() || aChildFrame->GetContent() == GetContent ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!GetContent() || !aChildFrame->GetContent() || aChildFrame->GetContent() == GetContent()" " (" "What content node is it a frame for?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11327); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!GetContent() || !aChildFrame->GetContent() || aChildFrame->GetContent() == GetContent()" ") (" "What content node is it a frame for?" ")"); do { *((volatile int*)__null) = 11327; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) | 
| 11326 | aChildFrame->GetContent() == GetContent(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!GetContent() || !aChildFrame->GetContent() || aChildFrame ->GetContent() == GetContent())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!GetContent() || !aChildFrame ->GetContent() || aChildFrame->GetContent() == GetContent ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!GetContent() || !aChildFrame->GetContent() || aChildFrame->GetContent() == GetContent()" " (" "What content node is it a frame for?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11327); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!GetContent() || !aChildFrame->GetContent() || aChildFrame->GetContent() == GetContent()" ") (" "What content node is it a frame for?" ")"); do { *((volatile int*)__null) = 11327; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) | 
| 11327 | "What content node is it a frame for?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!GetContent() || !aChildFrame->GetContent() || aChildFrame ->GetContent() == GetContent())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!GetContent() || !aChildFrame ->GetContent() || aChildFrame->GetContent() == GetContent ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!GetContent() || !aChildFrame->GetContent() || aChildFrame->GetContent() == GetContent()" " (" "What content node is it a frame for?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11327); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!GetContent() || !aChildFrame->GetContent() || aChildFrame->GetContent() == GetContent()" ") (" "What content node is it a frame for?" ")"); do { *((volatile int*)__null) = 11327; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 11328 | MOZ_ASSERT(!aChildFrame->GetPrevContinuation(),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aChildFrame->GetPrevContinuation())>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!aChildFrame->GetPrevContinuation()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!aChildFrame->GetPrevContinuation()" " (" "Only first continuations should end up here" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11329); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aChildFrame->GetPrevContinuation()" ") (" "Only first continuations should end up here" ")"); do { *((volatile int*)__null) = 11329; __attribute__((nomerge)) ::abort(); } while (false); } } while (false) | 
| 11329 | "Only first continuations should end up here")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aChildFrame->GetPrevContinuation())>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!aChildFrame->GetPrevContinuation()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!aChildFrame->GetPrevContinuation()" " (" "Only first continuations should end up here" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11329); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aChildFrame->GetPrevContinuation()" ") (" "Only first continuations should end up here" ")"); do { *((volatile int*)__null) = 11329; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 11330 | |
| 11331 | // We could force the caller to pass in the pseudo, since some callers know it | 
| 11332 | // statically... But this API is a bit nicer. | 
| 11333 | auto pseudo = aChildFrame->Style()->GetPseudoType(); | 
| 11334 | MOZ_ASSERT(PseudoStyle::IsAnonBox(pseudo), "Child is not an anon box?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(PseudoStyle::IsAnonBox(pseudo))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(PseudoStyle::IsAnonBox(pseudo )))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("PseudoStyle::IsAnonBox(pseudo)" " (" "Child is not an anon box?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11334); AnnotateMozCrashReason("MOZ_ASSERT" "(" "PseudoStyle::IsAnonBox(pseudo)" ") (" "Child is not an anon box?" ")"); do { *((volatile int *)__null) = 11334; __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | 
| 11335 | MOZ_ASSERT(!PseudoStyle::IsNonInheritingAnonBox(pseudo),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!PseudoStyle::IsNonInheritingAnonBox(pseudo))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!PseudoStyle::IsNonInheritingAnonBox(pseudo)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!PseudoStyle::IsNonInheritingAnonBox(pseudo)" " (" "Why did the caller bother calling us?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11336); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!PseudoStyle::IsNonInheritingAnonBox(pseudo)" ") (" "Why did the caller bother calling us?" ")"); do { *(( volatile int*)__null) = 11336; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) | 
| 11336 | "Why did the caller bother calling us?")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!PseudoStyle::IsNonInheritingAnonBox(pseudo))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!PseudoStyle::IsNonInheritingAnonBox(pseudo)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!PseudoStyle::IsNonInheritingAnonBox(pseudo)" " (" "Why did the caller bother calling us?" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11336); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!PseudoStyle::IsNonInheritingAnonBox(pseudo)" ") (" "Why did the caller bother calling us?" ")"); do { *(( volatile int*)__null) = 11336; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); | 
| 11337 | |
| 11338 | // Anon boxes inherit from their parent; that's us. | 
| 11339 | RefPtr<ComputedStyle> newContext = | 
| 11340 | aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle(pseudo, | 
| 11341 | Style()); | 
| 11342 | |
| 11343 | nsChangeHint childHint = | 
| 11344 | UpdateStyleOfOwnedChildFrame(aChildFrame, newContext, aRestyleState); | 
| 11345 | |
| 11346 | // Now that we've updated the style on aChildFrame, check whether it itself | 
| 11347 | // has anon boxes to deal with. | 
| 11348 | ServoRestyleState childrenState(*aChildFrame, aRestyleState, childHint, | 
| 11349 | ServoRestyleState::CanUseHandledHints::Yes); | 
| 11350 | aChildFrame->UpdateStyleOfOwnedAnonBoxes(childrenState); | 
| 11351 | |
| 11352 | // Assuming anon boxes don't have ::backdrop associated with them... if that | 
| 11353 | // ever changes, we'd need to handle that here, like we do in | 
| 11354 | // RestyleManager::ProcessPostTraversal | 
| 11355 | |
| 11356 | // We do need to handle block pseudo-elements here, though. Especially list | 
| 11357 | // bullets. | 
| 11358 | if (nsBlockFrame* block = do_QueryFrame(aChildFrame)) { | 
| 11359 | block->UpdatePseudoElementStyles(childrenState); | 
| 11360 | } | 
| 11361 | } | 
| 11362 | |
| 11363 | /* static */ | 
| 11364 | nsChangeHint nsIFrame::UpdateStyleOfOwnedChildFrame( | 
| 11365 | nsIFrame* aChildFrame, ComputedStyle* aNewComputedStyle, | 
| 11366 | ServoRestyleState& aRestyleState, | 
| 11367 | const Maybe<ComputedStyle*>& aContinuationComputedStyle) { | 
| 11368 | MOZ_ASSERT(!aChildFrame->GetAdditionalComputedStyle(0),do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aChildFrame->GetAdditionalComputedStyle(0))>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!aChildFrame->GetAdditionalComputedStyle(0)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!aChildFrame->GetAdditionalComputedStyle(0)" " (" "We don't handle additional styles here" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11369); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aChildFrame->GetAdditionalComputedStyle(0)" ") (" "We don't handle additional styles here" ")"); do { *( (volatile int*)__null) = 11369; __attribute__((nomerge)) ::abort (); } while (false); } } while (false) | 
| 11369 | "We don't handle additional styles here")do { static_assert( mozilla::detail::AssertionConditionType< decltype(!aChildFrame->GetAdditionalComputedStyle(0))>:: isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!aChildFrame->GetAdditionalComputedStyle(0)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!aChildFrame->GetAdditionalComputedStyle(0)" " (" "We don't handle additional styles here" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11369); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!aChildFrame->GetAdditionalComputedStyle(0)" ") (" "We don't handle additional styles here" ")"); do { *( (volatile int*)__null) = 11369; __attribute__((nomerge)) ::abort (); } while (false); } } while (false); | 
| 11370 | |
| 11371 | // Figure out whether we have an actual change. It's important that we do | 
| 11372 | // this, for several reasons: | 
| 11373 | // | 
| 11374 | // 1) Even if all the child's changes are due to properties it inherits from | 
| 11375 | // us, it's possible that no one ever asked us for those style structs and | 
| 11376 | // hence changes to them aren't reflected in the changes handled at all. | 
| 11377 | // | 
| 11378 | // 2) Content can change stylesheets that change the styles of pseudos, and | 
| 11379 | // extensions can add/remove stylesheets that change the styles of | 
| 11380 | // anonymous boxes directly. | 
| 11381 | uint32_t equalStructs; // Not used, actually. | 
| 11382 | nsChangeHint childHint = aChildFrame->Style()->CalcStyleDifference( | 
| 11383 | *aNewComputedStyle, &equalStructs); | 
| 11384 | |
| 11385 | // If aChildFrame is out of flow, then aRestyleState's "changes handled by the | 
| 11386 | // parent" doesn't apply to it, because it may have some other parent in the | 
| 11387 | // frame tree. | 
| 11388 | if (!aChildFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { | 
| 11389 | childHint = NS_RemoveSubsumedHints( | 
| 11390 | childHint, aRestyleState.ChangesHandledFor(aChildFrame)); | 
| 11391 | } | 
| 11392 | if (childHint) { | 
| 11393 | if (childHint & nsChangeHint_ReconstructFrame) { | 
| 11394 | // If we generate a reconstruct here, remove any non-reconstruct hints we | 
| 11395 | // may have already generated for this content. | 
| 11396 | aRestyleState.ChangeList().PopChangesForContent( | 
| 11397 | aChildFrame->GetContent()); | 
| 11398 | } | 
| 11399 | aRestyleState.ChangeList().AppendChange( | 
| 11400 | aChildFrame, aChildFrame->GetContent(), childHint); | 
| 11401 | } | 
| 11402 | |
| 11403 | aChildFrame->SetComputedStyle(aNewComputedStyle); | 
| 11404 | ComputedStyle* continuationStyle = aContinuationComputedStyle | 
| 11405 | ? *aContinuationComputedStyle | 
| 11406 | : aNewComputedStyle; | 
| 11407 | for (nsIFrame* kid = aChildFrame->GetNextContinuation(); kid; | 
| 11408 | kid = kid->GetNextContinuation()) { | 
| 11409 | MOZ_ASSERT(!kid->GetAdditionalComputedStyle(0))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!kid->GetAdditionalComputedStyle(0))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!kid->GetAdditionalComputedStyle(0)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!kid->GetAdditionalComputedStyle(0)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11409); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!kid->GetAdditionalComputedStyle(0)" ")"); do { *((volatile int*)__null) = 11409; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 11410 | kid->SetComputedStyle(continuationStyle); | 
| 11411 | } | 
| 11412 | |
| 11413 | return childHint; | 
| 11414 | } | 
| 11415 | |
| 11416 | /* static */ | 
| 11417 | void nsIFrame::AddInPopupStateBitToDescendants(nsIFrame* aFrame) { | 
| 11418 | if (!aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP) && | 
| 11419 | aFrame->TrackingVisibility()) { | 
| 11420 | // Assume all frames in popups are visible. | 
| 11421 | aFrame->IncApproximateVisibleCount(); | 
| 11422 | } | 
| 11423 | |
| 11424 | aFrame->AddStateBits(NS_FRAME_IN_POPUP); | 
| 11425 | |
| 11426 | for (const auto& childList : aFrame->CrossDocChildLists()) { | 
| 11427 | for (nsIFrame* child : childList.mList) { | 
| 11428 | AddInPopupStateBitToDescendants(child); | 
| 11429 | } | 
| 11430 | } | 
| 11431 | } | 
| 11432 | |
| 11433 | /* static */ | 
| 11434 | void nsIFrame::RemoveInPopupStateBitFromDescendants(nsIFrame* aFrame) { | 
| 11435 | if (!aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP) || | 
| 11436 | nsLayoutUtils::IsPopup(aFrame)) { | 
| 11437 | return; | 
| 11438 | } | 
| 11439 | |
| 11440 | aFrame->RemoveStateBits(NS_FRAME_IN_POPUP); | 
| 11441 | |
| 11442 | if (aFrame->TrackingVisibility()) { | 
| 11443 | // We assume all frames in popups are visible, so this decrement balances | 
| 11444 | // out the increment in AddInPopupStateBitToDescendants above. | 
| 11445 | aFrame->DecApproximateVisibleCount(); | 
| 11446 | } | 
| 11447 | for (const auto& childList : aFrame->CrossDocChildLists()) { | 
| 11448 | for (nsIFrame* child : childList.mList) { | 
| 11449 | RemoveInPopupStateBitFromDescendants(child); | 
| 11450 | } | 
| 11451 | } | 
| 11452 | } | 
| 11453 | |
| 11454 | void nsIFrame::SetParent(nsContainerFrame* aParent) { | 
| 11455 | // If our parent is a wrapper anon box, our new parent should be too. We | 
| 11456 | // _can_ change parent if our parent is a wrapper anon box, because some | 
| 11457 | // wrapper anon boxes can have continuations. | 
| 11458 | MOZ_ASSERT_IF(ParentIsWrapperAnonBox(),do { if (ParentIsWrapperAnonBox()) { do { static_assert( mozilla ::detail::AssertionConditionType<decltype(aParent->Style ()->IsInheritingAnonBox())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aParent->Style()->IsInheritingAnonBox ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aParent->Style()->IsInheritingAnonBox()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11459); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aParent->Style()->IsInheritingAnonBox()" ")"); do { *((volatile int*)__null) = 11459; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); } } while (false) | 
| 11459 | aParent->Style()->IsInheritingAnonBox())do { if (ParentIsWrapperAnonBox()) { do { static_assert( mozilla ::detail::AssertionConditionType<decltype(aParent->Style ()->IsInheritingAnonBox())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aParent->Style()->IsInheritingAnonBox ()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("aParent->Style()->IsInheritingAnonBox()", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11459); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aParent->Style()->IsInheritingAnonBox()" ")"); do { *((volatile int*)__null) = 11459; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); } } while (false); | 
| 11460 | |
| 11461 | // Note that the current mParent may already be destroyed at this point. | 
| 11462 | mParent = aParent; | 
| 11463 | MOZ_ASSERT(!mParent || PresShell() == mParent->PresShell())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!mParent || PresShell() == mParent->PresShell())> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(!mParent || PresShell() == mParent->PresShell())) ), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!mParent || PresShell() == mParent->PresShell()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11463); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!mParent || PresShell() == mParent->PresShell()" ")"); do { *((volatile int*)__null) = 11463; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 11464 | |
| 11465 | if (HasAnyStateBits(NS_FRAME_HAS_VIEW | NS_FRAME_HAS_CHILD_WITH_VIEW)) { | 
| 11466 | for (nsIFrame* f = aParent; | 
| 11467 | f && !f->HasAnyStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW); | 
| 11468 | f = f->GetParent()) { | 
| 11469 | f->AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW); | 
| 11470 | } | 
| 11471 | } | 
| 11472 | |
| 11473 | if (HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)) { | 
| 11474 | for (nsIFrame* f = aParent; f; f = f->GetParent()) { | 
| 11475 | if (f->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)) { | 
| 11476 | break; | 
| 11477 | } | 
| 11478 | f->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE); | 
| 11479 | } | 
| 11480 | } | 
| 11481 | |
| 11482 | if (HasAnyStateBits(NS_FRAME_DESCENDANT_INTRINSIC_ISIZE_DEPENDS_ON_BSIZE)) { | 
| 11483 | for (nsIFrame* f = aParent; f; f = f->GetParent()) { | 
| 11484 | if (f->HasAnyStateBits( | 
| 11485 | NS_FRAME_DESCENDANT_INTRINSIC_ISIZE_DEPENDS_ON_BSIZE)) { | 
| 11486 | break; | 
| 11487 | } | 
| 11488 | f->AddStateBits(NS_FRAME_DESCENDANT_INTRINSIC_ISIZE_DEPENDS_ON_BSIZE); | 
| 11489 | } | 
| 11490 | } | 
| 11491 | |
| 11492 | if (HasInvalidFrameInSubtree()) { | 
| 11493 | for (nsIFrame* f = aParent; | 
| 11494 | f && !f->HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT | | 
| 11495 | NS_FRAME_IS_NONDISPLAY); | 
| 11496 | f = nsLayoutUtils::GetCrossDocParentFrameInProcess(f)) { | 
| 11497 | f->AddStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT); | 
| 11498 | } | 
| 11499 | } | 
| 11500 | |
| 11501 | if (aParent->HasAnyStateBits(NS_FRAME_IN_POPUP)) { | 
| 11502 | AddInPopupStateBitToDescendants(this); | 
| 11503 | } else { | 
| 11504 | RemoveInPopupStateBitFromDescendants(this); | 
| 11505 | } | 
| 11506 | |
| 11507 | // If our new parent only has invalid children, then we just invalidate | 
| 11508 | // ourselves too. This is probably faster than clearing the flag all | 
| 11509 | // the way up the frame tree. | 
| 11510 | if (aParent->HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT)) { | 
| 11511 | InvalidateFrame(); | 
| 11512 | } else { | 
| 11513 | SchedulePaint(); | 
| 11514 | } | 
| 11515 | } | 
| 11516 | |
| 11517 | bool nsIFrame::IsStackingContext(const nsStyleDisplay* aStyleDisplay, | 
| 11518 | const nsStyleEffects* aStyleEffects) { | 
| 11519 | // Properties that influence the output of this function should be handled in | 
| 11520 | // change_bits_for_longhand as well. | 
| 11521 | if (HasOpacity(aStyleDisplay, aStyleEffects, nullptr)) { | 
| 11522 | return true; | 
| 11523 | } | 
| 11524 | if (IsTransformed()) { | 
| 11525 | return true; | 
| 11526 | } | 
| 11527 | auto willChange = aStyleDisplay->mWillChange.bits; | 
| 11528 | if (aStyleDisplay->IsContainPaint() || aStyleDisplay->IsContainLayout() || | 
| 11529 | willChange & StyleWillChangeBits::CONTAIN) { | 
| 11530 | if (SupportsContainLayoutAndPaint()) { | 
| 11531 | return true; | 
| 11532 | } | 
| 11533 | } | 
| 11534 | // strictly speaking, 'perspective' doesn't require visual atomicity, | 
| 11535 | // but the spec says it acts like the rest of these | 
| 11536 | if (aStyleDisplay->HasPerspectiveStyle() || | 
| 11537 | willChange & StyleWillChangeBits::PERSPECTIVE) { | 
| 11538 | if (SupportsCSSTransforms()) { | 
| 11539 | return true; | 
| 11540 | } | 
| 11541 | } | 
| 11542 | if (!StylePosition()->mZIndex.IsAuto() || | 
| 11543 | willChange & StyleWillChangeBits::Z_INDEX) { | 
| 11544 | if (ZIndexApplies()) { | 
| 11545 | return true; | 
| 11546 | } | 
| 11547 | } | 
| 11548 | return aStyleEffects->mMixBlendMode != StyleBlend::Normal || | 
| 11549 | SVGIntegrationUtils::UsingEffectsForFrame(this) || | 
| 11550 | aStyleDisplay->IsPositionForcingStackingContext() || | 
| 11551 | aStyleDisplay->mIsolation != StyleIsolation::Auto || | 
| 11552 | willChange & StyleWillChangeBits::STACKING_CONTEXT_UNCONDITIONAL; | 
| 11553 | } | 
| 11554 | |
| 11555 | bool nsIFrame::IsStackingContext() { | 
| 11556 | return IsStackingContext(StyleDisplay(), StyleEffects()); | 
| 11557 | } | 
| 11558 | |
| 11559 | static bool IsFrameRectScrolledOutOfView(const nsIFrame* aTarget, | 
| 11560 | const nsRect& aTargetRect, | 
| 11561 | const nsIFrame* aParent) { | 
| 11562 | // The ancestor frame we are checking if it clips out aTargetRect relative to | 
| 11563 | // aTarget. | 
| 11564 | nsIFrame* clipParent = nullptr; | 
| 11565 | |
| 11566 | // find the first scrollable frame or root frame if we are in a fixed pos | 
| 11567 | // subtree | 
| 11568 | for (nsIFrame* f = const_cast<nsIFrame*>(aParent); f; | 
| 11569 | f = nsLayoutUtils::GetCrossDocParentFrameInProcess(f)) { | 
| 11570 | ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(f); | 
| 11571 | if (scrollContainerFrame) { | 
| 11572 | clipParent = f; | 
| 11573 | break; | 
| 11574 | } | 
| 11575 | if (f->StyleDisplay()->mPosition == StylePositionProperty::Fixed && | 
| 11576 | nsLayoutUtils::IsReallyFixedPos(f)) { | 
| 11577 | clipParent = f->GetParent(); | 
| 11578 | break; | 
| 11579 | } | 
| 11580 | } | 
| 11581 | |
| 11582 | if (!clipParent) { | 
| 11583 | // Even if we couldn't find the nearest scrollable frame, it might mean we | 
| 11584 | // are in an out-of-process iframe, try to see if |aTarget| frame is | 
| 11585 | // scrolled out of view in an scrollable frame in a cross-process ancestor | 
| 11586 | // document. | 
| 11587 | return nsLayoutUtils::FrameRectIsScrolledOutOfViewInCrossProcess( | 
| 11588 | aTarget, aTargetRect); | 
| 11589 | } | 
| 11590 | |
| 11591 | nsRect clipRect = clipParent->InkOverflowRectRelativeToSelf(); | 
| 11592 | // We consider that the target is scrolled out if the scrollable (or root) | 
| 11593 | // frame is empty. | 
| 11594 | if (clipRect.IsEmpty()) { | 
| 11595 | return true; | 
| 11596 | } | 
| 11597 | |
| 11598 | nsRect transformedRect = nsLayoutUtils::TransformFrameRectToAncestor( | 
| 11599 | aTarget, aTargetRect, clipParent); | 
| 11600 | |
| 11601 | if (transformedRect.IsEmpty()) { | 
| 11602 | // If the transformed rect is empty it represents a line or a point that we | 
| 11603 | // should check is outside the the scrollable rect. | 
| 11604 | if (transformedRect.x > clipRect.XMost() || | 
| 11605 | transformedRect.y > clipRect.YMost() || | 
| 11606 | clipRect.x > transformedRect.XMost() || | 
| 11607 | clipRect.y > transformedRect.YMost()) { | 
| 11608 | return true; | 
| 11609 | } | 
| 11610 | } else if (!transformedRect.Intersects(clipRect)) { | 
| 11611 | return true; | 
| 11612 | } | 
| 11613 | |
| 11614 | nsIFrame* parent = clipParent->GetParent(); | 
| 11615 | if (!parent) { | 
| 11616 | return false; | 
| 11617 | } | 
| 11618 | |
| 11619 | return IsFrameRectScrolledOutOfView(clipParent, transformedRect, parent); | 
| 11620 | } | 
| 11621 | |
| 11622 | bool nsIFrame::IsScrolledOutOfView() const { | 
| 11623 | nsRect rect = InkOverflowRectRelativeToSelf(); | 
| 11624 | return IsFrameRectScrolledOutOfView(this, rect, this); | 
| 11625 | } | 
| 11626 | |
| 11627 | gfx::Matrix nsIFrame::ComputeWidgetTransform() const { | 
| 11628 | const nsStyleUIReset* uiReset = StyleUIReset(); | 
| 11629 | if (uiReset->mMozWindowTransform.IsNone()) { | 
| 11630 | return gfx::Matrix(); | 
| 11631 | } | 
| 11632 | |
| 11633 | TransformReferenceBox refBox(nullptr, nsRect(nsPoint(), GetSize())); | 
| 11634 | |
| 11635 | int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel(); | 
| 11636 | gfx::Matrix4x4 matrix = nsStyleTransformMatrix::ReadTransforms( | 
| 11637 | uiReset->mMozWindowTransform, refBox, float(appUnitsPerDevPixel)); | 
| 11638 | |
| 11639 | gfx::Matrix result2d; | 
| 11640 | if (!matrix.CanDraw2D(&result2d)) { | 
| 11641 | // FIXME: It would be preferable to reject non-2D transforms at parse time. | 
| 11642 | NS_WARNING(NS_DebugBreak(NS_DEBUG_WARNING, "-moz-window-transform does not describe a 2D transform, " "but only 2d transforms are supported", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11644) | 
| 11643 | "-moz-window-transform does not describe a 2D transform, "NS_DebugBreak(NS_DEBUG_WARNING, "-moz-window-transform does not describe a 2D transform, " "but only 2d transforms are supported", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11644) | 
| 11644 | "but only 2d transforms are supported")NS_DebugBreak(NS_DEBUG_WARNING, "-moz-window-transform does not describe a 2D transform, " "but only 2d transforms are supported", nullptr, "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11644); | 
| 11645 | return gfx::Matrix(); | 
| 11646 | } | 
| 11647 | |
| 11648 | return result2d; | 
| 11649 | } | 
| 11650 | |
| 11651 | void nsIFrame::DoUpdateStyleOfOwnedAnonBoxes(ServoRestyleState& aRestyleState) { | 
| 11652 | // As a special case, we check for {ib}-split block frames here, rather | 
| 11653 | // than have an nsInlineFrame::AppendDirectlyOwnedAnonBoxes implementation | 
| 11654 | // that returns them. | 
| 11655 | // | 
| 11656 | // (If we did handle them in AppendDirectlyOwnedAnonBoxes, we would have to | 
| 11657 | // return *all* of the in-flow {ib}-split block frames, not just the first | 
| 11658 | // one. For restyling, we really just need the first in flow, and the other | 
| 11659 | // user of the AppendOwnedAnonBoxes API, AllChildIterator, doesn't need to | 
| 11660 | // know about them at all, since these block frames never create NAC. So we | 
| 11661 | // avoid any unncessary hashtable lookups for the {ib}-split frames by calling | 
| 11662 | // UpdateStyleOfOwnedAnonBoxesForIBSplit directly here.) | 
| 11663 | if (IsInlineFrame()) { | 
| 11664 | if (HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) { | 
| 11665 | static_cast<nsInlineFrame*>(this)->UpdateStyleOfOwnedAnonBoxesForIBSplit( | 
| 11666 | aRestyleState); | 
| 11667 | } | 
| 11668 | return; | 
| 11669 | } | 
| 11670 | |
| 11671 | AutoTArray<OwnedAnonBox, 4> frames; | 
| 11672 | AppendDirectlyOwnedAnonBoxes(frames); | 
| 11673 | for (OwnedAnonBox& box : frames) { | 
| 11674 | if (box.mUpdateStyleFn) { | 
| 11675 | box.mUpdateStyleFn(this, box.mAnonBoxFrame, aRestyleState); | 
| 11676 | } else { | 
| 11677 | UpdateStyleOfChildAnonBox(box.mAnonBoxFrame, aRestyleState); | 
| 11678 | } | 
| 11679 | } | 
| 11680 | } | 
| 11681 | |
| 11682 | /* virtual */ | 
| 11683 | void nsIFrame::AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) { | 
| 11684 | MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11684); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES)" ")"); do { *((volatile int*)__null) = 11684; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 11685 | MOZ_ASSERT_UNREACHABLE(do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Subclasses that have directly owned anonymous boxes should override " "this method!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11687); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Subclasses that have directly owned anonymous boxes should override " "this method!" ")"); do { *((volatile int*)__null) = 11687; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 11686 | "Subclasses that have directly owned anonymous boxes should override "do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Subclasses that have directly owned anonymous boxes should override " "this method!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11687); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Subclasses that have directly owned anonymous boxes should override " "this method!" ")"); do { *((volatile int*)__null) = 11687; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false) | 
| 11687 | "this method!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Subclasses that have directly owned anonymous boxes should override " "this method!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11687); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Subclasses that have directly owned anonymous boxes should override " "this method!" ")"); do { *((volatile int*)__null) = 11687; __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | 
| 11688 | } | 
| 11689 | |
| 11690 | void nsIFrame::DoAppendOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) { | 
| 11691 | size_t i = aResult.Length(); | 
| 11692 | AppendDirectlyOwnedAnonBoxes(aResult); | 
| 11693 | |
| 11694 | // After appending the directly owned anonymous boxes of this frame to | 
| 11695 | // aResult above, we need to check each of them to see if they own | 
| 11696 | // any anonymous boxes themselves. Note that we keep progressing | 
| 11697 | // through aResult, looking for additional entries in aResult from these | 
| 11698 | // subsequent AppendDirectlyOwnedAnonBoxes calls. (Thus we can't | 
| 11699 | // use a ranged for loop here.) | 
| 11700 | |
| 11701 | while (i < aResult.Length()) { | 
| 11702 | nsIFrame* f = aResult[i].mAnonBoxFrame; | 
| 11703 | if (f->HasAnyStateBits(NS_FRAME_OWNS_ANON_BOXES)) { | 
| 11704 | f->AppendDirectlyOwnedAnonBoxes(aResult); | 
| 11705 | } | 
| 11706 | ++i; | 
| 11707 | } | 
| 11708 | } | 
| 11709 | |
| 11710 | nsIFrame::CaretPosition::CaretPosition() : mContentOffset(0) {} | 
| 11711 | |
| 11712 | nsIFrame::CaretPosition::~CaretPosition() = default; | 
| 11713 | |
| 11714 | bool nsIFrame::HasCSSAnimations() { | 
| 11715 | auto* collection = AnimationCollection<CSSAnimation>::Get(this); | 
| 11716 | return collection && !collection->mAnimations.IsEmpty(); | 
| 11717 | } | 
| 11718 | |
| 11719 | bool nsIFrame::HasCSSTransitions() { | 
| 11720 | auto* collection = AnimationCollection<CSSTransition>::Get(this); | 
| 11721 | return collection && !collection->mAnimations.IsEmpty(); | 
| 11722 | } | 
| 11723 | |
| 11724 | void nsIFrame::AddSizeOfExcludingThisForTree(nsWindowSizes& aSizes) const { | 
| 11725 | aSizes.mLayoutFramePropertiesSize += | 
| 11726 | mProperties.SizeOfExcludingThis(aSizes.mState.mMallocSizeOf); | 
| 11727 | |
| 11728 | // We don't do this for Gecko because this stuff is stored in the nsPresArena | 
| 11729 | // and so measured elsewhere. | 
| 11730 | if (!aSizes.mState.HaveSeenPtr(mComputedStyle)) { | 
| 11731 | mComputedStyle->AddSizeOfIncludingThis(aSizes, | 
| 11732 | &aSizes.mLayoutComputedValuesNonDom); | 
| 11733 | } | 
| 11734 | |
| 11735 | // And our additional styles. | 
| 11736 | int32_t index = 0; | 
| 11737 | while (auto* extra = GetAdditionalComputedStyle(index++)) { | 
| 11738 | if (!aSizes.mState.HaveSeenPtr(extra)) { | 
| 11739 | extra->AddSizeOfIncludingThis(aSizes, | 
| 11740 | &aSizes.mLayoutComputedValuesNonDom); | 
| 11741 | } | 
| 11742 | } | 
| 11743 | |
| 11744 | for (const auto& childList : ChildLists()) { | 
| 11745 | for (const nsIFrame* f : childList.mList) { | 
| 11746 | f->AddSizeOfExcludingThisForTree(aSizes); | 
| 11747 | } | 
| 11748 | } | 
| 11749 | } | 
| 11750 | |
| 11751 | nsRect nsIFrame::GetCompositorHitTestArea(nsDisplayListBuilder* aBuilder) { | 
| 11752 | nsRect area; | 
| 11753 | |
| 11754 | ScrollContainerFrame* scrollContainerFrame = | 
| 11755 | nsLayoutUtils::GetScrollContainerFrameFor(this); | 
| 11756 | if (scrollContainerFrame) { | 
| 11757 | // If this frame is the scrolled frame of a scroll container frame, then we | 
| 11758 | // need to pick up the area corresponding to the overflow rect as well. | 
| 11759 | // Otherwise the parts of the overflow that are not occupied by descendants | 
| 11760 | // get skipped and the APZ code sends touch events to the content underneath | 
| 11761 | // instead. See https://bugzilla.mozilla.org/show_bug.cgi?id=1127773#c15. | 
| 11762 | area = ScrollableOverflowRect(); | 
| 11763 | } else { | 
| 11764 | area = GetRectRelativeToSelf(); | 
| 11765 | } | 
| 11766 | |
| 11767 | if (!area.IsEmpty()) { | 
| 11768 | return area + aBuilder->ToReferenceFrame(this); | 
| 11769 | } | 
| 11770 | |
| 11771 | return area; | 
| 11772 | } | 
| 11773 | |
| 11774 | CompositorHitTestInfo nsIFrame::GetCompositorHitTestInfo( | 
| 11775 | nsDisplayListBuilder* aBuilder) { | 
| 11776 | CompositorHitTestInfo result = CompositorHitTestInvisibleToHit; | 
| 11777 | |
| 11778 | if (aBuilder->IsInsidePointerEventsNoneDoc()) { | 
| 11779 | // Somewhere up the parent document chain is a subdocument with pointer- | 
| 11780 | // events:none set on it. | 
| 11781 | return result; | 
| 11782 | } | 
| 11783 | if (!GetParent()) { | 
| 11784 | MOZ_ASSERT(IsViewportFrame())do { static_assert( mozilla::detail::AssertionConditionType< decltype(IsViewportFrame())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(IsViewportFrame()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsViewportFrame()" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11784); AnnotateMozCrashReason("MOZ_ASSERT" "(" "IsViewportFrame()" ")"); do { *((volatile int*)__null) = 11784; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 11785 | // Viewport frames are never event targets, other frames, like canvas | 
| 11786 | // frames, are the event targets for any regions viewport frames may cover. | 
| 11787 | return result; | 
| 11788 | } | 
| 11789 | if (Style()->PointerEvents() == StylePointerEvents::None) { | 
| 11790 | return result; | 
| 11791 | } | 
| 11792 | if (!StyleVisibility()->IsVisible()) { | 
| 11793 | return result; | 
| 11794 | } | 
| 11795 | |
| 11796 | // Anything that didn't match the above conditions is visible to hit-testing. | 
| 11797 | result = CompositorHitTestFlags::eVisibleToHitTest; | 
| 11798 | SVGUtils::MaskUsage maskUsage = SVGUtils::DetermineMaskUsage(this, false); | 
| 11799 | if (maskUsage.UsingMaskOrClipPath()) { | 
| 11800 | // If WebRender is enabled, simple clip-paths can be converted into WR | 
| 11801 | // clips that WR knows how to hit-test against, so we don't need to mark | 
| 11802 | // it as an irregular area. | 
| 11803 | if (!maskUsage.IsSimpleClipShape()) { | 
| 11804 | result += CompositorHitTestFlags::eIrregularArea; | 
| 11805 | } | 
| 11806 | } | 
| 11807 | |
| 11808 | if (aBuilder->IsBuildingNonLayerizedScrollbar()) { | 
| 11809 | // Scrollbars may be painted into a layer below the actual layer they will | 
| 11810 | // scroll, and therefore wheel events may be dispatched to the outer frame | 
| 11811 | // instead of the intended scrollframe. To address this, we force a d-t-c | 
| 11812 | // region on scrollbar frames that won't be placed in their own layer. See | 
| 11813 | // bug 1213324 for details. | 
| 11814 | result += CompositorHitTestFlags::eInactiveScrollframe; | 
| 11815 | } else if (aBuilder->GetAncestorHasApzAwareEventHandler()) { | 
| 11816 | result += CompositorHitTestFlags::eApzAwareListeners; | 
| 11817 | } else if (IsRangeFrame()) { | 
| 11818 | // Range frames handle touch events directly without having a touch listener | 
| 11819 | // so we need to let APZ know that this area cares about events. | 
| 11820 | result += CompositorHitTestFlags::eApzAwareListeners; | 
| 11821 | } | 
| 11822 | |
| 11823 | if (aBuilder->IsTouchEventPrefEnabledDoc()) { | 
| 11824 | // Inherit the touch-action flags from the parent, if there is one. We do | 
| 11825 | // this because of how the touch-action on a frame combines the touch-action | 
| 11826 | // from ancestor DOM elements. Refer to the documentation in | 
| 11827 | // TouchActionHelper.cpp for details; this code is meant to be equivalent to | 
| 11828 | // that code, but woven into the top-down recursive display list building | 
| 11829 | // process. | 
| 11830 | CompositorHitTestInfo inheritedTouchAction = | 
| 11831 | aBuilder->GetCompositorHitTestInfo() & CompositorHitTestTouchActionMask; | 
| 11832 | |
| 11833 | nsIFrame* touchActionFrame = this; | 
| 11834 | if (ScrollContainerFrame* scrollContainerFrame = | 
| 11835 | nsLayoutUtils::GetScrollContainerFrameFor(this)) { | 
| 11836 | ScrollStyles ss = scrollContainerFrame->GetScrollStyles(); | 
| 11837 | if (ss.mVertical != StyleOverflow::Hidden || | 
| 11838 | ss.mHorizontal != StyleOverflow::Hidden) { | 
| 11839 | touchActionFrame = scrollContainerFrame; | 
| 11840 | // On scrollframes, stop inheriting the pan-x and pan-y flags; instead, | 
| 11841 | // reset them back to zero to allow panning on the scrollframe unless we | 
| 11842 | // encounter an element that disables it that's inside the scrollframe. | 
| 11843 | // This is equivalent to the |considerPanning| variable in | 
| 11844 | // TouchActionHelper.cpp, but for a top-down traversal. | 
| 11845 | CompositorHitTestInfo panMask( | 
| 11846 | CompositorHitTestFlags::eTouchActionPanXDisabled, | 
| 11847 | CompositorHitTestFlags::eTouchActionPanYDisabled); | 
| 11848 | inheritedTouchAction -= panMask; | 
| 11849 | } | 
| 11850 | } | 
| 11851 | |
| 11852 | result += inheritedTouchAction; | 
| 11853 | |
| 11854 | const StyleTouchAction touchAction = touchActionFrame->UsedTouchAction(); | 
| 11855 | // The CSS allows the syntax auto | none | [pan-x || pan-y] | manipulation | 
| 11856 | // so we can eliminate some combinations of things. | 
| 11857 | if (touchAction == StyleTouchAction::AUTO) { | 
| 11858 | // nothing to do | 
| 11859 | } else if (touchAction & StyleTouchAction::MANIPULATION) { | 
| 11860 | result += CompositorHitTestFlags::eTouchActionAnimatingZoomDisabled; | 
| 11861 | } else { | 
| 11862 | // This path handles the cases none | [pan-x || pan-y || pinch-zoom] so | 
| 11863 | // double-tap is disabled in here. | 
| 11864 | if (!(touchAction & StyleTouchAction::PINCH_ZOOM)) { | 
| 11865 | result += CompositorHitTestFlags::eTouchActionPinchZoomDisabled; | 
| 11866 | } | 
| 11867 | |
| 11868 | result += CompositorHitTestFlags::eTouchActionAnimatingZoomDisabled; | 
| 11869 | |
| 11870 | if (!(touchAction & StyleTouchAction::PAN_X)) { | 
| 11871 | result += CompositorHitTestFlags::eTouchActionPanXDisabled; | 
| 11872 | } | 
| 11873 | if (!(touchAction & StyleTouchAction::PAN_Y)) { | 
| 11874 | result += CompositorHitTestFlags::eTouchActionPanYDisabled; | 
| 11875 | } | 
| 11876 | if (touchAction & StyleTouchAction::NONE) { | 
| 11877 | // all the touch-action disabling flags will already have been set above | 
| 11878 | MOZ_ASSERT(result.contains(CompositorHitTestTouchActionMask))do { static_assert( mozilla::detail::AssertionConditionType< decltype(result.contains(CompositorHitTestTouchActionMask))> ::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(result.contains(CompositorHitTestTouchActionMask)))) , 0))) { do { } while (false); MOZ_ReportAssertionFailure("result.contains(CompositorHitTestTouchActionMask)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11878); AnnotateMozCrashReason("MOZ_ASSERT" "(" "result.contains(CompositorHitTestTouchActionMask)" ")"); do { *((volatile int*)__null) = 11878; __attribute__(( nomerge)) ::abort(); } while (false); } } while (false); | 
| 11879 | } | 
| 11880 | } | 
| 11881 | } | 
| 11882 | |
| 11883 | const Maybe<ScrollDirection> scrollDirection = | 
| 11884 | aBuilder->GetCurrentScrollbarDirection(); | 
| 11885 | if (scrollDirection.isSome()) { | 
| 11886 | if (GetContent()->IsXULElement(nsGkAtoms::thumb)) { | 
| 11887 | const bool thumbGetsLayer = aBuilder->GetCurrentScrollbarTarget() != | 
| 11888 | layers::ScrollableLayerGuid::NULL_SCROLL_ID; | 
| 11889 | if (thumbGetsLayer) { | 
| 11890 | result += CompositorHitTestFlags::eScrollbarThumb; | 
| 11891 | } else { | 
| 11892 | result += CompositorHitTestFlags::eInactiveScrollframe; | 
| 11893 | } | 
| 11894 | } | 
| 11895 | |
| 11896 | if (*scrollDirection == ScrollDirection::eVertical) { | 
| 11897 | result += CompositorHitTestFlags::eScrollbarVertical; | 
| 11898 | } | 
| 11899 | |
| 11900 | // includes the ScrollbarFrame, SliderFrame, anything else that | 
| 11901 | // might be inside the xul:scrollbar | 
| 11902 | result += CompositorHitTestFlags::eScrollbar; | 
| 11903 | } | 
| 11904 | |
| 11905 | return result; | 
| 11906 | } | 
| 11907 | |
| 11908 | // Returns true if we can guarantee there is no visible descendants. | 
| 11909 | static bool HasNoVisibleDescendants(const nsIFrame* aFrame) { | 
| 11910 | for (const auto& childList : aFrame->ChildLists()) { | 
| 11911 | for (nsIFrame* f : childList.mList) { | 
| 11912 | if (nsPlaceholderFrame::GetRealFrameFor(f) | 
| 11913 | ->IsVisibleOrMayHaveVisibleDescendants()) { | 
| 11914 | return false; | 
| 11915 | } | 
| 11916 | } | 
| 11917 | } | 
| 11918 | return true; | 
| 11919 | } | 
| 11920 | |
| 11921 | void nsIFrame::UpdateVisibleDescendantsState() { | 
| 11922 | if (StyleVisibility()->IsVisible()) { | 
| 11923 | // Notify invisible ancestors that a visible descendant exists now. | 
| 11924 | nsIFrame* ancestor; | 
| 11925 | for (ancestor = GetInFlowParent(); | 
| 11926 | ancestor && !ancestor->StyleVisibility()->IsVisible(); | 
| 11927 | ancestor = ancestor->GetInFlowParent()) { | 
| 11928 | ancestor->mAllDescendantsAreInvisible = false; | 
| 11929 | } | 
| 11930 | } else { | 
| 11931 | mAllDescendantsAreInvisible = HasNoVisibleDescendants(this); | 
| 11932 | } | 
| 11933 | } | 
| 11934 | |
| 11935 | PhysicalAxes nsIFrame::ShouldApplyOverflowClipping( | 
| 11936 | const nsStyleDisplay* aDisp) const { | 
| 11937 | MOZ_ASSERT(aDisp == StyleDisplay(), "Wrong display struct")do { static_assert( mozilla::detail::AssertionConditionType< decltype(aDisp == StyleDisplay())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(aDisp == StyleDisplay()))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("aDisp == StyleDisplay()" " (" "Wrong display struct" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 11937); AnnotateMozCrashReason("MOZ_ASSERT" "(" "aDisp == StyleDisplay()" ") (" "Wrong display struct" ")"); do { *((volatile int*)__null ) = 11937; __attribute__((nomerge)) ::abort(); } while (false ); } } while (false); | 
| 11938 | |
| 11939 | // 'contain:paint', which we handle as 'overflow:clip' here. Except for | 
| 11940 | // scrollframes we don't need contain:paint to add any clipping, because | 
| 11941 | // the scrollable frame will already clip overflowing content, and because | 
| 11942 | // 'contain:paint' should prevent all means of escaping that clipping | 
| 11943 | // (e.g. because it forms a fixed-pos containing block). | 
| 11944 | if (aDisp->IsContainPaint() && !IsScrollContainerFrame() && | 
| 11945 | SupportsContainLayoutAndPaint()) { | 
| 11946 | return kPhysicalAxesBoth; | 
| 11947 | } | 
| 11948 | |
| 11949 | // and overflow:hidden that we should interpret as clip | 
| 11950 | if (aDisp->mOverflowX == StyleOverflow::Hidden && | 
| 11951 | aDisp->mOverflowY == StyleOverflow::Hidden) { | 
| 11952 | // REVIEW: these are the frame types that set up clipping. | 
| 11953 | LayoutFrameType type = Type(); | 
| 11954 | switch (type) { | 
| 11955 | case LayoutFrameType::CheckboxRadio: | 
| 11956 | case LayoutFrameType::ComboboxControl: | 
| 11957 | case LayoutFrameType::HTMLButtonControl: | 
| 11958 | case LayoutFrameType::ListControl: | 
| 11959 | case LayoutFrameType::Meter: | 
| 11960 | case LayoutFrameType::Progress: | 
| 11961 | case LayoutFrameType::Range: | 
| 11962 | case LayoutFrameType::SubDocument: | 
| 11963 | case LayoutFrameType::SVGForeignObject: | 
| 11964 | case LayoutFrameType::SVGInnerSVG: | 
| 11965 | case LayoutFrameType::SVGOuterSVG: | 
| 11966 | case LayoutFrameType::SVGSymbol: | 
| 11967 | case LayoutFrameType::Table: | 
| 11968 | case LayoutFrameType::TableCell: | 
| 11969 | return kPhysicalAxesBoth; | 
| 11970 | case LayoutFrameType::TextInput: | 
| 11971 | // It has an anonymous scroll container frame that handles any overflow. | 
| 11972 | return PhysicalAxes(); | 
| 11973 | default: | 
| 11974 | break; | 
| 11975 | } | 
| 11976 | } | 
| 11977 | |
| 11978 | // clip overflow:clip, except for nsListControlFrame which is | 
| 11979 | // a ScrollContainerFrame sub-class. | 
| 11980 | if (MOZ_UNLIKELY((aDisp->mOverflowX == mozilla::StyleOverflow::Clip ||(__builtin_expect(!!((aDisp->mOverflowX == mozilla::StyleOverflow ::Clip || aDisp->mOverflowY == mozilla::StyleOverflow::Clip ) && !IsListControlFrame()), 0)) | 
| 11981 | aDisp->mOverflowY == mozilla::StyleOverflow::Clip) &&(__builtin_expect(!!((aDisp->mOverflowX == mozilla::StyleOverflow ::Clip || aDisp->mOverflowY == mozilla::StyleOverflow::Clip ) && !IsListControlFrame()), 0)) | 
| 11982 | !IsListControlFrame())(__builtin_expect(!!((aDisp->mOverflowX == mozilla::StyleOverflow ::Clip || aDisp->mOverflowY == mozilla::StyleOverflow::Clip ) && !IsListControlFrame()), 0))) { | 
| 11983 | // FIXME: we could use GetViewportScrollStylesOverrideElement() here instead | 
| 11984 | // if that worked correctly in a print context. (see bug 1654667) | 
| 11985 | const auto* element = Element::FromNodeOrNull(GetContent()); | 
| 11986 | if (!element || | 
| 11987 | !PresContext()->ElementWouldPropagateScrollStyles(*element)) { | 
| 11988 | PhysicalAxes axes; | 
| 11989 | if (aDisp->mOverflowX == mozilla::StyleOverflow::Clip) { | 
| 11990 | axes += PhysicalAxis::Horizontal; | 
| 11991 | } | 
| 11992 | if (aDisp->mOverflowY == mozilla::StyleOverflow::Clip) { | 
| 11993 | axes += PhysicalAxis::Vertical; | 
| 11994 | } | 
| 11995 | return axes; | 
| 11996 | } | 
| 11997 | } | 
| 11998 | |
| 11999 | if (HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { | 
| 12000 | return PhysicalAxes(); | 
| 12001 | } | 
| 12002 | |
| 12003 | return IsSuppressedScrollableBlockForPrint() ? kPhysicalAxesBoth | 
| 12004 | : PhysicalAxes(); | 
| 12005 | } | 
| 12006 | |
| 12007 | bool nsIFrame::IsSuppressedScrollableBlockForPrint() const { | 
| 12008 | // This condition needs to match the suppressScrollFrame logic in the frame | 
| 12009 | // constructor. | 
| 12010 | if (!PresContext()->IsPaginated() || !IsBlockFrame() || | 
| 12011 | !StyleDisplay()->IsScrollableOverflow() || | 
| 12012 | !StyleDisplay()->IsBlockOutsideStyle() || | 
| 12013 | mContent->IsInNativeAnonymousSubtree()) { | 
| 12014 | return false; | 
| 12015 | } | 
| 12016 | if (auto* element = Element::FromNode(mContent); | 
| 12017 | element && PresContext()->ElementWouldPropagateScrollStyles(*element)) { | 
| 12018 | return false; | 
| 12019 | } | 
| 12020 | return true; | 
| 12021 | } | 
| 12022 | |
| 12023 | bool nsIFrame::HasUnreflowedContainerQueryAncestor() const { | 
| 12024 | // If this frame has done the first reflow, its ancestors are guaranteed to | 
| 12025 | // have as well. | 
| 12026 | if (!HasAnyStateBits(NS_FRAME_FIRST_REFLOW) || | 
| 12027 | !PresContext()->HasContainerQueryFrames()) { | 
| 12028 | return false; | 
| 12029 | } | 
| 12030 | for (nsIFrame* cur = GetInFlowParent(); cur; cur = cur->GetInFlowParent()) { | 
| 12031 | if (!cur->HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) { | 
| 12032 | // Done first reflow from this ancestor up, including query containers. | 
| 12033 | return false; | 
| 12034 | } | 
| 12035 | if (cur->StyleDisplay()->IsQueryContainer()) { | 
| 12036 | return true; | 
| 12037 | } | 
| 12038 | } | 
| 12039 | // No query container from this frame up to root. | 
| 12040 | return false; | 
| 12041 | } | 
| 12042 | |
| 12043 | bool nsIFrame::ShouldBreakBefore( | 
| 12044 | const ReflowInput::BreakType aBreakType) const { | 
| 12045 | const auto* display = StyleDisplay(); | 
| 12046 | return ShouldBreakBetween(display, display->mBreakBefore, aBreakType); | 
| 12047 | } | 
| 12048 | |
| 12049 | bool nsIFrame::ShouldBreakAfter(const ReflowInput::BreakType aBreakType) const { | 
| 12050 | const auto* display = StyleDisplay(); | 
| 12051 | return ShouldBreakBetween(display, display->mBreakAfter, aBreakType); | 
| 12052 | } | 
| 12053 | |
| 12054 | bool nsIFrame::ShouldBreakBetween( | 
| 12055 | const nsStyleDisplay* aDisplay, const StyleBreakBetween aBreakBetween, | 
| 12056 | const ReflowInput::BreakType aBreakType) const { | 
| 12057 | const bool shouldBreakBetween = [&] { | 
| 12058 | switch (aBreakBetween) { | 
| 12059 | case StyleBreakBetween::Always: | 
| 12060 | return true; | 
| 12061 | case StyleBreakBetween::Auto: | 
| 12062 | case StyleBreakBetween::Avoid: | 
| 12063 | return false; | 
| 12064 | case StyleBreakBetween::Page: | 
| 12065 | case StyleBreakBetween::Left: | 
| 12066 | case StyleBreakBetween::Right: | 
| 12067 | return aBreakType == ReflowInput::BreakType::Page; | 
| 12068 | } | 
| 12069 | MOZ_ASSERT_UNREACHABLE("Unknown break-between value!")do { static_assert( mozilla::detail::AssertionConditionType< decltype(false)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while ( false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: " "Unknown break-between value!" ")", "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 12069); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") (" "MOZ_ASSERT_UNREACHABLE: " "Unknown break-between value!" ")" ); do { *((volatile int*)__null) = 12069; __attribute__((nomerge )) ::abort(); } while (false); } } while (false); | 
| 12070 | return false; | 
| 12071 | }(); | 
| 12072 | |
| 12073 | if (!shouldBreakBetween) { | 
| 12074 | return false; | 
| 12075 | } | 
| 12076 | if (IsAbsolutelyPositioned(aDisplay)) { | 
| 12077 | // 'break-before' and 'break-after' properties does not apply to | 
| 12078 | // absolutely-positioned boxes. | 
| 12079 | return false; | 
| 12080 | } | 
| 12081 | return true; | 
| 12082 | } | 
| 12083 | |
| 12084 | #ifdef DEBUG1 | 
| 12085 | static void GetTagName(nsIFrame* aFrame, nsIContent* aContent, int aResultSize, | 
| 12086 | char* aResult) { | 
| 12087 | if (aContent) { | 
| 12088 | snprintf(aResult, aResultSize, "%s@%p", | 
| 12089 | nsAtomCString(aContent->NodeInfo()->NameAtom()).get(), aFrame); | 
| 12090 | } else { | 
| 12091 | snprintf(aResult, aResultSize, "@%p", aFrame); | 
| 12092 | } | 
| 12093 | } | 
| 12094 | |
| 12095 | void nsIFrame::Trace(const char* aMethod, bool aEnter) { | 
| 12096 | if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)(int(((mozilla::LogModule*)(sFrameLogModule))->Level()) & (0x1))) { | 
| 12097 | char tagbuf[40]; | 
| 12098 | GetTagName(this, mContent, sizeof(tagbuf), tagbuf); | 
| 12099 | printf_stderr("%s: %s %s", tagbuf, aEnter ? "enter" : "exit", aMethod); | 
| 12100 | } | 
| 12101 | } | 
| 12102 | |
| 12103 | void nsIFrame::Trace(const char* aMethod, bool aEnter, | 
| 12104 | const nsReflowStatus& aStatus) { | 
| 12105 | if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)(int(((mozilla::LogModule*)(sFrameLogModule))->Level()) & (0x1))) { | 
| 12106 | char tagbuf[40]; | 
| 12107 | GetTagName(this, mContent, sizeof(tagbuf), tagbuf); | 
| 12108 | printf_stderr("%s: %s %s, status=%scomplete%s", tagbuf, | 
| 12109 | aEnter ? "enter" : "exit", aMethod, | 
| 12110 | aStatus.IsIncomplete() ? "not" : "", | 
| 12111 | (aStatus.NextInFlowNeedsReflow()) ? "+reflow" : ""); | 
| 12112 | } | 
| 12113 | } | 
| 12114 | |
| 12115 | void nsIFrame::TraceMsg(const char* aFormatString, ...) { | 
| 12116 | if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)(int(((mozilla::LogModule*)(sFrameLogModule))->Level()) & (0x1))) { | 
| 12117 | // Format arguments into a buffer | 
| 12118 | char argbuf[200]; | 
| 12119 | va_list ap; | 
| 12120 | va_start(ap, aFormatString)__builtin_va_start(ap, aFormatString); | 
| 12121 | VsprintfLiteral(argbuf, aFormatString, ap); | 
| 12122 | va_end(ap)__builtin_va_end(ap); | 
| 12123 | |
| 12124 | char tagbuf[40]; | 
| 12125 | GetTagName(this, mContent, sizeof(tagbuf), tagbuf); | 
| 12126 | printf_stderr("%s: %s", tagbuf, argbuf); | 
| 12127 | } | 
| 12128 | } | 
| 12129 | |
| 12130 | void nsIFrame::VerifyDirtyBitSet(const nsFrameList& aFrameList) { | 
| 12131 | for (nsIFrame* f : aFrameList) { | 
| 12132 | NS_ASSERTION(f->HasAnyStateBits(NS_FRAME_IS_DIRTY), "dirty bit not set")do { if (!(f->HasAnyStateBits(NS_FRAME_IS_DIRTY))) { NS_DebugBreak (NS_DEBUG_ASSERTION, "dirty bit not set", "f->HasAnyStateBits(NS_FRAME_IS_DIRTY)" , "/var/lib/jenkins/workspace/firefox-scan-build/layout/generic/nsIFrame.cpp" , 12132); MOZ_PretendNoReturn(); } } while (0); | 
| 12133 | } | 
| 12134 | } | 
| 12135 | |
| 12136 | // Validation of SideIsVertical. | 
| 12137 | # define CASE(side, result) \ | 
| 12138 | static_assert(SideIsVertical(side) == result, "SideIsVertical is wrong") | 
| 12139 | CASE(eSideTop, false); | 
| 12140 | CASE(eSideRight, true); | 
| 12141 | CASE(eSideBottom, false); | 
| 12142 | CASE(eSideLeft, true); | 
| 12143 | # undef CASE | 
| 12144 | |
| 12145 | // Validation of HalfCornerIsX. | 
| 12146 | # define CASE(corner, result) \ | 
| 12147 | static_assert(HalfCornerIsX(corner) == result, "HalfCornerIsX is wrong") | 
| 12148 | CASE(eCornerTopLeftX, true); | 
| 12149 | CASE(eCornerTopLeftY, false); | 
| 12150 | CASE(eCornerTopRightX, true); | 
| 12151 | CASE(eCornerTopRightY, false); | 
| 12152 | CASE(eCornerBottomRightX, true); | 
| 12153 | CASE(eCornerBottomRightY, false); | 
| 12154 | CASE(eCornerBottomLeftX, true); | 
| 12155 | CASE(eCornerBottomLeftY, false); | 
| 12156 | # undef CASE | 
| 12157 | |
| 12158 | // Validation of HalfToFullCorner. | 
| 12159 | # define CASE(corner, result) \ | 
| 12160 | static_assert(HalfToFullCorner(corner) == result, \ | 
| 12161 | "HalfToFullCorner is " \ | 
| 12162 | "wrong") | 
| 12163 | CASE(eCornerTopLeftX, eCornerTopLeft); | 
| 12164 | CASE(eCornerTopLeftY, eCornerTopLeft); | 
| 12165 | CASE(eCornerTopRightX, eCornerTopRight); | 
| 12166 | CASE(eCornerTopRightY, eCornerTopRight); | 
| 12167 | CASE(eCornerBottomRightX, eCornerBottomRight); | 
| 12168 | CASE(eCornerBottomRightY, eCornerBottomRight); | 
| 12169 | CASE(eCornerBottomLeftX, eCornerBottomLeft); | 
| 12170 | CASE(eCornerBottomLeftY, eCornerBottomLeft); | 
| 12171 | # undef CASE | 
| 12172 | |
| 12173 | // Validation of FullToHalfCorner. | 
| 12174 | # define CASE(corner, vert, result) \ | 
| 12175 | static_assert(FullToHalfCorner(corner, vert) == result, \ | 
| 12176 | "FullToHalfCorner is wrong") | 
| 12177 | CASE(eCornerTopLeft, false, eCornerTopLeftX); | 
| 12178 | CASE(eCornerTopLeft, true, eCornerTopLeftY); | 
| 12179 | CASE(eCornerTopRight, false, eCornerTopRightX); | 
| 12180 | CASE(eCornerTopRight, true, eCornerTopRightY); | 
| 12181 | CASE(eCornerBottomRight, false, eCornerBottomRightX); | 
| 12182 | CASE(eCornerBottomRight, true, eCornerBottomRightY); | 
| 12183 | CASE(eCornerBottomLeft, false, eCornerBottomLeftX); | 
| 12184 | CASE(eCornerBottomLeft, true, eCornerBottomLeftY); | 
| 12185 | # undef CASE | 
| 12186 | |
| 12187 | // Validation of SideToFullCorner. | 
| 12188 | # define CASE(side, second, result) \ | 
| 12189 | static_assert(SideToFullCorner(side, second) == result, \ | 
| 12190 | "SideToFullCorner is wrong") | 
| 12191 | CASE(eSideTop, false, eCornerTopLeft); | 
| 12192 | CASE(eSideTop, true, eCornerTopRight); | 
| 12193 | |
| 12194 | CASE(eSideRight, false, eCornerTopRight); | 
| 12195 | CASE(eSideRight, true, eCornerBottomRight); | 
| 12196 | |
| 12197 | CASE(eSideBottom, false, eCornerBottomRight); | 
| 12198 | CASE(eSideBottom, true, eCornerBottomLeft); | 
| 12199 | |
| 12200 | CASE(eSideLeft, false, eCornerBottomLeft); | 
| 12201 | CASE(eSideLeft, true, eCornerTopLeft); | 
| 12202 | # undef CASE | 
| 12203 | |
| 12204 | // Validation of SideToHalfCorner. | 
| 12205 | # define CASE(side, second, parallel, result) \ | 
| 12206 | static_assert(SideToHalfCorner(side, second, parallel) == result, \ | 
| 12207 | "SideToHalfCorner is wrong") | 
| 12208 | CASE(eSideTop, false, true, eCornerTopLeftX); | 
| 12209 | CASE(eSideTop, false, false, eCornerTopLeftY); | 
| 12210 | CASE(eSideTop, true, true, eCornerTopRightX); | 
| 12211 | CASE(eSideTop, true, false, eCornerTopRightY); | 
| 12212 | |
| 12213 | CASE(eSideRight, false, false, eCornerTopRightX); | 
| 12214 | CASE(eSideRight, false, true, eCornerTopRightY); | 
| 12215 | CASE(eSideRight, true, false, eCornerBottomRightX); | 
| 12216 | CASE(eSideRight, true, true, eCornerBottomRightY); | 
| 12217 | |
| 12218 | CASE(eSideBottom, false, true, eCornerBottomRightX); | 
| 12219 | CASE(eSideBottom, false, false, eCornerBottomRightY); | 
| 12220 | CASE(eSideBottom, true, true, eCornerBottomLeftX); | 
| 12221 | CASE(eSideBottom, true, false, eCornerBottomLeftY); | 
| 12222 | |
| 12223 | CASE(eSideLeft, false, false, eCornerBottomLeftX); | 
| 12224 | CASE(eSideLeft, false, true, eCornerBottomLeftY); | 
| 12225 | CASE(eSideLeft, true, false, eCornerTopLeftX); | 
| 12226 | CASE(eSideLeft, true, true, eCornerTopLeftY); | 
| 12227 | # undef CASE | 
| 12228 | |
| 12229 | #endif |