Attachment #8392954: Rollup patch, including changes in bug 917313. (wdiff) for bug #907396

View | Details | Raw Unified | Return to bug 907396
Collapse All | Expand All

(-)mc.082761b7bc54/editor/libeditor/base/nsEditor.cpp (-2 / +2 lines)
Line     Link Here 
 Lines 3503-3526   IsElementVisible(dom::Element* aElement) Link Here 
3503
3503
3504
      // Otherwise, we might end up with a frame when that lazy bit is
3504
      // Otherwise, we might end up with a frame when that lazy bit is
3505
      // processed.  Figure out our actual style.
3505
      // processed.  Figure out our actual style.
3506
      break;
3506
      break;
3507
    }
3507
    }
3508
  }
3508
  }
3509
3509
3510
  // Now it might be that we have no frame because we're in a
3510
  // Now it might be that we have no frame because we're in a
3511
  // display:none subtree, or it might be that we're just dealing with
3511
  // display-box:none subtree, or it might be that we're just dealing with
3512
  // lazy frame construction and it hasn't happened yet.  Check which
3512
  // lazy frame construction and it hasn't happened yet.  Check which
3513
  // one it is.
3513
  // one it is.
3514
  nsRefPtr<nsStyleContext> styleContext =
3514
  nsRefPtr<nsStyleContext> styleContext =
3515
    nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement,
3515
    nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement,
3516
                                                         nullptr, nullptr);
3516
                                                         nullptr, nullptr);
3517
  if (styleContext) {
3517
  if (styleContext) {
3518
    return styleContext->StyleDisplay()->mDisplay != NS_STYLE_DISPLAY_NONE;
3518
    return styleContext->StyleDisplay()->mDisplayBox != NS_STYLE_DISPLAY_BOX_NONE;
3519
  }
3519
  }
3520
  return false;
3520
  return false;
3521
}
3521
}
3522
3522
3523
bool 
3523
bool 
3524
nsEditor::IsEditable(nsIDOMNode *aNode)
3524
nsEditor::IsEditable(nsIDOMNode *aNode)
3525
{
3525
{
3526
  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
3526
  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
(-)mc.082761b7bc54/layout/base/nsCSSFrameConstructor.cpp (-80 / +241 lines)
Line     Link Here 
 Lines 2384-2400   nsCSSFrameConstructor::ConstructDocEleme Link Here 
2384
2384
2385
#ifdef DEBUG
2385
#ifdef DEBUG
2386
  NS_ASSERTION(!display->IsScrollableOverflow() || 
2386
  NS_ASSERTION(!display->IsScrollableOverflow() || 
2387
               state.mPresContext->IsPaginated() ||
2387
               state.mPresContext->IsPaginated() ||
2388
               propagatedScrollFrom == aDocElement,
2388
               propagatedScrollFrom == aDocElement,
2389
               "Scrollbars should have been propagated to the viewport");
2389
               "Scrollbars should have been propagated to the viewport");
2390
#endif
2390
#endif
2391
2391
2392
  if (MOZ_UNLIKELY(display->mDisplay == NS_STYLE_DISPLAY_NONE)) {
2392
  if (MOZ_UNLIKELY(display->mDisplayBox == NS_STYLE_DISPLAY_BOX_NONE)) {
2393
    SetUndisplayedContent(aDocElement, styleContext);
2393
    SetUndisplayedContent(aDocElement, styleContext);
2394
    return nullptr;
2394
    return nullptr;
2395
  }
2395
  }
2396
2396
2397
  TreeMatchContext::AutoAncestorPusher ancestorPusher(state.mTreeMatchContext);
2397
  TreeMatchContext::AutoAncestorPusher ancestorPusher(state.mTreeMatchContext);
2398
  ancestorPusher.PushAncestorAndStyleScope(aDocElement);
2398
  ancestorPusher.PushAncestorAndStyleScope(aDocElement);
2399
2399
2400
  // Make sure to start any background image loads for the root element now.
2400
  // Make sure to start any background image loads for the root element now.
 Lines 2518-2534   nsCSSFrameConstructor::ConstructDocEleme Link Here 
2518
  NS_ASSERTION(processChildren ? !mRootElementFrame :
2518
  NS_ASSERTION(processChildren ? !mRootElementFrame :
2519
                 mRootElementFrame == contentFrame,
2519
                 mRootElementFrame == contentFrame,
2520
               "unexpected mRootElementFrame");
2520
               "unexpected mRootElementFrame");
2521
  mRootElementFrame = contentFrame;
2521
  mRootElementFrame = contentFrame;
2522
2522
2523
  // Figure out which frame has the main style for the document element,
2523
  // Figure out which frame has the main style for the document element,
2524
  // assigning it to mRootElementStyleFrame.
2524
  // assigning it to mRootElementStyleFrame.
2525
  // Backgrounds should be propagated from that frame to the viewport.
2525
  // Backgrounds should be propagated from that frame to the viewport.
2526
  mRootElementStyleFrame = contentFrame->GetParentStyleContextFrame();
2526
  contentFrame->GetParentStyleContext(&mRootElementStyleFrame);
2527
  bool isChild = mRootElementStyleFrame &&
2527
  bool isChild = mRootElementStyleFrame &&
2528
                 mRootElementStyleFrame->GetParent() == contentFrame;
2528
                 mRootElementStyleFrame->GetParent() == contentFrame;
2529
  if (!isChild) {
2529
  if (!isChild) {
2530
    mRootElementStyleFrame = mRootElementFrame;
2530
    mRootElementStyleFrame = mRootElementFrame;
2531
  }
2531
  }
2532
2532
2533
  if (processChildren) {
2533
  if (processChildren) {
2534
    // Still need to process the child content
2534
    // Still need to process the child content
 Lines 3325-3340   IsFrameForFieldSet(nsIFrame* aFrame, nsI Link Here 
3325
/* static */
3325
/* static */
3326
const nsCSSFrameConstructor::FrameConstructionData*
3326
const nsCSSFrameConstructor::FrameConstructionData*
3327
nsCSSFrameConstructor::FindHTMLData(Element* aElement,
3327
nsCSSFrameConstructor::FindHTMLData(Element* aElement,
3328
                                    nsIAtom* aTag,
3328
                                    nsIAtom* aTag,
3329
                                    int32_t aNameSpaceID,
3329
                                    int32_t aNameSpaceID,
3330
                                    nsIFrame* aParentFrame,
3330
                                    nsIFrame* aParentFrame,
3331
                                    nsStyleContext* aStyleContext)
3331
                                    nsStyleContext* aStyleContext)
3332
{
3332
{
3333
  MOZ_ASSERT(aStyleContext->StyleDisplay()->mDisplayBox != NS_STYLE_DISPLAY_BOX_NONE);
3334
3333
  // Ignore the tag if it's not HTML content and if it doesn't extend (via XBL)
3335
  // Ignore the tag if it's not HTML content and if it doesn't extend (via XBL)
3334
  // a valid HTML namespace.  This check must match the one in
3336
  // a valid HTML namespace.  This check must match the one in
3335
  // ShouldHaveFirstLineStyle.
3337
  // ShouldHaveFirstLineStyle.
3336
  if (aNameSpaceID != kNameSpaceID_XHTML) {
3338
  if (aNameSpaceID != kNameSpaceID_XHTML) {
3337
    return nullptr;
3339
    return nullptr;
3338
  }
3340
  }
3339
3341
3340
  NS_ASSERTION(!aParentFrame ||
3342
  NS_ASSERTION(!aParentFrame ||
 Lines 3570-3598   nsCSSFrameConstructor::ConstructFrameFro Link Here 
3570
3572
3571
  // Don't create a subdocument frame for iframes if we're creating extra frames
3573
  // Don't create a subdocument frame for iframes if we're creating extra frames
3572
  if (aState.mCreatingExtraFrames && aItem.mContent->IsHTML() &&
3574
  if (aState.mCreatingExtraFrames && aItem.mContent->IsHTML() &&
3573
      aItem.mContent->Tag() == nsGkAtoms::iframe)
3575
      aItem.mContent->Tag() == nsGkAtoms::iframe)
3574
  {
3576
  {
3575
    return;
3577
    return;
3576
  }
3578
  }
3577
3579
3578
  nsStyleContext* const styleContext = aItem.mStyleContext;
3579
  const nsStyleDisplay* display = styleContext->StyleDisplay();
3580
  nsIContent* const content = aItem.mContent;
3580
  nsIContent* const content = aItem.mContent;
3581
  nsIContent* parent = content->GetParent();
3582
3583
  // Push display-box:contents ancestors.
3584
  AutoDisplayBoxContentsAncestorPusher adcp(aState.mTreeMatchContext,
3585
                                            aState.mPresContext,
3586
                                            parent);
3581
3587
3582
  // Get the parent of the content and check if it is a XBL children element.
3588
  // Get the parent of the content and check if it is a XBL children element.
3583
  // Push the children element as an ancestor here because it does
3589
  // Push the children element as an ancestor here because it does
3584
  // not have a frame and would not otherwise be pushed as an ancestor. It is
3590
  // not have a frame and would not otherwise be pushed as an ancestor. It is
3585
  // necessary to do so in order to correctly handle style resolution on
3591
  // necessary to do so in order to correctly handle style resolution on
3586
  // descendants.
3592
  // descendants.
3587
  nsIContent* parent = content->GetParent();
3588
  TreeMatchContext::AutoAncestorPusher
3593
  TreeMatchContext::AutoAncestorPusher
3589
    insertionPointPusher(aState.mTreeMatchContext);
3594
    insertionPointPusher(aState.mTreeMatchContext);
3590
  if (parent && nsContentUtils::IsContentInsertionPoint(parent)) {
3595
  if (adcp.IsEmpty() && parent && nsContentUtils::IsContentInsertionPoint(parent)) {
3591
    if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3596
    if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3592
      insertionPointPusher.PushAncestorAndStyleScope(parent);
3597
      insertionPointPusher.PushAncestorAndStyleScope(parent);
3593
    } else {
3598
    } else {
3594
      insertionPointPusher.PushStyleScope(parent);
3599
      insertionPointPusher.PushStyleScope(parent);
3595
    }
3600
    }
3596
  }
3601
  }
3597
3602
3598
  // Push the content as a style ancestor now, so we don't have to do
3603
  // Push the content as a style ancestor now, so we don't have to do
 Lines 3608-3623   nsCSSFrameConstructor::ConstructFrameFro Link Here 
3608
  if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3613
  if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
3609
    ancestorPusher.PushAncestorAndStyleScope(content);
3614
    ancestorPusher.PushAncestorAndStyleScope(content);
3610
  } else {
3615
  } else {
3611
    ancestorPusher.PushStyleScope(content);
3616
    ancestorPusher.PushStyleScope(content);
3612
  }
3617
  }
3613
3618
3614
  nsIFrame* newFrame;
3619
  nsIFrame* newFrame;
3615
  nsIFrame* primaryFrame;
3620
  nsIFrame* primaryFrame;
3621
  nsStyleContext* const styleContext = aItem.mStyleContext;
3622
  const nsStyleDisplay* display = styleContext->StyleDisplay();
3616
  if (bits & FCDATA_FUNC_IS_FULL_CTOR) {
3623
  if (bits & FCDATA_FUNC_IS_FULL_CTOR) {
3617
    newFrame =
3624
    newFrame =
3618
      (this->*(data->mFullConstructor))(aState, aItem, aParentFrame,
3625
      (this->*(data->mFullConstructor))(aState, aItem, aParentFrame,
3619
                                        display, aFrameItems);
3626
                                        display, aFrameItems);
3620
    MOZ_ASSERT(newFrame, "Full constructor failed");
3627
    MOZ_ASSERT(newFrame, "Full constructor failed");
3621
    primaryFrame = newFrame;
3628
    primaryFrame = newFrame;
3622
  } else {
3629
  } else {
3623
    newFrame =
3630
    newFrame =
 Lines 4347-4370   nsCSSFrameConstructor::BuildScrollFrame( Link Here 
4347
4354
4348
const nsCSSFrameConstructor::FrameConstructionData*
4355
const nsCSSFrameConstructor::FrameConstructionData*
4349
nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay,
4356
nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay,
4350
                                       Element* aElement,
4357
                                       Element* aElement,
4351
                                       nsIFrame* aParentFrame,
4358
                                       nsIFrame* aParentFrame,
4352
                                       nsStyleContext* aStyleContext)
4359
                                       nsStyleContext* aStyleContext)
4353
{
4360
{
4354
  PR_STATIC_ASSERT(eParentTypeCount < (1 << (32 - FCDATA_PARENT_TYPE_OFFSET)));
4361
  PR_STATIC_ASSERT(eParentTypeCount < (1 << (32 - FCDATA_PARENT_TYPE_OFFSET)));
4362
  MOZ_ASSERT(aDisplay->mDisplayBox != NS_STYLE_DISPLAY_BOX_NONE);
4355
4363
4356
  // The style system ensures that floated and positioned frames are
4364
  // The style system ensures that floated and positioned frames are
4357
  // block-level.
4365
  // block-level.
4358
  NS_ASSERTION(!(aDisplay->IsFloatingStyle() ||
4366
  NS_ASSERTION(!(aDisplay->IsFloatingStyle() ||
4359
                 aDisplay->IsAbsolutelyPositionedStyle()) ||
4367
                 aDisplay->IsAbsolutelyPositionedStyle()) ||
4360
               aDisplay->IsBlockOutsideStyle(),
4368
               aDisplay->IsBlockOutsideStyle(),
4361
               "Style system did not apply CSS2.1 section 9.7 fixups");
4369
               "Style system did not apply CSS2.1 section 9.7 fixups");
4362
4370
4371
  if (aDisplay->mDisplayBox == NS_STYLE_DISPLAY_BOX_CONTENTS) {
4372
    // See the mDisplay/Box fixup code in nsRuleNode::ComputeDisplayData.
4373
    MOZ_ASSERT(!aElement->IsRootOfNativeAnonymousSubtree(),
4374
               "display-box:contents on anonymous content is unsupported");
4375
    static const FrameConstructionData sDisplayBoxContentsData =
4376
      FULL_CTOR_FCDATA(FCDATA_IS_CONTENTS, nullptr/*never called*/);
4377
    return &sDisplayBoxContentsData;
4378
  }
4379
4363
  // If this is "body", try propagating its scroll style to the viewport
4380
  // If this is "body", try propagating its scroll style to the viewport
4364
  // Note that we need to do this even if the body is NOT scrollable;
4381
  // Note that we need to do this even if the body is NOT scrollable;
4365
  // it might have dynamically changed from scrollable to not scrollable,
4382
  // it might have dynamically changed from scrollable to not scrollable,
4366
  // and that might need to be propagated.
4383
  // and that might need to be propagated.
4367
  // XXXbz is this the right place to do this?  If this code moves,
4384
  // XXXbz is this the right place to do this?  If this code moves,
4368
  // make this function static.
4385
  // make this function static.
4369
  bool propagatedScrollToViewport = false;
4386
  bool propagatedScrollToViewport = false;
4370
  if (aElement->IsHTML(nsGkAtoms::body)) {
4387
  if (aElement->IsHTML(nsGkAtoms::body)) {
 Lines 4578-4609   nsCSSFrameConstructor::InitAndRestoreFra Link Here 
4578
  }
4595
  }
4579
}
4596
}
4580
4597
4581
already_AddRefed<nsStyleContext>
4598
already_AddRefed<nsStyleContext>
4582
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*         aParentFrame,
4599
nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*         aParentFrame,
4583
                                           nsIContent*       aContent,
4600
                                           nsIContent*       aContent,
4584
                                           nsFrameConstructorState* aState)
4601
                                           nsFrameConstructorState* aState)
4585
{
4602
{
4586
  nsStyleContext* parentStyleContext = nullptr;
4603
  nsIContent* container = aContent->GetParent();
4587
  NS_ASSERTION(aContent->GetParent(), "Must have parent here");
4604
  NS_ASSERTION(container, "Must have parent here");
4588
4605
  nsStyleContext* parentStyleContext = GetDisplayBoxContentsStyleFor(container);
4606
  if (MOZ_LIKELY(!parentStyleContext)) {
4589
  aParentFrame = nsFrame::CorrectStyleParentFrame(aParentFrame, nullptr);
4607
  aParentFrame = nsFrame::CorrectStyleParentFrame(aParentFrame, nullptr);
4590
4591
  if (aParentFrame) {
4608
  if (aParentFrame) {
4592
    // Resolve the style context based on the content object and the parent
4609
    // Resolve the style context based on the content object and the parent
4593
    // style context
4610
    // style context
4594
    parentStyleContext = aParentFrame->StyleContext();
4611
    parentStyleContext = aParentFrame->StyleContext();
4595
  } else {
4612
  } else {
4596
    // Perhaps aParentFrame is a canvasFrame and we're replicating
4613
    // Perhaps aParentFrame is a canvasFrame and we're replicating
4597
    // fixed-pos frames.
4614
    // fixed-pos frames.
4598
    // XXX should we create a way to tell ConstructFrame which style
4615
    // XXX should we create a way to tell ConstructFrame which style
4599
    // context to use, and pass it the style context for the
4616
    // context to use, and pass it the style context for the
4600
    // previous page's fixed-pos frame?
4617
    // previous page's fixed-pos frame?
4601
  }
4618
  }
4619
  }
4602
4620
4603
  return ResolveStyleContext(parentStyleContext, aContent, aState);
4621
  return ResolveStyleContext(parentStyleContext, aContent, aState);
4604
}
4622
}
4605
4623
4606
already_AddRefed<nsStyleContext>
4624
already_AddRefed<nsStyleContext>
4607
nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
4625
nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
4608
                                           nsIContent* aContent,
4626
                                           nsIContent* aContent,
4609
                                           nsFrameConstructorState* aState)
4627
                                           nsFrameConstructorState* aState)
 Lines 5233-5251   nsCSSFrameConstructor::AddFrameConstruct Link Here 
5233
      aStyleContext = styleContext;
5251
      aStyleContext = styleContext;
5234
    }
5252
    }
5235
5253
5236
    aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID);
5254
    aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID);
5237
  }
5255
  }
5238
5256
5239
  bool isGeneratedContent = ((aFlags & ITEM_IS_GENERATED_CONTENT) != 0);
5257
  bool isGeneratedContent = ((aFlags & ITEM_IS_GENERATED_CONTENT) != 0);
5240
5258
5241
  // Pre-check for display "none" - if we find that, don't create
5259
  // Pre-check for display-box:none - if we find that, don't create any frame at all.
5242
  // any frame at all
5260
  if (NS_STYLE_DISPLAY_BOX_NONE == display->mDisplayBox) {
5243
  if (NS_STYLE_DISPLAY_NONE == display->mDisplay) {
5244
    SetAsUndisplayedContent(aItems, aContent, styleContext, isGeneratedContent);
5261
    SetAsUndisplayedContent(aItems, aContent, styleContext, isGeneratedContent);
5245
    return;
5262
    return;
5246
  }
5263
  }
5247
5264
5248
  bool isText = !aContent->IsElement();
5265
  bool isText = !aContent->IsElement();
5249
5266
5250
  // never create frames for non-option/optgroup kids of <select> and
5267
  // never create frames for non-option/optgroup kids of <select> and
5251
  // non-option kids of <optgroup> inside a <select>.
5268
  // non-option kids of <optgroup> inside a <select>.
 Lines 5360-5375   nsCSSFrameConstructor::AddFrameConstruct Link Here 
5360
    !display->IsAbsolutelyPositionedStyle() &&
5377
    !display->IsAbsolutelyPositionedStyle() &&
5361
    !(bits & FCDATA_IS_TABLE_PART) &&
5378
    !(bits & FCDATA_IS_TABLE_PART) &&
5362
    !(bits & FCDATA_IS_SVG_TEXT);
5379
    !(bits & FCDATA_IS_SVG_TEXT);
5363
5380
5364
  if (canHavePageBreak && display->mBreakBefore) {
5381
  if (canHavePageBreak && display->mBreakBefore) {
5365
    AddPageBreakItem(aContent, aStyleContext, aItems);
5382
    AddPageBreakItem(aContent, aStyleContext, aItems);
5366
  }
5383
  }
5367
5384
5385
  if (MOZ_UNLIKELY(bits & FCDATA_IS_CONTENTS)) {
5386
    if (!GetDisplayBoxContentsStyleFor(aContent)) {
5387
      if (styleContext->GetPseudo()) {
5388
        if (isGeneratedContent) {
5389
          aContent->UnbindFromTree();
5390
        }
5391
      } else {
5392
        MOZ_ASSERT(!isGeneratedContent, "Should have had pseudo type");
5393
        aState.mFrameManager->SetDisplayBoxContents(aContent, styleContext);
5394
      }
5395
    } else {
5396
      aState.mFrameManager->ChangeDisplayBoxContents(aContent, styleContext);
5397
    }
5398
5399
    TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
5400
    if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
5401
      ancestorPusher.PushAncestorAndStyleScope(aContent->AsElement());
5402
    } else {
5403
      ancestorPusher.PushStyleScope(aContent->AsElement());
5404
    }
5405
5406
    if (aParentFrame) {
5407
      aParentFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT);
5408
    }
5409
    CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext,
5410
                               nsCSSPseudoElements::ePseudo_before, aItems);
5411
5412
    FlattenedChildIterator iter(aContent);
5413
    for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
5414
      nsRefPtr<nsStyleContext> childContext =
5415
        ResolveStyleContext(styleContext, child, nullptr);
5416
      AddFrameConstructionItemsInternal(aState, child, aParentFrame,
5417
                                        child->Tag(), child->GetNameSpaceID(),
5418
                                        aSuppressWhiteSpaceOptimizations,
5419
                                        childContext, aFlags,
5420
                                        aAnonChildren, aItems);
5421
    }
5422
5423
    CreateGeneratedContentItem(aState, aParentFrame, aContent, styleContext,
5424
                               nsCSSPseudoElements::ePseudo_after, aItems);
5425
    if (canHavePageBreak && display->mBreakAfter) {
5426
      AddPageBreakItem(aContent, aStyleContext, aItems);
5427
    }
5428
    return;
5429
  }
5430
5368
  FrameConstructionItem* item =
5431
  FrameConstructionItem* item =
5369
    aItems.AppendItem(data, aContent, aTag, aNameSpaceID,
5432
    aItems.AppendItem(data, aContent, aTag, aNameSpaceID,
5370
                      pendingBinding, styleContext.forget(),
5433
                      pendingBinding, styleContext.forget(),
5371
                      aSuppressWhiteSpaceOptimizations, aAnonChildren);
5434
                      aSuppressWhiteSpaceOptimizations, aAnonChildren);
5372
  if (!item) {
5435
  if (!item) {
5373
    if (isGeneratedContent) {
5436
    if (isGeneratedContent) {
5374
      aContent->UnbindFromTree();
5437
      aContent->UnbindFromTree();
5375
    }
5438
    }
 Lines 5466-5499   nsCSSFrameConstructor::AddFrameConstruct Link Here 
5466
      ((bits & FCDATA_DISALLOW_OUT_OF_FLOW) ||
5529
      ((bits & FCDATA_DISALLOW_OUT_OF_FLOW) ||
5467
       !aState.GetGeometricParent(display, nullptr))) {
5530
       !aState.GetGeometricParent(display, nullptr))) {
5468
    item->mIsLineParticipant = true;
5531
    item->mIsLineParticipant = true;
5469
    aItems.LineParticipantItemAdded();
5532
    aItems.LineParticipantItemAdded();
5470
  }
5533
  }
5471
}
5534
}
5472
5535
5473
static void
5536
static void
5474
DestroyContent(void* aPropertyValue)
5537
AddGenConPseudoToFrame(nsIFrame* aOwnerFrame, nsIAtom* aPseudo,
5538
                       nsIContent* aContent)
5475
{
5539
{
5476
  nsIContent* content = static_cast<nsIContent*>(aPropertyValue);
5540
  typedef nsTArray<nsIContent*> T;
5477
  content->UnbindFromTree();
5541
  const FramePropertyDescriptor* prop = nsIFrame::GenConProperty();
5478
  NS_RELEASE(content);
5542
  FrameProperties props = aOwnerFrame->Properties();
5543
  T* value = static_cast<T*>(props.Get(prop));
5544
  if (!value) {
5545
    value = new T(2);
5546
    props.Set(prop, value);
5479
}
5547
}
5480
5548
  value->AppendElement(aContent);
5481
NS_DECLARE_FRAME_PROPERTY(BeforeProperty, DestroyContent)
5482
NS_DECLARE_FRAME_PROPERTY(AfterProperty, DestroyContent)
5483
5484
static const FramePropertyDescriptor*
5485
GenConPseudoToProperty(nsIAtom* aPseudo)
5486
{
5487
  NS_ASSERTION(aPseudo == nsCSSPseudoElements::before ||
5488
               aPseudo == nsCSSPseudoElements::after,
5489
               "Bad gen-con pseudo");
5490
  return aPseudo == nsCSSPseudoElements::before ? BeforeProperty()
5491
      : AfterProperty();
5492
}
5549
}
5493
5550
5494
/**
5551
/**
5495
 * Return true if the frame construction item pointed to by aIter will
5552
 * Return true if the frame construction item pointed to by aIter will
5496
 * create a frame adjacent to a line boundary in the frame tree, and that
5553
 * create a frame adjacent to a line boundary in the frame tree, and that
5497
 * line boundary is induced by a content node adjacent to the frame's
5554
 * line boundary is induced by a content node adjacent to the frame's
5498
 * content node in the content tree. The latter condition is necessary so
5555
 * content node in the content tree. The latter condition is necessary so
5499
 * that ContentAppended/ContentInserted/ContentRemoved can easily find any
5556
 * that ContentAppended/ContentInserted/ContentRemoved can easily find any
 Lines 5590-5606   nsCSSFrameConstructor::ConstructFramesFr Link Here 
5590
    // NS_FRAME_GENERATED_CONTENT.
5647
    // NS_FRAME_GENERATED_CONTENT.
5591
    aState.mAdditionalStateBits |= NS_FRAME_GENERATED_CONTENT;
5648
    aState.mAdditionalStateBits |= NS_FRAME_GENERATED_CONTENT;
5592
5649
5593
    // Note that we're not necessarily setting this property on the primary
5650
    // Note that we're not necessarily setting this property on the primary
5594
    // frame for the content for which this is generated content.  We might be
5651
    // frame for the content for which this is generated content.  We might be
5595
    // setting it on a table pseudo-frame inserted under that instead.  That's
5652
    // setting it on a table pseudo-frame inserted under that instead.  That's
5596
    // OK, though; we just need to do the property set so that the content will
5653
    // OK, though; we just need to do the property set so that the content will
5597
    // get cleaned up when the frame is destroyed.
5654
    // get cleaned up when the frame is destroyed.
5598
    aParentFrame->Properties().Set(GenConPseudoToProperty(styleContext->GetPseudo()),
5655
    ::AddGenConPseudoToFrame(aParentFrame, styleContext->GetPseudo(),
5599
                                   item.mContent);
5656
                                   item.mContent);
5600
5657
5601
    // Now that we've passed ownership of item.mContent to the frame, unset
5658
    // Now that we've passed ownership of item.mContent to the frame, unset
5602
    // our generated content flag so we don't release or unbind it ourselves.
5659
    // our generated content flag so we don't release or unbind it ourselves.
5603
    item.mIsGeneratedContent = false;
5660
    item.mIsGeneratedContent = false;
5604
  }
5661
  }
5605
5662
5606
  // XXXbz maybe just inline ConstructFrameFromItemInternal here or something?
5663
  // XXXbz maybe just inline ConstructFrameFromItemInternal here or something?
 Lines 5623-5652   nsCSSFrameConstructor::ReconstructDocEle Link Here 
5623
  if (!rootElement) {
5680
  if (!rootElement) {
5624
    /* nothing to do */
5681
    /* nothing to do */
5625
    return NS_OK;
5682
    return NS_OK;
5626
  }
5683
  }
5627
  return RecreateFramesForContent(rootElement, false);
5684
  return RecreateFramesForContent(rootElement, false);
5628
}
5685
}
5629
5686
5630
nsIFrame*
5687
nsIFrame*
5631
nsCSSFrameConstructor::GetFrameFor(nsIContent* aContent)
5688
nsCSSFrameConstructor::GetInsertionFrameFor(nsIContent* aContent)
5632
{
5689
{
5633
  // Get the primary frame associated with the content
5690
  // Get the primary frame associated with the content
5634
  nsIFrame* frame = aContent->GetPrimaryFrame();
5691
  nsIFrame* frame = aContent->GetPrimaryFrame();
5635
5692
5636
  if (!frame)
5693
  if (!frame) {
5694
    if (GetDisplayBoxContentsStyleFor(aContent)) {
5695
      nsIContent* parent = aContent->GetParent();
5696
      frame = parent ? GetInsertionFrameFor(parent) : nullptr;
5697
    }
5698
    if (!frame) {
5637
    return nullptr;
5699
    return nullptr;
5638
5700
    }
5701
  } else {
5639
  // If the content of the frame is not the desired content then this is not
5702
  // If the content of the frame is not the desired content then this is not
5640
  // really a frame for the desired content.
5703
  // really a frame for the desired content.
5641
  // XXX This check is needed due to bug 135040. Remove it once that's fixed.
5704
  // XXX This check is needed due to bug 135040. Remove it once that's fixed.
5642
  if (frame->GetContent() != aContent) {
5705
  if (frame->GetContent() != aContent) {
5643
    return nullptr;
5706
    return nullptr;
5644
  }
5707
  }
5708
  }
5645
5709
5646
  nsIFrame* insertionFrame = frame->GetContentInsertionFrame();
5710
  nsIFrame* insertionFrame = frame->GetContentInsertionFrame();
5647
5711
5648
  NS_ASSERTION(insertionFrame == frame || !frame->IsLeaf(),
5712
  NS_ASSERTION(insertionFrame == frame || !frame->IsLeaf(),
5649
    "The insertion frame is the primary frame or the primary frame isn't a leaf");
5713
    "The insertion frame is the primary frame or the primary frame isn't a leaf");
5650
5714
5651
  return insertionFrame;
5715
  return insertionFrame;
5652
}
5716
}
 Lines 5743-5773   nsCSSFrameConstructor::GetFloatContainin Link Here 
5743
5807
5744
/**
5808
/**
5745
 * This function will check whether aContainer has :after generated content.
5809
 * This function will check whether aContainer has :after generated content.
5746
 * If so, appending to it should actually insert.  The return value is the
5810
 * If so, appending to it should actually insert.  The return value is the
5747
 * parent to use for newly-appended content.  *aAfterFrame points to the :after
5811
 * parent to use for newly-appended content.  *aAfterFrame points to the :after
5748
 * frame before which appended content should go, if there is one.
5812
 * frame before which appended content should go, if there is one.
5749
 */
5813
 */
5750
static nsIFrame*
5814
static nsIFrame*
5751
AdjustAppendParentForAfterContent(nsPresContext* aPresContext,
5815
AdjustAppendParentForAfterContent(nsFrameManager* aFrameManager,
5752
                                  nsIContent* aContainer,
5816
                                  nsIContent* aContainer,
5753
                                  nsIFrame* aParentFrame,
5817
                                  nsIFrame* aParentFrame,
5818
                                  nsIContent* aChild,
5754
                                  nsIFrame** aAfterFrame)
5819
                                  nsIFrame** aAfterFrame)
5755
{
5820
{
5756
  // See if the parent has an :after pseudo-element.  Check for the presence
5821
  // If the parent frame has any pseudo-elements or aContainer is a
5757
  // of style first, since nsLayoutUtils::GetAfterFrame is sorta expensive.
5822
  // display-box:contents node then we need to walk through the child
5758
  nsStyleContext* parentStyle = aParentFrame->StyleContext();
5823
  // frames to find the first one that is either a ::after frame for an
5759
  if (nsLayoutUtils::HasPseudoStyle(aContainer, parentStyle,
5824
  // ancestor of aChild or a frame that is for a node later in the
5825
  // document than aChild and return that in aAfterFrame.
5826
  if (nsLayoutUtils::HasPseudoStyle(aContainer, aParentFrame->StyleContext(),
5760
                                    nsCSSPseudoElements::ePseudo_after,
5827
                                    nsCSSPseudoElements::ePseudo_after,
5761
                                    aPresContext)) {
5828
                                    aParentFrame->PresContext()) ||
5762
    // Ensure that the :after frame is on the principal child list.
5829
      aParentFrame->GetGenConPseudos() ||
5763
    aParentFrame->DrainSelfOverflowList();
5830
      aFrameManager->GetDisplayBoxContentsStyleFor(aContainer)) {
5831
    nsIFrame* afterFrame = nullptr;
5832
    nsIFrame* parent = aParentFrame->LastContinuation();
5833
    bool done = false;
5834
    while (!done && parent) {
5835
      // Ensure that all normal flow children are on the principal child list.
5836
      parent->DrainSelfOverflowList();
5837
5838
      nsIFrame* child = parent->GetLastChild(nsIFrame::kPrincipalList);
5839
      if (child && child->IsPseudoFrame(aContainer) &&
5840
          !child->IsGeneratedContentFrame()) {
5841
        // Drill down into non-generated pseudo frames of aContainer.
5842
        parent = nsLayoutUtils::LastContinuationWithChild(child);
5843
        continue;
5844
      }
5764
5845
5765
    nsIFrame* afterFrame = nsLayoutUtils::GetAfterFrame(aParentFrame);
5846
      for (; child; child = child->GetPrevSibling()) {
5847
        nsIContent* c = child->GetContent();
5848
        if (child->IsGeneratedContentFrame()) {
5849
          nsIContent* p = c->GetParent();
5850
          if (c->Tag() == nsGkAtoms::mozgeneratedcontentafter) {
5851
            if (!nsContentUtils::ContentIsDescendantOf(aChild, p) &&
5852
                (!c->IsInAnonymousSubtree() || c->GetBindingParent() != aContainer) &&
5853
                nsContentUtils::PositionIsBefore(p, aChild)) {
5854
              // ::after generated content for content earlier in the doc and not
5855
              // for an ancestor.
5856
              done = true;
5857
              break;
5858
            }
5859
          } else if (nsContentUtils::PositionIsBefore(p, aChild)) {
5860
            // Non-::after generated content for content earlier in the doc.
5861
            done = true;
5862
            break;
5863
          }
5864
        } else if (nsContentUtils::PositionIsBefore(c, aChild)) {
5865
          // Content is before aChild.
5866
          done = true;
5867
          break;
5868
        }
5869
        afterFrame = child;
5870
      }
5871
5872
      parent = parent->GetPrevContinuation();
5873
    }
5766
    if (afterFrame) {
5874
    if (afterFrame) {
5767
      *aAfterFrame = afterFrame;
5875
      *aAfterFrame = afterFrame;
5768
      return afterFrame->GetParent();
5876
      return afterFrame->GetParent();
5769
    }
5877
    }
5770
  }
5878
  }
5771
5879
5772
  *aAfterFrame = nullptr;
5880
  *aAfterFrame = nullptr;
5773
5881
 Lines 5950-5974   nsCSSFrameConstructor::IsValidSibling(ns Link Here 
5950
      (NS_STYLE_DISPLAY_TABLE_COLUMN       == siblingDisplay) ||
6058
      (NS_STYLE_DISPLAY_TABLE_COLUMN       == siblingDisplay) ||
5951
      (NS_STYLE_DISPLAY_TABLE_CAPTION      == siblingDisplay) ||
6059
      (NS_STYLE_DISPLAY_TABLE_CAPTION      == siblingDisplay) ||
5952
      (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == siblingDisplay) ||
6060
      (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == siblingDisplay) ||
5953
      (NS_STYLE_DISPLAY_TABLE_ROW_GROUP    == siblingDisplay) ||
6061
      (NS_STYLE_DISPLAY_TABLE_ROW_GROUP    == siblingDisplay) ||
5954
      (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == siblingDisplay) ||
6062
      (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == siblingDisplay) ||
5955
      nsGkAtoms::menuFrame == parentType) {
6063
      nsGkAtoms::menuFrame == parentType) {
5956
    // if we haven't already, construct a style context to find the display type of aContent
6064
    // if we haven't already, construct a style context to find the display type of aContent
5957
    if (UNSET_DISPLAY == aDisplay) {
6065
    if (UNSET_DISPLAY == aDisplay) {
5958
      nsRefPtr<nsStyleContext> styleContext;
6066
      nsIFrame* styleParent;
5959
      nsIFrame* styleParent = aSibling->GetParentStyleContextFrame();
6067
      aSibling->GetParentStyleContext(&styleParent);
6068
      if (!styleParent) {
6069
        styleParent = aSibling->GetParent();
6070
      }
5960
      if (!styleParent) {
6071
      if (!styleParent) {
5961
        NS_NOTREACHED("Shouldn't happen");
6072
        NS_NOTREACHED("Shouldn't happen");
5962
        return false;
6073
        return false;
5963
      }
6074
      }
5964
      // XXXbz when this code is killed, the state argument to
6075
      // XXXbz when this code is killed, the state argument to
5965
      // ResolveStyleContext can be made non-optional.
6076
      // ResolveStyleContext can be made non-optional.
5966
      styleContext = ResolveStyleContext(styleParent, aContent, nullptr);
6077
      nsRefPtr<nsStyleContext> styleContext =
6078
        ResolveStyleContext(styleParent, aContent, nullptr);
5967
      const nsStyleDisplay* display = styleContext->StyleDisplay();
6079
      const nsStyleDisplay* display = styleContext->StyleDisplay();
5968
      aDisplay = display->mDisplay;
6080
      aDisplay = display->mDisplay;
5969
    }
6081
    }
5970
    if (nsGkAtoms::menuFrame == parentType) {
6082
    if (nsGkAtoms::menuFrame == parentType) {
5971
      return
6083
      return
5972
        (NS_STYLE_DISPLAY_POPUP == aDisplay) ==
6084
        (NS_STYLE_DISPLAY_POPUP == aDisplay) ==
5973
        (NS_STYLE_DISPLAY_POPUP == siblingDisplay);
6085
        (NS_STYLE_DISPLAY_POPUP == siblingDisplay);
5974
    }
6086
    }
 Lines 6133-6149   nsCSSFrameConstructor::GetInsertionPrevS Link Here 
6133
  *aIsAppend = false;
6245
  *aIsAppend = false;
6134
6246
6135
  // Find the frame that precedes the insertion point. Walk backwards
6247
  // Find the frame that precedes the insertion point. Walk backwards
6136
  // from the parent frame to get the parent content, because if an
6248
  // from the parent frame to get the parent content, because if an
6137
  // XBL insertion point is involved, we'll need to use _that_ to find
6249
  // XBL insertion point is involved, we'll need to use _that_ to find
6138
  // the preceding frame.
6250
  // the preceding frame.
6139
6251
6140
  NS_PRECONDITION(aParentFrame, "Must have parent frame to start with");
6252
  NS_PRECONDITION(aParentFrame, "Must have parent frame to start with");
6141
  nsIContent* container = aParentFrame->GetContent();
6253
  const bool boxContents = GetDisplayBoxContentsStyleFor(aContainer);
6254
  nsIContent* container = boxContents ? aContainer : aParentFrame->GetContent();
6142
6255
6143
  FlattenedChildIterator iter(container);
6256
  FlattenedChildIterator iter(container);
6144
  bool xblCase = iter.XBLInvolved() || container != aContainer;
6257
  bool xblCase = iter.XBLInvolved() || container != aContainer;
6145
  if (xblCase || !aChild->IsRootOfAnonymousSubtree()) {
6258
  if (xblCase || !aChild->IsRootOfAnonymousSubtree()) {
6146
    // The check for IsRootOfAnonymousSubtree() is because editor is
6259
    // The check for IsRootOfAnonymousSubtree() is because editor is
6147
    // severely broken and calls us directly for native anonymous
6260
    // severely broken and calls us directly for native anonymous
6148
    // nodes that it creates.
6261
    // nodes that it creates.
6149
    if (aStartSkipChild) {
6262
    if (aStartSkipChild) {
 Lines 6163-6191   nsCSSFrameConstructor::GetInsertionPrevS Link Here 
6163
  uint8_t childDisplay = UNSET_DISPLAY;
6276
  uint8_t childDisplay = UNSET_DISPLAY;
6164
  nsIFrame* prevSibling = FindPreviousSibling(iter, childDisplay);
6277
  nsIFrame* prevSibling = FindPreviousSibling(iter, childDisplay);
6165
6278
6166
  // Now, find the geometric parent so that we can handle
6279
  // Now, find the geometric parent so that we can handle
6167
  // continuations properly. Use the prev sibling if we have it;
6280
  // continuations properly. Use the prev sibling if we have it;
6168
  // otherwise use the next sibling.
6281
  // otherwise use the next sibling.
6169
  if (prevSibling) {
6282
  if (prevSibling) {
6170
    aParentFrame = prevSibling->GetParent()->GetContentInsertionFrame();
6283
    aParentFrame = prevSibling->GetParent()->GetContentInsertionFrame();
6171
  }
6284
  } else {
6172
  else {
6173
    // If there is no previous sibling, then find the frame that follows
6285
    // If there is no previous sibling, then find the frame that follows
6174
    if (aEndSkipChild) {
6286
    if (aEndSkipChild) {
6175
      iter.Seek(aEndSkipChild);
6287
      iter.Seek(aEndSkipChild);
6176
      iter.GetPreviousChild();
6288
      iter.GetPreviousChild();
6177
    }
6289
    }
6178
    nsIFrame* nextSibling = FindNextSibling(iter, childDisplay);
6290
    nsIFrame* nextSibling = FindNextSibling(iter, childDisplay);
6179
6291
    if (boxContents) {
6180
    if (nextSibling) {
6292
    if (nextSibling) {
6181
      aParentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
6293
      aParentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
6294
        return nextSibling->GetPrevSibling();
6182
    }
6295
    }
6183
    else {
6296
      return GetInsertionPrevSibling(aParentFrame, aContainer->GetParent(),
6297
                                     aContainer, aIsAppend,
6298
                                     aIsRangeInsertSafe, nullptr, nullptr);
6299
    }
6300
    if (nextSibling) {
6301
      aParentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
6302
    } else {
6184
      // No previous or next sibling, so treat this like an appended frame.
6303
      // No previous or next sibling, so treat this like an appended frame.
6185
      *aIsAppend = true;
6304
      *aIsAppend = true;
6186
      if (IsFramePartOfIBSplit(aParentFrame)) {
6305
      if (IsFramePartOfIBSplit(aParentFrame)) {
6187
        // Since we're appending, we'll walk to the last anonymous frame
6306
        // Since we're appending, we'll walk to the last anonymous frame
6188
        // that was created for the broken inline frame.  But don't walk
6307
        // that was created for the broken inline frame.  But don't walk
6189
        // to the trailing inline if it's empty; stop at the block.
6308
        // to the trailing inline if it's empty; stop at the block.
6190
        aParentFrame = GetLastIBSplitSibling(aParentFrame, false);
6309
        aParentFrame = GetLastIBSplitSibling(aParentFrame, false);
6191
      }
6310
      }
 Lines 6193-6211   nsCSSFrameConstructor::GetInsertionPrevS Link Here 
6193
      // before the AdjustAppendParentForAfterContent call.
6312
      // before the AdjustAppendParentForAfterContent call.
6194
      aParentFrame = nsLayoutUtils::LastContinuationWithChild(aParentFrame);
6313
      aParentFrame = nsLayoutUtils::LastContinuationWithChild(aParentFrame);
6195
      // Deal with fieldsets
6314
      // Deal with fieldsets
6196
      aParentFrame = ::GetAdjustedParentFrame(aParentFrame,
6315
      aParentFrame = ::GetAdjustedParentFrame(aParentFrame,
6197
                                              aParentFrame->GetType(),
6316
                                              aParentFrame->GetType(),
6198
                                              aChild);
6317
                                              aChild);
6199
      nsIFrame* appendAfterFrame;
6318
      nsIFrame* appendAfterFrame;
6200
      aParentFrame =
6319
      aParentFrame =
6201
        ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
6320
        ::AdjustAppendParentForAfterContent(this, container, aParentFrame,
6202
                                            container, aParentFrame,
6321
                                            aChild, &appendAfterFrame);
6203
                                            &appendAfterFrame);
6204
      prevSibling = ::FindAppendPrevSibling(aParentFrame, appendAfterFrame);
6322
      prevSibling = ::FindAppendPrevSibling(aParentFrame, appendAfterFrame);
6205
    }
6323
    }
6206
  }
6324
  }
6207
6325
6208
  *aIsRangeInsertSafe = (childDisplay == UNSET_DISPLAY);
6326
  *aIsRangeInsertSafe = (childDisplay == UNSET_DISPLAY);
6209
  return prevSibling;
6327
  return prevSibling;
6210
}
6328
}
6211
6329
 Lines 6340-6355   nsCSSFrameConstructor::MaybeConstructLaz Link Here 
6340
    }
6458
    }
6341
    if (!noPrimaryFrame && !content->GetPrimaryFrame()) {
6459
    if (!noPrimaryFrame && !content->GetPrimaryFrame()) {
6342
      noPrimaryFrame = true;
6460
      noPrimaryFrame = true;
6343
    }
6461
    }
6344
    if (!needsFrameBitSet && content->HasFlag(NODE_NEEDS_FRAME)) {
6462
    if (!needsFrameBitSet && content->HasFlag(NODE_NEEDS_FRAME)) {
6345
      needsFrameBitSet = true;
6463
      needsFrameBitSet = true;
6346
    }
6464
    }
6347
#endif
6465
#endif
6466
    // XXX no lazy frames for display-box:contents descendants yet (bug 979782).
6467
    if (GetDisplayBoxContentsStyleFor(content)) {
6468
      return false;
6469
    }
6348
    content->SetFlags(NODE_DESCENDANTS_NEED_FRAMES);
6470
    content->SetFlags(NODE_DESCENDANTS_NEED_FRAMES);
6349
    content = content->GetFlattenedTreeParent();
6471
    content = content->GetFlattenedTreeParent();
6350
  }
6472
  }
