|
|
|
|
| 10 |
*/ |
10 |
*/ |
| 11 |
|
11 |
|
| 12 |
#include "mozilla/DebugOnly.h" |
12 |
#include "mozilla/DebugOnly.h" |
| 13 |
#include "mozilla/Likely.h" |
13 |
#include "mozilla/Likely.h" |
| 14 |
#include "mozilla/LinkedList.h" |
14 |
#include "mozilla/LinkedList.h" |
| 15 |
|
15 |
|
| 16 |
#include "nsCSSFrameConstructor.h" |
16 |
#include "nsCSSFrameConstructor.h" |
| 17 |
#include "nsAbsoluteContainingBlock.h" |
17 |
#include "nsAbsoluteContainingBlock.h" |
|
|
18 |
#include "nsBulletFrame.h" |
| 18 |
#include "nsCRT.h" |
19 |
#include "nsCRT.h" |
| 19 |
#include "nsIAtom.h" |
20 |
#include "nsIAtom.h" |
| 20 |
#include "nsIURL.h" |
21 |
#include "nsIURL.h" |
| 21 |
#include "nsHashtable.h" |
22 |
#include "nsHashtable.h" |
| 22 |
#include "nsIHTMLDocument.h" |
23 |
#include "nsIHTMLDocument.h" |
| 23 |
#include "nsIStyleRule.h" |
24 |
#include "nsIStyleRule.h" |
| 24 |
#include "nsIFrame.h" |
25 |
#include "nsIFrame.h" |
| 25 |
#include "nsGkAtoms.h" |
26 |
#include "nsGkAtoms.h" |
|
Lines 3150-3165
nsCSSFrameConstructor::ConstructFieldSetFrame(nsFrameConstructorState& aState,
|
Link Here
|
|---|
|
| 3150 |
newFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT); |
3151 |
newFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT); |
| 3151 |
|
3152 |
|
| 3152 |
// our new frame returned is the top frame which is the list frame. |
3153 |
// our new frame returned is the top frame which is the list frame. |
| 3153 |
*aNewFrame = newFrame; |
3154 |
*aNewFrame = newFrame; |
| 3154 |
|
3155 |
|
| 3155 |
return NS_OK; |
3156 |
return NS_OK; |
| 3156 |
} |
3157 |
} |
| 3157 |
|
3158 |
|
|
|
3159 |
nsresult |
| 3160 |
nsCSSFrameConstructor::ConstructDetailsFrame(nsFrameConstructorState& aState, |
| 3161 |
FrameConstructionItem& aItem, |
| 3162 |
nsIFrame* aParentFrame, |
| 3163 |
const nsStyleDisplay* aStyleDisplay, |
| 3164 |
nsFrameItems& aFrameItems, |
| 3165 |
nsIFrame** aNewFrame) |
| 3166 |
{ |
| 3167 |
nsIContent* const content = aItem.mContent; |
| 3168 |
nsStyleContext* const styleContext = aItem.mStyleContext; |
| 3169 |
|
| 3170 |
nsIFrame* newFrame = NS_NewDetailsFrame(mPresShell, styleContext); |
| 3171 |
InitAndRestoreFrame(aState, content, |
| 3172 |
aState.GetGeometricParent(aStyleDisplay, aParentFrame), |
| 3173 |
nullptr, newFrame); |
| 3174 |
|
| 3175 |
bool open = content->HasAttr(kNameSpaceID_None, nsGkAtoms::open); |
| 3176 |
|
| 3177 |
// Resolve style and create a frame for the first anonymous block child, |
| 3178 |
// which contains the <summary>. |
| 3179 |
nsRefPtr<nsStyleContext> summaryContentStyle; |
| 3180 |
summaryContentStyle = mPresShell->StyleSet()-> |
| 3181 |
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::summaryContent, styleContext); |
| 3182 |
|
| 3183 |
nsIFrame* summaryContentFrame = |
| 3184 |
NS_NewBlockFrame(mPresShell, summaryContentStyle, 0); |
| 3185 |
InitAndRestoreFrame(aState, content, newFrame, nullptr, summaryContentFrame); |
| 3186 |
|
| 3187 |
// Resolve style and create a frame for the second anonymous block child, |
| 3188 |
// which contains the remaining child content of the <details>. |
| 3189 |
nsRefPtr<nsStyleContext> detailsContentStyle; |
| 3190 |
detailsContentStyle = mPresShell->StyleSet()-> |
| 3191 |
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::detailsContent, styleContext); |
| 3192 |
|
| 3193 |
nsIFrame* detailsContentFrame = |
| 3194 |
NS_NewBlockFrame(mPresShell, detailsContentStyle, 0); |
| 3195 |
InitAndRestoreFrame(aState, content, newFrame, nullptr, detailsContentFrame); |
| 3196 |
|
| 3197 |
nsresult rv = aState.AddChild(newFrame, aFrameItems, content, styleContext, |
| 3198 |
aParentFrame); |
| 3199 |
if (NS_FAILED(rv)) { |
| 3200 |
return rv; |
| 3201 |
} |
| 3202 |
|
| 3203 |
nsFrameItems summaryContentItems; |
| 3204 |
nsFrameItems detailsContentItems; |
| 3205 |
|
| 3206 |
if (open) { |
| 3207 |
ProcessChildren(aState, content, styleContext, detailsContentFrame, true, |
| 3208 |
detailsContentItems, true, aItem.mPendingBinding); |
| 3209 |
for (nsFrameList::Enumerator e(detailsContentItems); !e.AtEnd(); e.Next()) { |
| 3210 |
nsIFrame* child = e.get(); |
| 3211 |
nsIAtom* type = child->GetContentInsertionFrame()->GetType(); |
| 3212 |
if (type == nsGkAtoms::summaryFrame) { |
| 3213 |
// Take out the first <summary> frame and put it as a child of the |
| 3214 |
// summary content frame. |
| 3215 |
detailsContentItems.RemoveFrame(child); |
| 3216 |
summaryContentItems.AppendFrame(summaryContentFrame, child); |
| 3217 |
break; |
| 3218 |
} |
| 3219 |
} |
| 3220 |
} else { |
| 3221 |
ProcessChildren(aState, content, styleContext, summaryContentFrame, true, |
| 3222 |
summaryContentItems, true, aItem.mPendingBinding); |
| 3223 |
} |
| 3224 |
|
| 3225 |
detailsContentFrame->SetInitialChildList(kPrincipalList, detailsContentItems); |
| 3226 |
summaryContentFrame->SetInitialChildList(kPrincipalList, summaryContentItems); |
| 3227 |
|
| 3228 |
nsFrameItems detailsItems; |
| 3229 |
detailsItems.AddChild(summaryContentFrame); |
| 3230 |
detailsItems.AddChild(detailsContentFrame); |
| 3231 |
|
| 3232 |
newFrame->SetInitialChildList(kPrincipalList, detailsItems); |
| 3233 |
|
| 3234 |
newFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT); |
| 3235 |
|
| 3236 |
*aNewFrame = newFrame; |
| 3237 |
|
| 3238 |
return NS_OK; |
| 3239 |
} |
| 3240 |
|
| 3158 |
static nsIFrame* |
3241 |
static nsIFrame* |
| 3159 |
FindAncestorWithGeneratedContentPseudo(nsIFrame* aFrame) |
3242 |
FindAncestorWithGeneratedContentPseudo(nsIFrame* aFrame) |
| 3160 |
{ |
3243 |
{ |
| 3161 |
for (nsIFrame* f = aFrame->GetParent(); f; f = f->GetParent()) { |
3244 |
for (nsIFrame* f = aFrame->GetParent(); f; f = f->GetParent()) { |
| 3162 |
NS_ASSERTION(f->IsGeneratedContentFrame(), |
3245 |
NS_ASSERTION(f->IsGeneratedContentFrame(), |
| 3163 |
"should not have exited generated content"); |
3246 |
"should not have exited generated content"); |
| 3164 |
nsIAtom* pseudo = f->GetStyleContext()->GetPseudo(); |
3247 |
nsIAtom* pseudo = f->GetStyleContext()->GetPseudo(); |
| 3165 |
if (pseudo == nsCSSPseudoElements::before || |
3248 |
if (pseudo == nsCSSPseudoElements::before || |
|
Lines 3323-3338
nsCSSFrameConstructor::FindHTMLData(Element* aElement,
|
Link Here
|
|---|
|
| 3323 |
return nullptr; |
3406 |
return nullptr; |
| 3324 |
} |
3407 |
} |
| 3325 |
|
3408 |
|
| 3326 |
NS_ASSERTION(!aParentFrame || |
3409 |
NS_ASSERTION(!aParentFrame || |
| 3327 |
aParentFrame->GetStyleContext()->GetPseudo() != |
3410 |
aParentFrame->GetStyleContext()->GetPseudo() != |
| 3328 |
nsCSSAnonBoxes::fieldsetContent || |
3411 |
nsCSSAnonBoxes::fieldsetContent || |
| 3329 |
aParentFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame, |
3412 |
aParentFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame, |
| 3330 |
"Unexpected parent for fieldset content anon box"); |
3413 |
"Unexpected parent for fieldset content anon box"); |
|
|
3414 |
|
| 3331 |
if (aTag == nsGkAtoms::legend && |
3415 |
if (aTag == nsGkAtoms::legend && |
| 3332 |
(!aParentFrame || |
3416 |
(!aParentFrame || |
| 3333 |
(aParentFrame->GetType() != nsGkAtoms::fieldSetFrame && |
3417 |
(aParentFrame->GetType() != nsGkAtoms::fieldSetFrame && |
| 3334 |
aParentFrame->GetStyleContext()->GetPseudo() != |
3418 |
aParentFrame->GetStyleContext()->GetPseudo() != |
| 3335 |
nsCSSAnonBoxes::fieldsetContent) || |
3419 |
nsCSSAnonBoxes::fieldsetContent) || |
| 3336 |
!aElement->GetParent() || |
3420 |
!aElement->GetParent() || |
| 3337 |
!aElement->GetParent()->IsHTML(nsGkAtoms::fieldset) || |
3421 |
!aElement->GetParent()->IsHTML(nsGkAtoms::fieldset) || |
| 3338 |
aStyleContext->GetStyleDisplay()->IsFloatingStyle() || |
3422 |
aStyleContext->GetStyleDisplay()->IsFloatingStyle() || |
|
Lines 3343-3358
nsCSSFrameConstructor::FindHTMLData(Element* aElement,
|
Link Here
|
|---|
|
| 3343 |
// not do special legend stuff. |
3427 |
// not do special legend stuff. |
| 3344 |
// XXXbz it would be nice if we could just decide this based on the parent |
3428 |
// XXXbz it would be nice if we could just decide this based on the parent |
| 3345 |
// tag, and hence just use a SIMPLE_TAG_CHAIN for legend below, but the |
3429 |
// tag, and hence just use a SIMPLE_TAG_CHAIN for legend below, but the |
| 3346 |
// fact that with XBL we could end up with this legend element in some |
3430 |
// fact that with XBL we could end up with this legend element in some |
| 3347 |
// totally weird insertion point makes that chancy, I think. |
3431 |
// totally weird insertion point makes that chancy, I think. |
| 3348 |
return nullptr; |
3432 |
return nullptr; |
| 3349 |
} |
3433 |
} |
| 3350 |
|
3434 |
|
|
|
3435 |
if (aTag == nsGkAtoms::summary && |
| 3436 |
(!aParentFrame || |
| 3437 |
aParentFrame->GetStyleContext()->GetPseudo() != |
| 3438 |
nsCSSAnonBoxes::detailsContent || |
| 3439 |
!aElement->GetParent() || |
| 3440 |
!aElement->GetParent()->IsHTML(nsGkAtoms::details))) { |
| 3441 |
// XXX comment. |
| 3442 |
return nullptr; |
| 3443 |
} |
| 3444 |
|
| 3351 |
static const FrameConstructionDataByTag sHTMLData[] = { |
3445 |
static const FrameConstructionDataByTag sHTMLData[] = { |
| 3352 |
SIMPLE_TAG_CHAIN(img, nsCSSFrameConstructor::FindImgData), |
3446 |
SIMPLE_TAG_CHAIN(img, nsCSSFrameConstructor::FindImgData), |
| 3353 |
SIMPLE_TAG_CHAIN(mozgeneratedcontentimage, |
3447 |
SIMPLE_TAG_CHAIN(mozgeneratedcontentimage, |
| 3354 |
nsCSSFrameConstructor::FindImgData), |
3448 |
nsCSSFrameConstructor::FindImgData), |
| 3355 |
{ &nsGkAtoms::br, |
3449 |
{ &nsGkAtoms::br, |
| 3356 |
FCDATA_DECL(FCDATA_IS_LINE_PARTICIPANT | FCDATA_IS_LINE_BREAK, |
3450 |
FCDATA_DECL(FCDATA_IS_LINE_PARTICIPANT | FCDATA_IS_LINE_BREAK, |
| 3357 |
NS_NewBRFrame) }, |
3451 |
NS_NewBRFrame) }, |
| 3358 |
SIMPLE_TAG_CREATE(wbr, NS_NewWBRFrame), |
3452 |
SIMPLE_TAG_CREATE(wbr, NS_NewWBRFrame), |
|
Lines 3374-3390
nsCSSFrameConstructor::FindHTMLData(Element* aElement,
|
Link Here
|
|---|
|
| 3374 |
NS_NewHTMLButtonControlFrame, |
3468 |
NS_NewHTMLButtonControlFrame, |
| 3375 |
nsCSSAnonBoxes::buttonContent) }, |
3469 |
nsCSSAnonBoxes::buttonContent) }, |
| 3376 |
SIMPLE_TAG_CHAIN(canvas, nsCSSFrameConstructor::FindCanvasData), |
3470 |
SIMPLE_TAG_CHAIN(canvas, nsCSSFrameConstructor::FindCanvasData), |
| 3377 |
#if defined(MOZ_MEDIA) |
3471 |
#if defined(MOZ_MEDIA) |
| 3378 |
SIMPLE_TAG_CREATE(video, NS_NewHTMLVideoFrame), |
3472 |
SIMPLE_TAG_CREATE(video, NS_NewHTMLVideoFrame), |
| 3379 |
SIMPLE_TAG_CREATE(audio, NS_NewHTMLVideoFrame), |
3473 |
SIMPLE_TAG_CREATE(audio, NS_NewHTMLVideoFrame), |
| 3380 |
#endif |
3474 |
#endif |
| 3381 |
SIMPLE_TAG_CREATE(progress, NS_NewProgressFrame), |
3475 |
SIMPLE_TAG_CREATE(progress, NS_NewProgressFrame), |
| 3382 |
SIMPLE_TAG_CREATE(meter, NS_NewMeterFrame) |
3476 |
SIMPLE_TAG_CREATE(meter, NS_NewMeterFrame), |
|
|
3477 |
COMPLEX_TAG_CREATE(details, &nsCSSFrameConstructor::ConstructDetailsFrame), |
| 3478 |
SIMPLE_TAG_CREATE(summary, NS_NewSummaryFrame) |
| 3383 |
}; |
3479 |
}; |
| 3384 |
|
3480 |
|
| 3385 |
return FindDataByTag(aTag, aElement, aStyleContext, sHTMLData, |
3481 |
return FindDataByTag(aTag, aElement, aStyleContext, sHTMLData, |
| 3386 |
ArrayLength(sHTMLData)); |
3482 |
ArrayLength(sHTMLData)); |
| 3387 |
} |
3483 |
} |
| 3388 |
|
3484 |
|
| 3389 |
/* static */ |
3485 |
/* static */ |
| 3390 |
const nsCSSFrameConstructor::FrameConstructionData* |
3486 |
const nsCSSFrameConstructor::FrameConstructionData* |
|
Lines 5064-5079
nsCSSFrameConstructor::AddFrameConstructionItems(nsFrameConstructorState& aState
|
Link Here
|
|---|
|
| 5064 |
return; |
5160 |
return; |
| 5065 |
} |
5161 |
} |
| 5066 |
|
5162 |
|
| 5067 |
// never create frames for comments or PIs |
5163 |
// never create frames for comments or PIs |
| 5068 |
if (aContent->IsNodeOfType(nsINode::eCOMMENT) || |
5164 |
if (aContent->IsNodeOfType(nsINode::eCOMMENT) || |
| 5069 |
aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) |
5165 |
aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) |
| 5070 |
return; |
5166 |
return; |
| 5071 |
|
5167 |
|
|
|
5168 |
// if we are creating a child of a <details> that is not open (which we |
| 5169 |
// know because we are constructing as a child of the summaryContentFrame |
| 5170 |
// anonymous block), then only create a frame for the first <summary> element, |
| 5171 |
// which we assume will be the only item in aItems if it has already been created |
| 5172 |
if (aParentFrame && |
| 5173 |
aParentFrame->GetStyleContext()->GetPseudo() == nsCSSAnonBoxes::summaryContent && |
| 5174 |
(!aContent->IsHTML(nsGkAtoms::summary) || |
| 5175 |
!aItems.IsEmpty())) { |
| 5176 |
return; |
| 5177 |
} |
| 5178 |
|
| 5072 |
nsRefPtr<nsStyleContext> styleContext; |
5179 |
nsRefPtr<nsStyleContext> styleContext; |
| 5073 |
styleContext = ResolveStyleContext(aParentFrame, aContent, &aState); |
5180 |
styleContext = ResolveStyleContext(aParentFrame, aContent, &aState); |
| 5074 |
|
5181 |
|
| 5075 |
AddFrameConstructionItemsInternal(aState, aContent, aParentFrame, |
5182 |
AddFrameConstructionItemsInternal(aState, aContent, aParentFrame, |
| 5076 |
aContent->Tag(), aContent->GetNameSpaceID(), |
5183 |
aContent->Tag(), aContent->GetNameSpaceID(), |
| 5077 |
aSuppressWhiteSpaceOptimizations, |
5184 |
aSuppressWhiteSpaceOptimizations, |
| 5078 |
styleContext, |
5185 |
styleContext, |
| 5079 |
ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK, |
5186 |
ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK, |
|
Lines 5907-5922
nsCSSFrameConstructor::IsValidSibling(nsIFrame* aSibling,
|
Link Here
|
|---|
|
| 5907 |
// Legends can be sibling of legends but not of other content in the fieldset |
6014 |
// Legends can be sibling of legends but not of other content in the fieldset |
| 5908 |
nsIAtom* sibType = aSibling->GetContentInsertionFrame()->GetType(); |
6015 |
nsIAtom* sibType = aSibling->GetContentInsertionFrame()->GetType(); |
| 5909 |
nsCOMPtr<nsIDOMHTMLLegendElement> legendContent(do_QueryInterface(aContent)); |
6016 |
nsCOMPtr<nsIDOMHTMLLegendElement> legendContent(do_QueryInterface(aContent)); |
| 5910 |
|
6017 |
|
| 5911 |
if ((legendContent && (nsGkAtoms::legendFrame != sibType)) || |
6018 |
if ((legendContent && (nsGkAtoms::legendFrame != sibType)) || |
| 5912 |
(!legendContent && (nsGkAtoms::legendFrame == sibType))) |
6019 |
(!legendContent && (nsGkAtoms::legendFrame == sibType))) |
| 5913 |
return false; |
6020 |
return false; |
| 5914 |
} |
6021 |
} |
|
|
6022 |
else if (grandparentType == nsGkAtoms::detailsFrame && |
| 6023 |
aSibling->GetType() == nsGkAtoms::summaryFrame) { |
| 6024 |
// A summary frame cannot be a sibling of anything |
| 6025 |
return false; |
| 6026 |
} |
| 5915 |
|
6027 |
|
| 5916 |
return true; |
6028 |
return true; |
| 5917 |
} |
6029 |
} |
| 5918 |
|
6030 |
|
| 5919 |
nsIFrame* |
6031 |
nsIFrame* |
| 5920 |
nsCSSFrameConstructor::FindFrameForContentSibling(nsIContent* aContent, |
6032 |
nsCSSFrameConstructor::FindFrameForContentSibling(nsIContent* aContent, |
| 5921 |
nsIContent* aTargetContent, |
6033 |
nsIContent* aTargetContent, |
| 5922 |
uint8_t& aTargetContentDisplay, |
6034 |
uint8_t& aTargetContentDisplay, |
|
Lines 6589-6605
nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
|
Link Here
|
|---|
|
| 6589 |
} |
6701 |
} |
| 6590 |
|
6702 |
|
| 6591 |
// Get continuation that parents the last child. This MUST be done |
6703 |
// Get continuation that parents the last child. This MUST be done |
| 6592 |
// before the AdjustAppendParentForAfterContent call. |
6704 |
// before the AdjustAppendParentForAfterContent call. |
| 6593 |
parentFrame = nsLayoutUtils::GetLastContinuationWithChild(parentFrame); |
6705 |
parentFrame = nsLayoutUtils::GetLastContinuationWithChild(parentFrame); |
| 6594 |
|
6706 |
|
| 6595 |
// We should never get here with fieldsets, since they have multiple |
6707 |
// We should never get here with fieldsets, since they have multiple |
| 6596 |
// insertion points. |
6708 |
// insertion points. |
| 6597 |
NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame, |
6709 |
NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame && |
|
|
6710 |
parentFrame->GetStyleContext()->GetPseudo() != |
| 6711 |
nsCSSAnonBoxes::detailsContent, |
| 6598 |
"Unexpected parent"); |
6712 |
"Unexpected parent"); |
| 6599 |
|
6713 |
|
| 6600 |
// Deal with possible :after generated content on the parent |
6714 |
// Deal with possible :after generated content on the parent |
| 6601 |
nsIFrame* parentAfterFrame; |
6715 |
nsIFrame* parentAfterFrame; |
| 6602 |
parentFrame = |
6716 |
parentFrame = |
| 6603 |
::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(), |
6717 |
::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(), |
| 6604 |
aContainer, parentFrame, |
6718 |
aContainer, parentFrame, |
| 6605 |
&parentAfterFrame); |
6719 |
&parentAfterFrame); |
|
Lines 6995-7024
nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
|
Link Here
|
|---|
|
| 6995 |
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild, |
7109 |
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild, |
| 6996 |
aAllowLazyConstruction); |
7110 |
aAllowLazyConstruction); |
| 6997 |
LAYOUT_PHASE_TEMP_REENTER(); |
7111 |
LAYOUT_PHASE_TEMP_REENTER(); |
| 6998 |
return NS_OK; |
7112 |
return NS_OK; |
| 6999 |
} |
7113 |
} |
| 7000 |
|
7114 |
|
| 7001 |
nsIContent* container = parentFrame->GetContent(); |
7115 |
nsIContent* container = parentFrame->GetContent(); |
| 7002 |
|
7116 |
|
| 7003 |
nsIAtom* frameType = parentFrame->GetType(); |
|
|
| 7004 |
LAYOUT_PHASE_TEMP_EXIT(); |
7117 |
LAYOUT_PHASE_TEMP_EXIT(); |
| 7005 |
if (MaybeRecreateForFrameset(parentFrame, aStartChild, aEndChild)) { |
7118 |
if (MaybeRecreateForFrameset(parentFrame, aStartChild, aEndChild)) { |
| 7006 |
LAYOUT_PHASE_TEMP_REENTER(); |
7119 |
LAYOUT_PHASE_TEMP_REENTER(); |
| 7007 |
return NS_OK; |
7120 |
return NS_OK; |
| 7008 |
} |
7121 |
} |
| 7009 |
LAYOUT_PHASE_TEMP_REENTER(); |
7122 |
LAYOUT_PHASE_TEMP_REENTER(); |
| 7010 |
|
7123 |
|
|
|
7124 |
nsIAtom* frameType = parentFrame->GetType(); |
| 7125 |
nsIAtom* framePseudo = parentFrame->GetStyleContext()->GetPseudo(); |
| 7126 |
|
| 7011 |
// We should only get here with fieldsets when doing a single insert, because |
7127 |
// We should only get here with fieldsets when doing a single insert, because |
| 7012 |
// fieldsets have multiple insertion points. |
7128 |
// fieldsets have multiple insertion points. |
| 7013 |
NS_ASSERTION(isSingleInsert || frameType != nsGkAtoms::fieldSetFrame, |
7129 |
NS_ASSERTION(isSingleInsert || |
|
|
7130 |
(frameType != nsGkAtoms::fieldSetFrame && |
| 7131 |
framePseudo != nsCSSAnonBoxes::detailsContent), |
| 7014 |
"Unexpected parent"); |
7132 |
"Unexpected parent"); |
| 7015 |
if (frameType == nsGkAtoms::fieldSetFrame && |
7133 |
if ((frameType == nsGkAtoms::fieldSetFrame && |
| 7016 |
aStartChild->Tag() == nsGkAtoms::legend) { |
7134 |
aStartChild->Tag() == nsGkAtoms::legend) || |
|
|
7135 |
(framePseudo == nsCSSAnonBoxes::detailsContent && |
| 7136 |
aStartChild->Tag() == nsGkAtoms::summary)) { |
| 7017 |
// Just reframe the parent, since figuring out whether this |
7137 |
// Just reframe the parent, since figuring out whether this |
| 7018 |
// should be the new legend and then handling it is too complex. |
7138 |
// should be the new legend and then handling it is too complex. |
| 7019 |
// We could do a little better here --- check if the fieldset already |
7139 |
// We could do a little better here --- check if the fieldset already |
| 7020 |
// has a legend which occurs earlier in its child list than this node, |
7140 |
// has a legend which occurs earlier in its child list than this node, |
| 7021 |
// and if so, proceed. But we'd have to extend nsFieldSetFrame |
7141 |
// and if so, proceed. But we'd have to extend nsFieldSetFrame |
| 7022 |
// to locate this legend in the inserted frames and extract it. |
7142 |
// to locate this legend in the inserted frames and extract it. |
| 7023 |
LAYOUT_PHASE_TEMP_EXIT(); |
7143 |
LAYOUT_PHASE_TEMP_EXIT(); |
| 7024 |
nsresult rv = RecreateFramesForContent(parentFrame->GetContent(), false); |
7144 |
nsresult rv = RecreateFramesForContent(parentFrame->GetContent(), false); |
|
Lines 7232-7248
nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
|
Link Here
|
|---|
|
| 7232 |
NS_ASSERTION(!IsFrameSpecial(frame1) && !IsFrameSpecial(frame2), |
7352 |
NS_ASSERTION(!IsFrameSpecial(frame1) && !IsFrameSpecial(frame2), |
| 7233 |
"Neither should be special"); |
7353 |
"Neither should be special"); |
| 7234 |
NS_ASSERTION((frame1->GetType() == nsGkAtoms::tableFrame && |
7354 |
NS_ASSERTION((frame1->GetType() == nsGkAtoms::tableFrame && |
| 7235 |
frame2->GetType() == nsGkAtoms::tableOuterFrame) || |
7355 |
frame2->GetType() == nsGkAtoms::tableOuterFrame) || |
| 7236 |
(frame1->GetType() == nsGkAtoms::tableOuterFrame && |
7356 |
(frame1->GetType() == nsGkAtoms::tableOuterFrame && |
| 7237 |
frame2->GetType() == nsGkAtoms::tableFrame) || |
7357 |
frame2->GetType() == nsGkAtoms::tableFrame) || |
| 7238 |
frame1->GetType() == nsGkAtoms::fieldSetFrame || |
7358 |
frame1->GetType() == nsGkAtoms::fieldSetFrame || |
| 7239 |
(frame1->GetParent() && |
7359 |
(frame1->GetParent() && |
| 7240 |
frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame), |
7360 |
frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame) || |
|
|
7361 |
frame1->GetType() == nsGkAtoms::detailsFrame || |
| 7362 |
(frame1->GetParent() && |
| 7363 |
frame1->GetParent()->GetType() == nsGkAtoms::detailsFrame), |
| 7241 |
"Unexpected frame types"); |
7364 |
"Unexpected frame types"); |
| 7242 |
#endif |
7365 |
#endif |
| 7243 |
isAppend = true; |
7366 |
isAppend = true; |
| 7244 |
nsIFrame* appendAfterFrame; |
7367 |
nsIFrame* appendAfterFrame; |
| 7245 |
parentFrame = |
7368 |
parentFrame = |
| 7246 |
::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(), |
7369 |
::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(), |
| 7247 |
container, |
7370 |
container, |
| 7248 |
frameItems.FirstChild()->GetParent(), |
7371 |
frameItems.FirstChild()->GetParent(), |
|
Lines 8314-8329
nsCSSFrameConstructor::RestyleElement(Element *aElement,
|
Link Here
|
|---|
|
| 8314 |
aRestyleTracker, aRestyleDescendants); |
8437 |
aRestyleTracker, aRestyleDescendants); |
| 8315 |
ProcessRestyledFrames(changeList, aTracker); |
8438 |
ProcessRestyledFrames(changeList, aTracker); |
| 8316 |
} else { |
8439 |
} else { |
| 8317 |
// no frames, reconstruct for content |
8440 |
// no frames, reconstruct for content |
| 8318 |
MaybeRecreateFramesForElement(aElement); |
8441 |
MaybeRecreateFramesForElement(aElement); |
| 8319 |
} |
8442 |
} |
| 8320 |
} |
8443 |
} |
| 8321 |
|
8444 |
|
|
|
8445 |
static void |
| 8446 |
UpdateHintToRepaintFrameIfThemed(nsPresContext* aPresContext, nsIFrame* aFrame, |
| 8447 |
nsChangeHint& aHint) |
| 8448 |
{ |
| 8449 |
uint8_t app = aFrame->GetStyleDisplay()->mAppearance; |
| 8450 |
if (app) { |
| 8451 |
nsITheme *theme = aPresContext->GetTheme(); |
| 8452 |
if (theme && theme->ThemeSupportsWidget(aPresContext, aFrame, app)) { |
| 8453 |
bool repaint = false; |
| 8454 |
theme->WidgetStateChanged(aFrame, app, nullptr, &repaint); |
| 8455 |
if (repaint) { |
| 8456 |
NS_UpdateHint(aHint, nsChangeHint_RepaintFrame); |
| 8457 |
} |
| 8458 |
} |
| 8459 |
} |
| 8460 |
} |
| 8461 |
|
| 8322 |
nsresult |
8462 |
nsresult |
| 8323 |
nsCSSFrameConstructor::ContentStateChanged(nsIContent* aContent, |
8463 |
nsCSSFrameConstructor::ContentStateChanged(nsIContent* aContent, |
| 8324 |
nsEventStates aStateMask) |
8464 |
nsEventStates aStateMask) |
| 8325 |
{ |
8465 |
{ |
| 8326 |
// XXXbz it would be good if this function only took Elements, but |
8466 |
// XXXbz it would be good if this function only took Elements, but |
| 8327 |
// we'd have to make ESM guarantee that usefully. |
8467 |
// we'd have to make ESM guarantee that usefully. |
| 8328 |
if (!aContent->IsElement()) { |
8468 |
if (!aContent->IsElement()) { |
| 8329 |
return NS_OK; |
8469 |
return NS_OK; |
|
Lines 8347-8371
nsCSSFrameConstructor::ContentStateChanged(nsIContent* aContent,
|
Link Here
|
|---|
|
| 8347 |
// If it's generated content, ignore LOADING/etc state changes on it. |
8487 |
// If it's generated content, ignore LOADING/etc state changes on it. |
| 8348 |
if (!primaryFrame->IsGeneratedContentFrame() && |
8488 |
if (!primaryFrame->IsGeneratedContentFrame() && |
| 8349 |
aStateMask.HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | |
8489 |
aStateMask.HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | |
| 8350 |
NS_EVENT_STATE_USERDISABLED | |
8490 |
NS_EVENT_STATE_USERDISABLED | |
| 8351 |
NS_EVENT_STATE_SUPPRESSED | |
8491 |
NS_EVENT_STATE_SUPPRESSED | |
| 8352 |
NS_EVENT_STATE_LOADING)) { |
8492 |
NS_EVENT_STATE_LOADING)) { |
| 8353 |
hint = nsChangeHint_ReconstructFrame; |
8493 |
hint = nsChangeHint_ReconstructFrame; |
| 8354 |
} else { |
8494 |
} else { |
| 8355 |
uint8_t app = primaryFrame->GetStyleDisplay()->mAppearance; |
8495 |
UpdateHintToRepaintFrameIfThemed(presContext, primaryFrame, hint); |
| 8356 |
if (app) { |
8496 |
|
| 8357 |
nsITheme *theme = presContext->GetTheme(); |
8497 |
// Special case for summary bullet, which is themed, while the summary |
| 8358 |
if (theme && theme->ThemeSupportsWidget(presContext, |
8498 |
// element itself is not. |
| 8359 |
primaryFrame, app)) { |
8499 |
if (aElement->IsHTML(nsGkAtoms::summary)) { |
| 8360 |
bool repaint = false; |
8500 |
nsBlockFrame* summaryFrame = nsLayoutUtils::GetAsBlock(primaryFrame); |
| 8361 |
theme->WidgetStateChanged(primaryFrame, app, nullptr, &repaint); |
8501 |
if (summaryFrame) { |
| 8362 |
if (repaint) { |
8502 |
nsIFrame* bullet = do_QueryFrame(summaryFrame->GetBullet()); |
| 8363 |
NS_UpdateHint(hint, nsChangeHint_RepaintFrame); |
8503 |
if (bullet) { |
|
|
8504 |
UpdateHintToRepaintFrameIfThemed(presContext, bullet, hint); |
| 8364 |
} |
8505 |
} |
| 8365 |
} |
8506 |
} |
| 8366 |
} |
8507 |
} |
| 8367 |
} |
8508 |
} |
| 8368 |
|
8509 |
|
| 8369 |
primaryFrame->ContentStatesChanged(aStateMask); |
8510 |
primaryFrame->ContentStatesChanged(aStateMask); |
| 8370 |
} |
8511 |
} |
| 8371 |
|
8512 |
|
|
Lines 8831-8846
nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
|
Link Here
|
|---|
|
| 8831 |
*aContinuingFrame = nullptr; |
8972 |
*aContinuingFrame = nullptr; |
| 8832 |
return rv; |
8973 |
return rv; |
| 8833 |
} |
8974 |
} |
| 8834 |
// Set the fieldset's initial child list |
8975 |
// Set the fieldset's initial child list |
| 8835 |
SetInitialSingleChild(newFrame, continuingBlockFrame); |
8976 |
SetInitialSingleChild(newFrame, continuingBlockFrame); |
| 8836 |
} else if (nsGkAtoms::legendFrame == frameType) { |
8977 |
} else if (nsGkAtoms::legendFrame == frameType) { |
| 8837 |
newFrame = NS_NewLegendFrame(shell, styleContext); |
8978 |
newFrame = NS_NewLegendFrame(shell, styleContext); |
| 8838 |
newFrame->Init(content, aParentFrame, aFrame); |
8979 |
newFrame->Init(content, aParentFrame, aFrame); |
|
|
8980 |
// } else if (nsGkAtoms::detailsFrame == frameType) { |
| 8981 |
// newFrame = NS_NewDetailsFrame(shell, styleContext); |
| 8982 |
// |
| 8983 |
// newFrame->Init(content, aParentFrame, aFrame); |
| 8984 |
// |
| 8985 |
// // Create a continuing area frame |
| 8986 |
// // XXXbz we really shouldn't have to do this by hand! |
| 8987 |
// nsIFrame* continuingBlockFrame; |
| 8988 |
// nsIFrame* blockFrame = GetFieldSetBlockFrame(aFrame); |
| 8989 |
// rv = CreateContinuingFrame(aPresContext, blockFrame, newFrame, |
| 8990 |
// &continuingBlockFrame); |
| 8991 |
// if (NS_FAILED(rv)) { |
| 8992 |
// newFrame->Destroy(); |
| 8993 |
// *aContinuingFrame = nullptr; |
| 8994 |
// return rv; |
| 8995 |
// } |
| 8996 |
// // Set the fieldset's initial child list |
| 8997 |
// SetInitialSingleChild(newFrame, continuingBlockFrame); |
| 8998 |
} else if (nsGkAtoms::summaryFrame == frameType) { |
| 8999 |
newFrame = NS_NewSummaryFrame(shell, styleContext); |
| 9000 |
newFrame->Init(content, aParentFrame, aFrame); |
| 8839 |
} else { |
9001 |
} else { |
| 8840 |
NS_NOTREACHED("unexpected frame type"); |
9002 |
NS_NOTREACHED("unexpected frame type"); |
| 8841 |
*aContinuingFrame = nullptr; |
9003 |
*aContinuingFrame = nullptr; |
| 8842 |
return NS_ERROR_UNEXPECTED; |
9004 |
return NS_ERROR_UNEXPECTED; |
| 8843 |
} |
9005 |
} |
| 8844 |
|
9006 |
|
| 8845 |
*aContinuingFrame = newFrame; |
9007 |
*aContinuingFrame = newFrame; |
| 8846 |
|
9008 |
|
|
Lines 8958-8974
nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame)
|
Link Here
|
|---|
|
| 8958 |
canvasFrame->SetInitialChildList(kPrincipalList, fixedPlaceholders); |
9120 |
canvasFrame->SetInitialChildList(kPrincipalList, fixedPlaceholders); |
| 8959 |
return NS_OK; |
9121 |
return NS_OK; |
| 8960 |
} |
9122 |
} |
| 8961 |
|
9123 |
|
| 8962 |
nsresult |
9124 |
nsresult |
| 8963 |
nsCSSFrameConstructor::GetInsertionPoint(nsIFrame* aParentFrame, |
9125 |
nsCSSFrameConstructor::GetInsertionPoint(nsIFrame* aParentFrame, |
| 8964 |
nsIContent* aChildContent, |
9126 |
nsIContent* aChildContent, |
| 8965 |
nsIFrame** aInsertionPoint, |
9127 |
nsIFrame** aInsertionPoint, |
| 8966 |
bool* aMultiple) |
9128 |
bool* aMultiple) |
| 8967 |
{ |
9129 |
{ |
| 8968 |
// Make the insertion point be the parent frame by default, in case |
9130 |
// Make the insertion point be the parent frame by default, in case |
| 8969 |
// we have to bail early. |
9131 |
// we have to bail early. |
| 8970 |
*aInsertionPoint = aParentFrame; |
9132 |
*aInsertionPoint = aParentFrame; |
| 8971 |
|
9133 |
|
| 8972 |
nsIContent* container = aParentFrame->GetContent(); |
9134 |
nsIContent* container = aParentFrame->GetContent(); |
| 8973 |
if (!container) |
9135 |
if (!container) |
| 8974 |
return NS_OK; |
9136 |
return NS_OK; |
|
Lines 9013-9029
nsCSSFrameConstructor::GetInsertionPoint(nsIFrame* aParentFrame,
|
Link Here
|
|---|
|
| 9013 |
*aInsertionPoint = nullptr; |
9175 |
*aInsertionPoint = nullptr; |
| 9014 |
} |
9176 |
} |
| 9015 |
} |
9177 |
} |
| 9016 |
|
9178 |
|
| 9017 |
// fieldsets have multiple insertion points. Note that we might |
9179 |
// fieldsets have multiple insertion points. Note that we might |
| 9018 |
// have to look at insertionElement here... |
9180 |
// have to look at insertionElement here... |
| 9019 |
if (aMultiple && !*aMultiple) { |
9181 |
if (aMultiple && !*aMultiple) { |
| 9020 |
nsIContent* content = insertionElement ? insertionElement : container; |
9182 |
nsIContent* content = insertionElement ? insertionElement : container; |
| 9021 |
if (content->IsHTML(nsGkAtoms::fieldset)) { |
9183 |
if (content->IsHTML(nsGkAtoms::fieldset) || |
|
|
9184 |
content->IsHTML(nsGkAtoms::details)) { |
| 9022 |
*aMultiple = true; |
9185 |
*aMultiple = true; |
| 9023 |
} |
9186 |
} |
| 9024 |
} |
9187 |
} |
| 9025 |
|
9188 |
|
| 9026 |
return NS_OK; |
9189 |
return NS_OK; |
| 9027 |
} |
9190 |
} |
| 9028 |
|
9191 |
|
| 9029 |
// Capture state for the frame tree rooted at the frame associated with the |
9192 |
// Capture state for the frame tree rooted at the frame associated with the |
|
Lines 9126-9145
nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
|
Link Here
|
|---|
|
| 9126 |
printf(" is special\n"); |
9289 |
printf(" is special\n"); |
| 9127 |
} |
9290 |
} |
| 9128 |
#endif |
9291 |
#endif |
| 9129 |
|
9292 |
|
| 9130 |
*aResult = ReframeContainingBlock(aFrame); |
9293 |
*aResult = ReframeContainingBlock(aFrame); |
| 9131 |
return true; |
9294 |
return true; |
| 9132 |
} |
9295 |
} |
| 9133 |
|
9296 |
|
| 9134 |
if (aFrame->GetContentInsertionFrame()->GetType() == nsGkAtoms::legendFrame && |
9297 |
if ((aFrame->GetContentInsertionFrame()->GetType() == nsGkAtoms::legendFrame && |
| 9135 |
aFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame) { |
9298 |
aFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame) || |
|
|
9299 |
(aFrame->GetContentInsertionFrame()->GetType() == nsGkAtoms::summaryFrame && |
| 9300 |
aFrame->GetParent()->GetStyleContext()->GetPseudo() == |
| 9301 |
nsCSSAnonBoxes::summaryContent)) { |
| 9136 |
// When we remove the legend for a fieldset, we should reframe |
9302 |
// When we remove the legend for a fieldset, we should reframe |
| 9137 |
// the fieldset to ensure another legend is used, if there is one |
9303 |
// the fieldset to ensure another legend is used, if there is one |
|
|
9304 |
// XXX same for details/summary |
| 9138 |
*aResult = RecreateFramesForContent(aFrame->GetParent()->GetContent(), false); |
9305 |
*aResult = RecreateFramesForContent(aFrame->GetParent()->GetContent(), false); |
| 9139 |
return true; |
9306 |
return true; |
| 9140 |
} |
9307 |
} |
| 9141 |
|
9308 |
|
| 9142 |
// Now check for possibly needing to reconstruct due to a pseudo parent |
9309 |
// Now check for possibly needing to reconstruct due to a pseudo parent |
| 9143 |
nsIFrame* inFlowFrame = |
9310 |
nsIFrame* inFlowFrame = |
| 9144 |
(aFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) ? |
9311 |
(aFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) ? |
| 9145 |
GetPlaceholderFrameFor(aFrame) : aFrame; |
9312 |
GetPlaceholderFrameFor(aFrame) : aFrame; |