| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/testing/Internals.h" | 27 #include "core/testing/Internals.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/ExceptionMessages.h" | 29 #include "bindings/core/v8/ExceptionMessages.h" |
| 30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
| 31 #include "bindings/core/v8/GeometryInterfaces.h" |
| 31 #include "bindings/core/v8/ScriptFunction.h" | 32 #include "bindings/core/v8/ScriptFunction.h" |
| 32 #include "bindings/core/v8/ScriptPromise.h" | 33 #include "bindings/core/v8/ScriptPromise.h" |
| 33 #include "bindings/core/v8/ScriptPromiseResolver.h" | 34 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 34 #include "bindings/core/v8/SerializedScriptValue.h" | 35 #include "bindings/core/v8/SerializedScriptValue.h" |
| 35 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 36 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 36 #include "bindings/core/v8/V8IteratorResultValue.h" | 37 #include "bindings/core/v8/V8IteratorResultValue.h" |
| 37 #include "bindings/core/v8/V8ThrowException.h" | 38 #include "bindings/core/v8/V8ThrowException.h" |
| 38 #include "core/HTMLNames.h" | 39 #include "core/HTMLNames.h" |
| 39 #include "core/SVGNames.h" | 40 #include "core/SVGNames.h" |
| 40 #include "core/animation/AnimationTimeline.h" | 41 #include "core/animation/AnimationTimeline.h" |
| 41 #include "core/css/StyleSheetContents.h" | 42 #include "core/css/StyleSheetContents.h" |
| 42 #include "core/css/resolver/StyleResolver.h" | 43 #include "core/css/resolver/StyleResolver.h" |
| 43 #include "core/css/resolver/StyleResolverStats.h" | 44 #include "core/css/resolver/StyleResolverStats.h" |
| 44 #include "core/css/resolver/ViewportStyleResolver.h" | 45 #include "core/css/resolver/ViewportStyleResolver.h" |
| 45 #include "core/dom/ClientRect.h" | 46 #include "core/dom/ClientRect.h" |
| 46 #include "core/dom/ClientRectList.h" | 47 #include "core/dom/ClientRectList.h" |
| 47 #include "core/dom/DOMArrayBuffer.h" | 48 #include "core/dom/DOMArrayBuffer.h" |
| 48 #include "core/dom/DOMNodeIds.h" | 49 #include "core/dom/DOMNodeIds.h" |
| 49 #include "core/dom/DOMPoint.h" | |
| 50 #include "core/dom/DOMStringList.h" | 50 #include "core/dom/DOMStringList.h" |
| 51 #include "core/dom/Document.h" | 51 #include "core/dom/Document.h" |
| 52 #include "core/dom/Element.h" | 52 #include "core/dom/Element.h" |
| 53 #include "core/dom/ExceptionCode.h" | 53 #include "core/dom/ExceptionCode.h" |
| 54 #include "core/dom/Iterator.h" | 54 #include "core/dom/Iterator.h" |
| 55 #include "core/dom/NodeComputedStyle.h" | 55 #include "core/dom/NodeComputedStyle.h" |
| 56 #include "core/dom/PseudoElement.h" | 56 #include "core/dom/PseudoElement.h" |
| 57 #include "core/dom/Range.h" | 57 #include "core/dom/Range.h" |
| 58 #include "core/dom/StaticNodeList.h" | 58 #include "core/dom/StaticNodeList.h" |
| 59 #include "core/dom/StyleEngine.h" | 59 #include "core/dom/StyleEngine.h" |
| (...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 | 1067 |
| 1068 String Internals::rangeAsText(const Range* range) | 1068 String Internals::rangeAsText(const Range* range) |
| 1069 { | 1069 { |
| 1070 ASSERT(range); | 1070 ASSERT(range); |
| 1071 return range->text(); | 1071 return range->text(); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 // FIXME: The next four functions are very similar - combine them once | 1074 // FIXME: The next four functions are very similar - combine them once |
| 1075 // bestClickableNode/bestContextMenuNode have been combined.. | 1075 // bestClickableNode/bestContextMenuNode have been combined.. |
| 1076 | 1076 |
| 1077 DOMPoint* Internals::touchPositionAdjustedToBestClickableNode(long x, long y, lo
ng width, long height, Document* document, ExceptionState& exceptionState) | 1077 ScriptValue Internals::touchPositionAdjustedToBestClickableNode(long x, long y,
long width, long height, Document* document, ExceptionState& exceptionState) |
| 1078 { | 1078 { |
| 1079 ASSERT(document); | 1079 ASSERT(document); |
| 1080 if (!document->frame()) { | 1080 if (!document->frame()) { |
| 1081 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); | 1081 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
| 1082 return 0; | 1082 return GeometryInterfaces::createDOMPoint(); |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 document->updateLayout(); | 1085 document->updateLayout(); |
| 1086 | 1086 |
| 1087 IntSize radius(width / 2, height / 2); | 1087 IntSize radius(width / 2, height / 2); |
| 1088 IntPoint point(x + radius.width(), y + radius.height()); | 1088 IntPoint point(x + radius.width(), y + radius.height()); |
| 1089 | 1089 |
| 1090 EventHandler& eventHandler = document->frame()->eventHandler(); | 1090 EventHandler& eventHandler = document->frame()->eventHandler(); |
| 1091 IntPoint hitTestPoint = document->frame()->view()->rootFrameToContents(point
); | 1091 IntPoint hitTestPoint = document->frame()->view()->rootFrameToContents(point
); |
| 1092 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, Layout
Size(radius)); | 1092 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, Layout
Size(radius)); |
| 1093 | 1093 |
| 1094 Node* targetNode = 0; | 1094 Node* targetNode = 0; |
| 1095 IntPoint adjustedPoint; | 1095 IntPoint adjustedPoint; |
| 1096 | 1096 |
| 1097 bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adju
stedPoint, targetNode); | 1097 bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adju
stedPoint, targetNode); |
| 1098 if (foundNode) | 1098 if (foundNode) |
| 1099 return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y()); | 1099 return GeometryInterfaces::createDOMPoint(adjustedPoint.x(), adjustedPoi
nt.y()); |
| 1100 | 1100 |
| 1101 return 0; | 1101 return GeometryInterfaces::createDOMPoint(); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width
, long height, Document* document, ExceptionState& exceptionState) | 1104 Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width
, long height, Document* document, ExceptionState& exceptionState) |
| 1105 { | 1105 { |
| 1106 ASSERT(document); | 1106 ASSERT(document); |
| 1107 if (!document->frame()) { | 1107 if (!document->frame()) { |
| 1108 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); | 1108 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
| 1109 return 0; | 1109 return 0; |
| 1110 } | 1110 } |
| 1111 | 1111 |
| 1112 document->updateLayout(); | 1112 document->updateLayout(); |
| 1113 | 1113 |
| 1114 IntSize radius(width / 2, height / 2); | 1114 IntSize radius(width / 2, height / 2); |
| 1115 IntPoint point(x + radius.width(), y + radius.height()); | 1115 IntPoint point(x + radius.width(), y + radius.height()); |
| 1116 | 1116 |
| 1117 EventHandler& eventHandler = document->frame()->eventHandler(); | 1117 EventHandler& eventHandler = document->frame()->eventHandler(); |
| 1118 IntPoint hitTestPoint = document->frame()->view()->rootFrameToContents(point
); | 1118 IntPoint hitTestPoint = document->frame()->view()->rootFrameToContents(point
); |
| 1119 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, Layout
Size(radius)); | 1119 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, Layout
Size(radius)); |
| 1120 | 1120 |
| 1121 Node* targetNode = 0; | 1121 Node* targetNode = 0; |
| 1122 IntPoint adjustedPoint; | 1122 IntPoint adjustedPoint; |
| 1123 document->frame()->eventHandler().bestClickableNodeForHitTestResult(result,
adjustedPoint, targetNode); | 1123 document->frame()->eventHandler().bestClickableNodeForHitTestResult(result,
adjustedPoint, targetNode); |
| 1124 return targetNode; | 1124 return targetNode; |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 DOMPoint* Internals::touchPositionAdjustedToBestContextMenuNode(long x, long y,
long width, long height, Document* document, ExceptionState& exceptionState) | 1127 ScriptValue Internals::touchPositionAdjustedToBestContextMenuNode(long x, long y
, long width, long height, Document* document, ExceptionState& exceptionState) |
| 1128 { | 1128 { |
| 1129 ASSERT(document); | 1129 ASSERT(document); |
| 1130 if (!document->frame()) { | 1130 if (!document->frame()) { |
| 1131 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); | 1131 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
| 1132 return 0; | 1132 return GeometryInterfaces::createDOMPoint(); |
| 1133 } | 1133 } |
| 1134 | 1134 |
| 1135 document->updateLayout(); | 1135 document->updateLayout(); |
| 1136 | 1136 |
| 1137 IntSize radius(width / 2, height / 2); | 1137 IntSize radius(width / 2, height / 2); |
| 1138 IntPoint point(x + radius.width(), y + radius.height()); | 1138 IntPoint point(x + radius.width(), y + radius.height()); |
| 1139 | 1139 |
| 1140 EventHandler& eventHandler = document->frame()->eventHandler(); | 1140 EventHandler& eventHandler = document->frame()->eventHandler(); |
| 1141 IntPoint hitTestPoint = document->frame()->view()->rootFrameToContents(point
); | 1141 IntPoint hitTestPoint = document->frame()->view()->rootFrameToContents(point
); |
| 1142 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, Layout
Size(radius)); | 1142 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, Layout
Size(radius)); |
| 1143 | 1143 |
| 1144 Node* targetNode = 0; | 1144 Node* targetNode = 0; |
| 1145 IntPoint adjustedPoint; | 1145 IntPoint adjustedPoint; |
| 1146 | 1146 |
| 1147 bool foundNode = eventHandler.bestContextMenuNodeForHitTestResult(result, ad
justedPoint, targetNode); | 1147 bool foundNode = eventHandler.bestContextMenuNodeForHitTestResult(result, ad
justedPoint, targetNode); |
| 1148 if (foundNode) | 1148 if (foundNode) |
| 1149 return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y()); | 1149 return GeometryInterfaces::createDOMPoint(adjustedPoint.x(), adjustedPoi
nt.y()); |
| 1150 | 1150 |
| 1151 return DOMPoint::create(x, y); | 1151 return GeometryInterfaces::createDOMPoint(x, y); |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long wid
th, long height, Document* document, ExceptionState& exceptionState) | 1154 Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long wid
th, long height, Document* document, ExceptionState& exceptionState) |
| 1155 { | 1155 { |
| 1156 ASSERT(document); | 1156 ASSERT(document); |
| 1157 if (!document->frame()) { | 1157 if (!document->frame()) { |
| 1158 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); | 1158 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
| 1159 return 0; | 1159 return 0; |
| 1160 } | 1160 } |
| 1161 | 1161 |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 } | 2560 } |
| 2561 | 2561 |
| 2562 int Internals::getScrollAnimationState(Node* node) const | 2562 int Internals::getScrollAnimationState(Node* node) const |
| 2563 { | 2563 { |
| 2564 if (ScrollableArea* scrollableArea = scrollableAreaForNode(node)) | 2564 if (ScrollableArea* scrollableArea = scrollableAreaForNode(node)) |
| 2565 return static_cast<int>(scrollableArea->scrollAnimator().m_runState); | 2565 return static_cast<int>(scrollableArea->scrollAnimator().m_runState); |
| 2566 return -1; | 2566 return -1; |
| 2567 } | 2567 } |
| 2568 | 2568 |
| 2569 } // namespace blink | 2569 } // namespace blink |
| OLD | NEW |