Files
palemoon27/layout/generic/nsHTMLReflowState.cpp
T
roytam1 c6e1bfdcf2 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1261578 - Part 1. Correct text color in selection range; r=jfkthame (6895ebe313)
- Bug 1261578 - Part 2. Correct text decoration color; r=jfkthame (348ba5a946)
- Bug 1261578 - Part 3. Correct MathML text color; r=jfkthame (99dfb99af4)
- Bug 1261578 - Part 4. Correct text overflow color; r=jfkthame (96318becf6)
- Bug 1261578 - Part 5. web-platform-test reftest; r=jfkthame (781bba0317)
- Bug 1110460, part 1 - Add operator= to nsCSSValuePair. r=dholbert (7d836b786b)
- Bug 1110460, part 2 - Move AddPositions() further up StyleAnimationValue.cpp and add asserts. r=dholbert (5f00295917)
- Bug 1110460, part 3 - Factor out a AddCSSValuePair helper in StyleAnimationValue.cpp. r=dholbert (9947835334)
- Bug 1110460, part 4 - Fix MOZ_ASSERT bug in nsComputedDOMStyle.cpp. r=dholbert (5403c0c377)
- Bug 1110460, part 5 - Factor out a nsStyleBasicShape::GetShapeTypeName method. r=dholbert (d27623d42f)
- Bug 1110460, part 6 - Make StyleAnimationValue support css::URLValue backed nsCSSValue objects. r=dholbert (dc006d1cae)
- Bug 1110460, part 7 - Factor out code for adding two nsCSSValuePairList lists. r=dholbert (f27f780005)
- Bug 1260655 - Allow StyleAnimationValue::UncomputeValue to produce values whose storage is independent of the passed-in computed value; r=heycam (abcc77ede5)
- Bug 1110460, part 8 - Support CSS animation of clip-path basic shapes. r=dholbert (cfe5bf883b)
- Bug 1238243 - Reftests involving possibly-ignorable hangul choseong filler. r=xidorn Bug 1238243 followup - Mark test 1238243-2.html as random on OS X 10.6, due to dependency on available fonts. Bug 1239564 - Add reftest for mask layer composition. r=roc (bb3bf56d52)
- Bug 1260543 - Treat currentcolor as computed value which is not interpolatable with actual color for text-emphasis-color and -webkit-text-fill-color. r=birtles (7b90f37e2f)
- Bug 1260543 followup - Fix the function name in test_transitions_per_property.html. DONTBUILD (1362d30c6a)
- Bug 1248708 - Part1: parse and compute -webkit-text-stroke property. r=heycam (c77332031d)
- Bug 1248708 - Part2.1: use mfbt/TypedEnumBits.h for DrawMode. r=jwatt (55bfbdf5dd)
- Bug 1266101, part 1 - Remove various bits of dead code related to painting SVG text. r=heycam (c5140a911c)
- Bug 1266101, part 2 - Remove most of the GLYPH_STROKE/GLYPH_STROKE_UNDERNEATH checking code. r=heycam (6d8f17bc19)
- Bug 1248708 - Part2.2: render -webkit-text-stroke property. r=jfkthame (bccc308ddc)
- Bug 1248708 - Part3: add reftests. r=jfkthame (0fc0864749)
- Bug 1248708 followup: Use MOZ_ARRAY_LENGTH instead of ArrayLength for expression used at compile time, to fix MSVC 2013 bustage. (trivial/bustage-fix, no review) (25cecd7585)
- Bug 1266341 - Pass the right kind of enum constants for script codes. r=masayuki (723e784a37)
- Bug 1245866 - A better buffer size check in nsIDNService::IDNA2008ToUnicode, r=jfkthame (683db7d93c)
- Bug 1233610 - IDN service should return NS_ERROR_MALFORMED_URI instead of NS_ERROR_FAILURE r=mcmanus (d70d4425ca)
- Bug 1266391 - Introduce an enum class mozilla::unicode::Script, and use this instead of bare integers to specify script codes for better type checking. r=masayuki (363a23049f)
- fix 1389436 backport (a8f96f6b33)
- Bug 1258228 - create special child accessibles in owner's constructor, part1, r=marcoz (2bbb819f76)
- Bug 1258228 - create special child accessibles in owner's constructor, part2, r=marcoz (5e20a7761a)
- Bug 1258228 - create special child accessibles in owner's constructor, part3, r=marcoz (6574efb1e7)
- Bug 1258228 - create special child accessibles in owner's constructor, part4, r=marcoz (15420c5a12)
- Bug 1188818 - DataTransfer must deal with nsIFile of directories, r=jwatt (715a857dd1)
- Bug 1126295 - Move TestAtoms.cpp to gtest and enable it; r=froydnj (9275ebeb3c)
- Bug 1257128 (part 1) - Remove nsIAtom.equalsUTF8. r=froydnj. (17238a04e6)
- Bug 1257128 (part 2) - Remove nsIAtomService.get{,Permanent}AtomUTF8. r=froydnj. (f4131f1024)
- Bug 1257128 (part 3) - Remove unused createAtom() function in a test. r=tbsaunde. (e082c1bc17)
- Bug 1257128 (part 4) - Remove unused nsIAtomService references in toolkit/. r=froydnj. (5ddae71ae8)
- Bug 1257402 - Remove NS_NewPermanentAtom() and nsIAtomService.getPermanentAtom(). r=froydnj,kmag. (4b9ad7894e)
- Bug 1145395 - Pass Element& to nsHTMLEditor::RemoveElementIfNoStyleOrIdOrClass; r=ehsan (83080cb024)
- Bug 1140105 - Can't query for a specific font face when the selection is collapsed. r=ehsan (b534c04e7f)
- Bug 1145395 - Introduce an overload of nsHTMLEditor::RemoveStyleInside that takes nsIContent&; r=ehsan (c5cb3bfb1d)
- Bug 1170326 - nsHTMLCSSUtils::ParseLength should check if the input is an empty string, r=ehsan (1950f67c9f)
- Bug 1260871 - Remove do_GetAtom() and rename NS_NewAtom() as NS_Atomize(). r=erahm. (984bc596bf)
- Bug 1254128 - Make the Mozilla .lldbinit use the full path for topsrcdir. r=sparky (20856a94b4)
- Bug 1259659 - rename from InternalUIEvent.detail to InternalUIEvent.mDetail. r=masayuki (37165bd487)
- Bug 1249664 - Make stateful frames responsible for their own keys r=dbaron (03a4365aa1)
- Bug 1232338 - part 1, Add better mouse support to InputData MouseInput r=kats (8be234631e)
- Bug 1259655 - part 1 Rename WidgetEventTime::time to WidgetEventTime::mTime r=masayuki (cd679b408e)
- Bug 1235908 - measure total event wait and process time. r=smaug (4364242809)
- Bug 1259655 - part 2 Rename WidgetEventTime::timeStamp to WidgetEventTime::mTimeStamp r=masayuki (94a507904d)
- Bug 1263785 - Kill off the deprecated nsINode::GetCurrentDoc. r=baku (670e175017)
- Bug 1245748 - Remove no-longer-needed code for directly setting up properties in KeyframeEffect(ReadOnly) constructor; r=heycam (166ed7697c)
- Bug 1259285 - Part1 - Move CSS/Web Animations-specific visibility handling. r=birtles (13a4ac2b94)
- Bug 1259285 - Part2 - Add web-platform test for visibility handling. r=birtles (b7cee58cf7)
- Bug 1260655 - Add KeyframeEffectReadOnly::SetFrames; r=heycam (7da27828da)
- Bug 1260655 - Wrap lines in keyframe-effect/constructor.html to 80 chars; r=whitespace-only (32b6412db2)
- Bug 1260655 - Update keyframe-effect/constructor.html to no longer refer to PropertyIndexedKeyframes or Keyframe; r=heycam (dbe0acf873)
- Bug 1260655 - Return the stored Keyframe objects from GetFrames, when available ; r=heycam (5b8cbc1773)
- Bug 1245748 - Add a Move constructor to Keyframe; r=heycam (eeabc9396a)
- Bug 1260655 - Add an assignment operator to Keyframe that takes an rvalue reference; r=heycam (e81f1f6d7c)
- Bug 1260655 - Add methods to CSSAnimationBuilder to build a set of Keyframe objects; r=heycam (93e2a7b3aa)
- Bug 1260655 - Use CSSAnimationBuilder::BuildAnimationFrames to set up CSS animations using Keyframe objects; r=heycam (4df3ad20cd)
- Bug 1260655 - Drop some no-longer-needed code for setting up CSS animations using AnimationProperty objects; r=heycam (e1d8e020aa)
- Bug 1260655 - Add a copy constructor and copy assignment operator to Keyframe; r=heycam (d9a1ca5d24)
- Bug 1249564 - Part 1: Assign the parent object of AnimationEffectTiming(ReadOnly). r=birtles,bz (298bdcf084)
- Bug 1249564 - Part 2: Cycle collect AnimationEffectTimingReadOnly. r=birtles (25d959d057)
- Bug 1263063 - Part 1: Remove unnecessary clamping of TimingParams::mIterationStart, since it's guaranteed to be nonnegative. r=dholbert (35362749d7)
- Bug 1263063 - Part 2: Add an assertion to ensure that iteration count is nonnegative and finite. r=dholbert (7df13df139)
- Bug 1263063 - Part 3: Change logic in KeyFrameEffect to assume that TimingParams' iteration-count has already been validated as nonnegative & finite. r=dholbert (6dd3f0d984)
- Bug 1263063 - Part 4: Move ActiveDuration() into TimingParams. r=dholbert (6760bdeaa7)
- Bug 1263063 - Part 5: Introduce TimingParams::EndTime(). r=dholbert (af9a4ddd95)
- Bug 1260983 - Allow creating animations with a target element not bound to a document; r=heycam (7d71619cfb)
- Bug 1244591 - Part 1: Implement KeyframeEffect.setFrames r=birtles,smaug (e090fa68b6)
- Bug 1244591 - Part 2: Extract useful keyframes tests to a new file r=birtles (780797fe53)
- Bug 1244591 - Part 3: Add web-platform tests for KeyframeEffect.setFrames r=birtles (997d26427b)
- Bug 1259878 - remove unnecessary isSome(). r=birtles (cb21268a0a)
- Bug 1248532 - Part 1: steps-start does not produce correct value at the beginning of the interval. r=birtles (9131923815)
- Bug 1248532 - Part 2: Add tests for step-start. r=birtles (04ae44375d)
- Bug 1248532 - Part 3: add a test for step-end with iterationStart. r=birtles (769827746b)
- Bug 1266257 - Revise timing model calculations to use fraction-based approach; r=hiro (c1de969ef0)
- Bug 1260572 - Replace AnimValuesStyleRule::AddEmptyValue with an overload of AddValue that takes an rvalue reference; r=heycam (08e01a4cdc)
- Bug 1260572 - Use 50% switch behavior if StyleAnimationValue::Interpolate fails; r=heycam (e67754e770)
- Bug 1260976 - Remove the old AnimationProperty-based GetFrames; r=heycam (efc88117e6)
- Bug 1259248. Add an ArrayView class. r=botond (5bb9e22500)
- Bug 1265648 - Remove the global nsTextFrameTextRunCache, as it no longer serves any useful purpose. r=mats (3ffbf42634)
- Bug 1238243 - Don't filter out Hangul jamo fillers as 'ignorable', because the font may require them to provide advance width. r=xidorn (9fc2f82853)
- Bug 1265648 followup - Use an array of UniquePtr<> for mTextRunsToDelete. r=mats (8745a7566e)
- Bug 1263956 - Adopt the new harfbuzz API for char-to-glyph mapping functions. r=jrmuizel (1f061d7b0f)
- Bug 1265568 - Don't require component alpha layers for text with -moz-osx-font-smoothing:grayscale. r=jfkthame,mattwoodrow (f819591273)
- Bug 1199547 - Backout workaround from bug 722676 as it causes issues on at least OSX 10.10 and 10.11. r=mstange (c96fb3a69d)
- Bug 1265953, part 1 - Convert most of the cocoa widget code from nsAutoPtr to UniquePtr. r=mstange (74aa93eaf9)
- Bug 1249915 - Add ability to synthesize native touch events on GTK for mochitests. r=karlt (b734a366fb)
- Bug 1259670 Rename WidgetPluginEvent::retargetToFocusedDocument to WidgetPluginEvent::mRetargetToFocusedDocument r=smaug (24c12b3bb4)
- Bug 1249915 - Fix synthesized touch injection code on Windows to not apply the scale factor twice. r=jimm (b590300aa3)
- Bug 1250505 - Convert SynthesizeNativeTouchPoint and SynthesizeNativeTouchTap to take a LayoutDeviceIntPoint instead of a ScreenPoint. r=njn (8ddd066519)
- Bug 1256731 - patch 1 - Don't apply theme-dpi scaling to metrics of window border elements, because Windows doesn't respect per-monitor dpi scaling when it draws them. r=emk (582676e33e)
- Bug 1247935 - Part 1: double-buffer nsShmImage. r=jrmuizel (2392a1e916)
- Bug 1247935 - Part 2: use shared pixmaps with XShm for nsShmImage. r=jrmuizel (b3dd105fcc)
- Bug 1265953, part 2 - Convert much of the rest of the widget code from nsAutoPtr to UniquePtr. r=mstange (e0c1c49ef8)
- Bug 1265953, part 3 - Convert more widget code from nsAutoPtr to UniquePtr. r=mstange (17e1be57d2)
- Bug 1265953, part 4 - Convert nsMenuX::LoadSubMenu and nsMenuX::AddMenu to UniquePtr. r=mstange (f4ea50b802)
- Bug 1259664 part.1 Rename WidgetWheelEvent::deltaX to WidgetWheelEvent::mDeltaX r=smaug (8c7ef861eb)
- Bug 1259664 part.2 Rename WidgetWheelEvent::deltaY to WidgetWheelEvent::mDeltaY r=smaug (03529452fb)
- Bug 1259664 part.3 Rename WidgetWheelEvent::deltaZ to WidgetWheelEvent::mDeltaZ r=smaug (0d664b2900)
- Bug 1259664 part.4 Rename WidgetWheelEvent::deltaMode to WidgetWheelEvent::mDeltaMode r=smaug (dc8283ee70)
- Bug 1253041 - Don't apply user wheel prefs more than once. r=smaug (2386a9da14)
- Bug 1259664 part.5 Rename WidgetWheelEvent::customizedByUserPrefs to WidgetWheelEvent::mCustomizedByUserPrefs r=smaug (3b16757c1e)
- Bug 1258820 - making root scrollable element not scroll if mouse wheel is used on xul dropdown r=masayuki (58ab750981)
- Bug 1250050 Add a pref to disable supporting mouse wheel of windowless plugins on Windows r=smaug (1560cfcb35)
- Bug 1256162, use last drag target for dragexit event when comparing to a remote browser, r=smaug (2d03394037)
- Bug 1110030 - part1 - add flags:IsSynthesizedByTIP and InputMethodAppState in WidgetKeyboardEvent. r=masayuki (c8f7802ee0)
- Bug 1110030 - part2 - Prevent PostHandleKeyboardEvent if it's handling by IME. r=masayuki (29fab0d4fe)
- Bug 1110030 - part3 - Interface between PresShell and HardwareKeyHandler. r=masayuki, r=smaug (cb152d6b4b)
- Bug 1110030 - part4 - HardwareKeyHandler component. r=masayuki, r=smaug (9e372e8f19)
- Bug 1110030 - part5 - Expose KeyboardEventInit dictionary. r=masayuki, r=smaug (3c38bf2f37)
- Bug 1110030 - part6 - Expose DefaultPreventedBy*. r=masayuki, r=smaug (5c94c067be)
- Bug 1110030 - part7 - Interface between HardwareKeyHandler and Input Method App. r=masayuki, r=smaug (f33b7f5ad5)
- Bug 1244546 part 1 - Apply proper unit conversion for SynthesizeNativeMouseEvent. r=karlt (8596ff8068)
- Bug 1244546 part 2 - Align the center point for pointerlock to meet widget's requirement. r=smaug (c447b8c770)
- Bug 1259664 part.6 Rename WidgetWheelEvent::mayHaveMomentum to WidgetWheelEvent::mMayHaveMomentum r=smaug (ef95784e26)
- Bug 1259664 part.7 Rename WidgetWheelEvent::isMomentum to WidgetWheelEvent::mIsMomentum r=smaug (983c8dc9e3)
- Bug 1259664 part.8 Rename WidgetWheelEvent::scrollType to WidgetWheelEvent::mScrollType r=smaug (c6731aee2d)
- Bug 1259664 part.9 Rename WidgetWheelEvent::lineOrPageDeltaX to WidgetWheelEvent::mLineOrPageDeltaX r=smaug (9c6d3d7f6b)
- Bug 1259664 part.10 Rename WidgetWheelEvent::lineOrPageDeltaY to WidgetWheelEvent::mLineOrPageDeltaY r=smaug (8a0d549eee)
- Bug 1259664 part.11 Rename WidgetWheelEvent::overflowDeltaX to WidgetWheelEvent::mOverflowDeltaX r=smaug (6200509b12)
- Bug 1259664 part.12 Rename WidgetWheelEvent::overflowDeltaY to Widget¦WheelEvent::mOverflowDeltaY r=smaug (3827fc7cef)
- Bug 1259664 part.13 Reorder the definition of members of WidgetWheelEvent r=smaug (ea69305e49)
- Bug 1243628 - Allow for presshell to have been destroyed and disconnected from prescontext during event dispatch. r=dholbert (b98e7ed1a2)
- Bug 1256952, send a dragexit at remote process when leaving the remote frame, r=smaug (1037c6a425)
- Bug 1261818 - don't pass nsAutoCStrings into nsBaseWidget debugging methods; r=karlt (36b2b66795)
- Bug 1250560 - Fix crash in HandleTouchEvent. r=roc (9586890edf)
- Bug 1121468 - Go to NoActionState after receiving release on LongTapState. r=roc (4e05f9ad70)
- Bug 1248847 - Assert AccessibleCaretEventHub mRefCnt > 1 in all its entry points. r=mats (89ced3c3e2)
- Bug 1251915 - Correct AccessibleCaretEventHub coding style by clang-format. r=roc (12d5b507d7)
- Bug 1259668 Rename WidgetTouchEvent::touches to WidgetTouchEvent::mTouches r=smaug (9c53824e17)
- Bug 1259657 Rename WidgetGUIEvent::widget to WidgetGUIEvent::mWidget r=smaug (8707f57a28)
- Bug 1246477 - Fix carets not updated by scroll events in LongTapState. r=roc (ba6f12001c)
- Bug 1259662 part.1 Rename WidgetDragEvent::dataTransfer to WidgetDragEvent::mDataTransfer r=smaug (79ffebe3ae)
- Bug 1259662 part.2 Rename WidgetDragEvent::userCancelled to WidgetDragEvent::mUserCancelled r=smaug (4b7ee565e7)
- Bug 1241008 - Add preference to show or hide selection bars. r=mtseng (aefd4c430d)
- Bug 1242349 - Provide unique AccessibleCaret pref for JS selection changes, r=TYLin (e964cb16cf)
- Bug 1240917 - Do not show caret in empty input on Fennec. r=roc (d73c6bd94d)
- Bug 1121468 - Show carets when long-pressing on selection highlight. r=roc (bf134067de)
- Bug 1246064 - Support long press to show AccessibleCaret on empty input for Fennec. r=roc (90791443cb)
- Bug 1246918 - Fix carets missing after scrolling down in selection mode on Fennec. r=roc (bc0915ad70)
- Bug 1246918 - Handle PresShell gone after FlushLayout(). r=roc (b2f18c9a03)
- Bug 1251915 - Ignore handling eTouchCancel events. r=roc (a04c3ad8eb)
- Bug 1121468 - Use auto* to explicit declare 'self' as a pointer. r=roc (d83a6020e3)
- Bug 1251346 - Fennec should not generate touch events from mouse events. r=kats (d8077748fc)
- Bug 1259656 part.1 Rename WidgetEvent::refPoint to WidgetEvent::mRefPoint r=smaug (fa66825fc9)
- Bug 1259656 part.2 Rename WidgetEvent::lastRefPoint to WidgetEvent::mLastRefPoint r=smaug (c964d62185)
- Bug 1259656 part.3 Rename WidgetEvent::userType to WidgetEvent::mSpecifiedEventType r=smaug (218ae50355)
- Bug 1259656 part.4 Rename WidgetEvent::typeString to WidgetEvent::mSpecifiedEventTypeString r=smaug (0192c890c9)
- Bug 1259656 part.5 Rename WidgetEvent::target to WidgetEvent::mTarget r=smaug (031356f40d)
- Bug 1259656 part.6 Rename WidgetEvent::currentTarget to WidgetEvent::mCurrentTarget r=smaug (451810f6d3)
- Bug 1259656 part.7 Rename WidgetEvent::originalTarget to WidgetEvent::mOriginalTarget r=smaug (643379c9cb)
- Bug 1259673 rename from InternalClipboardEvent.clipboardData to InternalClipboardEvent.mClipboardData. r=masayuki (5ad3c180fe)
- Bug 1259674 Part 1 rename InternalFocusEvent::fromRaise to InternalFocusEvent::mFrameRaise r=masayuki (400f1ba6e9)
- Bug 1259674 Part 2 rename InternalFocusEvent::isRefocus to InternalFocusEvent::mIsRefocus r=masayuki (93b5799c31)
- Bug 1259674 Part 3 rename InternalFocusEvent::relatedTarget to InternalFocusEvent::mRelatedTarget r=masayuki (2382b8de82)
- Bug 1256589 part.7 Add PropagationStopped() to WidgetEvent r=smaug (09325f188d)
- Bug 1259663 - Clean up WidgetMouseScrollEvent. r=masayuki (48e1389e22)
- Bug 1263782 - Kill off the deprecated nsINode::IsInDoc(). r=baku (ae80ec21f7)
- Bug 1223751 - Assume all frames are visible in subdocuments of a top level content document that's assuming all frames are visible. r=tn (3b4f99b2fc)
- Bug 1223747 - Don't assume all frames are visible in XUL documents. r=tn (7f26104ff8)
- Bug 1180267 - Switch Fennec over to using the MobileViewportManager for computing the CSS viewport. r=snorp (b85a3a5fb7)
- put back some SPS stuff (960414c383)
- Bug 1151152 - Change behavior when pointer is dragged out of the document. r=smaug (64779386f0)
- Bug 1263787 - Kill off the deprecated nsINode::GetCrossShadowCurrentDoc. r=baku (ed490173ff)
- Bug 1261933 - Continue unlocking pointer even if the widget has gone. r=smaug (93a781887a)
- Bug 1259296 - Do not scroll snap on the main thread for wheel events handled by APZ. r=kats (f72a7fef66)
- Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r=roc (1c2cc7e7c7)
- Bug 1208371 - Make AudioCaptureStream startable. r=padenot (15849ae011)
- Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r=roc (a772c949e0)
- Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r=jib (9157aa056e)
- Bug 1208371 - Introduce MediaStreamTrack logs. r=roc,jib (72ff4d4c59)
- Bug 1208371 - Track original track in MediaStreamTrack clones. r=jib (39e9ae1200)
- Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r=roc (b1e0b48012)
- Bug 1253333: Don't cause a second MediaManager to be created if there's a race with NotifyFinished r=jib (d22d6d01e5)
- Bug 1251357 - fix regression where last MediaStreamTrack.stop did not turn off the camera light. r=jesup (11b4880c02)
- Bug 1208371 - Add a MediaStreamTrackSource interface. r=roc (bb1880524b)
- Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r=roc (c57a1c6a74)
- Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r=roc (62739d72bf)
- Bug 1259236 - throw NotSupportedError on pc.addTrack of track in constructed stream. r=bwc (8b828e80e4)
- Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r=roc (26c24ad3c7)
- Bug 1208371 - Add some MediaStreamTrack helper methods. r=roc (1627cd36f8)
- Bug 1208371 - Count the users of a MediaStream to ease Destroy() resonsibility. r=roc (613d446b39)
- bug 1223670 assert that connected streams have the same graph r=padenot (17ea987392)
- Bug 1208371 - Add convenience method for checking if TrackID is explicit. r=roc (32c9d5fe45)
- Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r=roc (71d3c66c4d)
- Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r=roc (cbcf54a342)
- Bug 1208371 - Add MediaStreamTrack::Graph(). r=jib (044b348267)
- Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r=jib (6f58360808)
- Bug 1208371 - Add a generic PrincipalChangeObserver interface. r=mt (79dfb91a89)
- Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r=mt (41fdd835de)
- Bug 1208371 - Add principal APIs to MediaStreamTrack. r=mt (a8aab0e0d9)
- Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r=mt (d9fefd4e3c)
- Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r=mt (0c046c7c20)
- Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r=roc (ecde0ddae0)
- Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r=mt (03ccd4ab12)
- Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r=mt (5a4b1eb0bc)
- Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r=mt (d29fc5c36e)
- Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r=mt,bwc (e4337cc413)
- Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r=mt (9a7c744a19)
- Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r=mt (b30919c681)
- Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r=mt (5279935d2b)
- Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r=roc (5d7048793e)
- Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r=roc (98d081b034)
- Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r=jib (c65d07cb55)
- Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r=roc (092dad3654)
- Bug 1208371 - Remove MediaStreamTrack::GetStream. r=jib (a78f873d89)
- Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r=jib (32dfd76245)
- Bug 1208371 - Kill nsDOMUserMediaStream with fire. r=jib (9550ad61be)
- Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r=roc (39fdd2322f)
- Bug 1208371 - Implement MediaStreamTrack::Clone(). r=smaug,jib,roc (1995b87f10)
- Bug 1208371 - Implement DOMMediaStream::Clone() r=smaug,jib,roc (d445dffd30)
- Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r=jib (a174781a1b)
- Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r=roc (36ed98f3e4)
- Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r=jib (123bcd8192)
- Bug 1240478 - Add test for video size on 'loadedmetadata'. r=jesup,jib Bug 1208371 - Test DOMMediaStream::Clone(). r=jib (5ff908fcad)
- Bug 1208371 - Test DOMMediaStream::Clone(). r=jib (445556e6b5)
- Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r=jib (41c71b073c)
- Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r=bwc (f998354d96)
- Bug 1208371 - Test MediaStreamTrack::Clone(). r=jib (34865902b0)
- Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r=mt (2244b06567)
- Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r=roc (f21675220b)
- bug 1223670 throw not supported when creating a node from a stream with different channel r=baku (55e1d67356)
- Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r=mt,padenot (77640fa752)
- Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r=mt (aa533e8945)
- Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r=mt (41447ccea1)
- Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r=mt (b8168de792)
- Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r=roc (fe275597ca)
- Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r=padenot (ee97d9f274)
- bug 916387 remove workarounds in tests r=padenot (0285f2b98a)
- Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r=padenot (bb3afcdd12)
- Bug 1208371 - Make PeerIdentity RefCounted. r=mt (74320ca464)
- Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r=mt (77bffa988f)
- Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r=mt (4b4163b66d)
- Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r=mt (30b5ab4b5d)
- Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r=mt (0d6b66614e)
- Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r=roc (d9eb5210e0)
- Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r=roc (5d7b83b51c)
- Bug 1208371 - Inline MediaRecorder::Session::SetupStreams. r=roc (1f8463266e)
- Bug 1153690 - Release the Session and MediaRecorder objects correctly if there is no ExtractRunnable running. r=roc (424117e697)
- Bug 1257318: Move MediaRecorder to use DirectListeners wherever possible. r=roc (1d6336641b)
- Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r=roc (946080d5e7)
- Bug 1219711 - Add mochitest for track disabling over a peer connection. r=jib (ad345e05e2)
- Bug 1166832 - Add test to verify audio (using AudioStreamAnalyser) after renegotiation. r=bwc (ad11535ee3)
- Bug 1250934: Make tests use the correct audio frequency when fake devices are used r=drno (1b8cb18b8f)
- Bug 1182426 - Test that we can record CanvasCaptureMediaStreams. r=roc (e65a5dce61)
- Bug 1219711 - Refactor captureStream_common.js to accept generic pixel testing method. r=jib (e55194c8f5)
- Bug 1223696 - Make canvas captureStream helper resilient to exceptions when there's no video. r=roc (215711b89d)
- Bug 1223696. Don't destroy VideoFrameContainer when we reach MetadataLoaded without a video track. r=jwwang (2c83a23b24)
- Bug 1166832 - Add test for canvas capture on multiple streams. r=bwc (592db27fc4)
- Bug 1224029: ensure video elements that may be disabled (black) are scaled r=mattwoodrow (bfef6af17d)
- Bug 1208371 - Simplify track disabling test code. r=jib (771d560f40)
- Bug 1208371 - Test disabling track across peerconnection not affecting clones. r=jib (31913dd9e6)
- Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r=roc,jesup (ae86375502)
- Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r=jesup,bwc (aa32ce43e1)
- Bug 1208371 - Let PeerConnection consume principals from tracks instead of streams. r=mt (825d6775d0)
- Bug 1257318: Make recorder.pause()/resume() work with DirectListeners r=padenot (65ff6bff4e)
- Bug 1208371 - Move FindTrack from SourceMediaStream to MediaStream. r=roc (5725a863ae)
- Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r=jesup (ea7445369d)
- Bug 1208371 - Make GraphDriver callback log calls verbose. r=padenot (a502ceea55)
- Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r=jib (c27ee1c308)
- Bug 1208371 - Add a track getter to gUM for fake tracks. r=jib (4958d2b392)
- Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r=jib (2437b932b2)
- Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r=padenot (38b1ad91e8)
- Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r=padenot (a8b5a62ad6)
- Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r=jib (19e14785f3)
- Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r=padenot (b7e3280b68)
- Bug 1208371 - Add disconnect method to test helper AudioStreamAnalyser to improve performance on slow devices. r=padenot (2a18d693a7)
- Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r=pkerr (0f6d425cf4)
- Bug 1208371 - Clear output canvas on each drawImage(). r=jib (45731c0c9a)
- Bug 1208371 - Wait for "loadedmetadata" before setting up nodes in test_mediaElementAudioSourceNodeCrossOrigin.html. r=padenot (8e9398fe88)
- Bug 1181051 - Remove BOM from dom/media/test/test*.html. r=kinetik (c98b2c9b96)
- Bug 1070110 - Ensure the testcase will receive at least 2 blob. r=jwwang (028cb09b08)
- Bug 1208371 - Improve reliability of test_mediarecorder_record_timeslice.html. r=jwwang (c89bd3fe0b)
- Bug 1251494 - Remove remaining references to MOZILLA_XPCOMRT_API from dom. r=jesup (5b8e7ef603)
- Bug 1234230: Don't pass null images for video encoding, and don't reencode the same image r=roc (eb09c07d8d)
- Bug 1258567 - per comment 3, ensure volume is only applied once to the AudioSegment. r=kinetik. (a7e184e483)
- Bug 1250934: Modify MediaEngine shutdown to allow neutering the AudioDataListener r=padenot (70f4831508)
- Bug 1208371 - Add PrincipalHandle to MediaChunks. r=mt,jesup (0662c26a97)
- Bug 1208371 - Add NotifyPrincipalHandleChanged to MediaStreamTrackListener. r=mt,jesup (54d896b1ff)
- Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r=mt,jesup (9b4d2e0996)
- Bug 1256520 - use SyncRunnable to create DecodedStreamData synchronously to ensure the creation and destruction of DecodedStreamData happen in order. r=kikuo. (7d28eaebba)
- Bug 1237482 - Remove MediaDecoderStateMachine::mStreamSink. r=kikuo. (609efed70f)
- Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r=mt,jwwang (9290efb216)
- Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r=mt,bwc (b00ed70ddc)
- Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r=mt,jesup (bd3e32ef16)
- Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r=mt,jesup (7914faa5dc)
- Bug 1208371 - Forward declare MediaStreamTrack in MediaPipeline.h. r=bwc (4c88b79137)
- Bug 1208371 - Clean up unnecessary virtuals in MediaPipeline. r=bwc (b7112f4b34)
- Bug 1208371 - Move MediaStreamTrack's label to MediaStreamTrackSource. r=jib (045bfcc738)
- Bug 1259590 - Remove B2G ACL code. r=khuey (e13223c0f6)
- Bug 1265452 followup - Make mGlyphExtentsArray an array of UniquePtr. r=jrmuizel (d12ce46244)
- Bug 1250540 - have media.navigator.permission.disabled no longer bypass media.getusermedia.screensharing.allowed_domains. r=jesup (e55aa02580)
- Bug 1247806 - Fix HSTS redirect check in WebSocketChannel, r=mcmanus (4e44becf9e)
- Bug 1251530: Use 'MakeUnique' instead of 'new' to populate UniquePtr variable in AddCSSValuePair. r=jwatt (286bf2289a)
- Bug 1264787: Make nsCSSValue's AdoptListValue & AdoptPairListValue methods take a UniquePtr. r=heycam (0f7dc7164f)
- Bug 1151243 part 3 - [css-grid] Add a generic nsHTMLReflowState::STATIC_POS_IS_CB_ORIGIN flag to place the static-position at the CB origin, and make nsAbsoluteContainingBlock use it in Grid containers where the placeholder is a child too. r=dholbert (7bde498cc4)
- Bug 1151243 part 4 - Some code cleanup in nsHTMLReflowState::CalculateHypotheticalPosition, and make a few methods 'const' (idempotent patch). r=dholbert (e430f9b99d)
- Bug 1250540 - fix string-parsing regression that made screen share whitelisting stop working. r=jesup (f8af7c3053)
- Bug 1265641: Move AEC tail length and delay-agnostic settings to getUserMedia r=padenot (3feaf716ee)
- Bug 950936 - Introduce ui.popup.disable_autohide pref to ease debugging popups. r=neil (bc28dcd531)
- bug 1211892 read -unico-border-gradient of early Unico versions for ThreeDHighlight and ThreeDShadow r=acomminos (39c83b1865)
- bug 1257695 disable GTK3 deprecation warnings in widget/gtk r=acomminos (1ad2ba0271)
- Bug 1258989 - Switch gtk3drawing to a C++ file, r=karlt (55b8ea3cdf)
- Bug 1259433 - remove gtk_widget_style_get() from gtk3drawing, r=karlt a=kwierso (a9fc049140)
- Bug 1266680 - Rename BlockTrackId to BlockSourceTrackId. r=jesup (5066bbf870)
- Bug 1262808: Refactor |PrincipalID| to |PrincipalHandle| in Gonk media code, r=rjesup (49ec99e852)
- Bug 1144096 part 1 - [css-grid] Refactor nsGridContainerFrame state and methods. r=dholbert (502fb7d424)
- Bug 1144096 part 2 - [css-grid] Make GridItemInfo::mFrame available also in non-DEBUG builds since we'll need it to support fragmentation. r=dholbert (fe0b396741)
- Bug 1144096 part 3 - [css-grid] Remove CellMap::ClearOccupied() since it's not needed anymore. r=dholbert (7aeacdccab)
- Bug 1144096 part 4 - [css-grid] Move more local nsGridContainerFrame classes into .cpp file. r=dholbert (896fc410ac)
- Bug 1144096 part 5 - [css-grid] Create a couple of Grid container frame bits. r=dholbert (abd007fd90)
- Bug 1144096 part 6 - [css-grid] Add support for creating Grid container continuations and deal with overflow containers. r=dholbert (3f02728f24)
- Bug 1144096 part 7 - [css-grid] Don't create PageBreakFrames inside a Grid container. The container will handle forced breaks on its items. r=dholbert (5a0c64369c)
- Bug 1144096 part 8 - [css-grid] Add a new state flag, eBreakBefore, to record where breaks occur between tracks. r=dholbert (5f5d8761c6)
- Bug 1144096 part 9 - [css-grid] Create a SharedGridData object owned by the first-in-flow Grid container to share state between its continuations. r=dholbert (7e510f0bf0)
- Bug 1144096 part 10 - [css-grid] Add a few helper methods to do a break before a row, and resize a row. r=dholbert (d3fec771a6)
- Bug 1144096 part 11 - [css-grid] Add a GetNearestFragmentainer() method that collects some data from the nearest enclosing fragmentainer needed for fragmentation. r=dholbert (20d4736a1c)
- Bug 1144096 part 12 - [css-grid] Collect and merge child frames we need for reflow. r=dholbert (3b5c619f34)
- Bug 1144096 part 13 - [css-grid] Refactor ReflowChildren() by separating out the code that reflows normal flow children (grid items and placeholders) into a new method ReflowInFlowChild(). r=dholbert (ba8a1edc7b)
- Bug 1144096 part 14 - [css-grid] Make ReflowInFlowChild() deal with a constrained available block-size. r=dholbert (292df4167a)
- Bug 1144096 part 15 - [css-grid] Compute our pre-reflow logical skip sides and cache the result of ComputedLogicalBorderPadding() with that applied. r=dholbert (0c7f59389e)
- Bug 1144096 part 16 - [css-grid] Implement fragmentation. r=dholbert (af8b8aac41)
- Bug 1144096 part 17 - [css-grid] Add helper methods that add a sorted list of child frames to the Overflow and ExcessOverflowContainers child lists. r=dholbert (a6c80c9e9c)
- Bug 1144096 part 18 - [css-grid] Fix a couple of bugs in how we handle child existing continuations when pushing/pulling children. r=dholbert (b8a62fab65)
- Bug 1144096 part 19 - [css-grid] Sanity check the initial child lists we get from the frame constructor (DEBUG only). r=dholbert (f56955c3ec)
- Bug 1144096 part 20 - [css-grid] Sanity check our child lists before starting a Reflow (DEBUG only). r=dholbert (d89c771238)
- Bug 1144096 part 21 - [css-grid] Deal with dynamically inserted/appended/removed child frames. r=dholbert (a07ecc06e2)
- Bug 1144096 part 22 - [css-grid] Check NS_INLINE_IS_BREAK_BEFORE before checking other completion status. r=dholbert (731dcd0ac5)
- Bug 1144096 part 23 - [css-grid] A grid container fragment that is an overflow container can't be INCOMPLETE, only OVERFLOW_INCOMPLETE and it should always have zero BSize. r=dholbert (afcd6c1741)
- Bug 1144096 part 24 - [css-grid] Move the child frame merging code at the start of ReflowOverflowContainerChildren into a new method: DrainExcessOverflowContainersList. Make both take a param so that we can override how the OC child lists are merged together (normally just an Append; MergeSortedFrameLists for Grid). r=dholbert (95323b0a56)
- Bug 1144096 part 25 - [css-grid] Enable fragmentation to occur by reporting our actual reflow status. r=dholbert (767c389238)
- Bug 1144096 part 26 - [css-grid] Fragmentation reftests. (07e62f8fd6)
- Bug 1244006 - Use const instead of MOZ_CONSTEXPR to avoid startup crash; r=dbaron (39b0bb32fb)
- Bug 1053986 - Fix comment referring to a GetBorder method that no longer exists. r=dholbert (2cde22a42c)
- Bug 1264784 - part 1 - call nsIFrame::{GetScreenRect,GetView} instead of their *External counterparts; r=dholbert (a2cd84b7a2)
- Bug 963238: Support isTypeSupported() in MediaRecorder, and throw on invalid mimetypes at construction r=cpearce,khuey (5a3709e45f)
- Bug 963238: Fix compilation errors. r=me (09b541337f)
- Bug 1157654 - 1. Do not call MediaRecorder.stop immediately after MediaRecorder.start, because we want to receive an onerror callback. 2. Make the NofityError async. r=roc (ad56918042)
- Bug 1128448 - 1. Close the pref media.encoder.omx.enabled for newer android version. 2. Modify testcase and MR to eusure no timing issue. r=roc (9dfff44a2c)
- Bug 1197669 - Part3 - Ensure the start event comes before any blobs. r=jwwang (d4e950fa49)
- Bug 1225327 - fix |mEncoder| null-dereference. r=jwwang (5ffce18e33)
- Bug 1260702: Don't crash on input sources from WebAudio in MediaRecorder r=padenot (28bcb80a03)
- Bug 1018299 - Throw security error if principal check fails in MediaRecorder::Start(). r=jib, r=mt (1130168c8d)
- Bug 1261007 - Part 1 - Force to send video sample into encoder if we got the same video sample more than 1 seconds. Enable testcases. r=jolin (5698b39b45)
- Bug 1182426 - Test that changing video resolution of a recorded stream throws an error. r=roc (edaf49f2cf)
- Bug 1261007 - Part 2 - fix test_mediarecorder_webm_support. r=rillian (16ef931949)
- Bug 1250054. Part 1 - implement MediaDecoderReaderWrapper. r=jya. (4b78b4335d)
- Bug 1242841 - Make MDSM::mDecodedAudioEndTime zero-based. r=kikuo. (c6c756d554)
- Bug 1242843 - Make MDSM::mDecodedVideoEndTime zero-based. r=kikuo. (c194178323)
- Bug 1242783. Part 1 - per comment 11, increase mAmpleAudioThresholdUsecs to 2s to avoid audio underrun when BT is connected. r=kinetik. (49567f587e)
- Bug 1242783. Part 2 - per comment 12, buffer only 1s when audio is captured. r=kinetik. (e0f0cd9826)
- Bug 1230641: P1. Use UYVY (YUV422) format in decoders. r=mattwoodrow (17d4de398c)
- Bug 1230641: P2. Increase the video queue size on mac. r=cpearce (e575c85f44)
- Bug 1230641 - Make our NSOpenGLContext opaque when in fullscreen mode. r=mstange (51da9e1e70)
- Bug 1257094 - Remove MediaDecoderStateMachine::DECODER_STATE_DECODING_NONE. r=cpearce. (f0993582c7)
- Bug 1252344. Part 1 - remove unnecessary checks from MediaDecoderStateMachine::NeedToDecodeVideo(). r=bechen. (1c9b7aadf4)
- Bug 1252344. Part 2 - remove unnecessary checks from MediaDecoderStateMachine::NeedToDecodeAudio(). r=bechen. (6896d7d1f6)
- Bug 1252360 - remove some check from NeedToDecodeAudio(). r=bechen. (1c064a9985)
- Bug 1252762 - Decode at most one audio/video sample before finishing seeking. r=cpearce. (73ec7691df)
- Bug 1253928 - adjust the time passed to RequestVideoData() by the start time to avoid incorrectly skipping key frames. r=jya. (1bc203d8e6)
- Bug 1252766 - Remove MediaDecoderStateMachine::mDecodeToSeekTarget which is never read. r=kaku. (aac1fe8018)
- Bug 1251460 - MDSM now waits on a promise to enqueue first frame loaded. r=jya (0e7e67e006)
- Bug 1257013 - Part 3: Stop checking for corrupt frames in MediaDecoderStateMachine since we no longer produce them. r=ajones (fbbbabafbb)
2024-04-24 23:53:16 +08:00

2948 lines
116 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* struct containing the input to nsIFrame::Reflow */
#include "nsHTMLReflowState.h"
#include "LayoutLogging.h"
#include "nsStyleConsts.h"
#include "nsCSSAnonBoxes.h"
#include "nsFrame.h"
#include "nsIContent.h"
#include "nsGkAtoms.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsFontMetrics.h"
#include "nsBlockFrame.h"
#include "nsLineBox.h"
#include "nsImageFrame.h"
#include "nsTableFrame.h"
#include "nsTableCellFrame.h"
#include "nsIPercentBSizeObserver.h"
#include "nsLayoutUtils.h"
#include "mozilla/Preferences.h"
#include "nsFontInflationData.h"
#include "StickyScrollContainer.h"
#include "nsIFrameInlines.h"
#include "CounterStyleManager.h"
#include <algorithm>
#include "mozilla/dom/HTMLInputElement.h"
#ifdef DEBUG
#undef NOISY_VERTICAL_ALIGN
#else
#undef NOISY_VERTICAL_ALIGN
#endif
using namespace mozilla;
using namespace mozilla::css;
using namespace mozilla::dom;
using namespace mozilla::layout;
enum eNormalLineHeightControl {
eUninitialized = -1,
eNoExternalLeading = 0, // does not include external leading
eIncludeExternalLeading, // use whatever value font vendor provides
eCompensateLeading // compensate leading if leading provided by font vendor is not enough
};
static eNormalLineHeightControl sNormalLineHeightControl = eUninitialized;
// Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things.
nsHTMLReflowState::nsHTMLReflowState(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsRenderingContext* aRenderingContext,
const LogicalSize& aAvailableSpace,
uint32_t aFlags)
: nsCSSOffsetState(aFrame, aRenderingContext)
, mBlockDelta(0)
, mOrthogonalLimit(NS_UNCONSTRAINEDSIZE)
, mReflowDepth(0)
{
NS_PRECONDITION(aRenderingContext, "no rendering context");
MOZ_ASSERT(aPresContext, "no pres context");
MOZ_ASSERT(aFrame, "no frame");
MOZ_ASSERT(aPresContext == aFrame->PresContext(), "wrong pres context");
parentReflowState = nullptr;
AvailableISize() = aAvailableSpace.ISize(mWritingMode);
AvailableBSize() = aAvailableSpace.BSize(mWritingMode);
mFloatManager = nullptr;
mLineLayout = nullptr;
memset(&mFlags, 0, sizeof(mFlags));
mDiscoveredClearance = nullptr;
mPercentBSizeObserver = nullptr;
if (aFlags & DUMMY_PARENT_REFLOW_STATE) {
mFlags.mDummyParentReflowState = true;
}
if (aFlags & COMPUTE_SIZE_SHRINK_WRAP) {
mFlags.mShrinkWrap = true;
}
if (aFlags & STATIC_POS_IS_CB_ORIGIN) {
mFlags.mStaticPosIsCBOrigin = true;
}
if (!(aFlags & CALLER_WILL_INIT)) {
Init(aPresContext);
}
}
static bool CheckNextInFlowParenthood(nsIFrame* aFrame, nsIFrame* aParent)
{
nsIFrame* frameNext = aFrame->GetNextInFlow();
nsIFrame* parentNext = aParent->GetNextInFlow();
return frameNext && parentNext && frameNext->GetParent() == parentNext;
}
/**
* Adjusts the margin for a list (ol, ul), if necessary, depending on
* font inflation settings. Unfortunately, because bullets from a list are
* placed in the margin area, we only have ~40px in which to place the
* bullets. When they are inflated, however, this causes problems, since
* the text takes up more space than is available in the margin.
*
* This method will return a small amount (in app units) by which the
* margin can be adjusted, so that the space is available for list
* bullets to be rendered with font inflation enabled.
*/
static nscoord
FontSizeInflationListMarginAdjustment(const nsIFrame* aFrame)
{
float inflation = nsLayoutUtils::FontSizeInflationFor(aFrame);
if (aFrame->IsFrameOfType(nsIFrame::eBlockFrame)) {
const nsBlockFrame* blockFrame = static_cast<const nsBlockFrame*>(aFrame);
// We only want to adjust the margins if we're dealing with an ordered
// list.
if (inflation > 1.0f &&
blockFrame->HasBullet() &&
inflation > 1.0f) {
auto listStyleType = aFrame->StyleList()->GetCounterStyle()->GetStyle();
if (listStyleType != NS_STYLE_LIST_STYLE_NONE &&
listStyleType != NS_STYLE_LIST_STYLE_DISC &&
listStyleType != NS_STYLE_LIST_STYLE_CIRCLE &&
listStyleType != NS_STYLE_LIST_STYLE_SQUARE &&
listStyleType != NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED &&
listStyleType != NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN) {
// The HTML spec states that the default padding for ordered lists
// begins at 40px, indicating that we have 40px of space to place a
// bullet. When performing font inflation calculations, we add space
// equivalent to this, but simply inflated at the same amount as the
// text, in app units.
return nsPresContext::CSSPixelsToAppUnits(40) * (inflation - 1);
}
}
}
return 0;
}
// NOTE: If we ever want to use nsCSSOffsetState for a flex item or a
// grid item, we need to make it take the containing-block block-size as
// well as the inline-size, since flex items and grid items resolve
// block-direction percent margins and padding against the
// containing-block block-size, rather than its inline-size.
nsCSSOffsetState::nsCSSOffsetState(nsIFrame *aFrame,
nsRenderingContext *aRenderingContext,
WritingMode aContainingBlockWritingMode,
nscoord aContainingBlockISize)
: frame(aFrame)
, rendContext(aRenderingContext)
, mWritingMode(aFrame->GetWritingMode())
{
MOZ_ASSERT(!aFrame->IsFlexOrGridItem(),
"We're about to resolve percent margin & padding "
"values against CB inline size, which is incorrect for "
"flex/grid items");
LogicalSize cbSize(aContainingBlockWritingMode, aContainingBlockISize,
aContainingBlockISize);
InitOffsets(aContainingBlockWritingMode, cbSize, frame->GetType());
}
// Initialize a reflow state for a child frame's reflow. Some state
// is copied from the parent reflow state; the remaining state is
// computed.
nsHTMLReflowState::nsHTMLReflowState(
nsPresContext* aPresContext,
const nsHTMLReflowState& aParentReflowState,
nsIFrame* aFrame,
const LogicalSize& aAvailableSpace,
const LogicalSize* aContainingBlockSize,
uint32_t aFlags)
: nsCSSOffsetState(aFrame, aParentReflowState.rendContext)
, mBlockDelta(0)
, mOrthogonalLimit(NS_UNCONSTRAINEDSIZE)
, mReflowDepth(aParentReflowState.mReflowDepth + 1)
, mFlags(aParentReflowState.mFlags)
{
MOZ_ASSERT(aPresContext, "no pres context");
MOZ_ASSERT(aFrame, "no frame");
MOZ_ASSERT(aPresContext == aFrame->PresContext(), "wrong pres context");
NS_PRECONDITION(!mFlags.mSpecialBSizeReflow ||
!NS_SUBTREE_DIRTY(aFrame),
"frame should be clean when getting special bsize reflow");
parentReflowState = &aParentReflowState;
// If the parent is dirty, then the child is as well.
// XXX Are the other cases where the parent reflows a child a second
// time, as a resize?
if (!mFlags.mSpecialBSizeReflow)
frame->AddStateBits(parentReflowState->frame->GetStateBits() &
NS_FRAME_IS_DIRTY);
AvailableISize() = aAvailableSpace.ISize(mWritingMode);
AvailableBSize() = aAvailableSpace.BSize(mWritingMode);
if (mWritingMode.IsOrthogonalTo(aParentReflowState.GetWritingMode())) {
// If we're setting up for an orthogonal flow, and the parent reflow state
// had a constrained ComputedBSize, we can use that as our AvailableISize
// in preference to leaving it unconstrained.
if (AvailableISize() == NS_UNCONSTRAINEDSIZE &&
aParentReflowState.ComputedBSize() != NS_UNCONSTRAINEDSIZE) {
AvailableISize() = aParentReflowState.ComputedBSize();
}
}
mFloatManager = aParentReflowState.mFloatManager;
if (frame->IsFrameOfType(nsIFrame::eLineParticipant))
mLineLayout = aParentReflowState.mLineLayout;
else
mLineLayout = nullptr;
// Note: mFlags was initialized as a copy of aParentReflowState.mFlags up in
// this constructor's init list, so the only flags that we need to explicitly
// initialize here are those that may need a value other than our parent's.
mFlags.mNextInFlowUntouched = aParentReflowState.mFlags.mNextInFlowUntouched &&
CheckNextInFlowParenthood(aFrame, aParentReflowState.frame);
mFlags.mAssumingHScrollbar = mFlags.mAssumingVScrollbar = false;
mFlags.mIsColumnBalancing = false;
mFlags.mIsFlexContainerMeasuringHeight = false;
mFlags.mDummyParentReflowState = false;
mFlags.mShrinkWrap = !!(aFlags & COMPUTE_SIZE_SHRINK_WRAP);
mFlags.mStaticPosIsCBOrigin = !!(aFlags & STATIC_POS_IS_CB_ORIGIN);
mDiscoveredClearance = nullptr;
mPercentBSizeObserver = (aParentReflowState.mPercentBSizeObserver &&
aParentReflowState.mPercentBSizeObserver->NeedsToObserve(*this))
? aParentReflowState.mPercentBSizeObserver : nullptr;
if ((aFlags & DUMMY_PARENT_REFLOW_STATE) ||
(parentReflowState->mFlags.mDummyParentReflowState &&
frame->GetType() == nsGkAtoms::tableFrame)) {
mFlags.mDummyParentReflowState = true;
}
if (!(aFlags & CALLER_WILL_INIT)) {
Init(aPresContext, aContainingBlockSize);
}
}
inline nscoord
nsCSSOffsetState::ComputeISizeValue(nscoord aContainingBlockISize,
nscoord aContentEdgeToBoxSizing,
nscoord aBoxSizingToMarginEdge,
const nsStyleCoord& aCoord) const
{
return nsLayoutUtils::ComputeISizeValue(rendContext, frame,
aContainingBlockISize,
aContentEdgeToBoxSizing,
aBoxSizingToMarginEdge,
aCoord);
}
nscoord
nsCSSOffsetState::ComputeISizeValue(nscoord aContainingBlockISize,
StyleBoxSizing aBoxSizing,
const nsStyleCoord& aCoord) const
{
WritingMode wm = GetWritingMode();
nscoord inside = 0, outside = ComputedLogicalBorderPadding().IStartEnd(wm) +
ComputedLogicalMargin().IStartEnd(wm);
switch (aBoxSizing) {
case StyleBoxSizing::Border:
inside = ComputedLogicalBorderPadding().IStartEnd(wm);
break;
case StyleBoxSizing::Padding:
inside = ComputedLogicalPadding().IStartEnd(wm);
break;
case StyleBoxSizing::Content:
// nothing
break;
}
outside -= inside;
return ComputeISizeValue(aContainingBlockISize, inside,
outside, aCoord);
}
nscoord
nsCSSOffsetState::ComputeBSizeValue(nscoord aContainingBlockBSize,
StyleBoxSizing aBoxSizing,
const nsStyleCoord& aCoord) const
{
WritingMode wm = GetWritingMode();
nscoord inside = 0;
switch (aBoxSizing) {
case StyleBoxSizing::Border:
inside = ComputedLogicalBorderPadding().BStartEnd(wm);
break;
case StyleBoxSizing::Padding:
inside = ComputedLogicalPadding().BStartEnd(wm);
break;
case StyleBoxSizing::Content:
// nothing
break;
}
return nsLayoutUtils::ComputeBSizeValue(aContainingBlockBSize,
inside, aCoord);
}
void
nsHTMLReflowState::SetComputedWidth(nscoord aComputedWidth)
{
NS_ASSERTION(frame, "Must have a frame!");
// It'd be nice to assert that |frame| is not in reflow, but this fails for
// two reasons:
//
// 1) Viewport frames reset the computed width on a copy of their reflow
// state when reflowing fixed-pos kids. In that case we actually don't
// want to mess with the resize flags, because comparing the frame's rect
// to the munged computed width is pointless.
// 2) nsFrame::BoxReflow creates a reflow state for its parent. This reflow
// state is not used to reflow the parent, but just as a parent for the
// frame's own reflow state. So given a nsBoxFrame inside some non-XUL
// (like a text control, for example), we'll end up creating a reflow
// state for the parent while the parent is reflowing.
NS_PRECONDITION(aComputedWidth >= 0, "Invalid computed width");
if (ComputedWidth() != aComputedWidth) {
ComputedWidth() = aComputedWidth;
nsIAtom* frameType = frame->GetType();
if (frameType != nsGkAtoms::viewportFrame) { // Or check GetParent()?
InitResizeFlags(frame->PresContext(), frameType);
}
}
}
void
nsHTMLReflowState::SetComputedHeight(nscoord aComputedHeight)
{
NS_ASSERTION(frame, "Must have a frame!");
// It'd be nice to assert that |frame| is not in reflow, but this fails
// because:
//
// nsFrame::BoxReflow creates a reflow state for its parent. This reflow
// state is not used to reflow the parent, but just as a parent for the
// frame's own reflow state. So given a nsBoxFrame inside some non-XUL
// (like a text control, for example), we'll end up creating a reflow
// state for the parent while the parent is reflowing.
NS_PRECONDITION(aComputedHeight >= 0, "Invalid computed height");
if (ComputedHeight() != aComputedHeight) {
ComputedHeight() = aComputedHeight;
InitResizeFlags(frame->PresContext(), frame->GetType());
}
}
void
nsHTMLReflowState::Init(nsPresContext* aPresContext,
const LogicalSize* aContainingBlockSize,
const nsMargin* aBorder,
const nsMargin* aPadding)
{
if (AvailableISize() == NS_UNCONSTRAINEDSIZE) {
// Look up the parent chain for an orthogonal inline limit,
// and reset AvailableISize() if found.
for (const nsHTMLReflowState *parent = parentReflowState;
parent != nullptr; parent = parent->parentReflowState) {
if (parent->GetWritingMode().IsOrthogonalTo(mWritingMode) &&
parent->mOrthogonalLimit != NS_UNCONSTRAINEDSIZE) {
AvailableISize() = parent->mOrthogonalLimit;
break;
}
}
}
LAYOUT_WARN_IF_FALSE(AvailableISize() != NS_UNCONSTRAINEDSIZE,
"have unconstrained inline-size; this should only "
"result from very large sizes, not attempts at "
"intrinsic inline-size calculation");
mStylePosition = frame->StylePosition();
mStyleDisplay = frame->StyleDisplay();
mStyleVisibility = frame->StyleVisibility();
mStyleBorder = frame->StyleBorder();
mStyleMargin = frame->StyleMargin();
mStylePadding = frame->StylePadding();
mStyleText = frame->StyleText();
nsIAtom* type = frame->GetType();
InitFrameType(type);
InitCBReflowState();
LogicalSize cbSize(mWritingMode, -1, -1);
if (aContainingBlockSize) {
cbSize = *aContainingBlockSize;
}
InitConstraints(aPresContext, cbSize, aBorder, aPadding, type);
InitResizeFlags(aPresContext, type);
nsIFrame *parent = frame->GetParent();
if (parent &&
(parent->GetStateBits() & NS_FRAME_IN_CONSTRAINED_BSIZE) &&
!(parent->GetType() == nsGkAtoms::scrollFrame &&
parent->StyleDisplay()->mOverflowY != NS_STYLE_OVERFLOW_HIDDEN)) {
frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
} else if (type == nsGkAtoms::svgForeignObjectFrame) {
// An SVG foreignObject frame is inherently constrained block-size.
frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
} else {
const nsStyleCoord& bSizeCoord = mStylePosition->BSize(mWritingMode);
const nsStyleCoord& maxBSizeCoord = mStylePosition->MaxBSize(mWritingMode);
if ((bSizeCoord.GetUnit() != eStyleUnit_Auto ||
maxBSizeCoord.GetUnit() != eStyleUnit_None) &&
// Don't set NS_FRAME_IN_CONSTRAINED_BSIZE on body or html elements.
(frame->GetContent() &&
!(frame->GetContent()->IsAnyOfHTMLElements(nsGkAtoms::body,
nsGkAtoms::html)))) {
// If our block-size was specified as a percentage, then this could
// actually resolve to 'auto', based on:
// http://www.w3.org/TR/CSS21/visudet.html#the-height-property
nsIFrame* containingBlk = frame;
while (containingBlk) {
const nsStylePosition* stylePos = containingBlk->StylePosition();
const nsStyleCoord& bSizeCoord = stylePos->BSize(mWritingMode);
const nsStyleCoord& maxBSizeCoord = stylePos->MaxBSize(mWritingMode);
if ((bSizeCoord.IsCoordPercentCalcUnit() &&
!bSizeCoord.HasPercent()) ||
(maxBSizeCoord.IsCoordPercentCalcUnit() &&
!maxBSizeCoord.HasPercent())) {
frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
break;
} else if ((bSizeCoord.IsCoordPercentCalcUnit() &&
bSizeCoord.HasPercent()) ||
(maxBSizeCoord.IsCoordPercentCalcUnit() &&
maxBSizeCoord.HasPercent())) {
if (!(containingBlk = containingBlk->GetContainingBlock())) {
// If we've reached the top of the tree, then we don't have
// a constrained block-size.
frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
break;
}
continue;
} else {
frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
break;
}
}
} else {
frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
}
}
if (parentReflowState &&
parentReflowState->GetWritingMode().IsOrthogonalTo(mWritingMode)) {
// Orthogonal frames are always reflowed with an unconstrained
// dimension to avoid incomplete reflow across an orthogonal
// boundary. Normally this is the block-size, but for column sets
// with auto-height it's the inline-size, so that they can add
// columns in the container's block direction
if (type == nsGkAtoms::columnSetFrame &&
eStyleUnit_Auto == mStylePosition->ISize(mWritingMode).GetUnit()) {
ComputedISize() = NS_UNCONSTRAINEDSIZE;
} else {
AvailableBSize() = NS_UNCONSTRAINEDSIZE;
}
}
LAYOUT_WARN_IF_FALSE((mFrameType == NS_CSS_FRAME_TYPE_INLINE &&
!frame->IsFrameOfType(nsIFrame::eReplaced)) ||
type == nsGkAtoms::textFrame ||
ComputedISize() != NS_UNCONSTRAINEDSIZE,
"have unconstrained inline-size; this should only "
"result from very large sizes, not attempts at "
"intrinsic inline-size calculation");
}
void nsHTMLReflowState::InitCBReflowState()
{
if (!parentReflowState) {
mCBReflowState = nullptr;
return;
}
if (parentReflowState->mFlags.mDummyParentReflowState) {
// from bug 1316649
mCBReflowState = parentReflowState;
return;
}
if (parentReflowState->frame == frame->GetContainingBlock()) {
// Inner table frames need to use the containing block of the outer
// table frame.
if (frame->GetType() == nsGkAtoms::tableFrame) {
mCBReflowState = parentReflowState->mCBReflowState;
} else {
mCBReflowState = parentReflowState;
}
} else {
mCBReflowState = parentReflowState->mCBReflowState;
}
}
/* Check whether CalcQuirkContainingBlockHeight would stop on the
* given reflow state, using its block as a height. (essentially
* returns false for any case in which CalcQuirkContainingBlockHeight
* has a "continue" in its main loop.)
*
* XXX Maybe refactor CalcQuirkContainingBlockHeight so it uses
* this function as well
*/
static bool
IsQuirkContainingBlockHeight(const nsHTMLReflowState* rs, nsIAtom* aFrameType)
{
if (nsGkAtoms::blockFrame == aFrameType ||
#ifdef MOZ_XUL
nsGkAtoms::XULLabelFrame == aFrameType ||
#endif
nsGkAtoms::scrollFrame == aFrameType) {
// Note: This next condition could change due to a style change,
// but that would cause a style reflow anyway, which means we're ok.
if (NS_AUTOHEIGHT == rs->ComputedHeight()) {
if (!rs->frame->IsAbsolutelyPositioned()) {
return false;
}
}
}
return true;
}
void
nsHTMLReflowState::InitResizeFlags(nsPresContext* aPresContext, nsIAtom* aFrameType)
{
const WritingMode wm = mWritingMode; // just a shorthand
bool isIResize =
frame->ISize(wm) !=
ComputedISize() + ComputedLogicalBorderPadding().IStartEnd(wm);
if ((frame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT) &&
nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) {
// Create our font inflation data if we don't have it already, and
// give it our current width information.
bool dirty = nsFontInflationData::UpdateFontInflationDataISizeFor(*this) &&
// Avoid running this at the box-to-block interface
// (where we shouldn't be inflating anyway, and where
// reflow state construction is probably to construct a
// dummy parent reflow state anyway).
!mFlags.mDummyParentReflowState;
if (dirty || (!frame->GetParent() && isIResize)) {
// When font size inflation is enabled, a change in either:
// * the effective width of a font inflation flow root
// * the width of the frame
// needs to cause a dirty reflow since they change the font size
// inflation calculations, which in turn change the size of text,
// line-heights, etc. This is relatively similar to a classic
// case of style change reflow, except that because inflation
// doesn't affect the intrinsic sizing codepath, there's no need
// to invalidate intrinsic sizes.
//
// Note that this makes horizontal resizing a good bit more
// expensive. However, font size inflation is targeted at a set of
// devices (zoom-and-pan devices) where the main use case for
// horizontal resizing needing to be efficient (window resizing) is
// not present. It does still increase the cost of dynamic changes
// caused by script where a style or content change in one place
// causes a resize in another (e.g., rebalancing a table).
// FIXME: This isn't so great for the cases where
// nsHTMLReflowState::SetComputedWidth is called, if the first time
// we go through InitResizeFlags we set IsHResize() to true, and then
// the second time we'd set it to false even without the
// NS_FRAME_IS_DIRTY bit already set.
if (frame->GetType() == nsGkAtoms::svgForeignObjectFrame) {
// Foreign object frames use dirty bits in a special way.
frame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
nsIFrame *kid = frame->PrincipalChildList().FirstChild();
if (kid) {
kid->AddStateBits(NS_FRAME_IS_DIRTY);
}
} else {
frame->AddStateBits(NS_FRAME_IS_DIRTY);
}
// Mark intrinsic widths on all descendants dirty. We need to do
// this (1) since we're changing the size of text and need to
// clear text runs on text frames and (2) since we actually are
// changing some intrinsic widths, but only those that live inside
// of containers.
// It makes sense to do this for descendants but not ancestors
// (which is unusual) because we're only changing the unusual
// inflation-dependent intrinsic widths (i.e., ones computed with
// nsPresContext::mInflationDisabledForShrinkWrap set to false),
// which should never affect anything outside of their inflation
// flow root (or, for that matter, even their inflation
// container).
// This is also different from what PresShell::FrameNeedsReflow
// does because it doesn't go through placeholders. It doesn't
// need to because we're actually doing something that cares about
// frame tree geometry (the width on an ancestor) rather than
// style.
AutoTArray<nsIFrame*, 32> stack;
stack.AppendElement(frame);
do {
nsIFrame *f = stack.ElementAt(stack.Length() - 1);
stack.RemoveElementAt(stack.Length() - 1);
nsIFrame::ChildListIterator lists(f);
for (; !lists.IsDone(); lists.Next()) {
nsFrameList::Enumerator childFrames(lists.CurrentList());
for (; !childFrames.AtEnd(); childFrames.Next()) {
nsIFrame* kid = childFrames.get();
kid->MarkIntrinsicISizesDirty();
stack.AppendElement(kid);
}
}
} while (stack.Length() != 0);
}
}
SetIResize(!(frame->GetStateBits() & NS_FRAME_IS_DIRTY) &&
isIResize);
// XXX Should we really need to null check mCBReflowState? (We do for
// at least nsBoxFrame).
if (IS_TABLE_CELL(aFrameType) &&
(mFlags.mSpecialBSizeReflow ||
(frame->FirstInFlow()->GetStateBits() &
NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) &&
(frame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_BSIZE)) {
// Need to set the bit on the cell so that
// mCBReflowState->IsBResize() is set correctly below when
// reflowing descendant.
SetBResize(true);
} else if (mCBReflowState && frame->IsBlockWrapper()) {
// XXX Is this problematic for relatively positioned inlines acting
// as containing block for absolutely positioned elements?
// Possibly; in that case we should at least be checking
// NS_SUBTREE_DIRTY, I'd think.
SetBResize(mCBReflowState->IsBResize());
} else if (ComputedBSize() == NS_AUTOHEIGHT) {
if (eCompatibility_NavQuirks == aPresContext->CompatibilityMode() &&
mCBReflowState) {
SetBResize(mCBReflowState->IsBResize());
} else {
SetBResize(IsIResize());
}
SetBResize(IsBResize() || NS_SUBTREE_DIRTY(frame));
} else {
// not 'auto' block-size
SetBResize(frame->BSize(wm) !=
ComputedBSize() + ComputedLogicalBorderPadding().BStartEnd(wm));
}
bool dependsOnCBBSize =
(mStylePosition->BSizeDependsOnContainer(wm) &&
// FIXME: condition this on not-abspos?
mStylePosition->BSize(wm).GetUnit() != eStyleUnit_Auto) ||
mStylePosition->MinBSizeDependsOnContainer(wm) ||
mStylePosition->MaxBSizeDependsOnContainer(wm) ||
mStylePosition->OffsetHasPercent(wm.PhysicalSide(eLogicalSideBStart)) ||
mStylePosition->mOffset.GetBEndUnit(wm) != eStyleUnit_Auto ||
frame->IsBoxFrame();
if (mStyleText->mLineHeight.GetUnit() == eStyleUnit_Enumerated) {
NS_ASSERTION(mStyleText->mLineHeight.GetIntValue() ==
NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT,
"bad line-height value");
// line-height depends on block bsize
frame->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
// but only on containing blocks if this frame is not a suitable block
dependsOnCBBSize |= !nsLayoutUtils::IsNonWrapperBlock(frame);
}
// If we're the descendant of a table cell that performs special bsize
// reflows and we could be the child that requires them, always set
// the block-axis resize in case this is the first pass before the
// special bsize reflow. However, don't do this if it actually is
// the special bsize reflow, since in that case it will already be
// set correctly above if we need it set.
if (!IsBResize() && mCBReflowState &&
(IS_TABLE_CELL(mCBReflowState->frame->GetType()) ||
mCBReflowState->mFlags.mHeightDependsOnAncestorCell) &&
!mCBReflowState->mFlags.mSpecialBSizeReflow &&
dependsOnCBBSize) {
SetBResize(true);
mFlags.mHeightDependsOnAncestorCell = true;
}
// Set NS_FRAME_CONTAINS_RELATIVE_BSIZE if it's needed.
// It would be nice to check that |ComputedBSize != NS_AUTOHEIGHT|
// &&ed with the percentage bsize check. However, this doesn't get
// along with table special bsize reflows, since a special bsize
// reflow (a quirk that makes such percentage height work on children
// of table cells) can cause not just a single percentage height to
// become fixed, but an entire descendant chain of percentage height
// to become fixed.
if (dependsOnCBBSize && mCBReflowState) {
const nsHTMLReflowState *rs = this;
bool hitCBReflowState = false;
do {
rs = rs->parentReflowState;
if (!rs) {
break;
}
if (rs->frame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_BSIZE)
break; // no need to go further
rs->frame->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
// Keep track of whether we've hit the containing block, because
// we need to go at least that far.
if (rs == mCBReflowState) {
hitCBReflowState = true;
}
// XXX What about orthogonal flows? It doesn't make sense to
// keep propagating this bit across an orthogonal boundary,
// where the meaning of BSize changes. Bug 1175517.
} while (!hitCBReflowState ||
(eCompatibility_NavQuirks == aPresContext->CompatibilityMode() &&
!IsQuirkContainingBlockHeight(rs, rs->frame->GetType())));
// Note: We actually don't need to set the
// NS_FRAME_CONTAINS_RELATIVE_BSIZE bit for the cases
// where we hit the early break statements in
// CalcQuirkContainingBlockHeight. But it doesn't hurt
// us to set the bit in these cases.
}
if (frame->GetStateBits() & NS_FRAME_IS_DIRTY) {
// If we're reflowing everything, then we'll find out if we need
// to re-set this.
frame->RemoveStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
}
}
nscoord
nsHTMLReflowState::GetContainingBlockContentISize(WritingMode aWritingMode) const
{
if (!mCBReflowState) {
return 0;
}
return mCBReflowState->GetWritingMode().IsOrthogonalTo(aWritingMode)
? mCBReflowState->ComputedBSize()
: mCBReflowState->ComputedISize();
}
void
nsHTMLReflowState::InitFrameType(nsIAtom* aFrameType)
{
const nsStyleDisplay *disp = mStyleDisplay;
nsCSSFrameType frameType;
// Section 9.7 of the CSS2 spec indicates that absolute position
// takes precedence over float which takes precedence over display.
// XXXldb nsRuleNode::ComputeDisplayData should take care of this, right?
// Make sure the frame was actually moved out of the flow, and don't
// just assume what the style says, because we might not have had a
// useful float/absolute containing block
DISPLAY_INIT_TYPE(frame, this);
if (aFrameType == nsGkAtoms::tableFrame) {
mFrameType = NS_CSS_FRAME_TYPE_BLOCK;
return;
}
NS_ASSERTION(frame->StyleDisplay()->IsAbsolutelyPositionedStyle() ==
disp->IsAbsolutelyPositionedStyle(),
"Unexpected position style");
NS_ASSERTION(frame->StyleDisplay()->IsFloatingStyle() ==
disp->IsFloatingStyle(), "Unexpected float style");
if (frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
if (disp->IsAbsolutelyPositioned(frame)) {
frameType = NS_CSS_FRAME_TYPE_ABSOLUTE;
//XXXfr hack for making frames behave properly when in overflow container lists
// see bug 154892; need to revisit later
if (frame->GetPrevInFlow())
frameType = NS_CSS_FRAME_TYPE_BLOCK;
}
else if (disp->IsFloating(frame)) {
frameType = NS_CSS_FRAME_TYPE_FLOATING;
} else {
NS_ASSERTION(disp->mDisplay == NS_STYLE_DISPLAY_POPUP,
"unknown out of flow frame type");
frameType = NS_CSS_FRAME_TYPE_UNKNOWN;
}
}
else {
switch (GetDisplay()) {
case NS_STYLE_DISPLAY_BLOCK:
case NS_STYLE_DISPLAY_LIST_ITEM:
case NS_STYLE_DISPLAY_TABLE:
case NS_STYLE_DISPLAY_TABLE_CAPTION:
case NS_STYLE_DISPLAY_FLEX:
case NS_STYLE_DISPLAY_WEBKIT_BOX:
case NS_STYLE_DISPLAY_GRID:
case NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER:
frameType = NS_CSS_FRAME_TYPE_BLOCK;
break;
case NS_STYLE_DISPLAY_INLINE:
case NS_STYLE_DISPLAY_INLINE_BLOCK:
case NS_STYLE_DISPLAY_INLINE_TABLE:
case NS_STYLE_DISPLAY_INLINE_BOX:
case NS_STYLE_DISPLAY_INLINE_XUL_GRID:
case NS_STYLE_DISPLAY_INLINE_STACK:
case NS_STYLE_DISPLAY_INLINE_FLEX:
case NS_STYLE_DISPLAY_WEBKIT_INLINE_BOX:
case NS_STYLE_DISPLAY_INLINE_GRID:
case NS_STYLE_DISPLAY_RUBY:
case NS_STYLE_DISPLAY_RUBY_BASE:
case NS_STYLE_DISPLAY_RUBY_TEXT:
case NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER:
frameType = NS_CSS_FRAME_TYPE_INLINE;
break;
case NS_STYLE_DISPLAY_TABLE_CELL:
case NS_STYLE_DISPLAY_TABLE_ROW_GROUP:
case NS_STYLE_DISPLAY_TABLE_COLUMN:
case NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP:
case NS_STYLE_DISPLAY_TABLE_HEADER_GROUP:
case NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP:
case NS_STYLE_DISPLAY_TABLE_ROW:
frameType = NS_CSS_FRAME_TYPE_INTERNAL_TABLE;
break;
case NS_STYLE_DISPLAY_NONE:
default:
frameType = NS_CSS_FRAME_TYPE_UNKNOWN;
break;
}
}
// See if the frame is replaced
if (frame->IsFrameOfType(nsIFrame::eReplacedContainsBlock)) {
frameType = NS_FRAME_REPLACED_CONTAINS_BLOCK(frameType);
} else if (frame->IsFrameOfType(nsIFrame::eReplaced)) {
frameType = NS_FRAME_REPLACED(frameType);
}
mFrameType = frameType;
}
/* static */ void
nsHTMLReflowState::ComputeRelativeOffsets(WritingMode aWM,
nsIFrame* aFrame,
const LogicalSize& aCBSize,
nsMargin& aComputedOffsets)
{
LogicalMargin offsets(aWM);
mozilla::css::Side inlineStart = aWM.PhysicalSide(eLogicalSideIStart);
mozilla::css::Side inlineEnd = aWM.PhysicalSide(eLogicalSideIEnd);
mozilla::css::Side blockStart = aWM.PhysicalSide(eLogicalSideBStart);
mozilla::css::Side blockEnd = aWM.PhysicalSide(eLogicalSideBEnd);
const nsStylePosition* position = aFrame->StylePosition();
// Compute the 'inlineStart' and 'inlineEnd' values. 'inlineStart'
// moves the boxes to the end of the line, and 'inlineEnd' moves the
// boxes to the start of the line. The computed values are always:
// inlineStart=-inlineEnd
bool inlineStartIsAuto =
eStyleUnit_Auto == position->mOffset.GetUnit(inlineStart);
bool inlineEndIsAuto =
eStyleUnit_Auto == position->mOffset.GetUnit(inlineEnd);
// If neither 'inlineStart' nor 'inlineEnd' is auto, then we're
// over-constrained and we ignore one of them
if (!inlineStartIsAuto && !inlineEndIsAuto) {
inlineEndIsAuto = true;
}
if (inlineStartIsAuto) {
if (inlineEndIsAuto) {
// If both are 'auto' (their initial values), the computed values are 0
offsets.IStart(aWM) = offsets.IEnd(aWM) = 0;
} else {
// 'inlineEnd' isn't 'auto' so compute its value
offsets.IEnd(aWM) = nsLayoutUtils::
ComputeCBDependentValue(aCBSize.ISize(aWM),
position->mOffset.Get(inlineEnd));
// Computed value for 'inlineStart' is minus the value of 'inlineEnd'
offsets.IStart(aWM) = -offsets.IEnd(aWM);
}
} else {
NS_ASSERTION(inlineEndIsAuto, "unexpected specified constraint");
// 'InlineStart' isn't 'auto' so compute its value
offsets.IStart(aWM) = nsLayoutUtils::
ComputeCBDependentValue(aCBSize.ISize(aWM),
position->mOffset.Get(inlineStart));
// Computed value for 'inlineEnd' is minus the value of 'inlineStart'
offsets.IEnd(aWM) = -offsets.IStart(aWM);
}
// Compute the 'blockStart' and 'blockEnd' values. The 'blockStart'
// and 'blockEnd' properties move relatively positioned elements in
// the block progression direction. They also must be each other's
// negative
bool blockStartIsAuto =
eStyleUnit_Auto == position->mOffset.GetUnit(blockStart);
bool blockEndIsAuto =
eStyleUnit_Auto == position->mOffset.GetUnit(blockEnd);
// Check for percentage based values and a containing block block-size
// that depends on the content block-size. Treat them like 'auto'
if (NS_AUTOHEIGHT == aCBSize.BSize(aWM)) {
if (position->OffsetHasPercent(blockStart)) {
blockStartIsAuto = true;
}
if (position->OffsetHasPercent(blockEnd)) {
blockEndIsAuto = true;
}
}
// If neither is 'auto', 'block-end' is ignored
if (!blockStartIsAuto && !blockEndIsAuto) {
blockEndIsAuto = true;
}
if (blockStartIsAuto) {
if (blockEndIsAuto) {
// If both are 'auto' (their initial values), the computed values are 0
offsets.BStart(aWM) = offsets.BEnd(aWM) = 0;
} else {
// 'blockEnd' isn't 'auto' so compute its value
offsets.BEnd(aWM) = nsLayoutUtils::
ComputeBSizeDependentValue(aCBSize.BSize(aWM),
position->mOffset.Get(blockEnd));
// Computed value for 'blockStart' is minus the value of 'blockEnd'
offsets.BStart(aWM) = -offsets.BEnd(aWM);
}
} else {
NS_ASSERTION(blockEndIsAuto, "unexpected specified constraint");
// 'blockStart' isn't 'auto' so compute its value
offsets.BStart(aWM) = nsLayoutUtils::
ComputeBSizeDependentValue(aCBSize.BSize(aWM),
position->mOffset.Get(blockStart));
// Computed value for 'blockEnd' is minus the value of 'blockStart'
offsets.BEnd(aWM) = -offsets.BStart(aWM);
}
// Convert the offsets to physical coordinates and store them on the frame
aComputedOffsets = offsets.GetPhysicalMargin(aWM);
FrameProperties props = aFrame->Properties();
nsMargin* physicalOffsets = static_cast<nsMargin*>
(props.Get(nsIFrame::ComputedOffsetProperty()));
if (physicalOffsets) {
*physicalOffsets = aComputedOffsets;
} else {
props.Set(nsIFrame::ComputedOffsetProperty(),
new nsMargin(aComputedOffsets));
}
}
/* static */ void
nsHTMLReflowState::ApplyRelativePositioning(nsIFrame* aFrame,
const nsMargin& aComputedOffsets,
nsPoint* aPosition)
{
if (!aFrame->IsRelativelyPositioned()) {
NS_ASSERTION(!aFrame->Properties().Get(nsIFrame::NormalPositionProperty()),
"We assume that changing the 'position' property causes "
"frame reconstruction. If that ever changes, this code "
"should call "
"props.Delete(nsIFrame::NormalPositionProperty())");
return;
}
// Store the normal position
FrameProperties props = aFrame->Properties();
nsPoint* normalPosition = static_cast<nsPoint*>
(props.Get(nsIFrame::NormalPositionProperty()));
if (normalPosition) {
*normalPosition = *aPosition;
} else {
props.Set(nsIFrame::NormalPositionProperty(), new nsPoint(*aPosition));
}
const nsStyleDisplay* display = aFrame->StyleDisplay();
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
*aPosition += nsPoint(aComputedOffsets.left, aComputedOffsets.top);
} else if (NS_STYLE_POSITION_STICKY == display->mPosition &&
!aFrame->GetNextContinuation() &&
!aFrame->GetPrevContinuation() &&
!(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) {
// Sticky positioning for elements with multiple frames needs to be
// computed all at once. We can't safely do that here because we might be
// partway through (re)positioning the frames, so leave it until the scroll
// container reflows and calls StickyScrollContainer::UpdatePositions.
// For single-frame sticky positioned elements, though, go ahead and apply
// it now to avoid unnecessary overflow updates later.
StickyScrollContainer* ssc =
StickyScrollContainer::GetStickyScrollContainerForFrame(aFrame);
if (ssc) {
*aPosition = ssc->ComputePosition(aFrame);
}
}
}
nsIFrame*
nsHTMLReflowState::GetHypotheticalBoxContainer(nsIFrame* aFrame,
nscoord& aCBIStartEdge,
LogicalSize& aCBSize) const
{
aFrame = aFrame->GetContainingBlock();
NS_ASSERTION(aFrame != frame, "How did that happen?");
/* Now aFrame is the containing block we want */
/* Check whether the containing block is currently being reflowed.
If so, use the info from the reflow state. */
const nsHTMLReflowState* state;
if (aFrame->GetStateBits() & NS_FRAME_IN_REFLOW) {
for (state = parentReflowState; state && state->frame != aFrame;
state = state->parentReflowState) {
/* do nothing */
}
} else {
state = nullptr;
}
if (state) {
WritingMode wm = state->GetWritingMode();
NS_ASSERTION(wm == aFrame->GetWritingMode(), "unexpected writing mode");
aCBIStartEdge = state->ComputedLogicalBorderPadding().IStart(wm);
aCBSize = state->ComputedSize(wm);
} else {
/* Didn't find a reflow state for aFrame. Just compute the information we
want, on the assumption that aFrame already knows its size. This really
ought to be true by now. */
NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_IN_REFLOW),
"aFrame shouldn't be in reflow; we'll lie if it is");
WritingMode wm = aFrame->GetWritingMode();
LogicalMargin borderPadding = aFrame->GetLogicalUsedBorderAndPadding(wm);
aCBIStartEdge = borderPadding.IStart(wm);
aCBSize = aFrame->GetLogicalSize(wm) - borderPadding.Size(wm);
}
return aFrame;
}
struct nsHypotheticalPosition {
// offset from inline-start edge of containing block (which is a padding edge)
nscoord mIStart;
// offset from block-start edge of containing block (which is a padding edge)
nscoord mBStart;
WritingMode mWritingMode;
};
static bool
GetIntrinsicSizeFor(nsIFrame* aFrame, nsSize& aIntrinsicSize, nsIAtom* aFrameType)
{
// See if it is an image frame
bool success = false;
// Currently the only type of replaced frame that we can get the intrinsic
// size for is an image frame
// XXX We should add back the GetReflowMetrics() function and one of the
// things should be the intrinsic size...
if (aFrameType == nsGkAtoms::imageFrame) {
nsImageFrame* imageFrame = (nsImageFrame*)aFrame;
if (NS_SUCCEEDED(imageFrame->GetIntrinsicImageSize(aIntrinsicSize))) {
success = (aIntrinsicSize != nsSize(0, 0));
}
}
return success;
}
/**
* aInsideBoxSizing returns the part of the padding, border, and margin
* in the aAxis dimension that goes inside the edge given by box-sizing;
* aOutsideBoxSizing returns the rest.
*/
void
nsHTMLReflowState::CalculateBorderPaddingMargin(
LogicalAxis aAxis,
nscoord aContainingBlockSize,
nscoord* aInsideBoxSizing,
nscoord* aOutsideBoxSizing) const
{
WritingMode wm = GetWritingMode();
mozilla::css::Side startSide =
wm.PhysicalSide(MakeLogicalSide(aAxis, eLogicalEdgeStart));
mozilla::css::Side endSide =
wm.PhysicalSide(MakeLogicalSide(aAxis, eLogicalEdgeEnd));
nsMargin styleBorder = mStyleBorder->GetComputedBorder();
nscoord borderStartEnd =
styleBorder.Side(startSide) + styleBorder.Side(endSide);
nscoord paddingStartEnd, marginStartEnd;
// See if the style system can provide us the padding directly
nsMargin stylePadding;
if (mStylePadding->GetPadding(stylePadding)) {
paddingStartEnd =
stylePadding.Side(startSide) + stylePadding.Side(endSide);
} else {
// We have to compute the start and end values
nscoord start, end;
start = nsLayoutUtils::
ComputeCBDependentValue(aContainingBlockSize,
mStylePadding->mPadding.Get(startSide));
end = nsLayoutUtils::
ComputeCBDependentValue(aContainingBlockSize,
mStylePadding->mPadding.Get(endSide));
paddingStartEnd = start + end;
}
// See if the style system can provide us the margin directly
nsMargin styleMargin;
if (mStyleMargin->GetMargin(styleMargin)) {
marginStartEnd =
styleMargin.Side(startSide) + styleMargin.Side(endSide);
} else {
nscoord start, end;
// We have to compute the start and end values
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetUnit(startSide)) {
// XXX FIXME (or does CalculateBlockSideMargins do this?)
start = 0; // just ignore
} else {
start = nsLayoutUtils::
ComputeCBDependentValue(aContainingBlockSize,
mStyleMargin->mMargin.Get(startSide));
}
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetUnit(endSide)) {
// XXX FIXME (or does CalculateBlockSideMargins do this?)
end = 0; // just ignore
} else {
end = nsLayoutUtils::
ComputeCBDependentValue(aContainingBlockSize,
mStyleMargin->mMargin.Get(endSide));
}
marginStartEnd = start + end;
}
nscoord outside = paddingStartEnd + borderStartEnd + marginStartEnd;
nscoord inside = 0;
switch (mStylePosition->mBoxSizing) {
case StyleBoxSizing::Border:
inside += borderStartEnd;
MOZ_FALLTHROUGH;
case StyleBoxSizing::Padding:
inside += paddingStartEnd;
MOZ_FALLTHROUGH;
case StyleBoxSizing::Content:
// nothing
break;
}
outside -= inside;
*aInsideBoxSizing = inside;
*aOutsideBoxSizing = outside;
return;
}
/**
* Returns true iff a pre-order traversal of the normal child
* frames rooted at aFrame finds no non-empty frame before aDescendant.
*/
static bool AreAllEarlierInFlowFramesEmpty(nsIFrame* aFrame,
nsIFrame* aDescendant, bool* aFound) {
if (aFrame == aDescendant) {
*aFound = true;
return true;
}
if (!aFrame->IsSelfEmpty()) {
*aFound = false;
return false;
}
for (nsIFrame* f : aFrame->PrincipalChildList()) {
bool allEmpty = AreAllEarlierInFlowFramesEmpty(f, aDescendant, aFound);
if (*aFound || !allEmpty) {
return allEmpty;
}
}
*aFound = false;
return true;
}
// Calculate the position of the hypothetical box that the element would have
// if it were in the flow.
// The values returned are relative to the padding edge of the absolute
// containing block. The writing-mode of the hypothetical box position will
// have the same block direction as the absolute containing block, but may
// differ in inline-bidi direction.
// In the code below, |cbrs->frame| is the absolute containing block, while
// |containingBlock| is the nearest block container of the placeholder frame,
// which may be different from the absolute containing block.
void
nsHTMLReflowState::CalculateHypotheticalPosition
(nsPresContext* aPresContext,
nsIFrame* aPlaceholderFrame,
const nsHTMLReflowState* cbrs,
nsHypotheticalPosition& aHypotheticalPos,
nsIAtom* aFrameType) const
{
NS_ASSERTION(mStyleDisplay->mOriginalDisplay != NS_STYLE_DISPLAY_NONE,
"mOriginalDisplay has not been properly initialized");
// Find the nearest containing block frame to the placeholder frame,
// and its inline-start edge and width.
nscoord blockIStartContentEdge;
// Dummy writing mode for blockContentSize, will be changed as needed by
// GetHypotheticalBoxContainer.
WritingMode cbwm = cbrs->GetWritingMode();
LogicalSize blockContentSize(cbwm);
nsIFrame* containingBlock =
GetHypotheticalBoxContainer(aPlaceholderFrame, blockIStartContentEdge,
blockContentSize);
// Now blockContentSize is in containingBlock's writing mode.
// If it's a replaced element and it has a 'auto' value for
//'inline size', see if we can get the intrinsic size. This will allow
// us to exactly determine both the inline edges
WritingMode wm = containingBlock->GetWritingMode();
nsStyleCoord styleISize = mStylePosition->ISize(wm);
bool isAutoISize = styleISize.GetUnit() == eStyleUnit_Auto;
nsSize intrinsicSize;
bool knowIntrinsicSize = false;
if (NS_FRAME_IS_REPLACED(mFrameType) && isAutoISize) {
// See if we can get the intrinsic size of the element
knowIntrinsicSize = GetIntrinsicSizeFor(frame, intrinsicSize, aFrameType);
}
// See if we can calculate what the box inline size would have been if
// the element had been in the flow
nscoord boxISize;
bool knowBoxISize = false;
if ((NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mOriginalDisplay) &&
!NS_FRAME_IS_REPLACED(mFrameType)) {
// For non-replaced inline-level elements the 'inline size' property
// doesn't apply, so we don't know what the inline size would have
// been without reflowing it
} else {
// It's either a replaced inline-level element or a block-level element
// Determine the total amount of inline direction
// border/padding/margin that the element would have had if it had
// been in the flow. Note that we ignore any 'auto' and 'inherit'
// values
nscoord insideBoxSizing, outsideBoxSizing;
CalculateBorderPaddingMargin(eLogicalAxisInline,
blockContentSize.ISize(wm),
&insideBoxSizing, &outsideBoxSizing);
if (NS_FRAME_IS_REPLACED(mFrameType) && isAutoISize) {
// It's a replaced element with an 'auto' inline size so the box
// inline size is its intrinsic size plus any border/padding/margin
if (knowIntrinsicSize) {
boxISize = LogicalSize(wm, intrinsicSize).ISize(wm) +
outsideBoxSizing + insideBoxSizing;
knowBoxISize = true;
}
} else if (isAutoISize) {
// The box inline size is the containing block inline size
boxISize = blockContentSize.ISize(wm);
knowBoxISize = true;
} else {
// We need to compute it. It's important we do this, because if it's
// percentage based this computed value may be different from the computed
// value calculated using the absolute containing block width
boxISize = ComputeISizeValue(blockContentSize.ISize(wm),
insideBoxSizing, outsideBoxSizing,
styleISize) +
insideBoxSizing + outsideBoxSizing;
knowBoxISize = true;
}
}
// Get the placeholder x-offset and y-offset in the coordinate
// space of its containing block
// XXXbz the placeholder is not fully reflowed yet if our containing block is
// relatively positioned...
nsSize containerSize = containingBlock->GetStateBits() & NS_FRAME_IN_REFLOW
? cbrs->ComputedSizeAsContainerIfConstrained()
: containingBlock->GetSize();
LogicalPoint
placeholderOffset(wm, aPlaceholderFrame->GetOffsetTo(containingBlock),
containerSize);
// First, determine the hypothetical box's mBStart. We want to check the
// content insertion frame of containingBlock for block-ness, but make
// sure to compute all coordinates in the coordinate system of
// containingBlock.
nsBlockFrame* blockFrame =
nsLayoutUtils::GetAsBlock(containingBlock->GetContentInsertionFrame());
if (blockFrame) {
// Use a null containerSize to convert a LogicalPoint functioning as a
// vector into a physical nsPoint vector.
const nsSize nullContainerSize;
LogicalPoint blockOffset(wm, blockFrame->GetOffsetTo(containingBlock),
nullContainerSize);
bool isValid;
nsBlockInFlowLineIterator iter(blockFrame, aPlaceholderFrame, &isValid);
if (!isValid) {
// Give up. We're probably dealing with somebody using
// position:absolute inside native-anonymous content anyway.
aHypotheticalPos.mBStart = placeholderOffset.B(wm);
} else {
NS_ASSERTION(iter.GetContainer() == blockFrame,
"Found placeholder in wrong block!");
nsBlockFrame::line_iterator lineBox = iter.GetLine();
// How we determine the hypothetical box depends on whether the element
// would have been inline-level or block-level
LogicalRect lineBounds =
lineBox->GetBounds().ConvertTo(wm, lineBox->mWritingMode,
lineBox->mContainerSize);
if (mStyleDisplay->IsOriginalDisplayInlineOutsideStyle()) {
// Use the block-start of the inline box which the placeholder lives in
// as the hypothetical box's block-start.
aHypotheticalPos.mBStart = lineBounds.BStart(wm) + blockOffset.B(wm);
} else {
// The element would have been block-level which means it would
// be below the line containing the placeholder frame, unless
// all the frames before it are empty. In that case, it would
// have been just before this line.
// XXXbz the line box is not fully reflowed yet if our
// containing block is relatively positioned...
if (lineBox != iter.End()) {
nsIFrame * firstFrame = lineBox->mFirstChild;
bool found = false;
bool allEmpty = true;
while (firstFrame) { // See bug 223064
allEmpty = AreAllEarlierInFlowFramesEmpty(firstFrame,
aPlaceholderFrame, &found);
if (found || !allEmpty)
break;
firstFrame = firstFrame->GetNextSibling();
}
NS_ASSERTION(firstFrame, "Couldn't find placeholder!");
if (allEmpty) {
// The top of the hypothetical box is the top of the line
// containing the placeholder, since there is nothing in the
// line before our placeholder except empty frames.
aHypotheticalPos.mBStart =
lineBounds.BStart(wm) + blockOffset.B(wm);
} else {
// The top of the hypothetical box is just below the line
// containing the placeholder.
aHypotheticalPos.mBStart =
lineBounds.BEnd(wm) + blockOffset.B(wm);
}
} else {
// Just use the placeholder's block-offset wrt the containing block
aHypotheticalPos.mBStart = placeholderOffset.B(wm);
}
}
}
} else {
// The containing block is not a block, so it's probably something
// like a XUL box, etc.
// Just use the placeholder's block-offset
aHypotheticalPos.mBStart = placeholderOffset.B(wm);
}
// Second, determine the hypothetical box's mIStart.
// How we determine the hypothetical box depends on whether the element
// would have been inline-level or block-level
if (mStyleDisplay->IsOriginalDisplayInlineOutsideStyle()) {
// The placeholder represents the left edge of the hypothetical box
aHypotheticalPos.mIStart = placeholderOffset.I(wm);
} else {
aHypotheticalPos.mIStart = blockIStartContentEdge;
}
// The current coordinate space is that of the nearest block to the placeholder.
// Convert to the coordinate space of the absolute containing block
// One weird thing here is that for fixed-positioned elements we want to do
// the conversion incorrectly; specifically we want to ignore any scrolling
// that may have happened;
nsPoint cbOffset;
if (mStyleDisplay->mPosition == NS_STYLE_POSITION_FIXED &&
// Exclude cases inside -moz-transform where fixed is like absolute.
nsLayoutUtils::IsReallyFixedPos(frame)) {
// In this case, cbrs->frame will likely be an ancestor of
// containingBlock, so can just walk our way up the frame tree.
// Make sure to not add positions of frames whose parent is a
// scrollFrame, since we're doing fixed positioning, which assumes
// everything is scrolled to (0,0).
cbOffset.MoveTo(0, 0);
do {
cbOffset += containingBlock->GetPositionIgnoringScrolling();
nsContainerFrame* parent = containingBlock->GetParent();
if (!parent) {
// Oops, our absolute containing block isn't an ancestor of the
// placeholder's containing block. This can happen if the placeholder
// is pushed to a different page in a printing context. 'cbOffset' is
// currently relative to the root frame (containingBlock) - so just
// subtract the offset to the absolute containing block to make it
// relative to that.
cbOffset -= containingBlock->GetOffsetTo(cbrs->frame);
break;
}
containingBlock = parent;
} while (containingBlock != cbrs->frame);
} else {
// XXXldb We need to either ignore scrolling for the absolute
// positioning case too (and take the incompatibility) or figure out
// how to make these positioned elements actually *move* when we
// scroll, and thus avoid the resulting incremental reflow bugs.
cbOffset = containingBlock->GetOffsetTo(cbrs->frame);
}
nsSize cbrsSize = cbrs->ComputedSizeAsContainerIfConstrained();
LogicalPoint logCBOffs(wm, cbOffset, cbrsSize - containerSize);
aHypotheticalPos.mIStart += logCBOffs.I(wm);
aHypotheticalPos.mBStart += logCBOffs.B(wm);
// The specified offsets are relative to the absolute containing block's
// padding edge and our current values are relative to the border edge, so
// translate.
LogicalMargin border =
cbrs->ComputedLogicalBorderPadding() - cbrs->ComputedLogicalPadding();
border = border.ConvertTo(wm, cbrs->GetWritingMode());
aHypotheticalPos.mIStart -= border.IStart(wm);
aHypotheticalPos.mBStart -= border.BStart(wm);
// At this point, we have computed aHypotheticalPos using the writing mode
// of the placeholder's containing block.
if (cbwm.GetBlockDir() != wm.GetBlockDir()) {
// If the block direction we used in calculating aHypotheticalPos does not
// match the absolute containing block's, we need to convert here so that
// aHypotheticalPos is usable in relation to the absolute containing block.
// This requires computing or measuring the abspos frame's block-size,
// which is not otherwise required/used here (as aHypotheticalPos
// records only the block-start coordinate).
// This is similar to the inline-size calculation for a replaced
// inline-level element or a block-level element (above), except that
// 'auto' sizing is handled differently in the block direction for non-
// replaced elements and replaced elements lacking an intrinsic size.
// Determine the total amount of block direction
// border/padding/margin that the element would have had if it had
// been in the flow. Note that we ignore any 'auto' and 'inherit'
// values.
nscoord insideBoxSizing, outsideBoxSizing;
CalculateBorderPaddingMargin(eLogicalAxisBlock,
blockContentSize.BSize(wm),
&insideBoxSizing, &outsideBoxSizing);
nscoord boxBSize;
nsStyleCoord styleBSize = mStylePosition->BSize(wm);
bool isAutoBSize = styleBSize.GetUnit() == eStyleUnit_Auto;
if (isAutoBSize) {
if (NS_FRAME_IS_REPLACED(mFrameType) && knowIntrinsicSize) {
// It's a replaced element with an 'auto' block size so the box
// block size is its intrinsic size plus any border/padding/margin
boxBSize = LogicalSize(wm, intrinsicSize).BSize(wm) +
outsideBoxSizing + insideBoxSizing;
} else {
// XXX Bug 1191801
// Figure out how to get the correct boxBSize here (need to reflow the
// positioned frame?)
boxBSize = 0;
}
} else {
// We need to compute it. It's important we do this, because if it's
// percentage-based this computed value may be different from the
// computed value calculated using the absolute containing block height.
boxBSize = nsLayoutUtils::ComputeBSizeValue(blockContentSize.BSize(wm),
insideBoxSizing, styleBSize) +
insideBoxSizing + outsideBoxSizing;
}
LogicalSize boxSize(wm, knowBoxISize ? boxISize : 0, boxBSize);
LogicalPoint origin(wm, aHypotheticalPos.mIStart,
aHypotheticalPos.mBStart);
origin = origin.ConvertTo(cbwm, wm, cbrsSize -
boxSize.GetPhysicalSize(wm));
aHypotheticalPos.mIStart = origin.I(cbwm);
aHypotheticalPos.mBStart = origin.B(cbwm);
aHypotheticalPos.mWritingMode = cbwm;
} else {
aHypotheticalPos.mWritingMode = wm;
}
}
void
nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
const nsHTMLReflowState* cbrs,
const LogicalSize& aCBSize,
nsIAtom* aFrameType)
{
WritingMode wm = GetWritingMode();
WritingMode cbwm = cbrs->GetWritingMode();
NS_PRECONDITION(aCBSize.BSize(cbwm) != NS_AUTOHEIGHT,
"containing block bsize must be constrained");
NS_ASSERTION(aFrameType != nsGkAtoms::tableFrame,
"InitAbsoluteConstraints should not be called on table frames");
NS_ASSERTION(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
"Why are we here?");
const auto& styleOffset = mStylePosition->mOffset;
bool iStartIsAuto = styleOffset.GetIStartUnit(cbwm) == eStyleUnit_Auto;
bool iEndIsAuto = styleOffset.GetIEndUnit(cbwm) == eStyleUnit_Auto;
bool bStartIsAuto = styleOffset.GetBStartUnit(cbwm) == eStyleUnit_Auto;
bool bEndIsAuto = styleOffset.GetBEndUnit(cbwm) == eStyleUnit_Auto;
// If both 'left' and 'right' are 'auto' or both 'top' and 'bottom' are
// 'auto', then compute the hypothetical box position where the element would
// have been if it had been in the flow
nsHypotheticalPosition hypotheticalPos;
if ((iStartIsAuto && iEndIsAuto) || (bStartIsAuto && bEndIsAuto)) {
if (mFlags.mStaticPosIsCBOrigin) {
hypotheticalPos.mWritingMode = cbwm;
hypotheticalPos.mIStart = nscoord(0);
hypotheticalPos.mBStart = nscoord(0);
} else {
nsIFrame* placeholderFrame =
aPresContext->PresShell()->GetPlaceholderFrameFor(frame);
NS_ASSERTION(placeholderFrame, "no placeholder frame");
CalculateHypotheticalPosition(aPresContext, placeholderFrame, cbrs,
hypotheticalPos, aFrameType);
}
}
// Initialize the 'left' and 'right' computed offsets
// XXX Handle new 'static-position' value...
// Size of the containing block in its writing mode
LogicalSize cbSize = aCBSize;
LogicalMargin offsets = ComputedLogicalOffsets().ConvertTo(cbwm, wm);
if (iStartIsAuto) {
offsets.IStart(cbwm) = 0;
} else {
offsets.IStart(cbwm) = nsLayoutUtils::
ComputeCBDependentValue(cbSize.ISize(cbwm), styleOffset.GetIStart(cbwm));
}
if (iEndIsAuto) {
offsets.IEnd(cbwm) = 0;
} else {
offsets.IEnd(cbwm) = nsLayoutUtils::
ComputeCBDependentValue(cbSize.ISize(cbwm), styleOffset.GetIEnd(cbwm));
}
if (iStartIsAuto && iEndIsAuto) {
if (cbwm.IsBidiLTR() != hypotheticalPos.mWritingMode.IsBidiLTR()) {
offsets.IEnd(cbwm) = hypotheticalPos.mIStart;
iEndIsAuto = false;
} else {
offsets.IStart(cbwm) = hypotheticalPos.mIStart;
iStartIsAuto = false;
}
}
if (bStartIsAuto) {
offsets.BStart(cbwm) = 0;
} else {
offsets.BStart(cbwm) = nsLayoutUtils::
ComputeBSizeDependentValue(cbSize.BSize(cbwm),
styleOffset.GetBStart(cbwm));
}
if (bEndIsAuto) {
offsets.BEnd(cbwm) = 0;
} else {
offsets.BEnd(cbwm) = nsLayoutUtils::
ComputeBSizeDependentValue(cbSize.BSize(cbwm),
styleOffset.GetBEnd(cbwm));
}
if (bStartIsAuto && bEndIsAuto) {
// Treat 'top' like 'static-position'
offsets.BStart(cbwm) = hypotheticalPos.mBStart;
bStartIsAuto = false;
}
SetComputedLogicalOffsets(offsets.ConvertTo(wm, cbwm));
typedef nsIFrame::ComputeSizeFlags ComputeSizeFlags;
ComputeSizeFlags computeSizeFlags = ComputeSizeFlags::eDefault;
if (mFlags.mShrinkWrap) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
if (wm.IsOrthogonalTo(cbwm)) {
if (bStartIsAuto || bEndIsAuto) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
} else {
if (iStartIsAuto || iEndIsAuto) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
}
LogicalSize computedSize(wm);
{
AutoMaybeDisableFontInflation an(frame);
computedSize =
frame->ComputeSize(rendContext, wm, cbSize.ConvertTo(wm, cbwm),
cbSize.ConvertTo(wm, cbwm).ISize(wm), // XXX or AvailableISize()?
ComputedLogicalMargin().Size(wm) +
ComputedLogicalOffsets().Size(wm),
ComputedLogicalBorderPadding().Size(wm) -
ComputedLogicalPadding().Size(wm),
ComputedLogicalPadding().Size(wm),
computeSizeFlags);
ComputedISize() = computedSize.ISize(wm);
ComputedBSize() = computedSize.BSize(wm);
NS_ASSERTION(ComputedISize() >= 0, "Bogus inline-size");
NS_ASSERTION(ComputedBSize() == NS_UNCONSTRAINEDSIZE ||
ComputedBSize() >= 0, "Bogus block-size");
}
computedSize = computedSize.ConvertTo(cbwm, wm);
// XXX Now that we have ComputeSize, can we condense many of the
// branches off of widthIsAuto?
LogicalMargin margin = ComputedLogicalMargin().ConvertTo(cbwm, wm);
const LogicalMargin borderPadding =
ComputedLogicalBorderPadding().ConvertTo(cbwm, wm);
bool iSizeIsAuto = eStyleUnit_Auto == mStylePosition->ISize(cbwm).GetUnit();
if (iStartIsAuto) {
// We know 'right' is not 'auto' anymore thanks to the hypothetical
// box code above.
// Solve for 'left'.
if (iSizeIsAuto) {
// XXXldb This, and the corresponding code in
// nsAbsoluteContainingBlock.cpp, could probably go away now that
// we always compute widths.
offsets.IStart(cbwm) = NS_AUTOOFFSET;
} else {
offsets.IStart(cbwm) =
cbSize.ISize(cbwm) - offsets.IEnd(cbwm) -
computedSize.ISize(cbwm) - margin.IStartEnd(cbwm) -
borderPadding.IStartEnd(cbwm);
}
} else if (iEndIsAuto) {
// We know 'left' is not 'auto' anymore thanks to the hypothetical
// box code above.
// Solve for 'right'.
if (iSizeIsAuto) {
// XXXldb This, and the corresponding code in
// nsAbsoluteContainingBlock.cpp, could probably go away now that
// we always compute widths.
offsets.IEnd(cbwm) = NS_AUTOOFFSET;
} else {
offsets.IEnd(cbwm) =
cbSize.ISize(cbwm) - offsets.IStart(cbwm) -
computedSize.ISize(cbwm) - margin.IStartEnd(cbwm) -
borderPadding.IStartEnd(cbwm);
}
} else {
// Neither 'inline-start' nor 'inline-end' is 'auto'.
if (wm.IsOrthogonalTo(cbwm)) {
// For orthogonal blocks, we need to handle the case where the block had
// unconstrained block-size, which mapped to unconstrained inline-size
// in the containing block's writing mode.
nscoord autoISize = cbSize.ISize(cbwm) - margin.IStartEnd(cbwm) -
borderPadding.IStartEnd(cbwm) - offsets.IStartEnd(cbwm);
if (autoISize < 0) {
autoISize = 0;
}
if (computedSize.ISize(cbwm) == NS_UNCONSTRAINEDSIZE) {
// For non-replaced elements with block-size auto, the block-size
// fills the remaining space.
computedSize.ISize(cbwm) = autoISize;
// XXX Do these need box-sizing adjustments?
LogicalSize maxSize = ComputedMaxSize(cbwm);
LogicalSize minSize = ComputedMinSize(cbwm);
if (computedSize.ISize(cbwm) > maxSize.ISize(cbwm)) {
computedSize.ISize(cbwm) = maxSize.ISize(cbwm);
}
if (computedSize.ISize(cbwm) < minSize.ISize(cbwm)) {
computedSize.ISize(cbwm) = minSize.ISize(cbwm);
}
}
}
// However, the inline-size might
// still not fill all the available space (even though we didn't
// shrink-wrap) in case:
// * inline-size was specified
// * we're dealing with a replaced element
// * width was constrained by min- or max-inline-size.
nscoord availMarginSpace =
aCBSize.ISize(cbwm) - offsets.IStartEnd(cbwm) - margin.IStartEnd(cbwm) -
borderPadding.IStartEnd(cbwm) - computedSize.ISize(cbwm);
bool marginIStartIsAuto =
eStyleUnit_Auto == mStyleMargin->mMargin.GetIStartUnit(cbwm);
bool marginIEndIsAuto =
eStyleUnit_Auto == mStyleMargin->mMargin.GetIEndUnit(cbwm);
if (marginIStartIsAuto) {
if (marginIEndIsAuto) {
if (availMarginSpace < 0) {
// Note that this case is different from the neither-'auto'
// case below, where the spec says to ignore 'left'/'right'.
// Ignore the specified value for 'margin-right'.
margin.IEnd(cbwm) = availMarginSpace;
} else {
// Both 'margin-left' and 'margin-right' are 'auto', so they get
// equal values
margin.IStart(cbwm) = availMarginSpace / 2;
margin.IEnd(cbwm) = availMarginSpace - margin.IStart(cbwm);
}
} else {
// Just 'margin-left' is 'auto'
margin.IStart(cbwm) = availMarginSpace;
}
} else {
if (marginIEndIsAuto) {
// Just 'margin-right' is 'auto'
margin.IEnd(cbwm) = availMarginSpace;
} else {
// We're over-constrained so use the direction of the containing
// block to dictate which value to ignore. (And note that the
// spec says to ignore 'left' or 'right' rather than
// 'margin-left' or 'margin-right'.)
// Note that this case is different from the both-'auto' case
// above, where the spec says to ignore
// 'margin-left'/'margin-right'.
// Ignore the specified value for 'right'.
offsets.IEnd(cbwm) += availMarginSpace;
}
}
}
bool bSizeIsAuto = eStyleUnit_Auto == mStylePosition->BSize(cbwm).GetUnit();
if (bStartIsAuto) {
// solve for block-start
if (bSizeIsAuto) {
offsets.BStart(cbwm) = NS_AUTOOFFSET;
} else {
offsets.BStart(cbwm) = cbSize.BSize(cbwm) - margin.BStartEnd(cbwm) -
borderPadding.BStartEnd(cbwm) - computedSize.BSize(cbwm) -
offsets.BEnd(cbwm);
}
} else if (bEndIsAuto) {
// solve for block-end
if (bSizeIsAuto) {
offsets.BEnd(cbwm) = NS_AUTOOFFSET;
} else {
offsets.BEnd(cbwm) = cbSize.BSize(cbwm) - margin.BStartEnd(cbwm) -
borderPadding.BStartEnd(cbwm) - computedSize.BSize(cbwm) -
offsets.BStart(cbwm);
}
} else {
// Neither block-start nor -end is 'auto'.
nscoord autoBSize = cbSize.BSize(cbwm) - margin.BStartEnd(cbwm) -
borderPadding.BStartEnd(cbwm) - offsets.BStartEnd(cbwm);
if (autoBSize < 0) {
autoBSize = 0;
}
if (computedSize.BSize(cbwm) == NS_UNCONSTRAINEDSIZE) {
// For non-replaced elements with block-size auto, the block-size
// fills the remaining space.
computedSize.BSize(cbwm) = autoBSize;
// XXX Do these need box-sizing adjustments?
LogicalSize maxSize = ComputedMaxSize(cbwm);
LogicalSize minSize = ComputedMinSize(cbwm);
if (computedSize.BSize(cbwm) > maxSize.BSize(cbwm)) {
computedSize.BSize(cbwm) = maxSize.BSize(cbwm);
}
if (computedSize.BSize(cbwm) < minSize.BSize(cbwm)) {
computedSize.BSize(cbwm) = minSize.BSize(cbwm);
}
}
// The block-size might still not fill all the available space in case:
// * bsize was specified
// * we're dealing with a replaced element
// * bsize was constrained by min- or max-bsize.
nscoord availMarginSpace = autoBSize - computedSize.BSize(cbwm);
bool marginBStartIsAuto =
eStyleUnit_Auto == mStyleMargin->mMargin.GetBStartUnit(cbwm);
bool marginBEndIsAuto =
eStyleUnit_Auto == mStyleMargin->mMargin.GetBEndUnit(cbwm);
if (marginBStartIsAuto) {
if (marginBEndIsAuto) {
// Both 'margin-top' and 'margin-bottom' are 'auto', so they get
// equal values
margin.BStart(cbwm) = availMarginSpace / 2;
margin.BEnd(cbwm) = availMarginSpace - margin.BStart(cbwm);
} else {
// Just margin-block-start is 'auto'
margin.BStart(cbwm) = availMarginSpace;
}
} else {
if (marginBEndIsAuto) {
// Just margin-block-end is 'auto'
margin.BEnd(cbwm) = availMarginSpace;
} else {
// We're over-constrained so ignore the specified value for
// block-end. (And note that the spec says to ignore 'bottom'
// rather than 'margin-bottom'.)
offsets.BEnd(cbwm) += availMarginSpace;
}
}
}
ComputedBSize() = computedSize.ConvertTo(wm, cbwm).BSize(wm);
ComputedISize() = computedSize.ConvertTo(wm, cbwm).ISize(wm);
SetComputedLogicalOffsets(offsets.ConvertTo(wm, cbwm));
SetComputedLogicalMargin(margin.ConvertTo(wm, cbwm));
}
// This will not be converted to abstract coordinates because it's only
// used in CalcQuirkContainingBlockHeight
nscoord
GetBlockMarginBorderPadding(const nsHTMLReflowState* aReflowState)
{
nscoord result = 0;
if (!aReflowState) return result;
// zero auto margins
nsMargin margin = aReflowState->ComputedPhysicalMargin();
if (NS_AUTOMARGIN == margin.top)
margin.top = 0;
if (NS_AUTOMARGIN == margin.bottom)
margin.bottom = 0;
result += margin.top + margin.bottom;
result += aReflowState->ComputedPhysicalBorderPadding().top +
aReflowState->ComputedPhysicalBorderPadding().bottom;
return result;
}
/* Get the height based on the viewport of the containing block specified
* in aReflowState when the containing block has mComputedHeight == NS_AUTOHEIGHT
* This will walk up the chain of containing blocks looking for a computed height
* until it finds the canvas frame, or it encounters a frame that is not a block,
* area, or scroll frame. This handles compatibility with IE (see bug 85016 and bug 219693)
*
* When we encounter scrolledContent block frames, we skip over them,
* since they are guaranteed to not be useful for computing the containing block.
*
* See also IsQuirkContainingBlockHeight.
*/
static nscoord
CalcQuirkContainingBlockHeight(const nsHTMLReflowState* aCBReflowState)
{
const nsHTMLReflowState* firstAncestorRS = nullptr; // a candidate for html frame
const nsHTMLReflowState* secondAncestorRS = nullptr; // a candidate for body frame
// initialize the default to NS_AUTOHEIGHT as this is the containings block
// computed height when this function is called. It is possible that we
// don't alter this height especially if we are restricted to one level
nscoord result = NS_AUTOHEIGHT;
const nsHTMLReflowState* rs = aCBReflowState;
for (; rs; rs = rs->parentReflowState) {
nsIAtom* frameType = rs->frame->GetType();
// if the ancestor is auto height then skip it and continue up if it
// is the first block frame and possibly the body/html
if (nsGkAtoms::blockFrame == frameType ||
#ifdef MOZ_XUL
nsGkAtoms::XULLabelFrame == frameType ||
#endif
nsGkAtoms::scrollFrame == frameType) {
secondAncestorRS = firstAncestorRS;
firstAncestorRS = rs;
// If the current frame we're looking at is positioned, we don't want to
// go any further (see bug 221784). The behavior we want here is: 1) If
// not auto-height, use this as the percentage base. 2) If auto-height,
// keep looking, unless the frame is positioned.
if (NS_AUTOHEIGHT == rs->ComputedHeight()) {
if (rs->frame->IsAbsolutelyPositioned()) {
break;
} else {
continue;
}
}
}
else if (nsGkAtoms::canvasFrame == frameType) {
// Always continue on to the height calculation
}
else if (nsGkAtoms::pageContentFrame == frameType) {
nsIFrame* prevInFlow = rs->frame->GetPrevInFlow();
// only use the page content frame for a height basis if it is the first in flow
if (prevInFlow)
break;
}
else {
break;
}
// if the ancestor is the page content frame then the percent base is
// the avail height, otherwise it is the computed height
result = (nsGkAtoms::pageContentFrame == frameType)
? rs->AvailableHeight() : rs->ComputedHeight();
// if unconstrained - don't sutract borders - would result in huge height
if (NS_AUTOHEIGHT == result) return result;
// if we got to the canvas or page content frame, then subtract out
// margin/border/padding for the BODY and HTML elements
if ((nsGkAtoms::canvasFrame == frameType) ||
(nsGkAtoms::pageContentFrame == frameType)) {
result -= GetBlockMarginBorderPadding(firstAncestorRS);
result -= GetBlockMarginBorderPadding(secondAncestorRS);
#ifdef DEBUG
// make sure the first ancestor is the HTML and the second is the BODY
if (firstAncestorRS) {
nsIContent* frameContent = firstAncestorRS->frame->GetContent();
if (frameContent) {
NS_ASSERTION(frameContent->IsHTMLElement(nsGkAtoms::html),
"First ancestor is not HTML");
}
}
if (secondAncestorRS) {
nsIContent* frameContent = secondAncestorRS->frame->GetContent();
if (frameContent) {
NS_ASSERTION(frameContent->IsHTMLElement(nsGkAtoms::body),
"Second ancestor is not BODY");
}
}
#endif
}
// if we got to the html frame (a block child of the canvas) ...
else if (nsGkAtoms::blockFrame == frameType &&
rs->parentReflowState &&
nsGkAtoms::canvasFrame ==
rs->parentReflowState->frame->GetType()) {
// ... then subtract out margin/border/padding for the BODY element
result -= GetBlockMarginBorderPadding(secondAncestorRS);
}
break;
}
// Make sure not to return a negative height here!
return std::max(result, 0);
}
// Called by InitConstraints() to compute the containing block rectangle for
// the element. Handles the special logic for absolutely positioned elements
LogicalSize
nsHTMLReflowState::ComputeContainingBlockRectangle(
nsPresContext* aPresContext,
const nsHTMLReflowState* aContainingBlockRS)
{
// Unless the element is absolutely positioned, the containing block is
// formed by the content edge of the nearest block-level ancestor
LogicalSize cbSize = aContainingBlockRS->ComputedSize();
WritingMode wm = aContainingBlockRS->GetWritingMode();
// mFrameType for abs-pos tables is NS_CSS_FRAME_TYPE_BLOCK, so we need to
// special case them here.
if (NS_FRAME_GET_TYPE(mFrameType) == NS_CSS_FRAME_TYPE_ABSOLUTE ||
(frame->GetType() == nsGkAtoms::tableFrame &&
frame->IsAbsolutelyPositioned() &&
(frame->GetParent()->GetStateBits() & NS_FRAME_OUT_OF_FLOW))) {
// See if the ancestor is block-level or inline-level
if (NS_FRAME_GET_TYPE(aContainingBlockRS->mFrameType) == NS_CSS_FRAME_TYPE_INLINE) {
// Base our size on the actual size of the frame. In cases when this is
// completely bogus (eg initial reflow), this code shouldn't even be
// called, since the code in nsInlineFrame::Reflow will pass in
// the containing block dimensions to our constructor.
// XXXbz we should be taking the in-flows into account too, but
// that's very hard.
LogicalMargin computedBorder =
aContainingBlockRS->ComputedLogicalBorderPadding() -
aContainingBlockRS->ComputedLogicalPadding();
cbSize.ISize(wm) = aContainingBlockRS->frame->ISize(wm) -
computedBorder.IStartEnd(wm);
NS_ASSERTION(cbSize.ISize(wm) >= 0,
"Negative containing block isize!");
cbSize.BSize(wm) = aContainingBlockRS->frame->BSize(wm) -
computedBorder.BStartEnd(wm);
NS_ASSERTION(cbSize.BSize(wm) >= 0,
"Negative containing block bsize!");
} else {
// If the ancestor is block-level, the containing block is formed by the
// padding edge of the ancestor
cbSize.ISize(wm) +=
aContainingBlockRS->ComputedLogicalPadding().IStartEnd(wm);
cbSize.BSize(wm) +=
aContainingBlockRS->ComputedLogicalPadding().BStartEnd(wm);
}
} else {
// an element in quirks mode gets a containing block based on looking for a
// parent with a non-auto height if the element has a percent height
// Note: We don't emulate this quirk for percents in calc() or in
// vertical writing modes.
if (!wm.IsVertical() &&
NS_AUTOHEIGHT == cbSize.BSize(wm)) {
if (eCompatibility_NavQuirks == aPresContext->CompatibilityMode() &&
mStylePosition->mHeight.GetUnit() == eStyleUnit_Percent) {
cbSize.BSize(wm) = CalcQuirkContainingBlockHeight(aContainingBlockRS);
}
}
}
return cbSize.ConvertTo(GetWritingMode(), wm);
}
static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
{
if (sNormalLineHeightControl == eUninitialized) {
// browser.display.normal_lineheight_calc_control is not user
// changeable, so no need to register callback for it.
int32_t val =
Preferences::GetInt("browser.display.normal_lineheight_calc_control",
eNoExternalLeading);
sNormalLineHeightControl = static_cast<eNormalLineHeightControl>(val);
}
return sNormalLineHeightControl;
}
static inline bool
IsSideCaption(nsIFrame* aFrame, const nsStyleDisplay* aStyleDisplay,
WritingMode aWM)
{
if (aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CAPTION) {
return false;
}
uint8_t captionSide = aFrame->StyleTableBorder()->mCaptionSide;
return captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT;
}
// Flex/grid items resolve block-axis percentage margin & padding against the
// containing block block-size (also for abs/fixed-pos child frames).
// For everything else: the CSS21 spec requires that margin and padding
// percentage values are calculated with respect to the inline-size of the
// containing block, even for margin & padding in the block axis.
static LogicalSize
OffsetPercentBasis(const nsIFrame* aFrame,
WritingMode aWM,
const LogicalSize& aContainingBlockSize)
{
LogicalSize offsetPercentBasis = aContainingBlockSize;
if (MOZ_LIKELY(!aFrame->GetParent() ||
!aFrame->GetParent()->IsFlexOrGridContainer())) {
offsetPercentBasis.BSize(aWM) = offsetPercentBasis.ISize(aWM);
} else if (offsetPercentBasis.BSize(aWM) == NS_AUTOHEIGHT) {
offsetPercentBasis.BSize(aWM) = 0;
}
return offsetPercentBasis;
}
// XXX refactor this code to have methods for each set of properties
// we are computing: width,height,line-height; margin; offsets
void
nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
const LogicalSize& aContainingBlockSize,
const nsMargin* aBorder,
const nsMargin* aPadding,
nsIAtom* aFrameType)
{
WritingMode wm = GetWritingMode();
DISPLAY_INIT_CONSTRAINTS(frame, this,
aContainingBlockSize.ISize(wm),
aContainingBlockSize.BSize(wm),
aBorder, aPadding);
// If this is a reflow root, then set the computed width and
// height equal to the available space
if (nullptr == parentReflowState || mFlags.mDummyParentReflowState) {
// XXXldb This doesn't mean what it used to!
InitOffsets(wm, OffsetPercentBasis(frame, wm, aContainingBlockSize),
aFrameType, aBorder, aPadding);
// Override mComputedMargin since reflow roots start from the
// frame's boundary, which is inside the margin.
ComputedPhysicalMargin().SizeTo(0, 0, 0, 0);
ComputedPhysicalOffsets().SizeTo(0, 0, 0, 0);
ComputedISize() =
AvailableISize() - ComputedLogicalBorderPadding().IStartEnd(wm);
if (ComputedISize() < 0) {
ComputedISize() = 0;
}
if (AvailableBSize() != NS_UNCONSTRAINEDSIZE) {
ComputedBSize() =
AvailableBSize() - ComputedLogicalBorderPadding().BStartEnd(wm);
if (ComputedBSize() < 0) {
ComputedBSize() = 0;
}
} else {
ComputedBSize() = NS_UNCONSTRAINEDSIZE;
}
ComputedMinWidth() = ComputedMinHeight() = 0;
ComputedMaxWidth() = ComputedMaxHeight() = NS_UNCONSTRAINEDSIZE;
} else {
// Get the containing block reflow state
const nsHTMLReflowState* cbrs = mCBReflowState;
NS_ASSERTION(nullptr != cbrs, "no containing block");
// If we weren't given a containing block width and height, then
// compute one
LogicalSize cbSize = (aContainingBlockSize == LogicalSize(wm, -1, -1))
? ComputeContainingBlockRectangle(aPresContext, cbrs)
: aContainingBlockSize;
// See if the containing block height is based on the size of its
// content
nsIAtom* fType;
if (NS_AUTOHEIGHT == cbSize.BSize(wm)) {
// See if the containing block is a cell frame which needs
// to use the mComputedHeight of the cell instead of what the cell block passed in.
// XXX It seems like this could lead to bugs with min-height and friends
if (cbrs->parentReflowState) {
fType = cbrs->frame->GetType();
if (IS_TABLE_CELL(fType)) {
// use the cell's computed block size
cbSize.BSize(wm) = cbrs->ComputedSize(wm).BSize(wm);
}
}
}
// XXX Might need to also pass the CB height (not width) for page boxes,
// too, if we implement them.
// For calculating positioning offsets, margins, borders and
// padding, we use the writing mode of the containing block
WritingMode cbwm = cbrs->GetWritingMode();
InitOffsets(cbwm, OffsetPercentBasis(frame, cbwm,
cbSize.ConvertTo(cbwm, wm)),
aFrameType, aBorder, aPadding);
// For calculating the size of this box, we use its own writing mode
const nsStyleCoord &blockSize = mStylePosition->BSize(wm);
nsStyleUnit blockSizeUnit = blockSize.GetUnit();
// Check for a percentage based block size and a containing block
// block size that depends on the content block size
// XXX twiddling blockSizeUnit doesn't help anymore
// FIXME Shouldn't we fix that?
if (blockSize.HasPercent()) {
if (NS_AUTOHEIGHT == cbSize.BSize(wm)) {
// this if clause enables %-blockSize on replaced inline frames,
// such as images. See bug 54119. The else clause "blockSizeUnit = eStyleUnit_Auto;"
// used to be called exclusively.
if (NS_FRAME_REPLACED(NS_CSS_FRAME_TYPE_INLINE) == mFrameType ||
NS_FRAME_REPLACED_CONTAINS_BLOCK(
NS_CSS_FRAME_TYPE_INLINE) == mFrameType) {
// Get the containing block reflow state
NS_ASSERTION(nullptr != cbrs, "no containing block");
// in quirks mode, get the cb height using the special quirk method
if (!wm.IsVertical() &&
eCompatibility_NavQuirks == aPresContext->CompatibilityMode()) {
if (!IS_TABLE_CELL(fType)) {
cbSize.BSize(wm) = CalcQuirkContainingBlockHeight(cbrs);
if (cbSize.BSize(wm) == NS_AUTOHEIGHT) {
blockSizeUnit = eStyleUnit_Auto;
}
}
else {
blockSizeUnit = eStyleUnit_Auto;
}
}
// in standard mode, use the cb block size. if it's "auto",
// as will be the case by default in BODY, use auto block size
// as per CSS2 spec.
else
{
nscoord computedBSize = cbrs->ComputedSize(wm).BSize(wm);
if (NS_AUTOHEIGHT != computedBSize) {
cbSize.BSize(wm) = computedBSize;
}
else {
blockSizeUnit = eStyleUnit_Auto;
}
}
}
else {
// default to interpreting the blockSize like 'auto'
blockSizeUnit = eStyleUnit_Auto;
}
}
}
// Compute our offsets if the element is relatively positioned. We
// need the correct containing block inline-size and block-size
// here, which is why we need to do it after all the quirks-n-such
// above. (If the element is sticky positioned, we need to wait
// until the scroll container knows its size, so we compute offsets
// from StickyScrollContainer::UpdatePositions.)
if (mStyleDisplay->IsRelativelyPositioned(frame) &&
NS_STYLE_POSITION_RELATIVE == mStyleDisplay->mPosition) {
ComputeRelativeOffsets(cbwm, frame, cbSize.ConvertTo(cbwm, wm),
ComputedPhysicalOffsets());
} else {
// Initialize offsets to 0
ComputedPhysicalOffsets().SizeTo(0, 0, 0, 0);
}
// Calculate the computed values for min and max properties. Note that
// this MUST come after we've computed our border and padding.
ComputeMinMaxValues(cbSize);
// Calculate the computed inlineSize and blockSize.
// This varies by frame type.
if (NS_CSS_FRAME_TYPE_INTERNAL_TABLE == mFrameType) {
// Internal table elements. The rules vary depending on the type.
// Calculate the computed isize
bool rowOrRowGroup = false;
const nsStyleCoord &inlineSize = mStylePosition->ISize(wm);
nsStyleUnit inlineSizeUnit = inlineSize.GetUnit();
if ((NS_STYLE_DISPLAY_TABLE_ROW == mStyleDisplay->mDisplay) ||
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == mStyleDisplay->mDisplay)) {
// 'inlineSize' property doesn't apply to table rows and row groups
inlineSizeUnit = eStyleUnit_Auto;
rowOrRowGroup = true;
}
// calc() with percentages acts like auto on internal table elements
if (eStyleUnit_Auto == inlineSizeUnit ||
(inlineSize.IsCalcUnit() && inlineSize.CalcHasPercent())) {
ComputedISize() = AvailableISize();
if ((ComputedISize() != NS_UNCONSTRAINEDSIZE) && !rowOrRowGroup){
// Internal table elements don't have margins. Only tables and
// cells have border and padding
ComputedISize() -= ComputedLogicalBorderPadding().IStartEnd(wm);
if (ComputedISize() < 0)
ComputedISize() = 0;
}
NS_ASSERTION(ComputedISize() >= 0, "Bogus computed isize");
} else {
NS_ASSERTION(inlineSizeUnit == inlineSize.GetUnit(),
"unexpected inline size unit change");
ComputedISize() = ComputeISizeValue(cbSize.ISize(wm),
mStylePosition->mBoxSizing,
inlineSize);
}
// Calculate the computed block size
if ((NS_STYLE_DISPLAY_TABLE_COLUMN == mStyleDisplay->mDisplay) ||
(NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == mStyleDisplay->mDisplay)) {
// 'blockSize' property doesn't apply to table columns and column groups
blockSizeUnit = eStyleUnit_Auto;
}
// calc() with percentages acts like 'auto' on internal table elements
if (eStyleUnit_Auto == blockSizeUnit ||
(blockSize.IsCalcUnit() && blockSize.CalcHasPercent())) {
ComputedBSize() = NS_AUTOHEIGHT;
} else {
NS_ASSERTION(blockSizeUnit == blockSize.GetUnit(),
"unexpected block size unit change");
ComputedBSize() = ComputeBSizeValue(cbSize.BSize(wm),
mStylePosition->mBoxSizing,
blockSize);
}
// Doesn't apply to table elements
ComputedMinWidth() = ComputedMinHeight() = 0;
ComputedMaxWidth() = ComputedMaxHeight() = NS_UNCONSTRAINEDSIZE;
} else if (NS_FRAME_GET_TYPE(mFrameType) == NS_CSS_FRAME_TYPE_ABSOLUTE) {
// XXX not sure if this belongs here or somewhere else - cwk
InitAbsoluteConstraints(aPresContext, cbrs, cbSize.ConvertTo(cbrs->GetWritingMode(), wm), aFrameType);
} else {
AutoMaybeDisableFontInflation an(frame);
bool isBlock = NS_CSS_FRAME_TYPE_BLOCK == NS_FRAME_GET_TYPE(mFrameType);
typedef nsIFrame::ComputeSizeFlags ComputeSizeFlags;
ComputeSizeFlags computeSizeFlags =
isBlock ? ComputeSizeFlags::eDefault : ComputeSizeFlags::eShrinkWrap;
if (mFlags.mShrinkWrap) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
nsIFrame* parent = frame->GetParent();
nsIAtom* parentFrameType = parent ? parent->GetType() : nullptr;
if (parentFrameType == nsGkAtoms::gridContainerFrame) {
// Shrink-wrap grid items that will be aligned (rather than stretched)
// in its inline axis.
auto inlineAxisAlignment = wm.IsOrthogonalTo(cbwm) ?
mStylePosition->ComputedAlignSelf(frame->StyleContext()->GetParent()) :
mStylePosition->ComputedJustifySelf(frame->StyleContext()->GetParent());
if ((inlineAxisAlignment != NS_STYLE_ALIGN_STRETCH &&
inlineAxisAlignment != NS_STYLE_ALIGN_NORMAL) ||
mStyleMargin->mMargin.GetIStartUnit(wm) == eStyleUnit_Auto ||
mStyleMargin->mMargin.GetIEndUnit(wm) == eStyleUnit_Auto) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
} else {
// Make sure legend frames with display:block and width:auto still
// shrink-wrap.
// Also shrink-wrap blocks that are orthogonal to their container.
if (isBlock &&
((aFrameType == nsGkAtoms::legendFrame &&
frame->StyleContext()->GetPseudo() != nsCSSAnonBoxes::scrolledContent) ||
(aFrameType == nsGkAtoms::scrollFrame &&
frame->GetContentInsertionFrame()->GetType() == nsGkAtoms::legendFrame) ||
(mCBReflowState &&
mCBReflowState->GetWritingMode().IsOrthogonalTo(mWritingMode)))) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
if (parentFrameType == nsGkAtoms::flexContainerFrame) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
// If we're inside of a flex container that needs to measure our
// auto height, pass that information along to ComputeSize().
if (mFlags.mIsFlexContainerMeasuringHeight) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eUseAutoHeight);
}
} else {
MOZ_ASSERT(!mFlags.mIsFlexContainerMeasuringHeight,
"We're not in a flex container, so the flag "
"'mIsFlexContainerMeasuringHeight' shouldn't be set");
}
}
if (cbSize.ISize(wm) == NS_UNCONSTRAINEDSIZE) {
// For orthogonal flows, where we found a parent orthogonal-limit
// for AvailableISize() in Init(), we'll use the same here as well.
cbSize.ISize(wm) = AvailableISize();
}
LogicalSize size =
frame->ComputeSize(rendContext, wm, cbSize, AvailableISize(),
ComputedLogicalMargin().Size(wm),
ComputedLogicalBorderPadding().Size(wm) -
ComputedLogicalPadding().Size(wm),
ComputedLogicalPadding().Size(wm),
computeSizeFlags);
ComputedISize() = size.ISize(wm);
ComputedBSize() = size.BSize(wm);
NS_ASSERTION(ComputedISize() >= 0, "Bogus inline-size");
NS_ASSERTION(ComputedBSize() == NS_UNCONSTRAINEDSIZE ||
ComputedBSize() >= 0, "Bogus block-size");
// Exclude inline tables, side captions, flex and grid items from block
// margin calculations.
if (isBlock &&
!IsSideCaption(frame, mStyleDisplay, cbwm) &&
mStyleDisplay->mDisplay != NS_STYLE_DISPLAY_INLINE_TABLE &&
parentFrameType != nsGkAtoms::flexContainerFrame &&
parentFrameType != nsGkAtoms::gridContainerFrame) {
CalculateBlockSideMargins(aFrameType);
}
}
}
}
static void
UpdateProp(FrameProperties& aProps,
const FramePropertyDescriptor<nsMargin>* aProperty,
bool aNeeded,
nsMargin& aNewValue)
{
if (aNeeded) {
nsMargin* propValue = aProps.Get(aProperty);
if (propValue) {
*propValue = aNewValue;
} else {
aProps.Set(aProperty, new nsMargin(aNewValue));
}
} else {
aProps.Delete(aProperty);
}
}
void
nsCSSOffsetState::InitOffsets(WritingMode aWM,
const LogicalSize& aPercentBasis,
nsIAtom* aFrameType,
const nsMargin *aBorder,
const nsMargin *aPadding)
{
DISPLAY_INIT_OFFSETS(frame, this, aPercentBasis, aBorder, aPadding);
// Since we are in reflow, we don't need to store these properties anymore
// unless they are dependent on width, in which case we store the new value.
nsPresContext *presContext = frame->PresContext();
FrameProperties props(presContext->PropertyTable(), frame);
props.Delete(nsIFrame::UsedBorderProperty());
// Compute margins from the specified margin style information. These
// become the default computed values, and may be adjusted below
// XXX fix to provide 0,0 for the top&bottom margins for
// inline-non-replaced elements
bool needMarginProp = ComputeMargin(aWM, aPercentBasis);
// XXX We need to include 'auto' horizontal margins in this too!
// ... but if we did that, we'd need to fix nsFrame::GetUsedMargin
// to use it even when the margins are all zero (since sometimes
// they get treated as auto)
::UpdateProp(props, nsIFrame::UsedMarginProperty(), needMarginProp,
ComputedPhysicalMargin());
const nsStyleDisplay *disp = frame->StyleDisplay();
bool isThemed = frame->IsThemed(disp);
bool needPaddingProp;
nsIntMargin widget;
if (isThemed &&
presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
frame, disp->mAppearance,
&widget)) {
ComputedPhysicalPadding().top = presContext->DevPixelsToAppUnits(widget.top);
ComputedPhysicalPadding().right = presContext->DevPixelsToAppUnits(widget.right);
ComputedPhysicalPadding().bottom = presContext->DevPixelsToAppUnits(widget.bottom);
ComputedPhysicalPadding().left = presContext->DevPixelsToAppUnits(widget.left);
needPaddingProp = false;
}
else if (frame->IsSVGText()) {
ComputedPhysicalPadding().SizeTo(0, 0, 0, 0);
needPaddingProp = false;
}
else if (aPadding) { // padding is an input arg
ComputedPhysicalPadding() = *aPadding;
needPaddingProp = frame->StylePadding()->IsWidthDependent() ||
(frame->GetStateBits() & NS_FRAME_REFLOW_ROOT);
}
else {
needPaddingProp = ComputePadding(aWM, aPercentBasis, aFrameType);
}
if (isThemed) {
nsIntMargin widget;
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
frame, disp->mAppearance,
&widget);
ComputedPhysicalBorderPadding().top =
presContext->DevPixelsToAppUnits(widget.top);
ComputedPhysicalBorderPadding().right =
presContext->DevPixelsToAppUnits(widget.right);
ComputedPhysicalBorderPadding().bottom =
presContext->DevPixelsToAppUnits(widget.bottom);
ComputedPhysicalBorderPadding().left =
presContext->DevPixelsToAppUnits(widget.left);
}
else if (frame->IsSVGText()) {
ComputedPhysicalBorderPadding().SizeTo(0, 0, 0, 0);
}
else if (aBorder) { // border is an input arg
ComputedPhysicalBorderPadding() = *aBorder;
}
else {
ComputedPhysicalBorderPadding() = frame->StyleBorder()->GetComputedBorder();
}
ComputedPhysicalBorderPadding() += ComputedPhysicalPadding();
if (aFrameType == nsGkAtoms::tableFrame) {
nsTableFrame *tableFrame = static_cast<nsTableFrame*>(frame);
if (tableFrame->IsBorderCollapse()) {
// border-collapsed tables don't use any of their padding, and
// only part of their border. We need to do this here before we
// try to do anything like handling 'auto' widths,
// 'box-sizing', or 'auto' margins.
ComputedPhysicalPadding().SizeTo(0,0,0,0);
SetComputedLogicalBorderPadding(
tableFrame->GetIncludedOuterBCBorder(mWritingMode));
}
// The margin is inherited to the outer table frame via
// the ::-moz-table-outer rule in ua.css.
ComputedPhysicalMargin().SizeTo(0, 0, 0, 0);
} else if (aFrameType == nsGkAtoms::scrollbarFrame) {
// scrollbars may have had their width or height smashed to zero
// by the associated scrollframe, in which case we must not report
// any padding or border.
nsSize size(frame->GetSize());
if (size.width == 0 || size.height == 0) {
ComputedPhysicalPadding().SizeTo(0,0,0,0);
ComputedPhysicalBorderPadding().SizeTo(0,0,0,0);
}
}
::UpdateProp(props, nsIFrame::UsedPaddingProperty(), needPaddingProp,
ComputedPhysicalPadding());
}
// This code enforces section 10.3.3 of the CSS2 spec for this formula:
//
// 'margin-left' + 'border-left-width' + 'padding-left' + 'width' +
// 'padding-right' + 'border-right-width' + 'margin-right'
// = width of containing block
//
// Note: the width unit is not auto when this is called
void
nsHTMLReflowState::CalculateBlockSideMargins(nsIAtom* aFrameType)
{
// Calculations here are done in the containing block's writing mode,
// which is where margins will eventually be applied: we're calculating
// margins that will be used by the container in its inline direction,
// which in the case of an orthogonal contained block will correspond to
// the block direction of this reflow state. So in the orthogonal-flow
// case, "CalculateBlock*Side*Margins" will actually end up adjusting
// the BStart/BEnd margins; those are the "sides" of the block from its
// container's point of view.
WritingMode cbWM =
mCBReflowState ? mCBReflowState->GetWritingMode(): GetWritingMode();
nscoord availISizeCBWM = AvailableSize(cbWM).ISize(cbWM);
nscoord computedISizeCBWM = ComputedSize(cbWM).ISize(cbWM);
if (computedISizeCBWM == NS_UNCONSTRAINEDSIZE) {
// For orthogonal flows, where we found a parent orthogonal-limit
// for AvailableISize() in Init(), we'll use the same here as well.
computedISizeCBWM = availISizeCBWM;
}
LAYOUT_WARN_IF_FALSE(NS_UNCONSTRAINEDSIZE != computedISizeCBWM &&
NS_UNCONSTRAINEDSIZE != availISizeCBWM,
"have unconstrained inline-size; this should only "
"result from very large sizes, not attempts at "
"intrinsic inline-size calculation");
LogicalMargin margin =
ComputedLogicalMargin().ConvertTo(cbWM, mWritingMode);
LogicalMargin borderPadding =
ComputedLogicalBorderPadding().ConvertTo(cbWM, mWritingMode);
nscoord sum = margin.IStartEnd(cbWM) +
borderPadding.IStartEnd(cbWM) + computedISizeCBWM;
if (sum == availISizeCBWM) {
// The sum is already correct
return;
}
// Determine the start and end margin values. The isize value
// remains constant while we do this.
// Calculate how much space is available for margins
nscoord availMarginSpace = availISizeCBWM - sum;
// If the available margin space is negative, then don't follow the
// usual overconstraint rules.
if (availMarginSpace < 0) {
margin.IEnd(cbWM) += availMarginSpace;
SetComputedLogicalMargin(margin.ConvertTo(mWritingMode, cbWM));
return;
}
// The css2 spec clearly defines how block elements should behave
// in section 10.3.3.
const nsStyleSides& styleSides = mStyleMargin->mMargin;
bool isAutoStartMargin = eStyleUnit_Auto == styleSides.GetIStartUnit(cbWM);
bool isAutoEndMargin = eStyleUnit_Auto == styleSides.GetIEndUnit(cbWM);
if (!isAutoStartMargin && !isAutoEndMargin) {
// Neither margin is 'auto' so we're over constrained. Use the
// 'direction' property of the parent to tell which margin to
// ignore
// First check if there is an HTML alignment that we should honor
const nsHTMLReflowState* prs = parentReflowState;
if (aFrameType == nsGkAtoms::tableFrame) {
NS_ASSERTION(prs->frame->GetType() == nsGkAtoms::tableOuterFrame,
"table not inside outer table");
// Center the table within the outer table based on the alignment
// of the outer table's parent.
prs = prs->parentReflowState;
}
if (prs &&
(prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_LEFT ||
prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER ||
prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)) {
if (prs->mWritingMode.IsBidiLTR()) {
isAutoStartMargin =
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_LEFT;
isAutoEndMargin =
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_RIGHT;
} else {
isAutoStartMargin =
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_RIGHT;
isAutoEndMargin =
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_LEFT;
}
}
// Otherwise apply the CSS rules, and ignore one margin by forcing
// it to 'auto', depending on 'direction'.
else {
isAutoEndMargin = true;
}
}
// Logic which is common to blocks and tables
// The computed margins need not be zero because the 'auto' could come from
// overconstraint or from HTML alignment so values need to be accumulated
if (isAutoStartMargin) {
if (isAutoEndMargin) {
// Both margins are 'auto' so the computed addition should be equal
nscoord forStart = availMarginSpace / 2;
margin.IStart(cbWM) += forStart;
margin.IEnd(cbWM) += availMarginSpace - forStart;
} else {
margin.IStart(cbWM) += availMarginSpace;
}
} else if (isAutoEndMargin) {
margin.IEnd(cbWM) += availMarginSpace;
}
SetComputedLogicalMargin(margin.ConvertTo(mWritingMode, cbWM));
}
#define NORMAL_LINE_HEIGHT_FACTOR 1.2f // in term of emHeight
// For "normal" we use the font's normal line height (em height + leading).
// If both internal leading and external leading specified by font itself
// are zeros, we should compensate this by creating extra (external) leading
// in eCompensateLeading mode. This is necessary because without this
// compensation, normal line height might looks too tight.
// For risk management, we use preference to control the behavior, and
// eNoExternalLeading is the old behavior.
static nscoord
GetNormalLineHeight(nsFontMetrics* aFontMetrics)
{
NS_PRECONDITION(nullptr != aFontMetrics, "no font metrics");
nscoord normalLineHeight;
nscoord externalLeading = aFontMetrics->ExternalLeading();
nscoord internalLeading = aFontMetrics->InternalLeading();
nscoord emHeight = aFontMetrics->EmHeight();
switch (GetNormalLineHeightCalcControl()) {
case eIncludeExternalLeading:
normalLineHeight = emHeight+ internalLeading + externalLeading;
break;
case eCompensateLeading:
if (!internalLeading && !externalLeading)
normalLineHeight = NSToCoordRound(emHeight * NORMAL_LINE_HEIGHT_FACTOR);
else
normalLineHeight = emHeight+ internalLeading + externalLeading;
break;
default:
//case eNoExternalLeading:
normalLineHeight = emHeight + internalLeading;
}
return normalLineHeight;
}
static inline nscoord
ComputeLineHeight(nsStyleContext* aStyleContext,
nscoord aBlockBSize,
float aFontSizeInflation)
{
const nsStyleCoord& lhCoord = aStyleContext->StyleText()->mLineHeight;
if (lhCoord.GetUnit() == eStyleUnit_Coord) {
nscoord result = lhCoord.GetCoordValue();
if (aFontSizeInflation != 1.0f) {
result = NSToCoordRound(result * aFontSizeInflation);
}
return result;
}
if (lhCoord.GetUnit() == eStyleUnit_Factor)
// For factor units the computed value of the line-height property
// is found by multiplying the factor by the font's computed size
// (adjusted for min-size prefs and text zoom).
return NSToCoordRound(lhCoord.GetFactorValue() * aFontSizeInflation *
aStyleContext->StyleFont()->mFont.size);
NS_ASSERTION(lhCoord.GetUnit() == eStyleUnit_Normal ||
lhCoord.GetUnit() == eStyleUnit_Enumerated,
"bad line-height unit");
if (lhCoord.GetUnit() == eStyleUnit_Enumerated) {
NS_ASSERTION(lhCoord.GetIntValue() == NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT,
"bad line-height value");
if (aBlockBSize != NS_AUTOHEIGHT) {
return aBlockBSize;
}
}
RefPtr<nsFontMetrics> fm = nsLayoutUtils::
GetFontMetricsForStyleContext(aStyleContext, aFontSizeInflation);
return GetNormalLineHeight(fm);
}
nscoord
nsHTMLReflowState::CalcLineHeight() const
{
nscoord blockBSize =
nsLayoutUtils::IsNonWrapperBlock(frame) ? ComputedBSize() :
(mCBReflowState ? mCBReflowState->ComputedBSize() : NS_AUTOHEIGHT);
return CalcLineHeight(frame->GetContent(), frame->StyleContext(), blockBSize,
nsLayoutUtils::FontSizeInflationFor(frame));
}
/* static */ nscoord
nsHTMLReflowState::CalcLineHeight(nsIContent* aContent,
nsStyleContext* aStyleContext,
nscoord aBlockBSize,
float aFontSizeInflation)
{
NS_PRECONDITION(aStyleContext, "Must have a style context");
nscoord lineHeight =
ComputeLineHeight(aStyleContext, aBlockBSize, aFontSizeInflation);
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
HTMLInputElement* input = HTMLInputElement::FromContentOrNull(aContent);
if (input && input->IsSingleLineTextControl()) {
// For Web-compatibility, single-line text input elements cannot
// have a line-height smaller than one.
nscoord lineHeightOne =
aFontSizeInflation * aStyleContext->StyleFont()->mFont.size;
if (lineHeight < lineHeightOne) {
lineHeight = lineHeightOne;
}
}
return lineHeight;
}
bool
nsCSSOffsetState::ComputeMargin(WritingMode aWM,
const LogicalSize& aPercentBasis)
{
// SVG text frames have no margin.
if (frame->IsSVGText()) {
return false;
}
// If style style can provide us the margin directly, then use it.
const nsStyleMargin *styleMargin = frame->StyleMargin();
bool isCBDependent = !styleMargin->GetMargin(ComputedPhysicalMargin());
if (isCBDependent) {
// We have to compute the value. Note that this calculation is
// performed according to the writing mode of the containing block
// (http://dev.w3.org/csswg/css-writing-modes-3/#orthogonal-flows)
LogicalMargin m(aWM);
m.IStart(aWM) = nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
styleMargin->mMargin.GetIStart(aWM));
m.IEnd(aWM) = nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
styleMargin->mMargin.GetIEnd(aWM));
m.BStart(aWM) = nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
styleMargin->mMargin.GetBStart(aWM));
m.BEnd(aWM) = nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
styleMargin->mMargin.GetBEnd(aWM));
SetComputedLogicalMargin(aWM, m);
}
// ... but font-size-inflation-based margin adjustment uses the
// frame's writing mode
nscoord marginAdjustment = FontSizeInflationListMarginAdjustment(frame);
if (marginAdjustment > 0) {
LogicalMargin m = ComputedLogicalMargin();
m.IStart(mWritingMode) += marginAdjustment;
SetComputedLogicalMargin(m);
}
return isCBDependent;
}
bool
nsCSSOffsetState::ComputePadding(WritingMode aWM,
const LogicalSize& aPercentBasis,
nsIAtom* aFrameType)
{
// If style can provide us the padding directly, then use it.
const nsStylePadding *stylePadding = frame->StylePadding();
bool isCBDependent = !stylePadding->GetPadding(ComputedPhysicalPadding());
// a table row/col group, row/col doesn't have padding
// XXXldb Neither do border-collapse tables.
if (nsGkAtoms::tableRowGroupFrame == aFrameType ||
nsGkAtoms::tableColGroupFrame == aFrameType ||
nsGkAtoms::tableRowFrame == aFrameType ||
nsGkAtoms::tableColFrame == aFrameType) {
ComputedPhysicalPadding().SizeTo(0,0,0,0);
}
else if (isCBDependent) {
// We have to compute the value. This calculation is performed
// according to the writing mode of the containing block
// (http://dev.w3.org/csswg/css-writing-modes-3/#orthogonal-flows)
// clamp negative calc() results to 0
LogicalMargin p(aWM);
p.IStart(aWM) = std::max(0, nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
stylePadding->mPadding.GetIStart(aWM)));
p.IEnd(aWM) = std::max(0, nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
stylePadding->mPadding.GetIEnd(aWM)));
p.BStart(aWM) = std::max(0, nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
stylePadding->mPadding.GetBStart(aWM)));
p.BEnd(aWM) = std::max(0, nsLayoutUtils::
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
stylePadding->mPadding.GetBEnd(aWM)));
SetComputedLogicalPadding(aWM, p);
}
return isCBDependent;
}
void
nsHTMLReflowState::ComputeMinMaxValues(const LogicalSize&aCBSize)
{
WritingMode wm = GetWritingMode();
const nsStyleCoord& minISize = mStylePosition->MinISize(wm);
const nsStyleCoord& maxISize = mStylePosition->MaxISize(wm);
const nsStyleCoord& minBSize = mStylePosition->MinBSize(wm);
const nsStyleCoord& maxBSize = mStylePosition->MaxBSize(wm);
// NOTE: min-width:auto resolves to 0, except on a flex item. (But
// even there, it's supposed to be ignored (i.e. treated as 0) until
// the flex container explicitly resolves & considers it.)
if (eStyleUnit_Auto == minISize.GetUnit()) {
ComputedMinISize() = 0;
} else {
ComputedMinISize() = ComputeISizeValue(aCBSize.ISize(wm),
mStylePosition->mBoxSizing,
minISize);
}
if (eStyleUnit_None == maxISize.GetUnit()) {
// Specified value of 'none'
ComputedMaxISize() = NS_UNCONSTRAINEDSIZE; // no limit
} else {
ComputedMaxISize() = ComputeISizeValue(aCBSize.ISize(wm),
mStylePosition->mBoxSizing,
maxISize);
}
// If the computed value of 'min-width' is greater than the value of
// 'max-width', 'max-width' is set to the value of 'min-width'
if (ComputedMinISize() > ComputedMaxISize()) {
ComputedMaxISize() = ComputedMinISize();
}
// Check for percentage based values and a containing block height that
// depends on the content height. Treat them like 'auto'
// Likewise, check for calc() with percentages on internal table elements;
// that's treated as 'auto' too.
// Likewise, if we're a child of a flex container who's measuring our
// intrinsic height, then we want to disregard our min-height.
// NOTE: min-height:auto resolves to 0, except on a flex item. (But
// even there, it's supposed to be ignored (i.e. treated as 0) until
// the flex container explicitly resolves & considers it.)
if (eStyleUnit_Auto == minBSize.GetUnit() ||
(NS_AUTOHEIGHT == aCBSize.BSize(wm) &&
minBSize.HasPercent()) ||
(mFrameType == NS_CSS_FRAME_TYPE_INTERNAL_TABLE &&
minBSize.IsCalcUnit() && minBSize.CalcHasPercent()) ||
mFlags.mIsFlexContainerMeasuringHeight) {
ComputedMinBSize() = 0;
} else {
ComputedMinBSize() = ComputeBSizeValue(aCBSize.BSize(wm),
mStylePosition->mBoxSizing,
minBSize);
}
nsStyleUnit maxBSizeUnit = maxBSize.GetUnit();
if (eStyleUnit_None == maxBSizeUnit) {
// Specified value of 'none'
ComputedMaxBSize() = NS_UNCONSTRAINEDSIZE; // no limit
} else {
// Check for percentage based values and a containing block height that
// depends on the content height. Treat them like 'none'
// Likewise, check for calc() with percentages on internal table elements;
// that's treated as 'auto' too.
// Likewise, if we're a child of a flex container who's measuring our
// intrinsic height, then we want to disregard our max-height.
if ((NS_AUTOHEIGHT == aCBSize.BSize(wm) &&
maxBSize.HasPercent()) ||
(mFrameType == NS_CSS_FRAME_TYPE_INTERNAL_TABLE &&
maxBSize.IsCalcUnit() && maxBSize.CalcHasPercent()) ||
mFlags.mIsFlexContainerMeasuringHeight) {
ComputedMaxBSize() = NS_UNCONSTRAINEDSIZE;
} else {
ComputedMaxBSize() = ComputeBSizeValue(aCBSize.BSize(wm),
mStylePosition->mBoxSizing,
maxBSize);
}
}
// If the computed value of 'min-height' is greater than the value of
// 'max-height', 'max-height' is set to the value of 'min-height'
if (ComputedMinBSize() > ComputedMaxBSize()) {
ComputedMaxBSize() = ComputedMinBSize();
}
}
void
nsHTMLReflowState::SetTruncated(const nsHTMLReflowMetrics& aMetrics,
nsReflowStatus* aStatus) const
{
if (AvailableHeight() != NS_UNCONSTRAINEDSIZE &&
AvailableHeight() < aMetrics.Height() &&
!mFlags.mIsTopOfPage) {
*aStatus |= NS_FRAME_TRUNCATED;
} else {
*aStatus &= ~NS_FRAME_TRUNCATED;
}
}
bool
nsHTMLReflowState::IsFloating() const
{
return mStyleDisplay->IsFloating(frame);
}
uint8_t
nsHTMLReflowState::GetDisplay() const
{
return mStyleDisplay->GetDisplay(frame);
}