Bug 1309868 part 5 - Use const pointer in C++ side for immutable borrowed reference. r?manishearth,heycam
MozReview-Commit-ID: 3aSOgckBtS7
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -128,17 +128,17 @@ Gecko_GetDocumentElement(RawGeckoDocumen
StyleChildrenIteratorOwnedOrNull
Gecko_MaybeCreateStyleChildrenIterator(RawGeckoNodeBorrowed aNode)
{
if (!aNode->IsElement()) {
return nullptr;
}
- Element* el = aNode->AsElement();
+ const Element* el = aNode->AsElement();
return StyleChildrenIterator::IsNeeded(el) ? new StyleChildrenIterator(el)
: nullptr;
}
void
Gecko_DropStyleChildrenIterator(StyleChildrenIteratorOwned aIterator)
{
MOZ_ASSERT(aIterator);
@@ -219,23 +219,23 @@ uint32_t
Gecko_GetNodeFlags(RawGeckoNodeBorrowed aNode)
{
return aNode->GetFlags();
}
void
Gecko_SetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags)
{
- aNode->SetFlags(aFlags);
+ const_cast<nsINode*>(aNode)->SetFlags(aFlags);
}
void
Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags)
{
- aNode->UnsetFlags(aFlags);
+ const_cast<nsINode*>(aNode)->UnsetFlags(aFlags);
}
nsStyleContext*
Gecko_GetStyleContext(RawGeckoNodeBorrowed aNode, nsIAtom* aPseudoTagOrNull)
{
MOZ_ASSERT(aNode->IsContent());
nsIFrame* relevantFrame =
ServoRestyleManager::FrameForPseudoElement(aNode->AsContent(),
@@ -274,17 +274,17 @@ Gecko_CalcStyleDifference(nsStyleContext
void
Gecko_StoreStyleDifference(RawGeckoNodeBorrowed aNode, nsChangeHint aChangeHintToStore)
{
#ifdef MOZ_STYLO
MOZ_ASSERT(aNode->IsElement());
MOZ_ASSERT(aNode->IsDirtyForServo(),
"Change hint stored in a not-dirty node");
- Element* aElement = aNode->AsElement();
+ const Element* aElement = aNode->AsElement();
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
if (!primaryFrame) {
// If there's no primary frame, that means that either this content is
// undisplayed (so we only need to check at the restyling phase for the
// display value on the element), or is a display: contents element.
//
// In this second case, we should store it in the frame constructor display
// contents map. Note that while this operation looks hairy, this would be
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -70,18 +70,18 @@ using mozilla::dom::StyleChildrenIterato
//
// The "Owned" types generate Owned<T> or OwnedOrNull<T>. Some of these
// are Servo-managed and can be converted to Box<ServoType> on the
// Servo side.
//
// The "Arc" types are Servo-managed Arc<ServoType>s, which are passed
// over FFI as Strong<T> (which is nullable).
// Note that T != ServoType, rather T is ArcInner<ServoType>
-#define DECL_BORROWED_REF_TYPE_FOR(type_) typedef type_* type_##Borrowed;
-#define DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedOrNull;
+#define DECL_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##Borrowed;
+#define DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) typedef type_ const* type_##BorrowedOrNull;
#define DECL_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMut;
#define DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR(type_) typedef type_* type_##BorrowedMutOrNull;
#define DECL_ARC_REF_TYPE_FOR(type_) \
DECL_NULLABLE_BORROWED_REF_TYPE_FOR(type_) \
DECL_BORROWED_REF_TYPE_FOR(type_) \
struct MOZ_MUST_USE_TYPE type_##Strong \
{ \