-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bidi][java] Update the capture screenshot APIs to include all parame…
…ters and remove scroll parameter (#13743) Co-authored-by: Diego Molina <[email protected]>
- Loading branch information
Showing
6 changed files
with
233 additions
and
29 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
java/src/org/openqa/selenium/bidi/browsingcontext/BoxClipRectangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
package org.openqa.selenium.bidi.browsingcontext; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class BoxClipRectangle extends ClipRectangle { | ||
private final Map<String, Object> map = new HashMap<>(); | ||
|
||
public BoxClipRectangle(double x, double y, double width, double height) { | ||
super(Type.BOX); | ||
map.put("x", x); | ||
map.put("y", y); | ||
map.put("width", width); | ||
map.put("height", height); | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
map.put("type", super.getType().toString()); | ||
|
||
return map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
java/src/org/openqa/selenium/bidi/browsingcontext/CaptureScreenshotParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.browsingcontext; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class CaptureScreenshotParameters { | ||
|
||
public enum Origin { | ||
VIEWPORT("viewport"), | ||
DOCUMENT("document"); | ||
|
||
private final String value; | ||
|
||
Origin(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} | ||
|
||
private final Map<String, Object> map = new HashMap<>(); | ||
|
||
public CaptureScreenshotParameters origin(Origin origin) { | ||
map.put("origin", origin.toString()); | ||
return this; | ||
} | ||
|
||
public CaptureScreenshotParameters imageFormat(String type) { | ||
map.put("format", Map.of("type", type)); | ||
return this; | ||
} | ||
|
||
public CaptureScreenshotParameters imageFormat(String type, double quality) { | ||
map.put("format", Map.of("type", type, "quality", quality)); | ||
return this; | ||
} | ||
|
||
public CaptureScreenshotParameters clipRectangle(ClipRectangle clipRectangle) { | ||
map.put("clip", clipRectangle.toMap()); | ||
return this; | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
return map; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
java/src/org/openqa/selenium/bidi/browsingcontext/ClipRectangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
package org.openqa.selenium.bidi.browsingcontext; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class ClipRectangle { | ||
enum Type { | ||
ELEMENT("element"), | ||
BOX("box"); | ||
|
||
private final String value; | ||
|
||
Type(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} | ||
|
||
private Type type; | ||
|
||
ClipRectangle(Type type) { | ||
this.type = type; | ||
} | ||
|
||
Type getType() { | ||
return type; | ||
} | ||
|
||
public abstract Map<String, Object> toMap(); | ||
} |
41 changes: 41 additions & 0 deletions
41
java/src/org/openqa/selenium/bidi/browsingcontext/ElementClipRectangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
package org.openqa.selenium.bidi.browsingcontext; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ElementClipRectangle extends ClipRectangle { | ||
private final Map<String, Object> map = new HashMap<>(); | ||
|
||
public ElementClipRectangle(String sharedId) { | ||
super(Type.ELEMENT); | ||
map.put("sharedId", sharedId); | ||
} | ||
|
||
public ElementClipRectangle(String sharedId, String handle) { | ||
super(Type.ELEMENT); | ||
map.put("sharedId", sharedId); | ||
map.put("handle", handle); | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
map.put("type", super.getType().toString()); | ||
|
||
return map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters