Chromium Code Reviews| Index: Source/core/editing/DOMSelection.cpp |
| diff --git a/Source/core/editing/DOMSelection.cpp b/Source/core/editing/DOMSelection.cpp |
| index 0468dbc358f711e80df97db3fcc79745064fb840..175a1389c03ec99609f2e9a756bbdacf21944e7e 100644 |
| --- a/Source/core/editing/DOMSelection.cpp |
| +++ b/Source/core/editing/DOMSelection.cpp |
| @@ -107,7 +107,7 @@ Node* DOMSelection::anchorNode() const |
| return shadowAdjustedNode(anchorPosition(visibleSelection())); |
| } |
| -int DOMSelection::anchorOffset() const |
| +unsigned DOMSelection::anchorOffset() const |
| { |
| if (!m_frame) |
| return 0; |
| @@ -123,7 +123,7 @@ Node* DOMSelection::focusNode() const |
| return shadowAdjustedNode(focusPosition(visibleSelection())); |
| } |
| -int DOMSelection::focusOffset() const |
| +unsigned DOMSelection::focusOffset() const |
| { |
| if (!m_frame) |
| return 0; |
| @@ -139,7 +139,7 @@ Node* DOMSelection::baseNode() const |
| return shadowAdjustedNode(basePosition(visibleSelection())); |
| } |
| -int DOMSelection::baseOffset() const |
| +unsigned DOMSelection::baseOffset() const |
| { |
| if (!m_frame) |
| return 0; |
| @@ -155,7 +155,7 @@ Node* DOMSelection::extentNode() const |
| return shadowAdjustedNode(extentPosition(visibleSelection())); |
| } |
| -int DOMSelection::extentOffset() const |
| +unsigned DOMSelection::extentOffset() const |
| { |
| if (!m_frame) |
| return 0; |
| @@ -187,14 +187,14 @@ String DOMSelection::type() const |
| return "Range"; |
| } |
| -int DOMSelection::rangeCount() const |
| +unsigned DOMSelection::rangeCount() const |
| { |
| if (!m_frame) |
| return 0; |
| return m_frame->selection().isNone() ? 0 : 1; |
| } |
| -void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionState) |
| +void DOMSelection::collapse(Node* node, unsigned offset, ExceptionState& exceptionState) |
| { |
| if (!m_frame) |
| return; |
| @@ -204,8 +204,8 @@ void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta |
| return; |
| } |
| - if (offset < 0) { |
| - exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset."); |
| + if (static_cast<int>(offset) < 0) { |
|
philipj_slow
2015/08/10 13:46:40
This is really quite strange, and is strange in th
|
| + exceptionState.throwDOMException(IndexSizeError, String::number(static_cast<int>(offset)) + " is not a valid offset."); |
| return; |
| } |
| @@ -258,18 +258,18 @@ void DOMSelection::empty() |
| m_frame->selection().clear(); |
| } |
| -void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extentNode, int extentOffset, ExceptionState& exceptionState) |
| +void DOMSelection::setBaseAndExtent(Node* baseNode, unsigned baseOffset, Node* extentNode, unsigned extentOffset, ExceptionState& exceptionState) |
| { |
| if (!m_frame) |
| return; |
| - if (baseOffset < 0) { |
| - exceptionState.throwDOMException(IndexSizeError, String::number(baseOffset) + " is not a valid base offset."); |
| + if (static_cast<int>(baseOffset) < 0) { |
| + exceptionState.throwDOMException(IndexSizeError, String::number(static_cast<int>(baseOffset)) + " is not a valid base offset."); |
| return; |
| } |
| - if (extentOffset < 0) { |
| - exceptionState.throwDOMException(IndexSizeError, String::number(extentOffset) + " is not a valid extent offset."); |
| + if (static_cast<int>(extentOffset) < 0) { |
| + exceptionState.throwDOMException(IndexSizeError, String::number(static_cast<int>(extentOffset)) + " is not a valid extent offset."); |
| return; |
| } |
| @@ -332,19 +332,19 @@ void DOMSelection::modify(const String& alterString, const String& directionStri |
| m_frame->selection().modify(alter, direction, granularity); |
| } |
| -void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState) |
| +void DOMSelection::extend(Node* node, unsigned offset, ExceptionState& exceptionState) |
| { |
| ASSERT(node); |
| if (!m_frame) |
| return; |
| - if (offset < 0) { |
| - exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is not a valid offset."); |
| + if (static_cast<int>(offset) < 0) { |
| + exceptionState.throwDOMException(IndexSizeError, String::number(static_cast<int>(offset)) + " is not a valid offset."); |
| return; |
| } |
| - if (static_cast<unsigned>(offset) > node->lengthOfContents()) { |
| - exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length."); |
| + if (offset > node->lengthOfContents()) { |
| + exceptionState.throwDOMException(IndexSizeError, String::number(offset) + " is larger than the given node's length."); |
| return; |
| } |
| @@ -354,13 +354,13 @@ void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState |
| m_frame->selection().setExtent(VisiblePosition(Position(node, offset), DOWNSTREAM)); |
| } |
| -PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) |
| +PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(unsigned index, ExceptionState& exceptionState) |
| { |
| if (!m_frame) |
| return nullptr; |
| - if (index < 0 || index >= rangeCount()) { |
| - exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); |
| + if (static_cast<int>(index) < 0 || index >= rangeCount()) { |
| + exceptionState.throwDOMException(IndexSizeError, String::number(static_cast<int>(index)) + " is not a valid index."); |
| return nullptr; |
| } |
| @@ -525,7 +525,7 @@ Node* DOMSelection::shadowAdjustedNode(const Position& position) const |
| return adjustedNode->parentOrShadowHostNode(); |
| } |
| -int DOMSelection::shadowAdjustedOffset(const Position& position) const |
| +unsigned DOMSelection::shadowAdjustedOffset(const Position& position) const |
| { |
| if (position.isNull()) |
| return 0; |