mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
28eae10bc7
- Bug 1251797 - Don't fault struct out of rule tree if all of the potential physical property destinations already have a winning value in the cascade. r=heycam (b64f25ae75)
- Bug 1257688 part 0: Add an "IsLegacyBox" accessor to nsFlexContainerFrame, to enable special handling of display:-webkit-box & display:-webkit-inline-box. r=mats (f728070412)
- Bug 1257688 part 1: Change "-webkit-box-pack" & "-webkit-box-align" to alias their -moz equivalents, & change nsFlexContainerFrame to respect them in a -webkit-box. r=mats (fda7e641bb)
- Bug 1174248 - Apply RTL resizer failure only to GTK2. r=karlt (5f264b52bc)
- Bug 1234941 part 1: Add reftests for "-webkit-box" rendering, with -webkit-box-orient unset. r=heycam (bbdb2737a0)
- Bug 1234941 part 2: Add reftests for "-webkit-box" rendering, with -webkit-box-orient:horizontal. r=heycam (815f24f010)
- Bug 1234941 part 3: Add reftests for "-webkit-box" rendering, with -webkit-box-orient:vertical. r=heycam (a4f71266b9)
- Bug 1257688 part 2: Enable "-webkit-box-pack: justify" sections of -webkit-box reftests, & fix reference cases to use 'space-between' (the modern equivalent). (no review) (7641615ec0)
- Bug 1257688 part 3: Change "-webkit-box-ordinal-group" to alias its -moz equivalent, & change nsFlexContainerFrame to respect it in a -webkit-box. r=mats (90797264fe)
- Bug 1257688 part 4: Add reftests for -webkit-box-ordinal-group inside of display:-webkit-box. r=mats (7623b7a5dd)
- Bug 1257688 part 5: Change "-webkit-box-flex" to alias its -moz equivalent, & change nsFlexContainerFrame to use it instead of flex-shrink & flex-grow in a -webkit-box. r=mats (dabf0415f3)
- Bug 1257688 part 6: Add reftest for -webkit-box-flex inside of display:-webkit-box. r=mats (06d1384d0b)
- Bug 1257688 followup: Fix typo in <title>s in webkit-box-ordinal-group reftests. (no review, test-metadata only) (b8753af073)
- Bug 1262049 part 1: Back out bug 1208344 in its entirety, and mark -webkit-box-orient:vertical reftests as failing (for now). (no review) (fd3890a164)
- Bug 1262049 part 2: Add -webkit-box-orient & -webkit-box-direction as aliases for -moz versions, in the style system (but not yet honored by flexbox layout). r=mats (33e137427f)
- Bug 1262049 part 3: Refactor FlexboxAxisTracker constructor to take pointer to nsFlexContainerFrame. r=mats (0e9a26b85d)
- Bug 1262049 part 4: Refactor some of FlexboxAxisTracker constructor's logic into a helper method. r=mats (c298827ed2)
- Bug 1264837 Part 1 - Remove nsTextBoxFrameSuper. r=dholbert (dc64371da6)
- Bug 1264837 Part 2 - Remove nsColorControlFrameSuper. r=dholbert (166c5c13c3)
- Bug 1264837 Part 3 - Remove nsFormControlFrameSuper. r=dholbert (70c4c13c79)
- Bug 1264837 Part 4 - Remove nsImageControlFrameSuper. r=dholbert (68af4648e6)
- Bug 1264837 Part 5 - Remove nsFlexContainerFrameSuper. r=dholbert (ef7b1a912e)
- Bug 1261553 - Don't return from OnVisibilityChanged implementations without calling the superclass implementation. r=mstange (033d4cdf72)
- Bug 1264837 Part 6 - Remove ImageFrameSuper. r=dholbert (cbf002ba56)
- Bug 1264837 Part 7 - Remove nsInlineFrameBase r=dholbert (42e277593f)
- Bug 1262049 part 5: Honor -webkit-box-orient & -webkit-box-direction when determining axes for a -webkit-box flexbox. r=mats (a4f03722ed)
- Bug 1262049 part 6: Add reftest for -webkit-box-direction. (no review) (d41936d107)
- Bug 1266248 part 1: Rename MapSinglePropertyInto() args, to make src-vs-target distinctions clearer. r=heycam (2d46c21c34)
- Bug 1266248 part 2: Add assertion to verify that MapSinglePropertyInto() isn't called with a logical target-property. r=heycam (c51b780a2b)
- Bug 1264837 Part 8 - Remove nsPluginFrameSuper. r=dholbert (615738f0f0)
- Bug 1264837 Part 9 - Remove nsRubyBaseFrameSuper. r=dholbert (0fb30cf0a3)
- Bug 1264837 Part 10 - Remove nsRubyContentFrameSuper. r=dholbert (df02f9983c)
- Bug 1264837 Part 11 - Remove nsRubyFrameSuper. r=dholbert (684a20009b)
- Bug 1264837 Part 12 - Remove nsRubyTextContainerFrameSuper. r=dholbert (4961565c4b)
- Bug 1264837 Part 13 - Remove nsRubyTextFrameSuper. r=dholbert (aa9e863378)
- bits of 1261230 (cffbacd922)
- Bug 1264837 Part 14 - Remove nsSubDocumentFrameSuper. r=dholbert (2ddc0b2028)
- Bug 1264837 Part 15 - Remove nsVideoFrameBase r=dholbert (c1246fd0bc)
- Bug 1264837 Part 16 - Remove ViewportFrame::Super. r=dholbert (dff457b117)
- Bug 1264837 Part 17 - Remove nsSVGAFrameBase. r=dholbert (0df66e92c5)
- Bug 1253590, part 1 - Generalize AutoReferenceLoopDetector to allow it to be used to limit reference chain lengths. r=longsonr (e1673d2e9e)
- Bug 1253590, part 2 - Use the new AutoReferenceLimiter helper to limit clip path reference chain lengths. r=longsonr (4e03ec9001)
- Bug 1253590, part 3 - Crashtest for long clipPath reference chains. r=longsonr (c4da0e1dc4)
- Bug 1253590, part 4 - Follow-up to return the correct type. r=bustage (61c7fd965a)
- Bug 1264837 Part 18 - Remove nsSVGClipPathFrameBase. r=dholbert (ec78340590)
- Bug 1264837 Part 19 - Remove nsSVGContainerFrameBase. r=dholbert (57c5c44826)
- Bug 1264837 Part 20 - Remove nsSVGFilterFrameBase. r=dholbert (5f41a15a86)
- Bug 1264837 Part 21 - Remove nsSVGForeignObjectFrameBase. r=dholbert (c9aeb556ce)
- Bug 1264837 Part 22 - Remove nsSVGGenericContainerFrameBase. r=dholbert (bd4e21975d)
- Bug 1264837 Part 23 - Remove nsSVGGFrameBase. r=dholbert (bed40424fd)
- Bug 1264837 Part 24 - Remove nsSVGGradientFrameBase. r=dholbert (a9a7d3e0d4)
- Bug 1264837 Part 25 - Remove nsSVGLinearGradientFrameBase. r=dholbert (a48ed6b6b2)
- Bug 1264837 Part 26 - Remove nsSVGRadialGradientFrameBase. r=dholbert (76181ad3b2)
- Bug 1264837 Part 27 - Remove nsSVGImageFrameBase. r=dholbert (5aaa32517d)
- Bug 1242256 - ensure images in patterns and masks animate properly. r=jwatt,seth (cc40ee9520)
- Bug 1264837 Part 28 - Remove nsSVGInnerSVGFrameBase. r=dholbert (04b9d9b5fb)
- Bug 1264837 Part 29 - Remove nsSVGMarkerFrameBase. r=dholbert (bc28eca472)
- Bug 1264837 Part 30 - Remove nsSVGMarkerAnonChildFrameBase. r=dholbert (6898a93a31)
- Bug 1264837 Part 31 - Remove nsSVGMaskFrameBase. r=dholbert (26d0e7a5e1)
- Bug 1264837 Part 32 - Remove nsSVGOuterSVGFrameBase. r=dholbert (a473ae8be3)
- Bug 1264837 Part 33 - Remove nsSVGOuterSVGAnonChildFrameBase. r=dholbert (8c6cca5e9b)
- Bug 1264837 Part 34 - Remove nsSVGPaintServerFrameBase. r=dholbert (eab458bfab)
- Bug 1264837 Part 35 - Remove nsSVGPathGeometryFrameBase. r=dholbert (e5245d2be0)
- Bug 1264837 Part 36 - Remove nsSVGPatternFrameBase. r=dholbert (2df37d4056)
- Bug 1264837 Part 37 - Remove nsSVGStopFrameBase. r=dholbert (e367dba151)
- Bug 1264837 Part 38 - Remove nsSVGSwitchFrameBase. r=dholbert (7ffe7a731a)
- Bug 1264837 Part 39 - Remove nsSVGUseFrameBase. r=dholbert (b4445728e3)
- Bug 1264837 Part 40 - Remove SVGFEContainerFrameBase. r=dholbert (ee08ef9caf)
- Bug 1264837 Part 41 - Remove SVGFEImageFrameBase. r=dholbert (010f79b418)
- Bug 1264837 Part 42 - Remove SVGFELeafFrameBase. r=dholbert (949aeba02d)
- Bug 1264837 Part 44 - Remove SVGTextFrameBase. r=dholbert (bfd0603d44)
- Bug 1264837 Part 45 - Remove SVGViewFrameBase. r=dholbert (151f3c95b2)
- Bug 1265591 patch 1 - Remove Internal/External versions of ReconstructStyleData. r=heycam (a91f96e3b3)
- Bug 1265591 patch 2 - Rename nsIPresShell::ReconstructStyleData to RestyleForCSSRuleChanges. r=heycam (8ad2bc3021)
- Bug 1265591 patch 3 - Make the comment describing RestyleForCSSRuleChanges match reality. r=heycam (2ef053622d)
- Bug 1251150. Add crash annotations if image visibility is re-entering. r=mats (975a3e98d7)
- Bug 1261554 (Part 1) - Prepare for implementing in-displayport visibility tracking. r=mstange (b139489249)
- Bug 1261554 (Part 2) - Mark frames which are added to the display list when painting to the window as having Visibility::IN_DISPLAYPORT. r=mstange (4c8185bf0e)
- Bug 1259529 - Clean up the APZ minimap rendering code a bit. No functional changes. r=BenWa (9b99c27777)
- Bug 1256532 - Show the critical displayport in the APZ minimap as well. r=BenWa (9b131616a0)
- Bug 1251886 - Correct inputFrameID selection when using e10s r=daoshengmu (9e042f6af3)
- Bug 1261554 (Part 3) - Visualize Visibility::IN_DISPLAYPORT regions in the APZ minimap visibility debugger. r=botond (f9b72319e1)
- Bug 1261554 (Followup) - Fix memory reporting for PresShell::mVisibleRegions. r=me (6fc953c1de)
- Bug 1259529 - Ensure that the APZ minimap for subframes remains scaled to the visible portion of the composition bounds. r=BenWa (9f156773cf)
- Bug 1251150. Back out crash annotations used to try to diagnose crash. (db6ba80214)
- missing bits of Bug 1258476 - Optimize CreateRangePaintInfo by generating display lists for the minimum amount of range subtrees rather than for the range common ancestor. r=tn (2ded969082)
- Bug 1237821. Use displayport getter for image visibility in the (unused) display list builder based image visibility code. r=botond (a634182065)
- Bug 1253995 - Display stale image in nsImageFrame if we have a new src but haven't decoded it yet - r=seth (6add357448)
- Bug 1261703. When moving flex frame, position its view as well as any child views. r=dholbert (abd586f55f)
- bug 1246772 - work around x87 floating point truncation issues in gecko r=dholbert (de38865a9f)
- missing bits of 1202908 (4a254234f7)
- Bug 1249134: Remove support for -webkit-appearance as an alias for -moz-appearance, since the two prefixed properties behave differently in practice. r=heycam (7fd6826fb0)
- Bug 1249937 - Rename LayerComposite::SetShadowTransform to SetShadowBaseTransform. r=botond (c91f175b8d)
- Bug 1260335 - On perspective ContainerLayers, the clip deferred from their child layer needs to be affected by the perspective layer's async transforms. r=botond (ee1a19e113)
- Bug 1260335 - Add a comment that explains why the perspective child can't have more than one frame metrics. r=mattwoodrow (639d9ede24)
- Bug 1148978 - Remove plugin window update composition deferment. r=mattwoodrow (01e7da3570)
- Bug 1263515 - Destroy the compositor earlier in RecvWillStop when it still has a valid widget. r=jnicol (c14135bf7c)
- Bug 1258440 - Don't attempt to hide plugin windows when switching trees if the previous remote layer tree didn't contain plugin windows. Fixes a tpaint regression. r=mconley (929db2fdf2)
- Bug 1260976 - Make nsTransitionManager use Keyframe objects to set up transitions; r=heycam (3b8ef91fe9)
- Bug 1265611 - Make TransitionProperty() and ToValue() safe when mProperties is not set; r=heycam (37d234aad4)
- Bug 1259675 - Clean up InternalTransitionEvent r=masayuki (f6526d4dfa)
- Bug 1260976 - Remove some references to properties within nsTransitionManager; r=heycam (6c0f84fb17)
- Bug 1182856 - Part 4: Refactor code in nsTransitionManager::StyleContextChanged(). r=heycam (ee0f4d76fd)
- Bug 1182856 - Part 5: Avoid unnecessary transition update if display:none. r=heycam (5e01fff5cc)
- Bug 1182856 - Part 6: Revise tests for display:none in test_transitions.html. r=heycam (ac2dfe8e47)
- Bug 1182856 - Part 7: Test. r=cam (2aed7d5ae6)
- Bug 1265611 - Don't trigger transitions for properties that are disabled; r=heycam (dabf201421)
- Bug 1247533 - Annotate intentional switch fallthrough to suppress -Wimplicit-fallthrough warning in layout/style/. r=dbaron (a0b748bea2)
- Bug 1264830 - Part 1: Add an nsStyleAutoArray array type, similar to AutoTArray<...,1> but memmovable. r=bholley (ad4eb0692c)
- Bug 1264830 - Part 2: Change nsStyleImageLayers::mLayers to use nsStyleAutoArray. r=bholley (963a9e4033)
- Bug 1264830 - Part 3: Change nsStyleDisplay::{mTransitions,mAnimations} to use nsStyleAutoArray. r=bholley (396812da9d)
- Bug 1264830 - Part 4: Change nsStyleDisplay::mWillChange to use nsTArray. r=bholley (7dead8570f)
- Bug 1264830 - Part 5: Require all style structs be memmovable. r=bholley (8fdd844d1c)
- Bug 1244628: compare nsStyleImageLayers::mAttachmentCount in nsStyleImageLayers::CalcDifference. r=dbaron. (11e2bb1665)
- Bug 1252739 - nsStyleImageLayers::HasLayerWithImage should return true when we have mask-image:<element-reference> | <gradient>; r=dbaron (904b65a0e5)
- cleanup empty line (8263e0793e)
- Bug 1261392 - Define gettid for all Linux builds. r=bgirard (781ae95acc)
1206 lines
43 KiB
C++
1206 lines
43 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/. */
|
|
|
|
/* rendering object for CSS display:inline objects */
|
|
|
|
#include "nsInlineFrame.h"
|
|
#include "nsLineLayout.h"
|
|
#include "nsBlockFrame.h"
|
|
#include "nsPlaceholderFrame.h"
|
|
#include "nsGkAtoms.h"
|
|
#include "nsStyleContext.h"
|
|
#include "nsPresContext.h"
|
|
#include "nsRenderingContext.h"
|
|
#include "nsCSSAnonBoxes.h"
|
|
#include "nsAutoPtr.h"
|
|
#include "mozilla/RestyleManagerHandle.h"
|
|
#include "mozilla/RestyleManagerHandleInlines.h"
|
|
#include "nsDisplayList.h"
|
|
#include "mozilla/Likely.h"
|
|
#include "SVGTextFrame.h"
|
|
#include "mozilla/StyleSetHandle.h"
|
|
#include "mozilla/StyleSetHandleInlines.h"
|
|
|
|
#ifdef DEBUG
|
|
#undef NOISY_PUSHING
|
|
#endif
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::layout;
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Basic nsInlineFrame methods
|
|
|
|
nsInlineFrame*
|
|
NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsInlineFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsInlineFrame)
|
|
|
|
NS_QUERYFRAME_HEAD(nsInlineFrame)
|
|
NS_QUERYFRAME_ENTRY(nsInlineFrame)
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
nsresult
|
|
nsInlineFrame::GetFrameName(nsAString& aResult) const
|
|
{
|
|
return MakeFrameName(NS_LITERAL_STRING("Inline"), aResult);
|
|
}
|
|
#endif
|
|
|
|
nsIAtom*
|
|
nsInlineFrame::GetType() const
|
|
{
|
|
return nsGkAtoms::inlineFrame;
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
{
|
|
if (IsSVGText()) {
|
|
nsIFrame* svgTextFrame =
|
|
nsLayoutUtils::GetClosestFrameOfType(GetParent(),
|
|
nsGkAtoms::svgTextFrame);
|
|
svgTextFrame->InvalidateFrame();
|
|
return;
|
|
}
|
|
nsContainerFrame::InvalidateFrame(aDisplayItemKey);
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
|
{
|
|
if (IsSVGText()) {
|
|
nsIFrame* svgTextFrame =
|
|
nsLayoutUtils::GetClosestFrameOfType(GetParent(),
|
|
nsGkAtoms::svgTextFrame);
|
|
svgTextFrame->InvalidateFrame();
|
|
return;
|
|
}
|
|
nsContainerFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
}
|
|
|
|
static inline bool
|
|
IsMarginZero(const nsStyleCoord &aCoord)
|
|
{
|
|
return aCoord.GetUnit() == eStyleUnit_Auto ||
|
|
nsLayoutUtils::IsMarginZero(aCoord);
|
|
}
|
|
|
|
/* virtual */ bool
|
|
nsInlineFrame::IsSelfEmpty()
|
|
{
|
|
#if 0
|
|
// I used to think inline frames worked this way, but it seems they
|
|
// don't. At least not in our codebase.
|
|
if (GetPresContext()->CompatibilityMode() == eCompatibility_FullStandards) {
|
|
return false;
|
|
}
|
|
#endif
|
|
const nsStyleMargin* margin = StyleMargin();
|
|
const nsStyleBorder* border = StyleBorder();
|
|
const nsStylePadding* padding = StylePadding();
|
|
// Block-start and -end ignored, since they shouldn't affect things, but this
|
|
// doesn't really match with nsLineLayout.cpp's setting of
|
|
// ZeroEffectiveSpanBox, anymore, so what should this really be?
|
|
WritingMode wm = GetWritingMode();
|
|
bool haveStart, haveEnd;
|
|
// Initially set up haveStart and haveEnd in terms of visual (LTR/TTB)
|
|
// coordinates; we'll exchange them later if bidi-RTL is in effect to
|
|
// get logical start and end flags.
|
|
if (wm.IsVertical()) {
|
|
haveStart =
|
|
border->GetComputedBorderWidth(NS_SIDE_TOP) != 0 ||
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetTop()) ||
|
|
!IsMarginZero(margin->mMargin.GetTop());
|
|
haveEnd =
|
|
border->GetComputedBorderWidth(NS_SIDE_BOTTOM) != 0 ||
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetBottom()) ||
|
|
!IsMarginZero(margin->mMargin.GetBottom());
|
|
} else {
|
|
haveStart =
|
|
border->GetComputedBorderWidth(NS_SIDE_LEFT) != 0 ||
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetLeft()) ||
|
|
!IsMarginZero(margin->mMargin.GetLeft());
|
|
haveEnd =
|
|
border->GetComputedBorderWidth(NS_SIDE_RIGHT) != 0 ||
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetRight()) ||
|
|
!IsMarginZero(margin->mMargin.GetRight());
|
|
}
|
|
if (haveStart || haveEnd) {
|
|
// We skip this block and return false for box-decoration-break:clone since
|
|
// in that case all the continuations will have the border/padding/margin.
|
|
if ((GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) &&
|
|
StyleBorder()->mBoxDecorationBreak ==
|
|
NS_STYLE_BOX_DECORATION_BREAK_SLICE) {
|
|
// When direction=rtl, we need to consider logical rather than visual
|
|
// start and end, so swap the flags.
|
|
if (!wm.IsBidiLTR()) {
|
|
Swap(haveStart, haveEnd);
|
|
}
|
|
// For ib-split frames, ignore things we know we'll skip in GetSkipSides.
|
|
// XXXbz should we be doing this for non-ib-split frames too, in a more
|
|
// general way?
|
|
|
|
// Get the first continuation eagerly, as a performance optimization, to
|
|
// avoid having to get it twice..
|
|
nsIFrame* firstCont = FirstContinuation();
|
|
return
|
|
(!haveStart || firstCont->FrameIsNonFirstInIBSplit()) &&
|
|
(!haveEnd || firstCont->FrameIsNonLastInIBSplit());
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
nsInlineFrame::IsEmpty()
|
|
{
|
|
if (!IsSelfEmpty()) {
|
|
return false;
|
|
}
|
|
|
|
for (nsIFrame* kid : mFrames) {
|
|
if (!kid->IsEmpty())
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
nsIFrame::FrameSearchResult
|
|
nsInlineFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
|
bool aRespectClusters)
|
|
{
|
|
// Override the implementation in nsFrame, to skip empty inline frames
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
|
int32_t startOffset = *aOffset;
|
|
if (startOffset < 0)
|
|
startOffset = 1;
|
|
if (aForward == (startOffset == 0)) {
|
|
// We're before the frame and moving forward, or after it and moving backwards:
|
|
// skip to the other side, but keep going.
|
|
*aOffset = 1 - startOffset;
|
|
}
|
|
return CONTINUE;
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|
{
|
|
nsFrameList* overflowFrames = GetOverflowFrames();
|
|
if (overflowFrames) {
|
|
// Fixup the parent pointers for any child frames on the OverflowList.
|
|
// nsIFrame::DestroyFrom depends on that to find the sticky scroll
|
|
// container (an ancestor).
|
|
nsIFrame* lineContainer = nsLayoutUtils::FindNearestBlockAncestor(this);
|
|
DrainSelfOverflowListInternal(eForDestroy, lineContainer);
|
|
}
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
|
}
|
|
|
|
nsresult
|
|
nsInlineFrame::StealFrame(nsIFrame* aChild,
|
|
bool aForceNormal)
|
|
{
|
|
if (aChild->HasAnyStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER) &&
|
|
!aForceNormal) {
|
|
return nsContainerFrame::StealFrame(aChild, aForceNormal);
|
|
}
|
|
|
|
nsInlineFrame* parent = this;
|
|
bool removed = false;
|
|
do {
|
|
removed = parent->mFrames.StartRemoveFrame(aChild);
|
|
if (removed) {
|
|
break;
|
|
}
|
|
|
|
// We didn't find the child in our principal child list.
|
|
// Maybe it's on the overflow list?
|
|
nsFrameList* frameList = parent->GetOverflowFrames();
|
|
if (frameList) {
|
|
removed = frameList->ContinueRemoveFrame(aChild);
|
|
if (frameList->IsEmpty()) {
|
|
parent->DestroyOverflowList();
|
|
}
|
|
if (removed) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Due to our "lazy reparenting" optimization 'aChild' might not actually
|
|
// be on any of our child lists, but instead in one of our next-in-flows.
|
|
parent = static_cast<nsInlineFrame*>(parent->GetNextInFlow());
|
|
} while (parent);
|
|
|
|
MOZ_ASSERT(removed, "nsInlineFrame::StealFrame: can't find aChild");
|
|
return removed ? NS_OK : NS_ERROR_UNEXPECTED;
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
const nsRect& aDirtyRect,
|
|
const nsDisplayListSet& aLists)
|
|
{
|
|
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
|
|
|
|
// The sole purpose of this is to trigger display of the selection
|
|
// window for Named Anchors, which don't have any children and
|
|
// normally don't have any size, but in Editor we use CSS to display
|
|
// an image to represent this "hidden" element.
|
|
if (!mFrames.FirstChild()) {
|
|
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Reflow methods
|
|
|
|
/* virtual */ void
|
|
nsInlineFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
|
|
nsIFrame::InlineMinISizeData *aData)
|
|
{
|
|
DoInlineIntrinsicISize(aRenderingContext, aData, nsLayoutUtils::MIN_ISIZE);
|
|
}
|
|
|
|
/* virtual */ void
|
|
nsInlineFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
|
|
nsIFrame::InlinePrefISizeData *aData)
|
|
{
|
|
DoInlineIntrinsicISize(aRenderingContext, aData, nsLayoutUtils::PREF_ISIZE);
|
|
}
|
|
|
|
/* virtual */
|
|
LogicalSize
|
|
nsInlineFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
|
WritingMode aWM,
|
|
const LogicalSize& aCBSize,
|
|
nscoord aAvailableISize,
|
|
const LogicalSize& aMargin,
|
|
const LogicalSize& aBorder,
|
|
const LogicalSize& aPadding,
|
|
ComputeSizeFlags aFlags)
|
|
{
|
|
// Inlines and text don't compute size before reflow.
|
|
return LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
}
|
|
|
|
nsRect
|
|
nsInlineFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const
|
|
{
|
|
// be conservative
|
|
if (StyleContext()->HasTextDecorationLines()) {
|
|
return GetVisualOverflowRect();
|
|
}
|
|
return ComputeSimpleTightBounds(aDrawTarget);
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer,
|
|
nsIFrame* aFrame,
|
|
bool aReparentSiblings)
|
|
{
|
|
// XXXbz this would be better if it took a nsFrameList or a frame
|
|
// list slice....
|
|
NS_ASSERTION(aOurLineContainer->GetNextContinuation() ||
|
|
aOurLineContainer->GetPrevContinuation(),
|
|
"Don't call this when we have no continuation, it's a waste");
|
|
if (!aFrame) {
|
|
NS_ASSERTION(aReparentSiblings, "Why did we get called?");
|
|
return;
|
|
}
|
|
|
|
nsBlockFrame* frameBlock = nsLayoutUtils::GetFloatContainingBlock(aFrame);
|
|
if (!frameBlock || frameBlock == aOurLineContainer) {
|
|
return;
|
|
}
|
|
|
|
nsBlockFrame* ourBlock = nsLayoutUtils::GetAsBlock(aOurLineContainer);
|
|
NS_ASSERTION(ourBlock, "Not a block, but broke vertically?");
|
|
|
|
while (true) {
|
|
ourBlock->ReparentFloats(aFrame, frameBlock, false);
|
|
|
|
if (!aReparentSiblings)
|
|
return;
|
|
nsIFrame* next = aFrame->GetNextSibling();
|
|
if (!next)
|
|
return;
|
|
if (next->GetParent() == aFrame->GetParent()) {
|
|
aFrame = next;
|
|
continue;
|
|
}
|
|
// This is paranoid and will hardly ever get hit ... but we can't actually
|
|
// trust that the frames in the sibling chain all have the same parent,
|
|
// because lazy reparenting may be going on. If we find a different
|
|
// parent we need to redo our analysis.
|
|
ReparentFloatsForInlineChild(aOurLineContainer, next, aReparentSiblings);
|
|
return;
|
|
}
|
|
}
|
|
|
|
static void
|
|
ReparentChildListStyle(nsPresContext* aPresContext,
|
|
const nsFrameList::Slice& aFrames,
|
|
nsIFrame* aParentFrame)
|
|
{
|
|
RestyleManagerHandle restyleManager = aPresContext->RestyleManager();
|
|
|
|
for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) {
|
|
NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage");
|
|
restyleManager->ReparentStyleContext(e.get());
|
|
nsLayoutUtils::MarkDescendantsDirty(e.get());
|
|
}
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::Reflow(nsPresContext* aPresContext,
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
const nsHTMLReflowState& aReflowState,
|
|
nsReflowStatus& aStatus)
|
|
{
|
|
MarkInReflow();
|
|
DO_GLOBAL_REFLOW_COUNT("nsInlineFrame");
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
|
if (nullptr == aReflowState.mLineLayout) {
|
|
NS_ERROR("must have non-null aReflowState.mLineLayout");
|
|
return;
|
|
}
|
|
if (IsFrameTreeTooDeep(aReflowState, aMetrics, aStatus)) {
|
|
return;
|
|
}
|
|
|
|
bool lazilySetParentPointer = false;
|
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->LineContainerFrame();
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow();
|
|
if (prevInFlow) {
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
prevInFlow->StealOverflowFrames());
|
|
if (prevOverflowFrames) {
|
|
// When pushing and pulling frames we need to check for whether any
|
|
// views need to be reparented.
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
this);
|
|
|
|
// Check if we should do the lazilySetParentPointer optimization.
|
|
// Only do it in simple cases where we're being reflowed for the
|
|
// first time, nothing (e.g. bidi resolution) has already given
|
|
// us children, and there's no next-in-flow, so all our frames
|
|
// will be taken from prevOverflowFrames.
|
|
if ((GetStateBits() & NS_FRAME_FIRST_REFLOW) && mFrames.IsEmpty() &&
|
|
!GetNextInFlow()) {
|
|
// If our child list is empty, just put the new frames into it.
|
|
// Note that we don't set the parent pointer for the new frames. Instead wait
|
|
// to do this until we actually reflow the frame. If the overflow list contains
|
|
// thousands of frames this is a big performance issue (see bug #5588)
|
|
mFrames.SetFrames(*prevOverflowFrames);
|
|
lazilySetParentPointer = true;
|
|
} else {
|
|
// Assign all floats to our block if necessary
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
prevOverflowFrames->FirstChild(),
|
|
true);
|
|
}
|
|
// Insert the new frames at the beginning of the child list
|
|
// and set their parent pointer
|
|
const nsFrameList::Slice& newFrames =
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
|
// If our prev in flow was under the first continuation of a first-line
|
|
// frame then we need to reparent the style contexts to remove the
|
|
// the special first-line styling. In the lazilySetParentPointer case
|
|
// we reparent the style contexts when we set their parents in
|
|
// nsInlineFrame::ReflowFrames and nsInlineFrame::ReflowInlineFrame.
|
|
if (aReflowState.mLineLayout->GetInFirstLine()) {
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
|
#ifdef DEBUG
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
|
// If it's our initial reflow, then we should not have an overflow list.
|
|
// However, add an assertion in case we get reflowed more than once with
|
|
// the initial reflow reason
|
|
nsFrameList* overflowFrames = GetOverflowFrames();
|
|
NS_ASSERTION(!overflowFrames || overflowFrames->IsEmpty(),
|
|
"overflow list is not empty for initial reflow");
|
|
}
|
|
#endif
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
|
DrainFlags flags =
|
|
lazilySetParentPointer ? eDontReparentFrames : DrainFlags(0);
|
|
if (aReflowState.mLineLayout->GetInFirstLine()) {
|
|
flags = DrainFlags(flags | eInFirstLine);
|
|
}
|
|
DrainSelfOverflowListInternal(flags, lineContainer);
|
|
}
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
// aReflowState)
|
|
InlineReflowState irs;
|
|
irs.mPrevFrame = nullptr;
|
|
irs.mLineContainer = lineContainer;
|
|
irs.mLineLayout = aReflowState.mLineLayout;
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
|
irs.mSetParentPointer = lazilySetParentPointer;
|
|
|
|
if (mFrames.IsEmpty()) {
|
|
// Try to pull over one frame before starting so that we know
|
|
// whether we have an anonymous block or not.
|
|
bool complete;
|
|
(void) PullOneFrame(aPresContext, irs, &complete);
|
|
}
|
|
|
|
ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
|
|
|
|
// Note: the line layout code will properly compute our
|
|
// overflow-rect state for us.
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
|
}
|
|
|
|
nsresult
|
|
nsInlineFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
nsIAtom* aAttribute,
|
|
int32_t aModType)
|
|
{
|
|
nsresult rv =
|
|
nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
return rv;
|
|
}
|
|
|
|
if (IsSVGText()) {
|
|
SVGTextFrame* f = static_cast<SVGTextFrame*>(
|
|
nsLayoutUtils::GetClosestFrameOfType(this, nsGkAtoms::svgTextFrame));
|
|
f->HandleAttributeChangeInDescendant(mContent->AsElement(),
|
|
aNameSpaceID, aAttribute);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
bool
|
|
nsInlineFrame::DrainSelfOverflowListInternal(DrainFlags aFlags,
|
|
nsIFrame* aLineContainer)
|
|
{
|
|
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
|
|
if (overflowFrames) {
|
|
// The frames on our own overflowlist may have been pushed by a
|
|
// previous lazilySetParentPointer Reflow so we need to ensure the
|
|
// correct parent pointer. This is sometimes skipped by Reflow.
|
|
if (!(aFlags & eDontReparentFrames)) {
|
|
nsIFrame* firstChild = overflowFrames->FirstChild();
|
|
if (aLineContainer && aLineContainer->GetPrevContinuation()) {
|
|
ReparentFloatsForInlineChild(aLineContainer, firstChild, true);
|
|
}
|
|
const bool doReparentSC =
|
|
(aFlags & eInFirstLine) && !(aFlags & eForDestroy);
|
|
RestyleManagerHandle restyleManager = PresContext()->RestyleManager();
|
|
for (nsIFrame* f = firstChild; f; f = f->GetNextSibling()) {
|
|
f->SetParent(this);
|
|
if (doReparentSC) {
|
|
restyleManager->ReparentStyleContext(f);
|
|
nsLayoutUtils::MarkDescendantsDirty(f);
|
|
}
|
|
}
|
|
}
|
|
bool result = !overflowFrames->IsEmpty();
|
|
mFrames.AppendFrames(nullptr, *overflowFrames);
|
|
return result;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* virtual */ bool
|
|
nsInlineFrame::DrainSelfOverflowList()
|
|
{
|
|
nsIFrame* lineContainer = nsLayoutUtils::FindNearestBlockAncestor(this);
|
|
// Add the eInFirstLine flag if we have a ::first-line ancestor frame.
|
|
// No need to look further than the nearest line container though.
|
|
DrainFlags flags = DrainFlags(0);
|
|
for (nsIFrame* p = GetParent(); p != lineContainer; p = p->GetParent()) {
|
|
if (p->GetType() == nsGkAtoms::lineFrame) {
|
|
flags = DrainFlags(flags | eInFirstLine);
|
|
break;
|
|
}
|
|
}
|
|
return DrainSelfOverflowListInternal(flags, lineContainer);
|
|
}
|
|
|
|
/* virtual */ bool
|
|
nsInlineFrame::CanContinueTextRun() const
|
|
{
|
|
// We can continue a text run through an inline frame
|
|
return true;
|
|
}
|
|
|
|
/* virtual */ void
|
|
nsInlineFrame::PullOverflowsFromPrevInFlow()
|
|
{
|
|
nsInlineFrame* prevInFlow = static_cast<nsInlineFrame*>(GetPrevInFlow());
|
|
if (prevInFlow) {
|
|
nsPresContext* presContext = PresContext();
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
prevInFlow->StealOverflowFrames());
|
|
if (prevOverflowFrames) {
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
this);
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
|
const nsHTMLReflowState& aReflowState,
|
|
InlineReflowState& irs,
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
nsReflowStatus& aStatus)
|
|
{
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
|
bool inFirstLine = aReflowState.mLineLayout->GetInFirstLine();
|
|
RestyleManagerHandle restyleManager = aPresContext->RestyleManager();
|
|
WritingMode frameWM = aReflowState.GetWritingMode();
|
|
WritingMode lineWM = aReflowState.mLineLayout->mRootSpan->mWritingMode;
|
|
LogicalMargin framePadding = aReflowState.ComputedLogicalBorderPadding();
|
|
nscoord startEdge = 0;
|
|
const bool boxDecorationBreakClone =
|
|
MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
|
NS_STYLE_BOX_DECORATION_BREAK_CLONE);
|
|
// Don't offset by our start borderpadding if we have a prev continuation or
|
|
// if we're in a part of an {ib} split other than the first one. For
|
|
// box-decoration-break:clone we always offset our start since all
|
|
// continuations have border/padding.
|
|
if ((!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) ||
|
|
boxDecorationBreakClone) {
|
|
startEdge = framePadding.IStart(frameWM);
|
|
}
|
|
nscoord availableISize = aReflowState.AvailableISize();
|
|
NS_ASSERTION(availableISize != NS_UNCONSTRAINEDSIZE,
|
|
"should no longer use available widths");
|
|
// Subtract off inline axis border+padding from availableISize
|
|
availableISize -= startEdge;
|
|
availableISize -= framePadding.IEnd(frameWM);
|
|
lineLayout->BeginSpan(this, &aReflowState, startEdge,
|
|
startEdge + availableISize, &mBaseline);
|
|
|
|
// First reflow our principal children.
|
|
nsIFrame* frame = mFrames.FirstChild();
|
|
bool done = false;
|
|
while (frame) {
|
|
// Check if we should lazily set the child frame's parent pointer.
|
|
if (irs.mSetParentPointer) {
|
|
bool havePrevBlock =
|
|
irs.mLineContainer && irs.mLineContainer->GetPrevContinuation();
|
|
nsIFrame* child = frame;
|
|
do {
|
|
// If our block is the first in flow, then any floats under the pulled
|
|
// frame must already belong to our block.
|
|
if (havePrevBlock) {
|
|
// This has to happen before we update frame's parent; we need to
|
|
// know frame's ancestry under its old block.
|
|
// The blockChildren.ContainsFrame check performed by
|
|
// ReparentFloatsForInlineChild here may be slow, but we can't
|
|
// easily avoid it because we don't know where 'frame' originally
|
|
// came from. If we really really have to optimize this we could
|
|
// cache whether frame->GetParent() is under its containing blocks
|
|
// overflowList or not.
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, child, false);
|
|
}
|
|
child->SetParent(this);
|
|
if (inFirstLine) {
|
|
restyleManager->ReparentStyleContext(child);
|
|
nsLayoutUtils::MarkDescendantsDirty(child);
|
|
}
|
|
// We also need to do the same for |frame|'s next-in-flows that are in
|
|
// the sibling list. Otherwise, if we reflow |frame| and it's complete
|
|
// we'll crash when trying to delete its next-in-flow.
|
|
// This scenario doesn't happen often, but it can happen.
|
|
nsIFrame* nextSibling = child->GetNextSibling();
|
|
child = child->GetNextInFlow();
|
|
if (MOZ_UNLIKELY(child)) {
|
|
while (child != nextSibling && nextSibling) {
|
|
nextSibling = nextSibling->GetNextSibling();
|
|
}
|
|
if (!nextSibling) {
|
|
child = nullptr;
|
|
}
|
|
}
|
|
MOZ_ASSERT(!child || mFrames.ContainsFrame(child));
|
|
} while (child);
|
|
|
|
// Fix the parent pointer for ::first-letter child frame next-in-flows,
|
|
// so nsFirstLetterFrame::Reflow can destroy them safely (bug 401042).
|
|
nsIFrame* realFrame = nsPlaceholderFrame::GetRealFrameFor(frame);
|
|
if (realFrame->GetType() == nsGkAtoms::letterFrame) {
|
|
nsIFrame* child = realFrame->PrincipalChildList().FirstChild();
|
|
if (child) {
|
|
NS_ASSERTION(child->GetType() == nsGkAtoms::textFrame,
|
|
"unexpected frame type");
|
|
nsIFrame* nextInFlow = child->GetNextInFlow();
|
|
for ( ; nextInFlow; nextInFlow = nextInFlow->GetNextInFlow()) {
|
|
NS_ASSERTION(nextInFlow->GetType() == nsGkAtoms::textFrame,
|
|
"unexpected frame type");
|
|
if (mFrames.ContainsFrame(nextInFlow)) {
|
|
nextInFlow->SetParent(this);
|
|
if (inFirstLine) {
|
|
restyleManager->ReparentStyleContext(nextInFlow);
|
|
nsLayoutUtils::MarkDescendantsDirty(nextInFlow);
|
|
}
|
|
}
|
|
else {
|
|
#ifdef DEBUG
|
|
// Once we find a next-in-flow that isn't ours none of the
|
|
// remaining next-in-flows should be either.
|
|
for ( ; nextInFlow; nextInFlow = nextInFlow->GetNextInFlow()) {
|
|
NS_ASSERTION(!mFrames.ContainsFrame(nextInFlow),
|
|
"unexpected letter frame flow");
|
|
}
|
|
#endif
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
MOZ_ASSERT(frame->GetParent() == this);
|
|
|
|
if (!done) {
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
|
done = NS_INLINE_IS_BREAK(aStatus) ||
|
|
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus));
|
|
if (done) {
|
|
if (!irs.mSetParentPointer) {
|
|
break;
|
|
}
|
|
// Keep reparenting the remaining siblings, but don't reflow them.
|
|
nsFrameList* pushedFrames = GetOverflowFrames();
|
|
if (pushedFrames && pushedFrames->FirstChild() == frame) {
|
|
// Don't bother if |frame| was pushed to our overflow list.
|
|
break;
|
|
}
|
|
} else {
|
|
irs.mPrevFrame = frame;
|
|
}
|
|
}
|
|
frame = frame->GetNextSibling();
|
|
}
|
|
|
|
// Attempt to pull frames from our next-in-flow until we can't
|
|
if (!done && GetNextInFlow()) {
|
|
while (true) {
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
bool isComplete;
|
|
if (!frame) { // Could be non-null if we pulled a first-letter frame and
|
|
// it created a continuation, since we don't push those.
|
|
frame = PullOneFrame(aPresContext, irs, &isComplete);
|
|
}
|
|
#ifdef NOISY_PUSHING
|
|
printf("%p pulled up %p\n", this, frame);
|
|
#endif
|
|
if (nullptr == frame) {
|
|
if (!isComplete) {
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
}
|
|
break;
|
|
}
|
|
ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
|
if (NS_INLINE_IS_BREAK(aStatus) ||
|
|
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus))) {
|
|
break;
|
|
}
|
|
irs.mPrevFrame = frame;
|
|
frame = frame->GetNextSibling();
|
|
}
|
|
}
|
|
|
|
NS_ASSERTION(!NS_FRAME_IS_COMPLETE(aStatus) || !GetOverflowFrames(),
|
|
"We can't be complete AND have overflow frames!");
|
|
|
|
// If after reflowing our children they take up no area then make
|
|
// sure that we don't either.
|
|
//
|
|
// Note: CSS demands that empty inline elements still affect the
|
|
// line-height calculations. However, continuations of an inline
|
|
// that are empty we force to empty so that things like collapsed
|
|
// whitespace in an inline element don't affect the line-height.
|
|
aMetrics.ISize(lineWM) = lineLayout->EndSpan(this);
|
|
|
|
// Compute final width.
|
|
|
|
// XXX Note that that the padding start and end are in the frame's
|
|
// writing mode, but the metrics' inline-size is in the line's
|
|
// writing mode. This makes sense if the line and frame are both
|
|
// vertical or both horizontal, but what should happen with
|
|
// orthogonal inlines?
|
|
|
|
// Make sure to not include our start border and padding if we have a prev
|
|
// continuation or if we're in a part of an {ib} split other than the first
|
|
// one. For box-decoration-break:clone we always include our start border
|
|
// and padding since all continuations have them.
|
|
if ((!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) ||
|
|
boxDecorationBreakClone) {
|
|
aMetrics.ISize(lineWM) += framePadding.IStart(frameWM);
|
|
}
|
|
|
|
/*
|
|
* We want to only apply the end border and padding if we're the last
|
|
* continuation and either not in an {ib} split or the last part of it. To
|
|
* be the last continuation we have to be complete (so that we won't get a
|
|
* next-in-flow) and have no non-fluid continuations on our continuation
|
|
* chain. For box-decoration-break:clone we always apply the end border and
|
|
* padding since all continuations have them.
|
|
*/
|
|
if ((NS_FRAME_IS_COMPLETE(aStatus) &&
|
|
!LastInFlow()->GetNextContinuation() &&
|
|
!FrameIsNonLastInIBSplit()) ||
|
|
boxDecorationBreakClone) {
|
|
aMetrics.ISize(lineWM) += framePadding.IEnd(frameWM);
|
|
}
|
|
|
|
nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics,
|
|
framePadding, lineWM, frameWM);
|
|
|
|
// For now our overflow area is zero. The real value will be
|
|
// computed in |nsLineLayout::RelativePositionFrames|.
|
|
aMetrics.mOverflowAreas.Clear();
|
|
|
|
#ifdef NOISY_FINAL_SIZE
|
|
ListTag(stdout);
|
|
printf(": metrics=%d,%d ascent=%d\n",
|
|
aMetrics.Width(), aMetrics.Height(), aMetrics.TopAscent());
|
|
#endif
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
|
|
const nsHTMLReflowState& aReflowState,
|
|
InlineReflowState& irs,
|
|
nsIFrame* aFrame,
|
|
nsReflowStatus& aStatus)
|
|
{
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
bool pushedFrame;
|
|
lineLayout->ReflowFrame(aFrame, aStatus, nullptr, pushedFrame);
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(aStatus)) {
|
|
if (aFrame != mFrames.FirstChild()) {
|
|
// Change break-before status into break-after since we have
|
|
// already placed at least one child frame. This preserves the
|
|
// break-type so that it can be propagated upward.
|
|
aStatus = NS_FRAME_NOT_COMPLETE |
|
|
NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER |
|
|
(aStatus & NS_INLINE_BREAK_TYPE_MASK);
|
|
PushFrames(aPresContext, aFrame, irs.mPrevFrame, irs);
|
|
}
|
|
else {
|
|
// Preserve reflow status when breaking-before our first child
|
|
// and propagate it upward without modification.
|
|
}
|
|
return;
|
|
}
|
|
|
|
// Create a next-in-flow if needed.
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
|
|
CreateNextInFlow(aFrame);
|
|
}
|
|
|
|
if (NS_INLINE_IS_BREAK_AFTER(aStatus)) {
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
if (nextFrame) {
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
|
}
|
|
else {
|
|
// We must return an incomplete status if there are more child
|
|
// frames remaining in a next-in-flow that follows this frame.
|
|
nsInlineFrame* nextInFlow = static_cast<nsInlineFrame*>(GetNextInFlow());
|
|
while (nextInFlow) {
|
|
if (nextInFlow->mFrames.NotEmpty()) {
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
|
break;
|
|
}
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus) && !reflowingFirstLetter) {
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
if (nextFrame) {
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
|
}
|
|
}
|
|
}
|
|
|
|
nsIFrame*
|
|
nsInlineFrame::PullOneFrame(nsPresContext* aPresContext,
|
|
InlineReflowState& irs,
|
|
bool* aIsComplete)
|
|
{
|
|
bool isComplete = true;
|
|
|
|
nsIFrame* frame = nullptr;
|
|
nsInlineFrame* nextInFlow = irs.mNextInFlow;
|
|
while (nextInFlow) {
|
|
frame = nextInFlow->mFrames.FirstChild();
|
|
if (!frame) {
|
|
// The nextInFlow's principal list has no frames, try its overflow list.
|
|
nsFrameList* overflowFrames = nextInFlow->GetOverflowFrames();
|
|
if (overflowFrames) {
|
|
frame = overflowFrames->RemoveFirstChild();
|
|
if (overflowFrames->IsEmpty()) {
|
|
// We're stealing the only frame - delete the overflow list.
|
|
nextInFlow->DestroyOverflowList();
|
|
} else {
|
|
// We leave the remaining frames on the overflow list (rather than
|
|
// putting them on nextInFlow's principal list) so we don't have to
|
|
// set up the parent for them.
|
|
}
|
|
// ReparentFloatsForInlineChild needs it to be on a child list -
|
|
// we remove it again below.
|
|
nextInFlow->mFrames.SetFrames(frame);
|
|
}
|
|
}
|
|
|
|
if (frame) {
|
|
// If our block has no next continuation, then any floats belonging to
|
|
// the pulled frame must belong to our block already. This check ensures
|
|
// we do no extra work in the common non-vertical-breaking case.
|
|
if (irs.mLineContainer && irs.mLineContainer->GetNextContinuation()) {
|
|
// The blockChildren.ContainsFrame check performed by
|
|
// ReparentFloatsForInlineChild will be fast because frame's ancestor
|
|
// will be the first child of its containing block.
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, frame, false);
|
|
}
|
|
nextInFlow->mFrames.RemoveFirstChild();
|
|
// nsFirstLineFrame::PullOneFrame calls ReparentStyleContext.
|
|
|
|
mFrames.InsertFrame(this, irs.mPrevFrame, frame);
|
|
isComplete = false;
|
|
if (irs.mLineLayout) {
|
|
irs.mLineLayout->SetDirtyNextLine();
|
|
}
|
|
nsContainerFrame::ReparentFrameView(frame, nextInFlow, this);
|
|
break;
|
|
}
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
|
irs.mNextInFlow = nextInFlow;
|
|
}
|
|
|
|
*aIsComplete = isComplete;
|
|
return frame;
|
|
}
|
|
|
|
void
|
|
nsInlineFrame::PushFrames(nsPresContext* aPresContext,
|
|
nsIFrame* aFromChild,
|
|
nsIFrame* aPrevSibling,
|
|
InlineReflowState& aState)
|
|
{
|
|
NS_PRECONDITION(aFromChild, "null pointer");
|
|
NS_PRECONDITION(aPrevSibling, "pushing first child");
|
|
NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
|
|
|
|
#ifdef NOISY_PUSHING
|
|
printf("%p pushing aFromChild %p, disconnecting from prev sib %p\n",
|
|
this, aFromChild, aPrevSibling);
|
|
#endif
|
|
|
|
// Add the frames to our overflow list (let our next in flow drain
|
|
// our overflow list when it is ready)
|
|
SetOverflowFrames(mFrames.RemoveFramesAfter(aPrevSibling));
|
|
if (aState.mLineLayout) {
|
|
aState.mLineLayout->SetDirtyNextLine();
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
nsIFrame::LogicalSides
|
|
nsInlineFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const
|
|
{
|
|
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
|
NS_STYLE_BOX_DECORATION_BREAK_CLONE)) {
|
|
return LogicalSides();
|
|
}
|
|
|
|
LogicalSides skip;
|
|
if (!IsFirst()) {
|
|
nsInlineFrame* prev = (nsInlineFrame*) GetPrevContinuation();
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
(prev && (prev->mRect.height || prev->mRect.width))) {
|
|
// Prev continuation is not empty therefore we don't render our start
|
|
// border edge.
|
|
skip |= eLogicalSideBitsIStart;
|
|
}
|
|
else {
|
|
// If the prev continuation is empty, then go ahead and let our start
|
|
// edge border render.
|
|
}
|
|
}
|
|
if (!IsLast()) {
|
|
nsInlineFrame* next = (nsInlineFrame*) GetNextContinuation();
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
(next && (next->mRect.height || next->mRect.width))) {
|
|
// Next continuation is not empty therefore we don't render our end
|
|
// border edge.
|
|
skip |= eLogicalSideBitsIEnd;
|
|
}
|
|
else {
|
|
// If the next continuation is empty, then go ahead and let our end
|
|
// edge border render.
|
|
}
|
|
}
|
|
|
|
if (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) {
|
|
// All but the last part of an {ib} split should skip the "end" side (as
|
|
// determined by this frame's direction) and all but the first part of such
|
|
// a split should skip the "start" side. But figuring out which part of
|
|
// the split we are involves getting our first continuation, which might be
|
|
// expensive. So don't bother if we already have the relevant bits set.
|
|
if (skip != LogicalSides(eLogicalSideBitsIBoth)) {
|
|
// We're missing one of the skip bits, so check whether we need to set it.
|
|
// Only get the first continuation once, as an optimization.
|
|
nsIFrame* firstContinuation = FirstContinuation();
|
|
if (firstContinuation->FrameIsNonLastInIBSplit()) {
|
|
skip |= eLogicalSideBitsIEnd;
|
|
}
|
|
if (firstContinuation->FrameIsNonFirstInIBSplit()) {
|
|
skip |= eLogicalSideBitsIStart;
|
|
}
|
|
}
|
|
}
|
|
|
|
return skip;
|
|
}
|
|
|
|
nscoord
|
|
nsInlineFrame::GetLogicalBaseline(mozilla::WritingMode aWritingMode) const
|
|
{
|
|
return mBaseline;
|
|
}
|
|
|
|
#ifdef ACCESSIBILITY
|
|
a11y::AccType
|
|
nsInlineFrame::AccessibleType()
|
|
{
|
|
// Broken image accessibles are created here, because layout
|
|
// replaces the image or image control frame with an inline frame
|
|
if (mContent->IsHTMLElement(nsGkAtoms::input)) // Broken <input type=image ... />
|
|
return a11y::eHTMLButtonType;
|
|
if (mContent->IsHTMLElement(nsGkAtoms::img)) // Create accessible for broken <img>
|
|
return a11y::eHyperTextType;
|
|
|
|
return a11y::eNoType;
|
|
}
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// nsLineFrame implementation
|
|
|
|
nsFirstLineFrame*
|
|
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
{
|
|
return new (aPresShell) nsFirstLineFrame(aContext);
|
|
}
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFirstLineFrame)
|
|
|
|
void
|
|
nsFirstLineFrame::Init(nsIContent* aContent,
|
|
nsContainerFrame* aParent,
|
|
nsIFrame* aPrevInFlow)
|
|
{
|
|
nsInlineFrame::Init(aContent, aParent, aPrevInFlow);
|
|
if (!aPrevInFlow) {
|
|
MOZ_ASSERT(StyleContext()->GetPseudo() == nsCSSPseudoElements::firstLine);
|
|
return;
|
|
}
|
|
|
|
// This frame is a continuation - fixup the style context if aPrevInFlow
|
|
// is the first-in-flow (the only one with a ::first-line pseudo).
|
|
if (aPrevInFlow->StyleContext()->GetPseudo() == nsCSSPseudoElements::firstLine) {
|
|
MOZ_ASSERT(FirstInFlow() == aPrevInFlow);
|
|
// Create a new style context that is a child of the parent
|
|
// style context thus removing the ::first-line style. This way
|
|
// we behave as if an anonymous (unstyled) span was the child
|
|
// of the parent frame.
|
|
nsStyleContext* parentContext = aParent->StyleContext();
|
|
RefPtr<nsStyleContext> newSC = PresContext()->StyleSet()->
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozLineFrame, parentContext);
|
|
SetStyleContext(newSC);
|
|
} else {
|
|
MOZ_ASSERT(FirstInFlow() != aPrevInFlow);
|
|
MOZ_ASSERT(aPrevInFlow->StyleContext()->GetPseudo() ==
|
|
nsCSSAnonBoxes::mozLineFrame);
|
|
}
|
|
}
|
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
nsresult
|
|
nsFirstLineFrame::GetFrameName(nsAString& aResult) const
|
|
{
|
|
return MakeFrameName(NS_LITERAL_STRING("Line"), aResult);
|
|
}
|
|
#endif
|
|
|
|
nsIAtom*
|
|
nsFirstLineFrame::GetType() const
|
|
{
|
|
return nsGkAtoms::lineFrame;
|
|
}
|
|
|
|
nsIFrame*
|
|
nsFirstLineFrame::PullOneFrame(nsPresContext* aPresContext, InlineReflowState& irs,
|
|
bool* aIsComplete)
|
|
{
|
|
nsIFrame* frame = nsInlineFrame::PullOneFrame(aPresContext, irs, aIsComplete);
|
|
if (frame && !GetPrevInFlow()) {
|
|
// We are a first-line frame. Fixup the child frames
|
|
// style-context that we just pulled.
|
|
NS_ASSERTION(frame->GetParent() == this, "Incorrect parent?");
|
|
aPresContext->RestyleManager()->ReparentStyleContext(frame);
|
|
nsLayoutUtils::MarkDescendantsDirty(frame);
|
|
}
|
|
return frame;
|
|
}
|
|
|
|
void
|
|
nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
const nsHTMLReflowState& aReflowState,
|
|
nsReflowStatus& aStatus)
|
|
{
|
|
MarkInReflow();
|
|
if (nullptr == aReflowState.mLineLayout) {
|
|
return; // XXX does this happen? why?
|
|
}
|
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->LineContainerFrame();
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)GetPrevInFlow();
|
|
if (prevInFlow) {
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
prevInFlow->StealOverflowFrames());
|
|
if (prevOverflowFrames) {
|
|
// Assign all floats to our block if necessary
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
prevOverflowFrames->FirstChild(),
|
|
true);
|
|
}
|
|
const nsFrameList::Slice& newFrames =
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
|
}
|
|
}
|
|
|
|
// It's also possible that we have an overflow list for ourselves.
|
|
DrainSelfOverflowList();
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
// aReflowState)
|
|
InlineReflowState irs;
|
|
irs.mPrevFrame = nullptr;
|
|
irs.mLineContainer = lineContainer;
|
|
irs.mLineLayout = aReflowState.mLineLayout;
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
|
|
|
bool wasEmpty = mFrames.IsEmpty();
|
|
if (wasEmpty) {
|
|
// Try to pull over one frame before starting so that we know
|
|
// whether we have an anonymous block or not.
|
|
bool complete;
|
|
PullOneFrame(aPresContext, irs, &complete);
|
|
}
|
|
|
|
if (nullptr == GetPrevInFlow()) {
|
|
// XXX This is pretty sick, but what we do here is to pull-up, in
|
|
// advance, all of the next-in-flows children. We re-resolve their
|
|
// style while we are at at it so that when we reflow they have
|
|
// the right style.
|
|
//
|
|
// All of this is so that text-runs reflow properly.
|
|
irs.mPrevFrame = mFrames.LastChild();
|
|
for (;;) {
|
|
bool complete;
|
|
nsIFrame* frame = PullOneFrame(aPresContext, irs, &complete);
|
|
if (!frame) {
|
|
break;
|
|
}
|
|
irs.mPrevFrame = frame;
|
|
}
|
|
irs.mPrevFrame = nullptr;
|
|
}
|
|
|
|
NS_ASSERTION(!aReflowState.mLineLayout->GetInFirstLine(),
|
|
"Nested first-line frames? BOGUS");
|
|
aReflowState.mLineLayout->SetInFirstLine(true);
|
|
ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
|
aReflowState.mLineLayout->SetInFirstLine(false);
|
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
|
|
|
|
// Note: the line layout code will properly compute our overflow state for us
|
|
}
|
|
|
|
/* virtual */ void
|
|
nsFirstLineFrame::PullOverflowsFromPrevInFlow()
|
|
{
|
|
nsFirstLineFrame* prevInFlow = static_cast<nsFirstLineFrame*>(GetPrevInFlow());
|
|
if (prevInFlow) {
|
|
nsPresContext* presContext = PresContext();
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
prevInFlow->StealOverflowFrames());
|
|
if (prevOverflowFrames) {
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
|
const nsFrameList::Slice& newFrames =
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
|
ReparentChildListStyle(presContext, newFrames, this);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* virtual */ bool
|
|
nsFirstLineFrame::DrainSelfOverflowList()
|
|
{
|
|
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
|
|
if (overflowFrames) {
|
|
bool result = !overflowFrames->IsEmpty();
|
|
const nsFrameList::Slice& newFrames =
|
|
mFrames.AppendFrames(nullptr, *overflowFrames);
|
|
ReparentChildListStyle(PresContext(), newFrames, this);
|
|
return result;
|
|
}
|
|
return false;
|
|
}
|