Last active
January 1, 2016 03:19
-
-
Save joseanpg/8084711 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.w3.org/TR/2013/WD-cssom-view-20131217/ | |
// Window Extensions | |
enum ScrollBehavior { "auto", "instant", "smooth" }; | |
dictionary ScrollOptions { | |
ScrollBehavior behavior = "auto"; | |
}; | |
////////////////////////////////////////////////////////////////////////////////// | |
-- viewport scrolling | |
type Window add { scrollX, scrollY | |
, pageYOffset, pageXOffset :: Double | |
} | |
-- The scrollX|Y attribute attribute must return the x|y-coordinate, | |
-- relative to the initial containing block origin, of the left|top of the viewport, | |
-- or zero if there is no viewport. | |
-- page(X|Y)Offset === scroll(X|Y) | |
with scroll, scrollTo, scrollBy :: (x :: Double , y :: Double, options :: Maybe ScrollOptions ); | |
-- scroll === scrollTo | |
-- client | |
type Window add { screenX, screenY | |
, outerWidth, outerHeight | |
, devicePixelRatio :: Double | |
} | |
-- The screenX|Y attribute must return the x|y-coordinate, relative to the origin of the screen of the output device, | |
-- of the left|top of the client window as number of pixels, or zero if there is no such thing. | |
-- The outerWidth|Height: width|height of the client window. | |
-- If there is no client window this attribute must return zero. | |
-- viewport | |
type Window add {innerWidth, innerHeight :: Double } | |
-- The innerWidth|Height attribute must return the viewport width|height including | |
-- the size of a rendered scroll bar (if any), or zero if there is no viewport. | |
-- browsing context | |
type Window | |
with moveTo, moveBy, | |
resizeTo, resizeBy :: (x :: Double , y :: Double) -> IO() | |
type Window add { screen :: Screen } -- [SameObject] | |
with matchMedia :: (query :: DOMString) -> MediaQueryList | |
///////////////////////////////////////////////////////////////////////////////////////////////////////7 | |
type Screen add { availWidth, availHeight | |
, width, height :: Double | |
, colorDepth, pixelDepth; | |
} | |
-- The availWidth|Height attribute must return the available width|height of the rendering surface of the output device, | |
-- in CSS pixels. | |
-- The width|height attribute must return the width|height of the output device, in CSS pixels. | |
-- The colorDepth and pixelDepth attributes are useless but are included for compatibility. | |
-- colorDepth = pixelDepth = 24. | |
//////////////////////////////////////////////////////////////////77 | |
dictionary ScrollOptionsHorizontal : ScrollOptions { double x; }; | |
dictionary ScrollOptionsVertical : ScrollOptions { double y; }; | |
type Element add { scrollWidth, scrollHeight | |
, clientTop , clientLeft | |
, clientWidth, clientHeight :: Double | |
, mutable scrollTop :: (Double | ScrollOptionsVertical) | |
, mutable scrollLeft :: (Double | ScrollOptionsHorizontal) | |
} | |
with getClientRects :: () -> DOMRectList | |
getBoundingClientRect :: () -> DOMRect | |
scrollIntoView :: () -> IO() | |
scrollIntoView :: (top :: Bool, options :: Maybe ScrollOptionsboolean) | |
-- clientTop|Left: | |
-- If the element has no associated CSS layout box or if the CSS layout box is inline, return zero. | |
-- Return the computed value of the 'border-top-width' property plus the height of any scrollbar rendered | |
-- between the top padding edge and the top border edge, | |
-- ignoring any transforms that apply to the element and its ancestors. | |
-- clientWidth|Height attribute must run these steps: | |
-- If the element has no associated CSS layout box or if the CSS layout box is inline, return zero. | |
-- If the element is the root element and the element's document is not in quirks mode, | |
-- or if the element is the HTML body element and the element's document is in quirks mode, | |
-- return the viewport width|height | |
-- excluding the size of a rendered scroll bar (if any). | |
-- Return the width|height of the padding edge | |
-- excluding the width of any rendered scrollbar between the padding edge and the border edge, | |
-- ignoring any transforms that apply to the element and its ancestors. | |
//////////////////////////////////////////////////////////////////77 | |
type HTMLElement add { offsetParent :: Maybe Element | |
, offsetTop, offsetLeft | |
, offsetWidth, offsetHeight :: Double | |
//////////////////////////////////////////////////////////////////77 | |
type HTMLImageElement add { x, y :: Double } | |
//////////////////////////////////////////////////////////////////77 | |
partial interface Range { | |
DOMRectList getClientRects(); | |
DOMRect getBoundingClientRect(); | |
}; | |
//////////////////////////////////////////////////////////////////// | |
type MouseEvent add { screenX, screenY | |
, pageX, pageY | |
, clientX, clientY | |
, x ,y | |
, offsetX, offsetY | |
} | |
partial dictionary MouseEventInit { | |
double screenX = 0.0; | |
double screenY = 0.0; | |
double clientX = 0.0; | |
double clientY = 0.0; | |
}; | |
-- screenX|Y: the x|y-coordinate of the position where the event occurred relative to the origin of the screen. | |
-- clientX|Y: the x|y-coordinate of the position where the event occurred relative to the origin of the viewport. | |
-- x|y === clientX|Y | |
-- pageX|Y: | |
If the event's dispatch flag is set, return the horizontal|vertical coordinate of the position | |
where the event occurred relative to the origin of the initial containing block. | |
pageX|Y = clientX|Y attribute + window.scrollX|Y | |
-- offsetX|Y: | |
If the event's dispatch flag is set, return the x|y-coordinate of the position | |
where the event occurred relative to the origin of the padding edge of the target node, | |
ignoring the transforms that apply to the element and its ancestors | |
Return the value of the event's pageX attribute. | |
//////////////////////////////////////////////////////////////////// | |
enum CSSBoxType { "margin", "border", "padding", "content" }; | |
dictionary BoxQuadOptions { | |
CSSBoxType box = "border"; | |
GeometryNode relativeTo; | |
}; | |
dictionary ConvertCoordinateOptions { | |
CSSBoxType fromBox = "border"; | |
CSSBoxType toBox = "border"; | |
}; | |
[NoInterfaceObject] | |
interface GeometryUtils { | |
sequence<DOMQuad> getBoxQuads(optional BoxQuadOptions options); | |
DOMQuad convertQuadFromNode(DOMQuad quad, GeometryNode from, optional ConvertCoordinateOptions options); | |
DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options); | |
DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions options); | |
}; | |
Text implements GeometryUtils; | |
Element implements GeometryUtils; | |
PseudoElement implements GeometryUtils; | |
Document implements GeometryUtils; | |
typedef (Text or Element or PseudoElement or Document) GeometryNode; | |
//////////////////////////////////////////////////////////////////// | |
type Document with | |
elementFromPoint :: (x :: Double, y :: Double) -> Maybe Element | |
elementsFromPoint :: (x :: Double, y :: Double) -> [Element] | |
caretPositionFromPoint :: (x :: Double, y :: Double) -> Maybe CaretPosition | |
{- The elementFromPoint(x, y) | |
If either argument is negative | |
, x is greater than the viewport width excluding the size of a rendered scroll bar (if any) | |
, or y is greater than the viewport height excluding the size of a rendered scroll bar (if any), | |
, or there is no viewport associated with the document | |
then return null and terminate | |
If there is a layout box in the viewport that would be a target for hit testing at coordinates x,y, | |
when applying the transforms that apply to the descendants of the viewport, | |
return the associated element and terminate these steps. | |
If the document has a root element, return the root element and terminate these steps. | |
Return null. | |
The elementFromPoint() method does not necessarily return the top-most painted element. | |
For instance, an element can be excluded from being a target for hit testing by using | |
the 'pointer-events' CSS property. | |
//////////////////////////////////////////////////////////////////77 | |
type CaretPosition = { offsetNode :: Node | |
, offset :: UInt | |
} | |
with getClientRect :: () -> Maybe DOMRect | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment