Safari DOM Extensions Reference

79
Safari DOM Extensions Reference User Experience 2009-01-30

description

Use of the “keyboard” Apple logo (Option-Shift-K) for commercial purposes without the prior written consent of Apple may constitute trademark infringement and unfair competition in violation of federal and state laws. Java and all Java-based trademarks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.

Transcript of Safari DOM Extensions Reference

Page 1: Safari DOM Extensions Reference

Safari DOM Extensions ReferenceUser Experience

2009-01-30

Page 2: Safari DOM Extensions Reference

Apple Inc.© 2004, 2009 Apple Inc.All rights reserved.

No part of this publication may be reproduced,stored in a retrieval system, or transmitted, inany form or by any means, mechanical,electronic, photocopying, recording, orotherwise, without prior written permission ofApple Inc., with the following exceptions: Anyperson is hereby authorized to storedocumentation on a single computer forpersonal use only and to print copies ofdocumentation for personal use provided thatthe documentation contains Apple’s copyrightnotice.

The Apple logo is a trademark of Apple Inc.

Use of the “keyboard” Apple logo(Option-Shift-K) for commercial purposeswithout the prior written consent of Apple mayconstitute trademark infringement and unfaircompetition in violation of federal and statelaws.

No licenses, express or implied, are grantedwith respect to any of the technology describedin this document. Apple retains all intellectualproperty rights associated with the technologydescribed in this document. This document isintended to assist application developers todevelop applications only for Apple-labeledcomputers.

Every effort has been made to ensure that theinformation in this document is accurate. Appleis not responsible for typographical errors.

Apple Inc.1 Infinite LoopCupertino, CA 95014408-996-1010

Apple, the Apple logo, QuickTime, and Safariare trademarks of Apple Inc., registered in theUnited States and other countries.

iPhone is a trademark of Apple Inc.

Java and all Java-based trademarks aretrademarks or registered trademarks of SunMicrosystems, Inc. in the U.S. and othercountries.

SPEC is a registered trademark of the StandardPerformance Evaluation Corporation (SPEC).

Simultaneously published in the United Statesand Canada.

Even though Apple has reviewed this document,APPLE MAKES NO WARRANTY OR REPRESENTATION,

EITHER EXPRESS OR IMPLIED, WITH RESPECT TOTHIS DOCUMENT, ITS QUALITY, ACCURACY,MERCHANTABILITY, OR FITNESS FOR A PARTICULARPURPOSE. AS A RESULT, THIS DOCUMENT ISPROVIDED “AS IS,” AND YOU, THE READER, AREASSUMING THE ENTIRE RISK AS TO ITS QUALITYAND ACCURACY.

IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,INDIRECT, SPECIAL, INCIDENTAL, ORCONSEQUENTIAL DAMAGES RESULTING FROM ANYDEFECT OR INACCURACY IN THIS DOCUMENT, evenif advised of the possibility of such damages.

THE WARRANTY AND REMEDIES SET FORTH ABOVEARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORALOR WRITTEN, EXPRESS OR IMPLIED. No Appledealer, agent, or employee is authorized to makeany modification, extension, or addition to thiswarranty.

Some states do not allow the exclusion or limitationof implied warranties or liability for incidental orconsequential damages, so the above limitation orexclusion may not apply to you. This warranty givesyou specific legal rights, and you may also haveother rights which vary from state to state.

Page 3: Safari DOM Extensions Reference

Contents

Introduction Safari DOM Extensions Reference 9

Introduction 9See Also 9

Part I Classes 11

Chapter 1 CSSRule Additions 13

Overview 13Constants 13

Chapter 2 Document Additions 15

Overview 15Tasks 15Methods 15

Chapter 3 DOMApplicationCache 17

Overview 17Tasks 17Properties 18Methods 20Constants 20

Chapter 4 DOMWindow Additions 23

Overview 23Tasks 23Properties 23Methods 24

Chapter 5 GestureEvent 27

Overview 27Tasks 28Properties 28Methods 30

32009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

Page 4: Safari DOM Extensions Reference

Chapter 6 Touch 33

Overview 33Tasks 33Properties 34

Chapter 7 TouchEvent 37

Overview 37Tasks 37Properties 38Methods 38

Chapter 8 TouchList 41

Overview 41Tasks 41Properties 41Methods 42

Chapter 9 WebKitAnimationEvent 43

Overview 43Tasks 44Properties 44Methods 45

Chapter 10 WebKitCSSKeyframeRule 47

Overview 47Tasks 47Properties 47

Chapter 11 WebKitCSSKeyframesRule 49

Overview 49Tasks 49Properties 50Methods 50

Chapter 12 WebKitCSSMatrix 53

Overview 53Tasks 53Properties 55Methods 60

42009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CONTENTS

Page 5: Safari DOM Extensions Reference

Chapter 13 WebKitCSSTransformValue 65

Overview 65Tasks 65Properties 65Constants 66

Chapter 14 WebKitPoint 69

Overview 69Tasks 69Properties 69

Chapter 15 WebKitTransitionEvent 71

Overview 71Tasks 71Properties 72Methods 72

Document Revision History 75

Index 77

52009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CONTENTS

Page 6: Safari DOM Extensions Reference

62009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CONTENTS

Page 7: Safari DOM Extensions Reference

Tables

Chapter 4 DOMWindow Additions 23

Table 4-1 Window orientation values 24

72009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

Page 8: Safari DOM Extensions Reference

82009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

TABLES

Page 9: Safari DOM Extensions Reference

Important: This is a preliminary document for an API or technology in development. Although this documenthas been reviewed for technical accuracy, it is not final. Apple is supplying this information to help you planfor the adoption of the technologies and programming interfaces described herein. This information is subjectto change, and software implemented according to this document should be tested with final software andfinal documentation. Newer versions of this document may be provided with future releases of the API ortechnology. For information about updates to this and other developer documentation, view the New &Updated sidebars in subsequent seeds of the Reference Library.

Introduction

This covers miscellaneous WebKit DOM extensions used by Safari on iPhone OS. These extensions includeDOM touch events for processing gestures for devices that have a touch screen and visual effects that support2D and 3D transforms, animation, and transitions. Most of the classes described in this reference are Appleextensions that may also be proposed W3C standards.

See Also

There are a variety of other resources for Safari web content developers using JavaScript.

If you are using DOM touch events, you should also read:

■ Safari Web Content Guide for iPhone OS, which describes how to create web content and applications forSafari on iPhone.

If you are using visual effects, you should read:

■ Safari Visual Effects Guide, which describes how to use the CSS transition, animation, and transformproperties.

If you want to use the JavaScript database classes, you should read:

■ Safari Client-Side Storage andOffline Applications ProgrammingGuide, which describes a simple relationaldatabase that you can use to store persistent data in JavaScript that cannot be stored in cookies.

