Title: [90911] trunk/Source
Revision
90911
Author
[email protected]
Date
2011-07-13 06:31:23 -0700 (Wed, 13 Jul 2011)

Log Message

Refactoring: Ignored ExceptionCode value should be less annoying.
https://bugs.webkit.org/show_bug.cgi?id=63688

Source/_javascript_Core:

Added ASSERT_AT macro.

Reviewed by Darin Adler.

* wtf/Assertions.h:

Source/WebCore:

- Introduced ExceptionCodePlaceholder class for the default parameter of ExceptionCode.
- Introduced ASSERT_NO_EXCEPTION to check ExceptionCode not set to non-zero after the call.
- Adopted ASSERT_NO_EXCEPTION in Range.cpp

No new tests. No behaviour change.

Reviewed by Darin Adler.

* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* dom/ExceptionCodePlaceholder.h: Added.
(WebCore::ExceptionCodePlaceholder::ExceptionCodePlaceholder):
(WebCore::ExceptionCodePlaceholder::operator ExceptionCode& ):
(WebCore::IgnorableExceptionCode::IgnorableExceptionCode):
(WebCore::CheckedExceptionCode::CheckedExceptionCode):
(WebCore::CheckedExceptionCode::~CheckedExceptionCode):
* dom/Range.cpp:
(WebCore::Range::Range):
(WebCore::Range::editingStartPosition):
* dom/Range.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (90910 => 90911)


--- trunk/Source/_javascript_Core/ChangeLog	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-07-13 13:31:23 UTC (rev 90911)
@@ -1,3 +1,14 @@
+2011-07-13  MORITA Hajime  <[email protected]>
+
+        Refactoring: Ignored ExceptionCode value should be less annoying.
+        https://bugs.webkit.org/show_bug.cgi?id=63688
+
+        Added ASSERT_AT macro.
+
+        Reviewed by Darin Adler.
+
+        * wtf/Assertions.h:
+
 2011-07-12  Filip Pizlo  <[email protected]>
 
         DFG JIT does not implement op_construct.

Modified: trunk/Source/_javascript_Core/wtf/Assertions.h (90910 => 90911)


--- trunk/Source/_javascript_Core/wtf/Assertions.h	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/_javascript_Core/wtf/Assertions.h	2011-07-13 13:31:23 UTC (rev 90911)
@@ -235,6 +235,7 @@
 #if ASSERT_DISABLED
 
 #define ASSERT(assertion) ((void)0)
+#define ASSERT_AT(assertion, file, line, function) ((void)0)
 #define ASSERT_NOT_REACHED() ((void)0)
 
 #if COMPILER(INTEL) && !OS(WINDOWS) || COMPILER(RVCT)
@@ -254,6 +255,13 @@
     } \
 while (0)
 
