Skip to content

Commit

Permalink
Bug 1265818 - Part 1 - Convert nsILayoutHistoryState header to IDL. r…
Browse files Browse the repository at this point in the history
…=jst

Preparatory step to make nsILayoutHistoryState scriptable.

MozReview-Commit-ID: DWgXr0imRVb

--HG--
rename : layout/base/nsILayoutHistoryState.h => layout/base/nsILayoutHistoryState.idl
extra : rebase_source : c64ef4108df187c750852d5a364a5cb15d4e9d0d
  • Loading branch information
buttercookie42 committed Mar 4, 2017
1 parent a1f0215 commit 3d605b1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 38 deletions.
2 changes: 1 addition & 1 deletion layout/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ with Files('AccessibleCaret*'):
BUG_COMPONENT = ('Core', 'Selection')

XPIDL_SOURCES += [
'nsILayoutHistoryState.idl',
'nsIPreloadedStyleSheet.idl',
'nsIStyleSheetService.idl',
]
Expand Down Expand Up @@ -47,7 +48,6 @@ EXPORTS += [
'nsFrameTraversal.h',
'nsIFrameTraversal.h',
'nsILayoutDebugger.h',
'nsILayoutHistoryState.h',
'nsIPercentBSizeObserver.h',
'nsIPresShell.h',
'nsIPresShellInlines.h',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* -*- 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/. */
Expand All @@ -8,63 +8,63 @@
* the document is not
*/

#ifndef _nsILayoutHistoryState_h
#define _nsILayoutHistoryState_h
#include "nsISupports.idl"

#include "nsISupports.h"
interface nsPresState;

[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 */

17 changes: 2 additions & 15 deletions layout/base/nsLayoutHistoryState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,7 @@ class nsLayoutHistoryState final : public nsILayoutHistoryState,
}

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() {}
Expand Down Expand Up @@ -85,7 +72,7 @@ nsLayoutHistoryState::RemoveState(const nsCString& aKey)
}

bool
nsLayoutHistoryState::HasStates() const
nsLayoutHistoryState::HasStates()
{
return mStates.Count() != 0;
}
Expand Down

0 comments on commit 3d605b1

Please sign in to comment.