6351
#ifdef DEBUG
6473
#ifdef DEBUG
6352
  if (content && content->GetPrimaryFrame() &&
6474
  if (content && content->GetPrimaryFrame() &&
6353
      content->GetPrimaryFrame()->IsLeaf()) {
6475
      content->GetPrimaryFrame()->IsLeaf()) {
6354
    noPrimaryFrame = needsFrameBitSet = false;
6476
    noPrimaryFrame = needsFrameBitSet = false;
6355
  }
6477
  }
 Lines 6462-6479   void Link Here 
6462
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
6584
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
6463
                                                    nsIContent* aStartChild,
6585
                                                    nsIContent* aStartChild,
6464
                                                    nsIContent* aEndChild,
6586
                                                    nsIContent* aEndChild,
6465
                                                    bool aAllowLazyConstruction)
6587
                                                    bool aAllowLazyConstruction)
6466
{
6588
{
6467
  for (nsIContent* child = aStartChild;
6589
  for (nsIContent* child = aStartChild;
6468
       child != aEndChild;
6590
       child != aEndChild;
6469
       child = child->GetNextSibling()) {
6591
       child = child->GetNextSibling()) {
6470
    if ((child->GetPrimaryFrame() ||
6592
    if ((child->GetPrimaryFrame() || GetUndisplayedContent(child) ||
6471
         GetUndisplayedContent(child))
6593
         GetDisplayBoxContentsStyleFor(child))
6472
#ifdef MOZ_XUL
6594
#ifdef MOZ_XUL
6473
        //  Except listboxes suck, so do NOT skip anything here if
6595
        //  Except listboxes suck, so do NOT skip anything here if
6474
        //  we plan to notify a listbox.
6596
        //  we plan to notify a listbox.
6475
        && !MaybeGetListBoxBodyFrame(aContainer, child)
6597
        && !MaybeGetListBoxBodyFrame(aContainer, child)
6476
#endif
6598
#endif
6477
        ) {
6599
        ) {
6478
      // Already have a frame or undisplayed entry for this content; a
6600
      // Already have a frame or undisplayed entry for this content; a
6479
      // previous ContentInserted in this loop must have reconstructed
6601
      // previous ContentInserted in this loop must have reconstructed
 Lines 6622-6638   nsCSSFrameConstructor::ContentAppended(n Link Here 
6622
    nsIContent* bindingParent = aContainer->GetBindingParent();
6744
    nsIContent* bindingParent = aContainer->GetBindingParent();
6623
    LAYOUT_PHASE_TEMP_EXIT();
6745
    LAYOUT_PHASE_TEMP_EXIT();
6624
    nsresult rv = RecreateFramesForContent(bindingParent, false);
6746
    nsresult rv = RecreateFramesForContent(bindingParent, false);
6625
    LAYOUT_PHASE_TEMP_REENTER();
6747
    LAYOUT_PHASE_TEMP_REENTER();
6626
    return rv;
6748
    return rv;
6627
  }
6749
  }
6628
6750
6629
  // Get the frame associated with the content
6751
  // Get the frame associated with the content
6630
  nsIFrame* parentFrame = GetFrameFor(aContainer);
6752
  nsIFrame* parentFrame = GetInsertionFrameFor(aContainer);
6631
6753
6632
  // See comment in ContentRangeInserted for why this is necessary.
6754
  // See comment in ContentRangeInserted for why this is necessary.
6633
  if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
6755
  if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
6634
    return NS_OK;
6756
    return NS_OK;
6635
  }
6757
  }
6636
6758
6637
  if (aAllowLazyConstruction &&
6759
  if (aAllowLazyConstruction &&
6638
      MaybeConstructLazily(CONTENTAPPEND, aContainer, aFirstNewContent)) {
6760
      MaybeConstructLazily(CONTENTAPPEND, aContainer, aFirstNewContent)) {
 Lines 6695-6713   nsCSSFrameConstructor::ContentAppended(n Link Here 
6695
  // We should never get here with fieldsets, since they have multiple
6817
  // We should never get here with fieldsets, since they have multiple
6696
  // insertion points.
6818
  // insertion points.
6697
  NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame,
6819
  NS_ASSERTION(parentFrame->GetType() != nsGkAtoms::fieldSetFrame,
6698
               "Unexpected parent");
6820
               "Unexpected parent");
6699
6821
6700
  // Deal with possible :after generated content on the parent
6822
  // Deal with possible :after generated content on the parent
6701
  nsIFrame* parentAfterFrame;
6823
  nsIFrame* parentAfterFrame;
6702
  parentFrame =
6824
  parentFrame =
6703
    ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
6825
    ::AdjustAppendParentForAfterContent(this, aContainer, parentFrame,
6704
                                        aContainer, parentFrame,
6826
                                        aFirstNewContent, &parentAfterFrame);
6705
                                        &parentAfterFrame);
6706
  
6827
  
6707
  // Create some new frames
6828
  // Create some new frames
6708
  nsFrameConstructorState state(mPresShell,
6829
  nsFrameConstructorState state(mPresShell,
6709
                                GetAbsoluteContainingBlock(parentFrame, FIXED_POS),
6830
                                GetAbsoluteContainingBlock(parentFrame, FIXED_POS),
6710
                                GetAbsoluteContainingBlock(parentFrame, ABS_POS),
6831
                                GetAbsoluteContainingBlock(parentFrame, ABS_POS),
6711
                                GetFloatContainingBlock(parentFrame));
6832
                                GetFloatContainingBlock(parentFrame));
6712
  state.mTreeMatchContext.InitAncestors(aContainer->AsElement());
6833
  state.mTreeMatchContext.InitAncestors(aContainer->AsElement());
6713
6834
 Lines 7055-7080   nsCSSFrameConstructor::ContentRangeInser Link Here 
7055
    // the children of the host.
7176
    // the children of the host.
7056
    nsIContent* bindingParent = aContainer->GetBindingParent();
7177
    nsIContent* bindingParent = aContainer->GetBindingParent();
7057
    LAYOUT_PHASE_TEMP_EXIT();
7178
    LAYOUT_PHASE_TEMP_EXIT();
7058
    nsresult rv = RecreateFramesForContent(bindingParent, false);
7179
    nsresult rv = RecreateFramesForContent(bindingParent, false);
7059
    LAYOUT_PHASE_TEMP_REENTER();
7180
    LAYOUT_PHASE_TEMP_REENTER();
7060
    return rv;
7181
    return rv;
7061
  }
7182
  }
7062
7183
7063
  nsIFrame* parentFrame = GetFrameFor(aContainer);
7184
  nsIFrame* parentFrame = GetInsertionFrameFor(aContainer);
7064
  // The xbl:children element won't have a frame, but default content can have the children as
7185
  // The xbl:children element won't have a frame, but default content can have the children as
7065
  // a parent. While its uncommon to change the structure of the default content itself, a label,
7186
  // a parent. While its uncommon to change the structure of the default content itself, a label,
7066
  // for example, can be reframed by having its value attribute set or removed.
7187
  // for example, can be reframed by having its value attribute set or removed.
7067
  if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
7188
  if (!parentFrame && !aContainer->IsActiveChildrenElement()) {
7068
    return NS_OK;
7189
    return NS_OK;
7069
  }
7190
  }
7070
7191
7071
  // Otherwise, we've got parent content. Find its frame.
7192
  // Otherwise, we've got parent content. Find its frame.
7072
  NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer, "New XBL code is possibly wrong!");
7193
  NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer ||
7194
               GetDisplayBoxContentsStyleFor(aContainer), "New XBL code is possibly wrong!");
7073
7195
7074
  if (aAllowLazyConstruction &&
7196
  if (aAllowLazyConstruction &&
7075
      MaybeConstructLazily(CONTENTINSERT, aContainer, aStartChild)) {
7197
      MaybeConstructLazily(CONTENTINSERT, aContainer, aStartChild)) {
7076
    return NS_OK;
7198
    return NS_OK;
7077
  }
7199
  }
7078
7200
7079
  if (isSingleInsert) {
7201
  if (isSingleInsert) {
7080
    // See if we have an XBL insertion point. If so, then that's our
7202
    // See if we have an XBL insertion point. If so, then that's our
 Lines 7351-7370   nsCSSFrameConstructor::ContentRangeInser Link Here 
7351
                 frame1->GetType() == nsGkAtoms::fieldSetFrame ||
7473
                 frame1->GetType() == nsGkAtoms::fieldSetFrame ||
7352
                 (frame1->GetParent() &&
7474
                 (frame1->GetParent() &&
7353
                  frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame),
7475
                  frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame),
7354
                 "Unexpected frame types");
7476
                 "Unexpected frame types");
7355
#endif
7477
#endif
7356
    isAppend = true;
7478
    isAppend = true;
7357
    nsIFrame* appendAfterFrame;
7479
    nsIFrame* appendAfterFrame;
7358
    parentFrame =
7480
    parentFrame =
7359
      ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
7481
      ::AdjustAppendParentForAfterContent(this, container,
7360
                                          container,
7361
                                          frameItems.FirstChild()->GetParent(),
7482
                                          frameItems.FirstChild()->GetParent(),
7362
                                          &appendAfterFrame);
7483
                                          aStartChild, &appendAfterFrame);
7363
    prevSibling = ::FindAppendPrevSibling(parentFrame, appendAfterFrame);
7484
    prevSibling = ::FindAppendPrevSibling(parentFrame, appendAfterFrame);
7364
  }
7485
  }
7365
7486
7366
  if (haveFirstLineStyle && parentFrame == containingBlock) {
7487
  if (haveFirstLineStyle && parentFrame == containingBlock) {
7367
    // It's possible that the new frame goes into a first-line
7488
    // It's possible that the new frame goes into a first-line
7368
    // frame. Look at it and see...
7489
    // frame. Look at it and see...
7369
    if (isAppend) {
7490
    if (isAppend) {
7370
      // Use append logic when appending
7491
      // Use append logic when appending
 Lines 7494-7521   nsCSSFrameConstructor::ContentRemoved(ns Link Here 
7494
           static_cast<void*>(aChild),
7615
           static_cast<void*>(aChild),
7495
           static_cast<void*>(aOldNextSibling));
7616
           static_cast<void*>(aOldNextSibling));
7496
    if (gReallyNoisyContentUpdates) {
7617
    if (gReallyNoisyContentUpdates) {
7497
      aContainer->List(stdout, 0);
7618
      aContainer->List(stdout, 0);
7498
    }
7619
    }
7499
  }
7620
  }
7500
#endif
7621
#endif
7501
7622
7502
  nsPresContext *presContext = mPresShell->GetPresContext();
7503
  nsresult                  rv = NS_OK;
7623
  nsresult                  rv = NS_OK;
7504
7505
  // Find the child frame that maps the content
7506
  nsIFrame* childFrame = aChild->GetPrimaryFrame();
7624
  nsIFrame* childFrame = aChild->GetPrimaryFrame();
7507
7508
  if (!childFrame || childFrame->GetContent() != aChild) {
7625
  if (!childFrame || childFrame->GetContent() != aChild) {
7509
    // XXXbz the GetContent() != aChild check is needed due to bug 135040.
7626
    // XXXbz the GetContent() != aChild check is needed due to bug 135040.
7510
    // Remove it once that's fixed.
7627
    // Remove it once that's fixed.
7511
    ClearUndisplayedContentIn(aChild, aContainer);
7628
    ClearUndisplayedContentIn(aChild, aContainer);
7512
  }
7629
  }
7630
  MOZ_ASSERT(!childFrame || !GetDisplayBoxContentsStyleFor(aChild),
7631
             "display-box:contents nodes shouldn't have a frame");
7632
  if (!childFrame && GetDisplayBoxContentsStyleFor(aChild)) {
7633
    nsIFrame* ancestorFrame = nullptr;
7634
    for (nsIContent* p = aContainer; p && !ancestorFrame; p = p->GetParent()) {
7635
      ancestorFrame = p->GetPrimaryFrame();
7636
    }
7637
    if (ancestorFrame) {
7638
      nsTArray<nsIContent*>* generated = ancestorFrame->GetGenConPseudos();
7639
      if (generated) {
7640
        LAYOUT_PHASE_TEMP_EXIT();
7641
        // XXXmats Can we recreate frames only for the ::after/::before content?
7642
        // XXX Perhaps even only those that belong to the aChild sub-tree?
7643
        RecreateFramesForContent(ancestorFrame->GetContent(), false);
7644
        LAYOUT_PHASE_TEMP_REENTER();
7645
        *aDidReconstruct = true;
7646
        return NS_OK;
7647
      }
7648
    }
7649
7650
    FlattenedChildIterator iter(aChild);
7651
    for (nsIContent* c = iter.GetNextChild(); c; c = iter.GetNextChild()) {
7652
      if (c->GetPrimaryFrame() || GetDisplayBoxContentsStyleFor(c)) {
7653
        LAYOUT_PHASE_TEMP_EXIT();
7654
        rv = ContentRemoved(aChild, c, nullptr, aFlags, aDidReconstruct);
7655
        LAYOUT_PHASE_TEMP_REENTER();
7656
        NS_ENSURE_SUCCESS(rv, rv);
7657
        if (*aDidReconstruct) {
7658
          return rv;
7659
        }
7660
      }
7661
    }
7662
    ClearDisplayBoxContentsIn(aChild, aContainer);
7663
  }
7513
7664
7665
  nsPresContext* presContext = mPresShell->GetPresContext();
7514
#ifdef MOZ_XUL
7666
#ifdef MOZ_XUL
7515
  if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling, 
7667
  if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling, 
7516
                        mDocument, childFrame, CONTENT_REMOVED))
7668
                        mDocument, childFrame, CONTENT_REMOVED))
7517
    return NS_OK;
7669
    return NS_OK;
7518
7670
7519
#endif // MOZ_XUL
7671
#endif // MOZ_XUL
7520
7672
7521
  // If we're removing the root, then make sure to remove things starting at
7673
  // If we're removing the root, then make sure to remove things starting at
 Lines 8329-8345   nsCSSFrameConstructor::GetInsertionPoint Link Here 
8329
8481
8330
  nsIContent* insertionElement;
8482
  nsIContent* insertionElement;
8331
  if (aChildContent) {
8483
  if (aChildContent) {
8332
    // We've got an explicit insertion child. Check to see if it's
8484
    // We've got an explicit insertion child. Check to see if it's
8333
    // anonymous.
8485
    // anonymous.
8334
    if (aChildContent->GetBindingParent() == aContainer) {
8486
    if (aChildContent->GetBindingParent() == aContainer) {
8335
      // This child content is anonymous. Don't use the insertion
8487
      // This child content is anonymous. Don't use the insertion
8336
      // point, since that's only for the explicit kids.
8488
      // point, since that's only for the explicit kids.
8337
      return GetFrameFor(aContainer);
8489
      return GetInsertionFrameFor(aContainer);
8338
    }
8490
    }
8339
8491
8340
    insertionElement = bindingManager->FindNestedInsertionPoint(aContainer, aChildContent);
8492
    insertionElement = bindingManager->FindNestedInsertionPoint(aContainer, aChildContent);
8341
  }
8493
  }
8342
  else {
8494
  else {
8343
    bool multiple;
8495
    bool multiple;
8344
    insertionElement = bindingManager->FindNestedSingleInsertionPoint(aContainer, &multiple);
8496
    insertionElement = bindingManager->FindNestedSingleInsertionPoint(aContainer, &multiple);
8345
8497
 Lines 8350-8366   nsCSSFrameConstructor::GetInsertionPoint Link Here 
8350
      return nullptr;
8502
      return nullptr;
8351
    }
8503
    }
8352
  }
8504
  }
8353
8505
8354
  if (!insertionElement) {
8506
  if (!insertionElement) {
8355
    insertionElement = aContainer;
8507
    insertionElement = aContainer;
8356
  }
8508
  }
8357
8509
8358
  nsIFrame* insertionPoint = GetFrameFor(insertionElement);
8510
  nsIFrame* insertionPoint = GetInsertionFrameFor(insertionElement);
8359
8511
8360
  // fieldsets have multiple insertion points.  Note that we might
8512
  // fieldsets have multiple insertion points.  Note that we might
8361
  // have to look at insertionElement here...
8513
  // have to look at insertionElement here...
8362
  if (aMultiple && insertionElement->IsHTML(nsGkAtoms::fieldset)) {
8514
  if (aMultiple && insertionElement->IsHTML(nsGkAtoms::fieldset)) {
8363
    *aMultiple = true;
8515
    *aMultiple = true;
8364
  }
8516
  }
8365
8517
8366
  return insertionPoint;
8518
  return insertionPoint;
 Lines 8387-8431   nsCSSFrameConstructor::CaptureStateForFr Link Here 
8387
8539
8388
static bool EqualURIs(mozilla::css::URLValue *aURI1,
8540
static bool EqualURIs(mozilla::css::URLValue *aURI1,
8389
                      mozilla::css::URLValue *aURI2)
8541
                      mozilla::css::URLValue *aURI2)
