2013-07-20 19:14:24 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Code responsible for managing style changes: tracking what style
|
|
|
|
* changes need to happen, scheduling them, and doing them.
|
|
|
|
*/
|
|
|
|
|
2014-11-17 04:46:00 +00:00
|
|
|
#include <algorithm> // For std::max
|
2013-07-20 19:14:24 +00:00
|
|
|
#include "RestyleManager.h"
|
2014-04-03 04:18:36 +00:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2014-11-17 04:46:00 +00:00
|
|
|
#include "AnimationCommon.h" // For GetLayerAnimationInfo
|
2014-11-17 04:46:00 +00:00
|
|
|
#include "FrameLayerBuilder.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
#include "nsStyleChangeList.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsRuleProcessorData.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsStyleUtil.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
|
|
|
#include "nsSVGEffects.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsAnimationManager.h"
|
|
|
|
#include "nsTransitionManager.h"
|
|
|
|
#include "nsViewManager.h"
|
|
|
|
#include "nsRenderingContext.h"
|
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsPlaceholderFrame.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsBlockFrame.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsViewportFrame.h"
|
2013-12-20 16:38:51 +00:00
|
|
|
#include "SVGTextFrame.h"
|
2013-09-06 13:35:16 +00:00
|
|
|
#include "StickyScrollContainer.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsIRootBox.h"
|
|
|
|
#include "nsIDOMMutationEvent.h"
|
2013-08-14 06:55:46 +00:00
|
|
|
#include "nsContentUtils.h"
|
2013-10-01 21:00:38 +00:00
|
|
|
#include "nsIFrameInlines.h"
|
2013-09-04 11:30:57 +00:00
|
|
|
#include "ActiveLayerTracker.h"
|
2014-03-05 04:13:22 +00:00
|
|
|
#include "nsDisplayList.h"
|
2014-09-25 05:45:36 +00:00
|
|
|
#include "RestyleTrackerInlines.h"
|
2015-02-16 22:15:02 +00:00
|
|
|
#include "nsSMILAnimationController.h"
|
2013-07-20 19:14:24 +00:00
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2013-07-20 19:14:24 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
2014-03-05 05:05:18 +00:00
|
|
|
using namespace layers;
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#define LOG_RESTYLE_CONTINUE(reason_, ...) \
|
|
|
|
LOG_RESTYLE("continuing restyle since " reason_, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
static nsCString
|
|
|
|
FrameTagToString(const nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsCString result;
|
|
|
|
aFrame->ListTag(result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-20 19:14:24 +00:00
|
|
|
RestyleManager::RestyleManager(nsPresContext* aPresContext)
|
|
|
|
: mPresContext(aPresContext)
|
2015-01-14 05:03:11 +00:00
|
|
|
, mDoRebuildAllStyleData(false)
|
2015-01-14 05:03:12 +00:00
|
|
|
, mInRebuildAllStyleData(false)
|
2013-07-20 19:14:25 +00:00
|
|
|
, mObservingRefreshDriver(false)
|
|
|
|
, mInStyleRefresh(false)
|
2014-10-03 04:53:23 +00:00
|
|
|
, mSkipAnimationRules(false)
|
2015-02-16 22:15:02 +00:00
|
|
|
, mHavePendingNonAnimationRestyles(false)
|
2013-07-20 19:14:25 +00:00
|
|
|
, mHoverGeneration(0)
|
|
|
|
, mRebuildAllExtraHint(nsChangeHint(0))
|
2014-10-08 21:26:57 +00:00
|
|
|
, mRebuildAllRestyleHint(nsRestyleHint(0))
|
2014-07-25 04:35:34 +00:00
|
|
|
, mLastUpdateForThrottledAnimations(aPresContext->RefreshDriver()->
|
|
|
|
MostRecentRefresh())
|
2013-07-20 19:14:25 +00:00
|
|
|
, mAnimationGeneration(0)
|
2014-08-13 22:39:01 +00:00
|
|
|
, mReframingStyleContexts(nullptr)
|
2013-07-20 19:14:25 +00:00
|
|
|
, mPendingRestyles(ELEMENT_HAS_PENDING_RESTYLE |
|
|
|
|
ELEMENT_IS_POTENTIAL_RESTYLE_ROOT)
|
2014-10-03 04:53:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mIsProcessingRestyles(false)
|
|
|
|
#endif
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
, mLoggingDepth(0)
|
|
|
|
#endif
|
2013-07-20 19:14:24 +00:00
|
|
|
{
|
2013-07-20 19:14:25 +00:00
|
|
|
mPendingRestyles.Init(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::NotifyDestroyingFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
mOverflowChangedTracker.RemoveFrame(aFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// To ensure that the functions below are only called within
|
|
|
|
// |ApplyRenderingChangeToTree|.
|
|
|
|
static bool gInApplyRenderingChangeToTree = false;
|
|
|
|
#endif
|
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
static inline nsIFrame*
|
|
|
|
GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aFrame->GetPrevContinuation(),
|
|
|
|
"must start with the first continuation");
|
|
|
|
// Might we have ib-split siblings?
|
|
|
|
if (!(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) {
|
|
|
|
// nothing more to do here
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return static_cast<nsIFrame*>
|
|
|
|
(aPropTable->Get(aFrame, nsIFrame::IBSplitSibling()));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsIFrame*
|
|
|
|
GetNearestAncestorFrame(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
nsIFrame* ancestorFrame = nullptr;
|
|
|
|
for (nsIContent* ancestor = aContent->GetParent();
|
|
|
|
ancestor && !ancestorFrame;
|
|
|
|
ancestor = ancestor->GetParent()) {
|
|
|
|
ancestorFrame = ancestor->GetPrimaryFrame();
|
|
|
|
}
|
|
|
|
return ancestorFrame;
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
static void
|
|
|
|
DoApplyRenderingChangeToTree(nsIFrame* aFrame,
|
|
|
|
nsChangeHint aChange);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sync views on aFrame and all of aFrame's descendants (following placeholders),
|
|
|
|
* if aChange has nsChangeHint_SyncFrameView.
|
|
|
|
* Calls DoApplyRenderingChangeToTree on all aFrame's out-of-flow descendants
|
|
|
|
* (following placeholders), if aChange has nsChangeHint_RepaintFrame.
|
2014-07-16 11:28:50 +00:00
|
|
|
* aFrame should be some combination of nsChangeHint_SyncFrameView,
|
|
|
|
* nsChangeHint_RepaintFrame, nsChangeHint_UpdateOpacityLayer and
|
|
|
|
* nsChangeHint_SchedulePaint, nothing else.
|
2013-07-20 19:14:25 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
SyncViewsAndInvalidateDescendants(nsIFrame* aFrame,
|
|
|
|
nsChangeHint aChange)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(gInApplyRenderingChangeToTree,
|
|
|
|
"should only be called within ApplyRenderingChangeToTree");
|
|
|
|
NS_ASSERTION(aChange == (aChange & (nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_SyncFrameView |
|
2014-07-16 11:28:50 +00:00
|
|
|
nsChangeHint_UpdateOpacityLayer |
|
|
|
|
nsChangeHint_SchedulePaint)),
|
2013-07-20 19:14:25 +00:00
|
|
|
"Invalid change flag");
|
|
|
|
|
|
|
|
nsView* view = aFrame->GetView();
|
|
|
|
if (view) {
|
|
|
|
if (aChange & nsChangeHint_SyncFrameView) {
|
|
|
|
nsContainerFrame::SyncFrameViewProperties(aFrame->PresContext(),
|
|
|
|
aFrame, nullptr, view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
// only do frames that don't have placeholders
|
|
|
|
if (nsGkAtoms::placeholderFrame == child->GetType()) {
|
|
|
|
// do the out-of-flow frame and its continuations
|
|
|
|
nsIFrame* outOfFlowFrame =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
|
2013-07-20 19:14:25 +00:00
|
|
|
DoApplyRenderingChangeToTree(outOfFlowFrame, aChange);
|
2013-07-20 19:14:25 +00:00
|
|
|
} else if (lists.CurrentID() == nsIFrame::kPopupList) {
|
2013-07-20 19:14:25 +00:00
|
|
|
DoApplyRenderingChangeToTree(child, aChange);
|
2013-07-20 19:14:25 +00:00
|
|
|
} else { // regular frame
|
2013-07-20 19:14:25 +00:00
|
|
|
SyncViewsAndInvalidateDescendants(child, aChange);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To handle nsChangeHint_ChildrenOnlyTransform we must iterate over the child
|
|
|
|
* frames of the SVG frame concerned. This helper function is used to find that
|
|
|
|
* SVG frame when we encounter nsChangeHint_ChildrenOnlyTransform to ensure
|
|
|
|
* that we iterate over the intended children, since sometimes we end up
|
|
|
|
* handling that hint while processing hints for one of the SVG frame's
|
|
|
|
* ancestor frames.
|
|
|
|
*
|
|
|
|
* The reason that we sometimes end up trying to process the hint for an
|
|
|
|
* ancestor of the SVG frame that the hint is intended for is due to the way we
|
|
|
|
* process restyle events. ApplyRenderingChangeToTree adjusts the frame from
|
|
|
|
* the restyled element's principle frame to one of its ancestor frames based
|
|
|
|
* on what nsCSSRendering::FindBackground returns, since the background style
|
|
|
|
* may have been propagated up to an ancestor frame. Processing hints using an
|
|
|
|
* ancestor frame is fine in general, but nsChangeHint_ChildrenOnlyTransform is
|
|
|
|
* a special case since it is intended to update the children of a specific
|
|
|
|
* frame.
|
|
|
|
*/
|
|
|
|
static nsIFrame*
|
|
|
|
GetFrameForChildrenOnlyTransformHint(nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
if (aFrame->GetType() == nsGkAtoms::viewportFrame) {
|
|
|
|
// This happens if the root-<svg> is fixed positioned, in which case we
|
|
|
|
// can't use aFrame->GetContent() to find the primary frame, since
|
|
|
|
// GetContent() returns nullptr for ViewportFrame.
|
|
|
|
aFrame = aFrame->GetFirstPrincipalChild();
|
|
|
|
}
|
|
|
|
// For an nsHTMLScrollFrame, this will get the SVG frame that has the
|
|
|
|
// children-only transforms:
|
|
|
|
aFrame = aFrame->GetContent()->GetPrimaryFrame();
|
|
|
|
if (aFrame->GetType() == nsGkAtoms::svgOuterSVGFrame) {
|
|
|
|
aFrame = aFrame->GetFirstPrincipalChild();
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aFrame->GetType() == nsGkAtoms::svgOuterSVGAnonChildFrame,
|
|
|
|
"Where is the nsSVGOuterSVGFrame's anon child??");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aFrame->IsFrameOfType(nsIFrame::eSVG |
|
|
|
|
nsIFrame::eSVGContainer),
|
|
|
|
"Children-only transforms only expected on SVG frames");
|
2013-07-20 19:14:25 +00:00
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DoApplyRenderingChangeToTree(nsIFrame* aFrame,
|
|
|
|
nsChangeHint aChange)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(gInApplyRenderingChangeToTree,
|
|
|
|
"should only be called within ApplyRenderingChangeToTree");
|
|
|
|
|
2014-02-07 01:45:31 +00:00
|
|
|
for ( ; aFrame; aFrame = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(aFrame)) {
|
2013-07-20 19:14:25 +00:00
|
|
|
// Invalidate and sync views on all descendant frames, following placeholders.
|
|
|
|
// We don't need to update transforms in SyncViewsAndInvalidateDescendants, because
|
|
|
|
// there can't be any out-of-flows or popups that need to be transformed;
|
|
|
|
// all out-of-flow descendants of the transformed element must also be
|
|
|
|
// descendants of the transformed frame.
|
2013-07-20 19:14:25 +00:00
|
|
|
SyncViewsAndInvalidateDescendants(aFrame,
|
2013-07-20 19:14:25 +00:00
|
|
|
nsChangeHint(aChange & (nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_SyncFrameView |
|
2014-07-16 11:28:50 +00:00
|
|
|
nsChangeHint_UpdateOpacityLayer |
|
|
|
|
nsChangeHint_SchedulePaint)));
|
2013-07-20 19:14:25 +00:00
|
|
|
// This must be set to true if the rendering change needs to
|
|
|
|
// invalidate content. If it's false, a composite-only paint
|
|
|
|
// (empty transaction) will be scheduled.
|
|
|
|
bool needInvalidatingPaint = false;
|
|
|
|
|
|
|
|
// if frame has view, will already be invalidated
|
|
|
|
if (aChange & nsChangeHint_RepaintFrame) {
|
|
|
|
// Note that this whole block will be skipped when painting is suppressed
|
|
|
|
// (due to our caller ApplyRendingChangeToTree() discarding the
|
|
|
|
// nsChangeHint_RepaintFrame hint). If you add handling for any other
|
|
|
|
// hints within this block, be sure that they too should be ignored when
|
|
|
|
// painting is suppressed.
|
|
|
|
needInvalidatingPaint = true;
|
|
|
|
aFrame->InvalidateFrameSubtree();
|
2015-05-13 14:38:04 +00:00
|
|
|
if ((aChange & nsChangeHint_UpdateEffects) &&
|
2013-07-20 19:14:25 +00:00
|
|
|
aFrame->IsFrameOfType(nsIFrame::eSVG) &&
|
|
|
|
!(aFrame->GetStateBits() & NS_STATE_IS_OUTER_SVG)) {
|
|
|
|
// Need to update our overflow rects:
|
|
|
|
nsSVGUtils::ScheduleReflowSVG(aFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aChange & nsChangeHint_UpdateTextPath) {
|
2013-11-18 14:29:51 +00:00
|
|
|
if (aFrame->IsSVGText()) {
|
2013-12-20 16:38:51 +00:00
|
|
|
// Invalidate and reflow the entire SVGTextFrame:
|
2015-03-03 11:08:59 +00:00
|
|
|
NS_ASSERTION(aFrame->GetContent()->IsSVGElement(nsGkAtoms::textPath),
|
2013-07-20 19:14:25 +00:00
|
|
|
"expected frame for a <textPath> element");
|
|
|
|
nsIFrame* text = nsLayoutUtils::GetClosestFrameOfType(
|
|
|
|
aFrame,
|
2013-12-20 16:38:51 +00:00
|
|
|
nsGkAtoms::svgTextFrame);
|
|
|
|
NS_ASSERTION(text, "expected to find an ancestor SVGTextFrame");
|
|
|
|
static_cast<SVGTextFrame*>(text)->NotifyGlyphMetricsChange();
|
2013-07-20 19:14:25 +00:00
|
|
|
} else {
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(false, "unexpected frame got nsChangeHint_UpdateTextPath");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aChange & nsChangeHint_UpdateOpacityLayer) {
|
|
|
|
// FIXME/bug 796697: we can get away with empty transactions for
|
|
|
|
// opacity updates in many cases.
|
|
|
|
needInvalidatingPaint = true;
|
2013-09-04 11:30:57 +00:00
|
|
|
|
|
|
|
ActiveLayerTracker::NotifyRestyle(aFrame, eCSSProperty_opacity);
|
2013-07-20 19:14:25 +00:00
|
|
|
if (nsSVGIntegrationUtils::UsingEffectsForFrame(aFrame)) {
|
|
|
|
// SVG effects paints the opacity without using
|
|
|
|
// nsDisplayOpacity. We need to invalidate manually.
|
|
|
|
aFrame->InvalidateFrameSubtree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((aChange & nsChangeHint_UpdateTransformLayer) &&
|
|
|
|
aFrame->IsTransformed()) {
|
2013-09-04 11:30:57 +00:00
|
|
|
ActiveLayerTracker::NotifyRestyle(aFrame, eCSSProperty_transform);
|
2013-07-20 19:14:25 +00:00
|
|
|
// If we're not already going to do an invalidating paint, see
|
|
|
|
// if we can get away with only updating the transform on a
|
|
|
|
// layer for this frame, and not scheduling an invalidating
|
|
|
|
// paint.
|
|
|
|
if (!needInvalidatingPaint) {
|
2014-03-05 04:13:22 +00:00
|
|
|
Layer* layer;
|
|
|
|
needInvalidatingPaint |= !aFrame->TryUpdateTransformOnly(&layer);
|
|
|
|
|
|
|
|
if (!needInvalidatingPaint) {
|
|
|
|
// Since we're not going to paint, we need to resend animation
|
|
|
|
// data to the layer.
|
|
|
|
MOZ_ASSERT(layer, "this can't happen if there's no layer");
|
|
|
|
nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(layer,
|
|
|
|
nullptr, nullptr, aFrame, eCSSProperty_transform);
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aChange & nsChangeHint_ChildrenOnlyTransform) {
|
|
|
|
needInvalidatingPaint = true;
|
|
|
|
nsIFrame* childFrame =
|
|
|
|
GetFrameForChildrenOnlyTransformHint(aFrame)->GetFirstPrincipalChild();
|
|
|
|
for ( ; childFrame; childFrame = childFrame->GetNextSibling()) {
|
2013-09-04 11:30:57 +00:00
|
|
|
ActiveLayerTracker::NotifyRestyle(childFrame, eCSSProperty_transform);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-16 11:28:50 +00:00
|
|
|
if (aChange & nsChangeHint_SchedulePaint) {
|
|
|
|
needInvalidatingPaint = true;
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
aFrame->SchedulePaint(needInvalidatingPaint ?
|
|
|
|
nsIFrame::PAINT_DEFAULT :
|
|
|
|
nsIFrame::PAINT_COMPOSITE_ONLY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ApplyRenderingChangeToTree(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsChangeHint aChange)
|
|
|
|
{
|
2015-03-20 04:12:17 +00:00
|
|
|
// We check StyleDisplay()->HasTransformStyle() in addition to checking
|
2013-07-20 19:14:25 +00:00
|
|
|
// IsTransformed() since we can get here for some frames that don't support
|
|
|
|
// CSS transforms.
|
|
|
|
NS_ASSERTION(!(aChange & nsChangeHint_UpdateTransformLayer) ||
|
|
|
|
aFrame->IsTransformed() ||
|
2015-03-20 04:12:17 +00:00
|
|
|
aFrame->StyleDisplay()->HasTransformStyle(),
|
2013-07-20 19:14:25 +00:00
|
|
|
"Unexpected UpdateTransformLayer hint");
|
|
|
|
|
|
|
|
nsIPresShell *shell = aPresContext->PresShell();
|
|
|
|
if (shell->IsPaintingSuppressed()) {
|
|
|
|
// Don't allow synchronous rendering changes when painting is turned off.
|
|
|
|
aChange = NS_SubtractHint(aChange, nsChangeHint_RepaintFrame);
|
|
|
|
if (!aChange) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trigger rendering updates by damaging this frame and any
|
|
|
|
// continuations of this frame.
|
|
|
|
#ifdef DEBUG
|
|
|
|
gInApplyRenderingChangeToTree = true;
|
|
|
|
#endif
|
2014-07-21 13:57:52 +00:00
|
|
|
if (aChange & nsChangeHint_RepaintFrame) {
|
|
|
|
// If the frame's background is propagated to an ancestor, walk up to
|
|
|
|
// that ancestor and apply the RepaintFrame change hint to it.
|
|
|
|
nsStyleContext *bgSC;
|
|
|
|
nsIFrame* propagatedFrame = aFrame;
|
|
|
|
while (!nsCSSRendering::FindBackground(propagatedFrame, &bgSC)) {
|
|
|
|
propagatedFrame = propagatedFrame->GetParent();
|
|
|
|
NS_ASSERTION(aFrame, "root frame must paint");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (propagatedFrame != aFrame) {
|
|
|
|
DoApplyRenderingChangeToTree(propagatedFrame, nsChangeHint_RepaintFrame);
|
|
|
|
aChange = NS_SubtractHint(aChange, nsChangeHint_RepaintFrame);
|
|
|
|
if (!aChange) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
DoApplyRenderingChangeToTree(aFrame, aChange);
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
gInApplyRenderingChangeToTree = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
bool
|
|
|
|
RestyleManager::RecomputePosition(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
// Don't process position changes on table frames, since we already handle
|
|
|
|
// the dynamic position change on the outer table frame, and the reflow-based
|
|
|
|
// fallback code path also ignores positions on inner table frames.
|
|
|
|
if (aFrame->GetType() == nsGkAtoms::tableFrame) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-03 08:54:39 +00:00
|
|
|
const nsStyleDisplay* display = aFrame->StyleDisplay();
|
|
|
|
// Changes to the offsets of a non-positioned element can safely be ignored.
|
|
|
|
if (display->mPosition == NS_STYLE_POSITION_STATIC) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// Don't process position changes on frames which have views or the ones which
|
|
|
|
// have a view somewhere in their descendants, because the corresponding view
|
|
|
|
// needs to be repositioned properly as well.
|
|
|
|
if (aFrame->HasView() ||
|
|
|
|
(aFrame->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)) {
|
|
|
|
StyleChangeReflow(aFrame, nsChangeHint_NeedReflow);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aFrame->SchedulePaint();
|
|
|
|
|
|
|
|
// For relative positioning, we can simply update the frame rect
|
2013-09-06 13:35:16 +00:00
|
|
|
if (display->IsRelativelyPositionedStyle()) {
|
2013-07-20 19:14:25 +00:00
|
|
|
// Move the frame
|
2013-09-06 13:35:16 +00:00
|
|
|
if (display->mPosition == NS_STYLE_POSITION_STICKY) {
|
2014-08-20 01:24:58 +00:00
|
|
|
if (display->IsInnerTableStyle()) {
|
|
|
|
// We don't currently support sticky positioning of inner table
|
|
|
|
// elements (bug 975644). Bail.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-25 22:29:56 +00:00
|
|
|
// Update sticky positioning for an entire element at once, starting with
|
|
|
|
// the first continuation or ib-split sibling.
|
|
|
|
// It's rare that the frame we already have isn't already the first
|
|
|
|
// continuation or ib-split sibling, but it can happen when styles differ
|
|
|
|
// across continuations such as ::first-line or ::first-letter, and in
|
|
|
|
// those cases we will generally (but maybe not always) do the work twice.
|
|
|
|
nsIFrame *firstContinuation =
|
|
|
|
nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame);
|
|
|
|
|
|
|
|
StickyScrollContainer::ComputeStickyOffsets(firstContinuation);
|
2013-09-25 19:28:08 +00:00
|
|
|
StickyScrollContainer* ssc =
|
2014-04-25 22:29:56 +00:00
|
|
|
StickyScrollContainer::GetStickyScrollContainerForFrame(firstContinuation);
|
2013-09-25 19:28:08 +00:00
|
|
|
if (ssc) {
|
2014-04-25 22:29:56 +00:00
|
|
|
ssc->PositionContinuations(firstContinuation);
|
2013-09-13 23:53:48 +00:00
|
|
|
}
|
2013-09-06 13:35:16 +00:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(NS_STYLE_POSITION_RELATIVE == display->mPosition,
|
|
|
|
"Unexpected type of positioning");
|
2013-09-25 19:28:08 +00:00
|
|
|
for (nsIFrame *cont = aFrame; cont;
|
2014-02-07 01:45:31 +00:00
|
|
|
cont = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
|
2013-09-25 19:28:08 +00:00
|
|
|
nsIFrame* cb = cont->GetContainingBlock();
|
|
|
|
nsMargin newOffsets;
|
|
|
|
const nsSize size = cb->GetContentRectRelativeToSelf().Size();
|
|
|
|
|
|
|
|
nsHTMLReflowState::ComputeRelativeOffsets(
|
|
|
|
cb->StyleVisibility()->mDirection,
|
|
|
|
cont, size.width, size.height, newOffsets);
|
|
|
|
NS_ASSERTION(newOffsets.left == -newOffsets.right &&
|
|
|
|
newOffsets.top == -newOffsets.bottom,
|
|
|
|
"ComputeRelativeOffsets should return valid results");
|
|
|
|
|
|
|
|
// nsHTMLReflowState::ApplyRelativePositioning would work here, but
|
|
|
|
// since we've already checked mPosition and aren't changing the frame's
|
|
|
|
// normal position, go ahead and add the offsets directly.
|
|
|
|
cont->SetPosition(cont->GetNormalPosition() +
|
2013-09-13 23:53:48 +00:00
|
|
|
nsPoint(newOffsets.left, newOffsets.top));
|
2013-09-25 19:28:08 +00:00
|
|
|
}
|
2013-09-13 23:53:48 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-10 00:08:41 +00:00
|
|
|
// For the absolute positioning case, set up a fake HTML reflow state for
|
|
|
|
// the frame, and then get the offsets and size from it. If the frame's size
|
|
|
|
// doesn't need to change, we can simply update the frame position. Otherwise
|
|
|
|
// we fall back to a reflow.
|
2014-10-31 20:08:49 +00:00
|
|
|
nsRenderingContext rc(
|
|
|
|
aFrame->PresContext()->PresShell()->CreateReferenceRenderingContext());
|
2013-09-10 00:08:41 +00:00
|
|
|
|
|
|
|
// Construct a bogus parent reflow state so that there's a usable
|
|
|
|
// containing block reflow state.
|
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
2014-07-24 08:28:46 +00:00
|
|
|
WritingMode parentWM = parentFrame->GetWritingMode();
|
|
|
|
WritingMode frameWM = aFrame->GetWritingMode();
|
|
|
|
LogicalSize parentSize = parentFrame->GetLogicalSize();
|
2013-09-10 00:08:41 +00:00
|
|
|
|
|
|
|
nsFrameState savedState = parentFrame->GetStateBits();
|
|
|
|
nsHTMLReflowState parentReflowState(aFrame->PresContext(), parentFrame,
|
2014-10-31 20:08:49 +00:00
|
|
|
&rc, parentSize);
|
2013-09-10 00:08:41 +00:00
|
|
|
parentFrame->RemoveStateBits(~nsFrameState(0));
|
|
|
|
parentFrame->AddStateBits(savedState);
|
|
|
|
|
2014-07-24 08:28:46 +00:00
|
|
|
NS_WARN_IF_FALSE(parentSize.ISize(parentWM) != NS_INTRINSICSIZE &&
|
|
|
|
parentSize.BSize(parentWM) != NS_INTRINSICSIZE,
|
2013-09-10 00:08:41 +00:00
|
|
|
"parentSize should be valid");
|
2014-07-24 08:28:46 +00:00
|
|
|
parentReflowState.SetComputedISize(std::max(parentSize.ISize(parentWM), 0));
|
|
|
|
parentReflowState.SetComputedBSize(std::max(parentSize.BSize(parentWM), 0));
|
2013-12-27 17:59:21 +00:00
|
|
|
parentReflowState.ComputedPhysicalMargin().SizeTo(0, 0, 0, 0);
|
2013-09-10 00:08:41 +00:00
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
parentReflowState.ComputedPhysicalPadding() = parentFrame->GetUsedPadding();
|
|
|
|
parentReflowState.ComputedPhysicalBorderPadding() =
|
2013-09-10 00:08:41 +00:00
|
|
|
parentFrame->GetUsedBorderAndPadding();
|
2014-07-24 08:28:46 +00:00
|
|
|
LogicalSize availSize = parentSize.ConvertTo(frameWM, parentWM);
|
|
|
|
availSize.BSize(frameWM) = NS_INTRINSICSIZE;
|
2013-09-10 00:08:41 +00:00
|
|
|
|
|
|
|
ViewportFrame* viewport = do_QueryFrame(parentFrame);
|
|
|
|
nsSize cbSize = viewport ?
|
|
|
|
viewport->AdjustReflowStateAsContainingBlock(&parentReflowState).Size()
|
|
|
|
: aFrame->GetContainingBlock()->GetSize();
|
|
|
|
const nsMargin& parentBorder =
|
|
|
|
parentReflowState.mStyleBorder->GetComputedBorder();
|
|
|
|
cbSize -= nsSize(parentBorder.LeftRight(), parentBorder.TopBottom());
|
|
|
|
nsHTMLReflowState reflowState(aFrame->PresContext(), parentReflowState,
|
2014-07-24 08:28:46 +00:00
|
|
|
aFrame, availSize,
|
|
|
|
cbSize.width, cbSize.height);
|
2013-09-10 00:08:41 +00:00
|
|
|
nsSize computedSize(reflowState.ComputedWidth(), reflowState.ComputedHeight());
|
2013-12-27 17:59:21 +00:00
|
|
|
computedSize.width += reflowState.ComputedPhysicalBorderPadding().LeftRight();
|
2013-09-10 00:08:41 +00:00
|
|
|
if (computedSize.height != NS_INTRINSICSIZE) {
|
2013-12-27 17:59:21 +00:00
|
|
|
computedSize.height += reflowState.ComputedPhysicalBorderPadding().TopBottom();
|
2013-09-10 00:08:41 +00:00
|
|
|
}
|
|
|
|
nsSize size = aFrame->GetSize();
|
|
|
|
// The RecomputePosition hint is not used if any offset changed between auto
|
|
|
|
// and non-auto. If computedSize.height == NS_INTRINSICSIZE then the new
|
|
|
|
// element height will be its intrinsic height, and since 'top' and 'bottom''s
|
|
|
|
// auto-ness hasn't changed, the old height must also be its intrinsic
|
|
|
|
// height, which we can assume hasn't changed (or reflow would have
|
|
|
|
// been triggered).
|
|
|
|
if (computedSize.width == size.width &&
|
|
|
|
(computedSize.height == NS_INTRINSICSIZE || computedSize.height == size.height)) {
|
2013-07-20 19:14:25 +00:00
|
|
|
// If we're solving for 'left' or 'top', then compute it here, in order to
|
|
|
|
// match the reflow code path.
|
2013-12-27 17:59:21 +00:00
|
|
|
if (NS_AUTOOFFSET == reflowState.ComputedPhysicalOffsets().left) {
|
|
|
|
reflowState.ComputedPhysicalOffsets().left = cbSize.width -
|
|
|
|
reflowState.ComputedPhysicalOffsets().right -
|
|
|
|
reflowState.ComputedPhysicalMargin().right -
|
2013-07-20 19:14:25 +00:00
|
|
|
size.width -
|
2013-12-27 17:59:21 +00:00
|
|
|
reflowState.ComputedPhysicalMargin().left;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
if (NS_AUTOOFFSET == reflowState.ComputedPhysicalOffsets().top) {
|
|
|
|
reflowState.ComputedPhysicalOffsets().top = cbSize.height -
|
|
|
|
reflowState.ComputedPhysicalOffsets().bottom -
|
|
|
|
reflowState.ComputedPhysicalMargin().bottom -
|
2013-07-20 19:14:25 +00:00
|
|
|
size.height -
|
2013-12-27 17:59:21 +00:00
|
|
|
reflowState.ComputedPhysicalMargin().top;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Move the frame
|
2013-12-27 17:59:21 +00:00
|
|
|
nsPoint pos(parentBorder.left + reflowState.ComputedPhysicalOffsets().left +
|
|
|
|
reflowState.ComputedPhysicalMargin().left,
|
|
|
|
parentBorder.top + reflowState.ComputedPhysicalOffsets().top +
|
|
|
|
reflowState.ComputedPhysicalMargin().top);
|
2013-07-20 19:14:25 +00:00
|
|
|
aFrame->SetPosition(pos);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fall back to a reflow
|
|
|
|
StyleChangeReflow(aFrame, nsChangeHint_NeedReflow);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:53 +00:00
|
|
|
void
|
2013-07-20 19:14:25 +00:00
|
|
|
RestyleManager::StyleChangeReflow(nsIFrame* aFrame, nsChangeHint aHint)
|
|
|
|
{
|
|
|
|
nsIPresShell::IntrinsicDirty dirtyType;
|
|
|
|
if (aHint & nsChangeHint_ClearDescendantIntrinsics) {
|
|
|
|
NS_ASSERTION(aHint & nsChangeHint_ClearAncestorIntrinsics,
|
|
|
|
"Please read the comments in nsChangeHint.h");
|
|
|
|
dirtyType = nsIPresShell::eStyleChange;
|
|
|
|
} else if (aHint & nsChangeHint_ClearAncestorIntrinsics) {
|
|
|
|
dirtyType = nsIPresShell::eTreeChange;
|
|
|
|
} else {
|
|
|
|
dirtyType = nsIPresShell::eResize;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameState dirtyBits;
|
2014-09-17 00:40:11 +00:00
|
|
|
if (aFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
dirtyBits = nsFrameState(0);
|
|
|
|
} else if (aHint & nsChangeHint_NeedDirtyReflow) {
|
2013-07-20 19:14:25 +00:00
|
|
|
dirtyBits = NS_FRAME_IS_DIRTY;
|
|
|
|
} else {
|
|
|
|
dirtyBits = NS_FRAME_HAS_DIRTY_CHILDREN;
|
|
|
|
}
|
|
|
|
|
2014-09-17 00:40:11 +00:00
|
|
|
// If we're not going to clear any intrinsic sizes on the frames, and
|
|
|
|
// there are no dirty bits to set, then there's nothing to do.
|
|
|
|
if (dirtyType == nsIPresShell::eResize && !dirtyBits)
|
|
|
|
return;
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
do {
|
|
|
|
mPresContext->PresShell()->FrameNeedsReflow(aFrame, dirtyType, dirtyBits);
|
2014-02-07 01:45:31 +00:00
|
|
|
aFrame = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(aFrame);
|
2013-07-20 19:14:25 +00:00
|
|
|
} while (aFrame);
|
|
|
|
}
|
|
|
|
|
2014-06-17 14:32:00 +00:00
|
|
|
void
|
|
|
|
RestyleManager::AddSubtreeToOverflowTracker(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
mOverflowChangedTracker.AddFrame(
|
|
|
|
aFrame,
|
2015-02-16 03:34:29 +00:00
|
|
|
OverflowChangedTracker::CHILDREN_CHANGED);
|
2014-06-17 14:32:00 +00:00
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
|
|
|
AddSubtreeToOverflowTracker(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(ChangeListProperty, nullptr)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if aFrame's subtree has placeholders for out-of-flow content
|
|
|
|
* whose 'position' style's bit in aPositionMask is set.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
FrameHasPositionedPlaceholderDescendants(nsIFrame* aFrame, uint32_t aPositionMask)
|
|
|
|
{
|
|
|
|
const nsIFrame::ChildListIDs skip(nsIFrame::kAbsoluteList |
|
|
|
|
nsIFrame::kFixedList);
|
|
|
|
for (nsIFrame::ChildListIterator lists(aFrame); !lists.IsDone(); lists.Next()) {
|
|
|
|
if (!skip.Contains(lists.CurrentID())) {
|
|
|
|
for (nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
!childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* f = childFrames.get();
|
|
|
|
if (f->GetType() == nsGkAtoms::placeholderFrame) {
|
|
|
|
nsIFrame* outOfFlow = nsPlaceholderFrame::GetRealFrameForPlaceholder(f);
|
|
|
|
// If SVG text frames could appear here, they could confuse us since
|
|
|
|
// they ignore their position style ... but they can't.
|
|
|
|
NS_ASSERTION(!outOfFlow->IsSVGText(),
|
|
|
|
"SVG text frames can't be out of flow");
|
|
|
|
if (aPositionMask & (1 << outOfFlow->StyleDisplay()->mPosition)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (FrameHasPositionedPlaceholderDescendants(f, aPositionMask)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
NeedToReframeForAddingOrRemovingTransform(nsIFrame* aFrame)
|
|
|
|
{
|
2013-07-18 17:59:53 +00:00
|
|
|
static_assert(0 <= NS_STYLE_POSITION_ABSOLUTE &&
|
|
|
|
NS_STYLE_POSITION_ABSOLUTE < 32, "Style constant out of range");
|
|
|
|
static_assert(0 <= NS_STYLE_POSITION_FIXED &&
|
|
|
|
NS_STYLE_POSITION_FIXED < 32, "Style constant out of range");
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
uint32_t positionMask;
|
|
|
|
// Don't call aFrame->IsPositioned here, since that returns true if
|
|
|
|
// the frame already has a transform, and we want to ignore that here
|
|
|
|
if (aFrame->IsAbsolutelyPositioned() ||
|
|
|
|
aFrame->IsRelativelyPositioned()) {
|
|
|
|
// This frame is a container for abs-pos descendants whether or not it
|
|
|
|
// has a transform.
|
|
|
|
// So abs-pos descendants are no problem; we only need to reframe if
|
|
|
|
// we have fixed-pos descendants.
|
|
|
|
positionMask = 1 << NS_STYLE_POSITION_FIXED;
|
|
|
|
} else {
|
|
|
|
// This frame may not be a container for abs-pos descendants already.
|
|
|
|
// So reframe if we have abs-pos or fixed-pos descendants.
|
|
|
|
positionMask = (1 << NS_STYLE_POSITION_FIXED) |
|
|
|
|
(1 << NS_STYLE_POSITION_ABSOLUTE);
|
|
|
|
}
|
|
|
|
for (nsIFrame* f = aFrame; f;
|
2014-02-07 01:45:31 +00:00
|
|
|
f = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(f)) {
|
2013-07-20 19:14:25 +00:00
|
|
|
if (FrameHasPositionedPlaceholderDescendants(f, positionMask)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"Someone forgot a script blocker");
|
|
|
|
int32_t count = aChangeList.Count();
|
|
|
|
if (!count)
|
|
|
|
return NS_OK;
|
|
|
|
|
2014-05-23 21:12:29 +00:00
|
|
|
PROFILER_LABEL("RestyleManager", "ProcessRestyledFrames",
|
|
|
|
js::ProfileEntry::Category::CSS);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
// Make sure to not rebuild quote or counter lists while we're
|
|
|
|
// processing restyles
|
|
|
|
FrameConstructor()->BeginUpdate();
|
|
|
|
|
|
|
|
FramePropertyTable* propTable = mPresContext->PropertyTable();
|
|
|
|
|
|
|
|
// Mark frames so that we skip frames that die along the way, bug 123049.
|
|
|
|
// A frame can be in the list multiple times with different hints. Further
|
|
|
|
// optmization is possible if nsStyleChangeList::AppendChange could coalesce
|
|
|
|
int32_t index = count;
|
|
|
|
|
|
|
|
while (0 <= --index) {
|
|
|
|
const nsStyleChangeData* changeData;
|
|
|
|
aChangeList.ChangeAt(index, &changeData);
|
|
|
|
if (changeData->mFrame) {
|
|
|
|
propTable->Set(changeData->mFrame, ChangeListProperty(),
|
|
|
|
NS_INT32_TO_PTR(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
index = count;
|
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
bool didUpdateCursor = false;
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
while (0 <= --index) {
|
|
|
|
nsIFrame* frame;
|
|
|
|
nsIContent* content;
|
|
|
|
bool didReflowThisFrame = false;
|
|
|
|
nsChangeHint hint;
|
|
|
|
aChangeList.ChangeAt(index, frame, content, hint);
|
|
|
|
|
|
|
|
NS_ASSERTION(!(hint & nsChangeHint_AllReflowHints) ||
|
|
|
|
(hint & nsChangeHint_NeedReflow),
|
|
|
|
"Reflow hint bits set without actually asking for a reflow");
|
|
|
|
|
|
|
|
// skip any frame that has been destroyed due to a ripple effect
|
|
|
|
if (frame && !propTable->Get(frame, ChangeListProperty())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame && frame->GetContent() != content) {
|
|
|
|
// XXXbz this is due to image maps messing with the primary frame of
|
|
|
|
// <area>s. See bug 135040. Remove this block once that's fixed.
|
|
|
|
frame = nullptr;
|
|
|
|
if (!(hint & nsChangeHint_ReconstructFrame)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((hint & nsChangeHint_AddOrRemoveTransform) && frame &&
|
|
|
|
!(hint & nsChangeHint_ReconstructFrame)) {
|
2014-01-16 01:39:30 +00:00
|
|
|
if (NeedToReframeForAddingOrRemovingTransform(frame) ||
|
|
|
|
frame->GetType() == nsGkAtoms::fieldSetFrame ||
|
|
|
|
frame->GetContentInsertionFrame() != frame) {
|
|
|
|
// The frame has positioned children that need to be reparented, or
|
|
|
|
// it can't easily be converted to/from being an abs-pos container correctly.
|
2013-07-20 19:14:25 +00:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
} else {
|
2013-09-25 19:28:07 +00:00
|
|
|
for (nsIFrame *cont = frame; cont;
|
2014-02-07 01:45:31 +00:00
|
|
|
cont = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
|
2013-09-25 19:28:07 +00:00
|
|
|
// Normally frame construction would set state bits as needed,
|
|
|
|
// but we're not going to reconstruct the frame so we need to set them.
|
|
|
|
// It's because we need to set this state on each affected frame
|
|
|
|
// that we can't coalesce nsChangeHint_AddOrRemoveTransform hints up
|
|
|
|
// to ancestors (i.e. it can't be an inherited change hint).
|
2015-03-12 03:21:01 +00:00
|
|
|
if (cont->IsAbsPosContaininingBlock()) {
|
2013-09-25 19:28:07 +00:00
|
|
|
// If a transform has been added, we'll be taking this path,
|
|
|
|
// but we may be taking this path even if a transform has been
|
|
|
|
// removed. It's OK to add the bit even if it's not needed.
|
|
|
|
cont->AddStateBits(NS_FRAME_MAY_BE_TRANSFORMED);
|
|
|
|
if (!cont->IsAbsoluteContainer() &&
|
|
|
|
(cont->GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)) {
|
|
|
|
cont->MarkAsAbsoluteContainingBlock();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Don't remove NS_FRAME_MAY_BE_TRANSFORMED since it may still by
|
|
|
|
// transformed by other means. It's OK to have the bit even if it's
|
|
|
|
// not needed.
|
|
|
|
if (cont->IsAbsoluteContainer()) {
|
|
|
|
cont->MarkAsNotAbsoluteContainingBlock();
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hint & nsChangeHint_ReconstructFrame) {
|
|
|
|
// If we ever start passing true here, be careful of restyles
|
|
|
|
// that involve a reframe and animations. In particular, if the
|
|
|
|
// restyle we're processing here is an animation restyle, but
|
|
|
|
// the style resolution we will do for the frame construction
|
|
|
|
// happens async when we're not in an animation restyle already,
|
|
|
|
// problems could arise.
|
2014-08-13 22:39:00 +00:00
|
|
|
// We could also have problems with triggering of CSS transitions
|
|
|
|
// on elements whose frames are reconstructed, since we depend on
|
|
|
|
// the reconstruction happening synchronously.
|
2014-10-23 13:19:26 +00:00
|
|
|
FrameConstructor()->RecreateFramesForContent(content, false,
|
|
|
|
nsCSSFrameConstructor::REMOVE_FOR_RECONSTRUCTION, nullptr);
|
2013-07-20 19:14:25 +00:00
|
|
|
} else {
|
|
|
|
NS_ASSERTION(frame, "This shouldn't happen");
|
|
|
|
|
|
|
|
if ((frame->GetStateBits() & NS_FRAME_SVG_LAYOUT) &&
|
|
|
|
(frame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
|
|
|
|
// frame does not maintain overflow rects, so avoid calling
|
|
|
|
// FinishAndStoreOverflow on it:
|
|
|
|
hint = NS_SubtractHint(hint,
|
2015-02-16 03:34:29 +00:00
|
|
|
NS_CombineHint(
|
|
|
|
NS_CombineHint(nsChangeHint_UpdateOverflow,
|
|
|
|
nsChangeHint_ChildrenOnlyTransform),
|
|
|
|
NS_CombineHint(nsChangeHint_UpdatePostTransformOverflow,
|
|
|
|
nsChangeHint_UpdateParentOverflow)));
|
2014-03-14 00:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(frame->GetStateBits() & NS_FRAME_MAY_BE_TRANSFORMED)) {
|
|
|
|
// Frame can not be transformed, and thus a change in transform will
|
|
|
|
// have no effect and we should not use the
|
|
|
|
// nsChangeHint_UpdatePostTransformOverflow hint.
|
|
|
|
hint = NS_SubtractHint(hint, nsChangeHint_UpdatePostTransformOverflow);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hint & nsChangeHint_UpdateEffects) {
|
2013-09-25 19:28:07 +00:00
|
|
|
for (nsIFrame *cont = frame; cont;
|
2014-02-07 01:45:31 +00:00
|
|
|
cont = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
|
2013-09-25 19:28:07 +00:00
|
|
|
nsSVGEffects::UpdateEffects(cont);
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2015-05-13 14:38:04 +00:00
|
|
|
if ((hint & nsChangeHint_InvalidateRenderingObservers) ||
|
|
|
|
((hint & nsChangeHint_UpdateOpacityLayer) &&
|
|
|
|
frame->IsFrameOfType(nsIFrame::eSVG) &&
|
|
|
|
!(frame->GetStateBits() & NS_STATE_IS_OUTER_SVG))) {
|
2014-11-04 14:52:27 +00:00
|
|
|
nsSVGEffects::InvalidateRenderingObservers(frame);
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
if (hint & nsChangeHint_NeedReflow) {
|
|
|
|
StyleChangeReflow(frame, hint);
|
|
|
|
didReflowThisFrame = true;
|
|
|
|
}
|
2014-06-17 14:32:00 +00:00
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView |
|
|
|
|
nsChangeHint_UpdateOpacityLayer | nsChangeHint_UpdateTransformLayer |
|
2014-07-16 11:28:50 +00:00
|
|
|
nsChangeHint_ChildrenOnlyTransform | nsChangeHint_SchedulePaint)) {
|
2013-07-20 19:14:25 +00:00
|
|
|
ApplyRenderingChangeToTree(mPresContext, frame, hint);
|
|
|
|
}
|
|
|
|
if ((hint & nsChangeHint_RecomputePosition) && !didReflowThisFrame) {
|
2013-09-10 00:08:41 +00:00
|
|
|
ActiveLayerTracker::NotifyOffsetRestyle(frame);
|
2013-07-20 19:14:25 +00:00
|
|
|
// It is possible for this to fall back to a reflow
|
|
|
|
if (!RecomputePosition(frame)) {
|
|
|
|
didReflowThisFrame = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_ASSERTION(!(hint & nsChangeHint_ChildrenOnlyTransform) ||
|
|
|
|
(hint & nsChangeHint_UpdateOverflow),
|
|
|
|
"nsChangeHint_UpdateOverflow should be passed too");
|
2014-03-14 00:21:25 +00:00
|
|
|
if (!didReflowThisFrame &&
|
|
|
|
(hint & (nsChangeHint_UpdateOverflow |
|
2014-06-17 14:32:00 +00:00
|
|
|
nsChangeHint_UpdatePostTransformOverflow |
|
2015-02-16 03:34:29 +00:00
|
|
|
nsChangeHint_UpdateParentOverflow |
|
2014-06-17 14:32:00 +00:00
|
|
|
nsChangeHint_UpdateSubtreeOverflow))) {
|
|
|
|
if (hint & nsChangeHint_UpdateSubtreeOverflow) {
|
2015-02-19 00:49:52 +00:00
|
|
|
for (nsIFrame *cont = frame; cont; cont =
|
|
|
|
nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
|
|
|
|
AddSubtreeToOverflowTracker(cont);
|
|
|
|
}
|
|
|
|
// The work we just did in AddSubtreeToOverflowTracker
|
|
|
|
// subsumes some of the other hints:
|
|
|
|
hint = NS_SubtractHint(hint,
|
|
|
|
NS_CombineHint(nsChangeHint_UpdateOverflow,
|
|
|
|
nsChangeHint_UpdatePostTransformOverflow));
|
2014-06-17 14:32:00 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
if (hint & nsChangeHint_ChildrenOnlyTransform) {
|
|
|
|
// The overflow areas of the child frames need to be updated:
|
|
|
|
nsIFrame* hintFrame = GetFrameForChildrenOnlyTransformHint(frame);
|
|
|
|
nsIFrame* childFrame = hintFrame->GetFirstPrincipalChild();
|
2014-02-07 01:45:31 +00:00
|
|
|
NS_ASSERTION(!nsLayoutUtils::GetNextContinuationOrIBSplitSibling(frame),
|
2014-02-07 01:45:33 +00:00
|
|
|
"SVG frames should not have continuations "
|
|
|
|
"or ib-split siblings");
|
2014-02-07 01:45:31 +00:00
|
|
|
NS_ASSERTION(!nsLayoutUtils::GetNextContinuationOrIBSplitSibling(hintFrame),
|
2014-02-07 01:45:33 +00:00
|
|
|
"SVG frames should not have continuations "
|
|
|
|
"or ib-split siblings");
|
2013-07-20 19:14:25 +00:00
|
|
|
for ( ; childFrame; childFrame = childFrame->GetNextSibling()) {
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(childFrame->IsFrameOfType(nsIFrame::eSVG),
|
|
|
|
"Not expecting non-SVG children");
|
2013-07-20 19:14:25 +00:00
|
|
|
// If |childFrame| is dirty or has dirty children, we don't bother
|
|
|
|
// updating overflows since that will happen when it's reflowed.
|
|
|
|
if (!(childFrame->GetStateBits() &
|
|
|
|
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN))) {
|
2014-03-14 00:21:25 +00:00
|
|
|
mOverflowChangedTracker.AddFrame(childFrame,
|
2015-02-16 03:34:29 +00:00
|
|
|
OverflowChangedTracker::CHILDREN_CHANGED);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2014-02-07 01:45:31 +00:00
|
|
|
NS_ASSERTION(!nsLayoutUtils::GetNextContinuationOrIBSplitSibling(childFrame),
|
2014-02-07 01:45:33 +00:00
|
|
|
"SVG frames should not have continuations "
|
|
|
|
"or ib-split siblings");
|
2013-07-20 19:14:25 +00:00
|
|
|
NS_ASSERTION(childFrame->GetParent() == hintFrame,
|
|
|
|
"SVG child frame not expected to have different parent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If |frame| is dirty or has dirty children, we don't bother updating
|
|
|
|
// overflows since that will happen when it's reflowed.
|
|
|
|
if (!(frame->GetStateBits() &
|
|
|
|
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN))) {
|
2015-02-16 03:34:29 +00:00
|
|
|
if (hint & (nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_UpdatePostTransformOverflow)) {
|
|
|
|
OverflowChangedTracker::ChangeKind changeKind;
|
|
|
|
// If we have both nsChangeHint_UpdateOverflow and
|
|
|
|
// nsChangeHint_UpdatePostTransformOverflow,
|
2015-02-16 03:34:29 +00:00
|
|
|
// CHILDREN_CHANGED is selected as it is
|
2015-02-16 03:34:29 +00:00
|
|
|
// strictly stronger.
|
2015-02-19 00:49:52 +00:00
|
|
|
if (hint & nsChangeHint_UpdateOverflow) {
|
2015-02-16 03:34:29 +00:00
|
|
|
changeKind = OverflowChangedTracker::CHILDREN_CHANGED;
|
2015-02-16 03:34:29 +00:00
|
|
|
} else {
|
|
|
|
changeKind = OverflowChangedTracker::TRANSFORM_CHANGED;
|
|
|
|
}
|
|
|
|
for (nsIFrame *cont = frame; cont; cont =
|
|
|
|
nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
|
|
|
|
mOverflowChangedTracker.AddFrame(cont, changeKind);
|
|
|
|
}
|
2014-03-14 00:21:25 +00:00
|
|
|
}
|
2015-02-16 03:34:29 +00:00
|
|
|
// UpdateParentOverflow hints need to be processed in addition
|
|
|
|
// to the above, since if the processing of the above hints
|
|
|
|
// yields no change, the update will not propagate to the
|
|
|
|
// parent.
|
|
|
|
if (hint & nsChangeHint_UpdateParentOverflow) {
|
|
|
|
MOZ_ASSERT(frame->GetParent(),
|
|
|
|
"shouldn't get style hints for the root frame");
|
|
|
|
for (nsIFrame *cont = frame; cont; cont =
|
|
|
|
nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
|
|
|
|
mOverflowChangedTracker.AddFrame(cont->GetParent(),
|
|
|
|
OverflowChangedTracker::CHILDREN_CHANGED);
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-25 19:28:07 +00:00
|
|
|
if ((hint & nsChangeHint_UpdateCursor) && !didUpdateCursor) {
|
2015-04-06 15:22:00 +00:00
|
|
|
mPresContext->PresShell()->SynthesizeMouseMove(false);
|
2013-09-25 19:28:07 +00:00
|
|
|
didUpdateCursor = true;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameConstructor()->EndUpdate();
|
|
|
|
|
|
|
|
// cleanup references and verify the style tree. Note that the latter needs
|
|
|
|
// to happen once we've processed the whole list, since until then the tree
|
|
|
|
// is not in fact in a consistent state.
|
|
|
|
index = count;
|
|
|
|
while (0 <= --index) {
|
|
|
|
const nsStyleChangeData* changeData;
|
|
|
|
aChangeList.ChangeAt(index, &changeData);
|
|
|
|
if (changeData->mFrame) {
|
|
|
|
propTable->Delete(changeData->mFrame, ChangeListProperty());
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// reget frame from content since it may have been regenerated...
|
|
|
|
if (changeData->mContent) {
|
2014-11-20 02:48:42 +00:00
|
|
|
if (!css::CommonAnimationManager::ContentOrAncestorHasAnimation(changeData->mContent)) {
|
2013-07-20 19:14:25 +00:00
|
|
|
nsIFrame* frame = changeData->mContent->GetPrimaryFrame();
|
|
|
|
if (frame) {
|
2013-07-20 19:14:25 +00:00
|
|
|
DebugVerifyStyleTree(frame);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!changeData->mFrame ||
|
|
|
|
changeData->mFrame->GetType() != nsGkAtoms::viewportFrame) {
|
|
|
|
NS_WARNING("Unable to test style tree integrity -- no content node "
|
|
|
|
"(and not a viewport frame)");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
aChangeList.Clear();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::RestyleElement(Element* aElement,
|
|
|
|
nsIFrame* aPrimaryFrame,
|
|
|
|
nsChangeHint aMinHint,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
2014-06-19 00:07:26 +00:00
|
|
|
nsRestyleHint aRestyleHint)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
2015-01-14 05:03:13 +00:00
|
|
|
MOZ_ASSERT(mReframingStyleContexts, "should have rsc");
|
2013-07-20 19:14:25 +00:00
|
|
|
NS_ASSERTION(aPrimaryFrame == aElement->GetPrimaryFrame(),
|
|
|
|
"frame/content mismatch");
|
|
|
|
if (aPrimaryFrame && aPrimaryFrame->GetContent() != aElement) {
|
|
|
|
// XXXbz this is due to image maps messing with the primary frame pointer
|
|
|
|
// of <area>s. See bug 135040. We can remove this block once that's fixed.
|
|
|
|
aPrimaryFrame = nullptr;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(!aPrimaryFrame || aPrimaryFrame->GetContent() == aElement,
|
|
|
|
"frame/content mismatch");
|
|
|
|
|
|
|
|
// If we're restyling the root element and there are 'rem' units in
|
|
|
|
// use, handle dynamic changes to the definition of a 'rem' here.
|
2015-01-14 05:03:12 +00:00
|
|
|
if (mPresContext->UsesRootEMUnits() && aPrimaryFrame &&
|
|
|
|
!mInRebuildAllStyleData) {
|
2013-07-20 19:14:25 +00:00
|
|
|
nsStyleContext *oldContext = aPrimaryFrame->StyleContext();
|
|
|
|
if (!oldContext->GetParent()) { // check that we're the root element
|
|
|
|
nsRefPtr<nsStyleContext> newContext = mPresContext->StyleSet()->
|
|
|
|
ResolveStyleFor(aElement, nullptr /* == oldContext->GetParent() */);
|
|
|
|
if (oldContext->StyleFont()->mFont.size !=
|
|
|
|
newContext->StyleFont()->mFont.size) {
|
|
|
|
// The basis for 'rem' units has changed.
|
2015-01-14 05:03:11 +00:00
|
|
|
mRebuildAllRestyleHint |= aRestyleHint;
|
2015-01-14 05:03:12 +00:00
|
|
|
NS_UpdateHint(mRebuildAllExtraHint, aMinHint);
|
2015-01-14 05:03:12 +00:00
|
|
|
StartRebuildAllStyleData(aRestyleTracker);
|
2015-01-14 05:03:12 +00:00
|
|
|
return;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aMinHint & nsChangeHint_ReconstructFrame) {
|
2014-10-23 13:19:26 +00:00
|
|
|
FrameConstructor()->RecreateFramesForContent(aElement, false,
|
|
|
|
nsCSSFrameConstructor::REMOVE_FOR_RECONSTRUCTION, nullptr);
|
2013-07-20 19:14:25 +00:00
|
|
|
} else if (aPrimaryFrame) {
|
2014-08-13 22:39:00 +00:00
|
|
|
ComputeAndProcessStyleChange(aPrimaryFrame, aMinHint, aRestyleTracker,
|
|
|
|
aRestyleHint);
|
2014-08-03 20:11:55 +00:00
|
|
|
} else if (aRestyleHint & ~eRestyle_LaterSiblings) {
|
|
|
|
// We're restyling an element with no frame, so we should try to
|
|
|
|
// make one if its new style says it should have one. But in order
|
|
|
|
// to try to honor the restyle hint (which we'd like to do so that,
|
|
|
|
// for example, an animation-only style flush doesn't flush other
|
|
|
|
// buffered style changes), we only do this if the restyle hint says
|
|
|
|
// we have *some* restyling for this frame. This means we'll
|
|
|
|
// potentially get ahead of ourselves in that case, but not as much
|
|
|
|
// as we would if we didn't check the restyle hint.
|
2014-11-20 18:24:10 +00:00
|
|
|
nsStyleContext* newContext =
|
|
|
|
FrameConstructor()->MaybeRecreateFramesForElement(aElement);
|
|
|
|
if (newContext &&
|
|
|
|
newContext->StyleDisplay()->mDisplay == NS_STYLE_DISPLAY_CONTENTS) {
|
|
|
|
// Style change for a display:contents node that did not recreate frames.
|
|
|
|
ComputeAndProcessStyleChange(newContext, aElement, aMinHint,
|
|
|
|
aRestyleTracker, aRestyleHint);
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-14 05:03:13 +00:00
|
|
|
RestyleManager::ReframingStyleContexts::ReframingStyleContexts(
|
|
|
|
RestyleManager* aRestyleManager)
|
|
|
|
: mRestyleManager(aRestyleManager)
|
2015-01-14 05:03:13 +00:00
|
|
|
, mRestorePointer(mRestyleManager->mReframingStyleContexts)
|
2015-01-14 05:03:13 +00:00
|
|
|
{
|
2015-01-14 05:03:13 +00:00
|
|
|
MOZ_ASSERT(!mRestyleManager->mReframingStyleContexts,
|
|
|
|
"shouldn't construct recursively");
|
|
|
|
mRestyleManager->mReframingStyleContexts = this;
|
2015-01-14 05:03:13 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:03:13 +00:00
|
|
|
RestyleManager::ReframingStyleContexts::~ReframingStyleContexts()
|
|
|
|
{
|
|
|
|
// Before we go away, we need to flush out any frame construction that
|
|
|
|
// was enqueued, so that we start transitions.
|
|
|
|
// Note that this is a little bit evil in that we're calling into code
|
|
|
|
// that calls our member functions from our destructor, but it's at
|
|
|
|
// the beginning of our destructor, so it shouldn't be too bad.
|
|
|
|
mRestyleManager->mPresContext->FrameConstructor()->CreateNeededFrames();
|
|
|
|
}
|
|
|
|
|
2013-11-28 06:46:40 +00:00
|
|
|
static inline dom::Element*
|
|
|
|
ElementForStyleContext(nsIContent* aParentContent,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsCSSPseudoElements::Type aPseudoType);
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// Forwarded nsIDocumentObserver method, to handle restyling (and
|
|
|
|
// passing the notification to the frame).
|
|
|
|
nsresult
|
|
|
|
RestyleManager::ContentStateChanged(nsIContent* aContent,
|
2014-04-03 04:18:36 +00:00
|
|
|
EventStates aStateMask)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
|
|
|
// XXXbz it would be good if this function only took Elements, but
|
|
|
|
// we'd have to make ESM guarantee that usefully.
|
|
|
|
if (!aContent->IsElement()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Element* aElement = aContent->AsElement();
|
|
|
|
|
|
|
|
nsStyleSet* styleSet = mPresContext->StyleSet();
|
|
|
|
NS_ASSERTION(styleSet, "couldn't get style set");
|
|
|
|
|
|
|
|
nsChangeHint hint = NS_STYLE_HINT_NONE;
|
|
|
|
// Any change to a content state that affects which frames we construct
|
|
|
|
// must lead to a frame reconstruct here if we already have a frame.
|
|
|
|
// Note that we never decide through non-CSS means to not create frames
|
|
|
|
// based on content states, so if we already don't have a frame we don't
|
|
|
|
// need to force a reframe -- if it's needed, the HasStateDependentStyle
|
|
|
|
// call will handle things.
|
|
|
|
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
|
2013-11-28 06:46:40 +00:00
|
|
|
nsCSSPseudoElements::Type pseudoType =
|
|
|
|
nsCSSPseudoElements::ePseudo_NotPseudoElement;
|
2013-07-20 19:14:25 +00:00
|
|
|
if (primaryFrame) {
|
|
|
|
// If it's generated content, ignore LOADING/etc state changes on it.
|
|
|
|
if (!primaryFrame->IsGeneratedContentFrame() &&
|
|
|
|
aStateMask.HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN |
|
|
|
|
NS_EVENT_STATE_USERDISABLED |
|
|
|
|
NS_EVENT_STATE_SUPPRESSED |
|
|
|
|
NS_EVENT_STATE_LOADING)) {
|
|
|
|
hint = nsChangeHint_ReconstructFrame;
|
|
|
|
} else {
|
|
|
|
uint8_t app = primaryFrame->StyleDisplay()->mAppearance;
|
|
|
|
if (app) {
|
|
|
|
nsITheme *theme = mPresContext->GetTheme();
|
|
|
|
if (theme && theme->ThemeSupportsWidget(mPresContext,
|
|
|
|
primaryFrame, app)) {
|
|
|
|
bool repaint = false;
|
|
|
|
theme->WidgetStateChanged(primaryFrame, app, nullptr, &repaint);
|
|
|
|
if (repaint) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-28 06:46:40 +00:00
|
|
|
pseudoType = primaryFrame->StyleContext()->GetPseudoType();
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
primaryFrame->ContentStatesChanged(aStateMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-28 06:46:40 +00:00
|
|
|
nsRestyleHint rshint;
|
|
|
|
|
|
|
|
if (pseudoType >= nsCSSPseudoElements::ePseudo_PseudoElementCount) {
|
2015-04-17 01:09:59 +00:00
|
|
|
rshint = styleSet->HasStateDependentStyle(aElement, aStateMask);
|
2013-11-28 06:46:40 +00:00
|
|
|
} else if (nsCSSPseudoElements::PseudoElementSupportsUserActionState(
|
|
|
|
pseudoType)) {
|
|
|
|
// If aElement is a pseudo-element, we want to check to see whether there
|
|
|
|
// are any state-dependent rules applying to that pseudo.
|
|
|
|
Element* ancestor = ElementForStyleContext(nullptr, primaryFrame,
|
|
|
|
pseudoType);
|
2015-04-17 01:09:59 +00:00
|
|
|
rshint = styleSet->HasStateDependentStyle(ancestor, pseudoType, aElement,
|
2013-11-28 06:46:40 +00:00
|
|
|
aStateMask);
|
|
|
|
} else {
|
|
|
|
rshint = nsRestyleHint(0);
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
if (aStateMask.HasState(NS_EVENT_STATE_HOVER) && rshint != 0) {
|
|
|
|
++mHoverGeneration;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aStateMask.HasState(NS_EVENT_STATE_VISITED)) {
|
|
|
|
// Exposing information to the page about whether the link is
|
|
|
|
// visited or not isn't really something we can worry about here.
|
|
|
|
// FIXME: We could probably do this a bit better.
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
PostRestyleEvent(aElement, rshint, hint);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Forwarded nsIMutationObserver method, to handle restyling.
|
|
|
|
void
|
|
|
|
RestyleManager::AttributeWillChange(Element* aElement,
|
|
|
|
int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType)
|
|
|
|
{
|
|
|
|
nsRestyleHint rshint =
|
2015-04-17 01:09:59 +00:00
|
|
|
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
|
2013-07-20 19:14:25 +00:00
|
|
|
aAttribute,
|
|
|
|
aModType,
|
|
|
|
false);
|
|
|
|
PostRestyleEvent(aElement, rshint, NS_STYLE_HINT_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Forwarded nsIMutationObserver method, to handle restyling (and
|
|
|
|
// passing the notification to the frame).
|
|
|
|
void
|
|
|
|
RestyleManager::AttributeChanged(Element* aElement,
|
|
|
|
int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType)
|
|
|
|
{
|
|
|
|
// Hold onto the PresShell to prevent ourselves from being destroyed.
|
|
|
|
// XXXbz how, exactly, would this attribute change cause us to be
|
|
|
|
// destroyed from inside this function?
|
|
|
|
nsCOMPtr<nsIPresShell> shell = mPresContext->GetPresShell();
|
|
|
|
|
|
|
|
// Get the frame associated with the content which is the highest in the frame tree
|
|
|
|
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("RestyleManager::AttributeChanged: content=%p[%s] frame=%p",
|
|
|
|
aContent, ContentTag(aElement, 0), frame));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// the style tag has its own interpretation based on aHint
|
|
|
|
nsChangeHint hint = aElement->GetAttributeChangeHint(aAttribute, aModType);
|
|
|
|
|
|
|
|
bool reframe = (hint & nsChangeHint_ReconstructFrame) != 0;
|
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
// The following listbox widget trap prevents offscreen listbox widget
|
|
|
|
// content from being removed and re-inserted (which is what would
|
|
|
|
// happen otherwise).
|
|
|
|
if (!primaryFrame && !reframe) {
|
|
|
|
int32_t namespaceID;
|
|
|
|
nsIAtom* tag = mPresContext->Document()->BindingManager()->
|
|
|
|
ResolveTag(aElement, &namespaceID);
|
|
|
|
|
|
|
|
if (namespaceID == kNameSpaceID_XUL &&
|
|
|
|
(tag == nsGkAtoms::listitem ||
|
|
|
|
tag == nsGkAtoms::listcell))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::tooltiptext ||
|
|
|
|
aAttribute == nsGkAtoms::tooltip)
|
|
|
|
{
|
|
|
|
nsIRootBox* rootBox = nsIRootBox::GetRootBox(mPresContext->GetPresShell());
|
|
|
|
if (rootBox) {
|
|
|
|
if (aModType == nsIDOMMutationEvent::REMOVAL)
|
|
|
|
rootBox->RemoveTooltipSupport(aElement);
|
|
|
|
if (aModType == nsIDOMMutationEvent::ADDITION)
|
|
|
|
rootBox->AddTooltipSupport(aElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MOZ_XUL
|
|
|
|
|
|
|
|
if (primaryFrame) {
|
|
|
|
// See if we have appearance information for a theme.
|
|
|
|
const nsStyleDisplay* disp = primaryFrame->StyleDisplay();
|
|
|
|
if (disp->mAppearance) {
|
|
|
|
nsITheme *theme = mPresContext->GetTheme();
|
|
|
|
if (theme && theme->ThemeSupportsWidget(mPresContext, primaryFrame, disp->mAppearance)) {
|
|
|
|
bool repaint = false;
|
|
|
|
theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint);
|
|
|
|
if (repaint)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// let the frame deal with it now, so we don't have to deal later
|
|
|
|
primaryFrame->AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2014-02-07 01:45:33 +00:00
|
|
|
// XXXwaterson should probably check for IB split siblings
|
2013-07-20 19:14:25 +00:00
|
|
|
// here, and propagate the AttributeChanged notification to
|
|
|
|
// them, as well. Currently, inline frames don't do anything on
|
|
|
|
// this notification, so it's not that big a deal.
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if we can optimize away the style re-resolution -- must be called after
|
|
|
|
// the frame's AttributeChanged() in case it does something that affects the style
|
|
|
|
nsRestyleHint rshint =
|
2015-04-17 01:09:59 +00:00
|
|
|
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
|
2013-07-20 19:14:25 +00:00
|
|
|
aAttribute,
|
|
|
|
aModType,
|
|
|
|
true);
|
|
|
|
|
|
|
|
PostRestyleEvent(aElement, rshint, hint);
|
|
|
|
}
|
|
|
|
|
2014-11-17 04:46:00 +00:00
|
|
|
/* static */ uint64_t
|
|
|
|
RestyleManager::GetMaxAnimationGenerationForFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
if (!content || !content->IsElement()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPseudoElements::Type pseudoType =
|
|
|
|
aFrame->StyleContext()->GetPseudoType();
|
2015-04-21 01:22:10 +00:00
|
|
|
AnimationCollection* transitions =
|
2015-03-20 18:20:49 +00:00
|
|
|
aFrame->PresContext()->TransitionManager()->GetAnimations(
|
2014-11-17 04:46:00 +00:00
|
|
|
content->AsElement(), pseudoType, false /* don't create */);
|
2015-04-21 01:22:10 +00:00
|
|
|
AnimationCollection* animations =
|
2015-03-20 18:20:49 +00:00
|
|
|
aFrame->PresContext()->AnimationManager()->GetAnimations(
|
2014-11-17 04:46:00 +00:00
|
|
|
content->AsElement(), pseudoType, false /* don't create */);
|
|
|
|
|
|
|
|
return std::max(transitions ? transitions->mAnimationGeneration : 0,
|
|
|
|
animations ? animations->mAnimationGeneration : 0);
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
void
|
|
|
|
RestyleManager::RestyleForEmptyChange(Element* aContainer)
|
|
|
|
{
|
|
|
|
// In some cases (:empty + E, :empty ~ E), a change if the content of
|
|
|
|
// an element requires restyling its parent's siblings.
|
|
|
|
nsRestyleHint hint = eRestyle_Subtree;
|
|
|
|
nsIContent* grandparent = aContainer->GetParent();
|
|
|
|
if (grandparent &&
|
|
|
|
(grandparent->GetFlags() & NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS)) {
|
|
|
|
hint = nsRestyleHint(hint | eRestyle_LaterSiblings);
|
|
|
|
}
|
|
|
|
PostRestyleEvent(aContainer, hint, NS_STYLE_HINT_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::RestyleForAppend(Element* aContainer,
|
|
|
|
nsIContent* aFirstNewContent)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aContainer, "must have container for append");
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
for (nsIContent* cur = aFirstNewContent; cur; cur = cur->GetNextSibling()) {
|
|
|
|
NS_ASSERTION(!cur->IsRootOfAnonymousSubtree(),
|
|
|
|
"anonymous nodes should not be in child lists");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
uint32_t selectorFlags =
|
|
|
|
aContainer->GetFlags() & (NODE_ALL_SELECTOR_FLAGS &
|
|
|
|
~NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS);
|
|
|
|
if (selectorFlags == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_EMPTY_SELECTOR) {
|
|
|
|
// see whether we need to restyle the container
|
|
|
|
bool wasEmpty = true; // :empty or :-moz-only-whitespace
|
|
|
|
for (nsIContent* cur = aContainer->GetFirstChild();
|
|
|
|
cur != aFirstNewContent;
|
|
|
|
cur = cur->GetNextSibling()) {
|
|
|
|
// We don't know whether we're testing :empty or :-moz-only-whitespace,
|
|
|
|
// so be conservative and assume :-moz-only-whitespace (i.e., make
|
|
|
|
// IsSignificantChild less likely to be true, and thus make us more
|
|
|
|
// likely to restyle).
|
|
|
|
if (nsStyleUtil::IsSignificantChild(cur, true, false)) {
|
|
|
|
wasEmpty = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wasEmpty) {
|
|
|
|
RestyleForEmptyChange(aContainer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_SLOW_SELECTOR) {
|
|
|
|
PostRestyleEvent(aContainer, eRestyle_Subtree, NS_STYLE_HINT_NONE);
|
|
|
|
// Restyling the container is the most we can do here, so we're done.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_EDGE_CHILD_SELECTOR) {
|
|
|
|
// restyle the last element child before this node
|
|
|
|
for (nsIContent* cur = aFirstNewContent->GetPreviousSibling();
|
|
|
|
cur;
|
|
|
|
cur = cur->GetPreviousSibling()) {
|
|
|
|
if (cur->IsElement()) {
|
|
|
|
PostRestyleEvent(cur->AsElement(), eRestyle_Subtree, NS_STYLE_HINT_NONE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Needed since we can't use PostRestyleEvent on non-elements (with
|
|
|
|
// eRestyle_LaterSiblings or nsRestyleHint(eRestyle_Subtree |
|
|
|
|
// eRestyle_LaterSiblings) as appropriate).
|
|
|
|
static void
|
|
|
|
RestyleSiblingsStartingWith(RestyleManager* aRestyleManager,
|
|
|
|
nsIContent* aStartingSibling /* may be null */)
|
|
|
|
{
|
|
|
|
for (nsIContent *sibling = aStartingSibling; sibling;
|
|
|
|
sibling = sibling->GetNextSibling()) {
|
|
|
|
if (sibling->IsElement()) {
|
|
|
|
aRestyleManager->
|
|
|
|
PostRestyleEvent(sibling->AsElement(),
|
|
|
|
nsRestyleHint(eRestyle_Subtree | eRestyle_LaterSiblings),
|
|
|
|
NS_STYLE_HINT_NONE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restyling for a ContentInserted or CharacterDataChanged notification.
|
|
|
|
// This could be used for ContentRemoved as well if we got the
|
|
|
|
// notification before the removal happened (and sometimes
|
|
|
|
// CharacterDataChanged is more like a removal than an addition).
|
|
|
|
// The comments are written and variables are named in terms of it being
|
|
|
|
// a ContentInserted notification.
|
|
|
|
void
|
|
|
|
RestyleManager::RestyleForInsertOrChange(Element* aContainer,
|
|
|
|
nsIContent* aChild)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aChild->IsRootOfAnonymousSubtree(),
|
|
|
|
"anonymous nodes should not be in child lists");
|
|
|
|
uint32_t selectorFlags =
|
|
|
|
aContainer ? (aContainer->GetFlags() & NODE_ALL_SELECTOR_FLAGS) : 0;
|
|
|
|
if (selectorFlags == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_EMPTY_SELECTOR) {
|
|
|
|
// see whether we need to restyle the container
|
|
|
|
bool wasEmpty = true; // :empty or :-moz-only-whitespace
|
|
|
|
for (nsIContent* child = aContainer->GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
if (child == aChild)
|
|
|
|
continue;
|
|
|
|
// We don't know whether we're testing :empty or :-moz-only-whitespace,
|
|
|
|
// so be conservative and assume :-moz-only-whitespace (i.e., make
|
|
|
|
// IsSignificantChild less likely to be true, and thus make us more
|
|
|
|
// likely to restyle).
|
|
|
|
if (nsStyleUtil::IsSignificantChild(child, true, false)) {
|
|
|
|
wasEmpty = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wasEmpty) {
|
|
|
|
RestyleForEmptyChange(aContainer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_SLOW_SELECTOR) {
|
|
|
|
PostRestyleEvent(aContainer, eRestyle_Subtree, NS_STYLE_HINT_NONE);
|
|
|
|
// Restyling the container is the most we can do here, so we're done.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS) {
|
|
|
|
// Restyle all later siblings.
|
|
|
|
RestyleSiblingsStartingWith(this, aChild->GetNextSibling());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_EDGE_CHILD_SELECTOR) {
|
|
|
|
// restyle the previously-first element child if it is after this node
|
|
|
|
bool passedChild = false;
|
|
|
|
for (nsIContent* content = aContainer->GetFirstChild();
|
|
|
|
content;
|
|
|
|
content = content->GetNextSibling()) {
|
|
|
|
if (content == aChild) {
|
|
|
|
passedChild = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (content->IsElement()) {
|
|
|
|
if (passedChild) {
|
|
|
|
PostRestyleEvent(content->AsElement(), eRestyle_Subtree,
|
|
|
|
NS_STYLE_HINT_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// restyle the previously-last element child if it is before this node
|
|
|
|
passedChild = false;
|
|
|
|
for (nsIContent* content = aContainer->GetLastChild();
|
|
|
|
content;
|
|
|
|
content = content->GetPreviousSibling()) {
|
|
|
|
if (content == aChild) {
|
|
|
|
passedChild = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (content->IsElement()) {
|
|
|
|
if (passedChild) {
|
|
|
|
PostRestyleEvent(content->AsElement(), eRestyle_Subtree,
|
|
|
|
NS_STYLE_HINT_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::RestyleForRemove(Element* aContainer,
|
|
|
|
nsIContent* aOldChild,
|
|
|
|
nsIContent* aFollowingSibling)
|
|
|
|
{
|
|
|
|
if (aOldChild->IsRootOfAnonymousSubtree()) {
|
|
|
|
// This should be an assert, but this is called incorrectly in
|
|
|
|
// nsHTMLEditor::DeleteRefToAnonymousNode and the assertions were clogging
|
|
|
|
// up the logs. Make it an assert again when that's fixed.
|
|
|
|
NS_WARNING("anonymous nodes should not be in child lists (bug 439258)");
|
|
|
|
}
|
|
|
|
uint32_t selectorFlags =
|
|
|
|
aContainer ? (aContainer->GetFlags() & NODE_ALL_SELECTOR_FLAGS) : 0;
|
|
|
|
if (selectorFlags == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_EMPTY_SELECTOR) {
|
|
|
|
// see whether we need to restyle the container
|
|
|
|
bool isEmpty = true; // :empty or :-moz-only-whitespace
|
|
|
|
for (nsIContent* child = aContainer->GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
// We don't know whether we're testing :empty or :-moz-only-whitespace,
|
|
|
|
// so be conservative and assume :-moz-only-whitespace (i.e., make
|
|
|
|
// IsSignificantChild less likely to be true, and thus make us more
|
|
|
|
// likely to restyle).
|
|
|
|
if (nsStyleUtil::IsSignificantChild(child, true, false)) {
|
|
|
|
isEmpty = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isEmpty) {
|
|
|
|
RestyleForEmptyChange(aContainer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_SLOW_SELECTOR) {
|
|
|
|
PostRestyleEvent(aContainer, eRestyle_Subtree, NS_STYLE_HINT_NONE);
|
|
|
|
// Restyling the container is the most we can do here, so we're done.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS) {
|
|
|
|
// Restyle all later siblings.
|
|
|
|
RestyleSiblingsStartingWith(this, aFollowingSibling);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorFlags & NODE_HAS_EDGE_CHILD_SELECTOR) {
|
|
|
|
// restyle the now-first element child if it was after aOldChild
|
|
|
|
bool reachedFollowingSibling = false;
|
|
|
|
for (nsIContent* content = aContainer->GetFirstChild();
|
|
|
|
content;
|
|
|
|
content = content->GetNextSibling()) {
|
|
|
|
if (content == aFollowingSibling) {
|
|
|
|
reachedFollowingSibling = true;
|
|
|
|
// do NOT continue here; we might want to restyle this node
|
|
|
|
}
|
|
|
|
if (content->IsElement()) {
|
|
|
|
if (reachedFollowingSibling) {
|
|
|
|
PostRestyleEvent(content->AsElement(), eRestyle_Subtree,
|
|
|
|
NS_STYLE_HINT_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// restyle the now-last element child if it was before aOldChild
|
|
|
|
reachedFollowingSibling = (aFollowingSibling == nullptr);
|
|
|
|
for (nsIContent* content = aContainer->GetLastChild();
|
|
|
|
content;
|
|
|
|
content = content->GetPreviousSibling()) {
|
|
|
|
if (content->IsElement()) {
|
|
|
|
if (reachedFollowingSibling) {
|
|
|
|
PostRestyleEvent(content->AsElement(), eRestyle_Subtree, NS_STYLE_HINT_NONE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (content == aFollowingSibling) {
|
|
|
|
reachedFollowingSibling = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-10-08 21:26:57 +00:00
|
|
|
RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
|
|
|
|
nsRestyleHint aRestyleHint)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!(aExtraHint & nsChangeHint_ReconstructFrame),
|
|
|
|
"Should not reconstruct the root of the frame tree. "
|
|
|
|
"Use ReconstructDocElementHierarchy instead.");
|
|
|
|
|
2015-01-14 05:03:11 +00:00
|
|
|
NS_UpdateHint(mRebuildAllExtraHint, aExtraHint);
|
|
|
|
mRebuildAllRestyleHint |= aRestyleHint;
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
// Processing the style changes could cause a flush that propagates to
|
|
|
|
// the parent frame and thus destroys the pres shell, so we must hold
|
|
|
|
// a reference.
|
|
|
|
nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
|
2015-01-14 05:03:12 +00:00
|
|
|
if (!presShell || !presShell->GetRootFrame()) {
|
|
|
|
mDoRebuildAllStyleData = false;
|
2013-07-20 19:14:25 +00:00
|
|
|
return;
|
2015-01-14 05:03:12 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
// Make sure that the viewmanager will outlive the presshell
|
|
|
|
nsRefPtr<nsViewManager> vm = presShell->GetViewManager();
|
|
|
|
|
|
|
|
// We may reconstruct frames below and hence process anything that is in the
|
|
|
|
// tree. We don't want to get notified to process those items again after.
|
|
|
|
presShell->GetDocument()->FlushPendingNotifications(Flush_ContentAndNotify);
|
|
|
|
|
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
mDoRebuildAllStyleData = true;
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
ProcessPendingRestyles();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-14 05:03:12 +00:00
|
|
|
RestyleManager::StartRebuildAllStyleData(RestyleTracker& aRestyleTracker)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
2015-01-14 05:03:12 +00:00
|
|
|
MOZ_ASSERT(mIsProcessingRestyles);
|
2015-01-14 05:03:12 +00:00
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
nsIFrame* rootFrame = mPresContext->PresShell()->GetRootFrame();
|
|
|
|
if (!rootFrame) {
|
|
|
|
// No need to do anything.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
mInRebuildAllStyleData = true;
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// Tell the style set to get the old rule tree out of the way
|
|
|
|
// so we can recalculate while maintaining rule tree immutability
|
|
|
|
nsresult rv = mPresContext->StyleSet()->BeginReconstruct();
|
|
|
|
if (NS_FAILED(rv)) {
|
2015-01-14 05:03:12 +00:00
|
|
|
MOZ_CRASH("unable to rebuild style data");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:03:11 +00:00
|
|
|
nsRestyleHint restyleHint = mRebuildAllRestyleHint;
|
|
|
|
nsChangeHint changeHint = mRebuildAllExtraHint;
|
|
|
|
mRebuildAllExtraHint = nsChangeHint(0);
|
|
|
|
mRebuildAllRestyleHint = nsRestyleHint(0);
|
|
|
|
|
|
|
|
restyleHint |= eRestyle_ForceDescendants;
|
2014-10-04 23:59:47 +00:00
|
|
|
|
2015-01-14 05:03:11 +00:00
|
|
|
if (!(restyleHint & eRestyle_Subtree) &&
|
|
|
|
(restyleHint & ~(eRestyle_Force | eRestyle_ForceDescendants))) {
|
2014-08-03 20:11:55 +00:00
|
|
|
// We want this hint to apply to the root node's primary frame
|
|
|
|
// rather than the root frame, since it's the primary frame that has
|
|
|
|
// the styles for the root element (rather than the ancestors of the
|
|
|
|
// primary frame whose mContent is the root node but which have
|
|
|
|
// different styles). If we use up the hint for one of the
|
|
|
|
// ancestors that we hit first, then we'll fail to do the restyling
|
|
|
|
// we need to do.
|
2014-11-13 07:28:52 +00:00
|
|
|
Element* root = mPresContext->Document()->GetRootElement();
|
|
|
|
if (root) {
|
|
|
|
// If the root element is gone, dropping the hint on the floor
|
|
|
|
// should be fine.
|
2015-01-14 05:03:11 +00:00
|
|
|
aRestyleTracker.AddPendingRestyle(root, restyleHint, nsChangeHint(0));
|
2014-11-13 07:28:52 +00:00
|
|
|
}
|
2015-01-14 05:03:11 +00:00
|
|
|
restyleHint = nsRestyleHint(0);
|
2014-08-03 20:11:55 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
// Recalculate all of the style contexts for the document, from the
|
|
|
|
// root frame. We can't do this with a change hint, since we can't
|
|
|
|
// post a change hint for the root frame.
|
2013-07-20 19:14:25 +00:00
|
|
|
// Note that we can ignore the return value of ComputeStyleChangeFor
|
2015-01-14 05:03:12 +00:00
|
|
|
// because we never need to reframe the root frame.
|
2013-07-20 19:14:25 +00:00
|
|
|
// XXX Does it matter that we're passing aExtraHint to the real root
|
2014-08-03 20:11:55 +00:00
|
|
|
// frame and not the root node's primary frame? (We could do
|
|
|
|
// roughly what we do for aRestyleHint above.)
|
2015-01-14 05:03:12 +00:00
|
|
|
ComputeAndProcessStyleChange(rootFrame,
|
2015-01-14 05:03:11 +00:00
|
|
|
changeHint, aRestyleTracker, restyleHint);
|
2015-01-14 05:03:12 +00:00
|
|
|
}
|
2015-01-14 05:03:12 +00:00
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
void
|
|
|
|
RestyleManager::FinishRebuildAllStyleData()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mInRebuildAllStyleData, "bad caller");
|
|
|
|
|
|
|
|
// Tell the style set it's safe to destroy the old rule tree. We
|
|
|
|
// must do this after the ProcessRestyledFrames call in case the
|
|
|
|
// change list has frame reconstructs in it (since frames to be
|
|
|
|
// reconstructed will still have their old style context pointers
|
|
|
|
// until they are destroyed).
|
|
|
|
mPresContext->StyleSet()->EndReconstruct();
|
|
|
|
|
|
|
|
mInRebuildAllStyleData = false;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::ProcessPendingRestyles()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(mPresContext->Document(), "No document? Pshaw!");
|
|
|
|
NS_PRECONDITION(!nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"Missing a script blocker!");
|
|
|
|
|
2014-04-24 16:30:12 +00:00
|
|
|
// First do any queued-up frame creation. (We should really
|
|
|
|
// merge this into the rest of the process, though; see bug 827239.)
|
|
|
|
mPresContext->FrameConstructor()->CreateNeededFrames();
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// Process non-animation restyles...
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(!mIsProcessingRestyles,
|
|
|
|
"Nesting calls to ProcessPendingRestyles?");
|
2014-10-03 04:53:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
mIsProcessingRestyles = true;
|
|
|
|
#endif
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
// Before we process any restyles, we need to ensure that style
|
2015-02-16 22:15:02 +00:00
|
|
|
// resulting from any animations is up-to-date, so that if any style
|
|
|
|
// changes we cause trigger transitions, we have the correct old style
|
|
|
|
// for starting the transition.
|
2015-02-16 22:15:02 +00:00
|
|
|
bool haveNonAnimation =
|
|
|
|
mHavePendingNonAnimationRestyles || mDoRebuildAllStyleData;
|
|
|
|
if (haveNonAnimation) {
|
2014-11-17 04:45:59 +00:00
|
|
|
IncrementAnimationGeneration();
|
2014-07-25 04:35:34 +00:00
|
|
|
UpdateOnlyAnimationStyles();
|
2015-02-16 22:15:02 +00:00
|
|
|
} else {
|
|
|
|
// If we don't have non-animation style updates, then we have queued
|
|
|
|
// up animation style updates from the refresh driver tick. This
|
|
|
|
// doesn't necessarily include *all* animation style updates, since
|
|
|
|
// we might be suppressing main-thread updates for some animations,
|
|
|
|
// so we don't want to call UpdateOnlyAnimationStyles, which updates
|
|
|
|
// all animations. In other words, the work that we're about to do
|
|
|
|
// to process the pending restyles queue is a *subset* of the work
|
|
|
|
// that UpdateOnlyAnimationStyles would do, since we're *not*
|
|
|
|
// updating transitions that are running on the compositor thread
|
|
|
|
// and suppressed on the main thread.
|
|
|
|
//
|
|
|
|
// But when we update those styles, we want to suppress updates to
|
|
|
|
// transitions just like we do in UpdateOnlyAnimationStyles. So we
|
|
|
|
// want to tell the transition manager to act as though we're in
|
|
|
|
// UpdateOnlyAnimationStyles.
|
|
|
|
//
|
|
|
|
// FIXME: In the future, we might want to refactor the way the
|
|
|
|
// animation and transition manager do their refresh driver ticks so
|
|
|
|
// that we can use UpdateOnlyAnimationStyles, with a different
|
|
|
|
// boolean argument, for this update as well, instead of having them
|
|
|
|
// post style updates in their WillRefresh methods.
|
|
|
|
mPresContext->TransitionManager()->SetInAnimationOnlyStyleUpdate(true);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
ProcessRestyles(mPendingRestyles);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2015-02-16 22:15:02 +00:00
|
|
|
if (!haveNonAnimation) {
|
|
|
|
mPresContext->TransitionManager()->SetInAnimationOnlyStyleUpdate(false);
|
|
|
|
}
|
|
|
|
|
2014-10-03 04:53:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
mIsProcessingRestyles = false;
|
|
|
|
#endif
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2015-02-16 22:15:02 +00:00
|
|
|
NS_ASSERTION(haveNonAnimation || !mHavePendingNonAnimationRestyles,
|
|
|
|
"should not have added restyles");
|
2015-02-16 22:15:02 +00:00
|
|
|
mHavePendingNonAnimationRestyles = false;
|
|
|
|
|
2015-01-14 05:03:11 +00:00
|
|
|
if (mDoRebuildAllStyleData) {
|
2013-07-20 19:14:25 +00:00
|
|
|
// We probably wasted a lot of work up above, but this seems safest
|
|
|
|
// and it should be rarely used.
|
|
|
|
// This might add us as a refresh observer again; that's ok.
|
2015-01-14 05:03:12 +00:00
|
|
|
ProcessPendingRestyles();
|
2015-01-14 05:03:13 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(!mDoRebuildAllStyleData,
|
|
|
|
"repeatedly setting mDoRebuildAllStyleData?");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2015-01-14 05:03:13 +00:00
|
|
|
|
|
|
|
MOZ_ASSERT(!mInRebuildAllStyleData,
|
|
|
|
"should have called FinishRebuildAllStyleData");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2013-07-31 00:36:08 +00:00
|
|
|
void
|
2015-01-14 05:03:12 +00:00
|
|
|
RestyleManager::BeginProcessingRestyles(RestyleTracker& aRestyleTracker)
|
2013-07-31 00:36:08 +00:00
|
|
|
{
|
|
|
|
// Make sure to not rebuild quote or counter lists while we're
|
|
|
|
// processing restyles
|
|
|
|
mPresContext->FrameConstructor()->BeginUpdate();
|
|
|
|
|
|
|
|
mInStyleRefresh = true;
|
2015-01-14 05:03:12 +00:00
|
|
|
|
|
|
|
if (ShouldStartRebuildAllFor(aRestyleTracker)) {
|
|
|
|
mDoRebuildAllStyleData = false;
|
|
|
|
StartRebuildAllStyleData(aRestyleTracker);
|
|
|
|
}
|
2013-07-31 00:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::EndProcessingRestyles()
|
|
|
|
{
|
|
|
|
FlushOverflowChangedTracker();
|
|
|
|
|
|
|
|
// Set mInStyleRefresh to false now, since the EndUpdate call might
|
|
|
|
// add more restyles.
|
|
|
|
mInStyleRefresh = false;
|
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
if (mInRebuildAllStyleData) {
|
|
|
|
FinishRebuildAllStyleData();
|
|
|
|
}
|
|
|
|
|
2013-07-31 00:36:08 +00:00
|
|
|
mPresContext->FrameConstructor()->EndUpdate();
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
mPresContext->PresShell()->VerifyStyleTree();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-07-25 04:35:34 +00:00
|
|
|
void
|
|
|
|
RestyleManager::UpdateOnlyAnimationStyles()
|
|
|
|
{
|
2014-07-25 04:35:34 +00:00
|
|
|
TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh();
|
2015-02-16 22:15:02 +00:00
|
|
|
bool doCSS = mLastUpdateForThrottledAnimations != now;
|
|
|
|
mLastUpdateForThrottledAnimations = now;
|
|
|
|
|
|
|
|
bool doSMIL = false;
|
|
|
|
nsIDocument* document = mPresContext->Document();
|
|
|
|
nsSMILAnimationController* animationController = nullptr;
|
|
|
|
if (document->HasAnimationController()) {
|
|
|
|
animationController = document->GetAnimationController();
|
|
|
|
// FIXME: Ideally, we only want to do this if animation timelines
|
|
|
|
// have advanced. However, different SMIL animations could be
|
|
|
|
// getting their time from different outermost SVG elements, so
|
|
|
|
// finding all of them might be a pain. So this could be optimized
|
|
|
|
// to set doSMIL to true in fewer cases.
|
|
|
|
doSMIL = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!doCSS && !doSMIL) {
|
2014-07-25 04:35:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-07 05:58:44 +00:00
|
|
|
nsTransitionManager* transitionManager = mPresContext->TransitionManager();
|
|
|
|
nsAnimationManager* animationManager = mPresContext->AnimationManager();
|
|
|
|
|
|
|
|
transitionManager->SetInAnimationOnlyStyleUpdate(true);
|
|
|
|
|
2014-08-07 05:58:44 +00:00
|
|
|
RestyleTracker tracker(ELEMENT_HAS_PENDING_ANIMATION_ONLY_RESTYLE |
|
|
|
|
ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT);
|
|
|
|
tracker.Init(this);
|
|
|
|
|
2015-02-16 22:15:02 +00:00
|
|
|
if (doCSS) {
|
|
|
|
// FIXME: We should have the transition manager and animation manager
|
|
|
|
// add only the elements for which animations are currently throttled
|
|
|
|
// (i.e., animating on the compositor with main-thread style updates
|
|
|
|
// suppressed).
|
|
|
|
transitionManager->AddStyleUpdatesTo(tracker);
|
|
|
|
animationManager->AddStyleUpdatesTo(tracker);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doSMIL) {
|
|
|
|
animationController->AddStyleUpdatesTo(tracker);
|
|
|
|
}
|
2014-08-07 05:58:44 +00:00
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
ProcessRestyles(tracker);
|
2014-08-07 05:58:44 +00:00
|
|
|
|
|
|
|
transitionManager->SetInAnimationOnlyStyleUpdate(false);
|
2014-07-25 04:35:34 +00:00
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
void
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-16 22:15:05 +00:00
|
|
|
RestyleManager::PostRestyleEvent(Element* aElement,
|
|
|
|
nsRestyleHint aRestyleHint,
|
|
|
|
nsChangeHint aMinChangeHint)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-16 22:15:05 +00:00
|
|
|
if (MOZ_UNLIKELY(!mPresContext) ||
|
|
|
|
MOZ_UNLIKELY(mPresContext->PresShell()->IsDestroying())) {
|
2013-07-20 19:14:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRestyleHint == 0 && !aMinChangeHint) {
|
|
|
|
// Nothing to do here
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-16 22:15:05 +00:00
|
|
|
mPendingRestyles.AddPendingRestyle(aElement, aRestyleHint, aMinChangeHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2015-02-16 22:15:02 +00:00
|
|
|
// Set mHavePendingNonAnimationRestyles for any restyle that could
|
2015-02-19 08:22:05 +00:00
|
|
|
// possibly contain non-animation styles (i.e., those that require us
|
|
|
|
// to do an animation-only style flush before processing style changes
|
|
|
|
// to ensure correct initialization of CSS transitions).
|
|
|
|
if (aRestyleHint & ~eRestyle_AllHintsWithAnimations) {
|
2015-02-16 22:15:02 +00:00
|
|
|
mHavePendingNonAnimationRestyles = true;
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
PostRestyleEventInternal(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::PostRestyleEventInternal(bool aForLazyConstruction)
|
|
|
|
{
|
|
|
|
// Make sure we're not in a style refresh; if we are, we still have
|
|
|
|
// a call to ProcessPendingRestyles coming and there's no need to
|
|
|
|
// add ourselves as a refresh observer until then.
|
|
|
|
bool inRefresh = !aForLazyConstruction && mInStyleRefresh;
|
|
|
|
nsIPresShell* presShell = mPresContext->PresShell();
|
|
|
|
if (!mObservingRefreshDriver && !inRefresh) {
|
|
|
|
mObservingRefreshDriver = mPresContext->RefreshDriver()->
|
|
|
|
AddStyleFlushObserver(presShell);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unconditionally flag our document as needing a flush. The other
|
|
|
|
// option here would be a dedicated boolean to track whether we need
|
|
|
|
// to do so (set here and unset in ProcessPendingRestyles).
|
|
|
|
presShell->GetDocument()->SetNeedStyleFlush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-10-08 21:27:02 +00:00
|
|
|
RestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
|
|
|
|
nsRestyleHint aRestyleHint)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!(aExtraHint & nsChangeHint_ReconstructFrame),
|
|
|
|
"Should not reconstruct the root of the frame tree. "
|
|
|
|
"Use ReconstructDocElementHierarchy instead.");
|
|
|
|
|
2015-01-14 05:03:11 +00:00
|
|
|
mDoRebuildAllStyleData = true;
|
2013-07-20 19:14:25 +00:00
|
|
|
NS_UpdateHint(mRebuildAllExtraHint, aExtraHint);
|
2014-10-08 21:27:02 +00:00
|
|
|
mRebuildAllRestyleHint |= aRestyleHint;
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
// Get a restyle event posted if necessary
|
|
|
|
PostRestyleEventInternal(false);
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
static void
|
|
|
|
DumpContext(nsIFrame* aFrame, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
if (aFrame) {
|
|
|
|
fputs("frame: ", stdout);
|
|
|
|
nsAutoString name;
|
|
|
|
aFrame->GetFrameName(name);
|
|
|
|
fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout);
|
|
|
|
fprintf(stdout, " (%p)", static_cast<void*>(aFrame));
|
|
|
|
}
|
|
|
|
if (aContext) {
|
|
|
|
fprintf(stdout, " style: %p ", static_cast<void*>(aContext));
|
|
|
|
|
|
|
|
nsIAtom* pseudoTag = aContext->GetPseudo();
|
|
|
|
if (pseudoTag) {
|
|
|
|
nsAutoString buffer;
|
|
|
|
pseudoTag->ToString(buffer);
|
|
|
|
fputs(NS_LossyConvertUTF16toASCII(buffer).get(), stdout);
|
|
|
|
fputs(" ", stdout);
|
|
|
|
}
|
|
|
|
fputs("{}\n", stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VerifySameTree(nsStyleContext* aContext1, nsStyleContext* aContext2)
|
|
|
|
{
|
|
|
|
nsStyleContext* top1 = aContext1;
|
|
|
|
nsStyleContext* top2 = aContext2;
|
|
|
|
nsStyleContext* parent;
|
|
|
|
for (;;) {
|
|
|
|
parent = top1->GetParent();
|
|
|
|
if (!parent)
|
|
|
|
break;
|
|
|
|
top1 = parent;
|
|
|
|
}
|
|
|
|
for (;;) {
|
|
|
|
parent = top2->GetParent();
|
|
|
|
if (!parent)
|
|
|
|
break;
|
|
|
|
top2 = parent;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(top1 == top2,
|
|
|
|
"Style contexts are not in the same style context tree");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VerifyContextParent(nsPresContext* aPresContext, nsIFrame* aFrame,
|
|
|
|
nsStyleContext* aContext, nsStyleContext* aParentContext)
|
|
|
|
{
|
|
|
|
// get the contexts not provided
|
|
|
|
if (!aContext) {
|
|
|
|
aContext = aFrame->StyleContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aParentContext) {
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIFrame* providerFrame;
|
|
|
|
aParentContext = aFrame->GetParentStyleContext(&providerFrame);
|
2013-07-20 19:14:25 +00:00
|
|
|
// aParentContext could still be null
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(aContext, "Failure to get required contexts");
|
|
|
|
nsStyleContext* actualParentContext = aContext->GetParent();
|
|
|
|
|
|
|
|
if (aParentContext) {
|
|
|
|
if (aParentContext != actualParentContext) {
|
|
|
|
DumpContext(aFrame, aContext);
|
|
|
|
if (aContext == aParentContext) {
|
|
|
|
NS_ERROR("Using parent's style context");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ERROR("Wrong parent style context");
|
|
|
|
fputs("Wrong parent style context: ", stdout);
|
|
|
|
DumpContext(nullptr, actualParentContext);
|
|
|
|
fputs("should be using: ", stdout);
|
|
|
|
DumpContext(nullptr, aParentContext);
|
|
|
|
VerifySameTree(actualParentContext, aParentContext);
|
|
|
|
fputs("\n", stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (actualParentContext) {
|
|
|
|
NS_ERROR("Have parent context and shouldn't");
|
|
|
|
DumpContext(aFrame, aContext);
|
|
|
|
fputs("Has parent context: ", stdout);
|
|
|
|
DumpContext(nullptr, actualParentContext);
|
|
|
|
fputs("Should be null\n\n", stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContext* childStyleIfVisited = aContext->GetStyleIfVisited();
|
|
|
|
// Either childStyleIfVisited has aContext->GetParent()->GetStyleIfVisited()
|
|
|
|
// as the parent or it has a different rulenode from aContext _and_ has
|
|
|
|
// aContext->GetParent() as the parent.
|
|
|
|
if (childStyleIfVisited &&
|
|
|
|
!((childStyleIfVisited->RuleNode() != aContext->RuleNode() &&
|
|
|
|
childStyleIfVisited->GetParent() == aContext->GetParent()) ||
|
|
|
|
childStyleIfVisited->GetParent() ==
|
|
|
|
aContext->GetParent()->GetStyleIfVisited())) {
|
|
|
|
NS_ERROR("Visited style has wrong parent");
|
|
|
|
DumpContext(aFrame, aContext);
|
|
|
|
fputs("\n", stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* aFrame,
|
|
|
|
nsStyleContext* aParentContext)
|
|
|
|
{
|
|
|
|
nsStyleContext* context = aFrame->StyleContext();
|
|
|
|
VerifyContextParent(aPresContext, aFrame, context, nullptr);
|
|
|
|
|
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
// only do frames that are in flow
|
|
|
|
if (nsGkAtoms::placeholderFrame == child->GetType()) {
|
|
|
|
// placeholder: first recurse and verify the out of flow frame,
|
|
|
|
// then verify the placeholder's context
|
|
|
|
nsIFrame* outOfFlowFrame =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
|
|
|
|
|
|
|
|
// recurse to out of flow frame, letting the parent context get resolved
|
|
|
|
do {
|
|
|
|
VerifyStyleTree(aPresContext, outOfFlowFrame, nullptr);
|
|
|
|
} while ((outOfFlowFrame = outOfFlowFrame->GetNextContinuation()));
|
|
|
|
|
|
|
|
// verify placeholder using the parent frame's context as
|
|
|
|
// parent context
|
|
|
|
VerifyContextParent(aPresContext, child, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
else { // regular frame
|
|
|
|
VerifyStyleTree(aPresContext, child, nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// do additional contexts
|
2013-07-31 00:36:11 +00:00
|
|
|
int32_t contextIndex = 0;
|
|
|
|
for (nsStyleContext* extraContext;
|
|
|
|
(extraContext = aFrame->GetAdditionalStyleContext(contextIndex));
|
|
|
|
++contextIndex) {
|
2013-07-31 00:36:12 +00:00
|
|
|
VerifyContextParent(aPresContext, aFrame, extraContext, context);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RestyleManager::DebugVerifyStyleTree(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (aFrame) {
|
|
|
|
nsStyleContext* context = aFrame->StyleContext();
|
|
|
|
nsStyleContext* parentContext = context->GetParent();
|
|
|
|
VerifyStyleTree(mPresContext, aFrame, parentContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
// aContent must be the content for the frame in question, which may be
|
|
|
|
// :before/:after content
|
2015-03-04 05:08:00 +00:00
|
|
|
/* static */ bool
|
2014-08-13 22:39:01 +00:00
|
|
|
RestyleManager::TryStartingTransition(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleContext* aOldStyleContext,
|
|
|
|
nsRefPtr<nsStyleContext>*
|
|
|
|
aNewStyleContext /* inout */)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
|
|
|
if (!aContent || !aContent->IsElement()) {
|
2015-03-04 05:08:00 +00:00
|
|
|
return false;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 22:15:02 +00:00
|
|
|
// Notify the transition manager. If it starts a transition,
|
|
|
|
// it might modify the new style context.
|
2015-03-04 05:08:00 +00:00
|
|
|
nsRefPtr<nsStyleContext> sc = *aNewStyleContext;
|
2015-02-16 22:15:02 +00:00
|
|
|
aPresContext->TransitionManager()->StyleContextChanged(
|
|
|
|
aContent->AsElement(), aOldStyleContext, aNewStyleContext);
|
2015-03-04 05:08:00 +00:00
|
|
|
return *aNewStyleContext != sc;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 22:15:05 +00:00
|
|
|
static dom::Element*
|
2013-07-20 19:14:25 +00:00
|
|
|
ElementForStyleContext(nsIContent* aParentContent,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsCSSPseudoElements::Type aPseudoType)
|
|
|
|
{
|
|
|
|
// We don't expect XUL tree stuff here.
|
|
|
|
NS_PRECONDITION(aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
|
|
|
|
aPseudoType == nsCSSPseudoElements::ePseudo_AnonBox ||
|
|
|
|
aPseudoType < nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"Unexpected pseudo");
|
|
|
|
// XXX see the comments about the various element confusion in
|
2013-07-31 00:36:09 +00:00
|
|
|
// ElementRestyler::Restyle.
|
2013-07-20 19:14:25 +00:00
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
|
|
|
return aFrame->GetContent()->AsElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLetter) {
|
|
|
|
NS_ASSERTION(aFrame->GetType() == nsGkAtoms::letterFrame,
|
|
|
|
"firstLetter pseudoTag without a nsFirstLetterFrame");
|
|
|
|
nsBlockFrame* block = nsBlockFrame::GetNearestAncestorBlock(aFrame);
|
|
|
|
return block->GetContent()->AsElement();
|
|
|
|
}
|
|
|
|
|
2013-10-22 15:29:20 +00:00
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_mozColorSwatch) {
|
|
|
|
MOZ_ASSERT(aFrame->GetParent() &&
|
|
|
|
aFrame->GetParent()->GetParent(),
|
|
|
|
"Color swatch frame should have a parent & grandparent");
|
|
|
|
|
|
|
|
nsIFrame* grandparentFrame = aFrame->GetParent()->GetParent();
|
|
|
|
MOZ_ASSERT(grandparentFrame->GetType() == nsGkAtoms::colorControlFrame,
|
|
|
|
"Color swatch's grandparent should be nsColorControlFrame");
|
|
|
|
|
|
|
|
return grandparentFrame->GetContent()->AsElement();
|
|
|
|
}
|
|
|
|
|
2013-09-04 10:30:36 +00:00
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberText ||
|
|
|
|
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberWrapper ||
|
|
|
|
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinBox ||
|
|
|
|
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinUp ||
|
|
|
|
aPseudoType == nsCSSPseudoElements::ePseudo_mozNumberSpinDown) {
|
|
|
|
// Get content for nearest nsNumberControlFrame:
|
|
|
|
nsIFrame* f = aFrame->GetParent();
|
|
|
|
MOZ_ASSERT(f);
|
|
|
|
while (f->GetType() != nsGkAtoms::numberControlFrame) {
|
|
|
|
f = f->GetParent();
|
|
|
|
MOZ_ASSERT(f);
|
|
|
|
}
|
|
|
|
return f->GetContent()->AsElement();
|
|
|
|
}
|
|
|
|
|
2013-11-28 01:22:20 +00:00
|
|
|
if (aParentContent) {
|
|
|
|
return aParentContent->AsElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(aFrame->GetContent()->GetParent(),
|
|
|
|
"should not have got here for the root element");
|
|
|
|
return aFrame->GetContent()->GetParent()->AsElement();
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 22:15:05 +00:00
|
|
|
/**
|
|
|
|
* Some pseudo-elements actually have a content node created for them,
|
|
|
|
* whereas others have only a frame but not a content node. In some
|
|
|
|
* cases, we want to support style attributes or states on those
|
|
|
|
* elements. For those pseudo-elements, we need to pass the
|
|
|
|
* anonymous pseudo-element content to selector matching processes in
|
|
|
|
* addition to the element that the pseudo-element is for; in other
|
|
|
|
* cases we should pass null instead. This function returns the
|
|
|
|
* pseudo-element content that we should pass.
|
|
|
|
*/
|
|
|
|
static dom::Element*
|
|
|
|
PseudoElementForStyleContext(nsIFrame* aFrame,
|
|
|
|
nsCSSPseudoElements::Type aPseudoType)
|
|
|
|
{
|
|
|
|
if (aPseudoType >= nsCSSPseudoElements::ePseudo_PseudoElementCount) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsCSSPseudoElements::PseudoElementSupportsStyleAttribute(aPseudoType) ||
|
|
|
|
nsCSSPseudoElements::PseudoElementSupportsUserActionState(aPseudoType)) {
|
|
|
|
return aFrame->GetContent()->AsElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
/**
|
|
|
|
* FIXME: Temporary. Should merge with following function.
|
|
|
|
*/
|
2013-07-20 19:14:25 +00:00
|
|
|
static nsIFrame*
|
|
|
|
GetPrevContinuationWithPossiblySameStyle(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
// Account for {ib} splits when looking for "prevContinuation". In
|
2014-02-07 01:45:33 +00:00
|
|
|
// particular, for the first-continuation of a part of an {ib} split
|
|
|
|
// we want to use the previous ib-split sibling of the previous
|
|
|
|
// ib-split sibling of aFrame, which should have the same style
|
|
|
|
// context as aFrame itself. In particular, if aFrame is the first
|
|
|
|
// continuation of an inline part of a block-in-inline split then its
|
|
|
|
// previous ib-split sibling is a block, and the previous ib-split
|
|
|
|
// sibling of _that_ is an inline, just like aFrame. Similarly, if
|
|
|
|
// aFrame is the first continuation of a block part of an
|
|
|
|
// block-in-inline split (a block-in-inline wrapper block), then its
|
|
|
|
// previous ib-split sibling is an inline and the previous ib-split
|
|
|
|
// sibling of that is either another block-in-inline wrapper block box
|
|
|
|
// or null.
|
2013-07-20 19:14:25 +00:00
|
|
|
nsIFrame *prevContinuation = aFrame->GetPrevContinuation();
|
2014-02-07 01:45:28 +00:00
|
|
|
if (!prevContinuation &&
|
|
|
|
(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) {
|
2013-07-20 19:14:25 +00:00
|
|
|
// We're the first continuation, so we can just get the frame
|
|
|
|
// property directly
|
|
|
|
prevContinuation = static_cast<nsIFrame*>(
|
2014-02-07 01:45:31 +00:00
|
|
|
aFrame->Properties().Get(nsIFrame::IBSplitPrevSibling()));
|
2013-07-20 19:14:25 +00:00
|
|
|
if (prevContinuation) {
|
|
|
|
prevContinuation = static_cast<nsIFrame*>(
|
2014-02-07 01:45:31 +00:00
|
|
|
prevContinuation->Properties().Get(nsIFrame::IBSplitPrevSibling()));
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-25 19:28:07 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(!prevContinuation ||
|
|
|
|
prevContinuation->GetContent() == aFrame->GetContent(),
|
|
|
|
"unexpected content mismatch");
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
return prevContinuation;
|
|
|
|
}
|
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
/**
|
2014-02-07 01:45:33 +00:00
|
|
|
* Get the previous continuation or similar ib-split sibling (assuming
|
2013-09-25 19:28:07 +00:00
|
|
|
* block/inline alternation), conditionally on it having the same style.
|
|
|
|
* This assumes that we're not between resolving the two (i.e., that
|
|
|
|
* they're both already resolved.
|
|
|
|
*/
|
|
|
|
static nsIFrame*
|
|
|
|
GetPrevContinuationWithSameStyle(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIFrame* prevContinuation = GetPrevContinuationWithPossiblySameStyle(aFrame);
|
|
|
|
if (!prevContinuation) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContext* prevStyle = prevContinuation->StyleContext();
|
|
|
|
nsStyleContext* selfStyle = aFrame->StyleContext();
|
|
|
|
if (prevStyle != selfStyle) {
|
|
|
|
NS_ASSERTION(prevStyle->GetPseudo() != selfStyle->GetPseudo() ||
|
|
|
|
prevStyle->GetParent() != selfStyle->GetParent(),
|
|
|
|
"continuations should have the same style context");
|
|
|
|
prevContinuation = nullptr;
|
|
|
|
}
|
|
|
|
return prevContinuation;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-02-07 01:45:33 +00:00
|
|
|
* Get the next continuation or similar ib-split sibling (assuming
|
2013-09-25 19:28:07 +00:00
|
|
|
* block/inline alternation), conditionally on it having the same style.
|
|
|
|
*
|
|
|
|
* Since this is used when deciding to copy the new style context, it
|
|
|
|
* takes as an argument the old style context to check if the style is
|
|
|
|
* the same. When it is used in other contexts (i.e., where the next
|
|
|
|
* continuation would already have the new style context), the current
|
|
|
|
* style context should be passed.
|
|
|
|
*/
|
|
|
|
static nsIFrame*
|
|
|
|
GetNextContinuationWithSameStyle(nsIFrame* aFrame,
|
2014-08-03 20:11:55 +00:00
|
|
|
nsStyleContext* aOldStyleContext,
|
|
|
|
bool* aHaveMoreContinuations = nullptr)
|
2013-09-25 19:28:07 +00:00
|
|
|
{
|
|
|
|
// See GetPrevContinuationWithSameStyle about {ib} splits.
|
|
|
|
|
|
|
|
nsIFrame *nextContinuation = aFrame->GetNextContinuation();
|
2014-02-07 01:45:28 +00:00
|
|
|
if (!nextContinuation &&
|
|
|
|
(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) {
|
2013-09-25 19:28:07 +00:00
|
|
|
// We're the last continuation, so we have to hop back to the first
|
|
|
|
// before getting the frame property
|
|
|
|
nextContinuation = static_cast<nsIFrame*>(aFrame->FirstContinuation()->
|
2014-02-07 01:45:30 +00:00
|
|
|
Properties().Get(nsIFrame::IBSplitSibling()));
|
2013-09-25 19:28:07 +00:00
|
|
|
if (nextContinuation) {
|
|
|
|
nextContinuation = static_cast<nsIFrame*>(
|
2014-02-07 01:45:30 +00:00
|
|
|
nextContinuation->Properties().Get(nsIFrame::IBSplitSibling()));
|
2013-09-25 19:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nextContinuation) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(nextContinuation->GetContent() == aFrame->GetContent(),
|
|
|
|
"unexpected content mismatch");
|
|
|
|
|
|
|
|
nsStyleContext* nextStyle = nextContinuation->StyleContext();
|
|
|
|
if (nextStyle != aOldStyleContext) {
|
|
|
|
NS_ASSERTION(aOldStyleContext->GetPseudo() != nextStyle->GetPseudo() ||
|
|
|
|
aOldStyleContext->GetParent() != nextStyle->GetParent(),
|
|
|
|
"continuations should have the same style context");
|
|
|
|
nextContinuation = nullptr;
|
2014-08-03 20:11:55 +00:00
|
|
|
if (aHaveMoreContinuations) {
|
|
|
|
*aHaveMoreContinuations = true;
|
|
|
|
}
|
2013-09-25 19:28:07 +00:00
|
|
|
}
|
|
|
|
return nextContinuation;
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
nsresult
|
|
|
|
RestyleManager::ReparentStyleContext(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (nsGkAtoms::placeholderFrame == aFrame->GetType()) {
|
|
|
|
// Also reparent the out-of-flow and all its continuations.
|
|
|
|
nsIFrame* outOfFlow =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(aFrame);
|
|
|
|
NS_ASSERTION(outOfFlow, "no out-of-flow frame");
|
|
|
|
do {
|
|
|
|
ReparentStyleContext(outOfFlow);
|
|
|
|
} while ((outOfFlow = outOfFlow->GetNextContinuation()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// DO NOT verify the style tree before reparenting. The frame
|
|
|
|
// tree has already been changed, so this check would just fail.
|
|
|
|
nsStyleContext* oldContext = aFrame->StyleContext();
|
2013-07-31 00:36:11 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
nsRefPtr<nsStyleContext> newContext;
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIFrame* providerFrame;
|
|
|
|
nsStyleContext* newParentContext = aFrame->GetParentStyleContext(&providerFrame);
|
2013-07-31 00:36:11 +00:00
|
|
|
bool isChild = providerFrame && providerFrame->GetParent() == aFrame;
|
|
|
|
nsIFrame* providerChild = nullptr;
|
|
|
|
if (isChild) {
|
|
|
|
ReparentStyleContext(providerFrame);
|
2014-11-20 18:24:10 +00:00
|
|
|
// Get the style context again after ReparentStyleContext() which might have
|
|
|
|
// changed it.
|
2013-07-31 00:36:11 +00:00
|
|
|
newParentContext = providerFrame->StyleContext();
|
|
|
|
providerChild = providerFrame;
|
|
|
|
}
|
2014-11-20 18:24:10 +00:00
|
|
|
NS_ASSERTION(newParentContext, "Reparenting something that has no usable"
|
|
|
|
" parent? Shouldn't happen!");
|
2013-07-31 00:36:11 +00:00
|
|
|
// XXX need to do something here to produce the correct style context for
|
|
|
|
// an IB split whose first inline part is inside a first-line frame.
|
|
|
|
// Currently the first IB anonymous block's style context takes the first
|
|
|
|
// part's style context as parent, which is wrong since first-line style
|
|
|
|
// should not apply to the anonymous block.
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-07-31 00:36:11 +00:00
|
|
|
{
|
|
|
|
// Check that our assumption that continuations of the same
|
|
|
|
// pseudo-type and with the same style context parent have the
|
|
|
|
// same style context is valid before the reresolution. (We need
|
|
|
|
// to check the pseudo-type and style context parent because of
|
|
|
|
// :first-letter and :first-line, where we create styled and
|
|
|
|
// unstyled letter/line frames distinguished by pseudo-type, and
|
|
|
|
// then need to distinguish their descendants based on having
|
|
|
|
// different parents.)
|
|
|
|
nsIFrame *nextContinuation = aFrame->GetNextContinuation();
|
|
|
|
if (nextContinuation) {
|
|
|
|
nsStyleContext *nextContinuationContext =
|
|
|
|
nextContinuation->StyleContext();
|
|
|
|
NS_ASSERTION(oldContext == nextContinuationContext ||
|
|
|
|
oldContext->GetPseudo() !=
|
|
|
|
nextContinuationContext->GetPseudo() ||
|
|
|
|
oldContext->GetParent() !=
|
|
|
|
nextContinuationContext->GetParent(),
|
|
|
|
"continuations should have the same style context");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
nsIFrame *prevContinuation =
|
|
|
|
GetPrevContinuationWithPossiblySameStyle(aFrame);
|
|
|
|
nsStyleContext *prevContinuationContext;
|
|
|
|
bool copyFromContinuation =
|
|
|
|
prevContinuation &&
|
|
|
|
(prevContinuationContext = prevContinuation->StyleContext())
|
|
|
|
->GetPseudo() == oldContext->GetPseudo() &&
|
|
|
|
prevContinuationContext->GetParent() == newParentContext;
|
|
|
|
if (copyFromContinuation) {
|
|
|
|
// Just use the style context from the frame's previous
|
|
|
|
// continuation (see assertion about aFrame->GetNextContinuation()
|
|
|
|
// above, which we would have previously hit for aFrame's previous
|
|
|
|
// continuation).
|
|
|
|
newContext = prevContinuationContext;
|
|
|
|
} else {
|
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
|
|
|
Element* element =
|
|
|
|
ElementForStyleContext(parentFrame ? parentFrame->GetContent() : nullptr,
|
|
|
|
aFrame,
|
|
|
|
oldContext->GetPseudoType());
|
|
|
|
newContext = mPresContext->StyleSet()->
|
2015-02-16 22:15:05 +00:00
|
|
|
ReparentStyleContext(oldContext, newParentContext, element);
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (newContext) {
|
|
|
|
if (newContext != oldContext) {
|
|
|
|
// We probably don't want to initiate transitions from
|
|
|
|
// ReparentStyleContext, since we call it during frame
|
|
|
|
// construction rather than in response to dynamic changes.
|
|
|
|
// Also see the comment at the start of
|
|
|
|
// nsTransitionManager::ConsiderStartingTransition.
|
2013-07-20 19:14:25 +00:00
|
|
|
#if 0
|
2013-07-31 00:36:11 +00:00
|
|
|
if (!copyFromContinuation) {
|
|
|
|
TryStartingTransition(mPresContext, aFrame->GetContent(),
|
|
|
|
oldContext, &newContext);
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
// Make sure to call CalcStyleDifference so that the new context ends
|
|
|
|
// up resolving all the structs the old context resolved.
|
2013-09-25 19:28:08 +00:00
|
|
|
if (!copyFromContinuation) {
|
2014-09-05 03:48:44 +00:00
|
|
|
uint32_t equalStructs;
|
2013-09-25 19:28:08 +00:00
|
|
|
DebugOnly<nsChangeHint> styleChange =
|
2014-09-05 03:48:44 +00:00
|
|
|
oldContext->CalcStyleDifference(newContext, nsChangeHint(0),
|
|
|
|
&equalStructs);
|
2013-09-25 19:28:08 +00:00
|
|
|
// The style change is always 0 because we have the same rulenode and
|
|
|
|
// CalcStyleDifference optimizes us away. That's OK, though:
|
|
|
|
// reparenting should never trigger a frame reconstruct, and whenever
|
|
|
|
// it's happening we already plan to reflow and repaint the frames.
|
|
|
|
NS_ASSERTION(!(styleChange & nsChangeHint_ReconstructFrame),
|
|
|
|
"Our frame tree is likely to be bogus!");
|
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
|
|
|
|
aFrame->SetStyleContext(newContext);
|
|
|
|
|
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
|
|
|
// only do frames that are in flow
|
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
|
|
|
child != providerChild) {
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef DEBUG
|
2013-07-31 00:36:11 +00:00
|
|
|
if (nsGkAtoms::placeholderFrame == child->GetType()) {
|
|
|
|
nsIFrame* outOfFlowFrame =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
|
|
|
|
NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
|
|
|
|
|
|
|
|
NS_ASSERTION(outOfFlowFrame != providerChild,
|
|
|
|
"Out of flow provider?");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
#endif
|
|
|
|
ReparentStyleContext(child);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
// If this frame is part of an IB split, then the style context of
|
|
|
|
// the next part of the split might be a child of our style context.
|
|
|
|
// Reparent its style context just in case one of our ancestors
|
|
|
|
// (split or not) hasn't done so already). It's not a problem to
|
|
|
|
// reparent the same frame twice because the "if (newContext !=
|
|
|
|
// oldContext)" check will prevent us from redoing work.
|
2014-02-07 01:45:28 +00:00
|
|
|
if ((aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) &&
|
2013-07-31 00:36:11 +00:00
|
|
|
!aFrame->GetPrevContinuation()) {
|
|
|
|
nsIFrame* sib = static_cast<nsIFrame*>
|
2014-02-07 01:45:30 +00:00
|
|
|
(aFrame->Properties().Get(nsIFrame::IBSplitSibling()));
|
2013-07-31 00:36:11 +00:00
|
|
|
if (sib) {
|
|
|
|
ReparentStyleContext(sib);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
// do additional contexts
|
2013-07-31 00:36:11 +00:00
|
|
|
int32_t contextIndex = 0;
|
|
|
|
for (nsStyleContext* oldExtraContext;
|
|
|
|
(oldExtraContext = aFrame->GetAdditionalStyleContext(contextIndex));
|
|
|
|
++contextIndex) {
|
2013-07-31 00:36:12 +00:00
|
|
|
nsRefPtr<nsStyleContext> newExtraContext;
|
|
|
|
newExtraContext = mPresContext->StyleSet()->
|
|
|
|
ReparentStyleContext(oldExtraContext,
|
2015-02-16 22:15:05 +00:00
|
|
|
newContext, nullptr);
|
2013-07-31 00:36:12 +00:00
|
|
|
if (newExtraContext) {
|
|
|
|
if (newExtraContext != oldExtraContext) {
|
|
|
|
// Make sure to call CalcStyleDifference so that the new
|
|
|
|
// context ends up resolving all the structs the old context
|
|
|
|
// resolved.
|
2014-09-05 03:48:44 +00:00
|
|
|
uint32_t equalStructs;
|
2013-09-25 19:28:08 +00:00
|
|
|
DebugOnly<nsChangeHint> styleChange =
|
2013-07-31 00:36:12 +00:00
|
|
|
oldExtraContext->CalcStyleDifference(newExtraContext,
|
2014-09-05 03:48:44 +00:00
|
|
|
nsChangeHint(0),
|
|
|
|
&equalStructs);
|
2013-07-31 00:36:12 +00:00
|
|
|
// The style change is always 0 because we have the same
|
|
|
|
// rulenode and CalcStyleDifference optimizes us away. That's
|
|
|
|
// OK, though: reparenting should never trigger a frame
|
|
|
|
// reconstruct, and whenever it's happening we already plan to
|
|
|
|
// reflow and repaint the frames.
|
|
|
|
NS_ASSERTION(!(styleChange & nsChangeHint_ReconstructFrame),
|
|
|
|
"Our frame tree is likely to be bogus!");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
|
|
|
|
aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext);
|
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef DEBUG
|
2013-07-31 00:36:11 +00:00
|
|
|
VerifyStyleTree(mPresContext, aFrame, newParentContext);
|
2013-07-20 19:14:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
ElementRestyler::ElementRestyler(nsPresContext* aPresContext,
|
2013-07-31 00:36:09 +00:00
|
|
|
nsIFrame* aFrame,
|
2013-07-31 00:36:10 +00:00
|
|
|
nsStyleChangeList* aChangeList,
|
2013-07-31 00:36:10 +00:00
|
|
|
nsChangeHint aHintsHandledByAncestors,
|
2013-07-31 00:36:10 +00:00
|
|
|
RestyleTracker& aRestyleTracker,
|
2013-07-31 00:36:10 +00:00
|
|
|
TreeMatchContext& aTreeMatchContext,
|
2013-07-31 00:36:10 +00:00
|
|
|
nsTArray<nsIContent*>&
|
2015-02-17 22:28:53 +00:00
|
|
|
aVisibleKidsOfHiddenElement,
|
|
|
|
nsTArray<ContextToClear>& aContextsToClear,
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>>&
|
|
|
|
aSwappedStructOwners)
|
2013-07-31 00:36:09 +00:00
|
|
|
: mPresContext(aPresContext)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mFrame(aFrame)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mParentContent(nullptr)
|
|
|
|
// XXXldb Why does it make sense to use aParentContent? (See
|
|
|
|
// comment above assertion at start of ElementRestyler::Restyle.)
|
|
|
|
, mContent(mFrame->GetContent() ? mFrame->GetContent() : mParentContent)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mChangeList(aChangeList)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mHintsHandled(NS_SubtractHint(aHintsHandledByAncestors,
|
|
|
|
NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors)))
|
2013-07-31 00:36:10 +00:00
|
|
|
, mParentFrameHintsNotHandledForDescendants(nsChangeHint(0))
|
|
|
|
, mHintsNotHandledForDescendants(nsChangeHint(0))
|
2013-07-31 00:36:10 +00:00
|
|
|
, mRestyleTracker(aRestyleTracker)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mTreeMatchContext(aTreeMatchContext)
|
2013-07-31 00:36:11 +00:00
|
|
|
, mResolvedChild(nullptr)
|
2015-02-17 22:28:53 +00:00
|
|
|
, mContextsToClear(aContextsToClear)
|
|
|
|
, mSwappedStructOwners(aSwappedStructOwners)
|
2013-08-01 02:15:19 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2013-07-31 00:36:10 +00:00
|
|
|
, mDesiredA11yNotifications(eSendAllNotifications)
|
|
|
|
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications)
|
|
|
|
, mOurA11yNotification(eDontNotify)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mVisibleKidsOfHiddenElement(aVisibleKidsOfHiddenElement)
|
2013-08-01 02:15:19 +00:00
|
|
|
#endif
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
, mLoggingDepth(aRestyleTracker.LoggingDepth() + 1)
|
|
|
|
#endif
|
2013-07-31 00:36:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
ElementRestyler::ElementRestyler(const ElementRestyler& aParentRestyler,
|
2013-07-31 00:36:10 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint32_t aConstructorFlags)
|
2013-07-31 00:36:09 +00:00
|
|
|
: mPresContext(aParentRestyler.mPresContext)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mFrame(aFrame)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mParentContent(aParentRestyler.mContent)
|
|
|
|
// XXXldb Why does it make sense to use aParentContent? (See
|
|
|
|
// comment above assertion at start of ElementRestyler::Restyle.)
|
|
|
|
, mContent(mFrame->GetContent() ? mFrame->GetContent() : mParentContent)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mChangeList(aParentRestyler.mChangeList)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mHintsHandled(NS_SubtractHint(aParentRestyler.mHintsHandled,
|
|
|
|
NS_HintsNotHandledForDescendantsIn(aParentRestyler.mHintsHandled)))
|
2013-07-31 00:36:10 +00:00
|
|
|
, mParentFrameHintsNotHandledForDescendants(
|
|
|
|
aParentRestyler.mHintsNotHandledForDescendants)
|
|
|
|
, mHintsNotHandledForDescendants(nsChangeHint(0))
|
2013-07-31 00:36:10 +00:00
|
|
|
, mRestyleTracker(aParentRestyler.mRestyleTracker)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mTreeMatchContext(aParentRestyler.mTreeMatchContext)
|
2013-07-31 00:36:11 +00:00
|
|
|
, mResolvedChild(nullptr)
|
2015-02-17 22:28:53 +00:00
|
|
|
, mContextsToClear(aParentRestyler.mContextsToClear)
|
|
|
|
, mSwappedStructOwners(aParentRestyler.mSwappedStructOwners)
|
2013-08-01 02:15:19 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2013-07-31 00:36:10 +00:00
|
|
|
, mDesiredA11yNotifications(aParentRestyler.mKidsDesiredA11yNotifications)
|
|
|
|
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications)
|
|
|
|
, mOurA11yNotification(eDontNotify)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement)
|
2013-08-01 02:15:19 +00:00
|
|
|
#endif
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
, mLoggingDepth(aParentRestyler.mLoggingDepth + 1)
|
|
|
|
#endif
|
2013-07-31 00:36:09 +00:00
|
|
|
{
|
2013-07-31 00:36:10 +00:00
|
|
|
if (aConstructorFlags & FOR_OUT_OF_FLOW_CHILD) {
|
2013-09-25 19:28:07 +00:00
|
|
|
// Note that the out-of-flow may not be a geometric descendant of
|
|
|
|
// the frame where we started the reresolve. Therefore, even if
|
|
|
|
// mHintsHandled already includes nsChangeHint_AllReflowHints we
|
|
|
|
// don't want to pass that on to the out-of-flow reresolve, since
|
|
|
|
// that can lead to the out-of-flow not getting reflowed when it
|
|
|
|
// should be (eg a reresolve starting at <body> that involves
|
|
|
|
// reflowing the <body> would miss reflowing fixed-pos nodes that
|
|
|
|
// also need reflow). In the cases when the out-of-flow _is_ a
|
|
|
|
// geometric descendant of a frame we already have a reflow hint
|
|
|
|
// for, reflow coalescing should keep us from doing the work twice.
|
2013-07-31 00:36:10 +00:00
|
|
|
mHintsHandled = NS_SubtractHint(mHintsHandled, nsChangeHint_AllReflowHints);
|
|
|
|
}
|
2013-07-31 00:36:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ElementRestyler::ElementRestyler(ParentContextFromChildFrame,
|
2013-07-31 00:36:09 +00:00
|
|
|
const ElementRestyler& aParentRestyler,
|
|
|
|
nsIFrame* aFrame)
|
2013-07-31 00:36:09 +00:00
|
|
|
: mPresContext(aParentRestyler.mPresContext)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mFrame(aFrame)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mParentContent(aParentRestyler.mParentContent)
|
|
|
|
// XXXldb Why does it make sense to use aParentContent? (See
|
|
|
|
// comment above assertion at start of ElementRestyler::Restyle.)
|
|
|
|
, mContent(mFrame->GetContent() ? mFrame->GetContent() : mParentContent)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mChangeList(aParentRestyler.mChangeList)
|
2013-07-31 00:36:09 +00:00
|
|
|
, mHintsHandled(NS_SubtractHint(aParentRestyler.mHintsHandled,
|
|
|
|
NS_HintsNotHandledForDescendantsIn(aParentRestyler.mHintsHandled)))
|
2013-07-31 00:36:10 +00:00
|
|
|
, mParentFrameHintsNotHandledForDescendants(
|
|
|
|
// assume the worst
|
|
|
|
nsChangeHint_Hints_NotHandledForDescendants)
|
|
|
|
, mHintsNotHandledForDescendants(nsChangeHint(0))
|
2013-07-31 00:36:10 +00:00
|
|
|
, mRestyleTracker(aParentRestyler.mRestyleTracker)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mTreeMatchContext(aParentRestyler.mTreeMatchContext)
|
2013-07-31 00:36:11 +00:00
|
|
|
, mResolvedChild(nullptr)
|
2015-02-17 22:28:53 +00:00
|
|
|
, mContextsToClear(aParentRestyler.mContextsToClear)
|
|
|
|
, mSwappedStructOwners(aParentRestyler.mSwappedStructOwners)
|
2013-08-01 02:15:19 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2013-07-31 00:36:10 +00:00
|
|
|
, mDesiredA11yNotifications(aParentRestyler.mDesiredA11yNotifications)
|
|
|
|
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications)
|
|
|
|
, mOurA11yNotification(eDontNotify)
|
2013-07-31 00:36:10 +00:00
|
|
|
, mVisibleKidsOfHiddenElement(aParentRestyler.mVisibleKidsOfHiddenElement)
|
2013-08-01 02:15:19 +00:00
|
|
|
#endif
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
, mLoggingDepth(aParentRestyler.mLoggingDepth + 1)
|
|
|
|
#endif
|
2013-07-31 00:36:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
ElementRestyler::ElementRestyler(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleChangeList* aChangeList,
|
|
|
|
nsChangeHint aHintsHandledByAncestors,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
TreeMatchContext& aTreeMatchContext,
|
|
|
|
nsTArray<nsIContent*>&
|
2015-02-17 22:28:53 +00:00
|
|
|
aVisibleKidsOfHiddenElement,
|
|
|
|
nsTArray<ContextToClear>& aContextsToClear,
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>>&
|
|
|
|
aSwappedStructOwners)
|
2014-11-20 18:24:10 +00:00
|
|
|
: mPresContext(aPresContext)
|
|
|
|
, mFrame(nullptr)
|
|
|
|
, mParentContent(nullptr)
|
|
|
|
, mContent(aContent)
|
|
|
|
, mChangeList(aChangeList)
|
|
|
|
, mHintsHandled(NS_SubtractHint(aHintsHandledByAncestors,
|
|
|
|
NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors)))
|
|
|
|
, mParentFrameHintsNotHandledForDescendants(nsChangeHint(0))
|
|
|
|
, mHintsNotHandledForDescendants(nsChangeHint(0))
|
|
|
|
, mRestyleTracker(aRestyleTracker)
|
|
|
|
, mTreeMatchContext(aTreeMatchContext)
|
|
|
|
, mResolvedChild(nullptr)
|
2015-02-17 22:28:53 +00:00
|
|
|
, mContextsToClear(aContextsToClear)
|
|
|
|
, mSwappedStructOwners(aSwappedStructOwners)
|
2014-11-20 18:24:10 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
, mDesiredA11yNotifications(eSendAllNotifications)
|
|
|
|
, mKidsDesiredA11yNotifications(mDesiredA11yNotifications)
|
|
|
|
, mOurA11yNotification(eDontNotify)
|
|
|
|
, mVisibleKidsOfHiddenElement(aVisibleKidsOfHiddenElement)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-11-17 04:46:00 +00:00
|
|
|
void
|
|
|
|
ElementRestyler::AddLayerChangesForAnimation()
|
|
|
|
{
|
|
|
|
// Bug 847286 - We should have separate animation generation counters
|
|
|
|
// on layers for transitions and animations and use != comparison below
|
|
|
|
// rather than a > comparison.
|
|
|
|
uint64_t frameGeneration =
|
|
|
|
RestyleManager::GetMaxAnimationGenerationForFrame(mFrame);
|
|
|
|
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2014-11-17 04:46:00 +00:00
|
|
|
const auto& layerInfo = css::CommonAnimationManager::sLayerAnimationInfo;
|
|
|
|
for (size_t i = 0; i < ArrayLength(layerInfo); i++) {
|
2014-11-17 04:46:00 +00:00
|
|
|
Layer* layer =
|
2014-11-17 04:46:00 +00:00
|
|
|
FrameLayerBuilder::GetDedicatedLayer(mFrame, layerInfo[i].mLayerType);
|
2014-11-17 04:46:00 +00:00
|
|
|
if (layer && frameGeneration > layer->GetAnimationGeneration()) {
|
|
|
|
// If we have a transform layer but don't have any transform style, we
|
|
|
|
// probably just removed the transform but haven't destroyed the layer
|
|
|
|
// yet. In this case we will add the appropriate change hint
|
|
|
|
// (nsChangeHint_AddOrRemoveTransform) when we compare style contexts
|
|
|
|
// so we can skip adding any change hint here. (If we *were* to add
|
|
|
|
// nsChangeHint_UpdateTransformLayer, ApplyRenderingChangeToTree would
|
|
|
|
// complain that we're updating a transform layer without a transform).
|
2014-11-17 04:46:00 +00:00
|
|
|
if (layerInfo[i].mLayerType == nsDisplayItem::TYPE_TRANSFORM &&
|
2015-03-20 04:12:17 +00:00
|
|
|
!mFrame->StyleDisplay()->HasTransformStyle()) {
|
2014-11-17 04:46:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
2014-11-17 04:46:00 +00:00
|
|
|
NS_UpdateHint(hint, layerInfo[i].mChangeHint);
|
2014-11-17 04:46:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hint) {
|
|
|
|
mChangeList->AppendChange(mFrame, mContent, hint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
void
|
|
|
|
ElementRestyler::CaptureChange(nsStyleContext* aOldContext,
|
|
|
|
nsStyleContext* aNewContext,
|
2014-09-05 03:48:45 +00:00
|
|
|
nsChangeHint aChangeToAssume,
|
|
|
|
uint32_t* aEqualStructs)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
2014-09-05 03:48:45 +00:00
|
|
|
static_assert(nsStyleStructID_Length <= 32,
|
|
|
|
"aEqualStructs is not big enough");
|
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
// Check some invariants about replacing one style context with another.
|
|
|
|
NS_ASSERTION(aOldContext->GetPseudo() == aNewContext->GetPseudo(),
|
|
|
|
"old and new style contexts should have the same pseudo");
|
|
|
|
NS_ASSERTION(aOldContext->GetPseudoType() == aNewContext->GetPseudoType(),
|
|
|
|
"old and new style contexts should have the same pseudo");
|
|
|
|
|
2014-09-05 03:48:44 +00:00
|
|
|
nsChangeHint ourChange =
|
|
|
|
aOldContext->CalcStyleDifference(aNewContext,
|
|
|
|
mParentFrameHintsNotHandledForDescendants,
|
2014-09-05 03:48:45 +00:00
|
|
|
aEqualStructs);
|
2013-07-20 19:14:25 +00:00
|
|
|
NS_ASSERTION(!(ourChange & nsChangeHint_AllReflowHints) ||
|
|
|
|
(ourChange & nsChangeHint_NeedReflow),
|
|
|
|
"Reflow hint bits set without actually asking for a reflow");
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("CaptureChange, ourChange = %s, aChangeToAssume = %s",
|
|
|
|
RestyleManager::ChangeHintToString(ourChange).get(),
|
|
|
|
RestyleManager::ChangeHintToString(aChangeToAssume).get());
|
|
|
|
LOG_RESTYLE_INDENT();
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// nsChangeHint_UpdateEffects is inherited, but it can be set due to changes
|
|
|
|
// in inherited properties (fill and stroke). Avoid propagating it into
|
|
|
|
// text nodes.
|
|
|
|
if ((ourChange & nsChangeHint_UpdateEffects) &&
|
2013-07-31 00:36:09 +00:00
|
|
|
mContent && !mContent->IsElement()) {
|
2013-07-20 19:14:25 +00:00
|
|
|
ourChange = NS_SubtractHint(ourChange, nsChangeHint_UpdateEffects);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_UpdateHint(ourChange, aChangeToAssume);
|
2013-07-31 00:36:09 +00:00
|
|
|
if (NS_UpdateHint(mHintsHandled, ourChange)) {
|
2013-07-31 00:36:09 +00:00
|
|
|
if (!(ourChange & nsChangeHint_ReconstructFrame) || mContent) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("appending change %s",
|
|
|
|
RestyleManager::ChangeHintToString(ourChange).get());
|
2013-09-25 19:28:08 +00:00
|
|
|
mChangeList->AppendChange(mFrame, mContent, ourChange);
|
2014-09-25 05:45:36 +00:00
|
|
|
} else {
|
|
|
|
LOG_RESTYLE("change has already been handled");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:10 +00:00
|
|
|
NS_UpdateHint(mHintsNotHandledForDescendants,
|
|
|
|
NS_HintsNotHandledForDescendantsIn(ourChange));
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("mHintsNotHandledForDescendants = %s",
|
|
|
|
RestyleManager::ChangeHintToString(mHintsNotHandledForDescendants).get());
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-25 19:28:07 +00:00
|
|
|
* Recompute style for mFrame (which should not have a prev continuation
|
|
|
|
* with the same style), all of its next continuations with the same
|
2014-02-07 01:45:33 +00:00
|
|
|
* style, and all ib-split siblings of the same type (either block or
|
2013-09-25 19:28:07 +00:00
|
|
|
* inline, skipping the intermediates of the other type) and accumulate
|
|
|
|
* changes into mChangeList given that mHintsHandled is already accumulated
|
|
|
|
* for an ancestor.
|
2013-07-31 00:36:09 +00:00
|
|
|
* mParentContent is the content node used to resolve the parent style
|
2013-07-20 19:14:25 +00:00
|
|
|
* context. This means that, for pseudo-elements, it is the content
|
|
|
|
* that should be used for selector matching (rather than the fake
|
|
|
|
* content node attached to the frame).
|
|
|
|
*/
|
2013-07-31 00:36:09 +00:00
|
|
|
void
|
2013-07-31 00:36:10 +00:00
|
|
|
ElementRestyler::Restyle(nsRestyleHint aRestyleHint)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
|
|
|
// It would be nice if we could make stronger assertions here; they
|
|
|
|
// would let us simplify the ?: expressions below setting |content|
|
|
|
|
// and |pseudoContent| in sensible ways as well as making what
|
2013-07-31 00:36:09 +00:00
|
|
|
// |content| and |pseudoContent| mean, and their relationship to
|
|
|
|
// |mFrame->GetContent()|, make more sense. However, we can't,
|
|
|
|
// because of frame trees like the one in
|
2013-07-20 19:14:25 +00:00
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=472353#c14 . Once we
|
|
|
|
// fix bug 242277 we should be able to make this make more sense.
|
2013-07-31 00:36:09 +00:00
|
|
|
NS_ASSERTION(mFrame->GetContent() || !mParentContent ||
|
|
|
|
!mParentContent->GetParent(),
|
2013-07-20 19:14:25 +00:00
|
|
|
"frame must have content (unless at the top of the tree)");
|
2013-07-31 00:36:11 +00:00
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
NS_ASSERTION(!GetPrevContinuationWithSameStyle(mFrame),
|
|
|
|
"should not be trying to restyle this frame separately");
|
|
|
|
|
2014-06-19 00:07:26 +00:00
|
|
|
MOZ_ASSERT(!(aRestyleHint & eRestyle_LaterSiblings),
|
|
|
|
"eRestyle_LaterSiblings must not be part of aRestyleHint");
|
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
AutoDisplayContentsAncestorPusher adcp(mTreeMatchContext, mFrame->PresContext(),
|
|
|
|
mFrame->GetContent() ? mFrame->GetContent()->GetParent() : nullptr);
|
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
// List of descendant elements of mContent we know we will eventually need to
|
|
|
|
// restyle. Before we return from this function, we call
|
|
|
|
// RestyleTracker::AddRestyleRootsIfAwaitingRestyle to ensure they get
|
|
|
|
// restyled in RestyleTracker::DoProcessRestyles.
|
|
|
|
nsTArray<nsRefPtr<Element>> descendants;
|
|
|
|
|
2014-08-03 20:11:55 +00:00
|
|
|
nsRestyleHint hintToRestore = nsRestyleHint(0);
|
2014-08-03 20:11:55 +00:00
|
|
|
if (mContent && mContent->IsElement() &&
|
2014-12-25 07:28:25 +00:00
|
|
|
// If we're resolving from the root of the frame tree (which
|
2015-01-14 05:03:12 +00:00
|
|
|
// we do when mDoRebuildAllStyleData), we need to avoid getting the
|
2014-08-03 20:11:55 +00:00
|
|
|
// root's restyle data until we get to its primary frame, since
|
|
|
|
// it's the primary frame that has the styles for the root element
|
|
|
|
// (rather than the ancestors of the primary frame whose mContent
|
|
|
|
// is the root node but which have different styles). If we use
|
|
|
|
// up the hint for one of the ancestors that we hit first, then
|
|
|
|
// we'll fail to do the restyling we need to do.
|
2015-02-16 22:15:04 +00:00
|
|
|
// Likewise, if we're restyling something with two nested frames,
|
|
|
|
// and we post a restyle from the transition manager while
|
|
|
|
// computing style for the outer frame (to be computed after the
|
|
|
|
// descendants have been resolved), we don't want to consume it
|
|
|
|
// for the inner frame.
|
|
|
|
mContent->GetPrimaryFrame() == mFrame) {
|
2013-07-31 00:36:11 +00:00
|
|
|
mContent->OwnerDoc()->FlushPendingLinkUpdates();
|
2014-09-05 03:48:48 +00:00
|
|
|
nsAutoPtr<RestyleTracker::RestyleData> restyleData;
|
|
|
|
if (mRestyleTracker.GetRestyleData(mContent->AsElement(), restyleData)) {
|
|
|
|
if (NS_UpdateHint(mHintsHandled, restyleData->mChangeHint)) {
|
|
|
|
mChangeList->AppendChange(mFrame, mContent, restyleData->mChangeHint);
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2014-09-05 03:48:48 +00:00
|
|
|
hintToRestore = restyleData->mRestyleHint;
|
|
|
|
aRestyleHint = nsRestyleHint(aRestyleHint | restyleData->mRestyleHint);
|
|
|
|
descendants.SwapElements(restyleData->mDescendants);
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-13 07:28:52 +00:00
|
|
|
// If we are restyling this frame with eRestyle_Self or weaker hints,
|
|
|
|
// we restyle children with nsRestyleHint(0). But we pass the
|
2015-02-16 22:15:06 +00:00
|
|
|
// eRestyle_ForceDescendants flag down too.
|
2014-09-05 03:48:45 +00:00
|
|
|
nsRestyleHint childRestyleHint =
|
|
|
|
nsRestyleHint(aRestyleHint & (eRestyle_Subtree |
|
|
|
|
eRestyle_ForceDescendants));
|
2013-07-31 00:36:11 +00:00
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
nsRefPtr<nsStyleContext> oldContext = mFrame->StyleContext();
|
|
|
|
|
|
|
|
// TEMPORARY (until bug 918064): Call RestyleSelf for each
|
|
|
|
// continuation or block-in-inline sibling.
|
|
|
|
|
|
|
|
// We must make a single decision on how to process this frame and
|
|
|
|
// its descendants, yet RestyleSelf might return different RestyleResult
|
|
|
|
// values for the different same-style continuations. |result| is our
|
|
|
|
// overall decision.
|
|
|
|
RestyleResult result = RestyleResult(0);
|
|
|
|
uint32_t swappedStructs = 0;
|
|
|
|
|
|
|
|
nsRestyleHint thisRestyleHint = aRestyleHint;
|
|
|
|
|
|
|
|
bool haveMoreContinuations = false;
|
|
|
|
for (nsIFrame* f = mFrame; f; ) {
|
2014-09-25 05:30:18 +00:00
|
|
|
RestyleResult thisResult = RestyleSelf(f, thisRestyleHint, &swappedStructs);
|
2014-09-05 03:48:45 +00:00
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
if (thisResult != eRestyleResult_Stop) {
|
|
|
|
// Calls to RestyleSelf for later same-style continuations must not
|
|
|
|
// return eRestyleResult_Stop, so pass eRestyle_Force in to them.
|
|
|
|
thisRestyleHint = nsRestyleHint(thisRestyleHint | eRestyle_Force);
|
|
|
|
|
|
|
|
if (result == eRestyleResult_Stop) {
|
|
|
|
// We received eRestyleResult_Stop for earlier same-style
|
|
|
|
// continuations, and eRestyleResult_Continue(AndForceDescendants) for
|
|
|
|
// this one; go back and force-restyle the earlier continuations.
|
2014-09-05 03:48:45 +00:00
|
|
|
result = thisResult;
|
2014-09-05 03:48:47 +00:00
|
|
|
f = mFrame;
|
|
|
|
continue;
|
2014-09-05 03:48:45 +00:00
|
|
|
}
|
2014-09-05 03:48:47 +00:00
|
|
|
}
|
2014-09-05 03:48:46 +00:00
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
if (thisResult > result) {
|
|
|
|
// We take the highest RestyleResult value when working out what to do
|
|
|
|
// with this frame and its descendants. Higher RestyleResult values
|
|
|
|
// represent a superset of the work done by lower values.
|
|
|
|
result = thisResult;
|
2014-09-05 03:48:46 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
f = GetNextContinuationWithSameStyle(f, oldContext, &haveMoreContinuations);
|
|
|
|
}
|
2014-09-05 03:48:46 +00:00
|
|
|
|
2014-12-25 07:28:25 +00:00
|
|
|
// Some changes to animations don't affect the computed style and yet still
|
|
|
|
// require the layer to be updated. For example, pausing an animation via
|
|
|
|
// the Web Animations API won't affect an element's style but still
|
|
|
|
// requires us to pull the animation off the layer.
|
|
|
|
//
|
|
|
|
// Although we only expect this code path to be called when computed style
|
|
|
|
// is not changing, we can sometimes reach this at the end of a transition
|
|
|
|
// when the animated style is being removed. Since
|
|
|
|
// AddLayerChangesForAnimation checks if mFrame has a transform style or not,
|
|
|
|
// we need to call it *after* calling RestyleSelf to ensure the animated
|
|
|
|
// transform has been removed first.
|
|
|
|
AddLayerChangesForAnimation();
|
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
if (haveMoreContinuations && hintToRestore) {
|
|
|
|
// If we have more continuations with different style (e.g., because
|
|
|
|
// we're inside a ::first-letter or ::first-line), put the restyle
|
|
|
|
// hint back.
|
|
|
|
mRestyleTracker.AddPendingRestyleToTable(mContent->AsElement(),
|
|
|
|
hintToRestore, nsChangeHint(0));
|
|
|
|
}
|
2014-09-05 03:48:46 +00:00
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
if (result == eRestyleResult_Stop) {
|
|
|
|
MOZ_ASSERT(mFrame->StyleContext() == oldContext,
|
|
|
|
"frame should have been left with its old style context");
|
2014-09-05 03:48:46 +00:00
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIFrame* unused;
|
|
|
|
nsStyleContext* newParent = mFrame->GetParentStyleContext(&unused);
|
2014-09-05 03:48:47 +00:00
|
|
|
if (oldContext->GetParent() != newParent) {
|
|
|
|
// If we received eRestyleResult_Stop, then the old style context was
|
|
|
|
// left on mFrame. Since we ended up restyling our parent, change
|
|
|
|
// this old style context to point to its new parent.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("moving style context %p from old parent %p to new parent %p",
|
|
|
|
oldContext.get(), oldContext->GetParent(), newParent);
|
2015-02-17 22:28:53 +00:00
|
|
|
// We keep strong references to the new parent around until the end
|
|
|
|
// of the restyle, in case:
|
|
|
|
// (a) we swapped structs between the old and new parent,
|
|
|
|
// (b) some descendants of the old parent are not getting restyled
|
|
|
|
// (which is the reason for the existence of
|
|
|
|
// ClearCachedInheritedStyleDataOnDescendants),
|
2015-04-14 22:13:45 +00:00
|
|
|
// (c) something under ProcessPendingRestyles (which notably is called
|
2015-02-17 22:28:53 +00:00
|
|
|
// *before* ClearCachedInheritedStyleDataOnDescendants is called
|
|
|
|
// on the old context) causes the new parent to be destroyed, thus
|
|
|
|
// destroying its owned structs, and
|
2015-04-14 22:13:45 +00:00
|
|
|
// (d) something under ProcessPendingRestyles then wants to use of those
|
2015-02-17 22:28:53 +00:00
|
|
|
// now destroyed structs (through the old parent's descendants).
|
|
|
|
mSwappedStructOwners.AppendElement(newParent);
|
2014-09-05 03:48:47 +00:00
|
|
|
oldContext->MoveTo(newParent);
|
2014-09-05 03:48:45 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
// Send the accessibility notifications that RestyleChildren otherwise
|
|
|
|
// would have sent.
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
|
2014-11-20 18:24:10 +00:00
|
|
|
InitializeAccessibilityNotifications(mFrame->StyleContext());
|
2014-09-05 03:48:47 +00:00
|
|
|
SendAccessibilityNotifications();
|
2013-09-25 19:28:07 +00:00
|
|
|
}
|
2014-08-03 20:11:55 +00:00
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
mRestyleTracker.AddRestyleRootsIfAwaitingRestyle(descendants);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!swappedStructs) {
|
|
|
|
// If we swapped any structs from the old context, then we need to keep
|
|
|
|
// it alive until after the RestyleChildren call so that we can fix up
|
|
|
|
// its descendants' cached structs.
|
|
|
|
oldContext = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == eRestyleResult_ContinueAndForceDescendants) {
|
|
|
|
childRestyleHint =
|
|
|
|
nsRestyleHint(childRestyleHint | eRestyle_ForceDescendants);
|
2013-09-25 19:28:07 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
// No need to do this if we're planning to reframe already.
|
|
|
|
// It's also important to check mHintsHandled since we use
|
|
|
|
// mFrame->StyleContext(), which is out of date if mHintsHandled
|
|
|
|
// has a ReconstructFrame hint. Using an out of date style
|
|
|
|
// context could trigger assertions about mismatched rule trees.
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
|
|
|
|
RestyleChildren(childRestyleHint);
|
|
|
|
}
|
2014-09-05 03:48:47 +00:00
|
|
|
|
|
|
|
if (oldContext && !oldContext->HasSingleReference()) {
|
|
|
|
// If we swapped some structs out of oldContext in the RestyleSelf call
|
|
|
|
// and after the RestyleChildren call we still have other strong references
|
2015-02-17 22:28:53 +00:00
|
|
|
// to it, we need to make ensure its descendants don't cache any of the
|
2014-09-05 03:48:47 +00:00
|
|
|
// structs that were swapped out.
|
|
|
|
//
|
2015-02-17 22:28:53 +00:00
|
|
|
// Much of the time we will not get in here; we do for example when the
|
|
|
|
// style context is shared with a later IB split sibling (which we won't
|
|
|
|
// restyle until a bit later) or if other code is holding a strong reference
|
|
|
|
// to the style context (as is done by nsTransformedTextRun objects, which
|
|
|
|
// can be referenced by a text frame's mTextRun longer than the frame's
|
|
|
|
// mStyleContext).
|
2015-04-29 04:47:15 +00:00
|
|
|
//
|
|
|
|
// Also, we don't want this style context to get any more uses by being
|
|
|
|
// returned from nsStyleContext::FindChildWithRules, so we add the
|
|
|
|
// NS_STYLE_INELIGIBLE_FOR_SHARING bit to it.
|
|
|
|
oldContext->SetIneligibleForSharing();
|
|
|
|
|
2015-03-04 07:06:29 +00:00
|
|
|
ContextToClear* toClear = mContextsToClear.AppendElement();
|
|
|
|
toClear->mStyleContext = Move(oldContext);
|
|
|
|
toClear->mStructs = swappedStructs;
|
2014-09-05 03:48:47 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 03:48:47 +00:00
|
|
|
mRestyleTracker.AddRestyleRootsIfAwaitingRestyle(descendants);
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 03:48:46 +00:00
|
|
|
/**
|
|
|
|
* Depending on the details of the frame we are restyling or its old style
|
|
|
|
* context, we may or may not be able to stop restyling after this frame if
|
|
|
|
* we find we had no style changes.
|
|
|
|
*
|
|
|
|
* This function returns eRestyleResult_Stop if it does not find any
|
|
|
|
* conditions that would preclude stopping restyling, and
|
|
|
|
* eRestyleResult_Continue if it does.
|
|
|
|
*/
|
|
|
|
ElementRestyler::RestyleResult
|
|
|
|
ElementRestyler::ComputeRestyleResultFromFrame(nsIFrame* aSelf)
|
|
|
|
{
|
|
|
|
// We can't handle situations where the primary style context of a frame
|
|
|
|
// has not had any style data changes, but its additional style contexts
|
|
|
|
// have, so we don't considering stopping if this frame has any additional
|
|
|
|
// style contexts.
|
|
|
|
if (aSelf->GetAdditionalStyleContext(0)) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("there are additional style contexts");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Style changes might have moved children between the two nsLetterFrames
|
|
|
|
// (the one matching ::first-letter and the one containing the rest of the
|
|
|
|
// content). Continue restyling to the children of the nsLetterFrame so
|
|
|
|
// that they get the correct style context parent. Similarly for
|
|
|
|
// nsLineFrames.
|
|
|
|
nsIAtom* type = aSelf->GetType();
|
2014-09-25 05:45:36 +00:00
|
|
|
|
|
|
|
if (type == nsGkAtoms::letterFrame) {
|
|
|
|
LOG_RESTYLE_CONTINUE("frame is a letter frame");
|
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == nsGkAtoms::lineFrame) {
|
|
|
|
LOG_RESTYLE_CONTINUE("frame is a line frame");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some style computations depend not on the parent's style, but a grandparent
|
|
|
|
// or one the grandparent's ancestors. An example is an explicit 'inherit'
|
|
|
|
// value for align-self, where if the parent frame's value for the property is
|
|
|
|
// 'auto' we end up inheriting the computed value from the grandparent. We
|
|
|
|
// can't stop the restyling process on this frame (the one with 'auto', in
|
|
|
|
// this example), as the grandparent's computed value might have changed
|
|
|
|
// and we need to recompute the child's 'inherit' to that new value.
|
|
|
|
nsStyleContext* oldContext = aSelf->StyleContext();
|
|
|
|
if (oldContext->HasChildThatUsesGrandancestorStyle()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the old context uses grandancestor style");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We ignore all situations that involve :visited style.
|
|
|
|
if (oldContext->GetStyleIfVisited()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the old style context has StyleIfVisited");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContext* parentContext = oldContext->GetParent();
|
|
|
|
if (parentContext && parentContext->GetStyleIfVisited()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the old style context's parent has StyleIfVisited");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We also ignore frames for pseudos, as their style contexts have
|
|
|
|
// inheritance structures that do not match the frame inheritance
|
|
|
|
// structure. To avoid enumerating and checking all of the cases
|
|
|
|
// where we have this kind of inheritance, we keep restyling past
|
|
|
|
// pseudos.
|
|
|
|
nsIAtom* pseudoTag = oldContext->GetPseudo();
|
|
|
|
if (pseudoTag && pseudoTag != nsCSSAnonBoxes::mozNonElement) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the old style context is for a pseudo");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* parent = mFrame->GetParent();
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
// Also if the parent has a pseudo, as this frame's style context will
|
|
|
|
// be inheriting from a grandparent frame's style context (or a further
|
|
|
|
// ancestor).
|
|
|
|
nsIAtom* parentPseudoTag = parent->StyleContext()->GetPseudo();
|
|
|
|
if (parentPseudoTag && parentPseudoTag != nsCSSAnonBoxes::mozNonElement) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the old style context's parent is for a pseudo");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return eRestyleResult_Stop;
|
|
|
|
}
|
|
|
|
|
|
|
|
ElementRestyler::RestyleResult
|
|
|
|
ElementRestyler::ComputeRestyleResultFromNewContext(nsIFrame* aSelf,
|
|
|
|
nsStyleContext* aNewContext)
|
|
|
|
{
|
|
|
|
// Keep restyling if the new style context has any style-if-visted style, so
|
|
|
|
// that we can avoid the style context tree surgery having to deal to deal
|
|
|
|
// with visited styles.
|
|
|
|
if (aNewContext->GetStyleIfVisited()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the new style context has StyleIfVisited");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If link-related information has changed, or the pseudo for the frame has
|
|
|
|
// changed, or the new style context points to a different rule node, we can't
|
|
|
|
// leave the old style context on the frame.
|
|
|
|
nsStyleContext* oldContext = aSelf->StyleContext();
|
|
|
|
if (oldContext->IsLinkContext() != aNewContext->IsLinkContext() ||
|
|
|
|
oldContext->RelevantLinkVisited() != aNewContext->RelevantLinkVisited() ||
|
|
|
|
oldContext->GetPseudo() != aNewContext->GetPseudo() ||
|
|
|
|
oldContext->GetPseudoType() != aNewContext->GetPseudoType() ||
|
|
|
|
oldContext->RuleNode() != aNewContext->RuleNode()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the old and new style contexts have different link/"
|
|
|
|
"visited/pseudo/rulenodes");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the old and new style contexts differ in their
|
|
|
|
// NS_STYLE_HAS_TEXT_DECORATION_LINES or NS_STYLE_HAS_PSEUDO_ELEMENT_DATA
|
|
|
|
// bits, then we must keep restyling so that those new bit values are
|
|
|
|
// propagated.
|
|
|
|
if (oldContext->HasTextDecorationLines() !=
|
2014-09-25 05:45:36 +00:00
|
|
|
aNewContext->HasTextDecorationLines()) {
|
|
|
|
LOG_RESTYLE_CONTINUE("NS_STYLE_HAS_TEXT_DECORATION_LINES differs between old"
|
|
|
|
" and new style contexts");
|
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldContext->HasPseudoElementData() !=
|
2014-09-05 03:48:46 +00:00
|
|
|
aNewContext->HasPseudoElementData()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("NS_STYLE_HAS_PSEUDO_ELEMENT_DATA differs between old"
|
|
|
|
" and new style contexts");
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
2015-03-10 23:28:21 +00:00
|
|
|
if (oldContext->ShouldSuppressLineBreak() !=
|
|
|
|
aNewContext->ShouldSuppressLineBreak()) {
|
2015-03-16 00:28:49 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("NS_STYLE_SUPPRESS_LINEBREAK differs"
|
2014-12-31 05:39:43 +00:00
|
|
|
"between old and new style contexts");
|
2015-03-16 00:28:49 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldContext->IsInDisplayNoneSubtree() !=
|
|
|
|
aNewContext->IsInDisplayNoneSubtree()) {
|
|
|
|
LOG_RESTYLE_CONTINUE("NS_STYLE_IN_DISPLAY_NONE_SUBTREE differs between old"
|
|
|
|
" and new style contexts");
|
2014-12-10 22:26:18 +00:00
|
|
|
return eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
|
2014-09-05 03:48:46 +00:00
|
|
|
return eRestyleResult_Stop;
|
|
|
|
}
|
|
|
|
|
2014-09-05 03:48:45 +00:00
|
|
|
ElementRestyler::RestyleResult
|
2014-09-05 03:48:47 +00:00
|
|
|
ElementRestyler::RestyleSelf(nsIFrame* aSelf,
|
|
|
|
nsRestyleHint aRestyleHint,
|
2014-09-25 05:30:18 +00:00
|
|
|
uint32_t* aSwappedStructs)
|
2013-07-31 00:36:11 +00:00
|
|
|
{
|
2014-06-19 00:07:26 +00:00
|
|
|
MOZ_ASSERT(!(aRestyleHint & eRestyle_LaterSiblings),
|
|
|
|
"eRestyle_LaterSiblings must not be part of aRestyleHint");
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// XXXldb get new context from prev-in-flow if possible, to avoid
|
|
|
|
// duplication. (Or should we just let |GetContext| handle that?)
|
|
|
|
// Getting the hint would be nice too, but that's harder.
|
|
|
|
|
|
|
|
// XXXbryner we may be able to avoid some of the refcounting goop here.
|
|
|
|
// We do need a reference to oldContext for the lifetime of this function, and it's possible
|
|
|
|
// that the frame has the last reference to it, so AddRef it here.
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("RestyleSelf %s, aRestyleHint = %s",
|
|
|
|
FrameTagToString(aSelf).get(),
|
|
|
|
RestyleManager::RestyleHintToString(aRestyleHint).get());
|
|
|
|
LOG_RESTYLE_INDENT();
|
|
|
|
|
2014-09-05 03:48:46 +00:00
|
|
|
RestyleResult result;
|
|
|
|
|
2015-02-17 22:28:53 +00:00
|
|
|
if (aRestyleHint) {
|
2014-09-05 03:48:46 +00:00
|
|
|
result = eRestyleResult_Continue;
|
|
|
|
} else {
|
|
|
|
result = ComputeRestyleResultFromFrame(aSelf);
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
nsChangeHint assumeDifferenceHint = NS_STYLE_HINT_NONE;
|
2013-09-25 19:28:07 +00:00
|
|
|
nsRefPtr<nsStyleContext> oldContext = aSelf->StyleContext();
|
2013-07-31 00:36:09 +00:00
|
|
|
nsStyleSet* styleSet = mPresContext->StyleSet();
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2013-07-31 00:36:12 +00:00
|
|
|
mWasFrameVisible = nsIPresShell::IsAccessibilityActive() ?
|
|
|
|
oldContext->StyleVisibility()->IsVisible() : false;
|
2013-07-20 19:14:25 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-31 00:36:12 +00:00
|
|
|
nsIAtom* const pseudoTag = oldContext->GetPseudo();
|
|
|
|
const nsCSSPseudoElements::Type pseudoType = oldContext->GetPseudoType();
|
|
|
|
|
|
|
|
// Get the frame providing the parent style context. If it is a
|
|
|
|
// child, then resolve the provider first.
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIFrame* providerFrame;
|
|
|
|
nsStyleContext* parentContext = aSelf->GetParentStyleContext(&providerFrame);
|
2013-09-25 19:28:07 +00:00
|
|
|
bool isChild = providerFrame && providerFrame->GetParent() == aSelf;
|
2014-11-20 18:24:10 +00:00
|
|
|
if (isChild) {
|
2013-09-25 19:28:07 +00:00
|
|
|
MOZ_ASSERT(providerFrame->GetContent() == aSelf->GetContent(),
|
2014-11-20 18:24:10 +00:00
|
|
|
"Postcondition for GetParentStyleContext() violated. "
|
2013-07-31 00:36:12 +00:00
|
|
|
"That means we need to add the current element to the "
|
|
|
|
"ancestor filter.");
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
// resolve the provider here (before aSelf below).
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("resolving child provider frame");
|
2013-07-31 00:36:12 +00:00
|
|
|
|
|
|
|
// assumeDifferenceHint forces the parent's change to be also
|
|
|
|
// applied to this frame, no matter what
|
|
|
|
// nsStyleContext::CalcStyleDifference says. CalcStyleDifference
|
|
|
|
// can't be trusted because it assumes any changes to the parent
|
|
|
|
// style context provider will be automatically propagated to
|
|
|
|
// the frame(s) with child style contexts.
|
|
|
|
|
|
|
|
ElementRestyler providerRestyler(PARENT_CONTEXT_FROM_CHILD_FRAME,
|
|
|
|
*this, providerFrame);
|
|
|
|
providerRestyler.Restyle(aRestyleHint);
|
|
|
|
assumeDifferenceHint = providerRestyler.HintsHandledForFrame();
|
|
|
|
|
|
|
|
// The provider's new context becomes the parent context of
|
2013-09-25 19:28:07 +00:00
|
|
|
// aSelf's context.
|
2013-07-31 00:36:12 +00:00
|
|
|
parentContext = providerFrame->StyleContext();
|
|
|
|
// Set |mResolvedChild| so we don't bother resolving the
|
|
|
|
// provider again.
|
|
|
|
mResolvedChild = providerFrame;
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("we had a provider frame");
|
2014-09-05 03:48:46 +00:00
|
|
|
// Continue restyling past the odd style context inheritance.
|
|
|
|
result = eRestyleResult_Continue;
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
if (providerFrame != aSelf->GetParent()) {
|
2013-07-31 00:36:12 +00:00
|
|
|
// We don't actually know what the parent style context's
|
|
|
|
// non-inherited hints were, so assume the worst.
|
|
|
|
mParentFrameHintsNotHandledForDescendants =
|
|
|
|
nsChangeHint_Hints_NotHandledForDescendants;
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("parentContext = %p", parentContext);
|
|
|
|
|
2013-07-31 00:36:12 +00:00
|
|
|
// do primary context
|
|
|
|
nsRefPtr<nsStyleContext> newContext;
|
|
|
|
nsIFrame *prevContinuation =
|
2013-09-25 19:28:07 +00:00
|
|
|
GetPrevContinuationWithPossiblySameStyle(aSelf);
|
2013-07-31 00:36:12 +00:00
|
|
|
nsStyleContext *prevContinuationContext;
|
|
|
|
bool copyFromContinuation =
|
|
|
|
prevContinuation &&
|
|
|
|
(prevContinuationContext = prevContinuation->StyleContext())
|
|
|
|
->GetPseudo() == oldContext->GetPseudo() &&
|
|
|
|
prevContinuationContext->GetParent() == parentContext;
|
|
|
|
if (copyFromContinuation) {
|
|
|
|
// Just use the style context from the frame's previous
|
2013-09-25 19:28:07 +00:00
|
|
|
// continuation.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("using previous continuation's context");
|
2013-07-31 00:36:12 +00:00
|
|
|
newContext = prevContinuationContext;
|
|
|
|
}
|
|
|
|
else if (pseudoTag == nsCSSAnonBoxes::mozNonElement) {
|
2013-09-25 19:28:07 +00:00
|
|
|
NS_ASSERTION(aSelf->GetContent(),
|
2013-07-31 00:36:12 +00:00
|
|
|
"non pseudo-element frame without content node");
|
|
|
|
newContext = styleSet->ResolveStyleForNonElement(parentContext);
|
|
|
|
}
|
2014-08-03 20:11:55 +00:00
|
|
|
else if (!(aRestyleHint & (eRestyle_Self | eRestyle_Subtree))) {
|
2014-08-03 02:37:43 +00:00
|
|
|
Element* element = ElementForStyleContext(mParentContent, aSelf, pseudoType);
|
2014-09-05 03:48:45 +00:00
|
|
|
if (!(aRestyleHint & ~(eRestyle_Force | eRestyle_ForceDescendants)) &&
|
2014-08-03 20:11:55 +00:00
|
|
|
!styleSet->IsInRuleTreeReconstruct()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("reparenting style context");
|
2014-08-03 02:37:43 +00:00
|
|
|
newContext =
|
2015-02-16 22:15:05 +00:00
|
|
|
styleSet->ReparentStyleContext(oldContext, parentContext, element);
|
2014-08-03 02:37:43 +00:00
|
|
|
} else {
|
2014-08-03 20:11:55 +00:00
|
|
|
// Use ResolveStyleWithReplacement either for actual replacements
|
|
|
|
// or, with no replacements, as a substitute for
|
|
|
|
// ReparentStyleContext that rebuilds the path in the rule tree
|
|
|
|
// rather than reusing the rule node, as we need to do during a
|
|
|
|
// rule tree reconstruct.
|
2015-02-16 22:15:05 +00:00
|
|
|
Element* pseudoElement = PseudoElementForStyleContext(aSelf, pseudoType);
|
|
|
|
MOZ_ASSERT(!element || element != pseudoElement,
|
|
|
|
"pseudo-element for selector matching should be "
|
|
|
|
"the anonymous content node that we create, "
|
|
|
|
"not the real element");
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("resolving style with replacement");
|
2014-08-03 02:37:43 +00:00
|
|
|
newContext =
|
2015-02-16 22:15:05 +00:00
|
|
|
styleSet->ResolveStyleWithReplacement(element, pseudoElement,
|
|
|
|
parentContext, oldContext,
|
2014-08-03 02:37:44 +00:00
|
|
|
aRestyleHint);
|
2014-08-03 02:37:43 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
} else if (pseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
|
|
|
|
newContext = styleSet->ResolveAnonymousBoxStyle(pseudoTag,
|
|
|
|
parentContext);
|
|
|
|
}
|
|
|
|
else {
|
2013-09-25 19:28:07 +00:00
|
|
|
Element* element = ElementForStyleContext(mParentContent, aSelf, pseudoType);
|
2013-07-31 00:36:12 +00:00
|
|
|
if (pseudoTag) {
|
|
|
|
if (pseudoTag == nsCSSPseudoElements::before ||
|
|
|
|
pseudoTag == nsCSSPseudoElements::after) {
|
|
|
|
// XXX what other pseudos do we need to treat like this?
|
|
|
|
newContext = styleSet->ProbePseudoElementStyle(element,
|
|
|
|
pseudoType,
|
|
|
|
parentContext,
|
|
|
|
mTreeMatchContext);
|
|
|
|
if (!newContext) {
|
|
|
|
// This pseudo should no longer exist; gotta reframe
|
|
|
|
NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame);
|
2013-09-25 19:28:07 +00:00
|
|
|
mChangeList->AppendChange(aSelf, element,
|
2013-07-31 00:36:12 +00:00
|
|
|
nsChangeHint_ReconstructFrame);
|
|
|
|
// We're reframing anyway; just keep the same context
|
|
|
|
newContext = oldContext;
|
2014-09-05 03:48:47 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// oldContext's parent might have had its style structs swapped out
|
|
|
|
// with parentContext, so to avoid any assertions that might
|
|
|
|
// otherwise trigger in oldContext's parent's destructor, we set a
|
|
|
|
// flag on oldContext to skip it and its descendants in
|
|
|
|
// nsStyleContext::AssertStructsNotUsedElsewhere.
|
|
|
|
if (oldContext->GetParent() != parentContext) {
|
|
|
|
oldContext->AddStyleBit(NS_STYLE_IS_GOING_AWAY);
|
|
|
|
}
|
|
|
|
#endif
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Don't expect XUL tree stuff here, since it needs a comparator and
|
|
|
|
// all.
|
|
|
|
NS_ASSERTION(pseudoType <
|
|
|
|
nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"Unexpected pseudo type");
|
2013-11-28 06:46:38 +00:00
|
|
|
Element* pseudoElement =
|
2015-02-16 22:15:05 +00:00
|
|
|
PseudoElementForStyleContext(aSelf, pseudoType);
|
|
|
|
MOZ_ASSERT(element != pseudoElement,
|
|
|
|
"pseudo-element for selector matching should be "
|
|
|
|
"the anonymous content node that we create, "
|
|
|
|
"not the real element");
|
2013-07-31 00:36:12 +00:00
|
|
|
newContext = styleSet->ResolvePseudoElementStyle(element,
|
|
|
|
pseudoType,
|
2013-11-28 06:46:38 +00:00
|
|
|
parentContext,
|
|
|
|
pseudoElement);
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
else {
|
2013-09-25 19:28:07 +00:00
|
|
|
NS_ASSERTION(aSelf->GetContent(),
|
2013-07-20 19:14:25 +00:00
|
|
|
"non pseudo-element frame without content node");
|
2014-06-16 13:55:00 +00:00
|
|
|
// Skip parent display based style fixup for anonymous subtrees:
|
|
|
|
TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper
|
|
|
|
parentDisplayBasedFixupSkipper(mTreeMatchContext,
|
2014-05-03 13:42:33 +00:00
|
|
|
element->IsRootOfNativeAnonymousSubtree());
|
2013-07-31 00:36:12 +00:00
|
|
|
newContext = styleSet->ResolveStyleFor(element, parentContext,
|
|
|
|
mTreeMatchContext);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 04:11:06 +00:00
|
|
|
MOZ_ASSERT(newContext);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:12 +00:00
|
|
|
if (!parentContext) {
|
|
|
|
if (oldContext->RuleNode() == newContext->RuleNode() &&
|
|
|
|
oldContext->IsLinkContext() == newContext->IsLinkContext() &&
|
|
|
|
oldContext->RelevantLinkVisited() ==
|
|
|
|
newContext->RelevantLinkVisited()) {
|
|
|
|
// We're the root of the style context tree and the new style
|
|
|
|
// context returned has the same rule node. This means that
|
|
|
|
// we can use FindChildWithRules to keep a lot of the old
|
|
|
|
// style contexts around. However, we need to start from the
|
|
|
|
// same root.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("restyling root and keeping old context");
|
|
|
|
LOG_RESTYLE_IF(this, result != eRestyleResult_Continue,
|
|
|
|
"continuing restyle since this is the root");
|
2013-07-31 00:36:12 +00:00
|
|
|
newContext = oldContext;
|
2014-09-05 03:48:46 +00:00
|
|
|
// Never consider stopping restyling at the root.
|
|
|
|
result = eRestyleResult_Continue;
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("oldContext = %p, newContext = %p%s",
|
|
|
|
oldContext.get(), newContext.get(),
|
|
|
|
oldContext == newContext ? (const char*) " (same)" :
|
|
|
|
(const char*) "");
|
|
|
|
|
2013-07-31 00:36:12 +00:00
|
|
|
if (newContext != oldContext) {
|
2014-09-05 03:48:46 +00:00
|
|
|
if (result == eRestyleResult_Stop) {
|
|
|
|
if (oldContext->IsShared()) {
|
|
|
|
// If the old style context was shared, then we can't return
|
|
|
|
// eRestyleResult_Stop and patch its parent to point to the
|
|
|
|
// new parent style context, as that change might not be valid
|
|
|
|
// for the other frames sharing the style context.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("the old style context is shared");
|
2014-09-05 03:48:46 +00:00
|
|
|
result = eRestyleResult_Continue;
|
|
|
|
} else {
|
|
|
|
// Look at some details of the new style context to see if it would
|
|
|
|
// be safe to stop restyling, if we discover it has the same style
|
|
|
|
// data as the old style context.
|
|
|
|
result = ComputeRestyleResultFromNewContext(aSelf, newContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-05 03:48:46 +00:00
|
|
|
uint32_t equalStructs = 0;
|
|
|
|
|
2014-09-05 03:48:46 +00:00
|
|
|
if (copyFromContinuation) {
|
|
|
|
// In theory we should know whether there was any style data difference,
|
|
|
|
// since we would have calculated that in the previous call to
|
|
|
|
// RestyleSelf, so until we perform only one restyling per chain-of-
|
|
|
|
// same-style continuations (bug 918064), we need to check again here to
|
|
|
|
// determine whether it is safe to stop restyling.
|
|
|
|
if (result == eRestyleResult_Stop) {
|
|
|
|
oldContext->CalcStyleDifference(newContext, nsChangeHint(0),
|
|
|
|
&equalStructs);
|
|
|
|
if (equalStructs != NS_STYLE_INHERIT_MASK) {
|
|
|
|
// At least one struct had different data in it, so we must
|
|
|
|
// continue restyling children.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("there is different style data: %s",
|
|
|
|
RestyleManager::StructNamesToString(
|
|
|
|
~equalStructs & NS_STYLE_INHERIT_MASK).get());
|
2014-09-05 03:48:46 +00:00
|
|
|
result = eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-04 05:08:00 +00:00
|
|
|
bool changedStyle =
|
|
|
|
RestyleManager::TryStartingTransition(mPresContext, aSelf->GetContent(),
|
|
|
|
oldContext, &newContext);
|
|
|
|
if (changedStyle) {
|
|
|
|
LOG_RESTYLE_CONTINUE("TryStartingTransition changed the new style context");
|
|
|
|
result = eRestyleResult_Continue;
|
|
|
|
}
|
2014-09-05 03:48:45 +00:00
|
|
|
CaptureChange(oldContext, newContext, assumeDifferenceHint,
|
|
|
|
&equalStructs);
|
2014-09-05 03:48:46 +00:00
|
|
|
if (equalStructs != NS_STYLE_INHERIT_MASK) {
|
|
|
|
// At least one struct had different data in it, so we must
|
|
|
|
// continue restyling children.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("there is different style data: %s",
|
|
|
|
RestyleManager::StructNamesToString(
|
|
|
|
~equalStructs & NS_STYLE_INHERIT_MASK).get());
|
2014-09-05 03:48:46 +00:00
|
|
|
result = eRestyleResult_Continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == eRestyleResult_Stop) {
|
|
|
|
// Since we currently have eRestyleResult_Stop, we know at this
|
|
|
|
// point that all of our style structs are equal in terms of styles.
|
|
|
|
// However, some of them might be different pointers. Since our
|
|
|
|
// descendants might share those pointers, we have to continue to
|
|
|
|
// restyling our descendants.
|
|
|
|
//
|
|
|
|
// However, because of the swapping of equal structs we've done on
|
2014-09-05 03:48:46 +00:00
|
|
|
// ancestors (later in this function), we've ensured that for structs
|
2014-09-05 03:48:46 +00:00
|
|
|
// that cannot be stored in the rule tree, we keep the old equal structs
|
2014-09-05 03:48:46 +00:00
|
|
|
// around rather than replacing them with new ones. This means that we
|
|
|
|
// only time we hit this deoptimization is either
|
|
|
|
//
|
|
|
|
// (a) when at least one of the (old or new) equal structs could be stored
|
|
|
|
// in the rule tree, and those structs are then inherited (by pointer
|
|
|
|
// sharing) to descendant style contexts; or
|
|
|
|
//
|
|
|
|
// (b) when we were unable to swap the structs on the parent because
|
|
|
|
// either or both of the old parent and new parent are shared.
|
2014-09-05 03:48:46 +00:00
|
|
|
for (nsStyleStructID sid = nsStyleStructID(0);
|
|
|
|
sid < nsStyleStructID_Length;
|
|
|
|
sid = nsStyleStructID(sid + 1)) {
|
|
|
|
if (oldContext->HasCachedInheritedStyleData(sid) &&
|
|
|
|
!oldContext->HasSameCachedStyleData(newContext, sid)) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE_CONTINUE("there are different struct pointers");
|
2014-09-05 03:48:46 +00:00
|
|
|
result = eRestyleResult_Continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:12 +00:00
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
|
2013-09-25 19:28:08 +00:00
|
|
|
// If the frame gets regenerated, let it keep its old context,
|
|
|
|
// which is important to maintain various invariants about
|
|
|
|
// frame types matching their style contexts.
|
|
|
|
// Note that this check even makes sense if we didn't call
|
|
|
|
// CaptureChange because of copyFromContinuation being true,
|
|
|
|
// since we'll have copied the existing context from the
|
|
|
|
// previous continuation, so newContext == oldContext.
|
2014-09-05 03:48:46 +00:00
|
|
|
|
|
|
|
if (result != eRestyleResult_Stop) {
|
2015-02-17 22:28:53 +00:00
|
|
|
if (copyFromContinuation) {
|
2014-09-25 05:51:43 +00:00
|
|
|
LOG_RESTYLE("not swapping style structs, since we copied from a "
|
|
|
|
"continuation");
|
|
|
|
} else if (oldContext->IsShared() && newContext->IsShared()) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("not swapping style structs, since both old and contexts "
|
|
|
|
"are shared");
|
|
|
|
} else if (oldContext->IsShared()) {
|
|
|
|
LOG_RESTYLE("not swapping style structs, since the old context is "
|
|
|
|
"shared");
|
|
|
|
} else if (newContext->IsShared()) {
|
|
|
|
LOG_RESTYLE("not swapping style structs, since the new context is "
|
|
|
|
"shared");
|
|
|
|
} else {
|
|
|
|
LOG_RESTYLE("swapping style structs between %p and %p",
|
|
|
|
oldContext.get(), newContext.get());
|
2014-09-05 03:48:46 +00:00
|
|
|
oldContext->SwapStyleData(newContext, equalStructs);
|
2014-09-05 03:48:47 +00:00
|
|
|
*aSwappedStructs |= equalStructs;
|
2014-09-30 23:13:57 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
uint32_t structs = RestyleManager::StructsToLog() & equalStructs;
|
|
|
|
if (structs) {
|
|
|
|
LOG_RESTYLE_INDENT();
|
|
|
|
LOG_RESTYLE("old style context now has: %s",
|
|
|
|
oldContext->GetCachedStyleDataAsString(structs).get());
|
|
|
|
LOG_RESTYLE("new style context now has: %s",
|
|
|
|
newContext->GetCachedStyleDataAsString(structs).get());
|
|
|
|
}
|
|
|
|
#endif
|
2014-09-05 03:48:46 +00:00
|
|
|
}
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("setting new style context");
|
2014-09-05 03:48:46 +00:00
|
|
|
aSelf->SetStyleContext(newContext);
|
|
|
|
}
|
2014-09-25 05:45:36 +00:00
|
|
|
} else {
|
|
|
|
LOG_RESTYLE("not setting new style context, since we'll reframe");
|
2015-04-14 22:13:45 +00:00
|
|
|
// We need to keep the new parent alive, in case it had structs
|
|
|
|
// swapped into it that our frame's style context still has cached.
|
|
|
|
// This is a similar scenario to the one described in the
|
|
|
|
// ElementRestyler::Restyle comment where we append to
|
|
|
|
// mSwappedStructOwners.
|
|
|
|
//
|
|
|
|
// We really only need to do this if we did swap structs on the
|
|
|
|
// parent, but we don't have that information here.
|
|
|
|
mSwappedStructOwners.AppendElement(newContext->GetParent());
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
oldContext = nullptr;
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:12 +00:00
|
|
|
// do additional contexts
|
|
|
|
// XXXbz might be able to avoid selector matching here in some
|
|
|
|
// cases; won't worry about it for now.
|
|
|
|
int32_t contextIndex = 0;
|
|
|
|
for (nsStyleContext* oldExtraContext;
|
2013-09-25 19:28:07 +00:00
|
|
|
(oldExtraContext = aSelf->GetAdditionalStyleContext(contextIndex));
|
2013-07-31 00:36:12 +00:00
|
|
|
++contextIndex) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("extra context %d", contextIndex);
|
|
|
|
LOG_RESTYLE_INDENT();
|
2013-07-31 00:36:12 +00:00
|
|
|
nsRefPtr<nsStyleContext> newExtraContext;
|
|
|
|
nsIAtom* const extraPseudoTag = oldExtraContext->GetPseudo();
|
|
|
|
const nsCSSPseudoElements::Type extraPseudoType =
|
|
|
|
oldExtraContext->GetPseudoType();
|
|
|
|
NS_ASSERTION(extraPseudoTag &&
|
|
|
|
extraPseudoTag != nsCSSAnonBoxes::mozNonElement,
|
|
|
|
"extra style context is not pseudo element");
|
2014-08-03 20:11:55 +00:00
|
|
|
if (!(aRestyleHint & (eRestyle_Self | eRestyle_Subtree))) {
|
|
|
|
Element* element = extraPseudoType != nsCSSPseudoElements::ePseudo_AnonBox
|
|
|
|
? mContent->AsElement() : nullptr;
|
2014-08-03 20:11:55 +00:00
|
|
|
if (styleSet->IsInRuleTreeReconstruct()) {
|
|
|
|
// Use ResolveStyleWithReplacement as a substitute for
|
|
|
|
// ReparentStyleContext that rebuilds the path in the rule tree
|
|
|
|
// rather than reusing the rule node, as we need to do during a
|
|
|
|
// rule tree reconstruct.
|
2015-02-16 22:15:05 +00:00
|
|
|
Element* pseudoElement =
|
|
|
|
PseudoElementForStyleContext(aSelf, extraPseudoType);
|
|
|
|
MOZ_ASSERT(!element || element != pseudoElement,
|
|
|
|
"pseudo-element for selector matching should be "
|
|
|
|
"the anonymous content node that we create, "
|
|
|
|
"not the real element");
|
2014-08-03 20:11:55 +00:00
|
|
|
newExtraContext =
|
2015-02-16 22:15:05 +00:00
|
|
|
styleSet->ResolveStyleWithReplacement(element, pseudoElement,
|
|
|
|
newContext, oldExtraContext,
|
2014-08-03 20:11:55 +00:00
|
|
|
nsRestyleHint(0));
|
|
|
|
} else {
|
|
|
|
newExtraContext =
|
2015-02-16 22:15:05 +00:00
|
|
|
styleSet->ReparentStyleContext(oldExtraContext, newContext, element);
|
2014-08-03 20:11:55 +00:00
|
|
|
}
|
2014-08-03 20:11:55 +00:00
|
|
|
} else if (extraPseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
|
2013-07-31 00:36:12 +00:00
|
|
|
newExtraContext = styleSet->ResolveAnonymousBoxStyle(extraPseudoTag,
|
|
|
|
newContext);
|
2014-08-03 20:11:55 +00:00
|
|
|
} else {
|
2013-07-31 00:36:12 +00:00
|
|
|
// Don't expect XUL tree stuff here, since it needs a comparator and
|
|
|
|
// all.
|
|
|
|
NS_ASSERTION(extraPseudoType <
|
|
|
|
nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"Unexpected type");
|
|
|
|
newExtraContext = styleSet->ResolvePseudoElementStyle(mContent->AsElement(),
|
|
|
|
extraPseudoType,
|
2013-11-28 06:46:38 +00:00
|
|
|
newContext,
|
|
|
|
nullptr);
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
2013-08-03 04:11:06 +00:00
|
|
|
|
|
|
|
MOZ_ASSERT(newExtraContext);
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("newExtraContext = %p", newExtraContext.get());
|
|
|
|
|
2013-08-03 04:11:06 +00:00
|
|
|
if (oldExtraContext != newExtraContext) {
|
2014-09-05 03:48:45 +00:00
|
|
|
uint32_t equalStructs;
|
|
|
|
CaptureChange(oldExtraContext, newExtraContext, assumeDifferenceHint,
|
|
|
|
&equalStructs);
|
2013-08-03 04:11:06 +00:00
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("setting new extra style context");
|
2013-09-25 19:28:07 +00:00
|
|
|
aSelf->SetAdditionalStyleContext(contextIndex, newExtraContext);
|
2014-09-25 05:45:36 +00:00
|
|
|
} else {
|
|
|
|
LOG_RESTYLE("not setting new extra style context, since we'll reframe");
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
2014-09-05 03:48:45 +00:00
|
|
|
|
2014-10-03 04:53:22 +00:00
|
|
|
if (aRestyleHint & eRestyle_ForceDescendants) {
|
|
|
|
result = eRestyleResult_ContinueAndForceDescendants;
|
|
|
|
}
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("returning %s", RestyleResultToString(result).get());
|
|
|
|
|
2014-09-05 03:48:46 +00:00
|
|
|
return result;
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ElementRestyler::RestyleChildren(nsRestyleHint aChildRestyleHint)
|
|
|
|
{
|
2014-11-20 18:24:10 +00:00
|
|
|
MOZ_ASSERT(!(mHintsHandled & nsChangeHint_ReconstructFrame),
|
|
|
|
"No need to do this if we're planning to reframe already.");
|
|
|
|
|
2014-08-03 20:11:55 +00:00
|
|
|
// We'd like style resolution to be exact in the sense that an
|
|
|
|
// animation-only style flush flushes only the styles it requests
|
|
|
|
// flushing and doesn't update any other styles. This means avoiding
|
|
|
|
// constructing new frames during such a flush.
|
|
|
|
//
|
|
|
|
// For a ::before or ::after, we'll do an eRestyle_Subtree due to
|
|
|
|
// RestyleHintForOp in nsCSSRuleProcessor.cpp (via its
|
|
|
|
// HasAttributeDependentStyle or HasStateDependentStyle), given that
|
|
|
|
// we store pseudo-elements in selectors like they were children.
|
|
|
|
//
|
|
|
|
// Also, it's faster to skip the work we do on undisplayed children
|
|
|
|
// and pseudo-elements when we can skip it.
|
|
|
|
bool mightReframePseudos = aChildRestyleHint & eRestyle_Subtree;
|
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
RestyleUndisplayedDescendants(aChildRestyleHint);
|
2013-07-31 00:36:12 +00:00
|
|
|
|
|
|
|
// Check whether we might need to create a new ::before frame.
|
|
|
|
// There's no need to do this if we're planning to reframe already
|
|
|
|
// or if we're not forcing restyles on kids.
|
|
|
|
// It's also important to check mHintsHandled since we use
|
|
|
|
// mFrame->StyleContext(), which is out of date if mHintsHandled has a
|
|
|
|
// ReconstructFrame hint. Using an out of date style context could
|
|
|
|
// trigger assertions about mismatched rule trees.
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) &&
|
2014-08-03 20:11:55 +00:00
|
|
|
mightReframePseudos) {
|
2014-08-25 04:48:21 +00:00
|
|
|
MaybeReframeForBeforePseudo();
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// There is no need to waste time crawling into a frame's children
|
|
|
|
// on a frame change. The act of reconstructing frames will force
|
|
|
|
// new style contexts to be resolved on all of this frame's
|
|
|
|
// descendants anyway, so we want to avoid wasting time processing
|
|
|
|
// style contexts that we're just going to throw away anyway. - dwh
|
|
|
|
// It's also important to check mHintsHandled since reresolving the
|
|
|
|
// kids would use mFrame->StyleContext(), which is out of date if
|
|
|
|
// mHintsHandled has a ReconstructFrame hint; doing this could trigger
|
|
|
|
// assertions about mismatched rule trees.
|
2013-09-25 19:28:07 +00:00
|
|
|
nsIFrame *lastContinuation;
|
2013-07-31 00:36:12 +00:00
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
|
2014-11-20 18:24:10 +00:00
|
|
|
InitializeAccessibilityNotifications(mFrame->StyleContext());
|
2013-07-31 00:36:12 +00:00
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
for (nsIFrame* f = mFrame; f;
|
|
|
|
f = GetNextContinuationWithSameStyle(f, f->StyleContext())) {
|
|
|
|
lastContinuation = f;
|
|
|
|
RestyleContentChildren(f, aChildRestyleHint);
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
|
|
|
|
SendAccessibilityNotifications();
|
|
|
|
}
|
2013-09-25 19:28:07 +00:00
|
|
|
|
|
|
|
// Check whether we might need to create a new ::after frame.
|
|
|
|
// See comments above regarding :before.
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) &&
|
2014-08-03 20:11:55 +00:00
|
|
|
mightReframePseudos) {
|
2014-08-25 04:48:21 +00:00
|
|
|
MaybeReframeForAfterPseudo(lastContinuation);
|
2013-09-25 19:28:07 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
void
|
|
|
|
ElementRestyler::RestyleChildrenOfDisplayContentsElement(
|
|
|
|
nsIFrame* aParentFrame,
|
|
|
|
nsStyleContext* aNewContext,
|
|
|
|
nsChangeHint aMinHint,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
nsRestyleHint aRestyleHint)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(mHintsHandled & nsChangeHint_ReconstructFrame), "why call me?");
|
|
|
|
|
|
|
|
const bool mightReframePseudos = aRestyleHint & eRestyle_Subtree;
|
|
|
|
DoRestyleUndisplayedDescendants(nsRestyleHint(0), mContent, aNewContext);
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && mightReframePseudos) {
|
|
|
|
MaybeReframeForBeforePseudo(aParentFrame, nullptr, mContent, aNewContext);
|
|
|
|
}
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame) && mightReframePseudos) {
|
|
|
|
MaybeReframeForAfterPseudo(aParentFrame, nullptr, mContent, aNewContext);
|
|
|
|
}
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
|
|
|
|
InitializeAccessibilityNotifications(aNewContext);
|
|
|
|
|
|
|
|
// Then process child frames for content that is a descendant of mContent.
|
|
|
|
// XXX perhaps it's better to walk child frames (before reresolving
|
|
|
|
// XXX undisplayed contexts above) and mark those that has a stylecontext
|
|
|
|
// XXX leading up to mContent's old context? (instead of the
|
|
|
|
// XXX ContentIsDescendantOf check below)
|
|
|
|
nsIFrame::ChildListIterator lists(aParentFrame);
|
|
|
|
for ( ; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* f = childFrames.get();
|
|
|
|
if (nsContentUtils::ContentIsDescendantOf(f->GetContent(), mContent) &&
|
|
|
|
!f->GetPrevContinuation()) {
|
|
|
|
if (!(f->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
ComputeStyleChangeFor(f, mChangeList, aMinHint, aRestyleTracker,
|
2015-02-17 22:28:53 +00:00
|
|
|
aRestyleHint, mContextsToClear,
|
|
|
|
mSwappedStructOwners);
|
2014-11-20 18:24:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
|
|
|
|
SendAccessibilityNotifications();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ElementRestyler::ComputeStyleChangeFor(nsIFrame* aFrame,
|
|
|
|
nsStyleChangeList* aChangeList,
|
|
|
|
nsChangeHint aMinChange,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
2015-02-17 22:28:53 +00:00
|
|
|
nsRestyleHint aRestyleHint,
|
|
|
|
nsTArray<ContextToClear>&
|
|
|
|
aContextsToClear,
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>>&
|
|
|
|
aSwappedStructOwners)
|
2014-11-20 18:24:10 +00:00
|
|
|
{
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
2015-02-25 22:16:00 +00:00
|
|
|
nsAutoCString idStr;
|
|
|
|
if (profiler_is_active() && content) {
|
|
|
|
nsIAtom* id = content->GetID();
|
|
|
|
if (id) {
|
|
|
|
id->ToUTF8String(idStr);
|
|
|
|
} else {
|
|
|
|
idStr.AssignLiteral("?");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PROFILER_LABEL_PRINTF("ElementRestyler", "ComputeStyleChangeFor",
|
|
|
|
js::ProfileEntry::Category::CSS,
|
|
|
|
content ? "Element: %s" : "%s",
|
|
|
|
content ? idStr.get() : "");
|
2014-11-20 18:24:10 +00:00
|
|
|
if (aMinChange) {
|
|
|
|
aChangeList->AppendChange(aFrame, content, aMinChange);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(!aFrame->GetPrevContinuation(),
|
|
|
|
"must start with the first continuation");
|
|
|
|
|
|
|
|
// We want to start with this frame and walk all its next-in-flows,
|
|
|
|
// as well as all its ib-split siblings and their next-in-flows,
|
|
|
|
// reresolving style on all the frames we encounter in this walk that
|
|
|
|
// we didn't reach already. In the normal case, this will mean only
|
|
|
|
// restyling the first two block-in-inline splits and no
|
|
|
|
// continuations, and skipping everything else. However, when we have
|
|
|
|
// a style change targeted at an element inside a context where styles
|
|
|
|
// vary between continuations (e.g., a style change on an element that
|
|
|
|
// extends from inside a styled ::first-line to outside of that first
|
|
|
|
// line), we might restyle more than that.
|
|
|
|
|
|
|
|
nsPresContext* presContext = aFrame->PresContext();
|
|
|
|
FramePropertyTable* propTable = presContext->PropertyTable();
|
|
|
|
|
|
|
|
TreeMatchContext treeMatchContext(true,
|
|
|
|
nsRuleWalker::eRelevantLinkUnvisited,
|
|
|
|
presContext->Document());
|
|
|
|
Element* parent =
|
|
|
|
content ? content->GetParentElementCrossingShadowRoot() : nullptr;
|
|
|
|
treeMatchContext.InitAncestors(parent);
|
|
|
|
nsTArray<nsIContent*> visibleKidsOfHiddenElement;
|
|
|
|
for (nsIFrame* ibSibling = aFrame; ibSibling;
|
|
|
|
ibSibling = GetNextBlockInInlineSibling(propTable, ibSibling)) {
|
|
|
|
// Outer loop over ib-split siblings
|
|
|
|
for (nsIFrame* cont = ibSibling; cont; cont = cont->GetNextContinuation()) {
|
|
|
|
if (GetPrevContinuationWithSameStyle(cont)) {
|
|
|
|
// We already handled this element when dealing with its earlier
|
|
|
|
// continuation.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inner loop over next-in-flows of the current frame
|
|
|
|
ElementRestyler restyler(presContext, cont, aChangeList,
|
|
|
|
aMinChange, aRestyleTracker,
|
|
|
|
treeMatchContext,
|
2015-02-17 22:28:53 +00:00
|
|
|
visibleKidsOfHiddenElement,
|
|
|
|
aContextsToClear, aSwappedStructOwners);
|
2014-11-20 18:24:10 +00:00
|
|
|
|
|
|
|
restyler.Restyle(aRestyleHint);
|
|
|
|
|
|
|
|
if (restyler.HintsHandledForFrame() & nsChangeHint_ReconstructFrame) {
|
|
|
|
// If it's going to cause a framechange, then don't bother
|
|
|
|
// with the continuations or ib-split siblings since they'll be
|
|
|
|
// clobbered by the frame reconstruct anyway.
|
|
|
|
NS_ASSERTION(!cont->GetPrevContinuation(),
|
|
|
|
"continuing frame had more severe impact than first-in-flow");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
void
|
2014-11-20 18:24:10 +00:00
|
|
|
ElementRestyler::RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint)
|
2013-07-31 00:36:11 +00:00
|
|
|
{
|
2013-07-31 00:36:12 +00:00
|
|
|
// When the root element is display:none, we still construct *some*
|
|
|
|
// frames that have the root element as their mContent, down to the
|
|
|
|
// DocElementContainingBlock.
|
|
|
|
bool checkUndisplayed;
|
|
|
|
nsIContent* undisplayedParent;
|
|
|
|
if (mFrame->StyleContext()->GetPseudo()) {
|
2014-11-20 18:24:10 +00:00
|
|
|
checkUndisplayed = mFrame == mPresContext->FrameConstructor()->
|
2013-07-31 00:36:12 +00:00
|
|
|
GetDocElementContainingBlock();
|
|
|
|
undisplayedParent = nullptr;
|
|
|
|
} else {
|
|
|
|
checkUndisplayed = !!mFrame->GetContent();
|
|
|
|
undisplayedParent = mFrame->GetContent();
|
|
|
|
}
|
2014-11-20 18:24:10 +00:00
|
|
|
if (checkUndisplayed) {
|
2014-11-20 18:24:10 +00:00
|
|
|
DoRestyleUndisplayedDescendants(aChildRestyleHint, undisplayedParent,
|
|
|
|
mFrame->StyleContext());
|
2014-11-20 18:24:10 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
void
|
|
|
|
ElementRestyler::DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint,
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIContent* aParent,
|
|
|
|
nsStyleContext* aParentContext)
|
2014-11-20 18:24:10 +00:00
|
|
|
{
|
|
|
|
nsCSSFrameConstructor* fc = mPresContext->FrameConstructor();
|
|
|
|
UndisplayedNode* nodes = fc->GetAllUndisplayedContentIn(aParent);
|
|
|
|
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent,
|
2014-11-20 18:24:10 +00:00
|
|
|
aParentContext, NS_STYLE_DISPLAY_NONE);
|
2014-11-20 18:24:10 +00:00
|
|
|
nodes = fc->GetAllDisplayContentsIn(aParent);
|
|
|
|
RestyleUndisplayedNodes(aChildRestyleHint, nodes, aParent,
|
2014-11-20 18:24:10 +00:00
|
|
|
aParentContext, NS_STYLE_DISPLAY_CONTENTS);
|
2014-11-20 18:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint,
|
|
|
|
UndisplayedNode* aUndisplayed,
|
|
|
|
nsIContent* aUndisplayedParent,
|
2014-11-20 18:24:10 +00:00
|
|
|
nsStyleContext* aParentContext,
|
2014-11-20 18:24:10 +00:00
|
|
|
const uint8_t aDisplay)
|
|
|
|
{
|
|
|
|
nsIContent* undisplayedParent = aUndisplayedParent;
|
|
|
|
UndisplayedNode* undisplayed = aUndisplayed;
|
|
|
|
TreeMatchContext::AutoAncestorPusher pusher(mTreeMatchContext);
|
|
|
|
if (undisplayed) {
|
|
|
|
pusher.PushAncestorAndStyleScope(undisplayedParent);
|
|
|
|
}
|
|
|
|
for (; undisplayed; undisplayed = undisplayed->mNext) {
|
|
|
|
NS_ASSERTION(undisplayedParent ||
|
|
|
|
undisplayed->mContent ==
|
|
|
|
mPresContext->Document()->GetRootElement(),
|
|
|
|
"undisplayed node child of null must be root");
|
|
|
|
NS_ASSERTION(!undisplayed->mStyle->GetPseudo(),
|
|
|
|
"Shouldn't have random pseudo style contexts in the "
|
|
|
|
"undisplayed map");
|
|
|
|
|
|
|
|
LOG_RESTYLE("RestyleUndisplayedChildren: undisplayed->mContent = %p",
|
|
|
|
undisplayed->mContent.get());
|
|
|
|
|
|
|
|
// Get the parent of the undisplayed content and check if it is a XBL
|
|
|
|
// children element. Push the children element as an ancestor here because it does
|
|
|
|
// not have a frame and would not otherwise be pushed as an ancestor.
|
|
|
|
nsIContent* parent = undisplayed->mContent->GetParent();
|
|
|
|
TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
|
|
|
|
if (parent && nsContentUtils::IsContentInsertionPoint(parent)) {
|
|
|
|
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRestyleHint thisChildHint = aChildRestyleHint;
|
|
|
|
nsAutoPtr<RestyleTracker::RestyleData> undisplayedRestyleData;
|
|
|
|
Element* element = undisplayed->mContent->AsElement();
|
|
|
|
if (mRestyleTracker.GetRestyleData(element,
|
|
|
|
undisplayedRestyleData)) {
|
|
|
|
thisChildHint =
|
|
|
|
nsRestyleHint(thisChildHint | undisplayedRestyleData->mRestyleHint);
|
|
|
|
}
|
|
|
|
nsRefPtr<nsStyleContext> undisplayedContext;
|
|
|
|
nsStyleSet* styleSet = mPresContext->StyleSet();
|
|
|
|
if (thisChildHint & (eRestyle_Self | eRestyle_Subtree)) {
|
|
|
|
undisplayedContext =
|
2014-11-20 18:24:10 +00:00
|
|
|
styleSet->ResolveStyleFor(element, aParentContext, mTreeMatchContext);
|
2014-11-20 18:24:10 +00:00
|
|
|
} else if (thisChildHint ||
|
|
|
|
styleSet->IsInRuleTreeReconstruct()) {
|
|
|
|
// Use ResolveStyleWithReplacement either for actual
|
|
|
|
// replacements, or as a substitute for ReparentStyleContext
|
|
|
|
// that rebuilds the path in the rule tree rather than reusing
|
|
|
|
// the rule node, as we need to do during a rule tree
|
|
|
|
// reconstruct.
|
|
|
|
undisplayedContext =
|
2015-02-16 22:15:05 +00:00
|
|
|
styleSet->ResolveStyleWithReplacement(element, nullptr,
|
2014-11-20 18:24:10 +00:00
|
|
|
aParentContext,
|
2014-11-20 18:24:10 +00:00
|
|
|
undisplayed->mStyle,
|
|
|
|
thisChildHint);
|
|
|
|
} else {
|
|
|
|
undisplayedContext =
|
|
|
|
styleSet->ReparentStyleContext(undisplayed->mStyle,
|
2014-11-20 18:24:10 +00:00
|
|
|
aParentContext,
|
2015-02-16 22:15:05 +00:00
|
|
|
element);
|
2014-11-20 18:24:10 +00:00
|
|
|
}
|
|
|
|
const nsStyleDisplay* display = undisplayedContext->StyleDisplay();
|
|
|
|
if (display->mDisplay != aDisplay) {
|
|
|
|
NS_ASSERTION(element, "Must have undisplayed content");
|
|
|
|
mChangeList->AppendChange(nullptr, element,
|
|
|
|
NS_STYLE_HINT_FRAMECHANGE);
|
|
|
|
// The node should be removed from the undisplayed map when
|
|
|
|
// we reframe it.
|
|
|
|
} else {
|
|
|
|
// update the undisplayed node with the new context
|
|
|
|
undisplayed->mStyle = undisplayedContext;
|
|
|
|
|
|
|
|
if (aDisplay == NS_STYLE_DISPLAY_CONTENTS) {
|
2014-11-20 18:24:10 +00:00
|
|
|
DoRestyleUndisplayedDescendants(aChildRestyleHint, element,
|
|
|
|
undisplayed->mStyle);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
void
|
2014-08-25 04:48:21 +00:00
|
|
|
ElementRestyler::MaybeReframeForBeforePseudo()
|
2014-11-20 18:24:10 +00:00
|
|
|
{
|
|
|
|
MaybeReframeForBeforePseudo(mFrame, mFrame, mFrame->GetContent(),
|
|
|
|
mFrame->StyleContext());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ElementRestyler::MaybeReframeForBeforePseudo(nsIFrame* aGenConParentFrame,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext)
|
2013-07-31 00:36:11 +00:00
|
|
|
{
|
2013-07-31 00:36:12 +00:00
|
|
|
// Make sure not to do this for pseudo-frames or frames that
|
|
|
|
// can't have generated content.
|
2014-05-24 22:20:39 +00:00
|
|
|
nsContainerFrame* cif;
|
2014-11-20 18:24:10 +00:00
|
|
|
if (!aStyleContext->GetPseudo() &&
|
|
|
|
((aGenConParentFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
|
|
|
|
// Our content insertion frame might have gotten flagged.
|
|
|
|
((cif = aGenConParentFrame->GetContentInsertionFrame()) &&
|
2014-05-24 22:20:39 +00:00
|
|
|
(cif->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT)))) {
|
2014-11-20 18:24:10 +00:00
|
|
|
// Check for a ::before pseudo style and the absence of a ::before content,
|
2015-01-11 23:43:10 +00:00
|
|
|
// but only if aFrame is null or is the first continuation/ib-split.
|
|
|
|
if (!aFrame ||
|
|
|
|
nsLayoutUtils::IsFirstContinuationOrIBSplitSibling(aFrame)) {
|
2014-11-20 18:24:10 +00:00
|
|
|
// Checking for a ::before frame is cheaper than getting the
|
|
|
|
// ::before style context.
|
|
|
|
if (!nsLayoutUtils::GetBeforeFrameForContent(aGenConParentFrame, aContent) &&
|
|
|
|
nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
|
2013-07-31 00:36:12 +00:00
|
|
|
nsCSSPseudoElements::ePseudo_before,
|
|
|
|
mPresContext)) {
|
2014-11-20 18:24:10 +00:00
|
|
|
// Have to create the new ::before frame.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("MaybeReframeForBeforePseudo, appending "
|
|
|
|
"nsChangeHint_ReconstructFrame");
|
2013-07-31 00:36:12 +00:00
|
|
|
NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame);
|
2014-11-20 18:24:10 +00:00
|
|
|
mChangeList->AppendChange(aFrame, aContent,
|
2013-07-31 00:36:12 +00:00
|
|
|
nsChangeHint_ReconstructFrame);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
/**
|
|
|
|
* aFrame is the last continuation or block-in-inline sibling that this
|
|
|
|
* ElementRestyler is restyling.
|
|
|
|
*/
|
2013-07-31 00:36:11 +00:00
|
|
|
void
|
2014-08-25 04:48:21 +00:00
|
|
|
ElementRestyler::MaybeReframeForAfterPseudo(nsIFrame* aFrame)
|
2014-11-20 18:24:10 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFrame);
|
|
|
|
MaybeReframeForAfterPseudo(aFrame, aFrame, aFrame->GetContent(),
|
|
|
|
aFrame->StyleContext());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ElementRestyler::MaybeReframeForAfterPseudo(nsIFrame* aGenConParentFrame,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext)
|
2013-07-31 00:36:11 +00:00
|
|
|
{
|
2013-07-31 00:36:12 +00:00
|
|
|
// Make sure not to do this for pseudo-frames or frames that
|
|
|
|
// can't have generated content.
|
2014-05-24 22:20:39 +00:00
|
|
|
nsContainerFrame* cif;
|
2014-11-20 18:24:10 +00:00
|
|
|
if (!aStyleContext->GetPseudo() &&
|
|
|
|
((aGenConParentFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
|
|
|
|
// Our content insertion frame might have gotten flagged.
|
|
|
|
((cif = aGenConParentFrame->GetContentInsertionFrame()) &&
|
2014-05-24 22:20:39 +00:00
|
|
|
(cif->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT)))) {
|
2014-11-20 18:24:10 +00:00
|
|
|
// Check for an ::after pseudo style and the absence of an ::after content,
|
2015-01-11 23:43:10 +00:00
|
|
|
// but only if aFrame is null or is the last continuation/ib-split.
|
|
|
|
if (!aFrame ||
|
|
|
|
!nsLayoutUtils::GetNextContinuationOrIBSplitSibling(aFrame)) {
|
2014-11-20 18:24:10 +00:00
|
|
|
// Checking for an ::after frame is cheaper than getting the
|
|
|
|
// ::after style context.
|
|
|
|
if (!nsLayoutUtils::GetAfterFrameForContent(aGenConParentFrame, aContent) &&
|
|
|
|
nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
|
2013-07-31 00:36:12 +00:00
|
|
|
nsCSSPseudoElements::ePseudo_after,
|
2014-11-20 18:24:10 +00:00
|
|
|
mPresContext)) {
|
|
|
|
// Have to create the new ::after frame.
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("MaybeReframeForAfterPseudo, appending "
|
|
|
|
"nsChangeHint_ReconstructFrame");
|
2013-07-31 00:36:12 +00:00
|
|
|
NS_UpdateHint(mHintsHandled, nsChangeHint_ReconstructFrame);
|
2013-09-25 19:28:07 +00:00
|
|
|
mChangeList->AppendChange(aFrame, mContent,
|
2013-07-31 00:36:12 +00:00
|
|
|
nsChangeHint_ReconstructFrame);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
void
|
2014-11-20 18:24:10 +00:00
|
|
|
ElementRestyler::InitializeAccessibilityNotifications(nsStyleContext* aNewContext)
|
2013-07-31 00:36:11 +00:00
|
|
|
{
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2013-07-31 00:36:12 +00:00
|
|
|
// Notify a11y for primary frame only if it's a root frame of visibility
|
|
|
|
// changes or its parent frame was hidden while it stays visible and
|
|
|
|
// it is not inside a {ib} split or is the first frame of {ib} split.
|
|
|
|
if (nsIPresShell::IsAccessibilityActive() &&
|
2014-11-20 18:24:10 +00:00
|
|
|
(!mFrame ||
|
|
|
|
(!mFrame->GetPrevContinuation() &&
|
|
|
|
!mFrame->FrameIsNonFirstInIBSplit()))) {
|
2013-07-31 00:36:12 +00:00
|
|
|
if (mDesiredA11yNotifications == eSendAllNotifications) {
|
2014-11-20 18:24:10 +00:00
|
|
|
bool isFrameVisible = aNewContext->StyleVisibility()->IsVisible();
|
2013-07-31 00:36:12 +00:00
|
|
|
if (isFrameVisible != mWasFrameVisible) {
|
|
|
|
if (isFrameVisible) {
|
|
|
|
// Notify a11y the element (perhaps with its children) was shown.
|
|
|
|
// We don't fall into this case if this element gets or stays shown
|
|
|
|
// while its parent becomes hidden.
|
2013-07-31 00:36:10 +00:00
|
|
|
mKidsDesiredA11yNotifications = eSkipNotifications;
|
2013-07-31 00:36:12 +00:00
|
|
|
mOurA11yNotification = eNotifyShown;
|
|
|
|
} else {
|
|
|
|
// The element is being hidden; its children may stay visible, or
|
|
|
|
// become visible after being hidden previously. If we'll find
|
|
|
|
// visible children then we should notify a11y about that as if
|
|
|
|
// they were inserted into tree. Notify a11y this element was
|
|
|
|
// hidden.
|
|
|
|
mKidsDesiredA11yNotifications = eNotifyIfShown;
|
|
|
|
mOurA11yNotification = eNotifyHidden;
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
} else if (mDesiredA11yNotifications == eNotifyIfShown &&
|
2014-11-20 18:24:10 +00:00
|
|
|
aNewContext->StyleVisibility()->IsVisible()) {
|
|
|
|
// Notify a11y that element stayed visible while its parent was hidden.
|
|
|
|
nsIContent* c = mFrame ? mFrame->GetContent() : mContent;
|
|
|
|
mVisibleKidsOfHiddenElement.AppendElement(c);
|
2013-07-31 00:36:12 +00:00
|
|
|
mKidsDesiredA11yNotifications = eSkipNotifications;
|
|
|
|
}
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
#endif
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
void
|
2013-09-25 19:28:07 +00:00
|
|
|
ElementRestyler::RestyleContentChildren(nsIFrame* aParent,
|
|
|
|
nsRestyleHint aChildRestyleHint)
|
2013-07-31 00:36:11 +00:00
|
|
|
{
|
2014-09-25 05:45:36 +00:00
|
|
|
LOG_RESTYLE("RestyleContentChildren");
|
|
|
|
|
2013-09-25 19:28:07 +00:00
|
|
|
nsIFrame::ChildListIterator lists(aParent);
|
2013-11-17 06:51:04 +00:00
|
|
|
TreeMatchContext::AutoAncestorPusher ancestorPusher(mTreeMatchContext);
|
|
|
|
if (!lists.IsDone()) {
|
|
|
|
ancestorPusher.PushAncestorAndStyleScope(mContent);
|
|
|
|
}
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
2013-07-31 00:36:12 +00:00
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
2013-09-25 19:28:07 +00:00
|
|
|
// Out-of-flows are reached through their placeholders. Continuations
|
|
|
|
// and block-in-inline splits are reached through those chains.
|
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
|
|
|
!GetPrevContinuationWithSameStyle(child)) {
|
2013-07-31 00:36:12 +00:00
|
|
|
// Get the parent of the child frame's content and check if it
|
|
|
|
// is a XBL children element. Push the children element as an
|
|
|
|
// ancestor here because it does not have a frame and would not
|
|
|
|
// otherwise be pushed as an ancestor.
|
2013-07-31 00:36:12 +00:00
|
|
|
|
2013-07-31 00:36:12 +00:00
|
|
|
// Check if the frame has a content because |child| may be a
|
|
|
|
// nsPageFrame that does not have a content.
|
2013-07-31 00:36:12 +00:00
|
|
|
nsIContent* parent = child->GetContent() ? child->GetContent()->GetParent() : nullptr;
|
2013-11-17 06:51:04 +00:00
|
|
|
TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
|
2013-12-02 10:26:12 +00:00
|
|
|
if (parent && nsContentUtils::IsContentInsertionPoint(parent)) {
|
2013-11-17 06:51:04 +00:00
|
|
|
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
|
|
|
|
// only do frames that are in flow
|
|
|
|
if (nsGkAtoms::placeholderFrame == child->GetType()) { // placeholder
|
|
|
|
// get out of flow frame and recur there
|
|
|
|
nsIFrame* outOfFlowFrame =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
|
|
|
|
NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
|
|
|
|
NS_ASSERTION(outOfFlowFrame != mResolvedChild,
|
|
|
|
"out-of-flow frame not a true descendant");
|
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
// |nsFrame::GetParentStyleContext| checks being out
|
2013-07-31 00:36:12 +00:00
|
|
|
// of flow so that this works correctly.
|
|
|
|
do {
|
2013-09-25 19:28:07 +00:00
|
|
|
if (GetPrevContinuationWithSameStyle(outOfFlowFrame)) {
|
|
|
|
// Later continuations are likely restyled as a result of
|
|
|
|
// the restyling of the previous continuation.
|
|
|
|
// (Currently that's always true, but it's likely to
|
|
|
|
// change if we implement overflow:fragments or similar.)
|
|
|
|
continue;
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
ElementRestyler oofRestyler(*this, outOfFlowFrame,
|
|
|
|
FOR_OUT_OF_FLOW_CHILD);
|
|
|
|
oofRestyler.Restyle(aChildRestyleHint);
|
|
|
|
} while ((outOfFlowFrame = outOfFlowFrame->GetNextContinuation()));
|
|
|
|
|
|
|
|
// reresolve placeholder's context under the same parent
|
|
|
|
// as the out-of-flow frame
|
|
|
|
ElementRestyler phRestyler(*this, child, 0);
|
|
|
|
phRestyler.Restyle(aChildRestyleHint);
|
|
|
|
}
|
|
|
|
else { // regular child frame
|
|
|
|
if (child != mResolvedChild) {
|
|
|
|
ElementRestyler childRestyler(*this, child, 0);
|
|
|
|
childRestyler.Restyle(aChildRestyleHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// XXX need to do overflow frames???
|
2013-07-31 00:36:11 +00:00
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
void
|
|
|
|
ElementRestyler::SendAccessibilityNotifications()
|
|
|
|
{
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2013-07-31 00:36:12 +00:00
|
|
|
// Send notifications about visibility changes.
|
|
|
|
if (mOurA11yNotification == eNotifyShown) {
|
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
|
|
|
if (accService) {
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIPresShell* presShell = mPresContext->GetPresShell();
|
|
|
|
nsIContent* content = mFrame ? mFrame->GetContent() : mContent;
|
2013-07-31 00:36:12 +00:00
|
|
|
|
|
|
|
accService->ContentRangeInserted(presShell, content->GetParent(),
|
|
|
|
content,
|
|
|
|
content->GetNextSibling());
|
|
|
|
}
|
|
|
|
} else if (mOurA11yNotification == eNotifyHidden) {
|
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
|
|
|
if (accService) {
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIPresShell* presShell = mPresContext->GetPresShell();
|
|
|
|
nsIContent* content = mFrame ? mFrame->GetContent() : mContent;
|
2014-09-20 00:02:30 +00:00
|
|
|
accService->ContentRemoved(presShell, content);
|
2013-07-31 00:36:12 +00:00
|
|
|
|
|
|
|
// Process children staying shown.
|
|
|
|
uint32_t visibleContentCount = mVisibleKidsOfHiddenElement.Length();
|
|
|
|
for (uint32_t idx = 0; idx < visibleContentCount; idx++) {
|
|
|
|
nsIContent* childContent = mVisibleKidsOfHiddenElement[idx];
|
|
|
|
accService->ContentRangeInserted(presShell, childContent->GetParent(),
|
|
|
|
childContent,
|
|
|
|
childContent->GetNextSibling());
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
2013-07-31 00:36:12 +00:00
|
|
|
mVisibleKidsOfHiddenElement.Clear();
|
|
|
|
}
|
|
|
|
}
|
2013-07-20 19:14:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-17 22:28:53 +00:00
|
|
|
static void
|
|
|
|
ClearCachedInheritedStyleDataOnDescendants(
|
|
|
|
nsTArray<ElementRestyler::ContextToClear>& aContextsToClear)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < aContextsToClear.Length(); i++) {
|
|
|
|
auto& entry = aContextsToClear[i];
|
|
|
|
if (!entry.mStyleContext->HasSingleReference()) {
|
|
|
|
entry.mStyleContext->ClearCachedInheritedStyleDataOnDescendants(
|
|
|
|
entry.mStructs);
|
|
|
|
}
|
|
|
|
entry.mStyleContext = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-13 22:39:00 +00:00
|
|
|
void
|
|
|
|
RestyleManager::ComputeAndProcessStyleChange(nsIFrame* aFrame,
|
|
|
|
nsChangeHint aMinChange,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
nsRestyleHint aRestyleHint)
|
|
|
|
{
|
2015-01-14 05:03:13 +00:00
|
|
|
MOZ_ASSERT(mReframingStyleContexts, "should have rsc");
|
2014-08-13 22:39:00 +00:00
|
|
|
nsStyleChangeList changeList;
|
2015-02-17 22:28:53 +00:00
|
|
|
nsTArray<ElementRestyler::ContextToClear> contextsToClear;
|
2015-04-14 22:13:45 +00:00
|
|
|
|
|
|
|
// swappedStructOwners needs to be kept alive until after
|
|
|
|
// ProcessRestyledFrames and ClearCachedInheritedStyleDataOnDescendants
|
|
|
|
// calls; see comment in ElementRestyler::Restyle.
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>> swappedStructOwners;
|
|
|
|
ElementRestyler::ComputeStyleChangeFor(aFrame, &changeList, aMinChange,
|
|
|
|
aRestyleTracker, aRestyleHint,
|
|
|
|
contextsToClear, swappedStructOwners);
|
|
|
|
ProcessRestyledFrames(changeList);
|
2015-02-17 22:28:53 +00:00
|
|
|
ClearCachedInheritedStyleDataOnDescendants(contextsToClear);
|
2014-08-13 22:39:00 +00:00
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
void
|
2014-11-20 18:24:10 +00:00
|
|
|
RestyleManager::ComputeAndProcessStyleChange(nsStyleContext* aNewContext,
|
|
|
|
Element* aElement,
|
|
|
|
nsChangeHint aMinChange,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
nsRestyleHint aRestyleHint)
|
2013-07-20 19:14:25 +00:00
|
|
|
{
|
2015-01-14 05:03:13 +00:00
|
|
|
MOZ_ASSERT(mReframingStyleContexts, "should have rsc");
|
2014-11-20 18:24:10 +00:00
|
|
|
MOZ_ASSERT(aNewContext->StyleDisplay()->mDisplay == NS_STYLE_DISPLAY_CONTENTS);
|
|
|
|
nsIFrame* frame = GetNearestAncestorFrame(aElement);
|
|
|
|
MOZ_ASSERT(frame, "display:contents node in map although it's a "
|
|
|
|
"display:none descendant?");
|
2013-07-20 19:14:25 +00:00
|
|
|
TreeMatchContext treeMatchContext(true,
|
|
|
|
nsRuleWalker::eRelevantLinkUnvisited,
|
2014-11-20 18:24:10 +00:00
|
|
|
frame->PresContext()->Document());
|
|
|
|
nsIContent* parent = aElement->GetParent();
|
|
|
|
Element* parentElement =
|
|
|
|
parent && parent->IsElement() ? parent->AsElement() : nullptr;
|
|
|
|
treeMatchContext.InitAncestors(parentElement);
|
2013-07-20 19:14:25 +00:00
|
|
|
nsTArray<nsIContent*> visibleKidsOfHiddenElement;
|
2015-02-17 22:28:53 +00:00
|
|
|
nsTArray<ElementRestyler::ContextToClear> contextsToClear;
|
2015-04-14 22:13:45 +00:00
|
|
|
|
|
|
|
// swappedStructOwners needs to be kept alive until after
|
|
|
|
// ProcessRestyledFrames and ClearCachedInheritedStyleDataOnDescendants
|
|
|
|
// calls; see comment in ElementRestyler::Restyle.
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>> swappedStructOwners;
|
|
|
|
nsStyleChangeList changeList;
|
|
|
|
ElementRestyler r(frame->PresContext(), aElement, &changeList, aMinChange,
|
|
|
|
aRestyleTracker, treeMatchContext,
|
|
|
|
visibleKidsOfHiddenElement, contextsToClear,
|
|
|
|
swappedStructOwners);
|
|
|
|
r.RestyleChildrenOfDisplayContentsElement(frame, aNewContext, aMinChange,
|
|
|
|
aRestyleTracker, aRestyleHint);
|
|
|
|
ProcessRestyledFrames(changeList);
|
2015-02-17 22:28:53 +00:00
|
|
|
ClearCachedInheritedStyleDataOnDescendants(contextsToClear);
|
2013-07-20 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
2014-11-20 18:24:09 +00:00
|
|
|
AutoDisplayContentsAncestorPusher::AutoDisplayContentsAncestorPusher(
|
|
|
|
TreeMatchContext& aTreeMatchContext, nsPresContext* aPresContext,
|
|
|
|
nsIContent* aParent)
|
|
|
|
: mTreeMatchContext(aTreeMatchContext)
|
|
|
|
, mPresContext(aPresContext)
|
|
|
|
{
|
|
|
|
if (aParent) {
|
|
|
|
nsFrameManager* fm = mPresContext->FrameManager();
|
|
|
|
// Push display:contents mAncestors onto mTreeMatchContext.
|
|
|
|
for (nsIContent* p = aParent; p && fm->GetDisplayContentsStyleFor(p);
|
|
|
|
p = p->GetParent()) {
|
|
|
|
mAncestors.AppendElement(p->AsElement());
|
|
|
|
}
|
|
|
|
bool hasFilter = mTreeMatchContext.mAncestorFilter.HasFilter();
|
|
|
|
nsTArray<mozilla::dom::Element*>::size_type i = mAncestors.Length();
|
|
|
|
while (i--) {
|
|
|
|
if (hasFilter) {
|
|
|
|
mTreeMatchContext.mAncestorFilter.PushAncestor(mAncestors[i]);
|
|
|
|
}
|
|
|
|
mTreeMatchContext.PushStyleScope(mAncestors[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoDisplayContentsAncestorPusher::~AutoDisplayContentsAncestorPusher()
|
|
|
|
{
|
|
|
|
// Pop the ancestors we pushed in the CTOR, if any.
|
|
|
|
typedef nsTArray<mozilla::dom::Element*>::size_type sz;
|
|
|
|
sz len = mAncestors.Length();
|
|
|
|
bool hasFilter = mTreeMatchContext.mAncestorFilter.HasFilter();
|
|
|
|
for (sz i = 0; i < len; ++i) {
|
|
|
|
if (hasFilter) {
|
|
|
|
mTreeMatchContext.mAncestorFilter.PopAncestor();
|
|
|
|
}
|
|
|
|
mTreeMatchContext.PopStyleScope(mAncestors[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-30 23:13:57 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
uint32_t
|
|
|
|
RestyleManager::StructsToLog()
|
|
|
|
{
|
|
|
|
static bool initialized = false;
|
|
|
|
static uint32_t structs;
|
|
|
|
if (!initialized) {
|
|
|
|
structs = 0;
|
|
|
|
const char* value = getenv("MOZ_DEBUG_RESTYLE_STRUCTS");
|
|
|
|
if (value) {
|
|
|
|
nsCString s(value);
|
|
|
|
while (!s.IsEmpty()) {
|
|
|
|
int32_t index = s.FindChar(',');
|
|
|
|
nsStyleStructID sid;
|
|
|
|
bool found;
|
|
|
|
if (index == -1) {
|
|
|
|
found = nsStyleContext::LookupStruct(s, sid);
|
|
|
|
s.Truncate();
|
|
|
|
} else {
|
|
|
|
found = nsStyleContext::LookupStruct(Substring(s, 0, index), sid);
|
|
|
|
s = Substring(s, index + 1);
|
|
|
|
}
|
|
|
|
if (found) {
|
|
|
|
structs |= nsCachedStyleData::GetBitForSID(sid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
return structs;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */ nsCString
|
|
|
|
RestyleManager::RestyleHintToString(nsRestyleHint aHint)
|
|
|
|
{
|
|
|
|
nsCString result;
|
|
|
|
bool any = false;
|
|
|
|
const char* names[] = { "Self", "Subtree", "LaterSiblings", "CSSTransitions",
|
|
|
|
"CSSAnimations", "SVGAttrAnimations", "StyleAttribute",
|
2015-04-21 22:03:31 +00:00
|
|
|
"StyleAttribute_Animations", "Force", "ForceDescendants" };
|
2014-09-25 05:45:36 +00:00
|
|
|
uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
|
|
|
|
uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(names); i++) {
|
|
|
|
if (hint & (1 << i)) {
|
|
|
|
if (any) {
|
|
|
|
result.AppendLiteral(" | ");
|
|
|
|
}
|
|
|
|
result.AppendPrintf("eRestyle_%s", names[i]);
|
|
|
|
any = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rest) {
|
|
|
|
if (any) {
|
|
|
|
result.AppendLiteral(" | ");
|
|
|
|
}
|
|
|
|
result.AppendPrintf("0x%0x", rest);
|
|
|
|
} else {
|
|
|
|
if (!any) {
|
|
|
|
result.AppendLiteral("0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nsCString
|
|
|
|
RestyleManager::ChangeHintToString(nsChangeHint aHint)
|
|
|
|
{
|
|
|
|
nsCString result;
|
|
|
|
bool any = false;
|
|
|
|
const char* names[] = {
|
|
|
|
"RepaintFrame", "NeedReflow", "ClearAncestorIntrinsics",
|
|
|
|
"ClearDescendantIntrinsics", "NeedDirtyReflow", "SyncFrameView",
|
|
|
|
"UpdateCursor", "UpdateEffects", "UpdateOpacityLayer",
|
|
|
|
"UpdateTransformLayer", "ReconstructFrame", "UpdateOverflow",
|
|
|
|
"UpdateSubtreeOverflow", "UpdatePostTransformOverflow",
|
2015-02-16 03:34:29 +00:00
|
|
|
"UpdateParentOverflow",
|
2014-09-25 05:45:36 +00:00
|
|
|
"ChildrenOnlyTransform", "RecomputePosition", "AddOrRemoveTransform",
|
2015-04-21 22:03:31 +00:00
|
|
|
"BorderStyleNoneChange", "UpdateTextPath", "SchedulePaint",
|
|
|
|
"NeutralChange", "InvalidateRenderingObservers"
|
2014-09-25 05:45:36 +00:00
|
|
|
};
|
|
|
|
uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
|
|
|
|
uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
|
|
|
|
if (hint == nsChangeHint_Hints_NotHandledForDescendants) {
|
|
|
|
result.AppendLiteral("nsChangeHint_Hints_NotHandledForDescendants");
|
|
|
|
hint = 0;
|
|
|
|
any = true;
|
|
|
|
} else {
|
|
|
|
if ((hint & NS_STYLE_HINT_FRAMECHANGE) == NS_STYLE_HINT_FRAMECHANGE) {
|
|
|
|
result.AppendLiteral("NS_STYLE_HINT_FRAMECHANGE");
|
|
|
|
hint = hint & ~NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
any = true;
|
|
|
|
} else if ((hint & NS_STYLE_HINT_REFLOW) == NS_STYLE_HINT_REFLOW) {
|
|
|
|
result.AppendLiteral("NS_STYLE_HINT_REFLOW");
|
|
|
|
hint = hint & ~NS_STYLE_HINT_REFLOW;
|
|
|
|
any = true;
|
|
|
|
} else if ((hint & nsChangeHint_AllReflowHints) == nsChangeHint_AllReflowHints) {
|
|
|
|
result.AppendLiteral("nsChangeHint_AllReflowHints");
|
|
|
|
hint = hint & ~nsChangeHint_AllReflowHints;
|
|
|
|
any = true;
|
|
|
|
} else if ((hint & NS_STYLE_HINT_VISUAL) == NS_STYLE_HINT_VISUAL) {
|
|
|
|
result.AppendLiteral("NS_STYLE_HINT_VISUAL");
|
|
|
|
hint = hint & ~NS_STYLE_HINT_VISUAL;
|
|
|
|
any = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(names); i++) {
|
|
|
|
if (hint & (1 << i)) {
|
|
|
|
if (any) {
|
|
|
|
result.AppendLiteral(" | ");
|
|
|
|
}
|
|
|
|
result.AppendPrintf("nsChangeHint_%s", names[i]);
|
|
|
|
any = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rest) {
|
|
|
|
if (any) {
|
|
|
|
result.AppendLiteral(" | ");
|
|
|
|
}
|
|
|
|
result.AppendPrintf("0x%0x", rest);
|
|
|
|
} else {
|
|
|
|
if (!any) {
|
|
|
|
result.AppendLiteral("NS_STYLE_HINT_NONE");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nsCString
|
|
|
|
RestyleManager::StructNamesToString(uint32_t aSIDs)
|
|
|
|
{
|
|
|
|
nsCString result;
|
|
|
|
bool any = false;
|
|
|
|
for (nsStyleStructID sid = nsStyleStructID(0);
|
|
|
|
sid < nsStyleStructID_Length;
|
|
|
|
sid = nsStyleStructID(sid + 1)) {
|
|
|
|
if (aSIDs & nsCachedStyleData::GetBitForSID(sid)) {
|
|
|
|
if (any) {
|
|
|
|
result.AppendLiteral(",");
|
|
|
|
}
|
|
|
|
result.AppendPrintf("%s", nsStyleContext::StructName(sid));
|
|
|
|
any = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nsCString
|
|
|
|
ElementRestyler::RestyleResultToString(RestyleResult aRestyleResult)
|
|
|
|
{
|
|
|
|
nsCString result;
|
|
|
|
switch (aRestyleResult) {
|
|
|
|
case eRestyleResult_Stop:
|
|
|
|
result.AssignLiteral("eRestyleResult_Stop");
|
|
|
|
break;
|
|
|
|
case eRestyleResult_Continue:
|
|
|
|
result.AssignLiteral("eRestyleResult_Continue");
|
|
|
|
break;
|
|
|
|
case eRestyleResult_ContinueAndForceDescendants:
|
|
|
|
result.AssignLiteral("eRestyleResult_ContinueAndForceDescendants");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result.AppendPrintf("RestyleResult(%d)", aRestyleResult);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-20 19:14:24 +00:00
|
|
|
} // namespace mozilla
|