Backed out changesets 716f942b5798, 48edbd324d0f, 3e6446f6d0e6 (bug 918189) for bustage.
This commit is contained in:
@@ -65,17 +65,12 @@ inline bool IsSpaceCharacter(char aChar) {
|
||||
return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' ||
|
||||
aChar == '\f';
|
||||
}
|
||||
struct BoxQuadOptions;
|
||||
struct ConvertCoordinateOptions;
|
||||
class DOMPoint;
|
||||
class DOMQuad;
|
||||
class DOMRectReadOnly;
|
||||
class Element;
|
||||
struct BoxQuadOptions;
|
||||
class DOMQuad;
|
||||
class EventHandlerNonNull;
|
||||
class OnErrorEventHandlerNonNull;
|
||||
template<typename T> class Optional;
|
||||
class TextOrElementOrDocument;
|
||||
struct DOMPointInit;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -287,12 +282,7 @@ class nsINode : public mozilla::dom::EventTarget
|
||||
{
|
||||
public:
|
||||
typedef mozilla::dom::BoxQuadOptions BoxQuadOptions;
|
||||
typedef mozilla::dom::ConvertCoordinateOptions ConvertCoordinateOptions;
|
||||
typedef mozilla::dom::DOMPoint DOMPoint;
|
||||
typedef mozilla::dom::DOMPointInit DOMPointInit;
|
||||
typedef mozilla::dom::DOMQuad DOMQuad;
|
||||
typedef mozilla::dom::DOMRectReadOnly DOMRectReadOnly;
|
||||
typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument;
|
||||
typedef mozilla::ErrorResult ErrorResult;
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
|
||||
@@ -1630,19 +1620,6 @@ public:
|
||||
nsTArray<nsRefPtr<DOMQuad> >& aResult,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMQuad> ConvertQuadFromNode(DOMQuad& aQuad,
|
||||
const TextOrElementOrDocument& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<DOMQuad> ConvertRectFromNode(DOMRectReadOnly& aRect,
|
||||
const TextOrElementOrDocument& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<DOMPoint> ConvertPointFromNode(const DOMPointInit& aPoint,
|
||||
const TextOrElementOrDocument& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
|
||||
// Override this function to create a custom slots class.
|
||||
|
||||
@@ -1149,33 +1149,6 @@ nsINode::GetBoxQuads(const BoxQuadOptions& aOptions,
|
||||
mozilla::GetBoxQuads(this, aOptions, aResult, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
nsINode::ConvertQuadFromNode(DOMQuad& aQuad,
|
||||
const GeometryNode& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mozilla::ConvertQuadFromNode(this, aQuad, aFrom, aOptions, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
nsINode::ConvertRectFromNode(DOMRectReadOnly& aRect,
|
||||
const GeometryNode& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mozilla::ConvertRectFromNode(this, aRect, aFrom, aOptions, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMPoint>
|
||||
nsINode::ConvertPointFromNode(const DOMPointInit& aPoint,
|
||||
const GeometryNode& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mozilla::ConvertPointFromNode(this, aPoint, aFrom, aOptions, aRv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal)
|
||||
{
|
||||
|
||||
@@ -25,12 +25,9 @@ dictionary ConvertCoordinateOptions {
|
||||
interface GeometryUtils {
|
||||
[Throws, Pref="layout.css.getBoxQuads.enabled"]
|
||||
sequence<DOMQuad> getBoxQuads(optional BoxQuadOptions options);
|
||||
[Throws, Pref="layout.css.convertFromNode.enabled"]
|
||||
DOMQuad convertQuadFromNode(DOMQuad quad, GeometryNode from, optional ConvertCoordinateOptions options);
|
||||
[Throws, Pref="layout.css.convertFromNode.enabled"]
|
||||
DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options);
|
||||
[Throws, Pref="layout.css.convertFromNode.enabled"]
|
||||
DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions 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;
|
||||
|
||||
@@ -2932,7 +2932,7 @@ nsHTMLEditRules::MoveBlock(nsIDOMNode *aLeftBlock, nsIDOMNode *aRightBlock, int3
|
||||
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
// GetNodesFromPoint is the workhorse that figures out what we wnat to move.
|
||||
nsresult res = GetNodesFromPoint(::DOMPoint(aRightBlock,aRightOffset),
|
||||
nsresult res = GetNodesFromPoint(DOMPoint(aRightBlock,aRightOffset),
|
||||
EditAction::makeList, arrayOfNodes, true);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
int32_t listCount = arrayOfNodes.Count();
|
||||
@@ -6459,7 +6459,7 @@ nsHTMLEditRules::GetHighestInlineParent(nsIDOMNode* aNode)
|
||||
// of nodes from a point that will be operated on.
|
||||
//
|
||||
nsresult
|
||||
nsHTMLEditRules::GetNodesFromPoint(::DOMPoint point,
|
||||
nsHTMLEditRules::GetNodesFromPoint(DOMPoint point,
|
||||
EditAction operation,
|
||||
nsCOMArray<nsIDOMNode> &arrayOfNodes,
|
||||
bool dontTouchContent)
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
|
||||
#include "GeometryUtils.h"
|
||||
|
||||
#include "mozilla/dom/DOMPointBinding.h"
|
||||
#include "mozilla/dom/GeometryUtilsBinding.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "mozilla/dom/DOMPoint.h"
|
||||
#include "mozilla/dom/DOMQuad.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
@@ -23,6 +20,8 @@ using namespace mozilla::dom;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
typedef OwningTextOrElementOrDocument GeometryNode;
|
||||
|
||||
enum GeometryNodeType {
|
||||
GEOMETRY_NODE_ELEMENT,
|
||||
GEOMETRY_NODE_TEXT,
|
||||
@@ -56,14 +55,14 @@ GetFrameForNode(nsINode* aNode, GeometryNodeType aType)
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
GetFrameForGeometryNode(const Optional<OwningGeometryNode>& aGeometryNode,
|
||||
GetFrameForGeometryNode(const Optional<GeometryNode>& aGeometryNode,
|
||||
nsINode* aDefaultNode)
|
||||
{
|
||||
if (!aGeometryNode.WasPassed()) {
|
||||
return GetFrameForNode(aDefaultNode->OwnerDoc(), GEOMETRY_NODE_DOCUMENT);
|
||||
}
|
||||
|
||||
const OwningGeometryNode& value = aGeometryNode.Value();
|
||||
const GeometryNode& value = aGeometryNode.Value();
|
||||
if (value.IsElement()) {
|
||||
return GetFrameForNode(value.GetAsElement(), GEOMETRY_NODE_ELEMENT);
|
||||
}
|
||||
@@ -73,18 +72,6 @@ GetFrameForGeometryNode(const Optional<OwningGeometryNode>& aGeometryNode,
|
||||
return GetFrameForNode(value.GetAsText(), GEOMETRY_NODE_TEXT);
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
GetFrameForGeometryNode(const GeometryNode& aGeometryNode)
|
||||
{
|
||||
if (aGeometryNode.IsElement()) {
|
||||
return GetFrameForNode(&aGeometryNode.GetAsElement(), GEOMETRY_NODE_ELEMENT);
|
||||
}
|
||||
if (aGeometryNode.IsDocument()) {
|
||||
return GetFrameForNode(&aGeometryNode.GetAsDocument(), GEOMETRY_NODE_DOCUMENT);
|
||||
}
|
||||
return GetFrameForNode(&aGeometryNode.GetAsText(), GEOMETRY_NODE_TEXT);
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
GetFrameForNode(nsINode* aNode)
|
||||
{
|
||||
@@ -99,7 +86,7 @@ GetFrameForNode(nsINode* aNode)
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
GetFirstNonAnonymousFrameForGeometryNode(const Optional<OwningGeometryNode>& aNode,
|
||||
GetFirstNonAnonymousFrameForGeometryNode(const Optional<GeometryNode>& aNode,
|
||||
nsINode* aDefaultNode)
|
||||
{
|
||||
nsIFrame* f = GetFrameForGeometryNode(aNode, aDefaultNode);
|
||||
@@ -109,26 +96,6 @@ GetFirstNonAnonymousFrameForGeometryNode(const Optional<OwningGeometryNode>& aNo
|
||||
return f;
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
GetFirstNonAnonymousFrameForGeometryNode(const GeometryNode& aNode)
|
||||
{
|
||||
nsIFrame* f = GetFrameForGeometryNode(aNode);
|
||||
if (f) {
|
||||
f = nsLayoutUtils::GetFirstNonAnonymousFrame(f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
GetFirstNonAnonymousFrameForNode(nsINode* aNode)
|
||||
{
|
||||
nsIFrame* f = GetFrameForNode(aNode);
|
||||
if (f) {
|
||||
f = nsLayoutUtils::GetFirstNonAnonymousFrame(f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* This can modify aFrame to point to a different frame. This is needed to
|
||||
* handle SVG, where SVG elements can only compute a rect that's valid with
|
||||
@@ -268,102 +235,4 @@ void GetBoxQuads(nsINode* aNode,
|
||||
nsLayoutUtils::GetAllInFlowBoxes(frame, &callback);
|
||||
}
|
||||
|
||||
static void
|
||||
TransformPoints(nsINode* aTo, const GeometryNode& aFrom,
|
||||
uint32_t aPointCount, CSSPoint* aPoints,
|
||||
const ConvertCoordinateOptions& aOptions, ErrorResult& aRv)
|
||||
{
|
||||
nsIFrame* fromFrame = GetFirstNonAnonymousFrameForGeometryNode(aFrom);
|
||||
nsIFrame* toFrame = GetFirstNonAnonymousFrameForNode(aTo);
|
||||
if (!fromFrame || !toFrame) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
||||
return;
|
||||
}
|
||||
if (!CheckFramesInSameTopLevelBrowsingContext(fromFrame, toFrame)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
nsPoint fromOffset = GetBoxRectForFrame(&fromFrame, aOptions.mFromBox).TopLeft();
|
||||
nsPoint toOffset = GetBoxRectForFrame(&toFrame, aOptions.mToBox).TopLeft();
|
||||
CSSPoint fromOffsetGfx(nsPresContext::AppUnitsToFloatCSSPixels(fromOffset.x),
|
||||
nsPresContext::AppUnitsToFloatCSSPixels(fromOffset.y));
|
||||
for (uint32_t i = 0; i < aPointCount; ++i) {
|
||||
aPoints[i] += fromOffsetGfx;
|
||||
}
|
||||
nsLayoutUtils::TransformResult rv =
|
||||
nsLayoutUtils::TransformPoints(fromFrame, toFrame, aPointCount, aPoints);
|
||||
if (rv == nsLayoutUtils::TRANSFORM_SUCCEEDED) {
|
||||
CSSPoint toOffsetGfx(nsPresContext::AppUnitsToFloatCSSPixels(toOffset.x),
|
||||
nsPresContext::AppUnitsToFloatCSSPixels(toOffset.y));
|
||||
for (uint32_t i = 0; i < aPointCount; ++i) {
|
||||
aPoints[i] -= toOffsetGfx;
|
||||
}
|
||||
} else {
|
||||
PodZero(aPoints, aPointCount);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
ConvertQuadFromNode(nsINode* aTo, dom::DOMQuad& aQuad,
|
||||
const GeometryNode& aFrom,
|
||||
const dom::ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
CSSPoint points[4];
|
||||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
DOMPoint* p = aQuad.Point(i);
|
||||
if (p->W() != 1.0 || p->Z() != 0.0) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
points[i] = CSSPoint(p->X(), p->Y());
|
||||
}
|
||||
TransformPoints(aTo, aFrom, 4, points, aOptions, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<DOMQuad> result = new DOMQuad(aTo->GetParentObject(), points);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
ConvertRectFromNode(nsINode* aTo, dom::DOMRectReadOnly& aRect,
|
||||
const GeometryNode& aFrom,
|
||||
const dom::ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
CSSPoint points[4];
|
||||
double x = aRect.X(), y = aRect.Y(), w = aRect.Width(), h = aRect.Height();
|
||||
points[0] = CSSPoint(x, y);
|
||||
points[1] = CSSPoint(x + w, y);
|
||||
points[2] = CSSPoint(x + w, y + h);
|
||||
points[3] = CSSPoint(x, y + h);
|
||||
TransformPoints(aTo, aFrom, 4, points, aOptions, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<DOMQuad> result = new DOMQuad(aTo->GetParentObject(), points);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMPoint>
|
||||
ConvertPointFromNode(nsINode* aTo, const dom::DOMPointInit& aPoint,
|
||||
const GeometryNode& aFrom,
|
||||
const dom::ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (aPoint.mW != 1.0 || aPoint.mZ != 0.0) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
CSSPoint point(aPoint.mX, aPoint.mY);
|
||||
TransformPoints(aTo, aFrom, 1, &point, aOptions, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<DOMPoint> result = new DOMPoint(aTo->GetParentObject(), point.x, point.y);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,18 +22,11 @@ namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
struct BoxQuadOptions;
|
||||
struct ConvertCoordinateOptions;
|
||||
class DOMQuad;
|
||||
class DOMRectReadOnly;
|
||||
class DOMPoint;
|
||||
class DOMPointInit;
|
||||
class OwningTextOrElementOrDocument;
|
||||
class TextOrElementOrDocument;
|
||||
class Element;
|
||||
class Text;
|
||||
}
|
||||
|
||||
typedef dom::TextOrElementOrDocument GeometryNode;
|
||||
typedef dom::OwningTextOrElementOrDocument OwningGeometryNode;
|
||||
|
||||
/**
|
||||
* Computes quads for aNode using aOptions, according to GeometryUtils.getBoxQuads.
|
||||
* May set an error in aRv.
|
||||
@@ -43,24 +36,6 @@ void GetBoxQuads(nsINode* aNode,
|
||||
nsTArray<nsRefPtr<dom::DOMQuad> >& aResult,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<dom::DOMQuad>
|
||||
ConvertQuadFromNode(nsINode* aTo, dom::DOMQuad& aQuad,
|
||||
const GeometryNode& aFrom,
|
||||
const dom::ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<dom::DOMQuad>
|
||||
ConvertRectFromNode(nsINode* aTo, dom::DOMRectReadOnly& aRect,
|
||||
const GeometryNode& aFrom,
|
||||
const dom::ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<dom::DOMPoint>
|
||||
ConvertPointFromNode(nsINode* aTo, const dom::DOMPointInit& aPoint,
|
||||
const GeometryNode& aFrom,
|
||||
const dom::ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_GEOMETRYUTILS_H_ */
|
||||
|
||||
@@ -459,7 +459,6 @@ skip-if = toolkit == "win"
|
||||
[test_flush_on_paint.html]
|
||||
skip-if = true || (toolkit == 'android') || (toolkit == "cocoa") # Bug 688128, bug 539356
|
||||
[test_getBoxQuads_convertPointRectQuad.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 948948
|
||||
[test_bug687297.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 948948
|
||||
support-files =
|
||||
|
||||
@@ -12,13 +12,6 @@
|
||||
var f1d;
|
||||
var text;
|
||||
var suppressedText;
|
||||
var suppressedText2;
|
||||
var comment;
|
||||
var fragment;
|
||||
var openedWindow;
|
||||
var zeroPoint = new DOMPoint(0,0);
|
||||
var zeroRect = new DOMRect(0,0,0,0);
|
||||
var zeroQuad = new DOMQuad(zeroRect);
|
||||
var notInDocument = document.createElement('div');
|
||||
|
||||
function isEval(expr, b) {
|
||||
@@ -45,105 +38,6 @@ function makeQuadsExpr(fromStr, options) {
|
||||
return fromStr + ".getBoxQuads({" + getBoxQuadsOptionParts.join(',') + "})";
|
||||
}
|
||||
|
||||
function makePointExpr(fromStr, options, x, y) {
|
||||
var convertPointOptionParts = [];
|
||||
if ('box' in options) {
|
||||
convertPointOptionParts.push("fromBox:'" + options.box + "'");
|
||||
}
|
||||
if ('toBox' in options) {
|
||||
convertPointOptionParts.push("toBox:'" + options.toBox + "'");
|
||||
}
|
||||
return ('toStr' in options ? options.toStr : "document") +
|
||||
".convertPointFromNode(new DOMPoint(" + x + "," + y + ")," + fromStr + ",{" +
|
||||
convertPointOptionParts.join(",") + "})";
|
||||
}
|
||||
|
||||
function checkConvertPoints(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4) {
|
||||
var selfQuads = eval(fromStr).getBoxQuads(
|
||||
{box:options.box == "" ? "border" : options.box,
|
||||
relativeTo:eval(fromStr)});
|
||||
var boxWidth = selfQuads[0].bounds.width;
|
||||
var boxHeight = selfQuads[0].bounds.height;
|
||||
|
||||
var convertTopLeftPointExpr = makePointExpr(fromStr, options, 0, 0);
|
||||
var topLeft = eval(convertTopLeftPointExpr);
|
||||
isApprox(topLeft.x, x1, convertTopLeftPointExpr + ".x", options);
|
||||
isApprox(topLeft.y, y1, convertTopLeftPointExpr + ".y", options);
|
||||
|
||||
var convertTopRightPointExpr = makePointExpr(fromStr, options, boxWidth, 0);
|
||||
var topRight = eval(convertTopRightPointExpr);
|
||||
isApprox(topRight.x, x2, convertTopRightPointExpr + ".x", options);
|
||||
isApprox(topRight.y, y2, convertTopRightPointExpr + ".y", options);
|
||||
|
||||
var convertBottomRightPointExpr = makePointExpr(fromStr, options, boxWidth, boxHeight);
|
||||
var bottomRight = eval(convertBottomRightPointExpr);
|
||||
isApprox(bottomRight.x, x3, convertBottomRightPointExpr + ".x", options);
|
||||
isApprox(bottomRight.y, y3, convertBottomRightPointExpr + ".y", options);
|
||||
|
||||
var convertBottomLeftPointExpr = makePointExpr(fromStr, options, 0, boxHeight);
|
||||
var bottomLeft = eval(convertBottomLeftPointExpr);
|
||||
isApprox(bottomLeft.x, x4, convertBottomLeftPointExpr + ".x", options);
|
||||
isApprox(bottomLeft.y, y4, convertBottomLeftPointExpr + ".y", options);
|
||||
}
|
||||
|
||||
function checkConvertRect(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4) {
|
||||
var selfQuads = eval(fromStr).getBoxQuads(
|
||||
{box:options.box == "" ? "border" : options.box,
|
||||
relativeTo:eval(fromStr)});
|
||||
var boxWidth = selfQuads[0].bounds.width;
|
||||
var boxHeight = selfQuads[0].bounds.height;
|
||||
|
||||
var convertPointOptionParts = [];
|
||||
if ('box' in options) {
|
||||
convertPointOptionParts.push("fromBox:'" + options.box + "'");
|
||||
}
|
||||
if ('toBox' in options) {
|
||||
convertPointOptionParts.push("toBox:'" + options.toBox + "'");
|
||||
}
|
||||
|
||||
var convertRectExpr = ('toStr' in options ? options.toStr : "document") +
|
||||
".convertRectFromNode(new DOMRect(0,0," + boxWidth + "," + boxHeight + ")," +
|
||||
fromStr + ",{" + convertPointOptionParts.join(",") + "})";
|
||||
var quad = eval(convertRectExpr);
|
||||
isApprox(quad.p1.x, x1, convertRectExpr + ".p1.x", options);
|
||||
isApprox(quad.p1.y, y1, convertRectExpr + ".p1.y", options);
|
||||
isApprox(quad.p2.x, x2, convertRectExpr + ".p2.x", options);
|
||||
isApprox(quad.p2.y, y2, convertRectExpr + ".p2.y", options);
|
||||
isApprox(quad.p3.x, x3, convertRectExpr + ".p3.x", options);
|
||||
isApprox(quad.p3.y, y3, convertRectExpr + ".p3.y", options);
|
||||
isApprox(quad.p4.x, x4, convertRectExpr + ".p4.x", options);
|
||||
isApprox(quad.p4.y, y4, convertRectExpr + ".p4.y", options);
|
||||
}
|
||||
|
||||
function checkConvertQuad(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4) {
|
||||
var selfQuads = eval(fromStr).getBoxQuads(
|
||||
{box:options.box == "" ? "border" : options.box,
|
||||
relativeTo:eval(fromStr)});
|
||||
var boxWidth = selfQuads[0].bounds.width;
|
||||
var boxHeight = selfQuads[0].bounds.height;
|
||||
|
||||
var convertPointOptionParts = [];
|
||||
if ('box' in options) {
|
||||
convertPointOptionParts.push("fromBox:'" + options.box + "'");
|
||||
}
|
||||
if ('toBox' in options) {
|
||||
convertPointOptionParts.push("toBox:'" + options.toBox + "'");
|
||||
}
|
||||
|
||||
var convertQuadExpr = ('toStr' in options ? options.toStr : "document") +
|
||||
".convertQuadFromNode(new DOMQuad(new DOMRect(0,0," + boxWidth + "," + boxHeight + "))," +
|
||||
fromStr + ",{" + convertPointOptionParts.join(",") + "})";
|
||||
var quad = eval(convertQuadExpr);
|
||||
isApprox(quad.p1.x, x1, convertQuadExpr + ".p1.x", options);
|
||||
isApprox(quad.p1.y, y1, convertQuadExpr + ".p1.y", options);
|
||||
isApprox(quad.p2.x, x2, convertQuadExpr + ".p2.x", options);
|
||||
isApprox(quad.p2.y, y2, convertQuadExpr + ".p2.y", options);
|
||||
isApprox(quad.p3.x, x3, convertQuadExpr + ".p3.x", options);
|
||||
isApprox(quad.p3.y, y3, convertQuadExpr + ".p3.y", options);
|
||||
isApprox(quad.p4.x, x4, convertQuadExpr + ".p4.x", options);
|
||||
isApprox(quad.p4.y, y4, convertQuadExpr + ".p4.y", options);
|
||||
}
|
||||
|
||||
function checkQuadIsRect(fromStr, options, x, y, w, h) {
|
||||
var quadsExpr = makeQuadsExpr(fromStr, options);
|
||||
var quads = eval(quadsExpr);
|
||||
@@ -162,10 +56,6 @@ function checkQuadIsRect(fromStr, options, x, y, w, h) {
|
||||
isApprox(q.bounds.top, y, quadsExpr + " checking quad.bounds.top", options);
|
||||
isApprox(q.bounds.width, w, quadsExpr + " checking quad.bounds.width", options);
|
||||
isApprox(q.bounds.height, h, quadsExpr + " checking quad.bounds.height", options);
|
||||
|
||||
checkConvertPoints(fromStr, options, x, y, x + w, y, x + w, y + h, x, y + h);
|
||||
checkConvertRect(fromStr, options, x, y, x + w, y, x + w, y + h, x, y + h);
|
||||
checkConvertQuad(fromStr, options, x, y, x + w, y, x + w, y + h, x, y + h);
|
||||
}
|
||||
|
||||
function checkQuadIsQuad(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4) {
|
||||
@@ -186,33 +76,6 @@ function checkQuadIsQuad(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4) {
|
||||
isApprox(q.bounds.top, Math.min(y1,y2,y3,y4), quadsExpr + " checking quad.bounds.top", options);
|
||||
isApprox(q.bounds.right, Math.max(x1,x2,x3,x4), quadsExpr + " checking quad.bounds.right", options);
|
||||
isApprox(q.bounds.bottom, Math.max(y1,y2,y3,y4), quadsExpr + " checking quad.bounds.bottom", options);
|
||||
|
||||
checkConvertPoints(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
checkConvertRect(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
checkConvertQuad(fromStr, options, x1, y1, x2, y2, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
function checkException(expr, name) {
|
||||
try {
|
||||
eval(expr);
|
||||
ok(false, "Exception should have been thrown for " + expr);
|
||||
} catch (ex) {
|
||||
is(ex.name, name, "Checking exception type for " + expr);
|
||||
}
|
||||
}
|
||||
|
||||
function checkNotFound(fromStr, toStr, x1, y1, x2, y2) {
|
||||
var convertPointExpr = toStr + ".convertPointFromNode(new DOMPoint(" + x1 +
|
||||
"," + y1 + ")," + fromStr + ")";
|
||||
checkException(convertPointExpr, "NotFoundError");
|
||||
|
||||
var convertRectExpr = toStr + ".convertRectFromNode(new DOMRect(" + x1 +
|
||||
"," + y1 + "," + x2 + "," + y2 + ")," + fromStr + ")";
|
||||
checkException(convertRectExpr, "NotFoundError");
|
||||
|
||||
var convertQuadExpr = toStr + ".convertQuadFromNode(new DOMQuad(new DOMRect(" + x1 +
|
||||
"," + y1 + "," + x2 + "," + y2 + "))," + fromStr + ")";
|
||||
checkException(convertQuadExpr, "NotFoundError");
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
@@ -273,7 +136,6 @@ TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText
|
||||
></div>
|
||||
|
||||
<div id="suppressedTextContainer"> </div>
|
||||
<div id="suppressedTextContainer2"> </div>
|
||||
|
||||
<div id="commentContainer"><!-- COMMENT --></div>
|
||||
|
||||
@@ -354,8 +216,7 @@ window.scrollTo(0,0);
|
||||
function startTest() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["layout.css.DOMPoint.enabled", true],
|
||||
["layout.css.DOMQuad.enabled", true],
|
||||
["layout.css.getBoxQuads.enabled", true],
|
||||
["layout.css.convertFromNode.enabled", true]]}, runTest);
|
||||
["layout.css.getBoxQuads.enabled", true]]}, runTest);
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
@@ -363,9 +224,6 @@ function runTest() {
|
||||
f1d = f1.contentWindow.f1d;
|
||||
text = textContainer.firstChild;
|
||||
suppressedText = suppressedTextContainer.firstChild;
|
||||
suppressedText2 = suppressedTextContainer2.firstChild;
|
||||
comment = commentContainer.firstChild;
|
||||
fragment = document.createDocumentFragment();
|
||||
|
||||
// Test basic BoxQuadOptions.box.
|
||||
var dX = d.getBoundingClientRect().left;
|
||||
@@ -433,8 +291,6 @@ function runTest() {
|
||||
var tableY = table.getClientRects()[0].top;
|
||||
checkQuadIsRect("d", {toStr:"table"},
|
||||
dX - tableX, dY - tableY, dW, dH);
|
||||
isEval("ibSplit.convertPointFromNode(zeroPoint,d).x", dX - ibSplitPart1X);
|
||||
isEval("table.convertPointFromNode(zeroPoint,d).x", dX - table.getClientRects()[0].left);
|
||||
|
||||
// Test boxes generated by block splitting. Check for borders being placed correctly.
|
||||
var colSplitY = colSplit.getClientRects()[0].top;
|
||||
@@ -485,34 +341,40 @@ function runTest() {
|
||||
isEval("suppressedText.getBoxQuads()[0].bounds.left", suppressedTextContainerX);
|
||||
isEval("suppressedText.getBoxQuads()[0].bounds.width", 0);
|
||||
|
||||
var suppressedTextContainer2X = suppressedTextContainer2.getBoundingClientRect().left;
|
||||
isEval("document.convertPointFromNode(zeroPoint,suppressedText2).x",
|
||||
suppressedTextContainer2X);
|
||||
var comment = commentContainer.firstChild;
|
||||
try {
|
||||
comment.getBoxQuads();
|
||||
ok(false, "Exception should have been thrown");
|
||||
} catch (ex) {
|
||||
is(ex.name, "TypeError",
|
||||
"Exception for comment.getBoxQuads()");
|
||||
}
|
||||
try {
|
||||
d.getBoxQuads({relativeTo:comment});
|
||||
ok(false, "Exception should have been thrown");
|
||||
} catch (ex) {
|
||||
is(ex.name, "TypeError",
|
||||
"Exception for getBoxQuads({relativeTo:comment})");
|
||||
}
|
||||
|
||||
checkException("comment.getBoxQuads()", "TypeError");
|
||||
checkException("d.getBoxQuads({relativeTo:comment})", "TypeError");
|
||||
checkException("comment.convertPointFromNode(zeroPoint,document)", "TypeError");
|
||||
checkException("document.convertPointFromNode(zeroPoint,comment)", "TypeError");
|
||||
checkException("comment.convertRectFromNode(zeroRect,document)", "TypeError");
|
||||
checkException("document.convertRectFromNode(zeroRect,comment)", "TypeError");
|
||||
checkException("comment.convertQuadFromNode(zeroQuad,document)", "TypeError");
|
||||
checkException("document.convertQuadFromNode(zeroQuad,comment)", "TypeError");
|
||||
|
||||
checkException("fragment.getBoxQuads()", "TypeError");
|
||||
checkException("d.getBoxQuads({relativeTo:fragment})", "TypeError");
|
||||
checkException("fragment.convertPointFromNode(zeroPoint,document)", "TypeError");
|
||||
checkException("document.convertPointFromNode(zeroPoint,fragment)", "TypeError");
|
||||
checkException("fragment.convertRectFromNode(zeroRect,document)", "TypeError");
|
||||
checkException("document.convertRectFromNode(zeroRect,fragment)", "TypeError");
|
||||
checkException("fragment.convertQuadFromNode(zeroQuad,document)", "TypeError");
|
||||
checkException("document.convertQuadFromNode(zeroQuad,fragment)", "TypeError");
|
||||
var fragment = document.createDocumentFragment();
|
||||
try {
|
||||
fragment.getBoxQuads();
|
||||
ok(false, "Exception should have been thrown");
|
||||
} catch (ex) {
|
||||
is(ex.name, "TypeError",
|
||||
"Exception for fragment.getBoxQuads()");
|
||||
}
|
||||
try {
|
||||
d.getBoxQuads({relativeTo:fragment});
|
||||
ok(false, "Exception should have been thrown");
|
||||
} catch (ex) {
|
||||
is(ex.name, "TypeError",
|
||||
"Exception for getBoxQuads({relativeTo:fragment})");
|
||||
}
|
||||
|
||||
isEval("displayNone.getBoxQuads().length", 0);
|
||||
isEval("notInDocument.getBoxQuads().length", 0);
|
||||
checkNotFound("displayNone", "document", 1, 2, 3, 4);
|
||||
checkNotFound("notInDocument", "document", 1, 2, 3, 4);
|
||||
checkNotFound("document", "displayNone", 1, 2, 3, 4);
|
||||
checkNotFound("document", "notInDocument", 1, 2, 3, 4);
|
||||
|
||||
// Test an overflow:hidden version of d. overflow:hidden should not affect
|
||||
// the quads, basically.
|
||||
@@ -576,7 +438,7 @@ function runTest() {
|
||||
var rot45tcX = rot45TransformContainer.getBoundingClientRect().left;
|
||||
var rot45tcY = rot45TransformContainer.getBoundingClientRect().top;
|
||||
var halfDiagonal = 100/Math.sqrt(2);
|
||||
checkQuadIsQuad("rot45Transform", {tolerance:0.01},
|
||||
checkQuadIsQuad("rot45Transform", {tolerance:0.0001},
|
||||
rot45tcX + 50, rot45tcY + 50 - halfDiagonal,
|
||||
rot45tcX + 50 + halfDiagonal, rot45tcY + 50,
|
||||
rot45tcX + 50, rot45tcY + 50 + halfDiagonal,
|
||||
@@ -601,13 +463,13 @@ function runTest() {
|
||||
// Test 3D transforms.
|
||||
var t3tcX = threeDTransformContainer.getBoundingClientRect().left;
|
||||
var t3tcY = threeDTransformContainer.getBoundingClientRect().top;
|
||||
checkQuadIsQuad("threeDTransform", {tolerance:0.01},
|
||||
checkQuadIsQuad("threeDTransform", {tolerance:0.0001},
|
||||
t3tcX + 59.446714, t3tcY - 18.569847,
|
||||
t3tcX + 129.570778, t3tcY + 13.540874,
|
||||
t3tcX + 129.570778, t3tcY + 100,
|
||||
t3tcX + 59.446714, t3tcY + 100);
|
||||
// Test nested 3D transforms (without preserve-3d).
|
||||
checkQuadIsQuad("threeDTransformChild", {tolerance:0.01},
|
||||
checkQuadIsQuad("threeDTransformChild", {tolerance:0.0001},
|
||||
t3tcX + 89.395061, t3tcY + 2.243033,
|
||||
t3tcX + 113.041727, t3tcY - 2.758530,
|
||||
t3tcX + 113.041727, t3tcY + 52.985921,
|
||||
@@ -615,11 +477,11 @@ function runTest() {
|
||||
// Test preserve-3D.
|
||||
var p3dtcX = preserve3DTransformContainer.getBoundingClientRect().left;
|
||||
var p3dtcY = preserve3DTransformContainer.getBoundingClientRect().top;
|
||||
checkQuadIsRect("preserve3DTransformChild", {tolerance:0.01},
|
||||
checkQuadIsRect("preserve3DTransformChild", {tolerance:0.0001},
|
||||
p3dtcX, p3dtcY, 200, 50,
|
||||
{tolerance:0.0001});
|
||||
// Test mapping back into preserve-3D.
|
||||
checkQuadIsRect("d", {toStr:"preserve3DTransformChild",tolerance:0.01},
|
||||
checkQuadIsRect("d", {toStr:"preserve3DTransformChild",tolerance:0.0001},
|
||||
dX - p3dtcX, dY - p3dtcY, dW, dH);
|
||||
|
||||
// Test SVG.
|
||||
@@ -644,28 +506,19 @@ function runTest() {
|
||||
|
||||
// Test that converting between nodes in different toplevel browsing contexts
|
||||
// throws an exception.
|
||||
try {
|
||||
openedWindow = window.open("data:text/html,<div id='d'>","");
|
||||
} catch (ex) {
|
||||
// in some cases we can't open the window.
|
||||
openedWindow = null;
|
||||
}
|
||||
if (openedWindow) {
|
||||
var openedWindow = window.open("data:text/html,<div id='d'>","");
|
||||
openedWindow.addEventListener("load", function() {
|
||||
checkException("openedWindow.d.getBoxQuads({relativeTo:document})", "NotFoundError");
|
||||
checkException("document.getBoxQuads({relativeTo:openedWindow.d})", "NotFoundError");
|
||||
checkException("openedWindow.d.convertPointFromNode(zeroPoint,document)", "NotFoundError");
|
||||
checkException("document.convertPointFromNode(zeroPoint,openedWindow.d)", "NotFoundError");
|
||||
checkException("openedWindow.d.convertRectFromNode(zeroRect,document)", "NotFoundError");
|
||||
checkException("document.convertRectFromNode(zeroRect,openedWindow.d)", "NotFoundError");
|
||||
checkException("openedWindow.d.convertQuadFromNode(zeroQuad,document)", "NotFoundError");
|
||||
checkException("document.convertQuadFromNode(zeroQuad,openedWindow.d)", "NotFoundError");
|
||||
try {
|
||||
openedWindow.d.getBoxQuads({relativeTo:document});
|
||||
ok(false, "Exception should have been thrown");
|
||||
} catch (ex) {
|
||||
is(ex.name, "NotFoundError",
|
||||
"Exception for getBoxQuads on nodes in different toplevel browsing contexts");
|
||||
}
|
||||
openedWindow.close();
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
} else {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -1823,13 +1823,6 @@ pref("layout.css.getBoxQuads.enabled", false);
|
||||
pref("layout.css.getBoxQuads.enabled", true);
|
||||
#endif
|
||||
|
||||
// Is support for GeometryUtils.getBoxQuads enabled?
|
||||
#ifdef RELEASE_BUILD
|
||||
pref("layout.css.convertFromNode.enabled", false);
|
||||
#else
|
||||
pref("layout.css.convertFromNode.enabled", true);
|
||||
#endif
|
||||
|
||||
// Is support for CSS "text-align: true X" enabled?
|
||||
pref("layout.css.text-align-true-value.enabled", false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user