2016-02-24 10:01:10 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_ServoStyleSet_h
|
|
|
|
#define mozilla_ServoStyleSet_h
|
|
|
|
|
2016-02-26 04:51:02 +03:00
|
|
|
#include "mozilla/EnumeratedArray.h"
|
2016-02-24 10:01:10 +03:00
|
|
|
#include "mozilla/EventStates.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
2016-01-27 05:02:04 +03:00
|
|
|
#include "mozilla/ServoBindingHelpers.h"
|
2016-07-19 04:02:55 +03:00
|
|
|
#include "mozilla/ServoElementSnapshot.h"
|
2016-02-26 04:51:02 +03:00
|
|
|
#include "mozilla/ServoStyleSheet.h"
|
2016-02-24 10:01:10 +03:00
|
|
|
#include "mozilla/SheetType.h"
|
2016-01-27 05:02:04 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-02-24 10:01:10 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2016-07-19 04:02:55 +03:00
|
|
|
#include "nsChangeHint.h"
|
2016-02-24 10:01:10 +03:00
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
class CSSStyleSheet;
|
2016-07-13 23:42:47 +03:00
|
|
|
class ServoRestyleManager;
|
2016-02-24 10:01:12 +03:00
|
|
|
class ServoStyleSheet;
|
2016-02-24 10:01:10 +03:00
|
|
|
} // namespace mozilla
|
2016-02-24 10:01:12 +03:00
|
|
|
class nsIDocument;
|
2016-02-24 10:01:10 +03:00
|
|
|
class nsStyleContext;
|
|
|
|
class nsPresContext;
|
|
|
|
struct TreeMatchContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The set of style sheets that apply to a document, backed by a Servo
|
|
|
|
* Stylist. A ServoStyleSet contains ServoStyleSheets.
|
|
|
|
*/
|
|
|
|
class ServoStyleSet
|
|
|
|
{
|
2016-07-13 23:42:47 +03:00
|
|
|
friend class ServoRestyleManager;
|
2016-02-24 10:01:10 +03:00
|
|
|
public:
|
2016-02-24 10:01:12 +03:00
|
|
|
ServoStyleSet();
|
|
|
|
|
2016-02-24 10:01:10 +03:00
|
|
|
void Init(nsPresContext* aPresContext);
|
|
|
|
void BeginShutdown();
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
bool GetAuthorStyleDisabled() const;
|
|
|
|
nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
|
|
|
|
|
|
|
|
void BeginUpdate();
|
|
|
|
nsresult EndUpdate();
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveStyleFor(dom::Element* aElement,
|
|
|
|
nsStyleContext* aParentContext);
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveStyleFor(dom::Element* aElement,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
TreeMatchContext& aTreeMatchContext);
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
2016-04-29 07:01:44 +03:00
|
|
|
ResolveStyleForText(nsIContent* aTextNode,
|
|
|
|
nsStyleContext* aParentContext);
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveStyleForOtherNonElement(nsStyleContext* aParentContext);
|
2016-02-24 10:01:10 +03:00
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolvePseudoElementStyle(dom::Element* aParentElement,
|
|
|
|
mozilla::CSSPseudoElementType aType,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
dom::Element* aPseudoElement);
|
|
|
|
|
|
|
|
// aFlags is an nsStyleSet flags bitfield
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext,
|
|
|
|
uint32_t aFlags = 0);
|
|
|
|
|
|
|
|
// manage the set of style sheets in the style set
|
2016-02-24 10:01:12 +03:00
|
|
|
nsresult AppendStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
|
|
|
|
nsresult PrependStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
|
|
|
|
nsresult RemoveStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
|
2016-02-24 10:01:10 +03:00
|
|
|
nsresult ReplaceSheets(SheetType aType,
|
2016-02-24 10:01:12 +03:00
|
|
|
const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets);
|
2016-02-24 10:01:10 +03:00
|
|
|
nsresult InsertStyleSheetBefore(SheetType aType,
|
2016-02-24 10:01:12 +03:00
|
|
|
ServoStyleSheet* aNewSheet,
|
|
|
|
ServoStyleSheet* aReferenceSheet);
|
2016-02-24 10:01:10 +03:00
|
|
|
|
|
|
|
int32_t SheetCount(SheetType aType) const;
|
2016-02-24 10:01:12 +03:00
|
|
|
ServoStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
|
2016-02-24 10:01:10 +03:00
|
|
|
|
2016-02-24 10:01:12 +03:00
|
|
|
nsresult RemoveDocStyleSheet(ServoStyleSheet* aSheet);
|
|
|
|
nsresult AddDocStyleSheet(ServoStyleSheet* aSheet, nsIDocument* aDocument);
|
2016-02-24 10:01:10 +03:00
|
|
|
|
|
|
|
// check whether there is ::before/::after style for an element
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ProbePseudoElementStyle(dom::Element* aParentElement,
|
|
|
|
mozilla::CSSPseudoElementType aType,
|
|
|
|
nsStyleContext* aParentContext);
|
|
|
|
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ProbePseudoElementStyle(dom::Element* aParentElement,
|
|
|
|
mozilla::CSSPseudoElementType aType,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
TreeMatchContext& aTreeMatchContext,
|
|
|
|
dom::Element* aPseudoElement = nullptr);
|
|
|
|
|
|
|
|
// Test if style is dependent on content state
|
|
|
|
nsRestyleHint HasStateDependentStyle(dom::Element* aElement,
|
|
|
|
EventStates aStateMask);
|
2016-07-19 04:02:55 +03:00
|
|
|
nsRestyleHint HasStateDependentStyle(
|
|
|
|
dom::Element* aElement, mozilla::CSSPseudoElementType aPseudoType,
|
|
|
|
dom::Element* aPseudoElement, EventStates aStateMask);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes a restyle hint given a element and a previous element snapshot.
|
|
|
|
*/
|
|
|
|
nsRestyleHint ComputeRestyleHint(dom::Element* aElement,
|
|
|
|
ServoElementSnapshot* aSnapshot);
|
2016-02-24 10:01:12 +03:00
|
|
|
|
2016-07-13 23:42:47 +03:00
|
|
|
/**
|
2016-08-12 00:12:49 +03:00
|
|
|
* Performs a Servo traversal to compute style for all dirty nodes in the
|
2016-08-31 04:06:47 +03:00
|
|
|
* document. The root element must be non-null.
|
2016-08-12 00:12:49 +03:00
|
|
|
*
|
|
|
|
* If aLeaveDirtyBits is true, the dirty/dirty-descendant bits are not
|
|
|
|
* cleared.
|
2016-07-13 23:42:47 +03:00
|
|
|
*/
|
2016-08-12 00:12:49 +03:00
|
|
|
void StyleDocument(bool aLeaveDirtyBits);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Eagerly styles a subtree of dirty nodes that were just appended to the
|
|
|
|
* tree. This is used in situations where we need the style immediately and
|
|
|
|
* cannot wait for a future batch restyle.
|
|
|
|
*
|
|
|
|
* The subtree must have the root dirty bit set, which currently gets
|
|
|
|
* propagated to all descendants. The dirty bits are cleared before
|
|
|
|
* returning.
|
|
|
|
*/
|
|
|
|
void StyleNewSubtree(nsIContent* aContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Like the above, but does not assume that the root node is dirty. When
|
|
|
|
* appending multiple children to a potentially-non-dirty node, it's
|
|
|
|
* preferable to call StyleNewChildren on the node rather than making multiple
|
|
|
|
* calls to StyleNewSubtree on each child, since it allows for more
|
|
|
|
* parallelism.
|
|
|
|
*/
|
|
|
|
void StyleNewChildren(nsIContent* aParent);
|
2016-07-27 03:06:25 +03:00
|
|
|
|
2016-02-24 10:01:12 +03:00
|
|
|
private:
|
2016-04-29 03:56:37 +03:00
|
|
|
already_AddRefed<nsStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
CSSPseudoElementType aPseudoType);
|
|
|
|
|
2016-04-29 07:04:16 +03:00
|
|
|
already_AddRefed<nsStyleContext> GetContext(nsIContent* aContent,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
CSSPseudoElementType aPseudoType);
|
|
|
|
|
2016-03-18 23:14:07 +03:00
|
|
|
nsPresContext* mPresContext;
|
2016-01-27 05:02:04 +03:00
|
|
|
UniquePtr<RawServoStyleSet> mRawSet;
|
|
|
|
EnumeratedArray<SheetType, SheetType::Count,
|
|
|
|
nsTArray<RefPtr<ServoStyleSheet>>> mSheets;
|
2016-02-24 10:01:12 +03:00
|
|
|
int32_t mBatching;
|
2016-02-24 10:01:10 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ServoStyleSet_h
|