+#define ASSERT_AT(assertion, file, line, function) do  \
+    if (!(assertion)) { \
+        WTFReportAssertionFailure(file, line, function, #assertion); \
+        CRASH(); \
+    } \
+while (0)
+
 #define ASSERT_NOT_REACHED() do { \
     WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
     CRASH(); \

Modified: trunk/Source/WebCore/ChangeLog (90910 => 90911)


--- trunk/Source/WebCore/ChangeLog	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/WebCore/ChangeLog	2011-07-13 13:31:23 UTC (rev 90911)
@@ -1,3 +1,30 @@
+2011-07-13  MORITA Hajime  <[email protected]>
+
+        Refactoring: Ignored ExceptionCode value should be less annoying.
+        https://bugs.webkit.org/show_bug.cgi?id=63688
+
+        - Introduced ExceptionCodePlaceholder class for the default parameter of ExceptionCode.
+        - Introduced ASSERT_NO_EXCEPTION to check ExceptionCode not set to non-zero after the call.
+        - Adopted ASSERT_NO_EXCEPTION in Range.cpp
+
+        No new tests. No behaviour change.
+
+        Reviewed by Darin Adler.
+
+        * GNUmakefile.list.am:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/ExceptionCodePlaceholder.h: Added.
+        (WebCore::ExceptionCodePlaceholder::ExceptionCodePlaceholder):
+        (WebCore::ExceptionCodePlaceholder::operator ExceptionCode& ):
+        (WebCore::IgnorableExceptionCode::IgnorableExceptionCode):
+        (WebCore::CheckedExceptionCode::CheckedExceptionCode):
+        (WebCore::CheckedExceptionCode::~CheckedExceptionCode):
+        * dom/Range.cpp:
+        (WebCore::Range::Range):
+        (WebCore::Range::editingStartPosition):
+        * dom/Range.h:        
+
 2011-07-13  Nikolas Zimmermann  <[email protected]>
 
         Regression: OOB read in svg text run

Modified: trunk/Source/WebCore/GNUmakefile.list.am (90910 => 90911)


--- trunk/Source/WebCore/GNUmakefile.list.am	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2011-07-13 13:31:23 UTC (rev 90911)
@@ -1176,6 +1176,7 @@
 	Source/WebCore/dom/ExclusiveTrackList.h \
 	Source/WebCore/dom/FragmentScriptingPermission.h \
 	Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h \
+	Source/WebCore/dom/ExceptionCodePlaceholder.h \
 	Source/WebCore/dom/IconURL.cpp \
 	Source/WebCore/dom/IconURL.h \
 	Source/WebCore/dom/HashChangeEvent.h \

Modified: trunk/Source/WebCore/WebCore.gypi (90910 => 90911)


--- trunk/Source/WebCore/WebCore.gypi	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/WebCore/WebCore.gypi	2011-07-13 13:31:23 UTC (rev 90911)
@@ -538,6 +538,7 @@
             'dom/NamedNodeMap.h',
             'dom/Node.h',
             'dom/NodeList.h',
+            'dom/NeverThrown.h',
             'dom/PendingScript.h',
             'dom/Position.h',
             'dom/QualifiedName.h',
@@ -2507,6 +2508,7 @@
             'dom/ExclusiveTrackList.h',
             'dom/HashChangeEvent.h',
             'dom/IgnoreDestructiveWriteCountIncrementer.h',
+            'dom/ExceptionCodePlaceholder.h',
             'dom/IconURL.cpp',
             'dom/IconURL.h',
             'dom/KeyboardEvent.cpp',

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (90910 => 90911)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-07-13 13:31:23 UTC (rev 90911)
@@ -3285,6 +3285,7 @@
 		A71C30B91381265E00DBC351 /* ShadowContentSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = A71C30B71381265E00DBC351 /* ShadowContentSelector.h */; };
 		A73F95FE12C97BFE0031AAF9 /* RoundedRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73F95FC12C97BFE0031AAF9 /* RoundedRect.cpp */; };
 		A73F95FF12C97BFE0031AAF9 /* RoundedRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A73F95FD12C97BFE0031AAF9 /* RoundedRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A74BB76B13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h in Headers */ = {isa = PBXBuildFile; fileRef = A74BB76A13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A74C2D3C13811E0D00F83572 /* ShadowContentElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A74C2D3B13811E0D00F83572 /* ShadowContentElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A75E497610752ACB00C9B896 /* SerializedScriptValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A75E497410752ACB00C9B896 /* SerializedScriptValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A75E497710752ACB00C9B896 /* SerializedScriptValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */; };
@@ -9802,6 +9803,7 @@
 		A71C30B71381265E00DBC351 /* ShadowContentSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowContentSelector.h; sourceTree = "<group>"; };
 		A73F95FC12C97BFE0031AAF9 /* RoundedRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RoundedRect.cpp; sourceTree = "<group>"; };
 		A73F95FD12C97BFE0031AAF9 /* RoundedRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoundedRect.h; sourceTree = "<group>"; };
+		A74BB76A13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCodePlaceholder.h; sourceTree = "<group>"; };
 		A74C2D3B13811E0D00F83572 /* ShadowContentElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowContentElement.h; sourceTree = "<group>"; };
 		A75E497410752ACB00C9B896 /* SerializedScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedScriptValue.h; sourceTree = "<group>"; };
 		A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerializedScriptValue.cpp; sourceTree = "<group>"; };
@@ -19621,6 +19623,7 @@
 				BC60D8F10D2A11E000B9918F /* ExceptionBase.h */,
 				93831B560D087D6000E5C984 /* ExceptionCode.cpp */,
 				935FBCF109BA143B00E230B1 /* ExceptionCode.h */,
+				A74BB76A13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h */,
 				B12D233513560282002A28D4 /* ExclusiveTrackList.cpp */,
 				B12D233613560282002A28D4 /* ExclusiveTrackList.h */,
 				B12D233713560282002A28D4 /* ExclusiveTrackList.idl */,
@@ -21115,6 +21118,7 @@
 				E12EDB7B0B308A78002704B6 /* EventTarget.h in Headers */,
 				BC60D8F30D2A11E000B9918F /* ExceptionBase.h in Headers */,
 				935FBCF209BA143B00E230B1 /* ExceptionCode.h in Headers */,
+				A74BB76B13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h in Headers */,
 				148AFDA50AF58360008CC700 /* ExceptionHandlers.h in Headers */,
 				B12D233F13560282002A28D4 /* ExclusiveTrackList.h in Headers */,
 				6E67D2A91280E8BD008758F7 /* Extensions3D.h in Headers */,

Added: trunk/Source/WebCore/dom/ExceptionCodePlaceholder.h (0 => 90911)


--- trunk/Source/WebCore/dom/ExceptionCodePlaceholder.h	                        (rev 0)
+++ trunk/Source/WebCore/dom/ExceptionCodePlaceholder.h	2011-07-13 13:31:23 UTC (rev 90911)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ExceptionCodePlaceholder_h
+#define ExceptionCodePlaceholder_h
+
+#include <wtf/Assertions.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+typedef int ExceptionCode;
+
+class ExceptionCodePlaceholder {
+    WTF_MAKE_NONCOPYABLE(ExceptionCodePlaceholder);
+public:
+    ExceptionCodePlaceholder() { }
+    explicit ExceptionCodePlaceholder(ExceptionCode);
+
+    operator ExceptionCode& () const { return m_code; }
+
+protected:
+    mutable ExceptionCode m_code;
+};
+
+inline ExceptionCodePlaceholder::ExceptionCodePlaceholder(ExceptionCode code)
+    : m_code(code)
+{
+}
+
+class IgnorableExceptionCode : public ExceptionCodePlaceholder {
+};
+
+#if ASSERT_DISABLED
+
+#define ASSERT_NO_EXCEPTION ::WebCore::IgnorableExceptionCode()
+
+#else
+
+class NoExceptionAssertionChecker : public ExceptionCodePlaceholder {
+public:
+    NoExceptionAssertionChecker(const char* file, int line);
+    ~NoExceptionAssertionChecker();
+
+private:
+    const char* m_file;
+    int m_line;
+    const char* m_function;
+};
+
+inline NoExceptionAssertionChecker::NoExceptionAssertionChecker(const char* file, int line)
+    : ExceptionCodePlaceholder(0)
+    , m_file(file)
+    , m_line(line)
+{
+}
+
+inline NoExceptionAssertionChecker::~NoExceptionAssertionChecker()
+{
+    ASSERT_AT(!m_code, m_file, m_line, "");
+}
+
+#define ASSERT_NO_EXCEPTION ::WebCore::NoExceptionAssertionChecker(__FILE__, __LINE__)
+
+#endif
+
+}
+
+#endif

Modified: trunk/Source/WebCore/dom/Range.cpp (90910 => 90911)


--- trunk/Source/WebCore/dom/Range.cpp	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/WebCore/dom/Range.cpp	2011-07-13 13:31:23 UTC (rev 90911)
@@ -88,11 +88,8 @@
 
     // Simply setting the containers and offsets directly would not do any of the checking
     // that setStart and setEnd do, so we call those functions.
-    ExceptionCode ec = 0;
-    setStart(startContainer, startOffset, ec);
-    ASSERT(!ec);
-    setEnd(endContainer, endOffset, ec);
-    ASSERT(!ec);
+    setStart(startContainer, startOffset);
+    setEnd(endContainer, endOffset);
 }
 
 PassRefPtr<Range> Range::create(PassRefPtr<Document> ownerDocument, PassRefPtr<Node> startContainer, int startOffset, PassRefPtr<Node> endContainer, int endOffset)
@@ -1595,10 +1592,9 @@
     if (visiblePosition.isNull())
         return Position();
 
-    ExceptionCode ec = 0;
     // if the selection is a caret, just return the position, since the style
     // behind us is relevant
-    if (collapsed(ec))
+    if (collapsed())
         return visiblePosition.deepEquivalent();
 
     // if the selection starts just before a paragraph break, skip over it

Modified: trunk/Source/WebCore/dom/Range.h (90910 => 90911)


--- trunk/Source/WebCore/dom/Range.h	2011-07-13 13:02:54 UTC (rev 90910)
+++ trunk/Source/WebCore/dom/Range.h	2011-07-13 13:31:23 UTC (rev 90911)
@@ -25,6 +25,7 @@
 #ifndef Range_h
 #define Range_h
 
+#include "ExceptionCodePlaceholder.h"
 #include "FloatRect.h"
 #include "IntRect.h"
 #include "Node.h"
@@ -61,12 +62,12 @@
     int startOffset(ExceptionCode&) const;
     Node* endContainer(ExceptionCode&) const;
     int endOffset(ExceptionCode&) const;
-    bool collapsed(ExceptionCode&) const;
+    bool collapsed(ExceptionCode& = ASSERT_NO_EXCEPTION) const;
 
     Node* commonAncestorContainer(ExceptionCode&) const;
     static Node* commonAncestorContainer(Node* containerA, Node* containerB);
-    void setStart(PassRefPtr<Node> container, int offset, ExceptionCode&);
-    void setEnd(PassRefPtr<Node> container, int offset, ExceptionCode&);
+    void setStart(PassRefPtr<Node> container, int offset, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    void setEnd(PassRefPtr<Node> container, int offset, ExceptionCode& = ASSERT_NO_EXCEPTION);
     void collapse(bool toStart, ExceptionCode&);
     bool isPointInRange(Node* refNode, int offset, ExceptionCode&);
     short comparePoint(Node* refNode, int offset, ExceptionCode&) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to