8390
{
8542
{
8391
  return aURI1 == aURI2 ||    // handle null==null, and optimize
8543
  return aURI1 == aURI2 ||    // handle null==null, and optimize
8392
         (aURI1 && aURI2 && aURI1->URIEquals(*aURI2));
8544
         (aURI1 && aURI2 && aURI1->URIEquals(*aURI2));
8393
}
8545
}
8394
8546
8395
nsresult
8547
nsStyleContext*
8396
nsCSSFrameConstructor::MaybeRecreateFramesForElement(Element* aElement)
8548
nsCSSFrameConstructor::MaybeRecreateFramesForElement(Element* aElement)
8397
{
8549
{
8398
  nsRefPtr<nsStyleContext> oldContext = GetUndisplayedContent(aElement);
8550
  nsRefPtr<nsStyleContext> oldContext = GetUndisplayedContent(aElement);
8551
  uint8_t oldDisplayBoxStyle = NS_STYLE_DISPLAY_BOX_NONE;
8399
  if (!oldContext) {
8552
  if (!oldContext) {
8400
    return NS_OK;
8553
    oldContext = GetDisplayBoxContentsStyleFor(aElement);
8554
    if (!oldContext) {
8555
      return nullptr;
8556
    }
8557
    oldDisplayBoxStyle = NS_STYLE_DISPLAY_BOX_CONTENTS;
8401
  }
8558
  }
8402
8559
8403
  // The parent has a frame, so try resolving a new context.
8560
  // The parent has a frame, so try resolving a new context.
8404
  nsRefPtr<nsStyleContext> newContext = mPresShell->StyleSet()->
8561
  nsRefPtr<nsStyleContext> newContext = mPresShell->StyleSet()->
8405
    ResolveStyleFor(aElement, oldContext->GetParent());
8562
    ResolveStyleFor(aElement, oldContext->GetParent());
8406
8563
8564
  if (oldDisplayBoxStyle == NS_STYLE_DISPLAY_BOX_NONE) {
8407
  ChangeUndisplayedContent(aElement, newContext);
8565
  ChangeUndisplayedContent(aElement, newContext);
8566
  } else {
8567
    ChangeDisplayBoxContents(aElement, newContext);
8568
  }
8569
8408
  const nsStyleDisplay* disp = newContext->StyleDisplay();
8570
  const nsStyleDisplay* disp = newContext->StyleDisplay();
8409
  if (disp->mDisplay == NS_STYLE_DISPLAY_NONE) {
8571
  if (oldDisplayBoxStyle == disp->mDisplayBox) {
8410
    // We can skip trying to recreate frames here, but only if our style
8572
    // We can skip trying to recreate frames here, but only if our style
8411
    // context does not have a binding URI that differs from our old one.
8573
    // context does not have a binding URI that differs from our old one.
8412
    // Otherwise, we should try to recreate, because we may want to apply the
8574
    // Otherwise, we should try to recreate, because we may want to apply the
8413
    // new binding
8575
    // new binding
8414
    if (!disp->mBinding) {
8576
    if (!disp->mBinding) {
8415
      return NS_OK;
8577
      return newContext;
8416
    }
8578
    }
8417
    const nsStyleDisplay* oldDisp = oldContext->PeekStyleDisplay();
8579
    const nsStyleDisplay* oldDisp = oldContext->PeekStyleDisplay();
8418
    if (oldDisp && EqualURIs(disp->mBinding, oldDisp->mBinding)) {
8580
    if (oldDisp && EqualURIs(disp->mBinding, oldDisp->mBinding)) {
8419
      return NS_OK;
8581
      return newContext;
8420
    }
8582
    }
8421
  }
8583
  }
8422
8584
8423
  return RecreateFramesForContent(aElement, false);
8585
  RecreateFramesForContent(aElement, false);
8586
  return nullptr;
8424
}
8587
}
8425
8588
8426
static nsIFrame*
8589
static nsIFrame*
8427
FindFirstNonWhitespaceChild(nsIFrame* aParentFrame)
8590
FindFirstNonWhitespaceChild(nsIFrame* aParentFrame)
8428
{
8591
{
8429
  nsIFrame* f = aParentFrame->GetFirstPrincipalChild();
8592
  nsIFrame* f = aParentFrame->GetFirstPrincipalChild();
8430
  while (f && f->GetType() == nsGkAtoms::textFrame &&
8593
  while (f && f->GetType() == nsGkAtoms::textFrame &&
8431
         f->GetContent()->TextIsOnlyWhitespace()) {
8594
         f->GetContent()->TextIsOnlyWhitespace()) {
 Lines 10306-10326   nsCSSFrameConstructor::CreateListBoxCont Link Here 
10306
                                  mTempFrameTreeState);
10469
                                  mTempFrameTreeState);
10307
10470
10308
    // If we ever initialize the ancestor filter on |state|, make sure
10471
    // If we ever initialize the ancestor filter on |state|, make sure
10309
    // to push the right parent!
10472
    // to push the right parent!
10310
10473
10311
    nsRefPtr<nsStyleContext> styleContext;
10474
    nsRefPtr<nsStyleContext> styleContext;
10312
    styleContext = ResolveStyleContext(aParentFrame, aChild, &state);
10475
    styleContext = ResolveStyleContext(aParentFrame, aChild, &state);
10313
10476
10314
    // Pre-check for display "none" - only if we find that, do we create
10477
    // Pre-check for display-box:none - if we find that, don't create any frame at all.
10315
    // any frame at all
10316
    const nsStyleDisplay* display = styleContext->StyleDisplay();
10478
    const nsStyleDisplay* display = styleContext->StyleDisplay();
10317
10479
    if (NS_STYLE_DISPLAY_BOX_NONE == display->mDisplayBox) {
10318
    if (NS_STYLE_DISPLAY_NONE == display->mDisplay) {
10319
      *aNewFrame = nullptr;
10480
      *aNewFrame = nullptr;
10320
      return NS_OK;
10481
      return NS_OK;
10321
    }
10482
    }
10322
10483
10323
    BeginUpdate();
10484
    BeginUpdate();
10324
10485
10325
    FrameConstructionItemList items;
10486
    FrameConstructionItemList items;
10326
    AddFrameConstructionItemsInternal(state, aChild, aParentFrame,
10487
    AddFrameConstructionItemsInternal(state, aChild, aParentFrame,
(-)mc.082761b7bc54/layout/base/nsCSSFrameConstructor.h (-2 / +17 lines)
Line     Link Here 
 Lines 560-575   private: Link Here 
560
  /* If FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS is set, then create a
560
  /* If FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS is set, then create a
561
     block formatting context wrapper around the kids of this frame
561
     block formatting context wrapper around the kids of this frame
562
     using the FrameConstructionData's mPseudoAtom for its anonymous
562
     using the FrameConstructionData's mPseudoAtom for its anonymous
563
     box type. */
563
     box type. */
564
#define FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS 0x40000
564
#define FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS 0x40000
565
  /* If FCDATA_IS_SVG_TEXT is set, then this text frame is a descendant of
565
  /* If FCDATA_IS_SVG_TEXT is set, then this text frame is a descendant of
566
     an SVG text frame. */
566
     an SVG text frame. */
567
#define FCDATA_IS_SVG_TEXT 0x80000
567
#define FCDATA_IS_SVG_TEXT 0x80000
568
  /**
569
   * display-box:contents
570
   */
571
#define FCDATA_IS_CONTENTS 0x100000
568
572
569
  /* Structure representing information about how a frame should be
573
  /* Structure representing information about how a frame should be
570
     constructed.  */
574
     constructed.  */
571
  struct FrameConstructionData {
575
  struct FrameConstructionData {
572
    // Flag bits that can modify the way the construction happens
576
    // Flag bits that can modify the way the construction happens
573
    uint32_t mBits;
577
    uint32_t mBits;
574
    // We have exactly one of three types of functions, so use a union for
578
    // We have exactly one of three types of functions, so use a union for
575
    // better cache locality for the ones that aren't pointer-to-member.  That
579
    // better cache locality for the ones that aren't pointer-to-member.  That
 Lines 1368-1384   private: Link Here 
1368
                       nsStyleContext*          aStyleContext,
1372
                       nsStyleContext*          aStyleContext,
1369
                       nsIFrame*                aFrame,
1373
                       nsIFrame*                aFrame,
1370
                       const bool               aCanHaveGeneratedContent,
1374
                       const bool               aCanHaveGeneratedContent,
1371
                       nsFrameItems&            aFrameItems,
1375
                       nsFrameItems&            aFrameItems,
1372
                       const bool               aAllowBlockStyles,
1376
                       const bool               aAllowBlockStyles,
1373
                       PendingBinding*          aPendingBinding,
1377
                       PendingBinding*          aPendingBinding,
1374
                       nsIFrame*                aPossiblyLeafFrame = nullptr);
1378
                       nsIFrame*                aPossiblyLeafFrame = nullptr);
1375
1379
1376
  nsIFrame* GetFrameFor(nsIContent* aContent);
1380
  /**
1381
   * Return the insertion frame of the primary frame of aContent, or its nearest
1382
   * ancestor that isn't display:contents.
1383
   */
1384
  nsIFrame* GetInsertionFrameFor(nsIContent* aContent);
1377
1385
1378
  /**
1386
  /**
1379
   * These two functions are used when we start frame creation from a non-root
1387
   * These two functions are used when we start frame creation from a non-root
1380
   * element. They should recreate the same state that we would have
1388
   * element. They should recreate the same state that we would have
1381
   * arrived at if we had built frames from the root frame to aFrame.
1389
   * arrived at if we had built frames from the root frame to aFrame.
1382
   * Therefore, any calls to PushFloatContainingBlock and
1390
   * Therefore, any calls to PushFloatContainingBlock and
1383
   * PushAbsoluteContainingBlock during frame construction should get
1391
   * PushAbsoluteContainingBlock during frame construction should get
1384
   * corresponding logic in these functions.
1392
   * corresponding logic in these functions.
 Lines 1431-1447   private: Link Here 
1431
                        nsIFrame*                scrolledFrame,
1439
                        nsIFrame*                scrolledFrame,
1432
                        nsIContent*              aContent,
1440
                        nsIContent*              aContent,
1433
                        nsIFrame*                aParentFrame,
1441
                        nsIFrame*                aParentFrame,
1434
                        nsStyleContext*          aStyleContext,
1442
                        nsStyleContext*          aStyleContext,
1435
                        bool                     aBuildCombobox,
1443
                        bool                     aBuildCombobox,
1436
                        PendingBinding*          aPendingBinding,
1444
                        PendingBinding*          aPendingBinding,
1437
                        nsFrameItems&            aFrameItems);
1445
                        nsFrameItems&            aFrameItems);
1438
1446
1439
  nsresult MaybeRecreateFramesForElement(Element* aElement);
1447
  /**
1448
   * ReResolve style for aElement then recreate frames if required.
1449
   * Do nothing for other types of style changes, except for undisplayed nodes
1450
   * (display:none/contents) which will have their style context updated in the
1451
   * frame manager undisplayed maps.
1452
   * @return null if frames were recreated, the new style context otherwise
1453
   */
1454
  nsStyleContext* MaybeRecreateFramesForElement(Element* aElement);
1440
1455
1441
  // If aAsyncInsert is true then a restyle event will be posted to handle the
1456
  // If aAsyncInsert is true then a restyle event will be posted to handle the
1442
  // required ContentInserted call instead of doing it immediately.
1457
  // required ContentInserted call instead of doing it immediately.
1443
  nsresult RecreateFramesForContent(nsIContent* aContent, bool aAsyncInsert);
1458
  nsresult RecreateFramesForContent(nsIContent* aContent, bool aAsyncInsert);
1444
1459
1445
  // If removal of aFrame from the frame tree requires reconstruction of some
1460
  // If removal of aFrame from the frame tree requires reconstruction of some
1446
  // containing block (either of aFrame or of its parent) due to {ib} splits or
1461
  // containing block (either of aFrame or of its parent) due to {ib} splits or
1447
  // table pseudo-frames, recreate the relevant frame subtree.  The return value
1462
  // table pseudo-frames, recreate the relevant frame subtree.  The return value
(-)mc.082761b7bc54/layout/base/nsDisplayList.cpp (-2 / +9 lines)
Line     Link Here 
 Lines 4358-4378   nsDisplayTransform::GetDeltaToPerspectiv Link Here 
4358
4358
4359
  /* For both of the coordinates, if the value of -moz-perspective-origin is a
4359
  /* For both of the coordinates, if the value of -moz-perspective-origin is a
4360
   * percentage, it's relative to the size of the frame.  Otherwise, if it's
4360
   * percentage, it's relative to the size of the frame.  Otherwise, if it's
4361
   * a distance, it's already computed for us!
4361
   * a distance, it's already computed for us!
4362
   */
4362
   */
4363
4363
4364
  //TODO: Should this be using our bounds or the parent's bounds?
4364
  //TODO: Should this be using our bounds or the parent's bounds?
4365
  // How do we handle aBoundsOverride in the latter case?
4365
  // How do we handle aBoundsOverride in the latter case?
4366
  nsIFrame* parent = aFrame->GetParentStyleContextFrame();
4366
  nsIFrame* parent;
4367
  nsStyleContext* psc = aFrame->GetParentStyleContext(&parent);
4368
  if (!psc) {
4369
    return gfxPoint3D();
4370
  }
4371
  if (!parent) {
4372
    parent = aFrame->GetParent();
4367
  if (!parent) {
4373
  if (!parent) {
4368
    return gfxPoint3D();
4374
    return gfxPoint3D();
4369
  }
4375
  }
4370
  const nsStyleDisplay* display = parent->StyleDisplay();
4376
  }
4377
  const nsStyleDisplay* display = psc->StyleDisplay();
4371
  nsRect boundingRect = nsDisplayTransform::GetFrameBoundsForTransform(parent);
4378
  nsRect boundingRect = nsDisplayTransform::GetFrameBoundsForTransform(parent);
4372
4379
4373
  /* Allows us to access named variables by index. */
4380
  /* Allows us to access named variables by index. */
4374
  gfxPoint3D result;
4381
  gfxPoint3D result;
4375
  result.z = 0.0f;
4382
  result.z = 0.0f;
4376
  gfxFloat* coords[2] = {&result.x, &result.y};
4383
  gfxFloat* coords[2] = {&result.x, &result.y};
4377
  const nscoord* dimensions[2] =
4384
  const nscoord* dimensions[2] =
4378
    {&boundingRect.width, &boundingRect.height};
4385
    {&boundingRect.width, &boundingRect.height};
(-)mc.082761b7bc54/layout/base/nsFrameManagerBase.h (+1 lines)
Line     Link Here 
 Lines 60-75   protected: Link Here 
60
60
61
  // weak link, because the pres shell owns us
61
  // weak link, because the pres shell owns us
62
  nsIPresShell*                   mPresShell;
62
  nsIPresShell*                   mPresShell;
63
  // the pres shell owns the style set
63
  // the pres shell owns the style set
64
  nsStyleSet*                     mStyleSet;
64
  nsStyleSet*                     mStyleSet;
65
  nsIFrame*                       mRootFrame;
65
  nsIFrame*                       mRootFrame;
66
  PLDHashTable                    mPlaceholderMap;
66
  PLDHashTable                    mPlaceholderMap;
67
  UndisplayedMap*                 mUndisplayedMap;
67
  UndisplayedMap*                 mUndisplayedMap;
68
  UndisplayedMap*                 mDisplayDisplayBoxContentsMap;
68
  bool                            mIsDestroyingFrames;  // The frame manager is destroying some frame(s).
69
  bool                            mIsDestroyingFrames;  // The frame manager is destroying some frame(s).
69
70
70
  // The frame tree generation number
71
  // The frame tree generation number
71
  // We use this to avoid unnecessary screenshotting
72
  // We use this to avoid unnecessary screenshotting
72
  // on Android. Unfortunately, this is static to match
73
  // on Android. Unfortunately, this is static to match
73
  // the single consumer which is also static. Keeping
74
  // the single consumer which is also static. Keeping
74
  // this the same greatly simplifies lifetime issues and
75
  // this the same greatly simplifies lifetime issues and
75
  // makes sure we always using the correct number.
76
  // makes sure we always using the correct number.
(-)mc.082761b7bc54/layout/base/nsFrameManager.cpp (-3 / +161 lines)
Line     Link Here 
 Lines 34-51    Link Here 
34
#include "ChildIterator.h"
34
#include "ChildIterator.h"
35
35
36
#include "nsFrameManager.h"
36
#include "nsFrameManager.h"
37
#include "GeckoProfiler.h"
37
#include "GeckoProfiler.h"
38
#include "nsIStatefulFrame.h"
38
#include "nsIStatefulFrame.h"
39
39
40
  #ifdef DEBUG
40
  #ifdef DEBUG
41
    //#define DEBUG_UNDISPLAYED_MAP
41
    //#define DEBUG_UNDISPLAYED_MAP
42
    //#define DEBUG_DISPLAY_BOX_CONTENTS_MAP
42
  #else
43
  #else
43
    #undef DEBUG_UNDISPLAYED_MAP
44
    #undef DEBUG_UNDISPLAYED_MAP
45
    #undef DEBUG_DISPLAY_BOX_CONTENTS_MAP
44
  #endif
46
  #endif
45
47
46
using namespace mozilla;
48
using namespace mozilla;
47
using namespace mozilla::dom;
49
using namespace mozilla::dom;
48
50
49
//----------------------------------------------------------------------
51
//----------------------------------------------------------------------
50
52
51
struct PlaceholderMapEntry : public PLDHashEntryHdr {
53
struct PlaceholderMapEntry : public PLDHashEntryHdr {
 Lines 90-105   public: Link Here 
90
92
91
  NS_HIDDEN_(nsresult) AddNodeFor(nsIContent* aParentContent,
93
  NS_HIDDEN_(nsresult) AddNodeFor(nsIContent* aParentContent,
92
                                  nsIContent* aChild, nsStyleContext* aStyle);
94
                                  nsIContent* aChild, nsStyleContext* aStyle);
93
95
94
  NS_HIDDEN_(void) RemoveNodeFor(nsIContent* aParentContent,
96
  NS_HIDDEN_(void) RemoveNodeFor(nsIContent* aParentContent,
95
                                 UndisplayedNode* aNode);
97
                                 UndisplayedNode* aNode);
96
98
97
  NS_HIDDEN_(void) RemoveNodesFor(nsIContent* aParentContent);
99
  NS_HIDDEN_(void) RemoveNodesFor(nsIContent* aParentContent);
100
  NS_HIDDEN_(UndisplayedNode*) UnlinkNodesFor(nsIContent* aParentContent);
98
101
99
  // Removes all entries from the hash table
102
  // Removes all entries from the hash table
100
  NS_HIDDEN_(void)  Clear(void);
103
  NS_HIDDEN_(void)  Clear(void);
101
104
102
protected:
105
protected:
103
  /**
106
  /**
104
   * Gets the entry for the provided parent content. If the content
107
   * Gets the entry for the provided parent content. If the content
105
   * is a <xbl:children> element, |**aParentContent| is set to
108
   * is a <xbl:children> element, |**aParentContent| is set to
 Lines 133-148   nsFrameManager::Destroy() Link Here 
133
136
134
  if (mRootFrame) {
137
  if (mRootFrame) {
135
    mRootFrame->Destroy();
138
    mRootFrame->Destroy();
136
    mRootFrame = nullptr;
139
    mRootFrame = nullptr;
137
  }
140
  }
138
  
141
  
139
  delete mUndisplayedMap;
142
  delete mUndisplayedMap;
140
  mUndisplayedMap = nullptr;
143
  mUndisplayedMap = nullptr;
144
  delete mDisplayDisplayBoxContentsMap;
145
  mDisplayDisplayBoxContentsMap = nullptr;
141
146
142
  mPresShell = nullptr;
147
  mPresShell = nullptr;
143
}
148
}
144
149
145
//----------------------------------------------------------------------
150
//----------------------------------------------------------------------
146
151
147
// Placeholder frame functions
152
// Placeholder frame functions
148
nsPlaceholderFrame*
153
nsPlaceholderFrame*
 Lines 315-330   nsFrameManager::ClearUndisplayedContentI Link Here 
315
        nsStyleContext *context = GetUndisplayedContent(aContent);
320
        nsStyleContext *context = GetUndisplayedContent(aContent);
316
        NS_ASSERTION(context == nullptr, "Found more undisplayed content data after removal");
321
        NS_ASSERTION(context == nullptr, "Found more undisplayed content data after removal");
317
#endif
322
#endif
318
        return;
323
        return;
319
      }
324
      }
320
      node = node->mNext;
325
      node = node->mNext;
321
    }
326
    }
322
  }
327
  }
328
#ifdef DEBUG_UNDISPLAYED_MAP
329
  printf( "not found.\n");
330
#endif
323
}
331
}
324
332
325
void
333
void
326
nsFrameManager::ClearAllUndisplayedContentIn(nsIContent* aParentContent)
334
nsFrameManager::ClearAllUndisplayedContentIn(nsIContent* aParentContent)
327
{
335
{
328
#ifdef DEBUG_UNDISPLAYED_MAP
336
#ifdef DEBUG_UNDISPLAYED_MAP
329
  static int i = 0;
337
  static int i = 0;
330
  printf("ClearAllUndisplayedContentIn(%d): parent=%p \n", i++, (void*)aParentContent);
338
  printf("ClearAllUndisplayedContentIn(%d): parent=%p \n", i++, (void*)aParentContent);
 Lines 342-357   nsFrameManager::ClearAllUndisplayedConte Link Here 
342
  for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
350
  for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
343
    if (child->GetParent() != aParentContent) {
351
    if (child->GetParent() != aParentContent) {
344
      ClearUndisplayedContentIn(child, child->GetParent());
352
      ClearUndisplayedContentIn(child, child->GetParent());
345
    }
353
    }
346
  }
354
  }
347
}
355
}
348
356
349
//----------------------------------------------------------------------
357
//----------------------------------------------------------------------
358
359
nsStyleContext*
360
nsFrameManager::GetDisplayBoxContentsStyleFor(nsIContent* aContent)
361
{
362
  if (!aContent || !mDisplayDisplayBoxContentsMap) {
363
    return nullptr;
364
  }
365
  nsIContent* parent = aContent->GetParent();
366
  for (UndisplayedNode* node = mDisplayDisplayBoxContentsMap->GetFirstNode(parent);
367
         node; node = node->mNext) {
368
    if (node->mContent == aContent) {
369
      return node->mStyle;
370
    }
371
  }
372
  return nullptr;
373
}
374
375
UndisplayedNode*
376
nsFrameManager::GetAllDisplayBoxContentsIn(nsIContent* aParentContent)
377
{
378
  return mDisplayDisplayBoxContentsMap ? mDisplayDisplayBoxContentsMap->GetFirstNode(aParentContent)
379
    : nullptr;
380
}
381
382
void
383
nsFrameManager::SetDisplayBoxContents(nsIContent* aContent, 
384
                                      nsStyleContext* aStyleContext)
385
{
386
  NS_PRECONDITION(!aStyleContext->GetPseudo(),
387
                  "Should only have actual elements here");
388
389
#ifdef DEBUG_DISPLAY_BOX_CONTENTS_MAP
390
  static int i = 0;
391
  printf("SetDisplayBoxContents(%d): aContent=%p \n", i++, (void *)aContent);
392
#endif
393
394
  NS_ASSERTION(!GetDisplayBoxContentsStyleFor(aContent),
395
               "Already have an undisplayed context entry for aContent");
396
397
  if (!mDisplayDisplayBoxContentsMap) {
398
    mDisplayDisplayBoxContentsMap = new UndisplayedMap;
399
  }
400
  nsIContent* parent = aContent->GetParent();
401
  NS_ASSERTION(parent || (mPresShell && mPresShell->GetDocument() &&
402
               mPresShell->GetDocument()->GetRootElement() == aContent),
403
               "undisplayed content must have a parent, unless it's the root "
404
               "element");
405
  mDisplayDisplayBoxContentsMap->AddNodeFor(parent, aContent, aStyleContext);
406
}
407
408
void
409
nsFrameManager::ChangeDisplayBoxContents(nsIContent* aContent, 
410
                                         nsStyleContext* aStyleContext)
411
{
412
  NS_ASSERTION(mDisplayDisplayBoxContentsMap, "no existing display-box:contents content");
413
  
414
#ifdef DEBUG_DISPLAY_BOX_CONTENTS_MAP
415
   static int i = 0;
416
   printf("ChangeDisplayBoxContents(%d): aContent=%p \n", i++, (void *)aContent);
417
#endif
418
419
  for (UndisplayedNode* node = mDisplayDisplayBoxContentsMap->GetFirstNode(aContent->GetParent());
420
         node; node = node->mNext) {
421
    if (node->mContent == aContent) {
422
      node->mStyle = aStyleContext;
423
      return;
424
    }
425
  }
426
427
  NS_NOTREACHED("no existing display-box:contents content");
428
}
429
430
void
431
nsFrameManager::ClearDisplayBoxContentsIn(nsIContent* aContent,
432
                                          nsIContent* aParentContent)
433
{
434
#ifdef DEBUG_DISPLAY_BOX_CONTENTS_MAP
435
  static int i = 0;
436
  printf("ClearDisplayBoxContents(%d): content=%p parent=%p --> ", i++, (void *)aContent, (void*)aParentContent);
437
#endif
438
  
439
  if (mDisplayDisplayBoxContentsMap) {
440
    UndisplayedNode* node = mDisplayDisplayBoxContentsMap->GetFirstNode(aParentContent);
441
    while (node) {
442
      if (node->mContent == aContent) {
443
        mDisplayDisplayBoxContentsMap->RemoveNodeFor(aParentContent, node);
444
445
#ifdef DEBUG_DISPLAY_BOX_CONTENTS_MAP
446
        printf( "REMOVED!\n");
447
#endif
448
#ifdef DEBUG
449
        // make sure that there are no more entries for the same content
450
        nsStyleContext* context = GetDisplayBoxContentsStyleFor(aContent);
451
        NS_ASSERTION(context == nullptr, "Found more entries for aContent after removal");
452
#endif
453
        ClearAllDisplayBoxContentsIn(aContent);
454
        ClearAllUndisplayedContentIn(aContent);
455
        return;
456
      }
457
      node = node->mNext;
458
    }
459
  }
460
#ifdef DEBUG_DISPLAY_BOX_CONTENTS_MAP
461
  printf( "not found.\n");
462
#endif
463
}
464
465
void
466
nsFrameManager::ClearAllDisplayBoxContentsIn(nsIContent* aParentContent)
467
{
468
#ifdef DEBUG_DISPLAY_BOX_CONTENTS_MAP
469
  static int i = 0;
470
  printf("ClearAllDisplayBoxContentsIn(%d): parent=%p \n", i++, (void*)aParentContent);
471
#endif
472
473
  if (mDisplayDisplayBoxContentsMap) {
474
    UndisplayedNode* cur = mDisplayDisplayBoxContentsMap->UnlinkNodesFor(aParentContent);
475
    while (cur) {
476
      UndisplayedNode* next = cur->mNext;
477
      cur->mNext = nullptr;
478
      ClearAllDisplayBoxContentsIn(cur->mContent);
479
      ClearAllUndisplayedContentIn(cur->mContent);
480
      delete cur;
481
      cur = next;
482
    }
483
  }
484
485
  // Need to look at aParentContent's content list due to XBL insertions.
486
  // Nodes in aParentContent's content list do not have aParentContent as a
487
  // parent, but are treated as children of aParentContent. We iterate over
488
  // the flattened content list and just ignore any nodes we don't care about.
489
  FlattenedChildIterator iter(aParentContent);
490
  for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
491
    if (child->GetParent() != aParentContent) {
492
      ClearDisplayBoxContentsIn(child, child->GetParent());
493
      ClearUndisplayedContentIn(child, child->GetParent());
494
    }
495
  }
496
}
497
498
//----------------------------------------------------------------------
350
nsresult
499
nsresult
351
nsFrameManager::AppendFrames(nsIFrame*       aParentFrame,
500
nsFrameManager::AppendFrames(nsIFrame*       aParentFrame,
352
                             ChildListID     aListID,
501
                             ChildListID     aListID,
353
                             nsFrameList&    aFrameList)
502
                             nsFrameList&    aFrameList)
354
{
503
{
355
  if (aParentFrame->IsAbsoluteContainer() &&
504
  if (aParentFrame->IsAbsoluteContainer() &&
356
      aListID == aParentFrame->GetAbsoluteListID()) {
505
      aListID == aParentFrame->GetAbsoluteListID()) {
357
    return aParentFrame->GetAbsoluteContainingBlock()->
506
    return aParentFrame->GetAbsoluteContainingBlock()->
 Lines 421-436   nsFrameManager::RemoveFrame(ChildListID Link Here 
421
//----------------------------------------------------------------------
570
//----------------------------------------------------------------------
422
571
423
void
572
void
424
nsFrameManager::NotifyDestroyingFrame(nsIFrame* aFrame)
573
nsFrameManager::NotifyDestroyingFrame(nsIFrame* aFrame)
425
{
574
{
426
  nsIContent* content = aFrame->GetContent();
575
  nsIContent* content = aFrame->GetContent();
427
  if (content && content->GetPrimaryFrame() == aFrame) {
576
  if (content && content->GetPrimaryFrame() == aFrame) {
428
    ClearAllUndisplayedContentIn(content);
577
    ClearAllUndisplayedContentIn(content);
578
    ClearAllDisplayBoxContentsIn(content);
429
  }
579
  }
430
}
580
}
431
581
432
// Capture state for a given frame.
582
// Capture state for a given frame.
433
// Accept a content id here, in some cases we may not have content (scroll position)
583
// Accept a content id here, in some cases we may not have content (scroll position)
434
void
584
void
435
nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame,
585
nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame,
436
                                     nsILayoutHistoryState* aState)
586
                                     nsILayoutHistoryState* aState)
 Lines 697-724   nsFrameManagerBase::UndisplayedMap::Remo Link Here 
697
        }
847
        }
698
        node = node->mNext;
848
        node = node->mNext;
699
      }
849
      }
700
    }
850
    }
701
  }
851
  }
702
  delete aNode;
852
  delete aNode;
703
}
853
}
704
854
705
void
855
706
nsFrameManagerBase::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
856
UndisplayedNode*
857
nsFrameManagerBase::UndisplayedMap::UnlinkNodesFor(nsIContent* aParentContent)
707
{
858
{
708
  PLHashEntry** entry = GetEntryFor(&aParentContent);
859
  PLHashEntry** entry = GetEntryFor(&aParentContent);
709
  NS_ASSERTION(entry, "content not in map");
860
  NS_ASSERTION(entry, "content not in map");
710
  if (*entry) {
861
  if (*entry) {
711
    UndisplayedNode*  node = (UndisplayedNode*)((*entry)->value);
862
    UndisplayedNode*  node = (UndisplayedNode*)((*entry)->value);
712
    NS_ASSERTION(node, "null node for non-null entry in UndisplayedMap");
863
    NS_ASSERTION(node, "null node for non-null entry in UndisplayedMap");
713
    delete node;
714
    PL_HashTableRawRemove(mTable, entry, *entry);
864
    PL_HashTableRawRemove(mTable, entry, *entry);
715
    mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
865
    mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
866
    return node;
716
  }
867
  }
868
  return nullptr;
869
}
870
871
void
872
nsFrameManagerBase::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
873
{
874
  delete UnlinkNodesFor(aParentContent);
717
}
875
}
718
876
719
static int
877
static int
720
RemoveUndisplayedEntry(PLHashEntry* he, int i, void* arg)
878
RemoveUndisplayedEntry(PLHashEntry* he, int i, void* arg)
721
{
879
{
722
  UndisplayedNode*  node = (UndisplayedNode*)(he->value);
880
  UndisplayedNode*  node = (UndisplayedNode*)(he->value);
723
  delete node;
881
  delete node;
724
  // Remove and free this entry and continue enumerating
882
  // Remove and free this entry and continue enumerating
(-)mc.082761b7bc54/layout/base/nsFrameManager.h (+36 lines)
Line     Link Here 
 Lines 106-121   public: Link Here 
106
  NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
106
  NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
107
                                         nsStyleContext* aStyleContext);
107
                                         nsStyleContext* aStyleContext);
108
  NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
108
  NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
109
                                            nsStyleContext* aStyleContext);
109
                                            nsStyleContext* aStyleContext);
110
  NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
110
  NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
111
                                             nsIContent* aParentContent);
111
                                             nsIContent* aParentContent);
112
  NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
112
  NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
113
113
114
  // display-box:contents related methods:
115
  /**
116
   * Return the registered display-box:contents style context for aContent, if any.
117
   */
118
  NS_HIDDEN_(nsStyleContext*) GetDisplayBoxContentsStyleFor(nsIContent* aContent);
119
120
  /**
121
   * Return the linked list of UndisplayedNodes containing the registered
122
   * display-box:contents children of aParentContent, if any.
123
   */
124
  NS_HIDDEN_(mozilla::UndisplayedNode*)
125
    GetAllDisplayBoxContentsIn(nsIContent* aParentContent);
126
127
  /**
128
   * Register aContent as having (display-box:contents) aStyleContext.
129
   */
130
  NS_HIDDEN_(void) SetDisplayBoxContents(nsIContent* aContent,
131
                                         nsStyleContext* aStyleContext);
132
  /**
133
   * Change the registered style context for aContent to aStyleContext.
134
   */
135
  NS_HIDDEN_(void) ChangeDisplayBoxContents(nsIContent* aContent,
136
                                            nsStyleContext* aStyleContext);
137
  /**
138
   * Unregister the display-box:contents style context for aContent, if any.
139
   * If found, then also unregister any display-box:contents and display:none
140
   * style contexts for its descendants.
141
   */
142
  NS_HIDDEN_(void) ClearDisplayBoxContentsIn(nsIContent* aContent,
143
                                             nsIContent* aParentContent);
144
  /**
145
   * Unregister display-box:contents and display:none style contexts for all
146
   * descendants of aParentContent.
147
   */
148
  NS_HIDDEN_(void) ClearAllDisplayBoxContentsIn(nsIContent* aParentContent);
149
114
  // Functions for manipulating the frame model
150
  // Functions for manipulating the frame model
115
  NS_HIDDEN_(nsresult) AppendFrames(nsIFrame*       aParentFrame,
151
  NS_HIDDEN_(nsresult) AppendFrames(nsIFrame*       aParentFrame,
116
                                    ChildListID     aListID,
152
                                    ChildListID     aListID,
117
                                    nsFrameList&    aFrameList);
153
                                    nsFrameList&    aFrameList);
118
154
119
  NS_HIDDEN_(nsresult) InsertFrames(nsIFrame*       aParentFrame,
155
  NS_HIDDEN_(nsresult) InsertFrames(nsIFrame*       aParentFrame,
120
                                    ChildListID     aListID,
156
                                    ChildListID     aListID,
121
                                    nsIFrame*       aPrevFrame,
157
                                    nsIFrame*       aPrevFrame,
(-)mc.082761b7bc54/layout/base/nsLayoutUtils.cpp (-89 / +56 lines)
Line     Link Here 
 Lines 687-768   nsLayoutUtils::LastContinuationWithChild Link Here 
687
  aFrame = aFrame->LastContinuation();
687
  aFrame = aFrame->LastContinuation();
688
  while (!aFrame->GetFirstPrincipalChild() &&
688
  while (!aFrame->GetFirstPrincipalChild() &&
689
         aFrame->GetPrevContinuation()) {
689
         aFrame->GetPrevContinuation()) {
690
    aFrame = aFrame->GetPrevContinuation();
690
    aFrame = aFrame->GetPrevContinuation();
691
  }
691
  }
692
  return aFrame;
692
  return aFrame;
693
}
693
}
694
694
695
/**
696
 * GetFirstChildFrame returns the first "real" child frame of a
697
 * given frame.  It will descend down into pseudo-frames (unless the
698
 * pseudo-frame is the :before generated frame).
699
 * @param aFrame the frame
700
 * @param aFrame the frame's content node
701
 */
702
static nsIFrame*
703
GetFirstChildFrame(nsIFrame*       aFrame,
704
                   nsIContent*     aContent)
705
{
706
  NS_PRECONDITION(aFrame, "NULL frame pointer");
707
708
  // Get the first child frame
709
  nsIFrame* childFrame = aFrame->GetFirstPrincipalChild();
710
711
  // If the child frame is a pseudo-frame, then return its first child.
712
  // Note that the frame we create for the generated content is also a
713
  // pseudo-frame and so don't drill down in that case
714
  if (childFrame &&
715
      childFrame->IsPseudoFrame(aContent) &&
716
      !childFrame->IsGeneratedContentFrame()) {
717
    return GetFirstChildFrame(childFrame, aContent);
718
  }
719
720
  return childFrame;
721
}
722
723
/**
724
 * GetLastChildFrame returns the last "real" child frame of a
725
 * given frame.  It will descend down into pseudo-frames (unless the
726
 * pseudo-frame is the :after generated frame).
727
 * @param aFrame the frame
728
 * @param aFrame the frame's content node
729
 */
730
static nsIFrame*
731
GetLastChildFrame(nsIFrame*       aFrame,
732
                  nsIContent*     aContent)
733
{
734
  NS_PRECONDITION(aFrame, "NULL frame pointer");
735
736
  // Get the last continuation frame that's a parent
737
  nsIFrame* lastParentContinuation =
738
    nsLayoutUtils::LastContinuationWithChild(aFrame);
739
  nsIFrame* lastChildFrame =
740
    lastParentContinuation->GetLastChild(nsIFrame::kPrincipalList);
741
  if (lastChildFrame) {
742
    // Get the frame's first continuation. This matters in case the frame has
743
    // been continued across multiple lines or split by BiDi resolution.
744
    lastChildFrame = lastChildFrame->FirstContinuation();
745
746
    // If the last child frame is a pseudo-frame, then return its last child.
747
    // Note that the frame we create for the generated content is also a
748
    // pseudo-frame and so don't drill down in that case
749
    if (lastChildFrame &&
750
        lastChildFrame->IsPseudoFrame(aContent) &&
751
        !lastChildFrame->IsGeneratedContentFrame()) {
752
      return GetLastChildFrame(lastChildFrame, aContent);
753
    }
754
755
    return lastChildFrame;
756
  }
757
758
  return nullptr;
759
}
760
761
//static
695
//static
762
FrameChildListID
696
FrameChildListID
763
nsLayoutUtils::GetChildListNameFor(nsIFrame* aChildFrame)
697
nsLayoutUtils::GetChildListNameFor(nsIFrame* aChildFrame)
764
{
698
{
765
  nsIFrame::ChildListID id = nsIFrame::kPrincipalList;
699
  nsIFrame::ChildListID id = nsIFrame::kPrincipalList;
766
700
767
  if (aChildFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
701
  if (aChildFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
768
    nsIFrame* pif = aChildFrame->GetPrevInFlow();
702
    nsIFrame* pif = aChildFrame->GetPrevInFlow();
 Lines 851-900   nsLayoutUtils::GetChildListNameFor(nsIFr Link Here 
851
    // else it's positioned and should have been on the 'id' child list.
785
    // else it's positioned and should have been on the 'id' child list.
852
    NS_POSTCONDITION(found, "not in child list");
786
    NS_POSTCONDITION(found, "not in child list");
853
  }
787
  }
854
#endif
788
#endif
855
789
856
  return id;
790
  return id;
857
}
791
}
858
792
859
// static
793
/*static*/ nsIFrame*
860
nsIFrame*
794
nsLayoutUtils::GetBeforeFrameForContent(nsIFrame* aGenConParentFrame,
861
nsLayoutUtils::GetBeforeFrame(nsIFrame* aFrame)
795
                                        nsIContent* aContent)
862
{
796
{
863
  NS_PRECONDITION(aFrame, "NULL frame pointer");
797
  nsTArray<nsIContent*>* prop = aGenConParentFrame->GetGenConPseudos();
864
  NS_ASSERTION(!aFrame->GetPrevContinuation(),
798
  if (prop) {
865
               "aFrame must be first continuation");
799
    const nsTArray<nsIContent*>& pseudos(*prop);
866
800
    for (uint32_t i = 0; i < pseudos.Length(); ++i) {
867
  nsIFrame* firstFrame = GetFirstChildFrame(aFrame, aFrame->GetContent());
801
      if (pseudos[i]->GetParent() == aContent &&
868
802
          pseudos[i]->Tag() == nsGkAtoms::mozgeneratedcontentbefore) {
869
  if (firstFrame && IsGeneratedContentFor(nullptr, firstFrame,
803
        return pseudos[i]->GetPrimaryFrame();
870
                                          nsCSSPseudoElements::before)) {
804
      }
871
    return firstFrame;
805
    }
806
  }
807
  // If the first child frame is a pseudo-frame, then try that.
808
  // Note that the frame we create for the generated content is also a
809
  // pseudo-frame and so don't drill down in that case.
810
  nsIFrame* childFrame = aGenConParentFrame->GetFirstPrincipalChild();
811
  if (childFrame &&
812
      childFrame->IsPseudoFrame(aContent) &&
813
      !childFrame->IsGeneratedContentFrame()) {
814
    return GetBeforeFrameForContent(childFrame, aContent);
872
  }
815
  }
873
874
  return nullptr;
816
  return nullptr;
875
}
817
}
876
818
877
// static
819
/*static*/ nsIFrame*
878
nsIFrame*
820
nsLayoutUtils::GetBeforeFrame(nsIFrame* aFrame)
879
nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame)
880
{
821
{
881
  NS_PRECONDITION(aFrame, "NULL frame pointer");
822
  return GetBeforeFrameForContent(aFrame, aFrame->GetContent());
882
883
  nsIFrame* lastFrame = GetLastChildFrame(aFrame, aFrame->GetContent());
884
885
  if (lastFrame && IsGeneratedContentFor(nullptr, lastFrame,
886
                                         nsCSSPseudoElements::after)) {
887
    return lastFrame;
888
  }
823
  }
889
824
825
/*static*/ nsIFrame*
826
nsLayoutUtils::GetAfterFrameForContent(nsIFrame* aGenConParentFrame,
827
                                       nsIContent* aContent)
828
{
829
  nsTArray<nsIContent*>* prop = aGenConParentFrame->GetGenConPseudos();
830
  if (prop) {
831
    const nsTArray<nsIContent*>& pseudos(*prop);
832
    for (uint32_t i = 0; i < pseudos.Length(); ++i) {
833
      if (pseudos[i]->GetParent() == aContent &&
834
          pseudos[i]->Tag() == nsGkAtoms::mozgeneratedcontentafter) {
835
        return pseudos[i]->GetPrimaryFrame();
836
      }
837
    }
838
  }
839
  // If the last child frame is a pseudo-frame, then try that.
840
  // Note that the frame we create for the generated content is also a
841
  // pseudo-frame and so don't drill down in that case.
842
  nsIFrame* lastParentContinuation =
843
    nsLayoutUtils::LastContinuationWithChild(aGenConParentFrame);
844
  nsIFrame* childFrame =
845
    lastParentContinuation->GetLastChild(nsIFrame::kPrincipalList);
846
  if (childFrame &&
847
      childFrame->IsPseudoFrame(aContent) &&
848
      !childFrame->IsGeneratedContentFrame()) {
849
    return GetAfterFrameForContent(childFrame->FirstContinuation(), aContent);
850
  }
890
  return nullptr;
851
  return nullptr;
891
}
852
}
892
853
854
/*static*/ nsIFrame*
855
nsLayoutUtils::GetAfterFrame(nsIFrame* aFrame)
856
{
857
  return GetAfterFrameForContent(aFrame, aFrame->GetContent());
858
}
859
893
// static
860
// static
894
nsIFrame*
861
nsIFrame*
895
nsLayoutUtils::GetClosestFrameOfType(nsIFrame* aFrame, nsIAtom* aFrameType)
862
nsLayoutUtils::GetClosestFrameOfType(nsIFrame* aFrame, nsIAtom* aFrameType)
896
{
863
{
897
  for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent()) {
864
  for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent()) {
898
    if (frame->GetType() == aFrameType) {
865
    if (frame->GetType() == aFrameType) {
899
      return frame;
866
      return frame;
900
    }
867
    }
(-)mc.082761b7bc54/layout/base/nsLayoutUtils.h (-4 / +29 lines)
Line     Link Here 
 Lines 142-173   public: Link Here 
142
142
143
  /**
143
  /**
144
   * Use heuristics to figure out the child list that
144
   * Use heuristics to figure out the child list that
145
   * aChildFrame is currently in.
145
   * aChildFrame is currently in.
146
   */
146
   */
147
  static mozilla::layout::FrameChildListID GetChildListNameFor(nsIFrame* aChildFrame);
147
  static mozilla::layout::FrameChildListID GetChildListNameFor(nsIFrame* aChildFrame);
148
148
149
  /**
149
  /**
150
   * GetBeforeFrame returns the outermost :before frame of the given frame, if
150
   * GetBeforeFrameForContent returns the ::before frame for aContent, if
151
   * one exists.  This is typically O(1).  The frame passed in must be
151
   * one exists.  This is typically O(1).  The frame passed in must be
152
   * the first-in-flow.
152
   * the first-in-flow.
153
   *
153
   *
154
   * @param aFrame the frame whose :before is wanted
154
   * @param aGenConParentFrame an ancestor of the ::before frame
155
   * @param aContent the content whose ::before is wanted
156
   * @return the ::before frame or nullptr if there isn't one
157
   */
158
  static nsIFrame* GetBeforeFrameForContent(nsIFrame* aGenConParentFrame,
159
                                            nsIContent* aContent);
160
161
  /**
162
   * GetBeforeFrame returns the outermost ::before frame of the given frame, if
163
   * one exists.  This is typically O(1).  The frame passed in must be
164
   * the first-in-flow.
165
   *
166
   * @param aFrame the frame whose ::before is wanted
155
   * @return the :before frame or nullptr if there isn't one
167
   * @return the :before frame or nullptr if there isn't one
156
   */
168
   */
157
  static nsIFrame* GetBeforeFrame(nsIFrame* aFrame);
169
  static nsIFrame* GetBeforeFrame(nsIFrame* aFrame);
158
170
159
  /**
171
  /**
160
   * GetAfterFrame returns the outermost :after frame of the given frame, if one
172
   * GetAfterFrameForContent returns the ::after frame for aContent, if one
173
   * exists.  This will walk the in-flow chain of aGenConParentFrame to the
174
   * last-in-flow if needed.  This function is typically O(N) in the number
175
   * of child frames, following in-flows, etc.
176
   *
177
   * @param aGenConParentFrame an ancestor of the ::after frame
178
   * @param aContent the content whose ::after is wanted
179
   * @return the ::after frame or nullptr if there isn't one
180
   */
181
  static nsIFrame* GetAfterFrameForContent(nsIFrame* aGenConParentFrame,
182
                                           nsIContent* aContent);
183
184
  /**
185
   * GetAfterFrame returns the outermost ::after frame of the given frame, if one
161
   * exists.  This will walk the in-flow chain to the last-in-flow if
186
   * exists.  This will walk the in-flow chain to the last-in-flow if
162
   * needed.  This function is typically O(N) in the number of child
187
   * needed.  This function is typically O(N) in the number of child
163
   * frames, following in-flows, etc.
188
   * frames, following in-flows, etc.
164
   *
189
   *
165
   * @param aFrame the frame whose :after is wanted
190
   * @param aFrame the frame whose ::after is wanted
166
   * @return the :after frame or nullptr if there isn't one
191
   * @return the :after frame or nullptr if there isn't one
167
   */
192
   */
168
  static nsIFrame* GetAfterFrame(nsIFrame* aFrame);
193
  static nsIFrame* GetAfterFrame(nsIFrame* aFrame);
169
194
170
  /**
195
  /**
171
   * Given a frame, search up the frame tree until we find an
196
   * Given a frame, search up the frame tree until we find an
172
   * ancestor that (or the frame itself) is of type aFrameType, if any.
197
   * ancestor that (or the frame itself) is of type aFrameType, if any.
173
   *
198
   *
(-)mc.082761b7bc54/layout/base/nsStyleChangeList.cpp (-2 / +8 lines)
Line     Link Here 
 Lines 5-20    Link Here 
5
5
6
/*
6
/*
7
 * a list of the recomputation that needs to be done in response to a
7
 * a list of the recomputation that needs to be done in response to a
8
 * style change
8
 * style change
9
 */
9
 */
10
10
11
#include "nsStyleChangeList.h"
11
#include "nsStyleChangeList.h"
12
#include "nsIContent.h"
12
#include "nsIContent.h"
13
#include "nsIFrame.h"
14
#include "nsFrameManager.h"
13
15
14
static const uint32_t kGrowArrayBy = 10;
16
static const uint32_t kGrowArrayBy = 10;
15
17
16
nsStyleChangeList::nsStyleChangeList()
18
nsStyleChangeList::nsStyleChangeList()
17
  : mArray(mBuffer),
19
  : mArray(mBuffer),
18
    mArraySize(kStyleChangeBufferSize),
20
    mArraySize(kStyleChangeBufferSize),
19
    mCount(0)
21
    mCount(0)
20
{
22
{
 Lines 53-70   nsStyleChangeList::ChangeAt(int32_t aInd Link Here 
53
nsresult 
55
nsresult 
54
nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint)
56
nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint)
55
{
57
{
56
  NS_ASSERTION(aFrame || (aHint & nsChangeHint_ReconstructFrame),
58
  NS_ASSERTION(aFrame || (aHint & nsChangeHint_ReconstructFrame),
57
               "must have frame");
59
               "must have frame");
58
  NS_ASSERTION(aContent || !(aHint & nsChangeHint_ReconstructFrame),
60
  NS_ASSERTION(aContent || !(aHint & nsChangeHint_ReconstructFrame),
59
               "must have content");
61
               "must have content");
60
  // XXXbz we should make this take Element instead of nsIContent
62
  // XXXbz we should make this take Element instead of nsIContent
61
  NS_ASSERTION(!aContent || aContent->IsElement(),
63
  NS_ASSERTION(!aContent || aContent->IsElement() ||
62
               "Shouldn't be trying to restyle non-elements directly");
64
               // display-box:contents elements posts the changes for their children:
65
               (aFrame && aContent->GetParent() &&
66
                aFrame->PresContext()->FrameManager()->GetDisplayBoxContentsStyleFor(aContent->GetParent())),
67
               "Shouldn't be trying to restyle non-elements directly, "
68
               "except if it's a display-box:contents child");
63
  NS_ASSERTION(!(aHint & nsChangeHint_AllReflowHints) ||
69
  NS_ASSERTION(!(aHint & nsChangeHint_AllReflowHints) ||
64
               (aHint & nsChangeHint_NeedReflow),
70
               (aHint & nsChangeHint_NeedReflow),
65
               "Reflow hint bits set without actually asking for a reflow");
71
               "Reflow hint bits set without actually asking for a reflow");
66
72
67
  if ((0 < mCount) && (aHint & nsChangeHint_ReconstructFrame)) { // filter out all other changes for same content
73
  if ((0 < mCount) && (aHint & nsChangeHint_ReconstructFrame)) { // filter out all other changes for same content
68
    if (aContent) {
74
    if (aContent) {
69
      for (int32_t index = mCount - 1; index >= 0; --index) {
75
      for (int32_t index = mCount - 1; index >= 0; --index) {
70
        if (aContent == mArray[index].mContent) { // remove this change
76
        if (aContent == mArray[index].mContent) { // remove this change
(-)mc.082761b7bc54/layout/base/RestyleManager.cpp (-89 / +267 lines)
Line     Link Here 
 Lines 68-83   RestyleManager::NotifyDestroyingFrame(ns Link Here 
68
}
68
}
69
69
70
#ifdef DEBUG
70
#ifdef DEBUG
71
  // To ensure that the functions below are only called within
71
  // To ensure that the functions below are only called within
72
  // |ApplyRenderingChangeToTree|.
72
  // |ApplyRenderingChangeToTree|.
73
static bool gInApplyRenderingChangeToTree = false;
73
static bool gInApplyRenderingChangeToTree = false;
74
#endif
74
#endif
75
75
76
static nsIFrame*
77
GetNearestAncestorFrame(nsIContent* aContent)
78
{
79
  nsIFrame* ancestorFrame = nullptr;
80
  for (nsIContent* ancestor = aContent->GetParent();
81
       ancestor && !ancestorFrame;
82
       ancestor = ancestor->GetParent()) {
83
    ancestorFrame = ancestor->GetPrimaryFrame();
84
  }
85
  return ancestorFrame;
86
}
87
88
76
static void
89
static void
77
DoApplyRenderingChangeToTree(nsIFrame* aFrame,
90
DoApplyRenderingChangeToTree(nsIFrame* aFrame,
78
                             nsChangeHint aChange);
91
                             nsChangeHint aChange);
79
92
80
/**
93
/**
81
 * Sync views on aFrame and all of aFrame's descendants (following placeholders),
94
 * Sync views on aFrame and all of aFrame's descendants (following placeholders),
82
 * if aChange has nsChangeHint_SyncFrameView.
95
 * if aChange has nsChangeHint_SyncFrameView.
83
 * Calls DoApplyRenderingChangeToTree on all aFrame's out-of-flow descendants
96
 * Calls DoApplyRenderingChangeToTree on all aFrame's out-of-flow descendants
 Lines 834-850   RestyleManager::RestyleElement(Element* Link Here 
834
    FrameConstructor()->RecreateFramesForContent(aElement, false);
847
    FrameConstructor()->RecreateFramesForContent(aElement, false);
835
  } else if (aPrimaryFrame) {
848
  } else if (aPrimaryFrame) {
836
    nsStyleChangeList changeList;
849
    nsStyleChangeList changeList;
837
    ComputeStyleChangeFor(aPrimaryFrame, &changeList, aMinHint,
850
    ComputeStyleChangeFor(aPrimaryFrame, &changeList, aMinHint,
838
                          aRestyleTracker, aRestyleDescendants);
851
                          aRestyleTracker, aRestyleDescendants);
839
    ProcessRestyledFrames(changeList);
852
    ProcessRestyledFrames(changeList);
840
  } else {
853
  } else {
841
    // no frames, reconstruct for content
854
    // no frames, reconstruct for content
855
    nsStyleContext* newContext =
842
    FrameConstructor()->MaybeRecreateFramesForElement(aElement);
856
    FrameConstructor()->MaybeRecreateFramesForElement(aElement);
857
    if (newContext &&
858
        newContext->StyleDisplay()->mDisplayBox == NS_STYLE_DISPLAY_BOX_CONTENTS) {
859
      // Style change for a display-box:contents node that did not recreate frames.
860
      nsIFrame* frame = GetNearestAncestorFrame(aElement);
861
      MOZ_ASSERT(frame, "display-box:contents node in map although "
862
                        "it's a display:none descendant?");
863
      TreeMatchContext treeMatchContext(true,
864
                                        nsRuleWalker::eRelevantLinkUnvisited,
865
                                        frame->PresContext()->Document());
866
      nsIContent* parent = aElement->GetParent();
867
      Element* parentElement =
868
        parent && parent->IsElement() ? parent->AsElement() : nullptr;
869
      treeMatchContext.InitAncestors(parentElement);
870
      nsTArray<nsIContent*> visibleKidsOfHiddenElement;
871
      nsStyleChangeList changeList;
872
      ElementRestyler r(frame->PresContext(), aElement, &changeList,
873
                        aMinHint, aRestyleTracker, treeMatchContext,
874
                        visibleKidsOfHiddenElement);
875
      r.RestyleChildrenOfDisplayBoxContentsElement(frame, newContext,
876
                                                   aMinHint, aRestyleTracker,
877
                                                   aRestyleDescendants, this);
878
      ProcessRestyledFrames(changeList);
879
    }
843
  }
880
  }
844
}
881
}
845
882
846
static inline dom::Element*
883
static inline dom::Element*
847
ElementForStyleContext(nsIContent* aParentContent,
884
ElementForStyleContext(nsIContent* aParentContent,
848
                       nsIFrame* aFrame,
885
                       nsIFrame* aFrame,
849
                       nsCSSPseudoElements::Type aPseudoType);
886
                       nsCSSPseudoElements::Type aPseudoType);
850
887
 Lines 1571-1594   VerifyContextParent(nsPresContext* aPres Link Here 
1571
                    nsStyleContext* aContext, nsStyleContext* aParentContext)
1608
                    nsStyleContext* aContext, nsStyleContext* aParentContext)
1572
{
1609
{
1573
  // get the contexts not provided
1610
  // get the contexts not provided
1574
  if (!aContext) {
1611
  if (!aContext) {
1575
    aContext = aFrame->StyleContext();
1612
    aContext = aFrame->StyleContext();
1576
  }
1613
  }
1577
1614
1578
  if (!aParentContext) {
1615
  if (!aParentContext) {
1579
    // Get the correct parent context from the frame
1616
    nsIFrame* providerFrame;
1580
    //  - if the frame is a placeholder, we get the out of flow frame's context
1617
    aParentContext = aFrame->GetParentStyleContext(&providerFrame);
1581
    //    as the parent context instead of asking the frame
1582
1583
    // get the parent context from the frame (indirectly)
1584
    nsIFrame* providerFrame = aFrame->GetParentStyleContextFrame();
1585
    if (providerFrame)
1586
      aParentContext = providerFrame->StyleContext();
1587
    // aParentContext could still be null
1618
    // aParentContext could still be null
1588
  }
1619
  }
1589
1620
1590
  NS_ASSERTION(aContext, "Failure to get required contexts");
1621
  NS_ASSERTION(aContext, "Failure to get required contexts");
1591
  nsStyleContext* actualParentContext = aContext->GetParent();
1622
  nsStyleContext* actualParentContext = aContext->GetParent();
1592
1623
1593
  if (aParentContext) {
1624
  if (aParentContext) {
1594
    if (aParentContext != actualParentContext) {
1625
    if (aParentContext != actualParentContext) {
 Lines 1904-1933   RestyleManager::ReparentStyleContext(nsI Link Here 
1904
    } while ((outOfFlow = outOfFlow->GetNextContinuation()));
1935
    } while ((outOfFlow = outOfFlow->GetNextContinuation()));
1905
  }
1936
  }
1906
1937
1907
  // DO NOT verify the style tree before reparenting.  The frame
1938
  // DO NOT verify the style tree before reparenting.  The frame
1908
  // tree has already been changed, so this check would just fail.
1939
  // tree has already been changed, so this check would just fail.
1909
  nsStyleContext* oldContext = aFrame->StyleContext();
1940
  nsStyleContext* oldContext = aFrame->StyleContext();
1910
1941
1911
  nsRefPtr<nsStyleContext> newContext;
1942
  nsRefPtr<nsStyleContext> newContext;
1912
  nsIFrame* providerFrame = aFrame->GetParentStyleContextFrame();
1943
  nsIFrame* providerFrame;
1944
  nsStyleContext* newParentContext = aFrame->GetParentStyleContext(&providerFrame);
1913
  bool isChild = providerFrame && providerFrame->GetParent() == aFrame;
1945
  bool isChild = providerFrame && providerFrame->GetParent() == aFrame;
1914
  nsStyleContext* newParentContext = nullptr;
1915
  nsIFrame* providerChild = nullptr;
1946
  nsIFrame* providerChild = nullptr;
1916
  if (isChild) {
1947
  if (isChild) {
1917
    ReparentStyleContext(providerFrame);
1948
    ReparentStyleContext(providerFrame);
1949
    // Get the style context again after ReparentStyleContext() which might have
1950
    // changed it.
1918
    newParentContext = providerFrame->StyleContext();
1951
    newParentContext = providerFrame->StyleContext();
1919
    providerChild = providerFrame;
1952
    providerChild = providerFrame;
1920
  } else if (providerFrame) {
1921
    newParentContext = providerFrame->StyleContext();
1922
  } else {
1923
    NS_NOTREACHED("Reparenting something that has no usable parent? "
1924
                  "Shouldn't happen!");
1925
  }
1953
  }
1954
  NS_ASSERTION(newParentContext, "Reparenting something that has no usable"
1955
               " parent? Shouldn't happen!");
1926
  // XXX need to do something here to produce the correct style context for
1956
  // XXX need to do something here to produce the correct style context for
1927
  // an IB split whose first inline part is inside a first-line frame.
1957
  // an IB split whose first inline part is inside a first-line frame.
1928
  // Currently the first IB anonymous block's style context takes the first
1958
  // Currently the first IB anonymous block's style context takes the first
1929
  // part's style context as parent, which is wrong since first-line style
1959
  // part's style context as parent, which is wrong since first-line style
1930
  // should not apply to the anonymous block.
1960
  // should not apply to the anonymous block.
1931
1961
1932
#ifdef DEBUG
1962
#ifdef DEBUG
1933
  {
1963
  {
 Lines 2176-2191   ElementRestyler::ElementRestyler(ParentC Link Here 
2176
  , mDesiredA11yNotifications(aParentRestyler.mDesiredA11yNotifications)
2206
  , mDesiredA11yNotifications(aParentRestyler.mDesiredA11yNotifications)
2177
  , mKidsDesiredA11yNotifications(mDesiredA11yNotifications)
2207
  , mKidsDesiredA11yNotifications(mDesiredA11yNotifications)
2178
  , mOurA11yNotification(eDontNotify)
2208
  , mOurA11yNotification(eDontNotify)
2179
  , mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement)
2209
  , mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement)
2180
#endif
2210
#endif
2181
{
2211
{
2182
}
2212
}
2183
2213
2214
ElementRestyler::ElementRestyler(nsPresContext* aPresContext,
2215
                                 nsIContent* aContent,
2216
                                 nsStyleChangeList* aChangeList,
2217
                                 nsChangeHint aHintsHandledByAncestors,
2218
                                 RestyleTracker& aRestyleTracker,
2219
                                 TreeMatchContext& aTreeMatchContext,
2220
                                 nsTArray<nsIContent*>&
2221
                                 aVisibleKidsOfHiddenElement)
2222
  : mPresContext(aPresContext)
2223
  , mFrame(nullptr)
2224
  , mParentContent(nullptr)
2225
  , mContent(aContent)
2226
  , mChangeList(aChangeList)
2227
  , mHintsHandled(NS_SubtractHint(aHintsHandledByAncestors,
2228
                  NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors)))
2229
  , mParentFrameHintsNotHandledForDescendants(nsChangeHint(0))
2230
  , mHintsNotHandledForDescendants(nsChangeHint(0))
2231
  , mRestyleTracker(aRestyleTracker)
2232
  , mTreeMatchContext(aTreeMatchContext)
2233
  , mResolvedChild(nullptr)
2234
#ifdef ACCESSIBILITY
2235
  , mDesiredA11yNotifications(eSendAllNotifications)
2236
  , mKidsDesiredA11yNotifications(mDesiredA11yNotifications)
2237
  , mOurA11yNotification(eDontNotify)
2238
  , mVisibleKidsOfHiddenElement(aVisibleKidsOfHiddenElement)
2239
#endif
2240
{
2241
}
2242
2184
void
2243
void
2185
ElementRestyler::CaptureChange(nsStyleContext* aOldContext,
2244
ElementRestyler::CaptureChange(nsStyleContext* aOldContext,
2186
                               nsStyleContext* aNewContext,
2245
                               nsStyleContext* aNewContext,
2187
                               nsChangeHint aChangeToAssume)
2246
                               nsChangeHint aChangeToAssume)
2188
{
2247
{
2189
  // Check some invariants about replacing one style context with another.
2248
  // Check some invariants about replacing one style context with another.
2190
  NS_ASSERTION(aOldContext->GetPseudo() == aNewContext->GetPseudo(),
2249
  NS_ASSERTION(aOldContext->GetPseudo() == aNewContext->GetPseudo(),
2191
               "old and new style contexts should have the same pseudo");
2250
               "old and new style contexts should have the same pseudo");
 Lines 2241-2256   ElementRestyler::Restyle(nsRestyleHint a Link Here 
2241
  // fix bug 242277 we should be able to make this make more sense.
2300
  // fix bug 242277 we should be able to make this make more sense.
2242
  NS_ASSERTION(mFrame->GetContent() || !mParentContent ||
2301
  NS_ASSERTION(mFrame->GetContent() || !mParentContent ||
2243
               !mParentContent->GetParent(),
2302
               !mParentContent->GetParent(),
2244
               "frame must have content (unless at the top of the tree)");
2303
               "frame must have content (unless at the top of the tree)");
2245
2304
2246
  NS_ASSERTION(!GetPrevContinuationWithSameStyle(mFrame),
2305
  NS_ASSERTION(!GetPrevContinuationWithSameStyle(mFrame),
2247
               "should not be trying to restyle this frame separately");
2306
               "should not be trying to restyle this frame separately");
2248
2307
2308
  AutoDisplayBoxContentsAncestorPusher adcp(mTreeMatchContext, mFrame->PresContext(),
2309
      mFrame->GetContent() ? mFrame->GetContent()->GetParent() : nullptr);
2310
2249
  if (mContent && mContent->IsElement()) {
2311
  if (mContent && mContent->IsElement()) {
2250
    mContent->OwnerDoc()->FlushPendingLinkUpdates();
2312
    mContent->OwnerDoc()->FlushPendingLinkUpdates();
2251
    RestyleTracker::RestyleData restyleData;
2313
    RestyleTracker::RestyleData restyleData;
2252
    if (mRestyleTracker.GetRestyleData(mContent->AsElement(), &restyleData)) {
2314
    if (mRestyleTracker.GetRestyleData(mContent->AsElement(), &restyleData)) {
2253
      if (NS_UpdateHint(mHintsHandled, restyleData.mChangeHint)) {
2315
      if (NS_UpdateHint(mHintsHandled, restyleData.mChangeHint)) {
2254
        mChangeList->AppendChange(mFrame, mContent, restyleData.mChangeHint);
2316
        mChangeList->AppendChange(mFrame, mContent, restyleData.mChangeHint);
2255
      }
2317
      }
2256
      aRestyleHint = nsRestyleHint(aRestyleHint | restyleData.mRestyleHint);
2318
      aRestyleHint = nsRestyleHint(aRestyleHint | restyleData.mRestyleHint);
 Lines 2270-2287   ElementRestyler::Restyle(nsRestyleHint a Link Here 
2270
    // continuation or block-in-inline sibling.
2332
    // continuation or block-in-inline sibling.
2271
2333
2272
    for (nsIFrame* f = mFrame; f;
2334
    for (nsIFrame* f = mFrame; f;
2273
         f = GetNextContinuationWithSameStyle(f, oldContext)) {
2335
         f = GetNextContinuationWithSameStyle(f, oldContext)) {
2274
      RestyleSelf(f, aRestyleHint);
2336
      RestyleSelf(f, aRestyleHint);
2275
    }
2337
    }
2276
  }
2338
  }
2277
2339
2340
  // No need to do this if we're planning to reframe already.
2341
  // It's also important to check mHintsHandled since we use
2342
  // mFrame->StyleContext(), which is out of date if mHintsHandled
2343
  // has a ReconstructFrame hint.  Using an out of date style
2344
  // context could trigger assertions about mismatched rule trees.
2345
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2278
  RestyleChildren(childRestyleHint);
2346
  RestyleChildren(childRestyleHint);
2279
}
2347
}
2348
}
2280
2349
2281
void
2350
void
2282
ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
2351
ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
2283
{
2352
{
2284
  // XXXldb get new context from prev-in-flow if possible, to avoid
2353
  // XXXldb get new context from prev-in-flow if possible, to avoid
2285
  // duplication.  (Or should we just let |GetContext| handle that?)
2354
  // duplication.  (Or should we just let |GetContext| handle that?)
2286
  // Getting the hint would be nice too, but that's harder.
2355
  // Getting the hint would be nice too, but that's harder.
2287
2356
 Lines 2296-2325   ElementRestyler::RestyleSelf(nsIFrame* a Link Here 
2296
#ifdef ACCESSIBILITY
2365
#ifdef ACCESSIBILITY
2297
  mWasFrameVisible = nsIPresShell::IsAccessibilityActive() ?
2366
  mWasFrameVisible = nsIPresShell::IsAccessibilityActive() ?
2298
    oldContext->StyleVisibility()->IsVisible() : false;
2367
    oldContext->StyleVisibility()->IsVisible() : false;
2299
#endif
2368
#endif
2300
2369
2301
  nsIAtom* const pseudoTag = oldContext->GetPseudo();
2370
  nsIAtom* const pseudoTag = oldContext->GetPseudo();
2302
  const nsCSSPseudoElements::Type pseudoType = oldContext->GetPseudoType();
2371
  const nsCSSPseudoElements::Type pseudoType = oldContext->GetPseudoType();
2303
2372
2304
  nsStyleContext* parentContext;
2305
  // Get the frame providing the parent style context.  If it is a
2373
  // Get the frame providing the parent style context.  If it is a
2306
  // child, then resolve the provider first.
2374
  // child, then resolve the provider first.
2307
  nsIFrame* providerFrame = aSelf->GetParentStyleContextFrame();
2375
  nsIFrame* providerFrame;
2376
  nsStyleContext* parentContext = mFrame->GetParentStyleContext(&providerFrame);
2308
  bool isChild = providerFrame && providerFrame->GetParent() == aSelf;
2377
  bool isChild = providerFrame && providerFrame->GetParent() == aSelf;
2309
  if (!isChild) {
2378
  if (isChild) {
2310
    if (providerFrame)
2311
      parentContext = providerFrame->StyleContext();
2312
    else
2313
      parentContext = nullptr;
2314
  }
2315
  else {
2316
    MOZ_ASSERT(providerFrame->GetContent() == aSelf->GetContent(),
2379
    MOZ_ASSERT(providerFrame->GetContent() == aSelf->GetContent(),
2317
               "Postcondition for GetParentStyleContextFrame() violated. "
2380
               "Postcondition for GetParentStyleContext() violated. "
2318
               "That means we need to add the current element to the "
2381
               "That means we need to add the current element to the "
2319
               "ancestor filter.");
2382
               "ancestor filter.");
2320
2383
2321
    // resolve the provider here (before aSelf below).
2384
    // resolve the provider here (before aSelf below).
2322
2385
2323
    // assumeDifferenceHint forces the parent's change to be also
2386
    // assumeDifferenceHint forces the parent's change to be also
2324
    // applied to this frame, no matter what
2387
    // applied to this frame, no matter what
2325
    // nsStyleContext::CalcStyleDifference says. CalcStyleDifference
2388
    // nsStyleContext::CalcStyleDifference says. CalcStyleDifference
 Lines 2507-2523   ElementRestyler::RestyleSelf(nsIFrame* a Link Here 
2507
      }
2570
      }
2508
    }
2571
    }
2509
  }
2572
  }
2510
}
2573
}
2511
2574
2512
void
2575
void
2513
ElementRestyler::RestyleChildren(nsRestyleHint aChildRestyleHint)
2576
ElementRestyler::RestyleChildren(nsRestyleHint aChildRestyleHint)
2514
{
2577
{
2515
  RestyleUndisplayedChildren(aChildRestyleHint);
2578
  MOZ_ASSERT(!(mHintsHandled & nsChangeHint_ReconstructFrame),
2579
             "No need to do this if we're planning to reframe already.");
2580
2581
  RestyleUndisplayedDescendants(aChildRestyleHint);
2516
2582
2517
  // Check whether we might need to create a new ::before frame.
2583
  // Check whether we might need to create a new ::before frame.
2518
  // There's no need to do this if we're planning to reframe already
2584
  // There's no need to do this if we're planning to reframe already
2519
  // or if we're not forcing restyles on kids.
2585
  // or if we're not forcing restyles on kids.
2520
  // It's also important to check mHintsHandled since we use
2586
  // It's also important to check mHintsHandled since we use
2521
  // mFrame->StyleContext(), which is out of date if mHintsHandled has a
2587
  // mFrame->StyleContext(), which is out of date if mHintsHandled has a
2522
  // ReconstructFrame hint.  Using an out of date style context could
2588
  // ReconstructFrame hint.  Using an out of date style context could
2523
  // trigger assertions about mismatched rule trees.
2589
  // trigger assertions about mismatched rule trees.
 Lines 2532-2548   ElementRestyler::RestyleChildren(nsResty Link Here 
2532
  // descendants anyway, so we want to avoid wasting time processing
2598
  // descendants anyway, so we want to avoid wasting time processing
2533
  // style contexts that we're just going to throw away anyway. - dwh
2599
  // style contexts that we're just going to throw away anyway. - dwh
2534
  // It's also important to check mHintsHandled since reresolving the
2600
  // It's also important to check mHintsHandled since reresolving the
2535
  // kids would use mFrame->StyleContext(), which is out of date if
2601
  // kids would use mFrame->StyleContext(), which is out of date if
2536
  // mHintsHandled has a ReconstructFrame hint; doing this could trigger
2602
  // mHintsHandled has a ReconstructFrame hint; doing this could trigger
2537
  // assertions about mismatched rule trees.
2603
  // assertions about mismatched rule trees.
2538
  nsIFrame *lastContinuation;
2604
  nsIFrame *lastContinuation;
2539
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2605
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2540
    InitializeAccessibilityNotifications();
2606
    InitializeAccessibilityNotifications(mFrame->StyleContext());
2541
2607
2542
    for (nsIFrame* f = mFrame; f;
2608
    for (nsIFrame* f = mFrame; f;
2543
         f = GetNextContinuationWithSameStyle(f, f->StyleContext())) {
2609
         f = GetNextContinuationWithSameStyle(f, f->StyleContext())) {
2544
      lastContinuation = f;
2610
      lastContinuation = f;
2545
      RestyleContentChildren(f, aChildRestyleHint);
2611
      RestyleContentChildren(f, aChildRestyleHint);
2546
    }
2612
    }
2547
2613
2548
    SendAccessibilityNotifications();
2614
    SendAccessibilityNotifications();
 Lines 2552-2592   ElementRestyler::RestyleChildren(nsResty Link Here 
2552
  // See comments above regarding :before.
2618
  // See comments above regarding :before.
2553
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame) &&
2619
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame) &&
2554
      aChildRestyleHint) {
2620
      aChildRestyleHint) {
2555
    RestyleAfterPseudo(lastContinuation);
2621
    RestyleAfterPseudo(lastContinuation);
2556
  }
2622
  }
2557
}
2623
}
2558
2624
2559
void
2625
void
2560
ElementRestyler::RestyleUndisplayedChildren(nsRestyleHint aChildRestyleHint)
2626
ElementRestyler::RestyleChildrenOfDisplayBoxContentsElement(
2627
  nsIFrame*       aParentFrame,
2628
  nsStyleContext* aNewContext,
2629
  nsChangeHint    aMinHint,
2630
  RestyleTracker& aRestyleTracker,
2631
  bool            aRestyleDescendants,
2632
  RestyleManager* aRestyleManager)
2633
{
2634
  InitializeAccessibilityNotifications(aNewContext);
2635
  DoRestyleUndisplayedDescendants(nsRestyleHint(0), mContent, aNewContext);
2636
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2637
    RestyleBeforePseudo(aParentFrame, nullptr, mContent, aNewContext);
2638
  }
2639
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2640
    RestyleAfterPseudo(aParentFrame, nullptr, mContent, aNewContext);
2641
  }
2642
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2643
    // Then process child frames for content that is a descendant of mContent.
2644
    // XXX perhaps it's better to walk child frames (before reresolving
2645
    // XXX undisplayed contexts above) and mark those that has a stylecontext
2646
    // XXX leading up to mContent's old context? (instead of the
2647
    // XXX ContentIsDescendantOf check below)
2648
    nsIFrame::ChildListIterator lists(aParentFrame);
2649
    for ( ; !lists.IsDone(); lists.Next()) {
2650
      nsFrameList::Enumerator childFrames(lists.CurrentList());
2651
      for (; !childFrames.AtEnd(); childFrames.Next()) {
2652
        nsIFrame* f = childFrames.get();
2653
        nsIContent* c = f->GetContent();
2654
        if (nsContentUtils::ContentIsDescendantOf(c, mContent) &&
2655
            !f->GetPrevContinuation()) {
2656
          if (!(f->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
2657
            aRestyleManager->ComputeStyleChangeFor(f, mChangeList, aMinHint,
2658
                                                   aRestyleTracker,
2659
                                                   aRestyleDescendants);
2660
          }
2661
        }
2662
      }
2663
    }
2664
  }
2665
  if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2666
    SendAccessibilityNotifications();
2667
  }
2668
}
2669
2670
void
2671
ElementRestyler::RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint)
2561
{
2672
{
2562
  // When the root element is display:none, we still construct *some*
2673
  // When the root element is display:none, we still construct *some*
2563
  // frames that have the root element as their mContent, down to the
2674
  // frames that have the root element as their mContent, down to the
2564
  // DocElementContainingBlock.
2675
  // DocElementContainingBlock.
2565
  bool checkUndisplayed;
2676
  bool checkUndisplayed;
2566
  nsIContent* undisplayedParent;
2677
  nsIContent* undisplayedParent;
2567
  nsCSSFrameConstructor* frameConstructor = mPresContext->FrameConstructor();
2568
  if (mFrame->StyleContext()->GetPseudo()) {
2678
  if (mFrame->StyleContext()->GetPseudo()) {
2569
    checkUndisplayed = mFrame == frameConstructor->
2679
    checkUndisplayed = mFrame == mPresContext->FrameConstructor()->
2570
                                   GetDocElementContainingBlock();
2680
                                   GetDocElementContainingBlock();
2571
    undisplayedParent = nullptr;
2681
    undisplayedParent = nullptr;
2572
  } else {
2682
  } else {
2573
    checkUndisplayed = !!mFrame->GetContent();
2683
    checkUndisplayed = !!mFrame->GetContent();
2574
    undisplayedParent = mFrame->GetContent();
2684
    undisplayedParent = mFrame->GetContent();
2575
  }
2685
  }
2576
  if (checkUndisplayed &&
2686
  if (checkUndisplayed) {
2577
      // No need to do this if we're planning to reframe already.
2687
    DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayedParent,
2578
      // It's also important to check mHintsHandled since we use
2688
                                    mFrame->StyleContext());
2579
      // mFrame->StyleContext(), which is out of date if mHintsHandled
2689
  }
2580
      // has a ReconstructFrame hint.  Using an out of date style
2690
}
2581
      // context could trigger assertions about mismatched rule trees.
2691
2582
      !(mHintsHandled & nsChangeHint_ReconstructFrame)) {
2692
void
2583
    UndisplayedNode* undisplayed =
2693
ElementRestyler::DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint,
2584
      frameConstructor->GetAllUndisplayedContentIn(undisplayedParent);
2694
                                                 nsIContent* aParent,
2695
                                                 nsStyleContext* aParentContext)
2696
{
2697
  nsCSSFrameConstructor* fc = mPresContext->FrameConstructor();
2698
  UndisplayedNode* nodes = fc->GetAllUndisplayedContentIn(aParent);
2699
  RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent,
2700
                          aParentContext, NS_STYLE_DISPLAY_BOX_NONE);
2701
  nodes = fc->GetAllDisplayBoxContentsIn(aParent);
2702
  RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent,
2703
                          aParentContext, NS_STYLE_DISPLAY_BOX_CONTENTS);
2704
}
2705
2706
void
2707
ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint    aChildRestyleHint,
2708
                                         UndisplayedNode* aUndisplayed,
2709
                                         nsIContent*      aUndisplayedParent,
2710
                                         nsStyleContext*  aParentContext,
2711
                                         const uint8_t    aDisplayBoxStyle)
2712
{
2713
  nsIContent* undisplayedParent = aUndisplayedParent;
2714
  UndisplayedNode* undisplayed = aUndisplayed;
2585
    TreeMatchContext::AutoAncestorPusher pusher(mTreeMatchContext);
2715
    TreeMatchContext::AutoAncestorPusher pusher(mTreeMatchContext);
2586
    if (undisplayed) {
2716
    if (undisplayed) {
2587
      pusher.PushAncestorAndStyleScope(undisplayedParent);
2717
      pusher.PushAncestorAndStyleScope(undisplayedParent);
2588
    }
2718
    }
2589
    for (; undisplayed; undisplayed = undisplayed->mNext) {
2719
    for (; undisplayed; undisplayed = undisplayed->mNext) {
2590
      NS_ASSERTION(undisplayedParent ||
2720
      NS_ASSERTION(undisplayedParent ||
2591
                   undisplayed->mContent ==
2721
                   undisplayed->mContent ==
2592
                     mPresContext->Document()->GetRootElement(),
2722
                     mPresContext->Document()->GetRootElement(),
 Lines 2595-2727   ElementRestyler::RestyleUndisplayedChild Link Here 
2595
                   "Shouldn't have random pseudo style contexts in the "
2725
                   "Shouldn't have random pseudo style contexts in the "
2596
                   "undisplayed map");
2726
                   "undisplayed map");
2597
2727
2598
      // Get the parent of the undisplayed content and check if it is a XBL
2728
      // Get the parent of the undisplayed content and check if it is a XBL
2599
      // children element. Push the children element as an ancestor here because it does
2729
      // children element. Push the children element as an ancestor here because it does
2600
      // not have a frame and would not otherwise be pushed as an ancestor.
2730
      // not have a frame and would not otherwise be pushed as an ancestor.
2601
      nsIContent* parent = undisplayed->mContent->GetParent();
2731
      nsIContent* parent = undisplayed->mContent->GetParent();
2602
      TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
2732
      TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
2603
      if (parent && nsContentUtils::IsContentInsertionPoint(parent)) {
2733
    if (parent && parent->IsActiveChildrenElement()) {
2604
        insertionPointPusher.PushAncestorAndStyleScope(parent);
2734
        insertionPointPusher.PushAncestorAndStyleScope(parent);
2605
      }
2735
      }
2606
2736
2607
      nsRestyleHint thisChildHint = aChildRestyleHint;
2737
      nsRestyleHint thisChildHint = aChildRestyleHint;
2608
      RestyleTracker::RestyleData undisplayedRestyleData;
2738
      RestyleTracker::RestyleData undisplayedRestyleData;
2609
      if (mRestyleTracker.GetRestyleData(undisplayed->mContent->AsElement(),
2739
      if (mRestyleTracker.GetRestyleData(undisplayed->mContent->AsElement(),
2610
                                         &undisplayedRestyleData)) {
2740
                                         &undisplayedRestyleData)) {
2611
        thisChildHint =
2741
        thisChildHint =
2612
          nsRestyleHint(thisChildHint | undisplayedRestyleData.mRestyleHint);
2742
          nsRestyleHint(thisChildHint | undisplayedRestyleData.mRestyleHint);
2613
      }
2743
      }
2614
      nsRefPtr<nsStyleContext> undisplayedContext;
2744
      nsRefPtr<nsStyleContext> undisplayedContext;
2615
      nsStyleSet* styleSet = mPresContext->StyleSet();
2745
      nsStyleSet* styleSet = mPresContext->StyleSet();
2616
      if (thisChildHint) {
2746
      if (thisChildHint) {
2617
        undisplayedContext =
2747
        undisplayedContext =
2618
          styleSet->ResolveStyleFor(undisplayed->mContent->AsElement(),
2748
          styleSet->ResolveStyleFor(undisplayed->mContent->AsElement(),
2619
                                    mFrame->StyleContext(),
2749
                                  aParentContext,
2620
                                    mTreeMatchContext);
2750
                                    mTreeMatchContext);
2621
      } else {
2751
      } else {
2622
        undisplayedContext =
2752
        undisplayedContext =
2623
          styleSet->ReparentStyleContext(undisplayed->mStyle,
2753
          styleSet->ReparentStyleContext(undisplayed->mStyle,
2624
                                         mFrame->StyleContext(),
2754
                                       aParentContext,
2625
                                         undisplayed->mContent->AsElement());
2755
                                         undisplayed->mContent->AsElement());
2626
      }
2756
      }
2627
      const nsStyleDisplay* display = undisplayedContext->StyleDisplay();
2757
      const nsStyleDisplay* display = undisplayedContext->StyleDisplay();
2628
      if (display->mDisplay != NS_STYLE_DISPLAY_NONE) {
2758
    if (display->mDisplayBox != aDisplayBoxStyle) {
2629
        NS_ASSERTION(undisplayed->mContent,
2759
      NS_ASSERTION(undisplayed->mContent, "Must have undisplayed content");
2630
                     "Must have undisplayed content");
2631
        mChangeList->AppendChange(nullptr, undisplayed->mContent,
2760
        mChangeList->AppendChange(nullptr, undisplayed->mContent,
2632
                                  NS_STYLE_HINT_FRAMECHANGE);
2761
                                  NS_STYLE_HINT_FRAMECHANGE);
2633
        // The node should be removed from the undisplayed map when
2762
        // The node should be removed from the undisplayed map when
2634
        // we reframe it.
2763
        // we reframe it.
2635
      } else {
2764
      } else {
2636
        // update the undisplayed node with the new context
2765
        // update the undisplayed node with the new context
2637
        undisplayed->mStyle = undisplayedContext;
2766
        undisplayed->mStyle = undisplayedContext;
2767
2768
      if (aDisplayBoxStyle == NS_STYLE_DISPLAY_BOX_CONTENTS) {
2769
        DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayed->mContent,
2770
                                        undisplayed->mStyle);
2638
      }
2771
      }
2639
    }
2772
    }
2640
  }
2773
  }
2641
}
2774
}
2642
2775
2643
void
2776
void
2644
ElementRestyler::RestyleBeforePseudo()
2777
ElementRestyler::RestyleBeforePseudo()
2645
{
2778
{
2779
  RestyleBeforePseudo(mFrame, mFrame, mFrame->GetContent(),
2780
                      mFrame->StyleContext());
2781
}
2782
2783
void
2784
ElementRestyler::RestyleBeforePseudo(nsIFrame* aGenConParentFrame,
2785
                                     nsIFrame* aFrame,
2786
                                     nsIContent* aContent,
2787
                                     nsStyleContext* aStyleContext)
2788
{
2646
  // Make sure not to do this for pseudo-frames or frames that
2789
  // Make sure not to do this for pseudo-frames or frames that
2647
  // can't have generated content.
2790
  // can't have generated content.
2648
  if (!mFrame->StyleContext()->GetPseudo() &&
2791
  if (!aStyleContext->GetPseudo() &&
2649
      ((mFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
2792
      ((aGenConParentFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
2650
       // Our content insertion frame might have gotten flagged
2793
       // Our content insertion frame might have gotten flagged.
2651
       (mFrame->GetContentInsertionFrame()->GetStateBits() &
2794
       (aGenConParentFrame->GetContentInsertionFrame()->GetStateBits() &
2652
        NS_FRAME_MAY_HAVE_GENERATED_CONTENT))) {
2795
        NS_FRAME_MAY_HAVE_GENERATED_CONTENT))) {
2653
    // Check for a new :before pseudo and an existing :before
2796
    // Check for a ::before pseudo style and the absence of a ::before content,
2654
    // frame, but only if the frame is the first continuation.
2797
    // but only if aFrame is null or is the first continuation.
2655
    nsIFrame* prevContinuation = mFrame->GetPrevContinuation();
2798
    if (!aFrame || !aFrame->GetPrevContinuation()) {
2656
    if (!prevContinuation) {
2799
      if (!nsLayoutUtils::GetBeforeFrameForContent(aGenConParentFrame, aContent) &&
2657
      // Checking for a :before frame is cheaper than getting the
2800
          nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
2658
      // :before style context.
2659
      if (!nsLayoutUtils::GetBeforeFrame(mFrame) &&
2660
          nsLayoutUtils::HasPseudoStyle(mFrame->GetContent(),
2661
                                        mFrame->StyleContext(),
2662
                                        nsCSSPseudoElements::ePseudo_before,
2801
                                        nsCSSPseudoElements::ePseudo_before,
2663
                                        mPresContext)) {
2802
                                        mPresContext)) {
2664
        // Have to create the new :before frame
2803
        // Have to create the new ::before frame.
2665
        NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame);
2804
        NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame);
2666
        mChangeList->AppendChange(mFrame, mContent,
2805
        mChangeList->AppendChange(aFrame, aContent,
2667
                                  nsChangeHint_ReconstructFrame);
2806
                                  nsChangeHint_ReconstructFrame);
2668
      }
2807
      }
2669
    }
2808
    }
2670
  }
2809
  }
2671
}
2810
}
2672
2811
2673
/**
2812
/**
2674
 * aFrame is the last continuation or block-in-inline sibling that this
2813
 * aFrame is the last continuation or block-in-inline sibling that this
2675
 * ElementRestyler is restyling.
2814
 * ElementRestyler is restyling.
2676
 */
2815
 */
2677
void
2816
void
2678
ElementRestyler::RestyleAfterPseudo(nsIFrame* aFrame)
2817
ElementRestyler::RestyleAfterPseudo(nsIFrame* aFrame)
2679
{
2818
{
2819
  MOZ_ASSERT(aFrame);
2820
  RestyleAfterPseudo(aFrame, aFrame, aFrame->GetContent(),
2821
                     aFrame->StyleContext());
2822
}
2823
2824
void
2825
ElementRestyler::RestyleAfterPseudo(nsIFrame* aGenConParentFrame,
2826
                                    nsIFrame* aFrame,
2827
                                    nsIContent* aContent,
2828
                                    nsStyleContext* aStyleContext)
2829
{
2680
  // Make sure not to do this for pseudo-frames or frames that
2830
  // Make sure not to do this for pseudo-frames or frames that
2681
  // can't have generated content.
2831
  // can't have generated content.
2682
  if (!aFrame->StyleContext()->GetPseudo() &&
2832
  if (!aStyleContext->GetPseudo() &&
2683
      ((aFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
2833
      ((aGenConParentFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
2684
       // Our content insertion frame might have gotten flagged
2834
       // Our content insertion frame might have gotten flagged.
2685
       (aFrame->GetContentInsertionFrame()->GetStateBits() &
2835
       (aGenConParentFrame->GetContentInsertionFrame()->GetStateBits() &
2686
        NS_FRAME_MAY_HAVE_GENERATED_CONTENT))) {
2836
        NS_FRAME_MAY_HAVE_GENERATED_CONTENT))) {
2687
    // Check for new :after content, but only if the frame is the
2837
    // Check for an ::after pseudo style and the absence of an ::after content,
2688
    // last continuation.
2838
    // but only if aFrame is null or is the last continuation.
2689
    nsIFrame* nextContinuation = aFrame->GetNextContinuation();
2839
    if (!aFrame || !aFrame->GetNextContinuation()) {
2690
2840
      if (!nsLayoutUtils::GetAfterFrameForContent(aGenConParentFrame, aContent) &&
2691
    if (!nextContinuation) {
2841
          nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
2692
      // Getting the :after frame is more expensive than getting the pseudo
2693
      // context, so get the pseudo context first.
2694
      if (nsLayoutUtils::HasPseudoStyle(aFrame->GetContent(),
2695
                                        aFrame->StyleContext(),
2696
                                        nsCSSPseudoElements::ePseudo_after,
2842
                                        nsCSSPseudoElements::ePseudo_after,
2697
                                        mPresContext) &&
2843
                                        mPresContext)) {
2698
          !nsLayoutUtils::GetAfterFrame(aFrame)) {
2844
        // Have to create the new ::after frame.
2699
        // have to create the new :after frame
2700
        NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame);
2845
        NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame);
2701
        mChangeList->AppendChange(aFrame, mContent,
2846
        mChangeList->AppendChange(aFrame, mContent,
2702
                                  nsChangeHint_ReconstructFrame);
2847
                                  nsChangeHint_ReconstructFrame);
2703
      }
2848
      }
2704
    }
2849
    }
2705
  }
2850
  }
2706
}
2851
}
2707
2852
2708
void
2853
void
2709
ElementRestyler::InitializeAccessibilityNotifications()
2854
ElementRestyler::InitializeAccessibilityNotifications(nsStyleContext* aNewContext)
2710
{
2855
{
2711
#ifdef ACCESSIBILITY
2856
#ifdef ACCESSIBILITY
2712
  // Notify a11y for primary frame only if it's a root frame of visibility
2857
  // Notify a11y for primary frame only if it's a root frame of visibility
2713
  // changes or its parent frame was hidden while it stays visible and
2858
  // changes or its parent frame was hidden while it stays visible and
2714
  // it is not inside a {ib} split or is the first frame of {ib} split.
2859
  // it is not inside a {ib} split or is the first frame of {ib} split.
2715
  if (nsIPresShell::IsAccessibilityActive() &&
2860
  if (nsIPresShell::IsAccessibilityActive() &&
2716
      !mFrame->GetPrevContinuation() &&
2861
      (!mFrame ||
2717
      !mFrame->FrameIsNonFirstInIBSplit()) {
2862
       (!mFrame->GetPrevContinuation() &&
2863
        !mFrame->FrameIsNonFirstInIBSplit()))) {
2718
    if (mDesiredA11yNotifications == eSendAllNotifications) {
2864
    if (mDesiredA11yNotifications == eSendAllNotifications) {
2719
      bool isFrameVisible = mFrame->StyleVisibility()->IsVisible();
2865
      bool isFrameVisible = aNewContext->StyleVisibility()->IsVisible();
2720
      if (isFrameVisible != mWasFrameVisible) {
2866
      if (isFrameVisible != mWasFrameVisible) {
2721
        if (isFrameVisible) {
2867
        if (isFrameVisible) {
2722
          // Notify a11y the element (perhaps with its children) was shown.
2868
          // Notify a11y the element (perhaps with its children) was shown.
2723
          // We don't fall into this case if this element gets or stays shown
2869
          // We don't fall into this case if this element gets or stays shown
2724
          // while its parent becomes hidden.
2870
          // while its parent becomes hidden.
2725
          mKidsDesiredA11yNotifications = eSkipNotifications;
2871
          mKidsDesiredA11yNotifications = eSkipNotifications;
2726
          mOurA11yNotification = eNotifyShown;
2872
          mOurA11yNotification = eNotifyShown;
2727
        } else {
2873
        } else {
 Lines 2730-2749   ElementRestyler::InitializeAccessibility Link Here 
2730
          // visible children then we should notify a11y about that as if
2876
          // visible children then we should notify a11y about that as if
2731
          // they were inserted into tree. Notify a11y this element was
2877
          // they were inserted into tree. Notify a11y this element was
2732
          // hidden.
2878
          // hidden.
2733
          mKidsDesiredA11yNotifications = eNotifyIfShown;
2879
          mKidsDesiredA11yNotifications = eNotifyIfShown;
2734
          mOurA11yNotification = eNotifyHidden;
2880
          mOurA11yNotification = eNotifyHidden;
2735
        }
2881
        }
2736
      }
2882
      }
2737
    } else if (mDesiredA11yNotifications == eNotifyIfShown &&
2883
    } else if (mDesiredA11yNotifications == eNotifyIfShown &&
2738
               mFrame->StyleVisibility()->IsVisible()) {
2884
               aNewContext->StyleVisibility()->IsVisible()) {
2739
      // Notify a11y that element stayed visible while its parent was
2885
      // Notify a11y that element stayed visible while its parent was hidden.
2740
      // hidden.
2886
      nsIContent* c = mFrame ? mFrame->GetContent() : mContent;
2741
      mVisibleKidsOfHiddenElement.AppendElement(mFrame->GetContent());
2887
      mVisibleKidsOfHiddenElement.AppendElement(c);
2742
      mKidsDesiredA11yNotifications = eSkipNotifications;
2888
      mKidsDesiredA11yNotifications = eSkipNotifications;
2743
    }
2889
    }
2744
  }
2890
  }
2745
#endif
2891
#endif
2746
}
2892
}
2747
2893
2748
void
2894
void
2749
ElementRestyler::RestyleContentChildren(nsIFrame* aParent,
2895
ElementRestyler::RestyleContentChildren(nsIFrame* aParent,
 Lines 2779-2795   ElementRestyler::RestyleContentChildren( Link Here 
2779
        if (nsGkAtoms::placeholderFrame == child->GetType()) { // placeholder
2925
        if (nsGkAtoms::placeholderFrame == child->GetType()) { // placeholder
2780
          // get out of flow frame and recur there
2926
          // get out of flow frame and recur there
2781
          nsIFrame* outOfFlowFrame =
2927
          nsIFrame* outOfFlowFrame =
2782
            nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
2928
            nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
2783
          NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
2929
          NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
2784
          NS_ASSERTION(outOfFlowFrame != mResolvedChild,
2930
          NS_ASSERTION(outOfFlowFrame != mResolvedChild,
2785
                       "out-of-flow frame not a true descendant");
2931
                       "out-of-flow frame not a true descendant");
2786
2932
2787
          // |nsFrame::GetParentStyleContextFrame| checks being out
2933
          // |nsFrame::GetParentStyleContext| checks being out
2788
          // of flow so that this works correctly.
2934
          // of flow so that this works correctly.
2789
          do {
2935
          do {
2790
            if (GetPrevContinuationWithSameStyle(outOfFlowFrame)) {
2936
            if (GetPrevContinuationWithSameStyle(outOfFlowFrame)) {
2791
              // Later continuations are likely restyled as a result of
2937
              // Later continuations are likely restyled as a result of
2792
              // the restyling of the previous continuation.
2938
              // the restyling of the previous continuation.
2793
              // (Currently that's always true, but it's likely to
2939
              // (Currently that's always true, but it's likely to
2794
              // change if we implement overflow:fragments or similar.)
2940
              // change if we implement overflow:fragments or similar.)
2795
              continue;
2941
              continue;
 Lines 2819-2846   ElementRestyler::RestyleContentChildren( Link Here 
2819
void
2965
void
2820
ElementRestyler::SendAccessibilityNotifications()
2966
ElementRestyler::SendAccessibilityNotifications()
2821
{
2967
{
2822
#ifdef ACCESSIBILITY
2968
#ifdef ACCESSIBILITY
2823
  // Send notifications about visibility changes.
2969
  // Send notifications about visibility changes.
2824
  if (mOurA11yNotification == eNotifyShown) {
2970
  if (mOurA11yNotification == eNotifyShown) {
2825
    nsAccessibilityService* accService = nsIPresShell::AccService();
2971
    nsAccessibilityService* accService = nsIPresShell::AccService();
2826
    if (accService) {
2972
    if (accService) {
2827
      nsIPresShell* presShell = mFrame->PresContext()->GetPresShell();
2973
      nsIPresShell* presShell = mPresContext->GetPresShell();
2828
      nsIContent* content = mFrame->GetContent();
2974
      nsIContent* content = mFrame ? mFrame->GetContent() : mContent;
2829
2975
2830
      accService->ContentRangeInserted(presShell, content->GetParent(),
2976
      accService->ContentRangeInserted(presShell, content->GetParent(),
2831
                                       content,
2977
                                       content,
2832
                                       content->GetNextSibling());
2978
                                       content->GetNextSibling());
2833
    }
2979
    }
2834
  } else if (mOurA11yNotification == eNotifyHidden) {
2980
  } else if (mOurA11yNotification == eNotifyHidden) {
2835
    nsAccessibilityService* accService = nsIPresShell::AccService();
2981
    nsAccessibilityService* accService = nsIPresShell::AccService();
2836
    if (accService) {
2982
    if (accService) {
2837
      nsIPresShell* presShell = mFrame->PresContext()->GetPresShell();
2983
      nsIPresShell* presShell = mPresContext->GetPresShell();
2838
      nsIContent* content = mFrame->GetContent();
2984
      nsIContent* content = mFrame ? mFrame->GetContent() : mContent;
2839
      accService->ContentRemoved(presShell, content->GetParent(), content);
2985
      accService->ContentRemoved(presShell, content->GetParent(), content);
2840
2986
2841
      // Process children staying shown.
2987
      // Process children staying shown.
2842
      uint32_t visibleContentCount = mVisibleKidsOfHiddenElement.Length();
2988
      uint32_t visibleContentCount = mVisibleKidsOfHiddenElement.Length();
2843
      for (uint32_t idx = 0; idx < visibleContentCount; idx++) {
2989
      for (uint32_t idx = 0; idx < visibleContentCount; idx++) {
2844
        nsIContent* childContent = mVisibleKidsOfHiddenElement[idx];
2990
        nsIContent* childContent = mVisibleKidsOfHiddenElement[idx];
2845
        accService->ContentRangeInserted(presShell, childContent->GetParent(),
2991
        accService->ContentRangeInserted(presShell, childContent->GetParent(),
2846
                                         childContent,
2992
                                         childContent,
 Lines 2930-2938   RestyleManager::ComputeStyleChangeFor(ns Link Here 
2930
        NS_ASSERTION(!cont->GetPrevContinuation(),
3076
        NS_ASSERTION(!cont->GetPrevContinuation(),
2931
                     "continuing frame had more severe impact than first-in-flow");
3077
                     "continuing frame had more severe impact than first-in-flow");
2932
        return;
3078
        return;
2933
      }
3079
      }
2934
    }
3080
    }
2935
  }
3081
  }
2936
}
3082
}
2937
3083
3084
AutoDisplayBoxContentsAncestorPusher::AutoDisplayBoxContentsAncestorPusher(
3085
  TreeMatchContext& aTreeMatchContext, nsPresContext* aPresContext,
3086
  nsIContent* aParent)
3087
  : mTreeMatchContext(aTreeMatchContext)
3088
  , mPresContext(aPresContext)
3089
{
3090
  if (aParent && mTreeMatchContext.mAncestorFilter.HasFilter()) {
3091
    nsFrameManager* fm = mPresContext->FrameManager();
3092
    // Push display-box:contents mAncestors onto mTreeMatchContext.
3093
    for (nsIContent* p = aParent; p && fm->GetDisplayBoxContentsStyleFor(p);
3094
         p = p->GetParent()) {
3095
      mAncestors.AppendElement(p->AsElement());
3096
    }
3097
    nsTArray<mozilla::dom::Element*>::size_type i = mAncestors.Length();
3098
    while (i--) {
3099
      mTreeMatchContext.mAncestorFilter.PushAncestor(mAncestors[i]);
3100
      mTreeMatchContext.PushStyleScope(mAncestors[i]);
3101
    }
3102
  }
3103
3104
}
3105
3106
AutoDisplayBoxContentsAncestorPusher::~AutoDisplayBoxContentsAncestorPusher()
3107
{
3108
  // Pop the ancestors we pushed in the CTOR, if any.
3109
  nsTArray<mozilla::dom::Element*>::size_type i = mAncestors.Length();
3110
  while (i--) {
3111
    mTreeMatchContext.mAncestorFilter.PopAncestor();
3112
    mTreeMatchContext.PopStyleScope(mAncestors[i]);
3113
  }
3114
}
3115
2938
} // namespace mozilla
3116
} // namespace mozilla
(-)mc.082761b7bc54/layout/base/RestyleManager.h (-4 / +61 lines)
Line     Link Here 
 Lines 17-37    Link Here 
17
#include "nsPresContext.h"
17
#include "nsPresContext.h"
18
18
19
class nsRefreshDriver;
19
class nsRefreshDriver;
20
class nsIFrame;
20
class nsIFrame;
21
struct TreeMatchContext;
21
struct TreeMatchContext;
22
22
23
namespace mozilla {
23
namespace mozilla {
24
24
25
struct UndisplayedNode;
26
25
namespace dom {
27
namespace dom {
26
  class Element;
28
  class Element;
27
} // namespace dom
29
} // namespace dom
28
30
29
class RestyleManager MOZ_FINAL {
31
class RestyleManager MOZ_FINAL
32
{
30
public:
33
public:
31
  friend class ::nsRefreshDriver;
34
  friend class ::nsRefreshDriver;
32
  friend class RestyleTracker;
35
  friend class RestyleTracker;
33
36
34
  typedef mozilla::dom::Element Element;
37
  typedef mozilla::dom::Element Element;
35
38
36
  RestyleManager(nsPresContext* aPresContext);
39
  RestyleManager(nsPresContext* aPresContext);
37
40
 Lines 261-277   private: Link Here 
261
  RestyleTracker mPendingRestyles;
264
  RestyleTracker mPendingRestyles;
262
  RestyleTracker mPendingAnimationRestyles;
265
  RestyleTracker mPendingAnimationRestyles;
263
};
266
};
264
267
265
/**
268
/**
266
 * An ElementRestyler is created for *each* element in a subtree that we
269
 * An ElementRestyler is created for *each* element in a subtree that we
267
 * recompute styles for.
270
 * recompute styles for.
268
 */
271
 */
269
class ElementRestyler MOZ_FINAL {
272
class ElementRestyler MOZ_FINAL
273
{
270
public:
274
public:
271
  typedef mozilla::dom::Element Element;
275
  typedef mozilla::dom::Element Element;
272
276
273
  // Construct for the root of the subtree that we're restyling.
277
  // Construct for the root of the subtree that we're restyling.
274
  ElementRestyler(nsPresContext* aPresContext,
278
  ElementRestyler(nsPresContext* aPresContext,
275
                  nsIFrame* aFrame,
279
                  nsIFrame* aFrame,
276
                  nsStyleChangeList* aChangeList,
280
                  nsStyleChangeList* aChangeList,
277
                  nsChangeHint aHintsHandledByAncestors,
281
                  nsChangeHint aHintsHandledByAncestors,
 Lines 293-308   public: Link Here 
293
  // as the parent style context for their outer table frame (table
297
  // as the parent style context for their outer table frame (table
294
  // wrapper frame).  We should probably try to get rid of this
298
  // wrapper frame).  We should probably try to get rid of this
295
  // exception and have the inheritance go the other way.)
299
  // exception and have the inheritance go the other way.)
296
  enum ParentContextFromChildFrame { PARENT_CONTEXT_FROM_CHILD_FRAME };
300
  enum ParentContextFromChildFrame { PARENT_CONTEXT_FROM_CHILD_FRAME };
297
  ElementRestyler(ParentContextFromChildFrame,
301
  ElementRestyler(ParentContextFromChildFrame,
298
                  const ElementRestyler& aParentFrameRestyler,
302
                  const ElementRestyler& aParentFrameRestyler,
299
                  nsIFrame* aFrame);
303
                  nsIFrame* aFrame);
300
304
305
  // For restyling undisplayed content only (mFrame==null).
306
  ElementRestyler(nsPresContext* aPresContext,
307
                  nsIContent* aContent,
308
                  nsStyleChangeList* aChangeList,
309
                  nsChangeHint aHintsHandledByAncestors,
310
                  RestyleTracker& aRestyleTracker,
311
                  TreeMatchContext& aTreeMatchContext,
312
                  nsTArray<nsIContent*>& aVisibleKidsOfHiddenElement);
313
301
  /**
314
  /**
302
   * Restyle our frame's element and its subtree.
315
   * Restyle our frame's element and its subtree.
303
   *
316
   *
304
   * Use eRestyle_Self for the aRestyleHint argument to mean
317
   * Use eRestyle_Self for the aRestyleHint argument to mean
305
   * "reresolve our style context but not kids", use eRestyle_Subtree
318
   * "reresolve our style context but not kids", use eRestyle_Subtree
306
   * to mean "reresolve our style context and kids", and use
319
   * to mean "reresolve our style context and kids", and use
307
   * nsRestyleHint(0) to mean recompute a new style context for our
320
   * nsRestyleHint(0) to mean recompute a new style context for our
308
   * current parent and existing rulenode, and the same for kids.
321
   * current parent and existing rulenode, and the same for kids.
 Lines 313-328   public: Link Here 
313
   * mHintsHandled changes over time; it starts off as the hints that
326
   * mHintsHandled changes over time; it starts off as the hints that
314
   * have been handled by ancestors, and by the end of Restyle it
327
   * have been handled by ancestors, and by the end of Restyle it
315
   * represents the hints that have been handled for this frame.  This
328
   * represents the hints that have been handled for this frame.  This
316
   * method is intended to be called after Restyle, to find out what
329
   * method is intended to be called after Restyle, to find out what
317
   * hints have been handled for this frame.
330
   * hints have been handled for this frame.
318
   */
331
   */
319
  nsChangeHint HintsHandledForFrame() { return mHintsHandled; }
332
  nsChangeHint HintsHandledForFrame() { return mHintsHandled; }
320
333
334
  /**
335
   * Called from RestyleManager::RestyleElement to restyle children of
336
   * a display-box:contents element.
337
   */
338
  void RestyleChildrenOfDisplayBoxContentsElement(nsIFrame* aParentFrame,
339
                                                  nsStyleContext* aNewContext,
340
                                                  nsChangeHint    aMinHint,
341
                                                  RestyleTracker& aRestyleTracker,
342
                                                  bool            aRestyleDescendants,
343
                                                  RestyleManager* aRestyleManager);
321
private:
344
private:
322
  /**
345
  /**
323
   * First half of Restyle().
346
   * First half of Restyle().
324
   */
347
   */
325
  void RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint);
348
  void RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint);
326
349
327
  /**
350
  /**
328
   * Restyle the children of this frame (and, in turn, their children).
351
   * Restyle the children of this frame (and, in turn, their children).
 Lines 336-357   private: Link Here 
336
   */
359
   */
337
  void CaptureChange(nsStyleContext* aOldContext,
360
  void CaptureChange(nsStyleContext* aOldContext,
338
                     nsStyleContext* aNewContext,
361
                     nsStyleContext* aNewContext,
339
                     nsChangeHint aChangeToAssume);
362
                     nsChangeHint aChangeToAssume);
340
363
341
  /**
364
  /**
342
   * Helpers for RestyleChildren().
365
   * Helpers for RestyleChildren().
343
   */
366
   */
344
  void RestyleUndisplayedChildren(nsRestyleHint aChildRestyleHint);
367
  void RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint);
368
  void DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint,
369
                                       nsIContent* aParent,
370
                                       nsStyleContext* aParentStyleContext);
371
  void RestyleUndisplayedNodes(nsRestyleHint    aChildRestyleHint,
372
                               UndisplayedNode* aUndisplayed,
373
                               nsIContent*      aUndisplayedParent,
374
                               nsStyleContext*  aParentStyleContext,
375
                               const uint8_t    aDisplayBoxStyle);
345
  void RestyleBeforePseudo();
376
  void RestyleBeforePseudo();
377
  void RestyleBeforePseudo(nsIFrame* aGenConParentFrame,
378
                           nsIFrame* aFrame,
379
                           nsIContent* aContent,
380
                           nsStyleContext* aStyleContext);
346
  void RestyleAfterPseudo(nsIFrame* aFrame);
381
  void RestyleAfterPseudo(nsIFrame* aFrame);
382
  void RestyleAfterPseudo(nsIFrame* aGenConParentFrame,
383
                          nsIFrame* aFrame,
384
                          nsIContent* aContent,
385
                          nsStyleContext* aStyleContext);
347
  void RestyleContentChildren(nsIFrame* aParent,
386
  void RestyleContentChildren(nsIFrame* aParent,
348
                              nsRestyleHint aChildRestyleHint);
387
                              nsRestyleHint aChildRestyleHint);
349
  void InitializeAccessibilityNotifications();
388
  void InitializeAccessibilityNotifications(nsStyleContext* aNewContext);
350
  void SendAccessibilityNotifications();
389
  void SendAccessibilityNotifications();
351
390
352
  enum DesiredA11yNotifications {
391
  enum DesiredA11yNotifications {
353
    eSkipNotifications,
392
    eSkipNotifications,
354
    eSendAllNotifications,
393
    eSendAllNotifications,
355
    eNotifyIfShown
394
    eNotifyIfShown
356
  };
395
  };
357
396
 Lines 387-397   private: Link Here 
387
  const DesiredA11yNotifications mDesiredA11yNotifications;
426
  const DesiredA11yNotifications mDesiredA11yNotifications;
388
  DesiredA11yNotifications mKidsDesiredA11yNotifications;
427
  DesiredA11yNotifications mKidsDesiredA11yNotifications;
389
  A11yNotificationType mOurA11yNotification;
428
  A11yNotificationType mOurA11yNotification;
390
  nsTArray<nsIContent*>& mVisibleKidsOfHiddenElement;
429
  nsTArray<nsIContent*>& mVisibleKidsOfHiddenElement;
391
  bool mWasFrameVisible;
430
  bool mWasFrameVisible;
392
#endif
431
#endif
393
};
432
};
394
433
434
/**
435
 * This pushes any display-box:contents nodes onto a TreeMatchContext.
436
 */
437
class MOZ_STACK_CLASS AutoDisplayBoxContentsAncestorPusher MOZ_FINAL
438
{
439
 public:
440
  typedef mozilla::dom::Element Element;
441
  AutoDisplayBoxContentsAncestorPusher(TreeMatchContext& aTreeMatchContext,
442
                                nsPresContext*    aPresContext,
443
                                nsIContent*       aParent);
444
  ~AutoDisplayBoxContentsAncestorPusher();
445
  bool IsEmpty() const { return mAncestors.Length() == 0; }
446
private:
447
  TreeMatchContext& mTreeMatchContext;
448
  nsPresContext* const mPresContext;
449
  nsAutoTArray<mozilla::dom::Element*, 4> mAncestors;
450
};
451
395
} // namespace mozilla
452
} // namespace mozilla
396
453
397
#endif /* mozilla_RestyleManager_h */
454
#endif /* mozilla_RestyleManager_h */
(-)mc.082761b7bc54/layout/base/RestyleTracker.cpp (-1 / +3 lines)
Line     Link Here 
 Lines 71-87   CollectRestyles(nsISupports* aElement, Link Here 
71
      !element->HasFlag(collector->tracker->RestyleBit())) {
71
      !element->HasFlag(collector->tracker->RestyleBit())) {
72
    return PL_DHASH_NEXT;
72
    return PL_DHASH_NEXT;
73
  }
73
  }
74
74
75
  NS_ASSERTION(!element->HasFlag(collector->tracker->RootBit()) ||
75
  NS_ASSERTION(!element->HasFlag(collector->tracker->RootBit()) ||
76
               // Maybe we're just not reachable via the frame tree?
76
               // Maybe we're just not reachable via the frame tree?
77
               (element->GetFlattenedTreeParent() &&
77
               (element->GetFlattenedTreeParent() &&
78
                (!element->GetFlattenedTreeParent()->GetPrimaryFrame()||
78
                (!element->GetFlattenedTreeParent()->GetPrimaryFrame()||
79
                 element->GetFlattenedTreeParent()->GetPrimaryFrame()->IsLeaf())) ||
79
                 element->GetFlattenedTreeParent()->GetPrimaryFrame()->IsLeaf()||
80
                 element->GetCurrentDoc()->GetShell()->FrameManager()
81
                   ->GetDisplayBoxContentsStyleFor(element))) ||
80
               // Or not reachable due to an async reinsert we have
82
               // Or not reachable due to an async reinsert we have
81
               // pending?  If so, we'll have a reframe hint around.
83
               // pending?  If so, we'll have a reframe hint around.
82
               // That incidentally makes it safe that we still have
84
               // That incidentally makes it safe that we still have
83
               // the bit, since any descendants that didn't get added
85
               // the bit, since any descendants that didn't get added
84
               // to the roots list because we had the bits will be
86
               // to the roots list because we had the bits will be
85
               // completely restyled in a moment.
87
               // completely restyled in a moment.
86
               (aData.mChangeHint & nsChangeHint_ReconstructFrame),
88
               (aData.mChangeHint & nsChangeHint_ReconstructFrame),
87
               "Why did this not get handled while processing mRestyleRoots?");
89
               "Why did this not get handled while processing mRestyleRoots?");
(-)mc.082761b7bc54/layout/generic/nsFrame.cpp (-12 / +51 lines)
Line     Link Here 
 Lines 5475-5492   nsIFrame::ListGeneric(nsACString& aTo, c Link Here 
5475
  aTo += nsPrintfCString(" [sc=%p", static_cast<void*>(mStyleContext));
5475
  aTo += nsPrintfCString(" [sc=%p", static_cast<void*>(mStyleContext));
5476
  if (mStyleContext) {
5476
  if (mStyleContext) {
5477
    nsIAtom* pseudoTag = mStyleContext->GetPseudo();
5477
    nsIAtom* pseudoTag = mStyleContext->GetPseudo();
5478
    if (pseudoTag) {
5478
    if (pseudoTag) {
5479
      nsAutoString atomString;
5479
      nsAutoString atomString;
5480
      pseudoTag->ToString(atomString);
5480
      pseudoTag->ToString(atomString);
5481
      aTo += nsPrintfCString("%s", NS_LossyConvertUTF16toASCII(atomString).get());
5481
      aTo += nsPrintfCString("%s", NS_LossyConvertUTF16toASCII(atomString).get());
5482
    }
5482
    }
5483
    if (mParent && mStyleContext->GetParent() != mParent->StyleContext()) {
5483
    if (!mStyleContext->GetParent() ||
5484
      aTo += nsPrintfCString(",parent=%p", mStyleContext->GetParent());
5484
        (GetParent() && GetParent()->StyleContext() != mStyleContext->GetParent())) {
5485
      aTo += nsPrintfCString("^%p", mStyleContext->GetParent());
5486
      if (mStyleContext->GetParent()) {
5487
        aTo += nsPrintfCString("^%p", mStyleContext->GetParent()->GetParent());
5488
        if (mStyleContext->GetParent()->GetParent()) {
5489
          aTo += nsPrintfCString("^%p", mStyleContext->GetParent()->GetParent()->GetParent());
5490
        }
5491
      }
5485
    }
5492
    }
5486
  }
5493
  }
5487
  aTo += "]";
5494
  aTo += "]";
5488
}
5495
}
5489
5496
5490
void
5497
void
5491
nsIFrame::List(FILE* out, const char* aPrefix, uint32_t aFlags) const
5498
nsIFrame::List(FILE* out, const char* aPrefix, uint32_t aFlags) const
5492
{
5499
{
 Lines 7580-7633   nsFrame::CorrectStyleParentFrame(nsIFram Link Here 
7580
  // We can get here if the root element is absolutely positioned.
7587
  // We can get here if the root element is absolutely positioned.
7581
  // We can't test for this very accurately, but it can only happen
7588
  // We can't test for this very accurately, but it can only happen
7582
  // when the prospective parent is a canvas frame.
7589
  // when the prospective parent is a canvas frame.
7583
  NS_ASSERTION(aProspectiveParent->GetType() == nsGkAtoms::canvasFrame,
7590
  NS_ASSERTION(aProspectiveParent->GetType() == nsGkAtoms::canvasFrame,
7584
               "Should have found a parent before this");
7591
               "Should have found a parent before this");
7585
  return nullptr;
7592
  return nullptr;
7586
}
7593
}
7587
7594
7588
nsIFrame*
7595
nsStyleContext*
7589
nsFrame::DoGetParentStyleContextFrame() const
7596
nsFrame::DoGetParentStyleContext(nsIFrame** aProviderFrame) const
7590
{
7597
{
7591
  if (mContent && !mContent->GetParent() &&
7598
  *aProviderFrame = nullptr;
7592
      !StyleContext()->GetPseudo()) {
7599
  nsFrameManager* fm = PresContext()->FrameManager();
7600
  if (MOZ_LIKELY(mContent)) {
7601
    nsIContent* parentContent = mContent->GetParent();
7602
    if (MOZ_LIKELY(parentContent)) {
7603
      nsIAtom* pseudo = StyleContext()->GetPseudo();
7604
      if (!pseudo || !mContent->IsElement() ||
7605
          !nsCSSAnonBoxes::IsAnonBox(pseudo) ||
7606
          /* if next is true then it's really a request for the table frame's
7607
             parent context, see nsTable[Outer]Frame::GetParentStyleContext. */
7608
          pseudo == nsCSSAnonBoxes::tableOuter) {
7609
        nsStyleContext* sc = fm->GetDisplayBoxContentsStyleFor(parentContent);
7610
        if (MOZ_UNLIKELY(sc)) {
7611
          return sc;
7612
        }
7613
      }
7614
    } else {
7615
      if (!StyleContext()->GetPseudo()) {
7593
    // we're a frame for the root.  We have no style context parent.
7616
    // we're a frame for the root.  We have no style context parent.
7594
    return nullptr;
7617
    return nullptr;
7595
  }
7618
  }
7619
    }
7620
  }
7596
  
7621
  
7597
  if (!(mState & NS_FRAME_OUT_OF_FLOW)) {
7622
  if (!(mState & NS_FRAME_OUT_OF_FLOW)) {
7598
    /*
7623
    /*
7599
     * If this frame is an anonymous block created when an inline with a block
7624
     * If this frame is an anonymous block created when an inline with a block
7600
     * inside it got split, then the parent style context is on its preceding
7625
     * inside it got split, then the parent style context is on its preceding
7601
     * inline. We can get to it using GetIBSplitSiblingForAnonymousBlock.
7626
     * inline. We can get to it using GetIBSplitSiblingForAnonymousBlock.
7602
     */
7627
     */
7603
    if (mState & NS_FRAME_PART_OF_IBSPLIT) {
7628
    if (mState & NS_FRAME_PART_OF_IBSPLIT) {
7604
      nsIFrame* ibSplitSibling = GetIBSplitSiblingForAnonymousBlock(this);
7629
      nsIFrame* ibSplitSibling = GetIBSplitSiblingForAnonymousBlock(this);
7605
      if (ibSplitSibling) {
7630
      if (ibSplitSibling) {
7606
        return ibSplitSibling;
7631
        return (*aProviderFrame = ibSplitSibling)->StyleContext();
7607
      }
7632
      }
7608
    }
7633
    }
7609
7634
7610
    // If this frame is one of the blocks that split an inline, we must
7635
    // If this frame is one of the blocks that split an inline, we must
7611
    // return the "special" inline parent, i.e., the parent that this
7636
    // return the "special" inline parent, i.e., the parent that this
7612
    // frame would have if we didn't mangle the frame structure.
7637
    // frame would have if we didn't mangle the frame structure.
7613
    return GetCorrectedParent(this);
7638
    *aProviderFrame = GetCorrectedParent(this);
7639
    return *aProviderFrame ? (*aProviderFrame)->StyleContext() : nullptr;
7614
  }
7640
  }
7615
7641
7616
  // We're an out-of-flow frame.  For out-of-flow frames, we must
7642
  // We're an out-of-flow frame.  For out-of-flow frames, we must
7617
  // resolve underneath the placeholder's parent.  The placeholder is
7643
  // resolve underneath the placeholder's parent.  The placeholder is
7618
  // reached from the first-in-flow.
7644
  // reached from the first-in-flow.
7619
  nsIFrame* placeholder = PresContext()->FrameManager()->
7645
  nsIFrame* placeholder = fm->GetPlaceholderFrameFor(FirstInFlow());
7620
                            GetPlaceholderFrameFor(FirstInFlow());
7621
  if (!placeholder) {
7646
  if (!placeholder) {
7622
    NS_NOTREACHED("no placeholder frame for out-of-flow frame");
7647
    NS_NOTREACHED("no placeholder frame for out-of-flow frame");
7623
    return GetCorrectedParent(this);
7648
    *aProviderFrame = GetCorrectedParent(this);
7649
    return *aProviderFrame ? (*aProviderFrame)->StyleContext() : nullptr;
7624
  }
7650
  }
7625
  return placeholder->GetParentStyleContextFrame();
7651
  return placeholder->GetParentStyleContext(aProviderFrame);
7626
}
7652
}
7627
7653
7628
void
7654
void
7629
nsFrame::GetLastLeaf(nsPresContext* aPresContext, nsIFrame **aFrame)
7655
nsFrame::GetLastLeaf(nsPresContext* aPresContext, nsIFrame **aFrame)
7630
{
7656
{
7631
  if (!aFrame || !*aFrame)
7657
  if (!aFrame || !*aFrame)
7632
    return;
7658
    return;
7633
  nsIFrame *child = *aFrame;
7659
  nsIFrame *child = *aFrame;
 Lines 8499-8514   nsIFrame::DestroyDT(void* aPropertyValue Link Here 
8499
}
8525
}
8500
8526
8501
void
8527
void
8502
nsIFrame::DestroyRegion(void* aPropertyValue)
8528
nsIFrame::DestroyRegion(void* aPropertyValue)
8503
{
8529
{
8504
  delete static_cast<nsRegion*>(aPropertyValue);
8530
  delete static_cast<nsRegion*>(aPropertyValue);
8505
}
8531
}
8506
8532
8533
/*static*/ void
8534
nsIFrame::DestroyContentArray(void* aPropertyValue)
8535
{
8536
  typedef nsTArray<nsIContent*> T;
8537
  T* arr = static_cast<T*>(aPropertyValue);
8538
  for (T::size_type i = 0; i < arr->Length(); ++i) {
8539
    nsIContent* content = (*arr)[i];
8540
    content->UnbindFromTree();
8541
    NS_RELEASE(content);
8542
  }
8543
  delete arr;
8544
}
8545
8507
bool
8546
bool
8508
nsIFrame::IsPseudoStackingContextFromStyle() {
8547
nsIFrame::IsPseudoStackingContextFromStyle() {
8509
  const nsStyleDisplay* disp = StyleDisplay();
8548
  const nsStyleDisplay* disp = StyleDisplay();
8510
  // If you change this, also change the computation of pseudoStackingContext
8549
  // If you change this, also change the computation of pseudoStackingContext
8511
  // in BuildDisplayListForChild()
8550
  // in BuildDisplayListForChild()
8512
  return disp->mOpacity != 1.0f ||
8551
  return disp->mOpacity != 1.0f ||
8513
         disp->IsPositioned(this) ||
8552
         disp->IsPositioned(this) ||
8514
         disp->IsFloating(this) ||
8553
         disp->IsFloating(this) ||
(-)mc.082761b7bc54/layout/generic/nsFrame.h (-4 / +10 lines)
Line     Link Here 
 Lines 226-253   public: Link Here 
226
226
227
  virtual nsresult  GetOffsets(int32_t &aStart, int32_t &aEnd) const MOZ_OVERRIDE;
227
  virtual nsresult  GetOffsets(int32_t &aStart, int32_t &aEnd) const MOZ_OVERRIDE;
228
  virtual void ChildIsDirty(nsIFrame* aChild) MOZ_OVERRIDE;
228
  virtual void ChildIsDirty(nsIFrame* aChild) MOZ_OVERRIDE;
229
229
230
#ifdef ACCESSIBILITY
230
#ifdef ACCESSIBILITY
231
  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
231
  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
232
#endif
232
#endif
233
233
234
  virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE {
234
  virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const MOZ_OVERRIDE {
235
    return DoGetParentStyleContextFrame();
235
    return DoGetParentStyleContext(aProviderFrame);
236
  }
236
  }
237
237
238
  /**
238
  /**
239
   * Do the work for getting the parent style context frame so that
239
   * Do the work for getting the parent style context frame so that
240
   * other frame's |GetParentStyleContextFrame| methods can call this
240
   * other frame's |GetParentStyleContext| methods can call this
241
   * method on *another* frame.  (This function handles out-of-flow
241
   * method on *another* frame.  (This function handles out-of-flow
242
   * frames by using the frame manager's placeholder map and it also
242
   * frames by using the frame manager's placeholder map and it also
243
   * handles block-within-inline and generated content wrappers.)
243
   * handles block-within-inline and generated content wrappers.)
244
   *
245
   * @param aProviderFrame (out) the frame associated with the returned value
246
   *     or null if the style context is for display-box:contents content.
247
   * @return The style context that should be the parent of this frame's
248
   *         style context.  Null is permitted, and means that this frame's
249
   *         style context should be the root of the style context tree.
244
   */
250
   */
245
  nsIFrame* DoGetParentStyleContextFrame() const;
251
  nsStyleContext* DoGetParentStyleContext(nsIFrame** aProviderFrame) const;
246
252
247
  virtual bool IsEmpty() MOZ_OVERRIDE;
253
  virtual bool IsEmpty() MOZ_OVERRIDE;
248
  virtual bool IsSelfEmpty() MOZ_OVERRIDE;
254
  virtual bool IsSelfEmpty() MOZ_OVERRIDE;
249
255
250
  virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
256
  virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
251
  virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
257
  virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
252
  virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
258
  virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
253
  virtual void AddInlineMinWidth(nsRenderingContext *aRenderingContext,
259
  virtual void AddInlineMinWidth(nsRenderingContext *aRenderingContext,
(-)mc.082761b7bc54/layout/generic/nsIFrame.h (-2 / +12 lines)
Line     Link Here 
 Lines 836-851   public: Link Here 
836
836
837
  static void DestroyOverflowAreas(void* aPropertyValue)
837
  static void DestroyOverflowAreas(void* aPropertyValue)
838
  {
838
  {
839
    delete static_cast<nsOverflowAreas*>(aPropertyValue);
839
    delete static_cast<nsOverflowAreas*>(aPropertyValue);
840
  }
840
  }
841
841
842
  static void DestroySurface(void* aPropertyValue);
842
  static void DestroySurface(void* aPropertyValue);
843
  static void DestroyDT(void* aPropertyValue);
843
  static void DestroyDT(void* aPropertyValue);
844
  static void DestroyContentArray(void* aPropertyValue);
844
845
845
#ifdef _MSC_VER
846
#ifdef _MSC_VER
846
// XXX Workaround MSVC issue by making the static FramePropertyDescriptor
847
// XXX Workaround MSVC issue by making the static FramePropertyDescriptor
847
// non-const.  See bug 555727.
848
// non-const.  See bug 555727.
848
#define NS_PROPERTY_DESCRIPTOR_CONST
849
#define NS_PROPERTY_DESCRIPTOR_CONST
849
#else
850
#else
850
#define NS_PROPERTY_DESCRIPTOR_CONST const
851
#define NS_PROPERTY_DESCRIPTOR_CONST const
851
#endif
852
#endif
 Lines 888-903   public: Link Here 
888
889
889
  NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, DestroySurface)
890
  NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, DestroySurface)
890
  NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT, DestroyDT)
891
  NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT, DestroyDT)
891
892
892
  NS_DECLARE_FRAME_PROPERTY(InvalidationRect, DestroyRect)
893
  NS_DECLARE_FRAME_PROPERTY(InvalidationRect, DestroyRect)
893
894
894
  NS_DECLARE_FRAME_PROPERTY(RefusedAsyncAnimation, nullptr)
895
  NS_DECLARE_FRAME_PROPERTY(RefusedAsyncAnimation, nullptr)
895
896
897
  NS_DECLARE_FRAME_PROPERTY(GenConProperty, DestroyContentArray)
898
899
  nsTArray<nsIContent*>* GetGenConPseudos() {
900
    const FramePropertyDescriptor* prop = GenConProperty();
901
    return static_cast<nsTArray<nsIContent*> *>(Properties().Get(prop));
902
  }
903
896
  /**
904
  /**
897
   * Return the distance between the border edge of the frame and the
905
   * Return the distance between the border edge of the frame and the
898
   * margin edge of the frame.  Like GetRect(), returns the dimensions
906
   * margin edge of the frame.  Like GetRect(), returns the dimensions
899
   * as of the most recent reflow.
907
   * as of the most recent reflow.
900
   *
908
   *
901
   * This doesn't include any margin collapsing that may have occurred.
909
   * This doesn't include any margin collapsing that may have occurred.
902
   *
910
   *
903
   * It also treats 'auto' margins as zero, and treats any margins that
911
   * It also treats 'auto' margins as zero, and treats any margins that
 Lines 2494-2514   public: Link Here 
2494
  /**
2502
  /**
2495
   * Get the frame whose style context should be the parent of this
2503
   * Get the frame whose style context should be the parent of this
2496
   * frame's style context (i.e., provide the parent style context).
2504
   * frame's style context (i.e., provide the parent style context).
2497
   * This frame must either be an ancestor of this frame or a child.  If
2505
   * This frame must either be an ancestor of this frame or a child.  If
2498
   * this returns a child frame, then the child frame must be sure to
2506
   * this returns a child frame, then the child frame must be sure to
2499
   * return a grandparent or higher!  Furthermore, if a child frame is
2507
   * return a grandparent or higher!  Furthermore, if a child frame is
2500
   * returned it must have the same GetContent() as this frame.
2508
   * returned it must have the same GetContent() as this frame.
2501
   *
2509
   *
2502
   * @return The frame whose style context should be the parent of this frame's
2510
   * @param aProviderFrame (out) the frame associated with the returned value
2511
   *     or nullptr if the style context is for display-box:contents content.
2512
   * @return The style context that should be the parent of this frame's
2503
   *         style context.  Null is permitted, and means that this frame's
2513
   *         style context.  Null is permitted, and means that this frame's
2504
   *         style context should be the root of the style context tree.
2514
   *         style context should be the root of the style context tree.
2505
   */
2515
   */
2506
  virtual nsIFrame* GetParentStyleContextFrame() const = 0;
2516
  virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const = 0;
2507
2517
2508
  /**
2518
  /**
2509
   * Determines whether a frame is visible for painting;
2519
   * Determines whether a frame is visible for painting;
2510
   * taking into account whether it is painting a selection or printing.
2520
   * taking into account whether it is painting a selection or printing.
2511
   */
2521
   */
2512
  bool IsVisibleForPainting(nsDisplayListBuilder* aBuilder);
2522
  bool IsVisibleForPainting(nsDisplayListBuilder* aBuilder);
2513
  /**
2523
  /**
2514
   * Determines whether a frame is visible for painting or collapsed;
2524
   * Determines whether a frame is visible for painting or collapsed;
(-)mc.082761b7bc54/layout/generic/nsPlaceholderFrame.cpp (-3 / +14 lines)
Line     Link Here 
 Lines 181-205   nsPlaceholderFrame::CanContinueTextRun() Link Here 
181
  if (!mOutOfFlowFrame) {
181
  if (!mOutOfFlowFrame) {
182
    return false;
182
    return false;
183
  }
183
  }
184
  // first-letter frames can continue text runs, and placeholders for floated
184
  // first-letter frames can continue text runs, and placeholders for floated
185
  // first-letter frames can too
185
  // first-letter frames can too
186
  return mOutOfFlowFrame->CanContinueTextRun();
186
  return mOutOfFlowFrame->CanContinueTextRun();
187
}
187
}
188
188
189
nsIFrame*
189
nsStyleContext*
190
nsPlaceholderFrame::GetParentStyleContextFrame() const
190
nsPlaceholderFrame::GetParentStyleContext(nsIFrame** aProviderFrame) const
191
{
191
{
192
  NS_PRECONDITION(GetParent(), "How can we not have a parent here?");
192
  NS_PRECONDITION(GetParent(), "How can we not have a parent here?");
193
193
194
  nsIContent* parentContent = mContent ? mContent->GetParent() : nullptr;
195
  if (parentContent) {
196
    nsStyleContext* sc =
197
      PresContext()->FrameManager()->GetDisplayBoxContentsStyleFor(parentContent);
198
    if (sc) {
199
      *aProviderFrame = nullptr;
200
      return sc;
201
    }
202
  }
203
194
  // Lie about our pseudo so we can step out of all anon boxes and
204
  // Lie about our pseudo so we can step out of all anon boxes and
195
  // pseudo-elements.  The other option would be to reimplement the
205
  // pseudo-elements.  The other option would be to reimplement the
196
  // {ib} split gunk here.
206
  // {ib} split gunk here.
197
  return CorrectStyleParentFrame(GetParent(), nsGkAtoms::placeholderFrame);
207
  *aProviderFrame = CorrectStyleParentFrame(GetParent(), nsGkAtoms::placeholderFrame);
208
  return *aProviderFrame ? (*aProviderFrame)->StyleContext() : nullptr;
198
}
209
}
199
210
200
211
201
#ifdef DEBUG
212
#ifdef DEBUG
202
static void
213
static void
203
PaintDebugPlaceholder(nsIFrame* aFrame, nsRenderingContext* aCtx,
214
PaintDebugPlaceholder(nsIFrame* aFrame, nsRenderingContext* aCtx,
204
                      const nsRect& aDirtyRect, nsPoint aPt)
215
                      const nsRect& aDirtyRect, nsPoint aPt)
205
{
216
{
(-)mc.082761b7bc54/layout/generic/nsPlaceholderFrame.h (-1 / +1 lines)
Line     Link Here 
 Lines 130-146   public: Link Here 
130
  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE
130
  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE
131
  {
131
  {
132
    nsIFrame* realFrame = GetRealFrameForPlaceholder(this);
132
    nsIFrame* realFrame = GetRealFrameForPlaceholder(this);
133
    return realFrame ? realFrame->AccessibleType() :
133
    return realFrame ? realFrame->AccessibleType() :
134
                       nsFrame::AccessibleType();
134
                       nsFrame::AccessibleType();
135
  }
135
  }
136
#endif
136
#endif
137
137
138
  virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
138
  virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const MOZ_OVERRIDE;
139
139
140
  /**
140
  /**
141
   * @return the out-of-flow for aFrame if aFrame is a placeholder; otherwise
141
   * @return the out-of-flow for aFrame if aFrame is a placeholder; otherwise
142
   * aFrame
142
   * aFrame
143
   */
143
   */
144
  static nsIFrame* GetRealFrameFor(nsIFrame* aFrame) {
144
  static nsIFrame* GetRealFrameFor(nsIFrame* aFrame) {
145
    NS_PRECONDITION(aFrame, "Must have a frame to work with");
145
    NS_PRECONDITION(aFrame, "Must have a frame to work with");
146
    if (aFrame->GetType() == nsGkAtoms::placeholderFrame) {
146
    if (aFrame->GetType() == nsGkAtoms::placeholderFrame) {
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-495385-2d.html (+44 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE HTML>
2
<html>
3
<head>
4
<!-- Test that before/after generated content stops suppression correctly,
5
     both statically and dynamically -->
6
<style>
7
body > div { border:1px solid black; margin:1em;
8
             font-family:sans-serif; letter-spacing:2px; }
9
#d1:before { content:"Hello"; }
10
#d2:after { content:"Kitty"; }
11
#d3.c:before { content:"Hello"; }
12
#d4.c:after { content:"Kitty"; }
13
#d5.c:before { content:"Hello"; }
14
#d6.c:after { content:"Kitty"; }
15
#d7.c:after { content:"Kitty"; }
16
#d8.c:before { content:"Hello"; }
17
#d5,#d6 { overflow:hidden; }
18
#d1,#d2,#d3,#d4 { display-box:contents; }
19
x { display:table; }
20
y { display:table-outer; }
21
</style>
22
<script>
23
function loaded() {
24
  document.body.offsetHeight;
25
  document.getElementById("d3").setAttribute("class", "c");
26
  document.getElementById("d4").setAttribute("class", "c");
27
  document.getElementById("d5").setAttribute("class", "c");
28
  document.getElementById("d6").setAttribute("class", "c");
29
  document.getElementById("d7").setAttribute("class", "c");
30
  document.getElementById("d8").setAttribute("class", "c");
31
}
32
</script>
33
</head>
34
<body onload="loaded()">
35
  <div><div id="d1"> <span>Kitty</span></div></div>
36
  <div><div id="d2"><span>Hello</span> </div></div>
37
  <div><div id="d3"> <span>Kitty</span></div></div>
38
  <div><div id="d4"><span>Hello</span> </div></div>
39
  <div><div id="d5"> <span>Kitty</span></div></div>
40
  <div><div id="d6"><span>Hello</span> </div></div>
41
  <div><x id="d7"><span>Hello</span> </div></x>
42
  <div><x id="d8"> <span>Kitty</span> </div></x>
43
</body>
44
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-495385-2d-ref.html (+19 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE HTML>
2
<html>
3
<head>
4
<style>
5
body > div { border:1px solid black; margin:1em;
6
             font-family:sans-serif; letter-spacing:2px; }
7
</style>
8
</head>
9
<body>
10
  <div><span>Hello</span> <span>Kitty</span></div>
11
  <div><span>Hello</span> <span>Kitty</span></div>
12
  <div><span>Hello</span> <span>Kitty</span></div>
13
  <div><span>Hello</span> <span>Kitty</span></div>
14
  <div><span>Hello</span> <span>Kitty</span></div>
15
  <div><span>Hello</span> <span>Kitty</span></div>
16
  <div><span>Hello</span> <span>Kitty</span></div>
17
  <div><span>Hello</span> <span>Kitty</span></div>
18
</body>
19
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-acid-dyn-1.html (+45 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
10
        html,body {
11
            color:black; background-color:white; height:100%; font-size:16px; padding:0; margin:0;
12
        }
13
14
iframe { padding:0;margin:0;border-width:0;width:100%;height:90%; color:red; }
15
16
    </style>
17
<script>
18
function runTest(iframe) {
19
  var win = iframe.contentWindow;
20
  var doc = iframe.contentDocument;
21
  doc.body.offsetHeight
22
  var e = doc.querySelectorAll('*');
23
  var contents = new Array;
24
  for (i=0; i < e.length; ++i) {
25
    var elm = e[i];
26
    if (win.getComputedStyle(elm).displayBox == 'contents') {
27
      contents.push(elm);
28
      elm.style.displayBox='none';
29
    }
30
  }
31
  doc.body.offsetHeight;
32
  for (i=0; i < contents.length; ++i) {
33
    elm = contents[i];
34
    elm.style.displayBox='contents';
35
  }
36
  doc.body.offsetHeight;
37
}
38
</script>
39
</head>
40
<body>
41
42
<iframe src="display-box-contents-acid.html" frameborder=0 onload="runTest(this)"></iframe>
43
44
</body>
45
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-acid-dyn-2.html (+45 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
10
        html,body {
11
            color:black; background-color:white; height:100%; font-size:16px; padding:0; margin:0;
12
        }
13
14
iframe { padding:0;margin:0;border-width:0;width:100%;height:90%; color:red; }
15
16
    </style>
17
<script>
18
function runTest(iframe) {
19
  var win = iframe.contentWindow;
20
  var doc = iframe.contentDocument;
21
  doc.body.offsetHeight
22
  var e = doc.querySelectorAll('*');
23
  var contents = new Array;
24
  for (i=0; i < e.length; ++i) {
25
    var elm = e[i];
26
    if (win.getComputedStyle(elm).displayBox == 'contents') {
27
      contents.push(elm);
28
      elm.style.displayBox='inline';
29
    }
30
  }
31
  doc.body.offsetHeight;
32
  for (i=0; i < contents.length; ++i) {
33
    elm = contents[i];
34
    elm.style.displayBox='contents';
35
  }
36
  doc.body.offsetHeight;
37
}
38
</script>
39
</head>
40
<body>
41
42
<iframe src="display-box-contents-acid.html" frameborder=0 onload="runTest(this)"></iframe>
43
44
</body>
45
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-acid-dyn-3.html (+46 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
10
        html,body {
11
            color:black; background-color:white; height:100%; font-size:16px; padding:0; margin:0;
12
        }
13
14
iframe { padding:0;margin:0;border-width:0;width:100%;height:90%; color:red; }
15
16
    </style>
17
<script>
18
function runTest(iframe) {
19
  var win = iframe.contentWindow;
20
  var doc = iframe.contentDocument;
21
  doc.body.offsetHeight
22
  var e = doc.querySelectorAll('*');
23
  var contents = new Array;
24
  for (i=0; i < e.length; ++i) {
25
    var elm = e[i];
26
    if (win.getComputedStyle(elm).displayBox == 'contents') {
27
      contents.push([ elm, elm.nextSibling, elm.parentNode ]);
28
      elm.parentNode.removeChild(elm);
29
    }
30
  }
31
  doc.body.offsetHeight;
32
  var i = contents.length;
33
  while(i--) {
34
    var arr = contents[i];
35
    arr[2].insertBefore(arr[0], arr[1]);
36
  }
37
  doc.body.offsetHeight;
38
}
39
</script>
40
</head>
41
<body>
42
43
<iframe src="display-box-contents-acid.html" frameborder=0 onload="runTest(this)"></iframe>
44
45
</body>
46
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-acid.html (+184 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
10
        html,body {
11
            color:black; background-color:white; font-size:16px; padding:0; margin:0;
12
        }
13
	
14
.table   { display:table; border-collapse:collapse; border: blue solid 1pt;}
15
.itable  { display:inline-table; }
16
.caption { display:table-caption; }
17
.cell    { display:table-cell; border:inherit; }
18
.row     { display:table-row; border: green dashed 1pt; }
19
.rowg    { display:table-row-group; }
20
.head    { display:table-header-group; }
21
.foot    { display:table-footer-group; }
22
.col     { display:table-column; }
23
.colg    { display:table-column-group; }
24
.flex    { display:flex; }
25
.iflex   { display:inline-flex; }
26
.li      { display:list-item; }
27
.ib      { display:inline-block; }
28
.inline  { display:inline; }
29
.columns  { -moz-columns:2; columns:2; height:4em; }
30
31
.contents { display-box:contents; }
32
33
.c1 { color:lime; }
34
.c2 { background:blue; color:pink; }
35
.c3 { color:teal; }
36
.c4 { color:green; }
37
.c5 { color:silver; }
38
.c6 { color:cyan; }
39
.c7 { color:magenta; }
40
.c8 { color:yellow; }
41
.c9 { color:grey; }
42
.c10{ color:black; }
43
44
.b { background:inherit; }
45
    </style>
46
</head>
47
<body style="color:red">
48
49
<div class="contents c1"><div class="contents c2"><div class="caption">1<span class="b">1</span></div></div></div>
50
<div class="contents c2"><div class="row">2a<div class="cell">2<div class="contents c2">b<span class="b">b</span></div></div></div></div>
51
<div class="contents c3"><div class="cell">3</div></div>
52
<div class="contents c4"><div class="rowg">4</div></div>
53
<div class="contents c5"><div class="cell">5a</div></div>
54
<div class="cell c5">5b</div>
55
<div class="contents c6"><div class="head">6</div></div>
56
<div class="contents c7"><div class="cell"><div class="contents c2">7<span class="b">a</span></div></div></div>
57
<div class="contents c8"><div class="cell">7b</div></div>
58
<div class="contents c9"><div class="foot">8</div></div>
59
<div class="contents c9"><div class="foot">9<div class="contents c2">a<span class="b">b</span>c</div></div></div>
60
<div class="contents c10"><div class="cell">10</div></div>
61
62
<div class="table" style="float:right">
63
<div class="contents c1"><div class="contents c2"><div class="caption">1<span class="b">1</span></div></div></div>
64
<div class="contents c2"><div class="row">2a<div class="cell">2<div class="contents c2">b<span class="b">b</span></div></div></div></div>
65
<div class="contents c3"><div class="cell">3</div></div>
66
<div class="contents c4"><div class="rowg">4</div></div>
67
<div class="contents c5"><div class="cell">5a</div></div>
68
<div class="cell c5">5b</div>
69
<div class="contents c6"><div class="head">6</div></div>
70
<div class="contents c7"><div class="cell"><div class="contents c2">7<span class="b">a</span></div></div></div>
71
<div class="contents c8"><div class="cell">7b</div></div>
72
<div class="contents c9"><div class="foot">8</div></div>
73
<div class="contents c9"><div class="foot">9<div class="contents c2">a<span class="b">b</span>c</div></div></div>
74
<div class="contents c10"><div class="cell">10</div></div>
75
</div>
76
77
<div class="flex c1">
78
0
79
<div class="contents c1">x</div>
80
<div class="contents c1"><div class="contents c2">y</div></div>
81
<div class="contents c1"><div class="contents c2"><div class="">1<span class="b">1</span></div></div></div>
82
<div class="contents c2"><div class="inline">2a<div class="">2<div class="contents c2">b<span class="b">b</span></div></div></div></div>
83
<div class="contents c3"><div class="inline">3</div></div>
84
<div class="inline"><div class="contents c4">4</div></div>
85
<div class=""><div class="contents c5">5a</div></div>
86
<div class=" c5">5b</div>
87
<div class="contents c6"><div class="">6</div></div>
88
<div class="ib"><div class="contents c7"><div class="contents c2">7<span class="b">a</span></div></div></div>
89
<div class="contents c9"><div class="">8</div></div>
90
<div class="contents c9"><div class="contents">9<div class="contents c2">a<span class="b">b</span>c</div></div></div>
91
<div class="contents c10"><div class="">10</div></div>
92
</div>
93
94
<div class="flex"><div class="contents c2">
95
0
96
<div class="contents c1">x</div>
97
<div class="contents c1"><div class="contents c2">y</div></div>
98
<div class="contents c1"><div class="contents c2"><div class="">1<span class="b">1</span></div></div></div>
99
<div class="contents c2"><div class="inline">2a<div class="">2<div class="contents c2">b<span class="b">b</span></div></div></div></div>
100
<div class="contents c3"><div class="inline">3</div></div>
101
<div class=""><div class="contents c4">4</div></div>
102
<div class=""><div class="contents c5">5a</div></div>
103
<div class=" c5">5b</div>
104
<div class="contents c6"><div class="">6</div></div>
105
<div class="ib"><div class="contents c7"><div class="contents c2">7<span class="b">a</span></div></div></div>
106
<div class="contents c9"><div class="">8</div></div>
107
<div class="contents c9"><div class="contents">9<div class="contents c2">a<span class="b">b</span>c</div></div></div>
108
<div class="contents c10"><div class="">10</div></div>
109
</div></div>
110
111
<div class="iflex"><div class="contents c2">
112
0
113
</div></div>
114
<div class="iflex"><div class="contents c2">
115
0
116
<div class="contents c1">1</div>
117
2
118
</div></div>
119
<div class="iflex"><div class="contents c2">
120
0
121
<div class="c1">1</div>
122
2
123
</div></div>
124
<div class="iflex c3">
125
0
126
<div class="contents c2"><div class="c1">1</div></div>
127
2
128
</div>
129
<div class="iflex c3">
130
<div class="contents c2">0</div>
131
<div class="contents c2"><div class="c1">1</div></div>
132
<div class="contents c2">2</div>
133
</div>
134
<div class="iflex c3">
135
<div class="inline">0</div>
136
<div class="contents"><div class="inline c1">1</div></div>
137
<div class="inline">2</div>
138
</div>
139
140
<ul><li class="c1"><div class="contents c2">
141
0
142
<div class="contents c1">x</div>
143
<div class="contents c1"><div class="contents c2">y</div></div>
144
<div class="contents c1"><div class="contents c2"><div class="">1<span class="b">1</span></div></div></div>
145
<div class="contents c2"><div class="inline">2a<div class="">2<div class="contents c2">b<span class="b">b</span></div></div></div></div>
146
<div class="contents c3"><div class="inline">3</div></div>
147
<div class="inline"><div class="contents c4">4</div></div>
148
<div class=""><div class="contents c5">5a</div></div>
149
<div class=" c5">5b</div>
150
<div class="contents c6"><div class="">6</div></div>
151
<div class="ib"><div class="contents c7"><div class="contents c2">7<span class="b">a</span></div></div></div>
152
<div class="contents c9"><div class="">8</div></div>
153
<div class="contents c9"><div class="contents">9<div class="contents c2">a<span class="b">b</span>c</div></div></div>
154
<div class="contents c10"><div class="">10</div></div>
155
</div></li>
156
</ul>
157
158
<div class="columns">
159
<div class="contents c1"><div class="contents c2"><div>1<span class="b">1</span></div></div></div>
160
<div class="contents c2"><div>2</div></div>
161
<div class="contents c3"><div>3</div></div>
162
</div>
163
164
<div class="columns">
165
<div class="columns contents">
166
<div class="contents c1"><div class="contents c2"><div>1<span class="b">1</span></div></div></div>
167
<div class="contents c2"><div>2</div></div>
168
<div class="contents c3"><div>3</div></div>
169
</div>
170
</div>
171
172
<span class="c2"><legend class="contents c1">Legend</legend><legend class="contents c1">Legend</legend></span>
173
<br clear="all">
174
<span class="c3">x<div class="contents c1" style="float:left">float:left</div></span>
175
<span class="c3">y<div class="contents c1" style="position:absolute">position:absolute</div></span>
176
177
<!-- Stuff below should simply ignore having display-box:contents -->
178
179
<fieldset class="contents c1"><legend class="contents">Legend</legend>fieldset</fieldset>
180
<button class="contents c1">but<span>ton</span></button>
181
<select class="contents c1"><option>select</select>
182
183
</body>
184
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-acid-ref.html (+180 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
<style type="text/css">
8
9
        html,body {
10
            color:black; background-color:white; font-size:16px; padding:0; margin:0;
11
        }
12
	
13
.table   { display:table; border-collapse:collapse; border: blue solid 1pt;}
14
.itable  { display:inline-table; }
15
.caption { display:table-caption; }
16
.cell    { display:table-cell; border:inherit; }
17
.row     { display:table-row; border: green dashed 1pt; }
18
.rowg    { display:table-row-group; }
19
.head    { display:table-header-group; }
20
.foot    { display:table-footer-group; }
21
.col     { display:table-column; }
22
.colg    { display:table-column-group; }
23
.flex    { display:flex; }
24
.iflex   { display:inline-flex; }
25
.li      { display:list-item; }
26
.ib      { display:inline-block; }
27
.inline  { display:inline; }
28
.columns  { -moz-columns:2; columns:2; height:4em; }
29
30
31
32
.c1 { color:lime; }
33
.c2 { color:pink; }
34
.c3 { color:teal; }
35
.c4 { color:green; }
36
.c5 { color:silver; }
37
.c6 { color:cyan; }
38
.c7 { color:magenta; }
39
.c8 { color:yellow; }
40
.c9 { color:grey; }
41
.c10{ color:black; }
42
43
.b { background:blue; }
44
    </style>
45
</head>
46
<body style="color:red">
47
48
<div class="caption c2">1<span>1</span></div>
49
<div class="row c2">2a<div class="cell">2<div class="inline c2">b<span class="b">b</span></div></div></div>
50
<div class="cell c3">3</div>
51
<div class="rowg c4">4</div>
52
<div class="cell c5">5a</div>
53
<div class="cell c5">5b</div>
54
<div class="head c6">6</div>
55
<div class="cell c7"><div class="inline c2">7<span class="b">a</span></div></div>
56
<div class="cell c8">7b</div>
57
<div class="foot c9">8</div>
58
<div class="foot c9">9<div class="inline c2">a<span class="b">b</span>c</div></div>
59
<div class="cell c10">10</div>
60
61
<div class="table" style="float:right">
62
<div class="caption c2">1<span>1</span></div>
63
<div class="row c2">2a<div class="cell">2<div class="inline c2">b<span class="b">b</span></div></div></div>
64
<div class="cell c3" style="border:none">3</div>
65
<div class="rowg c4">4</div>
66
<div class="cell c5" style="border:none">5a</div>
67
<div class="cell c5">5b</div>
68
<div class="head c6">6</div>
69
<div class="cell c7" style="border:none"><div class="inline c2">7<span class="b">a</span></div></div>
70
<div class="cell c8" style="border:none">7b</div>
71
<div class="foot c9" style="border:none">8</div>
72
<div class="foot c9">9<div class="inline c2">a<span class="b">b</span>c</div></div>
73
<div class="cell c10" style="border:none">10</div>
74
</div>
75
76
<div class="flex c1">
77
0&nbsp;
78
<div class="inline c1">x&nbsp;</div>
79
<div class="inline c1"><div class="inline c2">y</div></div>
80
<div class="inline c1"><div class="inline c2"><div class="">1<span>1</span></div></div></div>
81
<div class="inline c2"><div class="inline">2a<div class="">2<div class="inline c2">b<span class="b">b</span></div></div></div></div>
82
<div class="c3">3</div>
83
<div class="inline"><div class="inline c4">4</div></div>
84
<div class=""><div class="inline c5">5a</div></div>
85
<div class=" c5">5b</div>
86
<div class="inline c6"><div class="">6</div></div>
87
<div class="ib"><div class="inline c7"><div class="inline c2">7<span class="b">a</span></div></div></div>
88
<div class="inline c9"><div class="">8</div></div>
89
<div class="inline c9"><div class="inline">9<div class="inline c2">a</div></div></div>
90
<span class="c2 b">b</span>
91
<div class="inline c2">c</div>
92
<div class="inline c10"><div class="">10</div></div>
93
</div>
94
95
<div class="flex c1">
96
<div class="inline c2">0&nbsp;</div>
97
<div class="inline c1">x&nbsp;</div>
98
<div class="inline c1"><div class="inline c2">y</div></div>
99
<div class="inline c1"><div class="inline c2"><div class="">1<span>1</span></div></div></div>
100
<div class="c2"><div class="inline">2a<div>2<div class="inline c2">b<span class="b">b</span></div></div></div></div>
101
<div class="c3">3</div>
102
<div class="inline"><div class="inline c4">4</div></div>
103
<div class=""><div class="inline c5">5a</div></div>
104
<div class=" c5">5b</div>
105
<div class="inline c6"><div class="">6</div></div>
106
<div class="ib"><div class="inline c7"><div class="inline c2">7<span class="b">a</span></div></div></div>
107
<div class="inline c9"><div class="">8</div></div>
108
<div class="inline c9"><div class="inline">9<div class="inline c2">a</div></div></div>
109
<span class="c2 b">b</span>
110
<div class="inline c2">c</div>
111
<div class="inline c10"><div class="">10</div></div>
112
</div>
113
114
115
<div class="iflex"><div class="contents c2">
116
0
117
</div></div>
118
<div class="iflex"><div class="contents c2">
119
0
120
<div class="inline c1">1</div>
121
2
122
</div></div>
123
<div class="iflex"><div class="contents c2">
124
0<div class="inline c1">1</div>2
125
</div></div>
126
<div class="iflex c3">
127
0<div class="inline c2"><div class="c1">1</div></div>2
128
</div>
129
<div class="iflex c3">
130
<div class="inline c2">0</div><div class="inline c2"><div class="c1">1</div></div><div class="inline c2">2</div>
131
</div>
132
<div class="iflex c3">
133
<div class="inline">0</div>
134
<div class="inline"><div class="inline c1">1</div></div>
135
<div class="inline">2</div>
136
</div>
137
138
<ul><li class="c1"><div class="inline c2">
139
0
140
<div class="inline c1">x</div>
141
<div class="inline c1"><div class="inline c2">y</div></div>
142
<div class="inline c1"><div class="inline c2"><div class="">1<span>1</span></div></div></div>
143
<div class="inline c2"><div class="inline">2a<div class="">2<div class="inline c2">b<span class="b">b</span></div></div></div></div>
144
<div class="inline c3"><div class="inline">3</div></div>
145
<div class="inline"><div class="inline c4">4</div></div>
146
<div class=""><div class="inline c5">5a</div></div>
147
<div class=" c5">5b</div>
148
<div class="inline c6"><div class="">6</div></div>
149
<div class="ib"><div class="inline c7"><div class="inline c2">7<span class="b">a</span></div></div></div>
150
<div class="inline c9"><div class="">8</div></div>
151
<div class="inline c9"><div class="inline">9<div class="inline c2">a<span class="b">b</span>c</div></div></div>
152
<div class="inline c10"><div class="">10</div></div>
153
</div></li>
154
</ul>
155
156
<div class="columns">
157
<div class="contents c1"><div class="contents c2"><div>1<span>1</span></div></div></div>
158
<div class="contents c2"><div>2</div></div>
159
<div class="contents c3"><div>3</div></div>
160
</div>
161
162
<div class="columns">
163
<div class="contents c1"><div class="contents c2"><div>1<span>1</span></div></div></div>
164
<div class="contents c2"><div>2</div></div>
165
<div class="contents c3"><div>3</div></div>
166
</div>
167
168
<span class="c2 b"><legend class="inline c1">Legend</legend><legend class="inline c1">Legend</legend></span>
169
<br clear="all">
170
<span class="c3">x<div class="inline c1">float:left</div></span>
171
<span class="c3">y<div class="inline c1">position:absolute</div></span>
172
173
<!--  -->
174
175
<fieldset class="c1"><legend>Legend</legend>fieldset</fieldset>
176
<button class="c1">but<span>ton</span></button>
177
<select class="c1"><option>select</select>
178
179
</body>
180
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-generated-content-2.html (+236 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US" class="reftest-wait">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents; generated content</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
body,html { color:black; background-color:white; }
10
div { display:inline; }
11
12
.test {
13
  display-box: contents;
14
  content: "content";
15
  color: lime;
16
}
17
.contents {
18
  display-box: contents;
19
  color: green;
20
}
21
.s1 {display: none;}
22
.s2 {display: none;}
23
.s3 {display-box: contents;}
24
.s5 {display-box: contents;}
25
.s7 {display: none;}
26
.s8 {display: none;}
27
.s9 {display-box: contents;}
28
.s11 {display-box: contents;}
29
.before::before {
30
  display-box: contents;
31
  content:"before";
32
}
33
.after::after {
34
  display-box: contents;
35
  content:"after";
36
}
37
</style>
38
<script>
39
40
function setup() {
41
  document.body.offsetHeight;
42
  document.querySelector('.t1').className = 'contents';
43
  document.body.offsetHeight;
44
  document.querySelector('.t2').style.display = 'none';
45
  document.body.offsetHeight;
46
  document.querySelector('.t3').className = 'contents';
47
  document.body.offsetHeight;
48
  document.querySelector('.t4').style.displayBox = 'none';
49
  document.body.offsetHeight;
50
  document.querySelector('.t5').className = 'contents';
51
  document.body.offsetHeight;
52
  document.querySelector('.t6').style.display = 'none';
53
  document.body.offsetHeight;
54
  document.querySelector('.t7').className = 'contents';
55
  document.body.offsetHeight;
56
  document.querySelector('.t8').style.displayBox = 'none';
57
  document.body.offsetHeight;
58
  document.querySelector('.t9').className = 'contents';
59
  document.body.offsetHeight;
60
  document.querySelector('.t10').style.display = 'none';
61
  document.body.offsetHeight;
62
  document.querySelector('.t11').className = 'contents';
63
  document.body.offsetHeight;
64
  document.querySelector('.t12').style.displayBox = 'none';
65
  document.body.offsetHeight;
66
  document.querySelector('.t13').className = 'contents';
67
  document.body.offsetHeight;
68
  document.querySelector('.s1').className = 'contents';
69
  document.body.offsetHeight;
70
  document.querySelector('.s2').style.display = 'inline';
71
  document.body.offsetHeight;
72
  document.querySelector('.s3').style.displayBox = 'normal';
73
  document.body.offsetHeight;
74
  document.querySelector('.s4').className = 'contents';
75
  document.body.offsetHeight;
76
  document.querySelector('.s5').style.display = 'none';
77
  document.body.offsetHeight;
78
  document.querySelector('.s6').style.displayBox = 'none';
79
  document.body.offsetHeight;
80
  document.querySelector('.s7').className = 'contents';
81
  document.body.offsetHeight;
82
  document.querySelector('.s8').style.display = 'inline';
83
  document.body.offsetHeight;
84
  document.querySelector('.s9').style.displayBox = 'normal';
85
  document.body.offsetHeight;
86
  document.querySelector('.s10').className = 'contents';
87
  document.body.offsetHeight;
88
  document.querySelector('.s11').style.display = 'none';
89
  document.body.offsetHeight;
90
  document.querySelector('.s12').style.displayBox = 'none';
91
  document.body.offsetHeight;
92
}
93
94
function runTest() {
95
  var doc = document;
96
  var win = window;
97
  setup();
98
  var e = doc.querySelectorAll('*');
99
  for (i=0; i < e.length; ++i) {
100
    var elm = e[i];
101
    if (win.getComputedStyle(elm).displayBox == 'contents') {
102
      var c = elm.childNodes[0];
103
      if (c) {
104
        var next = c.nextSibling;
105
        elm.removeChild(c);
106
        elm.insertBefore(c,next);
107
      }
108
      var c = elm.childNodes[1];
109
      if (c) {
110
        var next = c.nextSibling;
111
        elm.removeChild(c);
112
        elm.insertBefore(c,next);
113
      }
114
      var c = elm.childNodes.length ? elm.childNodes[elm.childNodes.length-1] : null;
115
      if (c) {
116
        elm.removeChild(c);
117
        elm.appendChild(c);
118
      }
119
    }
120
  }
121
122
  document.documentElement.className = '';
123
}
124
125
</script>
126
</head>
127
<body onload="runTest()">
128
129
<div class="test"><span>A a</span></div>
130
<div class="test"><span class="t1">t1</span></div>
131
<div class="test"><span class="t2">t2</span></div>
132
<div class="contents before">1<span>B b</span>2</div>
133
<div class="contents after">1<span>C c</span>2</div>
134
<div class="contents before after">1<span>D d</span>2</div>
135
<div class="contents before">1<span class="t5">B b</span>2</div>
136
<div class="contents after">1<span class="t6">C c</span>2</div>
137
<div class="contents before after">1<span class="t7">D d</span>2</div>
138
139
<div class="contents">
140
  <div class="test"><span>span</span></div>
141
  <div class="test"><span class="t3">t3</span></div>
142
  <div class="test"><span class="t4">t4</span></div>
143
  <div class="contents before">1<span>span</span>2</div>
144
  <div class="contents after">1<span>span</span>2</div>
145
  <div class="contents before after">1<span>span</span>2</div>
146
  <div class="contents before">1<span class="t8">span</span>2</div>
147
  <div class="contents after">1<span class="t9">span</span>2</div>
148
  <div class="contents before after">1<span class="t10">span</span>2</div>
149
  <div class="contents before">1<span class="t11">span</span>2</div>
150
  <div class="contents after">1<span class="t12">span</span>2</div>
151
  <div class="contents before after">1<span class="t13">span</span>2</div>
152
</div>
153
154
<div class="contents"><span class="s1">
155
  <div class="test"><span>span</span></div>
156
  <div class="contents before">1<span>span</span>2</div>
157
  <div class="contents after">1<span>span</span>2</div>
158
  <div class="contents before after">1<span>span</span>2</div>
159
</span></div>
160
161
<div class="contents"><span class="s2">
162
  <div class="test"><span>span</span></div>
163
  <div class="contents before">1<span>span</span>2</div>
164
  <div class="contents after">1<span>span</span>2</div>
165
  <div class="contents before after">1<span>span</span>2</div>
166
</span></div>
167
168
<div class="contents"><span class="s3">
169
  <div class="test"><span>span</span></div>
170
  <div class="contents before">1<span>span</span>2</div>
171
  <div class="contents after">1<span>span</span>2</div>
172
  <div class="contents before after">1<span>span</span>2</div>
173
</span></div>
174
175
<div class="contents"><span class="s4">
176
  <div class="test"><span>span</span></div>
177
  <div class="contents before">1<span>span</span>2</div>
178
  <div class="contents after">1<span>span</span>2</div>
179
  <div class="contents before after">1<span>span</span>2</div>
180
</span></div>
181
182
<div class="contents"><span class="s5">
183
  <div class="test"><span>span</span></div>
184
  <div class="contents before">1<span>span</span>2</div>
185
  <div class="contents after">1<span>span</span>2</div>
186
  <div class="contents before after">1<span>span</span>2</div>
187
</span></div>
188
189
<div class="contents"><span class="s6">
190
  <div class="test"><span>span</span></div>
191
  <div class="contents before">1<span>span</span>2</div>
192
  <div class="contents after">1<span>span</span>2</div>
193
  <div class="contents before after">1<span>span</span>2</div>
194
</span></div>
195
196
<div class="contents before"><span class="s7">
197
  <div class="contents before">1<span>span</span>2</div>
198
  <div class="contents after">1<span>span</span>2</div>
199
  <div class="contents before after">1<span>span</span>2</div>
200
</span></div>
201
202
<div class="contents after"><span class="s8">
203
  <div class="contents before">1<span>span</span>2</div>
204
  <div class="contents after">1<span>span</span>2</div>
205
  <div class="contents before after">1<span>span</span>2</div>
206
</span></div>
207
208
<div class="contents"><span class="s9">
209
  <div class="contents before">1<span>span</span>2</div>
210
  <div class="contents after">1<span>span</span>2</div>
211
  <div class="contents before after">1<span>span</span>2</div>
212
</span></div>
213
214
<div class="contents before after"><span class="s10">
215
  <div class="test"><span>span</span></div>
216
  <div class="contents before">1<span>span</span>2</div>
217
  <div class="contents after">1<span>span</span>2</div>
218
  <div class="contents before after">1<span>span</span>2</div>
219
</span></div>
220
221
<div class="contents before"><span class="s11">
222
  <div class="test"><span>span</span></div>
223
  <div class="contents before">1<span>span</span>2</div>
224
  <div class="contents after">1<span>span</span>2</div>
225
  <div class="contents before after">1<span>span</span>2</div>
226
</span></div>
227
228
<div class="contents after"><span class="s12">
229
  <div class="test"><span>span</span></div>
230
  <div class="contents before">1<span>span</span>2</div>
231
  <div class="contents after">1<span>span</span>2</div>
232
  <div class="contents before after">1<span>span</span>2</div>
233
</span></div>
234
235
</body>
236
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-generated-content.html (+207 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US" class="reftest-wait">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents; generated content</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
body,html { color:black; background-color:white; }
10
div { display:inline; }
11
12
.test {
13
  display-box: contents;
14
  content: "content";
15
  color: lime;
16
}
17
.contents {
18
  display-box: contents;
19
  color: green;
20
}
21
.s1 {display: none;}
22
.s2 {display: none;}
23
.s3 {display-box: contents;}
24
.s5 {display-box: contents;}
25
.s7 {display: none;}
26
.s8 {display: none;}
27
.s9 {display-box: contents;}
28
.s11 {display-box: contents;}
29
.before::before {
30
  display-box: contents;
31
  content:"before";
32
}
33
.after::after {
34
  display-box: contents;
35
  content:"after";
36
}
37
</style>
38
<script>
39
40
function runTest() {
41
  document.body.offsetHeight;
42
  document.querySelector('.t1').className = 'contents';
43
  document.body.offsetHeight;
44
  document.querySelector('.t2').style.display = 'none';
45
  document.body.offsetHeight;
46
  document.querySelector('.t3').className = 'contents';
47
  document.body.offsetHeight;
48
  document.querySelector('.t4').style.displayBox = 'none';
49
  document.body.offsetHeight;
50
  document.querySelector('.t5').className = 'contents';
51
  document.body.offsetHeight;
52
  document.querySelector('.t6').style.display = 'none';
53
  document.body.offsetHeight;
54
  document.querySelector('.t7').className = 'contents';
55
  document.body.offsetHeight;
56
  document.querySelector('.t8').style.displayBox = 'none';
57
  document.body.offsetHeight;
58
  document.querySelector('.t9').className = 'contents';
59
  document.body.offsetHeight;
60
  document.querySelector('.t10').style.display = 'none';
61
  document.body.offsetHeight;
62
  document.querySelector('.t11').className = 'contents';
63
  document.body.offsetHeight;
64
  document.querySelector('.t12').style.displayBox = 'none';
65
  document.body.offsetHeight;
66
  document.querySelector('.t13').className = 'contents';
67
  document.body.offsetHeight;
68
  document.querySelector('.s1').className = 'contents';
69
  document.body.offsetHeight;
70
  document.querySelector('.s2').style.display = 'inline';
71
  document.body.offsetHeight;
72
  document.querySelector('.s3').style.displayBox = 'normal';
73
  document.body.offsetHeight;
74
  document.querySelector('.s4').className = 'contents';
75
  document.body.offsetHeight;
76
  document.querySelector('.s5').style.display = 'none';
77
  document.body.offsetHeight;
78
  document.querySelector('.s6').style.displayBox = 'none';
79
  document.body.offsetHeight;
80
  document.querySelector('.s7').className = 'contents';
81
  document.body.offsetHeight;
82
  document.querySelector('.s8').style.display = 'inline';
83
  document.body.offsetHeight;
84
  document.querySelector('.s9').style.displayBox = 'normal';
85
  document.body.offsetHeight;
86
  document.querySelector('.s10').className = 'contents';
87
  document.body.offsetHeight;
88
  document.querySelector('.s11').style.display = 'none';
89
  document.body.offsetHeight;
90
  document.querySelector('.s12').style.displayBox = 'none';
91
  document.body.offsetHeight;
92
93
  document.documentElement.className = '';
94
}
95
96
</script>
97
</head>
98
<body onload="runTest()">
99
100
<div class="test"><span>A a</span></div>
101
<div class="test"><span class="t1">t1</span></div>
102
<div class="test"><span class="t2">t2</span></div>
103
<div class="contents before">1<span>B b</span>2</div>
104
<div class="contents after">1<span>C c</span>2</div>
105
<div class="contents before after">1<span>D d</span>2</div>
106
<div class="contents before">1<span class="t5">B b</span>2</div>
107
<div class="contents after">1<span class="t6">C c</span>2</div>
108
<div class="contents before after">1<span class="t7">D d</span>2</div>
109
110
<div class="contents">
111
  <div class="test"><span>span</span></div>
112
  <div class="test"><span class="t3">t3</span></div>
113
  <div class="test"><span class="t4">t4</span></div>
114
  <div class="contents before">1<span>span</span>2</div>
115
  <div class="contents after">1<span>span</span>2</div>
116
  <div class="contents before after">1<span>span</span>2</div>
117
  <div class="contents before">1<span class="t8">span</span>2</div>
118
  <div class="contents after">1<span class="t9">span</span>2</div>
119
  <div class="contents before after">1<span class="t10">span</span>2</div>
120
  <div class="contents before">1<span class="t11">span</span>2</div>
121
  <div class="contents after">1<span class="t12">span</span>2</div>
122
  <div class="contents before after">1<span class="t13">span</span>2</div>
123
</div>
124
125
<div class="contents"><span class="s1">
126
  <div class="test"><span>span</span></div>
127
  <div class="contents before">1<span>span</span>2</div>
128
  <div class="contents after">1<span>span</span>2</div>
129
  <div class="contents before after">1<span>span</span>2</div>
130
</span></div>
131
132
<div class="contents"><span class="s2">
133
  <div class="test"><span>span</span></div>
134
  <div class="contents before">1<span>span</span>2</div>
135
  <div class="contents after">1<span>span</span>2</div>
136
  <div class="contents before after">1<span>span</span>2</div>
137
</span></div>
138
139
<div class="contents"><span class="s3">
140
  <div class="test"><span>span</span></div>
141
  <div class="contents before">1<span>span</span>2</div>
142
  <div class="contents after">1<span>span</span>2</div>
143
  <div class="contents before after">1<span>span</span>2</div>
144
</span></div>
145
146
<div class="contents"><span class="s4">
147
  <div class="test"><span>span</span></div>
148
  <div class="contents before">1<span>span</span>2</div>
149
  <div class="contents after">1<span>span</span>2</div>
150
  <div class="contents before after">1<span>span</span>2</div>
151
</span></div>
152
153
<div class="contents"><span class="s5">
154
  <div class="test"><span>span</span></div>
155
  <div class="contents before">1<span>span</span>2</div>
156
  <div class="contents after">1<span>span</span>2</div>
157
  <div class="contents before after">1<span>span</span>2</div>
158
</span></div>
159
160
<div class="contents"><span class="s6">
161
  <div class="test"><span>span</span></div>
162
  <div class="contents before">1<span>span</span>2</div>
163
  <div class="contents after">1<span>span</span>2</div>
164
  <div class="contents before after">1<span>span</span>2</div>
165
</span></div>
166
167
<div class="contents before"><span class="s7">
168
  <div class="contents before">1<span>span</span>2</div>
169
  <div class="contents after">1<span>span</span>2</div>
170
  <div class="contents before after">1<span>span</span>2</div>
171
</span></div>
172
173
<div class="contents after"><span class="s8">
174
  <div class="contents before">1<span>span</span>2</div>
175
  <div class="contents after">1<span>span</span>2</div>
176
  <div class="contents before after">1<span>span</span>2</div>
177
</span></div>
178
179
<div class="contents"><span class="s9">
180
  <div class="contents before">1<span>span</span>2</div>
181
  <div class="contents after">1<span>span</span>2</div>
182
  <div class="contents before after">1<span>span</span>2</div>
183
</span></div>
184
185
<div class="contents before after"><span class="s10">
186
  <div class="test"><span>span</span></div>
187
  <div class="contents before">1<span>span</span>2</div>
188
  <div class="contents after">1<span>span</span>2</div>
189
  <div class="contents before after">1<span>span</span>2</div>
190
</span></div>
191
192
<div class="contents before"><span class="s11">
193
  <div class="test"><span>span</span></div>
194
  <div class="contents before">1<span>span</span>2</div>
195
  <div class="contents after">1<span>span</span>2</div>
196
  <div class="contents before after">1<span>span</span>2</div>
197
</span></div>
198
199
<div class="contents after"><span class="s12">
200
  <div class="test"><span>span</span></div>
201
  <div class="contents before">1<span>span</span>2</div>
202
  <div class="contents after">1<span>span</span>2</div>
203
  <div class="contents before after">1<span>span</span>2</div>
204
</span></div>
205
206
</body>
207
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-generated-content-ref.html (+119 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents; generated content</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
body,html { color:black; background-color:white; }
10
11
.test {
12
  display: inline;
13
  content: "content";
14
  color: lime;
15
}
16
.contents {
17
  display: inline;
18
  color: green;
19
}
20
.before::before {
21
  display: inline;
22
  content:"before";
23
}
24
.after::after {
25
  display: inline;
26
  content:"after";
27
}
28
</style>
29
</head>
30
<body>
31
32
<div class="test"><span>A a</span></div>
33
<div class="test"><span class="contents">t1</span></div>
34
<div class="test"></div>
35
<div class="contents before">1<span>B b</span>2</div>
36
<div class="contents after">1<span>C c</span>2</div>
37
<div class="contents before after">1<span>D d</span>2</div>
38
<div class="contents before">1<span class="t5">B b</span>2</div>
39
<div class="contents after">12</div>
40
<div class="contents before after">1<span class="t7">D d</span>2</div>
41
42
<div class="contents">
43
  <div class="test"><span>span</span></div>
44
  <div class="test"><span class="contents">t3</span></div>
45
  <div class="test"></div>
46
  <div class="contents before">1<span>span</span>2</div>
47
  <div class="contents after">1<span>span</span>2</div>
48
  <div class="contents before after">1<span>span</span>2</div>
49
  <div class="contents before">12</div>
50
  <div class="contents after">1<span class="t9">span</span>2</div>
51
  <div class="contents before after">12</div>
52
  <div class="contents before">1<span class="t11">span</span>2</div>
53
  <div class="contents after">12</div>
54
  <div class="contents before after">1<span class="t13">span</span>2</div>
55
</div>
56
57
<div class="contents"><span class="s1">
58
  <div class="test"><span>span</span></div>
59
  <div class="contents before">1<span>span</span>2</div>
60
  <div class="contents after">1<span>span</span>2</div>
61
  <div class="contents before after">1<span>span</span>2</div>
62
</span></div>
63
64
<div class="contents"><span class="s2">
65
  <div class="test"><span>span</span></div>
66
  <div class="contents before">1<span>span</span>2</div>
67
  <div class="contents after">1<span>span</span>2</div>
68
  <div class="contents before after">1<span>span</span>2</div>
69
</span></div>
70
71
<div class="contents"><span class="s3">
72
  <div class="test"><span>span</span></div>
73
  <div class="contents before">1<span>span</span>2</div>
74
  <div class="contents after">1<span>span</span>2</div>
75
  <div class="contents before after">1<span>span</span>2</div>
76
</span></div>
77
78
<div class="contents"><span class="s4">
79
  <div class="test"><span>span</span></div>
80
  <div class="contents before">1<span>span</span>2</div>
81
  <div class="contents after">1<span>span</span>2</div>
82
  <div class="contents before after">1<span>span</span>2</div>
83
</span></div>
84
85
<div class="contents"></div>
86
87
<div class="contents"></div>
88
89
<div class="contents before"><span class="s7">
90
  <div class="contents before">1<span>span</span>2</div>
91
  <div class="contents after">1<span>span</span>2</div>
92
  <div class="contents before after">1<span>span</span>2</div>
93
</span></div>
94
95
<div class="contents after"><span class="s8">
96
  <div class="contents before">1<span>span</span>2</div>
97
  <div class="contents after">1<span>span</span>2</div>
98
  <div class="contents before after">1<span>span</span>2</div>
99
</span></div>
100
101
<div class="contents"><span class="s9">
102
  <div class="contents before">1<span>span</span>2</div>
103
  <div class="contents after">1<span>span</span>2</div>
104
  <div class="contents before after">1<span>span</span>2</div>
105
</span></div>
106
107
<div class="contents before after"><span class="s10">
108
  <div class="test"><span>span</span></div>
109
  <div class="contents before">1<span>span</span>2</div>
110
  <div class="contents after">1<span>span</span>2</div>
111
  <div class="contents before after">1<span>span</span>2</div>
112
</span></div>
113
114
<div class="contents before"></div>
115
116
<div class="contents after"></div>
117
118
</body>
119
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-style-inheritance-1-dom-mutations.html (+110 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US" class="reftest-wait">
3
<head>
4
  <meta charset="utf-8">
5
  <title>CSS Test: CSS display-box:contents; style inheritance, DOM mutations</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
body,span { color:black; background-color:white; }
10
.test { display-box:contents; }
11
.green { color:green; }
12
.border { border-left:1px solid green; }
13
b { border:inherit; font-weight:normal; }
14
</style>
15
<script>
16
function $(id) { return document.getElementById(id); }
17
function text(s) { return document.createTextNode(s); }
18
function b(s) { var e = document.createElement('b'); e.appendChild(document.createTextNode(s)); return e; }
19
function div(s) { var e = document.createElement('div'); e.setAttribute('class','test'); e.appendChild(document.createTextNode(s)); return e; }
20
function runTest() {
21
  var e = $('t1');
22
  var c = e.firstChild;
23
  e.insertBefore(text('g'), c);
24
  e.insertBefore(text('r'), c);
25
  e.appendChild(text('n'));
26
27
  var e = $('t2');
28
  var c = e.firstChild;
29
  e.insertBefore(text('gr'), c);
30
  e.appendChild(text('n'));
31
32
  var e = $('t3');
33
  var c = e.firstChild;
34
  e.insertBefore(text('n'), c);
35
  e.insertBefore(text('o'), c);
36
  e.appendChild(text('er'));
37
38
  var e = $('t4');
39
  var c = e.firstChild;
40
  e.insertBefore(text('n'), c);
41
  e.insertBefore(text('o'), c);
42
  e.appendChild(text('er'));
43
44
  var e = $('t5');
45
  var c = e.firstChild;
46
  e.insertBefore(b('1px green left '), c);
47
  e.appendChild(text('er'));
48
49
  var e = $('t6');
50
  e.appendChild(b('2px green left border'));
51
52
  var e = $('t7');
53
  e.appendChild(div('green'));
54
55
  var e = $('t8');
56
  e.appendChild(div('green'));
57
58
  var e = $('t9');
59
  var c = b("1px green left border");
60
  var d = div('');
61
  d.appendChild(c);
62
  e.appendChild(d);
63
64
  var e = $('t10');
65
  var c = b("1px green left border");
66
  var d = div('');
67
  d.setAttribute('style','border:inherit');
68
  d.appendChild(c);
69
  e.appendChild(d);
70
71
  var e = $('t11');
72
  var c = b("2px green left border");
73
  var d = div('');
74
  d.setAttribute('style','border:inherit');
75
  d.appendChild(c);
76
  e.appendChild(d);
77
78
  var e = $('t12');
79
  var c = e.firstChild;
80
  e.insertBefore(text("This text"), c);
81
  e.insertBefore(b(" should be"), c);
82
  e.appendChild(text(" green"));
83
84
  document.documentElement.className = '';
85
}
86
</script>
87
</head>
88
<body onload="runTest()">
89
90
<span class="green"><div class="test" id="t1">ee</div></span>
91
<span><div class="test green" id="t2">ee</div></span>
92
<br>
93
<span><div class="test border" id="t3"> bord</div></span>
94
<span><div class="test border" id="t4"><span> bord</span></div></span>
95
<span class="border"><div class="test" id="t5">bord</div></span>
96
<span class="border"><div class="test" style="border:inherit" id="t6"></div></span>
97
<br>
98
99
<span class="green"><div class="test" id="t7"></div></span>
100
<span><div class="test green" id="t8"></div></span>
101
<br>
102
<span class="border"><div class="test" id="t9"></div></span>
103
<span class="border"><div class="test" id="t10"></div></span>
104
<span class="border"><div class="test" style="border:inherit" id="t11"></div></span>
105
<br>
106
107
<span style="color:red"><div class="test green" id="t12"></div></span>
108
109
</body>
110
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-style-inheritance-1.html (+37 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="utf-8">
5
  <title>CSS Test: CSS display-box:contents; style inheritance</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
body,span { color:black; background-color:white; }
10
.test { display-box:contents; }
11
.green { color:green; }
12
.border { border-left:1px solid green; }
13
b { border:inherit; font-weight:normal; }
14
</style>
15
</head>
16
<body>
17
<span class="green"><div class="test">green</div></span>
18
<span><div class="test green">green</div></span>
19
<br>
20
<span><div class="test border">no border</div></span>
21
<span><div class="test border"><span>no border</span></div></span>
22
<span class="border"><div class="test"><b>1px green left border</b></div></span>
23
<span class="border"><div class="test" style="border:inherit"><b>2px green left border</b></div></span>
24
<br>
25
26
<span class="green"><div class="test"><div class="test">green</div></div></span>
27
<span><div class="test green"><div class="test">green</div></div></span>
28
<br>
29
<span class="border"><div class="test"><div class="test"><b>1px green left border</b></div></div></span>
30
<span class="border"><div class="test"><div class="test" style="border:inherit"><b>1px green left border</b></div></div></span>
31
<span class="border"><div class="test" style="border:inherit"><div class="test" style="border:inherit"><b>2px green left border</b></div></div></span>
32
<br>
33
34
<span style="color:red"><div class="test green">This text should be green</div></span>
35
36
</body>
37
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-style-inheritance-1-ref.html (+36 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="utf-8">
5
  <title>CSS Test: CSS display-box:contents; style inheritance</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
<style type="text/css">
8
body,span { color:black; background-color:white; }
9
.test { display:inline; }
10
.green { color:green; }
11
.border { border-left:1px solid green; }
12
b { font-weight:normal; }
13
</style>
14
</head>
15
<body>
16
<span class="green"><div class="test">green</div></span>
17
<span><div class="test green">green</div></span>
18
<br>
19
<span><div class="test">no border</div></span>
20
<span><div class="test">no border</div></span>
21
<span class="border"><div class="test"><b>1px green left border</b></div></span>
22
<span class="border"><div class="test" style="border:inherit"><b>2px green left border</b></div></span>
23
<br>
24
25
<span class="green"><div class="test"><div class="test">green</div></div></span>
26
<span><div class="test green"><div class="test">green</div></div></span>
27
<br>
28
<span class="border"><div class="test"><div class="test"><b>1px green left border</b></div></div></span>
29
<span class="border"><div class="test"><div class="test" style="border:inherit"><b>1px green left border</b></div></div></span>
30
<span class="border"><div class="test" style="border:inherit"><div class="test"><b>2px green left border</b></div></div></span>
31
<br>
32
33
<span><div class="green" id="t12">This text should be green</div></span>
34
35
</body>
36
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-style-inheritance-1-stylechange.html (+52 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US" class="reftest-wait">
3
<head>
4
  <meta charset="utf-8">
5
  <title>CSS Test: CSS display-box:contents; style inheritance, style changes</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
<style type="text/css">
9
body,span { color:black; background-color:white; }
10
.test { display-box:contents; border:10px solid black; }
11
.test2 { display-box:contents; border-style:none; }
12
.test3:not(:lang(foo)) { display-box:contents; color:cyan; }
13
.green { color:green; }
14
.border { border-left:1px solid green; }
15
b { border:inherit; font-weight:normal; }
16
</style>
17
<script>
18
function runTest() {
19
  var elms = document.querySelectorAll('.test')
20
  for (i=0; i < elms.length; ++i) {
21
    elms[i].classList.remove('test');
22
    elms[i].classList.add('test2');
23
  }
24
  document.body.lang = 'foo';
25
  document.body.offsetWidth;
26
27
  document.documentElement.className = '';
28
}
29
</script>
30
</head>
31
<body onload="setTimeout(runTest,0)">
32
<span class="green"><div class="test">green</div></span>
33
<span><div class="test green">green</div></span>
34
<br>
35
<span><div class="test border">no border</div></span>
36
<span><div class="test border"><span>no border</span></div></span>
37
<span class="border"><div class="test"><b>1px green left border</b></div></span>
38
<span class="border"><div class="test" style="border:inherit"><b>2px green left border</b></div></span>
39
<br>
40
41
<span class="green"><div class="test"><div class="test">green</div></div></span>
42
<span><div class="test green"><div class="test">green</div></div></span>
43
<br>
44
<span class="border"><div class="test"><div class="test"><b>1px green left border</b></div></div></span>
45
<span class="border"><div class="test"><div class="test" style="border:inherit"><b>1px green left border</b></div></div></span>
46
<span class="border"><div class="test" style="border:inherit"><div class="test" style="border:inherit"><b>2px green left border</b></div></div></span>
47
<br>
48
49
<span style="color:red"><div class="test3 green">This text should be green</div></span>
50
51
</body>
52
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-tables-2.xhtml (+14 lines)
Line     Link Here 
Line 0    Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
3
<head>
4
  <title>CSS Test: CSS display-box:contents; tables</title>
5
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396"/>
6
  <link rel="help" href="http://dev.w3.org/csswg/css-display"/>
7
<style type="text/css">
8
html { color:red; background-color:white; }
9
body { color:white; background-color:pink; width:0; }
10
.test { display-box:contents; color:white; background-color:lime; }
11
td { background-color:inherit; }
12
</style>
13
</head>
14
<body><div class="test"><td>green</td></div><td>pink</td></body></html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-tables-3-ref.xhtml (+12 lines)
Line     Link Here 
Line 0    Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
3
<head>
4
  <title>CSS Test: CSS display-box:contents; tables</title>
5
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396"/>
6
<style type="text/css">
7
body { color:red; background-color:white; }
8
.test { float:left; color:white; background-color:lime; }
9
td { background-color:inherit; }
10
</style>
11
</head>
12
<body><div class="test"><td>green</td></div></body></html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-tables-3.xhtml (+13 lines)
Line     Link Here 
Line 0    Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
3
<head>
4
  <title>CSS Test: CSS display-box:contents; tables</title>
5
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396"/>
6
  <link rel="help" href="http://dev.w3.org/csswg/css-display"/>
7
<style type="text/css">
8
body { color:red; background-color:white; }
9
.test { display-box:contents; color:white; background-color:lime; }
10
td { background-color:inherit; }
11
</style>
12
</head>
13
<body><div class="test"><td>green</td></div></body></html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-tables-ref.xhtml (+12 lines)
Line     Link Here 
Line 0    Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
3
<head>
4
  <title>CSS Test: CSS display-box:contents; tables</title>
5
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396"/>
6
<style type="text/css">
7
body { color:red; background-color:white; }
8
td { color:white; background-color:lime; }
9
.pink { background-color:pink; }
10
</style>
11
</head>
12
<body><td>green</td><td class="pink">pink</td></body></html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-tables.xhtml (+13 lines)
Line     Link Here 
Line 0    Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
3
<head>
4
  <title>CSS Test: CSS display-box:contents; tables</title>
5
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396"/>
6
  <link rel="help" href="http://dev.w3.org/csswg/css-display"/>
7
<style type="text/css">
8
body { color:red; background-color:white; }
9
.test { display-box:contents; color:white; background-color:lime; }
10
td { background-color:inherit; }
11
</style>
12
</head>
13
<body><div class="test"><td>green</td></div><div class="test" style="background-color:pink"><td>pink</td></div></body></html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-visibility-hidden-2.html (+20 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US" class="reftest-wait">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents; visibility:hidden</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
</head>
9
<body style="color: red">
10
  <div id="x" style="display-box:contents; visibility: hidden; color: green">
11
    Line 1
12
  </div><script type="text/javascript">
13
    document.body.offsetWidth;
14
    document.getElementById("x").style.visibility = "visible";
15
    document.body.offsetWidth;
16
17
    document.documentElement.className = '';
18
  </script>
19
</body>
20
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-visibility-hidden.html (+22 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US" class="reftest-wait">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents; visibility:hidden</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
  <link rel="help" href="http://dev.w3.org/csswg/css-display">
8
</head>
9
<body>
10
  <div id="x" style="display-box:contents; visibility: hidden">
11
    Line 1
12
  </div><script type="text/javascript">
13
    document.body.offsetWidth;
14
    document.getElementById("x").style.visibility = "visible";
15
    document.body.style.color = "green";
16
    document.body.offsetWidth;
17
18
    document.documentElement.className = '';
19
  </script>
20
21
</body>
22
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/display-box-contents-visibility-hidden-ref.html (+14 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE html>
2
<html lang="en-US">
3
<head>
4
  <meta charset="UTF-8">
5
  <title>CSS Test: CSS display-box:contents; visibility:hidden</title>
6
  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=907396">
7
</head>
8
<body>
9
  <div id="x" style="color:green">
10
    Line 1
11
  </div>
12
13
</body>
14
</html>
(-)mc.082761b7bc54/layout/reftests/css-display/reftest.list (+18 lines)
Line     Link Here 
Line 0    Link Here 
1
# Tests for CSS Display spec features.
2
# http://dev.w3.org/csswg/css-display
3
4
pref(layout.css.display-box.enabled,true) == display-box-contents-acid.html display-box-contents-acid-ref.html
5
pref(layout.css.display-box.enabled,true) == display-box-contents-acid-dyn-1.html display-box-contents-acid-ref.html
6
pref(layout.css.display-box.enabled,true) == display-box-contents-acid-dyn-2.html display-box-contents-acid-ref.html
7
pref(layout.css.display-box.enabled,true) == display-box-contents-acid-dyn-3.html display-box-contents-acid-ref.html
8
pref(layout.css.display-box.enabled,true) == display-box-contents-generated-content.html display-box-contents-generated-content-ref.html
9
pref(layout.css.display-box.enabled,true) == display-box-contents-generated-content-2.html display-box-contents-generated-content-ref.html
10
pref(layout.css.display-box.enabled,true) == display-box-contents-style-inheritance-1.html display-box-contents-style-inheritance-1-ref.html
11
pref(layout.css.display-box.enabled,true) == display-box-contents-style-inheritance-1-stylechange.html display-box-contents-style-inheritance-1-ref.html
12
pref(layout.css.display-box.enabled,true) fuzzy-if(d2d,2,100) == display-box-contents-style-inheritance-1-dom-mutations.html display-box-contents-style-inheritance-1-ref.html
13
pref(layout.css.display-box.enabled,true) == display-box-contents-tables.xhtml display-box-contents-tables-ref.xhtml
14
pref(layout.css.display-box.enabled,true) == display-box-contents-tables-2.xhtml display-box-contents-tables-ref.xhtml
15
pref(layout.css.display-box.enabled,true) == display-box-contents-tables-3.xhtml display-box-contents-tables-3-ref.xhtml
16
pref(layout.css.display-box.enabled,true) == display-box-contents-visibility-hidden.html display-box-contents-visibility-hidden-ref.html
17
pref(layout.css.display-box.enabled,true) == display-box-contents-visibility-hidden-2.html display-box-contents-visibility-hidden-ref.html
18
pref(layout.css.display-box.enabled,true) == display-box-contents-495385-2d.html display-box-contents-495385-2d-ref.html
(-)mc.082761b7bc54/layout/reftests/reftest.list (+3 lines)
Line     Link Here 
 Lines 58-73   skip-if(B2G||Android) include css-blendi Link Here 
58
include css-calc/reftest.list
58
include css-calc/reftest.list
59
59
60
# css character encoding tests
60
# css character encoding tests
61
skip-if(B2G) include css-charset/reftest.list
61
skip-if(B2G) include css-charset/reftest.list
62
62
63
# css default pseudo class tests
63
# css default pseudo class tests
64
skip-if(B2G) include css-default/reftest.list
64
skip-if(B2G) include css-default/reftest.list
65
65
66
# css-display spec tests
67
include css-display/reftest.list
68
66
# css :disable tests
69
# css :disable tests
67
skip-if(Android||B2G) include css-disabled/reftest.list
70
skip-if(Android||B2G) include css-disabled/reftest.list
68
71
69
# css :enable tests
72
# css :enable tests
70
skip-if(Android||B2G) include css-enabled/reftest.list
73
skip-if(Android||B2G) include css-enabled/reftest.list
71
74
72
# css @import tests
75
# css @import tests
73
skip-if(B2G) include css-import/reftest.list
76
skip-if(B2G) include css-import/reftest.list
(-)mc.082761b7bc54/layout/style/nsComputedDOMStyle.cpp (+9 lines)
Line     Link Here 
 Lines 3849-3864   nsComputedDOMStyle::DoGetUserSelect() Link Here 
3849
  nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
3849
  nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
3850
  val->SetIdent(
3850
  val->SetIdent(
3851
    nsCSSProps::ValueToKeywordEnum(StyleUIReset()->mUserSelect,
3851
    nsCSSProps::ValueToKeywordEnum(StyleUIReset()->mUserSelect,
3852
                                   nsCSSProps::kUserSelectKTable));
3852
                                   nsCSSProps::kUserSelectKTable));
3853
  return val;
3853
  return val;
3854
}
3854
}
3855
3855
3856
CSSValue*
3856
CSSValue*
3857
nsComputedDOMStyle::DoGetDisplayBox()
3858
{
3859
  nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
3860
  val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mDisplayBox,
3861
                                               nsCSSProps::kDisplayBoxKTable));
3862
  return val;
3863
}
3864
3865
CSSValue*
3857
nsComputedDOMStyle::DoGetDisplay()
3866
nsComputedDOMStyle::DoGetDisplay()
3858
{
3867
{
3859
  nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
3868
  nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
3860
  val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mDisplay,
3869
  val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mDisplay,
3861
                                               nsCSSProps::kDisplayKTable));
3870
                                               nsCSSProps::kDisplayKTable));
3862
  return val;
3871
  return val;
3863
}
3872
}
3864
3873
(-)mc.082761b7bc54/layout/style/nsComputedDOMStyle.h (+1 lines)
Line     Link Here 
 Lines 402-417   private: Link Here 
402
  mozilla::dom::CSSValue* DoGetWritingMode();
402
  mozilla::dom::CSSValue* DoGetWritingMode();
403
403
404
  /* Direction properties */
404
  /* Direction properties */
405
  mozilla::dom::CSSValue* DoGetDirection();
405
  mozilla::dom::CSSValue* DoGetDirection();
406
  mozilla::dom::CSSValue* DoGetUnicodeBidi();
406
  mozilla::dom::CSSValue* DoGetUnicodeBidi();
407
407
408
  /* Display properties */
408
  /* Display properties */
409
  mozilla::dom::CSSValue* DoGetBinding();
409
  mozilla::dom::CSSValue* DoGetBinding();
410
  mozilla::dom::CSSValue* DoGetDisplayBox();
410
  mozilla::dom::CSSValue* DoGetClear();
411
  mozilla::dom::CSSValue* DoGetClear();
411
  mozilla::dom::CSSValue* DoGetFloat();
412
  mozilla::dom::CSSValue* DoGetFloat();
412
  mozilla::dom::CSSValue* DoGetDisplay();
413
  mozilla::dom::CSSValue* DoGetDisplay();
413
  mozilla::dom::CSSValue* DoGetPosition();
414
  mozilla::dom::CSSValue* DoGetPosition();
414
  mozilla::dom::CSSValue* DoGetClip();
415
  mozilla::dom::CSSValue* DoGetClip();
415
  mozilla::dom::CSSValue* DoGetImageOrientation();
416
  mozilla::dom::CSSValue* DoGetImageOrientation();
416
  mozilla::dom::CSSValue* DoGetWillChange();
417
  mozilla::dom::CSSValue* DoGetWillChange();
417
  mozilla::dom::CSSValue* DoGetOverflow();
418
  mozilla::dom::CSSValue* DoGetOverflow();
(-)mc.082761b7bc54/layout/style/nsComputedDOMStylePropertyList.h (+1 lines)
Line     Link Here 
 Lines 102-117   COMPUTED_STYLE_PROP(clear, Link Here 
102
COMPUTED_STYLE_PROP(clip,                          Clip)
102
COMPUTED_STYLE_PROP(clip,                          Clip)
103
COMPUTED_STYLE_PROP(color,                         Color)
103
COMPUTED_STYLE_PROP(color,                         Color)
104
COMPUTED_STYLE_PROP(content,                       Content)
104
COMPUTED_STYLE_PROP(content,                       Content)
105
COMPUTED_STYLE_PROP(counter_increment,             CounterIncrement)
105
COMPUTED_STYLE_PROP(counter_increment,             CounterIncrement)
106
COMPUTED_STYLE_PROP(counter_reset,                 CounterReset)
106
COMPUTED_STYLE_PROP(counter_reset,                 CounterReset)
107
COMPUTED_STYLE_PROP(cursor,                        Cursor)
107
COMPUTED_STYLE_PROP(cursor,                        Cursor)
108
COMPUTED_STYLE_PROP(direction,                     Direction)
108
COMPUTED_STYLE_PROP(direction,                     Direction)
109
COMPUTED_STYLE_PROP(display,                       Display)
109
COMPUTED_STYLE_PROP(display,                       Display)
110
COMPUTED_STYLE_PROP(display_box,                   DisplayBox)
110
COMPUTED_STYLE_PROP(empty_cells,                   EmptyCells)
111
COMPUTED_STYLE_PROP(empty_cells,                   EmptyCells)
111
COMPUTED_STYLE_PROP(flex_basis,                    FlexBasis)
112
COMPUTED_STYLE_PROP(flex_basis,                    FlexBasis)
112
COMPUTED_STYLE_PROP(flex_direction,                FlexDirection)
113
COMPUTED_STYLE_PROP(flex_direction,                FlexDirection)
113
COMPUTED_STYLE_PROP(flex_grow,                     FlexGrow)
114
COMPUTED_STYLE_PROP(flex_grow,                     FlexGrow)
114
COMPUTED_STYLE_PROP(flex_shrink,                   FlexShrink)
115
COMPUTED_STYLE_PROP(flex_shrink,                   FlexShrink)
115
COMPUTED_STYLE_PROP(flex_wrap,                     FlexWrap)
116
COMPUTED_STYLE_PROP(flex_wrap,                     FlexWrap)
116
COMPUTED_STYLE_PROP(float,                         Float)
117
COMPUTED_STYLE_PROP(float,                         Float)
117
//// COMPUTED_STYLE_PROP(font,                     Font)
118
//// COMPUTED_STYLE_PROP(font,                     Font)
(-)mc.082761b7bc54/layout/style/nsCSSKeywordList.h (+1 lines)
Line     Link Here 
 Lines 218-233   CSS_KEY(color, color) Link Here 
218
CSS_KEY(color-burn, color_burn)
218
CSS_KEY(color-burn, color_burn)
219
CSS_KEY(color-dodge, color_dodge)
219
CSS_KEY(color-dodge, color_dodge)
220
CSS_KEY(common-ligatures, common_ligatures)
220
CSS_KEY(common-ligatures, common_ligatures)
221
CSS_KEY(column, column)
221
CSS_KEY(column, column)
222
CSS_KEY(column-reverse, column_reverse)
222
CSS_KEY(column-reverse, column_reverse)
223
CSS_KEY(condensed, condensed)
223
CSS_KEY(condensed, condensed)
224
CSS_KEY(contain, contain)
224
CSS_KEY(contain, contain)
225
CSS_KEY(content-box, content_box)
225
CSS_KEY(content-box, content_box)
226
CSS_KEY(contents, contents)
226
CSS_KEY(context-fill, context_fill)
227
CSS_KEY(context-fill, context_fill)
227
CSS_KEY(context-fill-opacity, context_fill_opacity)
228
CSS_KEY(context-fill-opacity, context_fill_opacity)
228
CSS_KEY(context-menu, context_menu)
229
CSS_KEY(context-menu, context_menu)
229
CSS_KEY(context-stroke, context_stroke)
230
CSS_KEY(context-stroke, context_stroke)
230
CSS_KEY(context-stroke-opacity, context_stroke_opacity)
231
CSS_KEY(context-stroke-opacity, context_stroke_opacity)
231
CSS_KEY(context-value, context_value)
232
CSS_KEY(context-value, context_value)
232
CSS_KEY(continuous, continuous)
233
CSS_KEY(continuous, continuous)
233
CSS_KEY(contrast, contrast)
234
CSS_KEY(contrast, contrast)
(-)mc.082761b7bc54/layout/style/nsCSSPropList.h (+10 lines)
Line     Link Here 
 Lines 1600-1615   CSS_PROP_DISPLAY( Link Here 
1600
        // pseudo-element an inline-block in the UA stylesheet. It is a block
1600
        // pseudo-element an inline-block in the UA stylesheet. It is a block
1601
        // by default.
1601
        // by default.
1602
        CSS_PROPERTY_APPLIES_TO_PLACEHOLDER,
1602
        CSS_PROPERTY_APPLIES_TO_PLACEHOLDER,
1603
    "",
1603
    "",
1604
    VARIANT_HK,
1604
    VARIANT_HK,
1605
    kDisplayKTable,
1605
    kDisplayKTable,
1606
    offsetof(nsStyleDisplay, mDisplay),
1606
    offsetof(nsStyleDisplay, mDisplay),
1607
    eStyleAnimType_EnumU8)
1607
    eStyleAnimType_EnumU8)
1608
CSS_PROP_DISPLAY(
1609
    display-box,
1610
    display_box,
1611
    DisplayBox,
1612
    CSS_PROPERTY_PARSE_VALUE,
1613
    "layout.css.display-box.enabled",
1614
    VARIANT_HK,
1615
    kDisplayBoxKTable,
1616
    offsetof(nsStyleDisplay, mDisplayBox),
1617
    eStyleAnimType_EnumU8)
1608
CSS_PROP_TABLEBORDER(
1618
CSS_PROP_TABLEBORDER(
1609
    empty-cells,
1619
    empty-cells,
1610
    empty_cells,
1620
    empty_cells,
1611
    EmptyCells,
1621
    EmptyCells,
1612
    CSS_PROPERTY_PARSE_VALUE,
1622
    CSS_PROPERTY_PARSE_VALUE,
1613
    "",
1623
    "",
1614
    VARIANT_HK,
1624
    VARIANT_HK,
1615
    kEmptyCellsKTable,
1625
    kEmptyCellsKTable,
(-)mc.082761b7bc54/layout/style/nsCSSProps.cpp (+7 lines)
Line     Link Here 
 Lines 798-813   const KTableValue nsCSSProps::kBorderSty Link Here 
798
798
799
const KTableValue nsCSSProps::kBorderWidthKTable[] = {
799
const KTableValue nsCSSProps::kBorderWidthKTable[] = {
800
  eCSSKeyword_thin, NS_STYLE_BORDER_WIDTH_THIN,
800
  eCSSKeyword_thin, NS_STYLE_BORDER_WIDTH_THIN,
801
  eCSSKeyword_medium, NS_STYLE_BORDER_WIDTH_MEDIUM,
801
  eCSSKeyword_medium, NS_STYLE_BORDER_WIDTH_MEDIUM,
802
  eCSSKeyword_thick, NS_STYLE_BORDER_WIDTH_THICK,
802
  eCSSKeyword_thick, NS_STYLE_BORDER_WIDTH_THICK,
803
  eCSSKeyword_UNKNOWN,-1
803
  eCSSKeyword_UNKNOWN,-1
804
};
804
};
805
805
806
const KTableValue nsCSSProps::kDisplayBoxKTable[] = {
807
  eCSSKeyword_normal,       NS_STYLE_DISPLAY_BOX_NORMAL,
808
  eCSSKeyword_none,         NS_STYLE_DISPLAY_BOX_NONE,
809
  eCSSKeyword_contents,     NS_STYLE_DISPLAY_BOX_CONTENTS,
810
  eCSSKeyword_UNKNOWN,-1
811
};
812
806
const KTableValue nsCSSProps::kBoxPropSourceKTable[] = {
813
const KTableValue nsCSSProps::kBoxPropSourceKTable[] = {
807
  eCSSKeyword_physical,     NS_BOXPROP_SOURCE_PHYSICAL,
814
  eCSSKeyword_physical,     NS_BOXPROP_SOURCE_PHYSICAL,
808
  eCSSKeyword_logical,      NS_BOXPROP_SOURCE_LOGICAL,
815
  eCSSKeyword_logical,      NS_BOXPROP_SOURCE_LOGICAL,
809
  eCSSKeyword_UNKNOWN,-1
816
  eCSSKeyword_UNKNOWN,-1
810
};
817
};
811
818
812
const KTableValue nsCSSProps::kBoxShadowTypeKTable[] = {
819
const KTableValue nsCSSProps::kBoxShadowTypeKTable[] = {
813
  eCSSKeyword_inset, NS_STYLE_BOX_SHADOW_INSET,
820
  eCSSKeyword_inset, NS_STYLE_BOX_SHADOW_INSET,
(-)mc.082761b7bc54/layout/style/nsCSSProps.h (+1 lines)
Line     Link Here 
 Lines 528-543   public: Link Here 
528
  static const KTableValue kStrokeLinecapKTable[];
528
  static const KTableValue kStrokeLinecapKTable[];
529
  static const KTableValue kStrokeLinejoinKTable[];
529
  static const KTableValue kStrokeLinejoinKTable[];
530
  static const KTableValue kStrokeContextValueKTable[];
530
  static const KTableValue kStrokeContextValueKTable[];
531
  static const KTableValue kVectorEffectKTable[];
531
  static const KTableValue kVectorEffectKTable[];
532
  static const KTableValue kTextAnchorKTable[];
532
  static const KTableValue kTextAnchorKTable[];
533
  static const KTableValue kTextRenderingKTable[];
533
  static const KTableValue kTextRenderingKTable[];
534
  static const KTableValue kColorInterpolationKTable[];
534
  static const KTableValue kColorInterpolationKTable[];
535
  static const KTableValue kColumnFillKTable[];
535
  static const KTableValue kColumnFillKTable[];
536
  static const KTableValue kDisplayBoxKTable[];
536
  static const KTableValue kBoxPropSourceKTable[];
537
  static const KTableValue kBoxPropSourceKTable[];
537
  static const KTableValue kBoxShadowTypeKTable[];
538
  static const KTableValue kBoxShadowTypeKTable[];
538
  static const KTableValue kBoxSizingKTable[];
539
  static const KTableValue kBoxSizingKTable[];
539
  static const KTableValue kCaptionSideKTable[];
540
  static const KTableValue kCaptionSideKTable[];
540
  static const KTableValue kClearKTable[];
541
  static const KTableValue kClearKTable[];
541
  static const KTableValue kColorKTable[];
542
  static const KTableValue kColorKTable[];
542
  static const KTableValue kContentKTable[];
543
  static const KTableValue kContentKTable[];
543
  static const KTableValue kControlCharacterVisibilityKTable[];
544
  static const KTableValue kControlCharacterVisibilityKTable[];
(-)mc.082761b7bc54/layout/style/nsRuleNode.cpp (+25 lines)
Line     Link Here 
 Lines 5151-5166   nsRuleNode::ComputeDisplayData(void* aSt Link Here 
5151
            SETFCT_OPACITY | SETFCT_UNSET_INITIAL);
5151
            SETFCT_OPACITY | SETFCT_UNSET_INITIAL);
5152
5152
5153
  // display: enum, inherit, initial
5153
  // display: enum, inherit, initial
5154
  SetDiscrete(*aRuleData->ValueForDisplay(), display->mDisplay, canStoreInRuleTree,
5154
  SetDiscrete(*aRuleData->ValueForDisplay(), display->mDisplay, canStoreInRuleTree,
5155
              SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
5155
              SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
5156
              parentDisplay->mDisplay,
5156
              parentDisplay->mDisplay,
5157
              NS_STYLE_DISPLAY_INLINE, 0, 0, 0, 0);
5157
              NS_STYLE_DISPLAY_INLINE, 0, 0, 0, 0);
5158
5158
5159
  // display-box: enum, inherit, initial
5160
  if (display->mDisplay == NS_STYLE_DISPLAY_NONE) {
5161
    // display:none implies display-box:none.
5162
    display->mDisplayBox = NS_STYLE_DISPLAY_BOX_NONE;
5163
    canStoreInRuleTree = false;
5164
  } else {
5165
    SetDiscrete(*aRuleData->ValueForDisplayBox(), display->mDisplayBox, canStoreInRuleTree,
5166
                SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL, parentDisplay->mDisplayBox,
5167
                NS_STYLE_DISPLAY_BOX_NORMAL, 0, 0, 0, 0);
5168
  }
5169
5159
  // mix-blend-mode: enum, inherit, initial
5170
  // mix-blend-mode: enum, inherit, initial
5160
  SetDiscrete(*aRuleData->ValueForMixBlendMode(), display->mMixBlendMode,
5171
  SetDiscrete(*aRuleData->ValueForMixBlendMode(), display->mMixBlendMode,
5161
              canStoreInRuleTree,
5172
              canStoreInRuleTree,
5162
              SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
5173
              SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
5163
              parentDisplay->mMixBlendMode, NS_STYLE_BLEND_NORMAL,
5174
              parentDisplay->mMixBlendMode, NS_STYLE_BLEND_NORMAL,
5164
              0, 0, 0, 0);
5175
              0, 0, 0, 0);
5165
5176
5166
  // Backup original display value for calculation of a hypothetical
5177
  // Backup original display value for calculation of a hypothetical
 Lines 5397-5412   nsRuleNode::ComputeDisplayData(void* aSt Link Here 
5397
    NS_ABORT_IF_FALSE(false, "unrecognized clip unit");
5408
    NS_ABORT_IF_FALSE(false, "unrecognized clip unit");
5398
  }
5409
  }
5399
5410
5400
  if (display->mDisplay != NS_STYLE_DISPLAY_NONE) {
5411
  if (display->mDisplay != NS_STYLE_DISPLAY_NONE) {
5401
    // CSS2 9.7 specifies display type corrections dealing with 'float'
5412
    // CSS2 9.7 specifies display type corrections dealing with 'float'
5402
    // and 'position'.  Since generated content can't be floated or
5413
    // and 'position'.  Since generated content can't be floated or
5403
    // positioned, we can deal with it here.
5414
    // positioned, we can deal with it here.
5404
5415
5416
    if (display->mDisplayBox == NS_STYLE_DISPLAY_BOX_CONTENTS && aContext->GetPseudo()) {
5417
      // We don't want to create frames for anonymous content using a parent
5418
      // frame that is for content above the root of the anon tree.
5419
      // (XXX what we realy should check here is not GetPseudo() but if there's
5420
      //  a 'content' property value that implies anon content but we can't
5421
      //  check that here since that's a different struct(?))
5422
      // We might get display-box:contents to work for CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS
5423
      // pseudos (:first-letter etc) in the future, but those have a lot of
5424
      // special handling in frame construction so they are also unsupported
5425
      // for now.
5426
      display->mDisplayBox = NS_STYLE_DISPLAY_BOX_NORMAL;
5427
      canStoreInRuleTree = false;
5428
    }
5429
5405
    if (nsCSSPseudoElements::firstLetter == aContext->GetPseudo()) {
5430
    if (nsCSSPseudoElements::firstLetter == aContext->GetPseudo()) {
5406
      // a non-floating first-letter must be inline
5431
      // a non-floating first-letter must be inline
5407
      // XXX this fix can go away once bug 103189 is fixed correctly
5432
      // XXX this fix can go away once bug 103189 is fixed correctly
5408
      // Note that we reset mOriginalDisplay to enforce the invariant that it equals mDisplay if we're not positioned or floating.
5433
      // Note that we reset mOriginalDisplay to enforce the invariant that it equals mDisplay if we're not positioned or floating.
5409
      display->mOriginalDisplay = display->mDisplay = NS_STYLE_DISPLAY_INLINE;
5434
      display->mOriginalDisplay = display->mDisplay = NS_STYLE_DISPLAY_INLINE;
5410
5435
5411
      // We can't cache the data in the rule tree since if a more specific
5436
      // We can't cache the data in the rule tree since if a more specific
5412
      // rule has 'float: left' we'll end up with the wrong 'display'
5437
      // rule has 'float: left' we'll end up with the wrong 'display'
(-)mc.082761b7bc54/layout/style/nsStyleConsts.h (+5 lines)
Line     Link Here 
 Lines 407-422   static inline mozilla::css::Side operato Link Here 
407
#define NS_STYLE_DISPLAY_POPUP                  27
407
#define NS_STYLE_DISPLAY_POPUP                  27
408
#define NS_STYLE_DISPLAY_GROUPBOX               28
408
#define NS_STYLE_DISPLAY_GROUPBOX               28
409
#endif
409
#endif
410
#define NS_STYLE_DISPLAY_FLEX                   29
410
#define NS_STYLE_DISPLAY_FLEX                   29
411
#define NS_STYLE_DISPLAY_INLINE_FLEX            30
411
#define NS_STYLE_DISPLAY_INLINE_FLEX            30
412
#define NS_STYLE_DISPLAY_GRID                   31
412
#define NS_STYLE_DISPLAY_GRID                   31
413
#define NS_STYLE_DISPLAY_INLINE_GRID            32
413
#define NS_STYLE_DISPLAY_INLINE_GRID            32
414
414
415
// See nsStyleDisplay
416
#define NS_STYLE_DISPLAY_BOX_NORMAL             0
417
#define NS_STYLE_DISPLAY_BOX_NONE               1
418
#define NS_STYLE_DISPLAY_BOX_CONTENTS           2
419
415
// See nsStylePosition
420
// See nsStylePosition
416
#define NS_STYLE_ALIGN_CONTENT_FLEX_START       0
421
#define NS_STYLE_ALIGN_CONTENT_FLEX_START       0
417
#define NS_STYLE_ALIGN_CONTENT_FLEX_END         1
422
#define NS_STYLE_ALIGN_CONTENT_FLEX_END         1
418
#define NS_STYLE_ALIGN_CONTENT_CENTER           2
423
#define NS_STYLE_ALIGN_CONTENT_CENTER           2
419
#define NS_STYLE_ALIGN_CONTENT_SPACE_BETWEEN    3
424
#define NS_STYLE_ALIGN_CONTENT_SPACE_BETWEEN    3
420
#define NS_STYLE_ALIGN_CONTENT_SPACE_AROUND     4
425
#define NS_STYLE_ALIGN_CONTENT_SPACE_AROUND     4
421
#define NS_STYLE_ALIGN_CONTENT_STRETCH          5
426
#define NS_STYLE_ALIGN_CONTENT_STRETCH          5
422
427
(-)mc.082761b7bc54/layout/style/nsStyleContext.cpp (-5 / +18 lines)
Line     Link Here 
 Lines 355-375   nsStyleContext::ApplyStyleFixups(bool aS Link Here 
355
  }
355
  }
356
356
357
  // Adjust the "display" values of flex and grid items (but not for raw text,
357
  // Adjust the "display" values of flex and grid items (but not for raw text,
358
  // placeholders, or table-parts). CSS3 Flexbox section 4 says:
358
  // placeholders, or table-parts). CSS3 Flexbox section 4 says:
359
  //   # The computed 'display' of a flex item is determined
359
  //   # The computed 'display' of a flex item is determined
360
  //   # by applying the table in CSS 2.1 Chapter 9.7.
360
  //   # by applying the table in CSS 2.1 Chapter 9.7.
361
  // ...which converts inline-level elements to their block-level equivalents.
361
  // ...which converts inline-level elements to their block-level equivalents.
362
  if (!aSkipFlexItemStyleFixup && mParent) {
362
  if (!aSkipFlexItemStyleFixup && mParent) {
363
    const nsStyleDisplay* parentDisp = mParent->StyleDisplay();
363
    // Skip display-box:contents ancestors to reach the potential flex container.
364
    if ((parentDisp->mDisplay == NS_STYLE_DISPLAY_FLEX ||
364
    // (If there are only display-box:contents ancestors between this node and
365
         parentDisp->mDisplay == NS_STYLE_DISPLAY_INLINE_FLEX ||
365
    // a flex container ancestor, then this node is a flex item, since its
366
         parentDisp->mDisplay == NS_STYLE_DISPLAY_GRID ||
366
    // parent *in the frame tree* will be the flex container. So we treat
367
         parentDisp->mDisplay == NS_STYLE_DISPLAY_INLINE_GRID) &&
367
    // it like a flex item here.)
368
    nsStyleContext* containerContext = mParent;
369
    const nsStyleDisplay* containerDisp = containerContext->StyleDisplay();
370
    while (containerDisp->mDisplayBox == NS_STYLE_DISPLAY_BOX_CONTENTS) {
371
      if (!containerContext->GetParent()) {
372
        break;
373
      }
374
      containerContext = containerContext->GetParent();
375
      containerDisp = containerContext->StyleDisplay();
376
    }
377
    if ((containerDisp->mDisplay == NS_STYLE_DISPLAY_FLEX ||
378
         containerDisp->mDisplay == NS_STYLE_DISPLAY_INLINE_FLEX ||
379
         containerDisp->mDisplay == NS_STYLE_DISPLAY_GRID ||
380
         containerDisp->mDisplay == NS_STYLE_DISPLAY_INLINE_GRID) &&
368
        GetPseudo() != nsCSSAnonBoxes::mozNonElement) {
381
        GetPseudo() != nsCSSAnonBoxes::mozNonElement) {
369
      uint8_t displayVal = disp->mDisplay;
382
      uint8_t displayVal = disp->mDisplay;
370
      // Skip table parts.
383
      // Skip table parts.
371
      // NOTE: This list needs to be kept in sync with
384
      // NOTE: This list needs to be kept in sync with
372
      // nsCSSFrameConstructor.cpp's "sDisplayData" array -- specifically,
385
      // nsCSSFrameConstructor.cpp's "sDisplayData" array -- specifically,
373
      // this should be the list of display-values that have
386
      // this should be the list of display-values that have
374
      // FCDATA_DESIRED_PARENT_TYPE_TO_BITS specified in that array.
387
      // FCDATA_DESIRED_PARENT_TYPE_TO_BITS specified in that array.
375
      if (NS_STYLE_DISPLAY_TABLE_CAPTION      != displayVal &&
388
      if (NS_STYLE_DISPLAY_TABLE_CAPTION      != displayVal &&
(-)mc.082761b7bc54/layout/style/nsStyleSet.cpp (-1 / +1 lines)
Line     Link Here 
 Lines 1464-1480   nsStyleSet::ProbePseudoElementStyle(Elem Link Here 
1464
  // 'content' property is equivalent to not having the pseudo-element
1464
  // 'content' property is equivalent to not having the pseudo-element
1465
  // at all.
1465
  // at all.
1466
  if (result &&
1466
  if (result &&
1467
      (pseudoTag == nsCSSPseudoElements::before ||
1467
      (pseudoTag == nsCSSPseudoElements::before ||
1468
       pseudoTag == nsCSSPseudoElements::after)) {
1468
       pseudoTag == nsCSSPseudoElements::after)) {
1469
    const nsStyleDisplay *display = result->StyleDisplay();
1469
    const nsStyleDisplay *display = result->StyleDisplay();
1470
    const nsStyleContent *content = result->StyleContent();
1470
    const nsStyleContent *content = result->StyleContent();
1471
    // XXXldb What is contentCount for |content: ""|?
1471
    // XXXldb What is contentCount for |content: ""|?
1472
    if (display->mDisplay == NS_STYLE_DISPLAY_NONE ||
1472
    if (display->mDisplayBox == NS_STYLE_DISPLAY_BOX_NONE ||
1473
        content->ContentCount() == 0) {
1473
        content->ContentCount() == 0) {
1474
      result = nullptr;
1474
      result = nullptr;
1475
    }
1475
    }
1476
  }
1476
  }
1477
1477
1478
  return result.forget();
1478
  return result.forget();
1479
}
1479
}
1480
1480
(-)mc.082761b7bc54/layout/style/nsStyleStruct.cpp (-4 / +7 lines)
Line     Link Here 
 Lines 2335-2350   nsAnimation::SetInitialValues() Link Here 
2335
  mIterationCount = 1.0f;
2335
  mIterationCount = 1.0f;
2336
}
2336
}
2337
2337
2338
nsStyleDisplay::nsStyleDisplay()
2338
nsStyleDisplay::nsStyleDisplay()
2339
  : mWillChangeBitField(0)
2339
  : mWillChangeBitField(0)
2340
{
2340
{
2341
  MOZ_COUNT_CTOR(nsStyleDisplay);
2341
  MOZ_COUNT_CTOR(nsStyleDisplay);
2342
  mAppearance = NS_THEME_NONE;
2342
  mAppearance = NS_THEME_NONE;
2343
  mDisplayBox = NS_STYLE_DISPLAY_BOX_NORMAL;
2343
  mDisplay = NS_STYLE_DISPLAY_INLINE;
2344
  mDisplay = NS_STYLE_DISPLAY_INLINE;
2344
  mOriginalDisplay = mDisplay;
2345
  mOriginalDisplay = mDisplay;
2345
  mPosition = NS_STYLE_POSITION_STATIC;
2346
  mPosition = NS_STYLE_POSITION_STATIC;
2346
  mFloats = NS_STYLE_FLOAT_NONE;
2347
  mFloats = NS_STYLE_FLOAT_NONE;
2347
  mOriginalFloats = mFloats;
2348
  mOriginalFloats = mFloats;
2348
  mBreakType = NS_STYLE_CLEAR_NONE;
2349
  mBreakType = NS_STYLE_CLEAR_NONE;
2349
  mBreakInside = NS_STYLE_PAGE_BREAK_AUTO;
2350
  mBreakInside = NS_STYLE_PAGE_BREAK_AUTO;
2350
  mBreakBefore = false;
2351
  mBreakBefore = false;
 Lines 2391-2406   nsStyleDisplay::nsStyleDisplay() Link Here 
2391
  mAnimationPlayStateCount = 1;
2392
  mAnimationPlayStateCount = 1;
2392
  mAnimationIterationCountCount = 1;
2393
  mAnimationIterationCountCount = 1;
2393
}
2394
}
2394
2395
2395
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
2396
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
2396
  : mBinding(aSource.mBinding)
2397
  : mBinding(aSource.mBinding)
2397
  , mClip(aSource.mClip)
2398
  , mClip(aSource.mClip)
2398
  , mOpacity(aSource.mOpacity)
2399
  , mOpacity(aSource.mOpacity)
2400
  , mDisplayBox(aSource.mDisplayBox)
2399
  , mDisplay(aSource.mDisplay)
2401
  , mDisplay(aSource.mDisplay)
2400
  , mOriginalDisplay(aSource.mOriginalDisplay)
2402
  , mOriginalDisplay(aSource.mOriginalDisplay)
2401
  , mAppearance(aSource.mAppearance)
2403
  , mAppearance(aSource.mAppearance)
2402
  , mPosition(aSource.mPosition)
2404
  , mPosition(aSource.mPosition)
2403
  , mFloats(aSource.mFloats)
2405
  , mFloats(aSource.mFloats)
2404
  , mOriginalFloats(aSource.mOriginalFloats)
2406
  , mOriginalFloats(aSource.mOriginalFloats)
2405
  , mBreakType(aSource.mBreakType)
2407
  , mBreakType(aSource.mBreakType)
2406
  , mBreakInside(aSource.mBreakInside)
2408
  , mBreakInside(aSource.mBreakInside)
 Lines 2442-2468   nsStyleDisplay::nsStyleDisplay(const nsS Link Here 
2442
  mTransformOrigin[1] = aSource.mTransformOrigin[1];
2444
  mTransformOrigin[1] = aSource.mTransformOrigin[1];
2443
  mTransformOrigin[2] = aSource.mTransformOrigin[2];
2445
  mTransformOrigin[2] = aSource.mTransformOrigin[2];
2444
  mPerspectiveOrigin[0] = aSource.mPerspectiveOrigin[0];
2446
  mPerspectiveOrigin[0] = aSource.mPerspectiveOrigin[0];
2445
  mPerspectiveOrigin[1] = aSource.mPerspectiveOrigin[1];
2447
  mPerspectiveOrigin[1] = aSource.mPerspectiveOrigin[1];
2446
}
2448
}
2447
2449
2448
nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
2450
nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
2449
{
2451
{
2450
  nsChangeHint hint = nsChangeHint(0);
2451
2452
  if (!EqualURIs(mBinding, aOther.mBinding)
2452
  if (!EqualURIs(mBinding, aOther.mBinding)
2453
      || mPosition != aOther.mPosition
2453
      || mPosition != aOther.mPosition
2454
      || mDisplay != aOther.mDisplay
2454
      || mDisplay != aOther.mDisplay
2455
      || (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
2455
      || (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
2456
      || mOverflowX != aOther.mOverflowX
2456
      || mOverflowX != aOther.mOverflowX
2457
      || mOverflowY != aOther.mOverflowY
2457
      || mOverflowY != aOther.mOverflowY
2458
      || mResize != aOther.mResize)
2458
      || mResize != aOther.mResize
2459
    NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
2459
      || mDisplayBox != aOther.mDisplayBox) {
2460
    return nsChangeHint_ReconstructFrame;
2461
  }
2460
2462
2463
  nsChangeHint hint = nsChangeHint(0);
2461
  if ((mAppearance == NS_THEME_TEXTFIELD &&
2464
  if ((mAppearance == NS_THEME_TEXTFIELD &&
2462
       aOther.mAppearance != NS_THEME_TEXTFIELD) ||
2465
       aOther.mAppearance != NS_THEME_TEXTFIELD) ||
2463
      (mAppearance != NS_THEME_TEXTFIELD &&
2466
      (mAppearance != NS_THEME_TEXTFIELD &&
2464
       aOther.mAppearance == NS_THEME_TEXTFIELD)) {
2467
       aOther.mAppearance == NS_THEME_TEXTFIELD)) {
2465
    // This is for <input type=number> where we allow authors to specify a
2468
    // This is for <input type=number> where we allow authors to specify a
2466
    // |-moz-appearance:textfield| to get a control without a spinner. (The
2469
    // |-moz-appearance:textfield| to get a control without a spinner. (The
2467
    // spinner is present for |-moz-appearance:number-input| but also other
2470
    // spinner is present for |-moz-appearance:number-input| but also other
2468
    // values such as 'none'.) We need to reframe since we want to use
2471
    // values such as 'none'.) We need to reframe since we want to use
(-)mc.082761b7bc54/layout/style/nsStyleStruct.h (+1 lines)
Line     Link Here 
 Lines 1886-1901   struct nsStyleDisplay { Link Here 
1886
    return nsChangeHint(0);
1886
    return nsChangeHint(0);
1887
  }
1887
  }
1888
1888
1889
  // We guarantee that if mBinding is non-null, so are mBinding->GetURI() and
1889
  // We guarantee that if mBinding is non-null, so are mBinding->GetURI() and
1890
  // mBinding->mOriginPrincipal.
1890
  // mBinding->mOriginPrincipal.
1891
  nsRefPtr<mozilla::css::URLValue> mBinding;    // [reset]
1891
  nsRefPtr<mozilla::css::URLValue> mBinding;    // [reset]
1892
  nsRect  mClip;                // [reset] offsets from upper-left border edge
1892
  nsRect  mClip;                // [reset] offsets from upper-left border edge
1893
  float   mOpacity;             // [reset]
1893
  float   mOpacity;             // [reset]
1894
  uint8_t mDisplayBox;          // [reset] NS_STYLE_DISPLAY_BOX_NORMAL/NONE/CONTENTS
1894
  uint8_t mDisplay;             // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
1895
  uint8_t mDisplay;             // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
1895
  uint8_t mOriginalDisplay;     // [reset] saved mDisplay for position:absolute/fixed
1896
  uint8_t mOriginalDisplay;     // [reset] saved mDisplay for position:absolute/fixed
1896
                                //         and float:left/right; otherwise equal
1897
                                //         and float:left/right; otherwise equal
1897
                                //         to mDisplay
1898
                                //         to mDisplay
1898
  uint8_t mAppearance;          // [reset]
1899
  uint8_t mAppearance;          // [reset]
1899
  uint8_t mPosition;            // [reset] see nsStyleConsts.h
1900
  uint8_t mPosition;            // [reset] see nsStyleConsts.h
1900
  uint8_t mFloats;              // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
1901
  uint8_t mFloats;              // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
1901
  uint8_t mOriginalFloats;      // [reset] saved mFloats for position:absolute/fixed;
1902
  uint8_t mOriginalFloats;      // [reset] saved mFloats for position:absolute/fixed;
(-)mc.082761b7bc54/layout/style/nsStyleStructInlines.h (-2 / +1 lines)
Line     Link Here 
 Lines 97-114   nsStyleDisplay::IsOriginalDisplayInlineO Link Here 
97
  }
97
  }
98
  return IsOriginalDisplayInlineOutsideStyle();
98
  return IsOriginalDisplayInlineOutsideStyle();
99
}
99
}
100
100
101
uint8_t
101
uint8_t
102
nsStyleDisplay::GetDisplay(const nsIFrame* aContextFrame) const
102
nsStyleDisplay::GetDisplay(const nsIFrame* aContextFrame) const
103
{
103
{
104
  NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
104
  NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
105
  if (aContextFrame->IsSVGText() &&
105
  if (aContextFrame->IsSVGText() && mDisplayBox != NS_STYLE_DISPLAY_BOX_NONE) {
106
      mDisplay != NS_STYLE_DISPLAY_NONE) {
107
    return aContextFrame->GetType() == nsGkAtoms::blockFrame ?
106
    return aContextFrame->GetType() == nsGkAtoms::blockFrame ?
108
             NS_STYLE_DISPLAY_BLOCK :
107
             NS_STYLE_DISPLAY_BLOCK :
109
             NS_STYLE_DISPLAY_INLINE;
108
             NS_STYLE_DISPLAY_INLINE;
110
  }
109
  }
111
  return mDisplay;
110
  return mDisplay;
112
}
111
}
113
112
114
bool
113
bool
(-)mc.082761b7bc54/layout/style/test/property_database.js (+11 lines)
Line     Link Here 
 Lines 5168-5183   if (SpecialPowers.getBoolPref("layout.cs Link Here 
5168
		inherited: false,
5168
		inherited: false,
5169
		type: CSS_TYPE_LONGHAND,
5169
		type: CSS_TYPE_LONGHAND,
5170
		initial_values: [ "padding-box" ],
5170
		initial_values: [ "padding-box" ],
5171
		other_values: [ "content-box" ],
5171
		other_values: [ "content-box" ],
5172
		invalid_values: [ "none", "auto", "border-box", "0" ]
5172
		invalid_values: [ "none", "auto", "border-box", "0" ]
5173
	};
5173
	};
5174
}
5174
}
5175
5175
5176
if (SpecialPowers.getBoolPref("layout.css.display-box.enabled")) {
5177
	gCSSProperties["display-box"] = {
5178
		domProp: "displayBox",
5179
		inherited: false,
5180
		type: CSS_TYPE_LONGHAND,
5181
		initial_values: [ "normal" ],
5182
		other_values: [ "none", "contents" ],
5183
		invalid_values: [ "auto", "0" ]
5184
	};
5185
}
5186
5176
if (SpecialPowers.getBoolPref("layout.css.unset-value.enabled")) {
5187
if (SpecialPowers.getBoolPref("layout.css.unset-value.enabled")) {
5177
  gCSSProperties["animation-direction"].invalid_values.push("normal, unset");
5188
  gCSSProperties["animation-direction"].invalid_values.push("normal, unset");
5178
  gCSSProperties["animation-name"].invalid_values.push("bounce, unset", "unset, bounce");
5189
  gCSSProperties["animation-name"].invalid_values.push("bounce, unset", "unset, bounce");
5179
  gCSSProperties["-moz-border-bottom-colors"].invalid_values.push("red unset", "unset red");
5190
  gCSSProperties["-moz-border-bottom-colors"].invalid_values.push("red unset", "unset red");
5180
  gCSSProperties["-moz-border-left-colors"].invalid_values.push("red unset", "unset red");
5191
  gCSSProperties["-moz-border-left-colors"].invalid_values.push("red unset", "unset red");
5181
  gCSSProperties["border-radius"].invalid_values.push("unset 2px", "unset / 2px", "2px unset", "2px / unset");
5192
  gCSSProperties["border-radius"].invalid_values.push("unset 2px", "unset / 2px", "2px unset", "2px / unset");
5182
  gCSSProperties["border-bottom-left-radius"].invalid_values.push("unset 2px", "2px unset");
5193
  gCSSProperties["border-bottom-left-radius"].invalid_values.push("unset 2px", "2px unset");
5183
  gCSSProperties["border-bottom-right-radius"].invalid_values.push("unset 2px", "2px unset");
5194
  gCSSProperties["border-bottom-right-radius"].invalid_values.push("unset 2px", "2px unset");
(-)mc.082761b7bc54/layout/tables/nsTableColGroupFrame.cpp (-3 / +3 lines)
Line     Link Here 
 Lines 298-316   nsTableColGroupFrame::RemoveFrame(ChildL Link Here 
298
    nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame;
298
    nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame;
299
    if (colFrame->GetColType() == eColContent) {
299
    if (colFrame->GetColType() == eColContent) {
300
      contentRemoval = true;
300
      contentRemoval = true;
301
      // Remove any anonymous column frames this <col> produced via a colspan
301
      // Remove any anonymous column frames this <col> produced via a colspan
302
      nsTableColFrame* col = colFrame->GetNextCol();
302
      nsTableColFrame* col = colFrame->GetNextCol();
303
      nsTableColFrame* nextCol;
303
      nsTableColFrame* nextCol;
304
      while (col && col->GetColType() == eColAnonymousCol) {
304
      while (col && col->GetColType() == eColAnonymousCol) {
305
#ifdef DEBUG
305
#ifdef DEBUG
306
        nsIFrame* providerFrame = colFrame->GetParentStyleContextFrame();
306
        nsIFrame* providerFrame;
307
        if (colFrame->StyleContext()->GetParent() ==
307
        nsStyleContext* psc = colFrame->GetParentStyleContext(&providerFrame);
308
            providerFrame->StyleContext()) {
308
        if (colFrame->StyleContext()->GetParent() == psc) {
309
          NS_ASSERTION(col->StyleContext() == colFrame->StyleContext() &&
309
          NS_ASSERTION(col->StyleContext() == colFrame->StyleContext() &&
310
                       col->GetContent() == colFrame->GetContent(),
310
                       col->GetContent() == colFrame->GetContent(),
311
                       "How did that happen??");
311
                       "How did that happen??");
312
        }
312
        }
313
        // else colFrame is being removed because of a frame
313
        // else colFrame is being removed because of a frame
314
        // reconstruct on it, and its style context is still the old
314
        // reconstruct on it, and its style context is still the old
315
        // one, so we can't assert anything about how it compares to
315
        // one, so we can't assert anything about how it compares to
316
        // col's style context.
316
        // col's style context.
(-)mc.082761b7bc54/layout/tables/nsTableFrame.cpp (-3 / +4 lines)
Line     Link Here 
 Lines 127-155   struct BCPropertyData Link Here 
127
  BCPixelSize mTopBorderWidth;
127
  BCPixelSize mTopBorderWidth;
128
  BCPixelSize mRightBorderWidth;
128
  BCPixelSize mRightBorderWidth;
129
  BCPixelSize mBottomBorderWidth;
129
  BCPixelSize mBottomBorderWidth;
130
  BCPixelSize mLeftBorderWidth;
130
  BCPixelSize mLeftBorderWidth;
131
  BCPixelSize mLeftCellBorderWidth;
131
  BCPixelSize mLeftCellBorderWidth;
132
  BCPixelSize mRightCellBorderWidth;
132
  BCPixelSize mRightCellBorderWidth;
133
};
133
};
134
134
135
nsIFrame*
135
nsStyleContext*
136
nsTableFrame::GetParentStyleContextFrame() const
136
nsTableFrame::GetParentStyleContext(nsIFrame** aProviderFrame) const
137
{
137
{
138
  // Since our parent, the table outer frame, returned this frame, we
138
  // Since our parent, the table outer frame, returned this frame, we
139
  // must return whatever our parent would normally have returned.
139
  // must return whatever our parent would normally have returned.
140
140
141
  NS_PRECONDITION(mParent, "table constructed without outer table");
141
  NS_PRECONDITION(mParent, "table constructed without outer table");
142
  if (!mContent->GetParent() && !StyleContext()->GetPseudo()) {
142
  if (!mContent->GetParent() && !StyleContext()->GetPseudo()) {
143
    // We're the root.  We have no style context parent.
143
    // We're the root.  We have no style context parent.
144
    *aProviderFrame = nullptr;
144
    return nullptr;
145
    return nullptr;
145
  }
146
  }
146
147
147
  return static_cast<nsFrame*>(GetParent())->DoGetParentStyleContextFrame();
148
  return static_cast<nsFrame*>(GetParent())->DoGetParentStyleContext(aProviderFrame);
148
}
149
}
149
150
150
151
151
nsIAtom*
152
nsIAtom*
152
nsTableFrame::GetType() const
153
nsTableFrame::GetType() const
153
{
154
{
154
  return nsGkAtoms::tableFrame;
155
  return nsGkAtoms::tableFrame;
155
}
156
}
(-)mc.082761b7bc54/layout/tables/nsTableFrame.h (-1 / +1 lines)
Line     Link Here 
 Lines 346-362   public: Link Here 
346
  nsresult ReflowTable(nsHTMLReflowMetrics&     aDesiredSize,
346
  nsresult ReflowTable(nsHTMLReflowMetrics&     aDesiredSize,
347
                       const nsHTMLReflowState& aReflowState,
347
                       const nsHTMLReflowState& aReflowState,
348
                       nscoord                  aAvailHeight,
348
                       nscoord                  aAvailHeight,
349
                       nsIFrame*&               aLastChildReflowed,
349
                       nsIFrame*&               aLastChildReflowed,
350
                       nsReflowStatus&          aStatus);
350
                       nsReflowStatus&          aStatus);
351
351
352
  nsFrameList& GetColGroups();
352
  nsFrameList& GetColGroups();
353
353
354
  virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
354
  virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const MOZ_OVERRIDE;
355
355
356
  /**
356
  /**
357
   * Get the "type" of the frame
357
   * Get the "type" of the frame
358
   *
358
   *
359
   * @see nsGkAtoms::tableFrame
359
   * @see nsGkAtoms::tableFrame
360
   */
360
   */
361
  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
361
  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
362
362
(-)mc.082761b7bc54/layout/tables/nsTableOuterFrame.cpp (-9 / +19 lines)
Line     Link Here 
 Lines 1-13    Link Here 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
5
#include "nsTableOuterFrame.h"
6
#include "nsTableOuterFrame.h"
7
8
#include "nsFrameManager.h"
6
#include "nsTableFrame.h"
9
#include "nsTableFrame.h"
7
#include "nsTableCellFrame.h"
10
#include "nsTableCellFrame.h"
8
#include "nsStyleContext.h"
11
#include "nsStyleContext.h"
9
#include "nsStyleConsts.h"
12
#include "nsStyleConsts.h"
10
#include "nsPresContext.h"
13
#include "nsPresContext.h"
11
#include "nsCSSRendering.h"
14
#include "nsCSSRendering.h"
12
#include "nsIContent.h"
15
#include "nsIContent.h"
13
#include "prinrval.h"
16
#include "prinrval.h"
 Lines 86-120   nsTableCaptionFrame::ComputeAutoSize(nsR Link Here 
86
    if (min > aCBSize.width)
89
    if (min > aCBSize.width)
87
      min = aCBSize.width;
90
      min = aCBSize.width;
88
    if (min > result.width)
91
    if (min > result.width)
89
      result.width = min;
92
      result.width = min;
90
  }
93
  }
91
  return result;
94
  return result;
92
}
95
}
93
96
94
nsIFrame*
97
nsStyleContext*
95
nsTableCaptionFrame::GetParentStyleContextFrame() const
98
nsTableCaptionFrame::GetParentStyleContext(nsIFrame** aProviderFrame) const
96
{
99
{
97
  NS_PRECONDITION(mContent->GetParent(),
100
  MOZ_ASSERT(GetContent()->GetParent(), "How could we not have a parent here?");
98
                  "How could we not have a parent here?");
101
    
102
  nsStyleContext* sc =
103
    PresContext()->FrameManager()->GetDisplayBoxContentsStyleFor(GetContent()->GetParent());
104
  if (sc) {
105
    *aProviderFrame = nullptr;
106
    return sc;
107
  }
99
    
108
    
100
  // The caption's style context parent is the inner frame, unless
109
  // The caption's style context parent is the inner frame, unless
101
  // it's anonymous.
110
  // it's anonymous.
102
  nsIFrame* outerFrame = GetParent();
111
  nsIFrame* outerFrame = GetParent();
103
  if (outerFrame && outerFrame->GetType() == nsGkAtoms::tableOuterFrame) {
112
  if (outerFrame && outerFrame->GetType() == nsGkAtoms::tableOuterFrame) {
104
    nsIFrame* innerFrame = outerFrame->GetFirstPrincipalChild();
113
    nsIFrame* innerFrame = outerFrame->GetFirstPrincipalChild();
105
    if (innerFrame) {
114
    if (innerFrame) {
106
      return nsFrame::CorrectStyleParentFrame(innerFrame,
115
      *aProviderFrame = nsFrame::CorrectStyleParentFrame(innerFrame,
107
                                              StyleContext()->GetPseudo());
116
                                              StyleContext()->GetPseudo());
117
      return *aProviderFrame ? (*aProviderFrame)->StyleContext() : nullptr;
108
    }
118
    }
109
  }
119
  }
110
120
111
  NS_NOTREACHED("Where is our inner table frame?");
121
  NS_NOTREACHED("Where is our inner table frame?");
112
  return nsBlockFrame::GetParentStyleContextFrame();
122
  return nsBlockFrame::GetParentStyleContext(aProviderFrame);
113
}
123
}
114
124
115
#ifdef ACCESSIBILITY
125
#ifdef ACCESSIBILITY
116
a11y::AccType
126
a11y::AccType
117
nsTableCaptionFrame::AccessibleType()
127
nsTableCaptionFrame::AccessibleType()
118
{
128
{
119
  if (!GetRect().IsEmpty()) {
129
  if (!GetRect().IsEmpty()) {
120
    return a11y::eHTMLCaptionType;
130
    return a11y::eHTMLCaptionType;
 Lines 325-354   nsTableOuterFrame::BuildDisplayListForIn Link Here 
325
  nsIFrame* kid = mFrames.FirstChild();
335
  nsIFrame* kid = mFrames.FirstChild();
326
  // The children should be in content order
336
  // The children should be in content order
327
  while (kid) {
337
  while (kid) {
328
    BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
338
    BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
329
    kid = kid->GetNextSibling();
339
    kid = kid->GetNextSibling();
330
  }
340
  }
331
}
341
}
332
342
333
nsIFrame*
343
nsStyleContext*
334
nsTableOuterFrame::GetParentStyleContextFrame() const
344
nsTableOuterFrame::GetParentStyleContext(nsIFrame** aProviderFrame) const
335
{
345
{
336
  // The table outer frame and the (inner) table frame split the style
346
  // The table outer frame and the (inner) table frame split the style
337
  // data by giving the table frame the style context associated with
347
  // data by giving the table frame the style context associated with
338
  // the table content node and creating a style context for the outer
348
  // the table content node and creating a style context for the outer
339
  // frame that is a *child* of the table frame's style context,
349
  // frame that is a *child* of the table frame's style context,
340
  // matching the ::-moz-table-outer pseudo-element.  html.css has a
350
  // matching the ::-moz-table-outer pseudo-element.  html.css has a
341
  // rule that causes that pseudo-element (and thus the outer table)
351
  // rule that causes that pseudo-element (and thus the outer table)
342
  // to inherit *some* style properties from the table frame.  The
352
  // to inherit *some* style properties from the table frame.  The
343
  // children of the table inherit directly from the inner table, and
353
  // children of the table inherit directly from the inner table, and
344
  // the outer table's style context is a leaf.
354
  // the outer table's style context is a leaf.
345
355
346
  return InnerTableFrame();
356
  return (*aProviderFrame = InnerTableFrame())->StyleContext();
347
}
357
}
348
358
349
// INCREMENTAL REFLOW HELPER FUNCTIONS 
359
// INCREMENTAL REFLOW HELPER FUNCTIONS 
350
360
351
void
361
void
352
nsTableOuterFrame::InitChildReflowState(nsPresContext&    aPresContext,                     
362
nsTableOuterFrame::InitChildReflowState(nsPresContext&    aPresContext,                     
353
                                        nsHTMLReflowState& aReflowState)
363
                                        nsHTMLReflowState& aReflowState)
354
                                    
364
                                    
(-)mc.082761b7bc54/layout/tables/nsTableOuterFrame.h (-2 / +2 lines)
Line     Link Here 
 Lines 21-37   public: Link Here 
21
  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
21
  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
22
  friend nsIFrame* NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext*  aContext);
22
  friend nsIFrame* NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext*  aContext);
23
23
24
  virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
24
  virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
25
                                 nsSize aCBSize, nscoord aAvailableWidth,
25
                                 nsSize aCBSize, nscoord aAvailableWidth,
26
                                 nsSize aMargin, nsSize aBorder,
26
                                 nsSize aMargin, nsSize aBorder,
27
                                 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
27
                                 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
28
28
29
  virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
29
  virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const MOZ_OVERRIDE;
30
30
31
#ifdef ACCESSIBILITY
31
#ifdef ACCESSIBILITY
32
  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
32
  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
33
#endif
33
#endif
34
34
35
#ifdef DEBUG_FRAME_DUMP
35
#ifdef DEBUG_FRAME_DUMP
36
  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
36
  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
37
#endif
37
#endif
 Lines 125-141   public: Link Here 
125
   * @see nsGkAtoms::tableOuterFrame
125
   * @see nsGkAtoms::tableOuterFrame
126
   */
126
   */
127
  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
127
  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
128
128
129
#ifdef DEBUG_FRAME_DUMP
129
#ifdef DEBUG_FRAME_DUMP
130
  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
130
  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
131
#endif
131
#endif
132
132
133
  virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE;
133
  virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const MOZ_OVERRIDE;
134
134
135
  /**
135
  /**
136
   * Return the content for the cell at the given row and column.
136
   * Return the content for the cell at the given row and column.
137
   */
137
   */
138
  nsIContent* GetCellAt(uint32_t aRowIdx, uint32_t aColIdx) const;
138
  nsIContent* GetCellAt(uint32_t aRowIdx, uint32_t aColIdx) const;
139
139
140
  /**
140
  /**
141
   * Return the number of rows in the table.
141
   * Return the number of rows in the table.
(-)mc.082761b7bc54/modules/libpref/src/init/all.js (+3 lines)
Line     Link Here 
 Lines 1786-1801   pref("layout.css.masking.enabled", true) Link Here 
1786
pref("layout.css.mix-blend-mode.enabled", false);
1786
pref("layout.css.mix-blend-mode.enabled", false);
1787
1787
1788
// Is support for the the @supports rule enabled?
1788
// Is support for the the @supports rule enabled?
1789
pref("layout.css.supports-rule.enabled", true);
1789
pref("layout.css.supports-rule.enabled", true);
1790
1790
1791
// Is support for CSS Filters enabled?
1791
// Is support for CSS Filters enabled?
1792
pref("layout.css.filters.enabled", false);
1792
pref("layout.css.filters.enabled", false);
1793
1793
1794
// Is support for the CSS display-box property enabled?
1795
pref("layout.css.display-box.enabled", false);
1796
1794
// Is support for CSS sticky positioning enabled?
1797
// Is support for CSS sticky positioning enabled?
1795
#ifdef RELEASE_BUILD
1798
#ifdef RELEASE_BUILD
1796
pref("layout.css.sticky.enabled", false);
1799
pref("layout.css.sticky.enabled", false);
1797
#else
1800
#else
1798
pref("layout.css.sticky.enabled", true);
1801
pref("layout.css.sticky.enabled", true);
1799
#endif
1802
#endif
1800
1803
1801
// Is support for CSS "will-change" enabled?
1804
// Is support for CSS "will-change" enabled?

Return to bug 907396