<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebDocumentView",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WebDocumentView"
  },
  "title" : "WebDocumentView"
}
-->

# WebDocumentView

This protocol is adopted by the document view of a `WebFrameView`. You can extend WebKit to support additional MIME types by implementing your own document view and document representation classes to render data for specific MIME types. You register those classes using the WebFrame [`registerClass(_:representationClass:forMIMEType:)`](/documentation/WebKit/WebView-swift.class/registerClass(_:representationClass:forMIMEType:)) method. Classes that adopt this protocol are expected to be subclasses of `NSView`.

```
protocol WebDocumentView : NSObjectProtocol
```

## Topics

### Setting the data source

[`setDataSource(_:)`](/documentation/WebKit/WebDocumentView/setDataSource(_:))

Invoked when the data source for this document has been changed.

[`dataSourceUpdated(_:)`](/documentation/WebKit/WebDocumentView/dataSourceUpdated(_:))

Invoked when additional data has been received.

### Controlling the layout

[`setNeedsLayout(_:)`](/documentation/WebKit/WebDocumentView/setNeedsLayout(_:))

Sets whether or not the receiver should change its layout.

[`layout()`](/documentation/WebKit/WebDocumentView/layout())

Invoked when the receiver should change its layout immediately.

### Attaching to a window

[`viewDidMoveToHostWindow()`](/documentation/WebKit/WebDocumentView/viewDidMoveToHostWindow())

Invoked when a web view’s host window is set.

[`viewWillMove(toHostWindow:)`](/documentation/WebKit/WebDocumentView/viewWillMove(toHostWindow:))

Invoked when a web view’s host window is about to change.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)