If you want to use the JavaScript media APIs, then you should read:

■ JavaScript Scripting Guide for QuickTime, which describes how to use JavaScript to query and control theQuickTime plug-in directly.

Introduction 92009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

INTRODUCTION

Safari DOM Extensions Reference

Page 10: Safari DOM Extensions Reference

If you want access to the DOM or use the canvas object, then read:

■ WebKitDOMProgrammingTopics, which describes how to use JavaScript in web content for WebKit-basedapplications.

■ WebKit DOM Reference, which describes the API for accessing the WebKit Document Object Model.

If you want to read the WebKit W3C proposals then go to: http://www.webkit.org/specs.

10 See Also2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

INTRODUCTION

Safari DOM Extensions Reference

Page 11: Safari DOM Extensions Reference

112009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

PART I

Classes

Page 12: Safari DOM Extensions Reference

122009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

PART I

Classes

Page 13: Safari DOM Extensions Reference

Availability Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

These extensions to the CSSRule class are used to access animation keyframe and keyframes rules.

Constants

DescriptionConstant

Keyframes rule type. Read WebKitCSSKeyframesRule (page 49) for details.const unsigned short WEBKIT_KEYFRAMES_RULE = 7;

Safari Note: In Safari 4.0 and later, the value is 8.

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

WEBKIT_KEYFRAMES_-RULE

Keyframe rule type. Read WebKitCSSKeyframeRule (page 47) for details.const unsigned short WEBKIT_KEYFRAME_RULE = 8;

Safari Note: In Safari 4.0 and later, the value is 9.

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

WEBKIT_KEYFRAME_RULE

Overview 132009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 1

CSSRule Additions

Page 14: Safari DOM Extensions Reference

14 Constants2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 1

CSSRule Additions

Page 15: Safari DOM Extensions Reference

Availability Available in iPhone OS 2.0 and later.

Companion guide Safari Web Content Guide for iPhone OS

Overview

These additions to the Document class are used to create touch event objects.

Tasks

Creating Touches

createTouch (page 15)Creates a new Touch object.

createTouchList (page 16)Creates a new TouchList object.

Methods

createTouchCreates a new Touch object.

Touch createTouch(in DOMWindow view, in EventTarget target, in long identifier, in long pageX, in long pageY, in long screenX, in long screenY) raises (

DOMException);

Parametersview

The view (DOM window) in which the event occurred.

Overview 152009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 2

Document Additions

Page 16: Safari DOM Extensions Reference

targetThe target of this gesture.

identifierThe unique identifier for this touch object.

pageXThe x-coordinate of the touch’s location, in page coordinates.

pageYThe y-coordinate of the touch’s location, in page coordinates.

screenXThe x-coordinate of the event’s location, in screen coordinates.

screenYThe y-coordinate of the event’s location, in screen coordinates.

AvailabilityAvailable in iPhone OS 2.0 and later.

createTouchListCreates a new TouchList object.

TouchList createTouchList() raises ( DOMException);

AvailabilityAvailable in iPhone OS 2.0 and later.

16 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 2

Document Additions

Page 17: Safari DOM Extensions Reference

Availability Available in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

Companion guide Safari Web Content Guide for iPhone OS

Overview

A DOMApplicationCache object is used to store resources—such as, HTML, JavaScript, CSS, andimages—locally. This allows your web application to continue running offline when there is no networkconnection. The cache persists after Safari exits, so it can be used by multiple browser sessions. There is oneapplication cache per browsing context.

Tasks

Accessing Properties

status (page 19)The current status of the application cache. One of the values described in "Constants.”

Handling Events

onchecking (page 18)Sent when the cache update process begins.

onerror (page 19)Sent when an error occurs.

onnoupdate (page 19)Sent when the update process finishes but the manifest file does not change.

ondownloading (page 18)Sent when the update process begins downloading resources in the manifest file.

onprogress (page 19)Sent when each resource in the manifest file begins to download.

onupdateready (page 19)Sent when there is an existing application cache, the update process finishes, and there is a newapplication cache ready for use.

Overview 172009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache

Page 18: Safari DOM Extensions Reference

oncached (page 18)Sent when the update process finishes for the first time—that is, the first time an application cacheis saved.

Updating the Cache

update (page 20)Manually triggers the update process.

swapCache (page 20)Replaces the active cache with the latest version.

Properties

oncachedSent when the update process finishes for the first time—that is, the first time an application cache is saved.

attribute EventListener oncached;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

oncheckingSent when the cache update process begins.

attribute EventListener onchecking;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

ondownloadingSent when the update process begins downloading resources in the manifest file.

attribute EventListener ondownloading;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

18 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache

Page 19: Safari DOM Extensions Reference

onerrorSent when an error occurs.

attribute EventListener onerror;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

onnoupdateSent when the update process finishes but the manifest file does not change.

attribute EventListener onnoupdate;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

onprogressSent when each resource in the manifest file begins to download.

attribute EventListener onprogress;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

onupdatereadySent when there is an existing application cache, the update process finishes, and there is a new applicationcache ready for use.

attribute EventListener onupdateready;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

statusThe current status of the application cache. One of the values described in "Constants.”

readonly attribute unsigned short status;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

Properties 192009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache

Page 20: Safari DOM Extensions Reference

Methods

swapCacheReplaces the active cache with the latest version.

void swapCache() raises(DOMException);

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

updateManually triggers the update process.

void update() raises(DOMException);

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

Constants

Constants that indicate the status of the application cache.

DescriptionConstant

The object isn’t associated with an application cache. This can occur if the update process fails and there isno previous cache to revert to, or if there is no manifest file.

const unsigned short UNCACHED = 0;

Available in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

UNCACHED

The cache is idle.const unsigned short IDLE = 1;

Available in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

IDLE

The update has started but the resources are not downloaded yet—for example, this can happen when themanifest file is fetched.

const unsigned short CHECKING = 2;

Available in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

CHECKING

20 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache

Page 21: Safari DOM Extensions Reference

DescriptionConstant

The resources are being downloaded into the cache.const unsigned short DOWNLOADING = 3;

Available in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

DOWNLOADING

Resources have finished downloading and the new cache is ready to be used.const unsigned short UPDATEREADY = 4;

Available in Safari 4.0 and later.Available in iPhone OS 2.2 and later.

UPDATEREADY

Constants 212009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache

Page 22: Safari DOM Extensions Reference

22 Constants2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache

Page 23: Safari DOM Extensions Reference

Availability Available in iPhone OS 1.1.1 and later.

Companion guides Safari Web Content Guide for iPhone OSSafari Visual Effects Guide

Overview

DOMWindow additions allow conversion of points from page- and node-coordinate systems for transitions.

Tasks

Accessing Properties

applicationCache (page 23)The application cache associated with the current document.

orientation (page 24)Specifies the orientation of the device.

Converting Points

webkitConvertPointFromPageToNode (page 25)Converts a point from page coordinates to a given node’s coordinates.

webkitConvertPointFromNodeToPage (page 24)Converts a point from a given node’s coordinates to page coordinates.

Properties

applicationCacheThe application cache associated with the current document.

Overview 232009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions

Page 24: Safari DOM Extensions Reference

readonly attribute DOMApplicationCache applicationCache;

AvailabilityAvailable in iPhone OS 2.2 and later.

orientationSpecifies the orientation of the device.

readonly attribute long orientation;

DiscussionThis property is set to one of the values in Table 4-1 (page 24). For example, if the user starts with the devicein portrait orientation and then changes to landscape orientation by turning the device to the right, thewindow’s orientation property is set to -90. If the user instead changes to landscape by turning the deviceto the left, the window’s orientation property is set to 90. The default value is 0.

Table 4-1 Window orientation values

DescriptionValue

Portrait orientation. This is the default value.0

Landscape orientation with the screen turned clockwise.-90

Landscape orientation with the screen turned counterclockwise.90

Portrait orientation with the screen turned upside down. This value is currently not supported oniPhone.

180

AvailabilityAvailable in iPhone 1.1.1 and later.

Methods

webkitConvertPointFromNodeToPageConverts a point from a given node’s coordinates to page coordinates.

WebKitPoint webkitConvertPointFromNodeToPage(in Node node, in WebKitPoint p);

Parametersnode

The coordinate space for p.

pA point in node’s coordinates to convert to page coordinates.

Return ValueA point that is at the same location as p but in the page coordinates.

24 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions

Page 25: Safari DOM Extensions Reference

AvailabilityAvailable in iPhone OS 2.0 and later.

webkitConvertPointFromPageToNodeConverts a point from page coordinates to a given node’s coordinates.

WebKitPoint webkitConvertPointFromPageToNode(in Node node, in WebKitPoint p);

Parametersnode

The coordinate space to convert the given point to.

pA point in page coordinates to convert to node’s coordinates.

Return ValueA point that is at the same location as p but in the node’s coordinates.

AvailabilityAvailable in iPhone OS 2.0 and later.

Methods 252009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions

Page 26: Safari DOM Extensions Reference

26 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions

Page 27: Safari DOM Extensions Reference

Inherits from UIEvent

Availability Available in iPhone OS 2.0 and later.

Companion guide Safari Web Content Guide for iPhone OS

Overview

The GestureEvent class encapsulates information about a multi-touch gesture.

GestureEvent objects are high-level events that encapsulate the low-level TouchEvent objects. BothGestureEvent and TouchEvent events are sent during a multi-touch sequence. Gesture events containscaling and rotation information allowing gestures to be combined, if supported by the platform. If notsupported, one gesture ends before another starts. Listen for GestureEvent events if you want to respondto gestures only, not process the low-level TouchEvent objects.

The different types of GestureEvent objects that can occur are:

gesturestartSent when two or more fingers touch the surface.

gesturechangeSent when fingers are moved during a gesture.

gestureendSent when the gesture ends (when there are 1 or 0 fingers touching the surface).

For example, for a two finger multi-touch gesture, the events occur in the following sequence:

1. touchstart for finger 1. Sent when the first finger touches the surface.

2. gesturestart. Sent when the second finger touches the surface.

3. touchstart for finger 2. Sent immediately after gesturestart when the second finger touches thesurface.

4. gesturechange for current gesture. Sent when both fingers move while still touching the surface.

5. gestureend. Sent when the second finger lifts from the surface.

6. touchend for finger 2. Sent immediately after gestureendwhen the second finger lifts from the surface.

7. touchend for finger 1. Sent when the first finger lifts from the surface.

See TouchEvent (page 37) if you want to process just low-level TouchEvent objects.

Overview 272009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent

Page 28: Safari DOM Extensions Reference

Tasks

Accessing Properties

altKey (page 28)If true, the alt key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

ctrlKey (page 28)If true, the control key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

metaKey (page 29)If true, the meta key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

rotation (page 29)The delta rotation since the start of an event, in degrees, where clockwise is positive andcounter-clockwise is negative. The initial value is 0.0.

scale (page 29)The distance between two fingers since the start of an event, as a multiplier of the initial distance.The initial value is 1.0. If less than 1.0, the gesture is pinch close (to zoom out). If greater than 1.0,the gesture is pinch open (to zoom in).

shiftKey (page 29)If true, the Shift key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

target (page 29)The target of this gesture.

Initializing

initGestureEvent (page 30)Initializes a newly created GestureEvent object.

Properties

altKeyIf true, the alt key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

readonly attribute boolean altKey;

AvailabilityAvailable in iPhone OS 2.0 and later.

ctrlKeyIf true, the control key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

28 Tasks2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent

Page 29: Safari DOM Extensions Reference

readonly attribute boolean ctrlKey;

AvailabilityAvailable in iPhone OS 2.0 and later.

metaKeyIf true, the meta key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

readonly attribute boolean metaKey;

AvailabilityAvailable in iPhone OS 2.0 and later.

rotationThe delta rotation since the start of an event, in degrees, where clockwise is positive and counter-clockwiseis negative. The initial value is 0.0.

readonly attribute float rotation;

AvailabilityAvailable in iPhone OS 2.0 and later.

scaleThe distance between two fingers since the start of an event, as a multiplier of the initial distance. The initialvalue is 1.0. If less than 1.0, the gesture is pinch close (to zoom out). If greater than 1.0, the gesture is pinchopen (to zoom in).

readonly attribute float scale;

AvailabilityAvailable in iPhone OS 2.0 and later.

shiftKeyIf true, the Shift key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

readonly attribute boolean shiftKey;

AvailabilityAvailable in iPhone OS 2.0 and later.

targetThe target of this gesture.

Properties 292009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent

Page 30: Safari DOM Extensions Reference

readonly attribute EventTarget target;

AvailabilityAvailable in iPhone OS 2.0 and later.

Methods

initGestureEventInitializes a newly created GestureEvent object.

void initGestureEvent(in DOMString type, in boolean canBubble, in boolean cancelable, in DOMWindow view, in long detail, in long screenX, in long screenY, in long clientX, in long clientY, in boolean ctrlKey, in boolean altKey, in boolean shiftKey, in boolean metaKey, in EventTarget target, in float scale, in float rotation);

Parameterstype

The type of event that occurred.

canBubbleIndicates whether an event can bubble. If true, the event can bubble; otherwise, it cannot.

cancelableIndicates whether an event can have its default action prevented. If true, the default action can beprevented; otherwise, it cannot.

viewThe view (DOM window) where the event occurred.

detailSpecifies some detail information about the event depending on the type of event.

screenXThe x-coordinate of the event’s location in screen coordinates.

screenYThe y-coordinate of the event’s location in screen coordinates.

clientXThe x-coordinate of the event’s location relative to the window's viewport.

30 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent

Page 31: Safari DOM Extensions Reference

clientYThe y-coordinate of the event’s location relative to the window's viewport.

ctrlKeyIf true, the control key is pressed; otherwise, it is not.

altKeyIf true, the alt key is pressed; otherwise, it is not.

shiftKeyIf true, the Shift key is pressed; otherwise, it is not.

metaKeyIf true, the meta key is pressed; otherwise, it is not.

targetThe target of this gesture.

scaleThe distance between two fingers since the start of an event as a multiplier of the initial distance. Theinitial value is 1.0. If less than 1.0, the gesture is pinch close (to zoom out). If greater than 1.0, thegesture is pinch open (to zoom in).

rotationThe delta rotation since the start of an event, in degrees, where clockwise is positive andcounter-clockwise is negative. The initial value is 0.0.

DiscussionUse this method to programmatically create a GestureEvent object.

AvailabilityAvailable in iPhone OS 2.0 and later.

Methods 312009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent

Page 32: Safari DOM Extensions Reference

32 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent

Page 33: Safari DOM Extensions Reference

Availability Available in iPhone OS 2.0 and later.

Companion guide Safari Web Content Guide for iPhone OS

Overview

The Touch class represents a single touch on the surface. A touch is the presence or movement of a fingerthat is part of a unique multi-touch sequence.

Tasks

Accessing Properties

clientX (page 34)The x-coordinate of the touch’s location relative to the window’s viewport.

clientY (page 34)The y-coordinate of the touch’s location relative to the window’s viewport.

identifier (page 34)The unique identifier for this touch object.

pageX (page 34)The x-coordinate of the touch’s location in page coordinates.

pageY (page 34)The y-coordinate of the touch’s location in page coordinates.

screenX (page 35)The x-coordinate of the touch’s location in screen coordinates.

screenY (page 35)The y-coordinate of the touch’s location in screen coordinates.

target (page 35)The target of this touch.

Overview 332009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 6

Touch

Page 34: Safari DOM Extensions Reference

Properties

clientXThe x-coordinate of the touch’s location relative to the window’s viewport.

readonly attribute long clientX;

AvailabilityAvailable in iPhone OS 2.0 and later.

clientYThe y-coordinate of the touch’s location relative to the window’s viewport.

readonly attribute long clientY;

AvailabilityAvailable in iPhone OS 2.0 and later.

identifierThe unique identifier for this touch object.

readonly attribute unsigned long identifier;

AvailabilityAvailable in iPhone OS 2.0 and later.

pageXThe x-coordinate of the touch’s location in page coordinates.

readonly attribute long pageX;

AvailabilityAvailable in iPhone OS 2.0 and later.

pageYThe y-coordinate of the touch’s location in page coordinates.

readonly attribute long pageY;

AvailabilityAvailable in iPhone OS 2.0 and later.

34 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 6

Touch

Page 35: Safari DOM Extensions Reference

screenXThe x-coordinate of the touch’s location in screen coordinates.

readonly attribute long screenX;

AvailabilityAvailable in iPhone OS 2.0 and later.

screenYThe y-coordinate of the touch’s location in screen coordinates.

readonly attribute long screenY;

AvailabilityAvailable in iPhone OS 2.0 and later.

targetThe target of this touch.

readonly attribute EventTarget target;

AvailabilityAvailable in iPhone OS 2.0 and later.

Properties 352009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 6

Touch

Page 36: Safari DOM Extensions Reference

36 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 6

Touch

Page 37: Safari DOM Extensions Reference

Inherits from UIEvent

Availability Available in iPhone OS 2.0 and later.

Companion guide Safari Web Content Guide for iPhone OS

Overview

The TouchEvent class encapsulates information about a touch event.

The system continually sends TouchEvent objects to an application as fingers touch and move across asurface. A touch event provides a snapshot of all touches during a multi-touch sequence, most importantlythe touches that are new or have changed for a particular target. A multi-touch sequence begins when afinger first touches the surface. Other fingers may subsequently touch the surface, and all fingers may moveacross the surface. The sequence ends when the last of these fingers is lifted from the surface. An applicationreceives touch event objects during each phase of any touch.

The different types of TouchEvent objects that can occur are:

touchstartSent when a finger for a given event touches the surface.

touchmoveSent when a given event moves on the surface.

touchendSent when a given event lifts from the surface.

touchcancelSent when the system cancels tracking for the touch.

TouchEvent objects are combined together to form high-level GestureEvent objects that are also sentduring a multi-touch sequence. See GestureEvent (page 27) for details on GestureEvent objects and anexample of the events sent for a two finger multi-touch gesture.

Tasks

Accessing Properties

altKey (page 38)If true, the alt key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

Overview 372009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 7

TouchEvent

Page 38: Safari DOM Extensions Reference

changedTouches (page 38)A collection of Touch objects representing all touches that changed in this event.

Initializing

initTouchEvent (page 38)Initializes a newly created TouchEvent object.

Properties

altKeyIf true, the alt key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

readonly attribute boolean altKey;

AvailabilityAvailable in iPhone OS 2.0 and later.

changedTouchesA collection of Touch objects representing all touches that changed in this event.

readonly attribute TouchList changedTouches;

AvailabilityAvailable in iPhone OS 2.0 and later.

Methods

initTouchEventInitializes a newly created TouchEvent object.

38 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 7

TouchEvent

Page 39: Safari DOM Extensions Reference

void initTouchEvent(in DOMString type, in boolean canBubble, in boolean cancelable, in DOMWindow view, in long detail, in long screenX, in long screenY, in long clientX, in long clientY, in boolean ctrlKey, in boolean altKey, in boolean shiftKey, in boolean metaKey, in TouchList touches, in TouchList targetTouches, in TouchList changedTouches, in float scale, in float rotation);

Parameterstype

The type of event that occurred.

canBubbleIndicates whether an event can bubble. If true, the event can bubble; otherwise, it cannot.

cancelableIndicates whether an event can have its default action prevented. If true, the default action can beprevented; otherwise, it cannot.

viewThe view (DOM window) in which the event occurred.

detailSpecifies some detail information about the event depending on the type of event.

screenXThe x-coordinate of the event’s location in screen coordinates.

screenYThe y-coordinate of the event’s location in screen coordinates.

clientXThe x-coordinate of the event’s location relative to the window’s viewport.

