WebDocumentRepresentation Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/WebKit.framework
Availability
Available in OS X v10.2 with Safari 1.0 and later.
Available in OS X v10.2.7 and later.
Companion guide
Declared in
WebDocument.h

Overview

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 registerViewClass:representationClass:forMIMEType: method.

Tasks

Setting the Data Source

Loading Content

Getting Document Source

Getting the Document Title

Instance Methods

canProvideDocumentSource

Returns whether the receiver can provide content source.

- (BOOL)canProvideDocumentSource
Return Value

YES if the receiver can provide source for the document content (for example, HTML source), NO otherwise.

Discussion

The receiver should return YES only if it makes sense for someone to view the source of the document in question. For example, a web view returns NO if the content is an image, was produced by a plug-in, or contains text content already.

Availability
  • Available in OS X v10.2 with Safari 1.0 and later.
  • Available in OS X v10.2.7 and later.
Declared In
WebDocument.h

documentSource

Returns the receiver’s source as text.

- (NSString *)documentSource
Return Value

Returns the document source associated with the receiver or nil if the source cannot be provided.

Discussion

For example, for HTML documents, the receiver should return the HTML source.

Availability
  • Available in OS X v10.2 with Safari 1.0 and later.
  • Available in OS X v10.2.7 and later.
Declared In
WebDocument.h

finishedLoadingWithDataSource:

Invoked when a data source finishes loading its content.

- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
Parameters
dataSource

A WebDataSource object that identifies the request that finished loading.

Availability
  • Available in OS X v10.2 with Safari 1.0 and later.
  • Available in OS X v10.2.7 and later.
Declared In
WebDocument.h

receivedData:withDataSource:

Invoked when a data source has received some data.

- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource
Parameters
data

An NSData object containing the data received.

dataSource

A WebDataSource object that identifies the request that generated this data.

Discussion

Data is loaded incrementally, so this method may be invoked multiple times. The receiver is responsible for accumulating this data.

Availability
  • Available in OS X v10.2 with Safari 1.0 and later.
  • Available in OS X v10.2.7 and later.
Declared In
WebDocument.h

receivedError:withDataSource:

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

- (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource
Parameters
error

An NSError object that indicates what error occurred.

dataSource

A WebDataSource object that identifies the request that caused this error.

Discussion

The error argument contains details on the error that occurred.

Availability
  • Available in OS X v10.2 with Safari 1.0 and later.
  • Available in OS X v10.2.7 and later.
Declared In
WebDocument.h

setDataSource:

Sets the receiver’s data source.

- (void)setDataSource:(WebDataSource *)dataSource
Parameters
dataSource

The data source to associate with the object.

Discussion

This method is invoked soon after the document representation is created.

Availability
  • Available in OS X v10.2 with Safari 1.0 and later.
  • Available in OS X v10.2.7 and later.
Declared In
WebDocument.h

title

Returns the receiver’s document title.

- (NSString *)title
Return Value

The title associated with the receiving document object.

Availability
  • Available in OS X v10.2 with Safari 1.0 and later.
  • Available in OS X v10.2.7 and later.
Declared In
WebDocument.h