Bug 1265818 - Part 1 - Convert nsILayoutHistoryState header to IDL. r?jst
Preparatory step to make nsILayoutHistoryState scriptable.
MozReview-Commit-ID: DWgXr0imRVb
--- a/layout/base/moz.build
+++ b/layout/base/moz.build
@@ -15,16 +15,17 @@ with Files('nsChangeHint.h'):
with Files('nsBidi*'):
BUG_COMPONENT = ('Core', 'Layout: Text')
with Files('AccessibleCaret*'):
BUG_COMPONENT = ('Core', 'Selection')
XPIDL_SOURCES += [
+ 'nsILayoutHistoryState.idl',
'nsIPreloadedStyleSheet.idl',
'nsIStyleSheetService.idl',
]
if CONFIG['MOZ_DEBUG']:
UNIFIED_SOURCES += [
'nsAutoLayoutPhase.cpp',
]
@@ -42,17 +43,16 @@ EXPORTS += [
'nsChangeHint.h',
'nsCompatibility.h',
'nsCSSFrameConstructor.h',
'nsFrameManager.h',
'nsFrameManagerBase.h',
'nsFrameTraversal.h',
'nsIFrameTraversal.h',
'nsILayoutDebugger.h',
- 'nsILayoutHistoryState.h',
'nsIPercentBSizeObserver.h',
'nsIPresShell.h',
'nsIPresShellInlines.h',
'nsIReflowCallback.h',
'nsLayoutUtils.h',
'nsPresArena.h',
'nsPresArenaObjectList.h',
'nsPresContext.h',
rename from layout/base/nsILayoutHistoryState.h
rename to layout/base/nsILayoutHistoryState.idl
--- a/layout/base/nsILayoutHistoryState.h
+++ b/layout/base/nsILayoutHistoryState.idl
@@ -1,70 +1,70 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: IDL; 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/. */
/*
* interface for container for information saved in session history when
* the document is not
*/
-#ifndef _nsILayoutHistoryState_h
-#define _nsILayoutHistoryState_h
+#include "nsISupports.idl"
+
+interface nsPresState;
-#include "nsISupports.h"
+[ptr] native nsPresStatePtr(nsPresState);
+[ref] native nsCString(const nsCString);
+native constBool(const bool);
+
+%{C++
#include "nsStringFwd.h"
-class nsPresState;
template<typename> struct already_AddRefed;
+%}
-#define NS_ILAYOUTHISTORYSTATE_IID \
-{ 0xaef27cb3, 0x4df9, 0x4eeb, \
- { 0xb0, 0xb0, 0xac, 0x56, 0xcf, 0x86, 0x1d, 0x04 } }
-
-class nsILayoutHistoryState : public nsISupports {
- public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILAYOUTHISTORYSTATE_IID)
+[uuid(aef27cb3-4df9-4eeb-b0b0-ac56cf861d04)]
+interface nsILayoutHistoryState : nsISupports
+{
+ // Native only interface, converted from the original nsILayoutHistoryState.h
/**
* Set |aState| as the state object for |aKey|.
* This _transfers_ownership_ of |aState| to the LayoutHistoryState.
* It will be freed when RemoveState() is called or when the
* LayoutHistoryState is destroyed.
*/
- virtual void AddState(const nsCString& aKey, nsPresState* aState) = 0;
+ [noscript, notxpcom, nostdcall] void AddState(in nsCString aKey, in nsPresStatePtr aState);
/**
* Look up the state object for |aKey|.
*/
- virtual nsPresState* GetState(const nsCString& aKey) = 0;
+ [noscript, notxpcom, nostdcall] nsPresStatePtr GetState(in nsCString aKey);
/**
* Remove the state object for |aKey|.
*/
- virtual void RemoveState(const nsCString& aKey) = 0;
+ [noscript, notxpcom, nostdcall] void RemoveState(in nsCString aKey);
/**
* Check whether this history has any states in it
*/
- virtual bool HasStates() const = 0;
+ [noscript, notxpcom, nostdcall] boolean HasStates();
/**
* Sets whether this history can contain only scroll position history
* or all possible history
*/
- virtual void SetScrollPositionOnly(const bool aFlag) = 0;
+ [noscript, notxpcom, nostdcall] void SetScrollPositionOnly(in constBool aFlag);
/**
* Resets nsPresState::GetScrollState of all nsPresState objects to 0,0.
*/
- virtual void ResetScrollState() = 0;
+ [noscript, notxpcom, nostdcall] void ResetScrollState();
};
-NS_DEFINE_STATIC_IID_ACCESSOR(nsILayoutHistoryState,
- NS_ILAYOUTHISTORYSTATE_IID)
-
+%{C++
already_AddRefed<nsILayoutHistoryState>
NS_NewLayoutHistoryState();
+%}
-#endif /* _nsILayoutHistoryState_h */
--- a/layout/base/nsLayoutHistoryState.cpp
+++ b/layout/base/nsLayoutHistoryState.cpp
@@ -19,30 +19,17 @@ class nsLayoutHistoryState final : publi
{
public:
nsLayoutHistoryState()
: mScrollPositionOnly(false)
{
}
NS_DECL_ISUPPORTS
-
- // nsILayoutHistoryState
- virtual void
- AddState(const nsCString& aKey, nsPresState* aState) override;
- virtual nsPresState*
- GetState(const nsCString& aKey) override;
- virtual void
- RemoveState(const nsCString& aKey) override;
- virtual bool
- HasStates() const override;
- virtual void
- SetScrollPositionOnly(const bool aFlag) override;
- virtual void
- ResetScrollState() override;
+ NS_DECL_NSILAYOUTHISTORYSTATE
private:
~nsLayoutHistoryState() {}
bool mScrollPositionOnly;
nsClassHashtable<nsCStringHashKey,nsPresState> mStates;
};
@@ -80,17 +67,17 @@ nsLayoutHistoryState::GetState(const nsC
void
nsLayoutHistoryState::RemoveState(const nsCString& aKey)
{
mStates.Remove(aKey);
}
bool
-nsLayoutHistoryState::HasStates() const
+nsLayoutHistoryState::HasStates()
{
return mStates.Count() != 0;
}
void
nsLayoutHistoryState::SetScrollPositionOnly(const bool aFlag)
{
mScrollPositionOnly = aFlag;