clientYThe y-coordinate of the event’s location relative to the window’s viewport.

ctrlKeyIf true, the control key is pressed; otherwise, it is not.

altKeyIf true, the alt key is pressed; otherwise, it is not.

shiftKeyIf true, the shift key is pressed; otherwise, it is not.

metaKeyIf true, the meta key is pressed; otherwise, it is not.

Methods 392009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 7

TouchEvent

Page 40: Safari DOM Extensions Reference

touchesA collection of Touch objects representing all touches associated with this event.

targetTouchesA collection of Touch objects representing all touches associated with this target.

changedTouchesA collection of Touch objects representing all touches that changed in this event.

scaleThe distance between two fingers since the start of an event as a multiplier of the initial distance. Theinitial value is 1.0. If less than 1.0, the gesture is pinch close (to zoom out). If greater than 1.0, thegesture is pinch open (to zoom in).

rotationThe delta rotation since the start of an event, in degrees, where clockwise is positive andcounter-clockwise is negative. The initial value is 0.0.

DiscussionUse this method to programmatically create a TouchEvent object.

AvailabilityAvailable in iPhone OS 2.0 and later.

40 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 7

TouchEvent

Page 41: Safari DOM Extensions Reference

Availability Available in iPhone OS 2.0 and later.

Companion guide Safari Web Content Guide for iPhone OS

Overview

The TouchList class is used to represent a collection of Touch objects.

Tasks

Accessing Properties

length (page 41)The number of Touch objects in this TouchList object.

Getting Touch Objects

item (page 42)Returns the Touch object at the given index.

Properties

lengthThe number of Touch objects in this TouchList object.

readonly attribute unsigned long length;

AvailabilityAvailable in iPhone OS 2.0 and later.

Overview 412009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 8

TouchList

Page 42: Safari DOM Extensions Reference

Methods

itemReturns the Touch object at the given index.

Touch item(in unsigned long index);

Parametersindex

The index of the item to return.

AvailabilityAvailable in iPhone OS 2.0 and later.

42 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 8

TouchList

Page 43: Safari DOM Extensions Reference

Inherits from Event

Availability Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

WebKitAnimationEvent objects encapsulate information about running animations.

Several animation related events are available through the DOM Event system. The start and end of ananimation, and the end of each iteration of an animation all generate DOM events. An element can havemultiple properties that are animated simultaneously. This simultaneous animation can occur either by settinga single -webkit-animation-name value with keyframes containing multiple properties, or by settingmultiple -webkit-animation-name values. For the purposes of event dispatching, each CSS-webkit-animation-name property specifies a single animation. Therefore, an event is sent for each-webkit-animation-name property, not necessarily for each CSS property that is animated.

Each event contains the duration of the animation. This allows the event handler to determine the currentiteration of a looping animation or the current position of an alternating animation. This duration does notinclude time the animation was in the paused play state.

Types of Animation Events

The type property of an animation event can have the following string values:

webkitAnimationStartOccurs at the start of an animation. It can bubble and be canceled. Its animationName property isset.

webkitAnimationEndOccurs when the animation finishes. It can bubble and be canceled. Its animationName andelapsedTime properties are set.

webkitAnimationIterationOccurs at the end of each iteration of an animation when the-webkit-animation-iteration-count is greater than 1. It does not occur for animations withan iteration count of 1. It can bubble and be canceled. Its animationName and elapsedTimeproperties are set.

Overview 432009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 9

WebKitAnimationEvent

Page 44: Safari DOM Extensions Reference

Tasks

Accessing Properties

animationName (page 44)The name of the animation. The value of the CSS -webkit-animation-name property of theanimation that caused the event.

elapsedTime (page 44)The duration of the animation, in seconds, since this event was sent, excluding any time the animationis paused. This value is not affected by the value of the CSS -webkit-animation-delay property.If the type of the event is webkitAnimationStart, elapsedTime is 0.

Initializing Objects

initWebKitAnimationEvent (page 45)Initializes a new animation event object.

Properties

animationNameThe name of the animation. The value of the CSS -webkit-animation-name property of the animationthat caused the event.

readonly attribute DOMString animationName;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

elapsedTimeThe duration of the animation, in seconds, since this event was sent, excluding any time the animation ispaused. This value is not affected by the value of the CSS -webkit-animation-delay property. If the typeof the event is webkitAnimationStart, elapsedTime is 0.

readonly attribute double elapsedTime;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

44 Tasks2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 9

WebKitAnimationEvent

Page 45: Safari DOM Extensions Reference

Methods

initWebKitAnimationEventInitializes a new animation event object.

voidinitWebKitAnimationEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString animationNameArg, in double elapsedTimeArg);

ParameterstypeArg

The type of event. See “Types of Animation Events” (page 43) for possible values.

canBubbleArgDetermines whether the event can bubble. Pass true if it can bubble; otherwise, false.

cancelableArgDetermines whether the event’s default action can be prevented. Pass true if it can be prevented;otherwise, false.

animationNameArgThe name of the animation associated with this event.

elapsedTimeArgThe duration of the animation, in seconds, since the event was sent.

DiscussionYou use this method to initialize the value of a WebKitTransitionEvent object that is created throughthe DocumentEvent interface. This method can only be invoked before the WebKitTransitionEventobject is dispatched via the dispatchEvent method (although it can be invoked multiple times during thatphase, if necessary). If it is invoked multiple times, the final invocation takes precedence.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Methods 452009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 9

WebKitAnimationEvent

Page 46: Safari DOM Extensions Reference

46 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 9

WebKitAnimationEvent

Page 47: Safari DOM Extensions Reference

Inherits from CSSRule

Availability Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

WebKitCSSKeyframeRule objects represent the style rule for a single keyframe in the @-webkit-keyframesCSS rule.

Tasks

Accessing Properties

keyText (page 47)A keyframe selector.

style (page 48)The style associated with this keyframe.

Properties

keyTextA keyframe selector.

attribute DOMString keyText;

DiscussionA keyframe selector represented as a percentage value or the keyword from or to. The selector is used tospecify the percentage along the duration of the animation. The keyframe is specified by the block of propertyvalues declared for the selector. The keyword from is equivalent to 0 percent and to is equivalent to 100percent.

Overview 472009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 10

WebKitCSSKeyframeRule

Page 48: Safari DOM Extensions Reference

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

styleThe style associated with this keyframe.

readonly attribute CSSStyleDeclaration style;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

48 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 10

WebKitCSSKeyframeRule

Page 49: Safari DOM Extensions Reference

Inherits from CSSRule

Availability Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

WebKitCSSKeyframesRule objects represent the keyframes for a single animation, that is, the contents ofan @-webkit-keyframes CSS rule.

Tasks

Accessing Properties

