Diff
Modified: trunk/Source/WebCore/ChangeLog (208658 => 208659)
--- trunk/Source/WebCore/ChangeLog 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/ChangeLog 2016-11-12 22:31:17 UTC (rev 208659)
@@ -1,3 +1,57 @@
+2016-11-12 Darin Adler <[email protected]>
+
+ Remove a few assorted uses of ExceptionCode
+ https://bugs.webkit.org/show_bug.cgi?id=164683
+
+ Reviewed by Chris Dumez.
+
+ * Modules/applepay/PaymentContact.h: Removed include of ExceptionCode.h.
+ Also tidied up the constructor and destructor.
+
+ * Modules/indexeddb/IDBFactory.h: Removed typedef of ExceptionCode.
+ * Modules/indexeddb/IDBKeyRange.h: Ditto.
+
+ * bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
+ (WebCore::getObjectParameter): Removed local ExceptionCode variable that
+ was always 0.
+ (WebCore::JSWebGLRenderingContextBase::getAttachedShaders): Ditto.
+ (WebCore::dataFunctionf): Ditto.
+ (WebCore::dataFunctioni): Ditto.
+ (WebCore::dataFunctionMatrix): Ditto.
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::cloneChildNodes): Ditto.
+
+ * dom/Document.h: Removed typedef of ExceptionCode.
+ * dom/TreeWalker.h: Ditto.
+ * editing/markup.h: Ditto.
+ * html/ImageData.h: Ditto.
+ * html/InputType.h: Ditto.
+ * html/canvas/CanvasRenderingContext2D.h: Ditto.
+ * html/canvas/WebGLDebugShaders.h: Ditto.
+
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::setTimeout): Fixed typo where this was using
+ ExceptionCode instead of Exception. The code would return an integer
+ instead of an exception in this case. I could not produce a test that
+ exercises this code path; I suspect it is an unreachable error condition.
+ (WebCore::DOMWindow::setInterval): Ditto.
+
+ * replay/MemoizedDOMResult.h: Changed typedef of ExceptionCode into
+ a using statement. Not sure what the longer term fix is.
+
+ * xml/parser/XMLDocumentParserLibxml2.cpp:
+ (WebCore::PendingCallbacks::appendStartElementNSCallback): Renamed to use
+ WebKit-style "numXXX" rather than "nb_xxx".
+ (WebCore::PendingCallbacks::PendingStartElementNSCallback::~PendingStartElementNSCallback):
+ Ditto.
+ (WebCore::handleNamespaceAttributes): Ditto. Replaced ExceptionCode out
+ argument with a boolean return value.
+ (WebCore::handleElementAttributes): Ditto.
+ (WebCore::XMLDocumentParser::startElementNs): Ditto. Updated for changes
+ to the handle functions above.
+ (WebCore::startElementNsHandler): More of the same.
+ (WebCore::attributesStartElementNsHandler): Ditto.
+
2016-11-11 Darin Adler <[email protected]>
Remove LegacyException support from bindings script
Modified: trunk/Source/WebCore/Modules/applepay/PaymentContact.h (208658 => 208659)
--- trunk/Source/WebCore/Modules/applepay/PaymentContact.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/Modules/applepay/PaymentContact.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -27,7 +27,6 @@
#if ENABLE(APPLE_PAY)
-#include <WebCore/ExceptionCode.h>
#include <wtf/Forward.h>
#include <wtf/RetainPtr.h>
@@ -43,19 +42,12 @@
class PaymentContact {
public:
- PaymentContact()
- {
- }
-
+ PaymentContact() = default;
explicit PaymentContact(PKContact *pkContact)
: m_pkContact(pkContact)
{
}
- ~PaymentContact()
- {
- }
-
static Optional<PaymentContact> fromJS(JSC::ExecState&, JSC::JSValue, String& errorMessage);
JSC::JSValue toJS(JSC::ExecState&) const;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h (208658 => 208659)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -49,8 +49,6 @@
class IDBConnectionProxy;
}
-typedef int ExceptionCode;
-
class IDBFactory : public ThreadSafeRefCounted<IDBFactory> {
public:
static Ref<IDBFactory> create(IDBClient::IDBConnectionProxy&);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h (208658 => 208659)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -42,8 +42,6 @@
class IDBKey;
class ScriptExecutionContext;
-typedef int ExceptionCode;
-
class IDBKeyRange : public ScriptWrappable, public RefCounted<IDBKeyRange> {
public:
static Ref<IDBKeyRange> create(RefPtr<IDBKey>&& lower, RefPtr<IDBKey>&& upper, bool isLowerOpen, bool isUpperOpen);
Modified: trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp (208658 => 208659)
--- trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp 2016-11-12 22:31:17 UTC (rev 208659)
@@ -196,7 +196,6 @@
if (state.argumentCount() != 2)
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- ExceptionCode ec = 0;
WebGLRenderingContextBase& context = obj->wrapped();
unsigned target = state.uncheckedArgument(0).toInt32(&state);
RETURN_IF_EXCEPTION(scope, JSValue());
@@ -221,10 +220,6 @@
notImplemented();
break;
}
- if (ec) {
- setDOMException(&state, ec);
- return jsUndefined();
- }
return toJS(&state, obj->globalObject(), info);
}
@@ -304,19 +299,13 @@
if (state.argumentCount() < 1)
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- ExceptionCode ec = 0;
- WebGLRenderingContextBase& context = wrapped();
- WebGLProgram* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0));
+ auto& context = wrapped();
+ auto* program = JSWebGLProgram::toWrapped(state.uncheckedArgument(0));
if (!program && !state.uncheckedArgument(0).isUndefinedOrNull())
return throwTypeError(&state, scope);
Vector<RefPtr<WebGLShader>> shaders;
- bool succeed = context.getAttachedShaders(program, shaders);
- if (ec) {
- setDOMException(&state, ec);
+ if (!context.getAttachedShaders(program, shaders))
return jsNull();
- }
- if (!succeed)
- return jsNull();
JSC::MarkedArgumentBuffer list;
for (size_t ii = 0; ii < shaders.size(); ++ii)
list.append(toJS(&state, globalObject(), shaders[ii].get()));
@@ -516,7 +505,6 @@
RefPtr<Float32Array> webGLArray = toUnsharedFloat32Array(state.uncheckedArgument(1));
RETURN_IF_EXCEPTION(scope, JSValue());
- ExceptionCode ec = 0;
if (webGLArray) {
switch (f) {
case f_uniform1v:
@@ -545,7 +533,6 @@
break;
}
- setDOMException(&state, ec);
return jsUndefined();
}
@@ -580,7 +567,6 @@
break;
}
- setDOMException(&state, ec);
return jsUndefined();
}
@@ -598,7 +584,6 @@
RefPtr<Int32Array> webGLArray = toUnsharedInt32Array(state.uncheckedArgument(1));
- ExceptionCode ec = 0;
if (webGLArray) {
switch (f) {
case f_uniform1v:
@@ -617,7 +602,6 @@
break;
}
- setDOMException(&state, ec);
return jsUndefined();
}
@@ -643,7 +627,6 @@
break;
}
- setDOMException(&state, ec);
return jsUndefined();
}
@@ -677,8 +660,6 @@
break;
}
- ExceptionCode ec = 0;
- setDOMException(&state, ec);
return jsUndefined();
}
@@ -698,8 +679,6 @@
break;
}
- ExceptionCode ec = 0;
- setDOMException(&state, ec);
return jsUndefined();
}
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (208658 => 208659)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2016-11-12 22:31:17 UTC (rev 208659)
@@ -717,10 +717,9 @@
void ContainerNode::cloneChildNodes(ContainerNode& clone)
{
- ExceptionCode ec = 0;
Document& targetDocument = clone.document();
- for (Node* child = firstChild(); child && !ec; child = child->nextSibling()) {
- Ref<Node> clonedChild = child->cloneNodeInternal(targetDocument, CloningOperation::SelfWithTemplateContent);
+ for (Node* child = firstChild(); child; child = child->nextSibling()) {
+ auto clonedChild = child->cloneNodeInternal(targetDocument, CloningOperation::SelfWithTemplateContent);
if (!clone.appendChild(clonedChild).hasException() && is<ContainerNode>(*child))
downcast<ContainerNode>(*child).cloneChildNodes(downcast<ContainerNode>(clonedChild.get()));
}
Modified: trunk/Source/WebCore/dom/Document.h (208658 => 208659)
--- trunk/Source/WebCore/dom/Document.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/dom/Document.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -197,8 +197,6 @@
class FontFaceSet;
-typedef int ExceptionCode;
-
#if PLATFORM(IOS)
class DeviceMotionClient;
class DeviceMotionController;
@@ -886,8 +884,7 @@
static bool isValidName(const String&);
// The following breaks a qualified name into a prefix and a local name.
- // It also does a validity check, and returns false if the qualified name
- // is invalid. It also sets ExceptionCode when name is invalid.
+ // It also does a validity check, and returns an error if the qualified name is invalid.
static ExceptionOr<std::pair<AtomicString, AtomicString>> parseQualifiedName(const String& qualifiedName);
static ExceptionOr<QualifiedName> parseQualifiedName(const AtomicString& namespaceURI, const String& qualifiedName);
Modified: trunk/Source/WebCore/dom/TreeWalker.h (208658 => 208659)
--- trunk/Source/WebCore/dom/TreeWalker.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/dom/TreeWalker.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -31,8 +31,6 @@
namespace WebCore {
- typedef int ExceptionCode;
-
class TreeWalker : public ScriptWrappable, public RefCounted<TreeWalker>, public NodeIteratorBase {
public:
static Ref<TreeWalker> create(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
Modified: trunk/Source/WebCore/editing/markup.h (208658 => 208659)
--- trunk/Source/WebCore/editing/markup.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/editing/markup.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -43,8 +43,6 @@
class QualifiedName;
class Range;
-typedef int ExceptionCode;
-
enum EChildrenOnly { IncludeNode, ChildrenOnly };
enum EAbsoluteURLs { DoNotResolveURLs, ResolveAllURLs, ResolveNonLocalURLs };
enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerialization };
Modified: trunk/Source/WebCore/html/ImageData.h (208658 => 208659)
--- trunk/Source/WebCore/html/ImageData.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/html/ImageData.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -34,8 +34,6 @@
namespace WebCore {
-typedef int ExceptionCode;
-
class ImageData : public RefCounted<ImageData> {
public:
static ExceptionOr<Ref<ImageData>> create(unsigned sw, unsigned sh);
Modified: trunk/Source/WebCore/html/InputType.h (208658 => 208659)
--- trunk/Source/WebCore/html/InputType.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/html/InputType.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -65,8 +65,6 @@
struct InputElementClickState;
-typedef int ExceptionCode;
-
// An InputType object represents the type-specific part of an HTMLInputElement.
// Do not expose instances of InputType and classes derived from it to classes
// other than HTMLInputElement.
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (208658 => 208659)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -55,8 +55,6 @@
class ImageData;
class TextMetrics;
-typedef int ExceptionCode;
-
class CanvasRenderingContext2D final : public CanvasRenderingContext, public CanvasPath {
public:
CanvasRenderingContext2D(HTMLCanvasElement&, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
Modified: trunk/Source/WebCore/html/canvas/WebGLDebugShaders.h (208658 => 208659)
--- trunk/Source/WebCore/html/canvas/WebGLDebugShaders.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/html/canvas/WebGLDebugShaders.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -31,8 +31,6 @@
class WebGLShader;
-typedef int ExceptionCode;
-
class WebGLDebugShaders final : public WebGLExtension {
public:
explicit WebGLDebugShaders(WebGLRenderingContextBase*);
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (208658 => 208659)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2016-11-12 22:31:17 UTC (rev 208659)
@@ -1616,7 +1616,7 @@
{
auto* context = scriptExecutionContext();
if (!context)
- return ExceptionCode { INVALID_ACCESS_ERR };
+ return Exception { INVALID_ACCESS_ERR };
return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), true);
}
@@ -1648,7 +1648,7 @@
{
auto* context = scriptExecutionContext();
if (!context)
- return ExceptionCode { INVALID_ACCESS_ERR };
+ return Exception { INVALID_ACCESS_ERR };
return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), false);
}
Modified: trunk/Source/WebCore/replay/MemoizedDOMResult.h (208658 => 208659)
--- trunk/Source/WebCore/replay/MemoizedDOMResult.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/replay/MemoizedDOMResult.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -37,7 +37,7 @@
class SerializedScriptValue;
-typedef int ExceptionCode;
+using ExceptionCode = int;
// Add new memoized ctypes here. The first argument is the enum value,
// which cannot conflict with built-in primitive types. The second is
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (208658 => 208659)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-11-12 22:31:17 UTC (rev 208659)
@@ -98,11 +98,9 @@
class PendingCallbacks {
WTF_MAKE_NONCOPYABLE(PendingCallbacks); WTF_MAKE_FAST_ALLOCATED;
public:
- PendingCallbacks() { }
- ~PendingCallbacks() { }
+ PendingCallbacks() = default;
- void appendStartElementNSCallback(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
- const xmlChar** namespaces, int nb_attributes, int nb_defaulted, const xmlChar** attributes)
+ void appendStartElementNSCallback(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int numNamespaces, const xmlChar** namespaces, int numAttributes, int numDefaulted, const xmlChar** attributes)
{
auto callback = std::make_unique<PendingStartElementNSCallback>();
@@ -109,14 +107,14 @@
callback->xmlLocalName = xmlStrdup(xmlLocalName);
callback->xmlPrefix = xmlStrdup(xmlPrefix);
callback->xmlURI = xmlStrdup(xmlURI);
- callback->nb_namespaces = nb_namespaces;
- callback->namespaces = static_cast<xmlChar**>(xmlMalloc(sizeof(xmlChar*) * nb_namespaces * 2));
- for (int i = 0; i < nb_namespaces * 2 ; i++)
+ callback->numNamespaces = numNamespaces;
+ callback->namespaces = static_cast<xmlChar**>(xmlMalloc(sizeof(xmlChar*) * numNamespaces * 2));
+ for (int i = 0; i < numNamespaces * 2 ; i++)
callback->namespaces[i] = xmlStrdup(namespaces[i]);
- callback->nb_attributes = nb_attributes;
- callback->nb_defaulted = nb_defaulted;
- callback->attributes = static_cast<xmlChar**>(xmlMalloc(sizeof(xmlChar*) * nb_attributes * 5));
- for (int i = 0; i < nb_attributes; i++) {
+ callback->numAttributes = numAttributes;
+ callback->numDefaulted = numDefaulted;
+ callback->attributes = static_cast<xmlChar**>(xmlMalloc(sizeof(xmlChar*) * numAttributes * 5));
+ for (int i = 0; i < numAttributes; i++) {
// Each attribute has 5 elements in the array:
// name, prefix, uri, value and an end pointer.
@@ -219,29 +217,28 @@
xmlFree(xmlLocalName);
xmlFree(xmlPrefix);
xmlFree(xmlURI);
- for (int i = 0; i < nb_namespaces * 2; i++)
+ for (int i = 0; i < numNamespaces * 2; i++)
xmlFree(namespaces[i]);
xmlFree(namespaces);
- for (int i = 0; i < nb_attributes; i++)
+ for (int i = 0; i < numAttributes; i++) {
for (int j = 0; j < 4; j++)
xmlFree(attributes[i * 5 + j]);
+ }
xmlFree(attributes);
}
void call(XMLDocumentParser* parser) override
{
- parser->startElementNs(xmlLocalName, xmlPrefix, xmlURI,
- nb_namespaces, const_cast<const xmlChar**>(namespaces),
- nb_attributes, nb_defaulted, const_cast<const xmlChar**>(attributes));
+ parser->startElementNs(xmlLocalName, xmlPrefix, xmlURI, numNamespaces, const_cast<const xmlChar**>(namespaces), numAttributes, numDefaulted, const_cast<const xmlChar**>(attributes));
}
xmlChar* xmlLocalName;
xmlChar* xmlPrefix;
xmlChar* xmlURI;
- int nb_namespaces;
+ int numNamespaces;
xmlChar** namespaces;
- int nb_attributes;
- int nb_defaulted;
+ int numAttributes;
+ int numDefaulted;
xmlChar** attributes;
};
@@ -729,10 +726,10 @@
};
typedef struct _xmlSAX2Namespace xmlSAX2Namespace;
-static inline void handleNamespaceAttributes(Vector<Attribute>& prefixedAttributes, const xmlChar** libxmlNamespaces, int nb_namespaces, ExceptionCode& ec)
+static inline bool handleNamespaceAttributes(Vector<Attribute>& prefixedAttributes, const xmlChar** libxmlNamespaces, int numNamespaces)
{
xmlSAX2Namespace* namespaces = reinterpret_cast<xmlSAX2Namespace*>(libxmlNamespaces);
- for (int i = 0; i < nb_namespaces; i++) {
+ for (int i = 0; i < numNamespaces; i++) {
AtomicString namespaceQName = xmlnsAtom;
AtomicString namespaceURI = toAtomicString(namespaces[i].uri);
if (namespaces[i].prefix)
@@ -739,13 +736,12 @@
namespaceQName = "xmlns:" + toString(namespaces[i].prefix);
auto result = Element::parseAttributeName(XMLNSNames::xmlnsNamespaceURI, namespaceQName);
- if (result.hasException()) {
- ec = result.releaseException().code();
- return;
- }
+ if (result.hasException())
+ return false;
prefixedAttributes.append(Attribute(result.releaseReturnValue(), namespaceURI));
}
+ return true;
}
struct _xmlSAX2Attributes {
@@ -757,10 +753,10 @@
};
typedef struct _xmlSAX2Attributes xmlSAX2Attributes;
-static inline void handleElementAttributes(Vector<Attribute>& prefixedAttributes, const xmlChar** libxmlAttributes, int nb_attributes, ExceptionCode& ec)
+static inline bool handleElementAttributes(Vector<Attribute>& prefixedAttributes, const xmlChar** libxmlAttributes, int numAttributes)
{
xmlSAX2Attributes* attributes = reinterpret_cast<xmlSAX2Attributes*>(libxmlAttributes);
- for (int i = 0; i < nb_attributes; i++) {
+ for (int i = 0; i < numAttributes; i++) {
int valueLength = static_cast<int>(attributes[i].end - attributes[i].value);
AtomicString attrValue = toAtomicString(attributes[i].value, valueLength);
String attrPrefix = toString(attributes[i].prefix);
@@ -768,13 +764,12 @@
AtomicString attrQName = attrPrefix.isEmpty() ? toAtomicString(attributes[i].localname) : attrPrefix + ":" + toString(attributes[i].localname);
auto result = Element::parseAttributeName(attrURI, attrQName);
- if (result.hasException()) {
- ec = result.releaseException().code();
- return;
- }
+ if (result.hasException())
+ return false;
prefixedAttributes.append(Attribute(result.releaseReturnValue(), attrValue));
}
+ return true;
}
// This is a hack around https://bugzilla.gnome.org/show_bug.cgi?id=502960
@@ -790,15 +785,13 @@
#endif
}
-void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
- const xmlChar** libxmlNamespaces, int nb_attributes, int nb_defaulted, const xmlChar** libxmlAttributes)
+void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xmlPrefix, const xmlChar* xmlURI, int numNamespaces, const xmlChar** libxmlNamespaces, int numAttributes, int numDefaulted, const xmlChar** libxmlAttributes)
{
if (isStopped())
return;
if (m_parserPaused) {
- m_pendingCallbacks->appendStartElementNSCallback(xmlLocalName, xmlPrefix, xmlURI, nb_namespaces, libxmlNamespaces,
- nb_attributes, nb_defaulted, libxmlAttributes);
+ m_pendingCallbacks->appendStartElementNSCallback(xmlLocalName, xmlPrefix, xmlURI, numNamespaces, libxmlNamespaces, numAttributes, numDefaulted, libxmlAttributes);
return;
}
@@ -828,17 +821,15 @@
auto newElement = m_currentNode->document().createElement(qName, true);
Vector<Attribute> prefixedAttributes;
- ExceptionCode ec = 0;
- handleNamespaceAttributes(prefixedAttributes, libxmlNamespaces, nb_namespaces, ec);
- if (ec) {
+ if (!handleNamespaceAttributes(prefixedAttributes, libxmlNamespaces, numNamespaces)) {
setAttributes(newElement.ptr(), prefixedAttributes, parserContentPolicy());
stopParsing();
return;
}
- handleElementAttributes(prefixedAttributes, libxmlAttributes, nb_attributes, ec);
+ bool success = handleElementAttributes(prefixedAttributes, libxmlAttributes, numAttributes);
setAttributes(newElement.ptr(), prefixedAttributes, parserContentPolicy());
- if (ec) {
+ if (!success) {
stopParsing();
return;
}
@@ -1106,9 +1097,8 @@
static inline bool hackAroundLibXMLEntityBug(void* closure)
{
#if LIBXML_VERSION >= 20627
+ // This bug has been fixed in libxml 2.6.27.
UNUSED_PARAM(closure);
-
- // This bug has been fixed in libxml 2.6.27.
return false;
#else
return static_cast<xmlParserCtxtPtr>(closure)->node;
@@ -1115,12 +1105,12 @@
#endif
}
-static void startElementNsHandler(void* closure, const xmlChar* localname, const xmlChar* prefix, const xmlChar* uri, int nb_namespaces, const xmlChar** namespaces, int nb_attributes, int nb_defaulted, const xmlChar** libxmlAttributes)
+static void startElementNsHandler(void* closure, const xmlChar* localname, const xmlChar* prefix, const xmlChar* uri, int numNamespaces, const xmlChar** namespaces, int numAttributes, int numDefaulted, const xmlChar** libxmlAttributes)
{
if (hackAroundLibXMLEntityBug(closure))
return;
- getParser(closure)->startElementNs(localname, prefix, uri, nb_namespaces, namespaces, nb_attributes, nb_defaulted, libxmlAttributes);
+ getParser(closure)->startElementNs(localname, prefix, uri, numNamespaces, namespaces, numAttributes, numDefaulted, libxmlAttributes);
}
static void endElementNsHandler(void* closure, const xmlChar*, const xmlChar*, const xmlChar*)
@@ -1517,9 +1507,7 @@
bool gotAttributes;
};
-static void attributesStartElementNsHandler(void* closure, const xmlChar* xmlLocalName, const xmlChar* /*xmlPrefix*/,
- const xmlChar* /*xmlURI*/, int /*nb_namespaces*/, const xmlChar** /*namespaces*/,
- int nb_attributes, int /*nb_defaulted*/, const xmlChar** libxmlAttributes)
+static void attributesStartElementNsHandler(void* closure, const xmlChar* xmlLocalName, const xmlChar* /*xmlPrefix*/, const xmlChar* /*xmlURI*/, int /*numNamespaces*/, const xmlChar** /*namespaces*/, int numAttributes, int /*numDefaulted*/, const xmlChar** libxmlAttributes)
{
if (strcmp(reinterpret_cast<const char*>(xmlLocalName), "attrs") != 0)
return;
@@ -1530,7 +1518,7 @@
state->gotAttributes = true;
xmlSAX2Attributes* attributes = reinterpret_cast<xmlSAX2Attributes*>(libxmlAttributes);
- for (int i = 0; i < nb_attributes; i++) {
+ for (int i = 0; i < numAttributes; i++) {
String attrLocalName = toString(attributes[i].localname);
int valueLength = (int) (attributes[i].end - attributes[i].value);
String attrValue = toString(attributes[i].value, valueLength);
Modified: trunk/Source/WebKit/mac/ChangeLog (208658 => 208659)
--- trunk/Source/WebKit/mac/ChangeLog 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-11-12 22:31:17 UTC (rev 208659)
@@ -1,3 +1,37 @@
+2016-11-12 Darin Adler <[email protected]>
+
+ Remove a few assorted uses of ExceptionCode
+ https://bugs.webkit.org/show_bug.cgi?id=164683
+
+ Reviewed by Chris Dumez.
+
+ * DOM/DOMDOMImplementation.mm:
+ (-[DOMImplementation createDocumentType:publicId:systemId:]):
+ Use raiseOnDOMError instead of much longer hand written equivalent.
+ (-[DOMImplementation createDocument:qualifiedName:doctype:]): Ditto.
+
+ * DOM/DOMDocument.mm:
+ (-[DOMDocument createEntityReference:]): Use raiseNotSupportedErrorException
+ so we are not using a specific exception code.
+
+ * DOM/DOMHTMLOptionsCollection.mm:
+ (-[DOMHTMLOptionsCollection add:index:]): Use raiseOnDOMError instead of
+ much longer hand written equivalent.
+ * DOM/DOMHTMLSelectElement.mm:
+ (-[DOMHTMLSelectElement add:before:]): Ditto. Also removed unneeded return
+ statement after calling a "no return" function.
+
+ * DOM/ExceptionHandlers.h: Removed overloads of raiseDOMException and
+ raiseOnDOMError functions that take ExceptionCode; keep the ones that take
+ Exception and ExceptionOr. Renamed the other overload of raiseDOMException
+ to raiseDOMErrorException; it is only used as the non-inline implementation
+ part of the inline raiseOnDOMError function.
+ * DOM/ExceptionHandlers.mm:
+ (raiseDOMErrorException): Renamed. Made the ExceptionCode overload be local
+ to this source file instead of in the header.
+ (raiseTypeErrorException): Updated for name change.
+ (raiseNotSupportedErrorException): Added.
+
2016-11-11 Ryosuke Niwa <[email protected]>
Hovering over a slotted Text node clears hover state
Modified: trunk/Source/WebKit/mac/DOM/DOMDOMImplementation.mm (208658 => 208659)
--- trunk/Source/WebKit/mac/DOM/DOMDOMImplementation.mm 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebKit/mac/DOM/DOMDOMImplementation.mm 2016-11-12 22:31:17 UTC (rev 208659)
@@ -65,23 +65,13 @@
- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName publicId:(NSString *)publicId systemId:(NSString *)systemId
{
WebCore::JSMainThreadNullState state;
- auto result = unwrap(*self).createDocumentType(qualifiedName, publicId, systemId);
- if (result.hasException()) {
- raiseDOMException(result.releaseException().code());
- return nil;
- }
- return kit(result.releaseReturnValue().ptr());
+ return kit(raiseOnDOMError(unwrap(*self).createDocumentType(qualifiedName, publicId, systemId)).ptr());
}
- (DOMDocument *)createDocument:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName doctype:(DOMDocumentType *)doctype
{
WebCore::JSMainThreadNullState state;
- auto result = unwrap(*self).createDocument(namespaceURI, qualifiedName, core(doctype));
- if (result.hasException()) {
- raiseDOMException(result.releaseException().code());
- return nil;
- }
- return kit(result.releaseReturnValue().ptr());
+ return kit(raiseOnDOMError(unwrap(*self).createDocument(namespaceURI, qualifiedName, core(doctype))).ptr());
}
- (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title media:(NSString *)media
Modified: trunk/Source/WebKit/mac/DOM/DOMDocument.mm (208658 => 208659)
--- trunk/Source/WebKit/mac/DOM/DOMDocument.mm 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebKit/mac/DOM/DOMDocument.mm 2016-11-12 22:31:17 UTC (rev 208659)
@@ -487,7 +487,7 @@
- (DOMEntityReference *)createEntityReference:(NSString *)name
{
UNUSED_PARAM(name);
- raiseDOMException(WebCore::NOT_SUPPORTED_ERR);
+ raiseNotSupportedErrorException();
}
- (DOMNodeList *)getElementsByTagName:(NSString *)tagname
Modified: trunk/Source/WebKit/mac/DOM/DOMHTMLOptionsCollection.mm (208658 => 208659)
--- trunk/Source/WebKit/mac/DOM/DOMHTMLOptionsCollection.mm 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebKit/mac/DOM/DOMHTMLOptionsCollection.mm 2016-11-12 22:31:17 UTC (rev 208659)
@@ -90,9 +90,7 @@
WebCore::JSMainThreadNullState state;
if (!option)
raiseTypeErrorException();
- auto exception = IMPL->add(core(option), Optional<WebCore::HTMLOptionsCollection::HTMLElementOrInt>(static_cast<int>(index)));
- if (exception.hasException())
- raiseOnDOMError(exception.releaseException().code());
+ raiseOnDOMError(IMPL->add(core(option), Optional<WebCore::HTMLOptionsCollection::HTMLElementOrInt> { static_cast<int>(index) }));
}
- (void)remove:(unsigned)index
Modified: trunk/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm (208658 => 208659)
--- trunk/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm 2016-11-12 22:31:17 UTC (rev 208659)
@@ -190,13 +190,9 @@
variantElement = &downcast<WebCore::HTMLOptionElement>(coreElement);
else if (is<WebCore::HTMLOptGroupElement>(coreElement))
variantElement = &downcast<WebCore::HTMLOptGroupElement>(coreElement);
- else {
+ else
raiseTypeErrorException();
- return;
- }
- auto exception = IMPL->add(WTFMove(variantElement), WebCore::HTMLSelectElement::HTMLElementOrInt(core(before)));
- if (exception.hasException())
- raiseOnDOMError(exception.releaseException().code());
+ raiseOnDOMError(IMPL->add(WTFMove(variantElement), WebCore::HTMLSelectElement::HTMLElementOrInt(core(before))));
}
- (void)remove:(int)index
Modified: trunk/Source/WebKit/mac/DOM/ExceptionHandlers.h (208658 => 208659)
--- trunk/Source/WebKit/mac/DOM/ExceptionHandlers.h 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebKit/mac/DOM/ExceptionHandlers.h 2016-11-12 22:31:17 UTC (rev 208659)
@@ -27,29 +27,22 @@
#include <WebCore/ExceptionOr.h>
-NO_RETURN void raiseDOMException(WebCore::ExceptionCode);
-NO_RETURN void raiseDOMException(WebCore::Exception&&);
NO_RETURN void raiseTypeErrorException();
+NO_RETURN void raiseNotSupportedErrorException();
-void raiseOnDOMError(WebCore::ExceptionCode);
+NO_RETURN void raiseDOMErrorException(WebCore::Exception&&);
+template<typename T> T raiseOnDOMError(WebCore::ExceptionOr<T>&&);
void raiseOnDOMError(WebCore::ExceptionOr<void>&&);
-template<typename T> T raiseOnDOMError(WebCore::ExceptionOr<T>&&);
-inline void raiseOnDOMError(WebCore::ExceptionCode code)
-{
- if (code)
- raiseDOMException(code);
-}
-
inline void raiseOnDOMError(WebCore::ExceptionOr<void>&& possibleException)
{
if (possibleException.hasException())
- raiseDOMException(possibleException.releaseException());
+ raiseDOMErrorException(possibleException.releaseException());
}
template<typename T> inline T raiseOnDOMError(WebCore::ExceptionOr<T>&& exceptionOrReturnValue)
{
if (exceptionOrReturnValue.hasException())
- raiseDOMException(exceptionOrReturnValue.releaseException());
+ raiseDOMErrorException(exceptionOrReturnValue.releaseException());
return exceptionOrReturnValue.releaseReturnValue();
}
Modified: trunk/Source/WebKit/mac/DOM/ExceptionHandlers.mm (208658 => 208659)
--- trunk/Source/WebKit/mac/DOM/ExceptionHandlers.mm 2016-11-12 22:30:22 UTC (rev 208658)
+++ trunk/Source/WebKit/mac/DOM/ExceptionHandlers.mm 2016-11-12 22:31:17 UTC (rev 208659)
@@ -37,7 +37,7 @@
NSString * const DOMEventException = @"DOMEventException";
NSString * const DOMXPathException = @"DOMXPathException";
-void raiseDOMException(WebCore::ExceptionCode ec)
+static NO_RETURN void raiseDOMErrorException(WebCore::ExceptionCode ec)
{
ASSERT(ec);
@@ -74,10 +74,15 @@
void raiseTypeErrorException()
{
- raiseDOMException(WebCore::TypeError);
+ raiseDOMErrorException(WebCore::TypeError);
}
-void raiseDOMException(WebCore::Exception&& exception)
+void raiseNotSupportedErrorException()
{
- raiseDOMException(exception.code());
+ raiseDOMErrorException(WebCore::NOT_SUPPORTED_ERR);
}
+
+void raiseDOMErrorException(WebCore::Exception&& exception)
+{
+ raiseDOMErrorException(exception.code());
+}