Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: third_party/WebKit/Source/core/dom/CharacterData.cpp

Issue 1822353002: Revert of wtf/CheckedArithmetic.h delegates to base/numerics/safe_math.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/ImageResource.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 13 matching lines...) Expand all
24 #include "bindings/core/v8/ExceptionState.h" 24 #include "bindings/core/v8/ExceptionState.h"
25 #include "core/dom/Document.h" 25 #include "core/dom/Document.h"
26 #include "core/dom/ExceptionCode.h" 26 #include "core/dom/ExceptionCode.h"
27 #include "core/dom/MutationObserverInterestGroup.h" 27 #include "core/dom/MutationObserverInterestGroup.h"
28 #include "core/dom/MutationRecord.h" 28 #include "core/dom/MutationRecord.h"
29 #include "core/dom/ProcessingInstruction.h" 29 #include "core/dom/ProcessingInstruction.h"
30 #include "core/dom/Text.h" 30 #include "core/dom/Text.h"
31 #include "core/editing/FrameSelection.h" 31 #include "core/editing/FrameSelection.h"
32 #include "core/events/MutationEvent.h" 32 #include "core/events/MutationEvent.h"
33 #include "core/inspector/InspectorInstrumentation.h" 33 #include "core/inspector/InspectorInstrumentation.h"
34 #include "wtf/CheckedNumeric.h" 34 #include "wtf/CheckedArithmetic.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 void CharacterData::atomize() 38 void CharacterData::atomize()
39 { 39 {
40 m_data = AtomicString(m_data); 40 m_data = AtomicString(m_data);
41 } 41 }
42 42
43 void CharacterData::setData(const String& data) 43 void CharacterData::setData(const String& data)
44 { 44 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 document().didInsertText(this, offset, data.length()); 95 document().didInsertText(this, offset, data.length());
96 } 96 }
97 97
98 static bool validateOffsetCount(unsigned offset, unsigned count, unsigned length , unsigned& realCount, ExceptionState& exceptionState) 98 static bool validateOffsetCount(unsigned offset, unsigned count, unsigned length , unsigned& realCount, ExceptionState& exceptionState)
99 { 99 {
100 if (offset > length) { 100 if (offset > length) {
101 exceptionState.throwDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ) + ")."); 101 exceptionState.throwDOMException(IndexSizeError, "The offset " + String: :number(offset) + " is greater than the node's length (" + String::number(length ) + ").");
102 return false; 102 return false;
103 } 103 }
104 104
105 CheckedNumeric<unsigned> offsetCount = offset; 105 Checked<unsigned, RecordOverflow> offsetCount = offset;
106 offsetCount += count; 106 offsetCount += count;
107 107
108 if (!offsetCount.IsValid() || offset + count > length) 108 if (offsetCount.hasOverflowed() || offset + count > length)
109 realCount = length - offset; 109 realCount = length - offset;
110 else 110 else
111 realCount = count; 111 realCount = count;
112 112
113 return true; 113 return true;
114 } 114 }
115 115
116 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState& exceptionState, RecalcStyleBehavior recalcStyleBehavior) 116 void CharacterData::deleteData(unsigned offset, unsigned count, ExceptionState& exceptionState, RecalcStyleBehavior recalcStyleBehavior)
117 { 117 {
118 unsigned realCount = 0; 118 unsigned realCount = 0;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 InspectorInstrumentation::characterDataModified(this); 201 InspectorInstrumentation::characterDataModified(this);
202 } 202 }
203 203
204 int CharacterData::maxCharacterOffset() const 204 int CharacterData::maxCharacterOffset() const
205 { 205 {
206 return static_cast<int>(length()); 206 return static_cast<int>(length());
207 } 207 }
208 208
209 } // namespace blink 209 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/ImageResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698