name (page 50)The name of the target animation that is set using the -webkit-animation-name property.

cssRules (page 50)The set of style rules that define the keyframes following the animation name.

Changing Rules

insertRule (page 51)Adds a keyframe rule to the collection of keyframes.

deleteRule (page 50)Removes a keyframe rule from the collection of keyframes.

findRule (page 50)Returns the keyframe rule for the specified selector.

Overview 492009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 11

WebKitCSSKeyframesRule

Page 50: Safari DOM Extensions Reference

Properties

cssRulesThe set of style rules that define the keyframes following the animation name.

readonly attribute CSSRuleList cssRules;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

nameThe name of the target animation that is set using the -webkit-animation-name property.

attribute DOMString name;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Methods

deleteRuleRemoves a keyframe rule from the collection of keyframes.

void deleteRule(in DOMString key);

Parameterskey

A selector for the rule that is either a percentage or the keyword from or to.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

findRuleReturns the keyframe rule for the specified selector.

WebKitCSSKeyframeRule findRule(in DOMString key);

Parameterskey

A selector for the rule that is either a percentage or the keyword from or to.

50 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 11

WebKitCSSKeyframesRule

Page 51: Safari DOM Extensions Reference

Return ValueReturns the keyframe rule corresponding to the given selector if it exists.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

insertRuleAdds a keyframe rule to the collection of keyframes.

void insertRule(in DOMString rule);

Parametersrule

A string representing a selector and keyframe, where the selector is a percentage or keyword and thekeyframe is a block. The string must follow the format for keyframe blocks in the @-webkit-keyframesCSS rule.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Methods 512009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 11

WebKitCSSKeyframesRule

Page 52: Safari DOM Extensions Reference

52 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 11

WebKitCSSKeyframesRule

Page 53: Safari DOM Extensions Reference

Availability Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

WebKitCSSMatrix objects represent a 4x4 homogeneous matrix for 3D transforms or a vector for 2Dtransforms. You can use these objects to manipulate matrices in JavaScript. For example, you can multiply,translate, and scale matrices.

The values of a 3D matrix can be initialized from the matrix3d() string returned bywindow.getComputedStyle(element).webkitTransform(). To apply the final matrix to an element,construct a matrix3d() string using the 16 values, and assign it to element.style.webkitTransform.Similarly, you can construct a matrix for 2D transforms by setting 6 values, represented by the a-f properties.

Tasks

Accessing Properties

a (page 55)The first 2D vector value.

b (page 55)The second 2D vector value.

c (page 55)The third 2D vector value.

d (page 56)The fourth 2D vector value.

e (page 56)The fifth 2D vector value.

f (page 56)The sixth 2D vector value.

m11 (page 56)The 3D matrix value in the first row and first column.

Overview 532009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 54: Safari DOM Extensions Reference

m12 (page 56)The 3D matrix value in the first row and second column.

m13 (page 57)The 3D matrix value in the first row and third column.

m14 (page 57)The 3D matrix value in the first row and fourth column.

m21 (page 57)The 3D matrix value in the second row and first column.

m22 (page 57)The 3D matrix value in the second row and second column.

m23 (page 58)The 3D matrix value in the second row and third column.

m24 (page 58)The 3D matrix value in the second row and fourth column.

m31 (page 58)The 3D matrix value in the third row and first column.

m32 (page 58)The 3D matrix value in the third row and second column.

m33 (page 59)The 3D matrix value in the third row and third column.

m34 (page 59)The 3D matrix value in the third row and fourth column.

m41 (page 59)The 3D matrix value in the fourth row and first column.

m42 (page 59)The 3D matrix value in the fourth row and second column.

m43 (page 60)The 3D matrix value in the fourth row and third column.

m44 (page 60)The 3D matrix value in the fourth row and fourth column.

Setting the Matrix

setMatrixValue (page 62)Sets the matrix values using a string representation.

Applying Operations

multiply (page 61)Returns the result of multiplying this matrix by a given matrix that is on the right.

inverse (page 60)Returns the inverse of this matrix.

54 Tasks2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 55: Safari DOM Extensions Reference

translate (page 63)Returns the result of translating this matrix by a given vector.

scale (page 62)Returns the result of scaling this matrix by a given vector.

rotate (page 61)Returns the result of rotating this matrix by a given vector.

rotateAxisAngle (page 61)Returns the result of rotating this matrix by a given vector and angle.

Converting the Matrix

toString (page 63)Returns a string representation of the matrix.

Properties

aThe first 2D vector value.

attribute float a;

AvailabilityAvailable in Safari 4.0 and later.

bThe second 2D vector value.

attribute float b;

AvailabilityAvailable in Safari 4.0 and later.

cThe third 2D vector value.

attribute float c;

AvailabilityAvailable in Safari 4.0 and later.

Properties 552009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 56: Safari DOM Extensions Reference

dThe fourth 2D vector value.

attribute float d;

AvailabilityAvailable in Safari 4.0 and later.

eThe fifth 2D vector value.

attribute float e;

AvailabilityAvailable in Safari 4.0 and later.

fThe sixth 2D vector value.

attribute float f;

AvailabilityAvailable in Safari 4.0 and later.

m11The 3D matrix value in the first row and first column.

attribute float m11;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m12The 3D matrix value in the first row and second column.

attribute float m12;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

56 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 57: Safari DOM Extensions Reference

AvailabilityAvailable in iPhone OS 2.0 and later.

m13The 3D matrix value in the first row and third column.

attribute float m13;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m14The 3D matrix value in the first row and fourth column.

attribute float m14;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m21The 3D matrix value in the second row and first column.

attribute float m21;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m22The 3D matrix value in the second row and second column.

attribute float m22;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

Properties 572009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 58: Safari DOM Extensions Reference

AvailabilityAvailable in iPhone OS 2.0 and later.

m23The 3D matrix value in the second row and third column.

attribute float m23;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m24The 3D matrix value in the second row and fourth column.

attribute float m24;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m31The 3D matrix value in the third row and first column.

attribute float m31;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m32The 3D matrix value in the third row and second column.

attribute float m32;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

58 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 59: Safari DOM Extensions Reference

AvailabilityAvailable in iPhone OS 2.0 and later.

m33The 3D matrix value in the third row and third column.

attribute float m33;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m34The 3D matrix value in the third row and fourth column.

attribute float m34;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m41The 3D matrix value in the fourth row and first column.

attribute float m41;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m42The 3D matrix value in the fourth row and second column.

attribute float m42;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

Properties 592009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 60: Safari DOM Extensions Reference

AvailabilityAvailable in iPhone OS 2.0 and later.

m43The 3D matrix value in the fourth row and third column.

attribute float m43;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

m44The 3D matrix value in the fourth row and fourth column.

