2017-06-11 08:27:45 +03: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/. */
|
|
|
|
|
|
|
|
#include "mozilla/ServoStyleContext.h"
|
|
|
|
|
2017-08-05 00:34:18 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2017-06-11 08:27:45 +03:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsStyleStruct.h"
|
|
|
|
#include "nsPresContext.h"
|
2017-07-17 21:42:24 +03:00
|
|
|
#include "nsCSSRuleProcessor.h"
|
|
|
|
#include "mozilla/dom/HTMLBodyElement.h"
|
2017-06-11 08:27:45 +03:00
|
|
|
|
|
|
|
#include "mozilla/ServoBindings.h"
|
|
|
|
|
2017-07-21 06:42:42 +03:00
|
|
|
namespace mozilla {
|
2017-06-11 08:27:45 +03:00
|
|
|
|
2017-07-21 06:42:42 +03:00
|
|
|
ServoStyleContext::ServoStyleContext(
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
CSSPseudoElementType aPseudoType,
|
2017-07-21 07:44:02 +03:00
|
|
|
ServoComputedDataForgotten aComputedValues)
|
2017-07-31 17:21:40 +03:00
|
|
|
: nsStyleContext(aPseudoTag, aPseudoType)
|
2017-07-23 06:06:06 +03:00
|
|
|
, mPresContext(aPresContext)
|
2017-07-21 06:42:42 +03:00
|
|
|
, mSource(aComputedValues)
|
2017-06-11 08:27:45 +03:00
|
|
|
{
|
2017-07-19 09:17:34 +03:00
|
|
|
AddStyleBit(Servo_ComputedValues_GetStyleBits(this));
|
2017-07-31 17:21:40 +03:00
|
|
|
MOZ_ASSERT(ComputedData());
|
2017-06-11 08:27:45 +03:00
|
|
|
|
|
|
|
// No need to call ApplyStyleFixups here, since fixups are handled by Servo when
|
2017-07-21 07:44:02 +03:00
|
|
|
// producing the ServoComputedData.
|
2017-06-11 08:27:45 +03:00
|
|
|
}
|
2017-07-17 21:42:24 +03:00
|
|
|
|
2017-08-05 00:34:18 +03:00
|
|
|
ServoStyleContext*
|
|
|
|
ServoStyleContext::GetCachedInheritingAnonBoxStyle(nsIAtom* aAnonBox) const
|
|
|
|
{
|
|
|
|
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 19:42:55 +03: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 06:42:42 +03:00
|
|
|
} // namespace mozilla
|