2017-10-27 17:33:53 +00: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: */
|
2017-06-11 05:27:45 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#include "mozilla/ServoStyleContext.h"
|
|
|
|
|
2017-08-04 21:34:18 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2017-06-11 05:27:45 +00:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsStyleStruct.h"
|
|
|
|
#include "nsPresContext.h"
|
2017-07-17 18:42:24 +00:00
|
|
|
#include "nsCSSRuleProcessor.h"
|
|
|
|
#include "mozilla/dom/HTMLBodyElement.h"
|
2017-06-11 05:27:45 +00:00
|
|
|
|
|
|
|
#include "mozilla/ServoBindings.h"
|
|
|
|
|
2017-07-21 03:42:42 +00:00
|
|
|
namespace mozilla {
|
2017-06-11 05:27:45 +00:00
|
|
|
|
2017-07-21 03:42:42 +00:00
|
|
|
ServoStyleContext::ServoStyleContext(
|
|
|
|
nsPresContext* aPresContext,
|
2017-10-02 22:05:19 +00:00
|
|
|
nsAtom* aPseudoTag,
|
2017-07-21 03:42:42 +00:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2017-07-21 04:44:02 +00:00
|
|
|
ServoComputedDataForgotten aComputedValues)
|
2017-07-31 14:21:40 +00:00
|
|
|
: nsStyleContext(aPseudoTag, aPseudoType)
|
2017-07-23 03:06:06 +00:00
|
|
|
, mPresContext(aPresContext)
|
2017-07-21 03:42:42 +00:00
|
|
|
, mSource(aComputedValues)
|
2017-06-11 05:27:45 +00:00
|
|
|
{
|
2017-07-19 06:17:34 +00:00
|
|
|
AddStyleBit(Servo_ComputedValues_GetStyleBits(this));
|
2017-07-31 14:21:40 +00:00
|
|
|
MOZ_ASSERT(ComputedData());
|
2017-06-11 05:27:45 +00:00
|
|
|
|
|
|
|
// No need to call ApplyStyleFixups here, since fixups are handled by Servo when
|
2017-07-21 04:44:02 +00:00
|
|
|
// producing the ServoComputedData.
|
2017-06-11 05:27:45 +00:00
|
|
|
}
|
2017-07-17 18:42:24 +00:00
|
|
|
|
2017-08-04 21:34:18 +00:00
|
|
|
ServoStyleContext*
|
2017-10-02 22:05:19 +00:00
|
|
|
ServoStyleContext::GetCachedInheritingAnonBoxStyle(nsAtom* aAnonBox) const
|
2017-08-04 21:34:18 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(nsCSSAnonBoxes::IsInheritingAnonBox(aAnonBox));
|
|
|
|
|
|
|
|
// See the reasoning in SetCachedInheritingAnonBoxStyle to understand why we
|
|
|
|
// can't use the cache in this case.
|
|
|
|
if (IsInheritingAnonBox()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* current = mNextInheritingAnonBoxStyle.get();
|
|
|
|
|
|
|
|
while (current && current->GetPseudo() != aAnonBox) {
|
|
|
|
current = current->mNextInheritingAnonBoxStyle.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2017-08-06 16:42:55 +00:00
|
|
|
ServoStyleContext*
|
|
|
|
ServoStyleContext::GetCachedLazyPseudoStyle(CSSPseudoElementType aPseudo) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aPseudo != CSSPseudoElementType::NotPseudo &&
|
|
|
|
aPseudo != CSSPseudoElementType::InheritingAnonBox &&
|
|
|
|
aPseudo != CSSPseudoElementType::NonInheritingAnonBox);
|
|
|
|
MOZ_ASSERT(!IsLazilyCascadedPseudoElement(), "Lazy pseudos can't inherit lazy pseudos");
|
|
|
|
|
|
|
|
if (nsCSSPseudoElements::PseudoElementSupportsUserActionState(aPseudo)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* current = mNextLazyPseudoStyle.get();
|
|
|
|
|
|
|
|
while (current && current->GetPseudoType() != aPseudo) {
|
|
|
|
current = current->mNextLazyPseudoStyle.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2017-07-21 03:42:42 +00:00
|
|
|
} // namespace mozilla
|