attribute float m44;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in iPhone OS 2.0 and later.

Methods

inverseReturns the inverse of this matrix.

WebKitCSSMatrix inverse() raises CSSException;

Return ValueA new matrix that is the inverse of this matrix.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

60 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 61: Safari DOM Extensions Reference

multiplyReturns the result of multiplying this matrix by a given matrix that is on the right.

WebKitCSSMatrix multiply(in WebKitCSSMatrix secondMatrix) raises CSSException;

ParameterssecondMatrix

The matrix to multiply.

Return ValueA new matrix that is the result of multiplying this matrix by the given matrix.

DiscussionThe given matrix is on the right of the multiplication. This matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

rotateReturns the result of rotating this matrix by a given vector.

WebKitCSSMatrix rotate(in float rotX, in float rotY, in float rotZ);

ParametersrotX

The x component in the vector, in degrees.

rotYThe y component in the vector, in degrees. If undefined, the x component is used.

rotZThe z component in the vector, in degrees. If undefined, the x component is used.

Return ValueA new matrix that is the result of rotating this matrix by each of the three rotation matrices about the majoraxes, first the x axes, y axes, and then z axes.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

rotateAxisAngleReturns the result of rotating this matrix by a given vector and angle.

WebKitCSSMatrix rotateAxisAngle(in float x, in float y, in float z, in float angle);

Methods 612009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 62: Safari DOM Extensions Reference

Parametersx

The x component in the vector, in degrees.

yThe y component in the vector, in degrees. If undefined, the x component is used.

zThe z component in the vector, in degrees. If undefined, the x component is used.

angleThe angle of rotation about the axis vector, in degrees.

Return ValueA new matrix that is the result of rotating this matrix by each of the three rotation matrices about the majoraxes and angle. The right-hand rule is used to determine the direction of rotation.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

scaleReturns the result of scaling this matrix by a given vector.

WebKitCSSMatrix scale(in float scaleX, in float scaleY, in float scaleZ);

ParametersscaleX

The x component in the vector.

scaleYThe y component in the vector. If undefined, the x component is used.

scaleZThe z component in the vector. If undefined, 1 is used.

Return ValueA new matrix that is the result of scaling this matrix.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

setMatrixValueSets the matrix values using a string representation.

void setMatrixValue(in DOMString string);

62 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 63: Safari DOM Extensions Reference

Parametersstring

A matrix3d() string—typically returned bywindow.getComputedStyle(element).webkitTransform().

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

toStringReturns a string representation of the matrix.

DOMString toString();

Return ValueA string representation of the matrix’s values.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

translateReturns the result of translating this matrix by a given vector.

WebKitCSSMatrix translate(in float x, in float y, in float z);

Parametersx

The x component in the vector.

yThe y component in the vector.

zThe z component in the vector. If undefined, 0 is used.

Return ValueA new matrix that is the result of translating this matrix.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Methods 632009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 64: Safari DOM Extensions Reference

64 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitCSSMatrix

Page 65: Safari DOM Extensions Reference

Inherits from CSSValueList

Availability Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

WebKitCSSTransformValue objects represent one transform function in a CSS transform property. TheoperationType property in this class specifies which function is used. The objects also contain a list ofvalues which are the parameters to the function. The parameters appear in the same order as they appearin the function.

Tasks

Accessing Properties

operationType (page 65)The transform function used. Possible values are described in CSS_MATRIX (page 66).

Properties

operationTypeThe transform function used. Possible values are described in CSS_MATRIX (page 66).

readonly attribute unsigned short operationType;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Overview 652009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 13

WebKitCSSTransformValue

Page 66: Safari DOM Extensions Reference

Constants

DescriptionConstant

Specifies the matrix() transform function.const unsigned short CSS_MATRIX = 1;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_MATRIX

Specifies the matrix3d() transform function.const unsigned short CSS_MATRIX3D = 2;

Available in iPhone OS 2.0 and later.

CSS_MATRIX3D

Specifies the perspective() transform function.const unsigned short CSS_PERSPECTIVE = 12;

Available in iPhone OS 2.0 and later.

CSS_PERSPECTIVE

Specifies the rotate() transform function.const unsigned short CSS_ROTATE = 3;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_ROTATE

Specifies the rotate3d() transform function.const unsigned short CSS_ROTATE3D = 4;

Available in iPhone OS 2.0 and later.

CSS_ROTATE3D

Specifies the rotateX() transform function.const unsigned short CSS_ROTATEX = 13;

Available in iPhone OS 2.0 and later.

CSS_ROTATEX

Specifies the rotateY() transform function.const unsigned short CSS_ROTATEY = 14;

Available in iPhone OS 2.0 and later.

CSS_ROTATEY

Specifies the rotateZ() transform transform function.const unsigned short CSS_ROTATEZ = 15;

Available in iPhone OS 2.0 and later.

CSS_ROTATEZ

Specifies the scale() transform function.const unsigned short CSS_SCALE = 7;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_SCALE

66 Constants2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 13

WebKitCSSTransformValue

Page 67: Safari DOM Extensions Reference

DescriptionConstant

Specifies the scale3d() transform function.const unsigned short CSS_SCALE3D = 8;

Available in iPhone OS 2.0 and later.

CSS_SCALE3D

Specifies the scaleX() transform function.const unsigned short CSS_SCALEX = 19;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_SCALEX

Specifies the scaleY() transform function.const unsigned short CSS_SCALEY = 20;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_SCALEY

Specifies the scaleZ() transform function.const unsigned short CSS_SCALEZ = 21;

Available in iPhone OS 2.0 and later.

CSS_SCALEZ

Specifies the skew() transform function.const unsigned short CSS_SKEW = 8;

Available in Safari 4.0 and later.

CSS_SKEW

Specifies the skewX() transform function.const unsigned short CSS_SKEWX = 9;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_SKEWX

Specifies the skewY() transform function.const unsigned short CSS_SKEWY = 10;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_SKEWY

Specifies the translate() transform function.const unsigned short CSS_TRANSLATE = 5;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_TRANSLATE

Specifies the translate3d() transform function.const unsigned short CSS_TRANSLATE3D = 6;

Available in iPhone OS 2.0 and later.

CSS_TRANSLATE3D

Constants 672009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 13

WebKitCSSTransformValue

Page 68: Safari DOM Extensions Reference

DescriptionConstant

Specifies the translateX() transform function.const unsigned short CSS_TRANSLATEX = 16;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_TRANSLATEX

Specifies the translateY() transform function.const unsigned short CSS_TRANSLATEY = 17;

Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

CSS_TRANSLATEY

Specifies the translateZ() transform function.const unsigned short CSS_TRANSLATEZ = 18;

Available in iPhone OS 2.0 and later.

CSS_TRANSLATEZ

An unknown function.const unsigned short CSS_UNKNOWN = 0;

Available in iPhone OS 2.0 and later.

CSS_UNKNOWN

68 Constants2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 13

WebKitCSSTransformValue

Page 69: Safari DOM Extensions Reference

Availability Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

WebKitPoint objects represent a point in two-dimensional space used by transitions.

Tasks

Accessing Properties

x (page 69)The x coordinate for the point.

y (page 69)The y coordinate for the point.

Properties

xThe x coordinate for the point.

attribute float x;

AvailabilityAvailable in iPhone OS 2.0 and later.

yThe y coordinate for the point.

Overview 692009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 14

WebKitPoint

Page 70: Safari DOM Extensions Reference

attribute float y;

AvailabilityAvailable in iPhone OS 2.0 and later.

70 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 14

WebKitPoint

Page 71: Safari DOM Extensions Reference

Inherits from Event

Availability Available in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Companion guide Safari Visual Effects Guide

Overview

WebKitTransitionEvent objects provide information about CSS transitions. An event is sent at the endof a transition for each CSS property in the transition. Each event contains the name of the CSS property andduration of the transition. You can use these events to perform some action that starts at the end of atransition.

Types of Transition Events

The only possible string value for a transition event’s type property is:

webKitTransitionEndSent when a transition completes.

Tasks

Accessing Properties

propertyName (page 72)The name of the CSS property associated with the transition.

elapsedTime (page 72)The duration of the transition, in seconds, since this event was sent. This value is not affected by thevalue of the CSS -webkit-transition-delay property.

Overview 712009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitTransitionEvent

Page 72: Safari DOM Extensions Reference

Initializing

initWebKitTransitionEvent (page 72)Initializes a new transition event object.

Properties

elapsedTimeThe duration of the transition, in seconds, since this event was sent. This value is not affected by the valueof the CSS -webkit-transition-delay property.

readonly attribute double elapsedTime;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

propertyNameThe name of the CSS property associated with the transition.

readonly attribute DOMString propertyName;

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Methods

initWebKitTransitionEventInitializes a new transition event object.

void initWebKitTransitionEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString propertyNameArg, in double elapsedTimeArg);

ParameterstypeArg

The type of event.

Possible values for this argument are described in “Types of Transition Events” (page 71). This typeof event can bubble and be canceled. Its propertyName property is always set.

canBubbleArgDetermines whether the event can bubble. Pass true if it can bubble; otherwise, false.

72 Properties2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitTransitionEvent

Page 73: Safari DOM Extensions Reference

cancelableArgDetermines whether the event’s default action can be prevented. Pass true if it can be prevented;otherwise, false.

propertyNameArgThe name of the CSS property associated with this event.

elapsedTimeArgThe duration of the transition, in seconds, since the event was sent.

DiscussionYou use this method to initialize the value of a WebKitTransitionEvent object that is created throughthe DocumentEvent interface. This method can only be invoked before the WebKitTransitionEventobject is dispatched via the dispatchEvent method (although, it can be invoked multiple times duringthat phase, if necessary). If it is invoked multiple times, the final invocation takes precedence.

AvailabilityAvailable in Safari 4.0 and later.Available in iPhone OS 2.0 and later.

Methods 732009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitTransitionEvent

Page 74: Safari DOM Extensions Reference

74 Methods2009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitTransitionEvent

Page 75: Safari DOM Extensions Reference

This table describes the changes to Safari DOM Extensions Reference.

NotesDate

Updated per Safari 4.0 changes.2009-01-30

Added the DOMApplicationCache class.2008-11-21

Changed the title from "Safari DOM Touch Reference for iPhone OS" and addedvisual effects reference.

2008-10-15

Revised document that describes Safari on iPhone-only JavaScript functionsand properties.

2008-07-11

752009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

REVISION HISTORY

Document Revision History

Page 76: Safari DOM Extensions Reference

762009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

REVISION HISTORY

Document Revision History

Page 77: Safari DOM Extensions Reference

A

a property 55altKey property 28, 38animationName property 44applicationCache property 23

B

b property 55

C

c property 55changedTouches property 38CHECKING constant 20clientX property 34clientY property 34createTouch method 15createTouchList method 16cssRules property 50CSS_MATRIX constant 66CSS_MATRIX3D constant 66CSS_PERSPECTIVE constant 66CSS_ROTATE constant 66CSS_ROTATE3D constant 66CSS_ROTATEX constant 66CSS_ROTATEY constant 66CSS_ROTATEZ constant 66CSS_SCALE constant 66CSS_SCALE3D constant 67CSS_SCALEX constant 67CSS_SCALEY constant 67CSS_SCALEZ constant 67CSS_SKEW constant 67CSS_SKEWX constant 67CSS_SKEWY constant 67CSS_TRANSLATE constant 67

CSS_TRANSLATE3D constant 67CSS_TRANSLATEX constant 68CSS_TRANSLATEY constant 68CSS_TRANSLATEZ constant 68CSS_UNKNOWN constant 68ctrlKey property 28

D

d property 56deleteRule method 50DOWNLOADING constant 21

E

e property 56elapsedTime property 44, 72

F

f property 56findRule method 50

I

identifier property 34IDLE constant 20initGestureEvent method 30initTouchEvent method 38initWebKitAnimationEvent method 45initWebKitTransitionEvent method 72insertRule method 51inverse method 60item method 42

772009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

Index

Page 78: Safari DOM Extensions Reference

K

keyText property 47

L

length property 41

M

m11 property 56m12 property 56m13 property 57m14 property 57m21 property 57m22 property 57m23 property 58m24 property 58m31 property 58m32 property 58m33 property 59m34 property 59m41 property 59m42 property 59m43 property 60m44 property 60metaKey property 29multiply method 61

N

name property 50

O

oncached property 18onchecking property 18ondownloading property 18onerror property 19onnoupdate property 19onprogress property 19onupdateready property 19operationType property 65orientation property 24

P

pageX property 34pageY property 34propertyName property 72

R

rotate method 61rotateAxisAngle method 61rotation property 29

S

scale method 62scale property 29screenX property 35screenY property 35setMatrixValue method 62shiftKey property 29status property 19style property 48swapCache method 20

T

target property 29, 35toString method 63translate method 63

U

UNCACHED constant 20update method 20UPDATEREADY constant 21

W

webkitConvertPointFromNodeToPage method 24webkitConvertPointFromPageToNode method 25WEBKIT_KEYFRAMES_RULE constant 13WEBKIT_KEYFRAME_RULE constant 13

782009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

INDEX

Page 79: Safari DOM Extensions Reference

X

x property 69

Y

y property 69

792009-01-30 | © 2004, 2009 Apple Inc. All Rights Reserved.

INDEX