| Index: third_party/WebKit/Source/core/dom/Range.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp
|
| index fcc24003565722162929fd31f9b2eda301c7b44c..18aa96d37ba9d4a46962121d71cdb17a153088ae 100644
|
| --- a/third_party/WebKit/Source/core/dom/Range.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Range.cpp
|
| @@ -68,9 +68,9 @@ Range* Range::create(Document& ownerDocument) {
|
|
|
| inline Range::Range(Document& ownerDocument,
|
| Node* startContainer,
|
| - int startOffset,
|
| + unsigned startOffset,
|
| Node* endContainer,
|
| - int endOffset)
|
| + unsigned endOffset)
|
| : m_ownerDocument(&ownerDocument),
|
| m_start(m_ownerDocument),
|
| m_end(m_ownerDocument) {
|
| @@ -84,9 +84,9 @@ inline Range::Range(Document& ownerDocument,
|
|
|
| Range* Range::create(Document& ownerDocument,
|
| Node* startContainer,
|
| - int startOffset,
|
| + unsigned startOffset,
|
| Node* endContainer,
|
| - int endOffset) {
|
| + unsigned endOffset) {
|
| return new Range(ownerDocument, startContainer, startOffset, endContainer,
|
| endOffset);
|
| }
|
| @@ -161,7 +161,7 @@ static inline bool checkForDifferentRootContainer(
|
| }
|
|
|
| void Range::setStart(Node* refNode,
|
| - int offset,
|
| + unsigned offset,
|
| ExceptionState& exceptionState) {
|
| if (!refNode) {
|
| // FIXME: Generated bindings code never calls with null, and neither should
|
| @@ -186,7 +186,9 @@ void Range::setStart(Node* refNode,
|
| collapse(true);
|
| }
|
|
|
| -void Range::setEnd(Node* refNode, int offset, ExceptionState& exceptionState) {
|
| +void Range::setEnd(Node* refNode,
|
| + unsigned offset,
|
| + ExceptionState& exceptionState) {
|
| if (!refNode) {
|
| // FIXME: Generated bindings code never calls with null, and neither should
|
| // other callers!
|
| @@ -255,7 +257,7 @@ bool Range::hasSameRoot(const Node& node) const {
|
| }
|
|
|
| bool Range::isPointInRange(Node* refNode,
|
| - int offset,
|
| + unsigned offset,
|
| ExceptionState& exceptionState) const {
|
| if (!refNode) {
|
| // FIXME: Generated bindings code never calls with null, and neither should
|
| @@ -279,7 +281,7 @@ bool Range::isPointInRange(Node* refNode,
|
| }
|
|
|
| short Range::comparePoint(Node* refNode,
|
| - int offset,
|
| + unsigned offset,
|
| ExceptionState& exceptionState) const {
|
| // http://developer.mozilla.org/en/docs/DOM:range.comparePoint
|
| // This method returns -1, 0 or 1 depending on if the point described by the
|
| @@ -366,9 +368,9 @@ short Range::compareBoundaryPoints(unsigned how,
|
| }
|
|
|
| short Range::compareBoundaryPoints(Node* containerA,
|
| - int offsetA,
|
| + unsigned offsetA,
|
| Node* containerB,
|
| - int offsetB,
|
| + unsigned offsetB,
|
| ExceptionState& exceptionState) {
|
| bool disconnected = false;
|
| short result = comparePositionsInDOMTree(containerA, offsetA, containerB,
|
| @@ -420,7 +422,7 @@ bool Range::intersectsNode(Node* refNode, ExceptionState& exceptionState) {
|
| if (!parentNode)
|
| return true;
|
|
|
| - int nodeIndex = refNode->nodeIndex();
|
| + unsigned nodeIndex = refNode->nodeIndex();
|
|
|
| if (comparePoint(parentNode, nodeIndex, exceptionState) <
|
| 0 // starts before start
|
| @@ -940,13 +942,12 @@ String Range::toString() const {
|
| Node::NodeType type = n->getNodeType();
|
| if (type == Node::kTextNode || type == Node::kCdataSectionNode) {
|
| String data = toCharacterData(n)->data();
|
| - int length = data.length();
|
| - int start = (n == m_start.container())
|
| - ? std::min(std::max(0, m_start.offset()), length)
|
| - : 0;
|
| - int end = (n == m_end.container())
|
| - ? std::min(std::max(start, m_end.offset()), length)
|
| - : length;
|
| + unsigned length = data.length();
|
| + unsigned start =
|
| + (n == m_start.container()) ? std::min(m_start.offset(), length) : 0;
|
| + unsigned end = (n == m_end.container())
|
| + ? std::min(std::max(start, m_end.offset()), length)
|
| + : length;
|
| builder.append(data, start, end - start);
|
| }
|
| }
|
| @@ -1008,7 +1009,7 @@ void Range::detach() {
|
| }
|
|
|
| Node* Range::checkNodeWOffset(Node* n,
|
| - int offset,
|
| + unsigned offset,
|
| ExceptionState& exceptionState) {
|
| switch (n->getNodeType()) {
|
| case Node::kDocumentTypeNode:
|
| @@ -1019,7 +1020,7 @@ Node* Range::checkNodeWOffset(Node* n,
|
| case Node::kCdataSectionNode:
|
| case Node::kCommentNode:
|
| case Node::kTextNode:
|
| - if (static_cast<unsigned>(offset) > toCharacterData(n)->length())
|
| + if (offset > toCharacterData(n)->length())
|
| exceptionState.throwDOMException(
|
| IndexSizeError,
|
| "The offset " + String::number(offset) +
|
| @@ -1027,8 +1028,7 @@ Node* Range::checkNodeWOffset(Node* n,
|
| String::number(toCharacterData(n)->length()) + ").");
|
| return nullptr;
|
| case Node::kProcessingInstructionNode:
|
| - if (static_cast<unsigned>(offset) >
|
| - toProcessingInstruction(n)->data().length())
|
| + if (offset > toProcessingInstruction(n)->data().length())
|
| exceptionState.throwDOMException(
|
| IndexSizeError,
|
| "The offset " + String::number(offset) +
|
| @@ -1547,7 +1547,7 @@ static inline void boundaryTextNodesMerged(RangeBoundaryPoint& boundary,
|
| boundary.set(oldNode.node().previousSibling(), boundary.offset() + offset,
|
| 0);
|
| else if (boundary.container() == oldNode.node().parentNode() &&
|
| - boundary.offset() == oldNode.index())
|
| + boundary.offset() == static_cast<unsigned>(oldNode.index()))
|
| boundary.set(oldNode.node().previousSibling(), offset, 0);
|
| }
|
|
|
|
|