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

# WebDocumentRepresentation

This protocol is adopted by document representation classes that handle specific MIME types. You can implement your own document view classes and document representation classes to render data for specific MIME types, and register those classes using the `WebFrame` [`registerClass(_:representationClass:forMIMEType:)`](/documentation/WebKit/WebView-swift.class/registerClass(_:representationClass:forMIMEType:)) method.

```
protocol WebDocumentRepresentation : NSObjectProtocol
```

## Topics

### Setting the data source

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

Sets the receiver’s data source.

### Loading content

[`receivedData(_:with:)`](/documentation/WebKit/WebDocumentRepresentation/receivedData(_:with:))

Invoked when a data source has received some data.

[`receivedError(_:with:)`](/documentation/WebKit/WebDocumentRepresentation/receivedError(_:with:))

Invoked when a data source receives an error loading its content.

[`finishedLoading(with:)`](/documentation/WebKit/WebDocumentRepresentation/finishedLoading(with:))

Invoked when a data source finishes loading its content.

### Getting document source

[`canProvideDocumentSource()`](/documentation/WebKit/WebDocumentRepresentation/canProvideDocumentSource())

Returns whether the receiver can provide content source.

[`documentSource()`](/documentation/WebKit/WebDocumentRepresentation/documentSource())

Returns the receiver’s source as text.

### Getting the document title

[`title()`](/documentation/WebKit/WebDocumentRepresentation/title())

Returns the receiver’s document title.



---

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)