瀏覽代碼

LibWeb: Make Document::open functions take a StringView

One of these functions doesn't make any use of the arguments at all, and
the other defers to an open helper which already takes a StringView.
Shannon Booth 1 年之前
父節點
當前提交
e42bda5f19
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      Userland/Libraries/LibWeb/DOM/Document.cpp
  2. 2 2
      Userland/Libraries/LibWeb/DOM/Document.h

+ 2 - 2
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -464,7 +464,7 @@ WebIDL::ExceptionOr<void> Document::run_the_document_write_steps(DeprecatedStrin
 }
 
 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open
-WebIDL::ExceptionOr<Document*> Document::open(DeprecatedString const&, DeprecatedString const&)
+WebIDL::ExceptionOr<Document*> Document::open(StringView, StringView)
 {
     // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception.
     if (m_type == Type::XML)
@@ -535,7 +535,7 @@ WebIDL::ExceptionOr<Document*> Document::open(DeprecatedString const&, Deprecate
 }
 
 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open-window
-WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> Document::open(DeprecatedString const& url, DeprecatedString const& name, DeprecatedString const& features)
+WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> Document::open(StringView url, StringView name, StringView features)
 {
     // 1. If this is not fully active, then throw an "InvalidAccessError" DOMException exception.
     if (!is_fully_active())

+ 2 - 2
Userland/Libraries/LibWeb/DOM/Document.h

@@ -319,8 +319,8 @@ public:
     WebIDL::ExceptionOr<void> write(Vector<DeprecatedString> const& strings);
     WebIDL::ExceptionOr<void> writeln(Vector<DeprecatedString> const& strings);
 
-    WebIDL::ExceptionOr<Document*> open(DeprecatedString const& = "", DeprecatedString const& = "");
-    WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> open(DeprecatedString const& url, DeprecatedString const& name, DeprecatedString const& features);
+    WebIDL::ExceptionOr<Document*> open(StringView = ""sv, StringView = ""sv);
+    WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> open(StringView url, StringView name, StringView features);
     WebIDL::ExceptionOr<void> close();
 
     HTML::Window* default_view() { return m_window.ptr(); }