Skip to content

Commit bdddbf0

Browse files
committed
Add missing methods and types for IContextMenuParams
Part of #1589
1 parent f360808 commit bdddbf0

File tree

8 files changed

+273
-30
lines changed

8 files changed

+273
-30
lines changed

CefSharp.Core/Internals/CefContextMenuParamsWrapper.cpp

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ namespace CefSharp
2323
return _wrappedInfo->GetXCoord();
2424
}
2525

26-
//// TODO: Implement:
27-
////virtual TypeFlags GetTypeFlags() OVERRIDE;
26+
ContextMenuType CefContextMenuParamsWrapper::TypeFlags::get()
27+
{
28+
ThrowIfDisposed();
29+
30+
return (ContextMenuType)_wrappedInfo->GetTypeFlags();
31+
}
2832

2933
String^ CefContextMenuParamsWrapper::LinkUrl::get()
3034
{
@@ -75,9 +79,19 @@ namespace CefSharp
7579
return StringUtils::ToClr(_wrappedInfo->GetFrameCharset());
7680
}
7781

78-
//// TODO: Implement:
79-
////virtual MediaType GetMediaType() OVERRIDE;
80-
////virtual MediaStateFlags GetMediaStateFlags() OVERRIDE;
82+
ContextMenuMediaType CefContextMenuParamsWrapper::MediaType::get()
83+
{
84+
ThrowIfDisposed();
85+
86+
return (ContextMenuMediaType)_wrappedInfo->GetMediaType();
87+
}
88+
89+
ContextMenuMediaState CefContextMenuParamsWrapper::MediaStateFlags::get()
90+
{
91+
ThrowIfDisposed();
92+
93+
return (ContextMenuMediaState)_wrappedInfo->GetMediaStateFlags();
94+
}
8195

8296
String^ CefContextMenuParamsWrapper::SelectionText::get()
8397
{
@@ -117,7 +131,25 @@ namespace CefSharp
117131
return _wrappedInfo->IsSpellCheckEnabled();
118132
}
119133

120-
//// TODO: Implement:
121-
////virtual EditStateFlags GetEditStateFlags() OVERRIDE;
134+
ContextMenuEditState CefContextMenuParamsWrapper::EditStateFlags::get()
135+
{
136+
ThrowIfDisposed();
137+
138+
return (ContextMenuEditState)_wrappedInfo->GetEditStateFlags();
139+
}
140+
141+
bool CefContextMenuParamsWrapper::IsCustomMenu::get()
142+
{
143+
ThrowIfDisposed();
144+
145+
return _wrappedInfo->IsCustomMenu();
146+
}
147+
148+
bool CefContextMenuParamsWrapper::IsPepperMenu::get()
149+
{
150+
ThrowIfDisposed();
151+
152+
return _wrappedInfo->IsPepperMenu();
153+
}
122154
}
123155
}

CefSharp.Core/Internals/CefContextMenuParamsWrapper.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,24 @@ namespace CefSharp
4040
public:
4141
virtual property int YCoord { int get(); }
4242
virtual property int XCoord { int get(); }
43-
44-
// TODO: Implement:
45-
//virtual TypeFlags GetTypeFlags() OVERRIDE;
43+
virtual property ContextMenuType TypeFlags { ContextMenuType get(); }
4644
virtual property String^ LinkUrl { String^ get(); }
4745
virtual property String^ UnfilteredLinkUrl { String^ get(); }
4846
virtual property String^ SourceUrl { String^ get(); }
4947
virtual property bool HasImageContents { bool get(); }
5048
virtual property String^ PageUrl { String^ get(); }
5149
virtual property String^ FrameUrl { String^ get(); }
5250
virtual property String^ FrameCharset { String^ get(); }
53-
54-
// TODO: Implement:
55-
//virtual MediaType GetMediaType() OVERRIDE;
56-
//virtual MediaStateFlags GetMediaStateFlags() OVERRIDE;
57-
51+
virtual property ContextMenuMediaType MediaType { ContextMenuMediaType get(); }
52+
virtual property ContextMenuMediaState MediaStateFlags { ContextMenuMediaState get(); }
5853
virtual property String^ SelectionText { String^ get(); }
5954
virtual property String^ MisspelledWord { String^ get(); }
60-
6155
virtual property List<String^>^ DictionarySuggestions { List<String^>^ get(); }
62-
6356
virtual property bool IsEditable { bool get(); }
6457
virtual property bool IsSpellCheckEnabled { bool get(); }
65-
66-
// TODO: Implement:
67-
//virtual EditStateFlags GetEditStateFlags() OVERRIDE;
58+
virtual property ContextMenuEditState EditStateFlags { ContextMenuEditState get(); }
59+
virtual property bool IsCustomMenu { bool get(); }
60+
virtual property bool IsPepperMenu { bool get(); }
6861
};
6962
}
7063
}

CefSharp/CefSharp.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
<Compile Include="CefJsDialogType.cs" />
7878
<Compile Include="CefMenuCommand.cs" />
7979
<Compile Include="CefPdfPrintMarginType.cs" />
80+
<Compile Include="ContextMenuEditState.cs" />
81+
<Compile Include="ContextMenuMediaState.cs" />
82+
<Compile Include="ContextMenuMediaType.cs" />
83+
<Compile Include="ContextMenuType.cs" />
8084
<Compile Include="DomNode.cs" />
8185
<Compile Include="DraggableRegion.cs" />
8286
<Compile Include="Geoposition.cs" />

CefSharp/ContextMenuEditState.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
using System;
6+
7+
namespace CefSharp
8+
{
9+
/// <summary>
10+
/// Supported context menu edit state bit flags.
11+
/// </summary>
12+
[Flags]
13+
public enum ContextMenuEditState
14+
{
15+
NONE = 0,
16+
CanUndo = 1 << 0,
17+
CanRedo = 1 << 1,
18+
CanCut = 1 << 2,
19+
CanCopy = 1 << 3,
20+
CanPaste = 1 << 4,
21+
CanDelete = 1 << 5,
22+
CanSelectAll = 1 << 6,
23+
CanTranslate = 1 << 7,
24+
}
25+
}

CefSharp/ContextMenuMediaState.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
using System;
6+
7+
namespace CefSharp
8+
{
9+
/// <summary>
10+
/// Supported context menu media state bit flags.
11+
/// </summary>
12+
[Flags]
13+
public enum ContextMenuMediaState
14+
{
15+
None = 0,
16+
Error = 1 << 0,
17+
Paused = 1 << 1,
18+
Muted = 1 << 2,
19+
Loop = 1 << 3,
20+
CanSave = 1 << 4,
21+
HasAudio = 1 << 5,
22+
HasVideo = 1 << 6,
23+
ControlRootElement = 1 << 7,
24+
CanPrint = 1 << 8,
25+
CanRotate = 1 << 9,
26+
}
27+
}

CefSharp/ContextMenuMediaType.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
using System;
6+
7+
namespace CefSharp
8+
{
9+
/// <summary>
10+
/// Supported context menu media types.
11+
/// </summary>
12+
public enum ContextMenuMediaType
13+
{
14+
/// <summary>
15+
/// No special node is in context.
16+
/// </summary>
17+
None,
18+
/// <summary>
19+
/// An image node is selected.
20+
/// </summary>
21+
Image,
22+
/// <summary>
23+
/// A video node is selected.
24+
/// </summary>
25+
Video,
26+
/// <summary>
27+
/// An audio node is selected.
28+
/// </summary>
29+
Audio,
30+
/// <summary>
31+
/// A file node is selected.
32+
/// </summary>
33+
File,
34+
/// <summary>
35+
/// A plugin node is selected.
36+
/// </summary>
37+
Plugin,
38+
}
39+
}

CefSharp/ContextMenuType.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
using System;
6+
7+
namespace CefSharp
8+
{
9+
[Flags]
10+
public enum ContextMenuType
11+
{
12+
/// <summary>
13+
/// No node is selected.
14+
/// </summary>
15+
None = 0,
16+
/// <summary>
17+
/// The top page is selected.
18+
/// </summary>
19+
Page = 1 << 0,
20+
/// <summary>
21+
/// A subframe page is selected.
22+
/// </summary>
23+
Frame = 1 << 1,
24+
/// <summary>
25+
/// A link is selected.
26+
/// </summary>
27+
Link = 1 << 2,
28+
/// <summary>
29+
/// A media node is selected.
30+
/// </summary>
31+
Media = 1 << 3,
32+
/// <summary>
33+
/// There is a textual or mixed selection that is selected.
34+
/// </summary>
35+
Selection = 1 << 4,
36+
/// <summary>
37+
/// An editable element is selected.
38+
/// </summary>
39+
Editable = 1 << 5,
40+
}
41+
}

CefSharp/IContextMenuParams.cs

Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,119 @@ namespace CefSharp
1212
/// </summary>
1313
public interface IContextMenuParams : IDisposable
1414
{
15+
/// <summary>
16+
/// Returns the Y coordinate of the mouse where the context menu was invoked.
17+
/// Coords are relative to the associated RenderView's origin.
18+
/// </summary>
1519
int YCoord { get; }
20+
21+
/// <summary>
22+
/// Returns the X coordinate of the mouse where the context menu was invoked.
23+
/// Coords are relative to the associated RenderView's origin.
24+
/// </summary>
1625
int XCoord { get; }
1726

18-
// TODO: Implement:
19-
//virtual TypeFlags GetTypeFlags() OVERRIDE;
27+
/// <summary>
28+
/// Returns flags representing the type of node that the context menu was invoked on.
29+
/// </summary>
30+
ContextMenuType TypeFlags { get; }
2031

32+
/// <summary>
33+
/// Returns the URL of the link, if any, that encloses the node that the
34+
/// context menu was invoked on.
35+
/// </summary>
2136
string LinkUrl { get; }
37+
38+
/// <summary>
39+
/// Returns the link URL, if any, to be used ONLY for "copy link address". We
40+
/// don't validate this field in the frontend process.
41+
/// </summary>
2242
string UnfilteredLinkUrl { get; }
43+
44+
/// <summary>
45+
/// Returns the source URL, if any, for the element that the context menu was
46+
/// invoked on. Example of elements with source URLs are img, audio, and video.
47+
/// </summary>
2348
string SourceUrl { get; }
49+
50+
/// <summary>
51+
/// Returns true if the context menu was invoked on an image which has
52+
/// non-empty contents.
53+
/// </summary>
2454
bool HasImageContents { get; }
55+
56+
/// <summary>
57+
/// Returns the URL of the top level page that the context menu was invoked on.
58+
/// </summary>
2559
string PageUrl { get; }
60+
61+
/// <summary>
62+
/// Returns the URL of the subframe that the context menu was invoked on.
63+
/// </summary>
2664
string FrameUrl { get; }
65+
66+
/// <summary>
67+
/// Returns the character encoding of the subframe that the context menu was
68+
/// invoked on.
69+
/// </summary>
2770
string FrameCharset { get; }
2871

72+
/// <summary>
73+
/// Returns the type of context node that the context menu was invoked on.
74+
/// </summary>
75+
ContextMenuMediaType MediaType { get; }
76+
77+
/// <summary>
78+
/// Returns flags representing the actions supported by the media element, if
79+
/// any, that the context menu was invoked on.
80+
/// </summary>
81+
ContextMenuMediaState MediaStateFlags { get; }
2982

30-
// TODO: Implement:
31-
//virtual MediaType GetMediaType() OVERRIDE;
32-
//virtual MediaStateFlags GetMediaStateFlags() OVERRIDE;
33-
34-
83+
/// <summary>
84+
/// Returns the text of the selection, if any, that the context menu was
85+
/// invoked on.
86+
/// </summary>
3587
string SelectionText { get; }
88+
89+
/// <summary>
90+
/// Returns the text of the misspelled word, if any, that the context menu was
91+
/// invoked on.
92+
/// </summary>
3693
string MisspelledWord { get; }
3794

95+
/// <summary>
96+
/// Returns a list of strings from the spell check service for the misspelled word if there is one.
97+
/// </summary>
3898
List<string> DictionarySuggestions { get; }
3999

100+
/// <summary>
101+
/// Returns true if the context menu was invoked on an editable node.
102+
/// </summary>
40103
bool IsEditable { get; }
104+
105+
/// <summary>
106+
/// Returns true if the context menu was invoked on an editable node where
107+
/// spell-check is enabled.
108+
/// </summary>
41109
bool IsSpellCheckEnabled { get; }
42-
43110

44-
// TODO: Implement:
45-
//virtual EditStateFlags GetEditStateFlags() OVERRIDE;
111+
/// <summary>
112+
/// Returns flags representing the actions supported by the editable node, if
113+
/// any, that the context menu was invoked on.
114+
/// </summary>
115+
/// <returns>Returns ContextMenuEditState as flags</returns>
116+
ContextMenuEditState EditStateFlags { get ;}
117+
118+
/// <summary>
119+
/// Returns true if the context menu contains items specified by the renderer
120+
/// process (for example, plugin placeholder or pepper plugin menu items).
121+
/// </summary>
122+
bool IsCustomMenu { get; }
123+
124+
/// <summary>
125+
/// Returns true if the context menu was invoked from a pepper plugin.
126+
/// </summary>
127+
bool IsPepperMenu { get; }
46128

47129
/// <summary>
48130
/// Gets a value indicating whether the object has been disposed of.

0 commit comments

Comments
 (0)