Commit 4d257487 authored by mkwst@chromium.org's avatar mkwst@chromium.org

Replace ExceptionCode assertions with ASSERT_NO_EXCEPTION macro.

https://bugs.webkit.org/show_bug.cgi?id=109044

Reviewed by Darin Adler.

The pattern:

    ExceptionCode ec = 0;
    methodThatGeneratesException(ec);
    ASSERT(!ec);

is more clearly and succinctly written as:

    methodThatGeneratesException(ASSERT_NO_EXCEPTION);

This patch replaces the occurances of the former that never touch 'ec'
again with the latter. It does the same for 'ASSERT(ec == 0);' (and, as
a drive-by, replaces 'ASSERT(ec == 0)' with 'ASSERT(!ec)' in places
where it does indeed matter that 'ec' get set properly.

No change in behavior should result from this refactoring.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::takeAllChildrenFrom):
* dom/Document.cpp:
(WebCore::Document::setTitle):
* dom/MessagePort.cpp:
(WebCore::MessagePort::dispatchMessages):
(WebCore::MessagePort::disentanglePorts):
* editing/DeleteButtonController.cpp:
(WebCore::enclosingDeletableElement):
(WebCore::DeleteButtonController::createDeletionUI):
    Replaced inline ASSERT with ASSERT_NO_EXCEPTION.
(WebCore::DeleteButtonController::show):
    Replaced 'ASSERT(ec == 0)' with 'ASSERT(!ec)' to match the style guide.
* editing/EditorCommand.cpp:
(WebCore::unionDOMRanges):
* editing/ReplaceNodeWithSpanCommand.cpp:
(WebCore::swapInNodePreservingAttributesAndChildren):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplacementFragment::ReplacementFragment):
(WebCore::ReplacementFragment::removeNode):
(WebCore::ReplacementFragment::insertNodeBefore):
(WebCore::ReplacementFragment::insertFragmentForTestRendering):
(WebCore::ReplacementFragment::restoreAndRemoveTestRenderingNodesToFragment):
(WebCore::ReplaceSelectionCommand::insertAsListItems):
* editing/SplitTextNodeCommand.cpp:
(WebCore::SplitTextNodeCommand::doUnapply):
* editing/TextIterator.cpp:
(WebCore::CharacterIterator::range):
(WebCore::BackwardsCharacterIterator::range):
(WebCore::TextIterator::rangeFromLocationAndLength):
(WebCore::collapsedToBoundary):
* editing/htmlediting.cpp:
(WebCore::createTabSpanElement):
* editing/mac/EditorMac.mm:
(WebCore::Editor::fontForSelection):
(WebCore::Editor::fontAttributesForSelectionStart):
* editing/markup.cpp:
(WebCore::createMarkup):
(WebCore::trimFragment):
(WebCore::createFragmentFromMarkupWithContext):
(WebCore::fillContainerFromString):
(WebCore::createFragmentFromText):
(WebCore::createFragmentFromNodes):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::createShadowSubtree):
    Replaced inline ASSERT with ASSERT_NO_EXCEPTION.
* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::add):
    Replaced 'ASSERT(ec == 0)' with 'ASSERT(!ec)' to match the style guide.
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::updatePlaceholderText):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForVisiblePosition):
(WebCore::HTMLTextFormControlElement::setInnerTextValue):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::updatePlaceholderText):
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::buildBubbleTree):
* html/shadow/MediaControlElementTypes.cpp:
(WebCore::MediaControlVolumeSliderElement::defaultEventHandler):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::getCookies):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule):
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::dispatchDOMEvent):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::deleteFromDocument):
* page/DragController.cpp:
(WebCore::prepareClipboardForImageDrag):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::visiblePositionForIndex):
    Replaced inline ASSERT with ASSERT_NO_EXCEPTION.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142247 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 204eb2b8
2013-02-08 Mike West <mkwst@chromium.org>
Replace ExceptionCode assertions with ASSERT_NO_EXCEPTION macro.
https://bugs.webkit.org/show_bug.cgi?id=109044
Reviewed by Darin Adler.
The pattern:
ExceptionCode ec = 0;
methodThatGeneratesException(ec);
ASSERT(!ec);
is more clearly and succinctly written as:
methodThatGeneratesException(ASSERT_NO_EXCEPTION);
This patch replaces the occurances of the former that never touch 'ec'
again with the latter. It does the same for 'ASSERT(ec == 0);' (and, as
a drive-by, replaces 'ASSERT(ec == 0)' with 'ASSERT(!ec)' in places
where it does indeed matter that 'ec' get set properly.
No change in behavior should result from this refactoring.
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::takeAllChildrenFrom):
* dom/Document.cpp:
(WebCore::Document::setTitle):
* dom/MessagePort.cpp:
(WebCore::MessagePort::dispatchMessages):
(WebCore::MessagePort::disentanglePorts):
* editing/DeleteButtonController.cpp:
(WebCore::enclosingDeletableElement):
(WebCore::DeleteButtonController::createDeletionUI):
Replaced inline ASSERT with ASSERT_NO_EXCEPTION.
(WebCore::DeleteButtonController::show):
Replaced 'ASSERT(ec == 0)' with 'ASSERT(!ec)' to match the style guide.
* editing/EditorCommand.cpp:
(WebCore::unionDOMRanges):
* editing/ReplaceNodeWithSpanCommand.cpp:
(WebCore::swapInNodePreservingAttributesAndChildren):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplacementFragment::ReplacementFragment):
(WebCore::ReplacementFragment::removeNode):
(WebCore::ReplacementFragment::insertNodeBefore):
(WebCore::ReplacementFragment::insertFragmentForTestRendering):
(WebCore::ReplacementFragment::restoreAndRemoveTestRenderingNodesToFragment):
(WebCore::ReplaceSelectionCommand::insertAsListItems):
* editing/SplitTextNodeCommand.cpp:
(WebCore::SplitTextNodeCommand::doUnapply):
* editing/TextIterator.cpp:
(WebCore::CharacterIterator::range):
(WebCore::BackwardsCharacterIterator::range):
(WebCore::TextIterator::rangeFromLocationAndLength):
(WebCore::collapsedToBoundary):
* editing/htmlediting.cpp:
(WebCore::createTabSpanElement):
* editing/mac/EditorMac.mm:
(WebCore::Editor::fontForSelection):
(WebCore::Editor::fontAttributesForSelectionStart):
* editing/markup.cpp:
(WebCore::createMarkup):
(WebCore::trimFragment):
(WebCore::createFragmentFromMarkupWithContext):
(WebCore::fillContainerFromString):
(WebCore::createFragmentFromText):
(WebCore::createFragmentFromNodes):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::createShadowSubtree):
Replaced inline ASSERT with ASSERT_NO_EXCEPTION.
* html/HTMLOptionsCollection.cpp:
(WebCore::HTMLOptionsCollection::add):
Replaced 'ASSERT(ec == 0)' with 'ASSERT(!ec)' to match the style guide.
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::updatePlaceholderText):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForVisiblePosition):
(WebCore::HTMLTextFormControlElement::setInnerTextValue):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::updatePlaceholderText):
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::buildBubbleTree):
* html/shadow/MediaControlElementTypes.cpp:
(WebCore::MediaControlVolumeSliderElement::defaultEventHandler):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::getCookies):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule):
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::dispatchDOMEvent):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::deleteFromDocument):
* page/DragController.cpp:
(WebCore::prepareClipboardForImageDrag):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::visiblePositionForIndex):
Replaced inline ASSERT with ASSERT_NO_EXCEPTION.
2013-02-08 Alexei Filippov <alph@chromium.org>
Web Inspector: disable profile type switching while profile in progress
......@@ -118,12 +118,10 @@ void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
oldParent->removeDetachedChildren();
for (unsigned i = 0; i < children.size(); ++i) {
ExceptionCode ec = 0;
if (children[i]->attached())
children[i]->detach();
// FIXME: We need a no mutation event version of adoptNode.
RefPtr<Node> child = document()->adoptNode(children[i].release(), ec);
ASSERT(!ec);
RefPtr<Node> child = document()->adoptNode(children[i].release(), ASSERT_NO_EXCEPTION);
parserAppendChild(child.get());
// FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
// (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
......
......@@ -1526,9 +1526,7 @@ void Document::setTitle(const String& title)
else if (!m_titleElement) {
if (HTMLElement* headElement = head()) {
m_titleElement = createElement(titleTag, false);
ExceptionCode ec = 0;
headElement->appendChild(m_titleElement, ec);
ASSERT(!ec);
headElement->appendChild(m_titleElement, ASSERT_NO_EXCEPTION);
}
}
......
......@@ -186,9 +186,7 @@ void MessagePort::dispatchMessages()
OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, eventData->channels());
RefPtr<Event> evt = MessageEvent::create(ports.release(), eventData->message());
ExceptionCode ec = 0;
dispatchEvent(evt.release(), ec);
ASSERT(!ec);
dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION);
}
}
......@@ -229,8 +227,7 @@ PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessageP
// Passed-in ports passed validity checks, so we can disentangle them.
OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelArray(ports->size()));
for (unsigned int i = 0 ; i < ports->size() ; ++i) {
OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle(ec);
ASSERT(!ec); // Can't generate exception here if passed above checks.
OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle(ASSERT_NO_EXCEPTION); // Can't generate exception here if passed above checks.
(*portArray)[i] = channel.release();
}
return portArray.release();
......
......@@ -155,10 +155,8 @@ static HTMLElement* enclosingDeletableElement(const VisibleSelection& selection)
if (!range)
return 0;
ExceptionCode ec = 0;
Node* container = range->commonAncestorContainer(ec);
Node* container = range->commonAncestorContainer(ASSERT_NO_EXCEPTION);
ASSERT(container);
ASSERT(ec == 0);
// The enclosingNodeOfType function only works on nodes that are editable
// (which is strange, given its name).
......@@ -234,7 +232,7 @@ void DeleteButtonController::createDeletionUI()
ExceptionCode ec = 0;
container->appendChild(outline.get(), ec);
ASSERT(ec == 0);
ASSERT(!ec);
if (ec)
return;
......@@ -266,7 +264,7 @@ void DeleteButtonController::createDeletionUI()
button->setCachedImage(new CachedImage(buttonImage.get()));
container->appendChild(button.get(), ec);
ASSERT(ec == 0);
ASSERT(!ec);
if (ec)
return;
......@@ -300,7 +298,7 @@ void DeleteButtonController::show(HTMLElement* element)
ExceptionCode ec = 0;
m_target->appendChild(m_containerElement.get(), ec);
ASSERT(ec == 0);
ASSERT(!ec);
if (ec) {
hide();
return;
......
......@@ -266,11 +266,8 @@ static unsigned verticalScrollDistance(Frame* frame)
static RefPtr<Range> unionDOMRanges(Range* a, Range* b)
{
ExceptionCode ec = 0;
Range* start = a->compareBoundaryPoints(Range::START_TO_START, b, ec) <= 0 ? a : b;
ASSERT(!ec);
Range* end = a->compareBoundaryPoints(Range::END_TO_END, b, ec) <= 0 ? b : a;
ASSERT(!ec);
Range* start = a->compareBoundaryPoints(Range::START_TO_START, b, ASSERT_NO_EXCEPTION) <= 0 ? a : b;
Range* end = a->compareBoundaryPoints(Range::END_TO_END, b, ASSERT_NO_EXCEPTION) <= 0 ? b : a;
return Range::create(a->ownerDocument(), start->startContainer(), start->startOffset(), end->endContainer(), end->endOffset());
}
......
......@@ -51,23 +51,18 @@ ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand(PassRefPtr<HTMLElement> e
static void swapInNodePreservingAttributesAndChildren(HTMLElement* newNode, HTMLElement* nodeToReplace)
{
ASSERT(nodeToReplace->inDocument());
ExceptionCode ec = 0;
RefPtr<ContainerNode> parentNode = nodeToReplace->parentNode();
parentNode->insertBefore(newNode, nodeToReplace, ec);
ASSERT(!ec);
parentNode->insertBefore(newNode, nodeToReplace, ASSERT_NO_EXCEPTION);
NodeVector children;
getChildNodes(nodeToReplace, children);
for (size_t i = 0; i < children.size(); ++i) {
newNode->appendChild(children[i], ec);
ASSERT(!ec);
}
for (size_t i = 0; i < children.size(); ++i)
newNode->appendChild(children[i], ASSERT_NO_EXCEPTION);
// FIXME: Fix this to send the proper MutationRecords when MutationObservers are present.
newNode->cloneDataFromElement(*nodeToReplace);
parentNode->removeChild(nodeToReplace, ec);
ASSERT(!ec);
parentNode->removeChild(nodeToReplace, ASSERT_NO_EXCEPTION);
}
void ReplaceNodeWithSpanCommand::doApply()
......
......@@ -181,9 +181,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
// Give the root a chance to change the text.
RefPtr<BeforeTextInsertedEvent> evt = BeforeTextInsertedEvent::create(text);
ExceptionCode ec = 0;
editableRoot->dispatchEvent(evt, ec);
ASSERT(ec == 0);
editableRoot->dispatchEvent(evt, ASSERT_NO_EXCEPTION);
if (text != evt->text() || !editableRoot->rendererIsRichlyEditable()) {
restoreAndRemoveTestRenderingNodesToFragment(holder.get());
......@@ -234,9 +232,7 @@ void ReplacementFragment::removeNode(PassRefPtr<Node> node)
if (!parent)
return;
ExceptionCode ec = 0;
parent->removeChild(node.get(), ec);
ASSERT(ec == 0);
parent->removeChild(node.get(), ASSERT_NO_EXCEPTION);
}
void ReplacementFragment::insertNodeBefore(PassRefPtr<Node> node, Node* refNode)
......@@ -248,23 +244,15 @@ void ReplacementFragment::insertNodeBefore(PassRefPtr<Node> node, Node* refNode)
if (!parent)
return;
ExceptionCode ec = 0;
parent->insertBefore(node, refNode, ec);
ASSERT(ec == 0);
parent->insertBefore(node, refNode, ASSERT_NO_EXCEPTION);
}
PassRefPtr<StyledElement> ReplacementFragment::insertFragmentForTestRendering(Node* rootEditableElement)
{
RefPtr<StyledElement> holder = createDefaultParagraphElement(m_document.get());
ExceptionCode ec = 0;
holder->appendChild(m_fragment, ec);
ASSERT(ec == 0);
rootEditableElement->appendChild(holder.get(), ec);
ASSERT(ec == 0);
holder->appendChild(m_fragment, ASSERT_NO_EXCEPTION);
rootEditableElement->appendChild(holder.get(), ASSERT_NO_EXCEPTION);
m_document->updateLayoutIgnorePendingStylesheets();
return holder.release();
......@@ -275,12 +263,9 @@ void ReplacementFragment::restoreAndRemoveTestRenderingNodesToFragment(StyledEle
if (!holder)
return;
ExceptionCode ec = 0;
while (RefPtr<Node> node = holder->firstChild()) {
holder->removeChild(node.get(), ec);
ASSERT(ec == 0);
m_fragment->appendChild(node.get(), ec);
ASSERT(ec == 0);
holder->removeChild(node.get(), ASSERT_NO_EXCEPTION);
m_fragment->appendChild(node.get(), ASSERT_NO_EXCEPTION);
}
removeNode(holder);
......@@ -1318,9 +1303,7 @@ Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtr<HTMLElement> prpList
}
while (RefPtr<Node> listItem = listElement->firstChild()) {
ExceptionCode ec = 0;
listElement->removeChild(listItem.get(), ec);
ASSERT(!ec);
listElement->removeChild(listItem.get(), ASSERT_NO_EXCEPTION);
if (isStart || isMiddle) {
insertNodeBefore(listItem, lastNode);
insertedNodes.respondToNodeInsertion(listItem.get());
......
......@@ -75,12 +75,10 @@ void SplitTextNodeCommand::doUnapply()
String prefixText = m_text1->data();
ExceptionCode ec = 0;
m_text2->insertData(0, prefixText, ec);
ASSERT(!ec);
m_text2->insertData(0, prefixText, ASSERT_NO_EXCEPTION);
document()->markers()->copyMarkers(m_text1.get(), 0, prefixText.length(), m_text2.get(), 0);
m_text1->remove(ec);
m_text1->remove(ASSERT_NO_EXCEPTION);
}
void SplitTextNodeCommand::doReapply()
......
......@@ -1418,10 +1418,8 @@ PassRefPtr<Range> CharacterIterator::range() const
Node* n = r->startContainer();
ASSERT(n == r->endContainer());
int offset = r->startOffset() + m_runOffset;
ExceptionCode ec = 0;
r->setStart(n, offset, ec);
r->setEnd(n, offset + 1, ec);
ASSERT(!ec);
r->setStart(n, offset, ASSERT_NO_EXCEPTION);
r->setEnd(n, offset + 1, ASSERT_NO_EXCEPTION);
}
}
return r.release();
......@@ -1526,10 +1524,8 @@ PassRefPtr<Range> BackwardsCharacterIterator::range() const
Node* n = r->startContainer();
ASSERT(n == r->endContainer());
int offset = r->endOffset() - m_runOffset;
ExceptionCode ec = 0;
r->setStart(n, offset - 1, ec);
r->setEnd(n, offset, ec);
ASSERT(!ec);
r->setStart(n, offset - 1, ASSERT_NO_EXCEPTION);
r->setEnd(n, offset, ASSERT_NO_EXCEPTION);
}
}
return r.release();
......@@ -2440,11 +2436,8 @@ PassRefPtr<Range> TextIterator::rangeFromLocationAndLength(ContainerNode* scope,
if (rangeLocation == 0 && rangeLength == 0 && it.atEnd()) {
textRunRange = it.range();
ExceptionCode ec = 0;
resultRange->setStart(textRunRange->startContainer(), 0, ec);
ASSERT(!ec);
resultRange->setEnd(textRunRange->startContainer(), 0, ec);
ASSERT(!ec);
resultRange->setStart(textRunRange->startContainer(), 0, ASSERT_NO_EXCEPTION);
resultRange->setEnd(textRunRange->startContainer(), 0, ASSERT_NO_EXCEPTION);
return resultRange.release();
}
......@@ -2466,17 +2459,12 @@ PassRefPtr<Range> TextIterator::rangeFromLocationAndLength(ContainerNode* scope,
it.advance();
if (!it.atEnd()) {
RefPtr<Range> range = it.range();
ExceptionCode ec = 0;
textRunRange->setEnd(range->startContainer(), range->startOffset(), ec);
ASSERT(!ec);
textRunRange->setEnd(range->startContainer(), range->startOffset(), ASSERT_NO_EXCEPTION);
} else {
Position runStart = textRunRange->startPosition();
Position runEnd = VisiblePosition(runStart).next().deepEquivalent();
if (runEnd.isNotNull()) {
ExceptionCode ec = 0;
textRunRange->setEnd(runEnd.containerNode(), runEnd.computeOffsetInContainerNode(), ec);
ASSERT(!ec);
}
if (runEnd.isNotNull())
textRunRange->setEnd(runEnd.containerNode(), runEnd.computeOffsetInContainerNode(), ASSERT_NO_EXCEPTION);
}
}
}
......@@ -2598,11 +2586,8 @@ static inline bool isAllCollapsibleWhitespace(const String& string)
static PassRefPtr<Range> collapsedToBoundary(const Range* range, bool forward)
{
ExceptionCode ec = 0;
RefPtr<Range> result = range->cloneRange(ec);
ASSERT(!ec);
result->collapse(!forward, ec);
ASSERT(!ec);
RefPtr<Range> result = range->cloneRange(ASSERT_NO_EXCEPTION);
result->collapse(!forward, ASSERT_NO_EXCEPTION);
return result.release();
}
......
......@@ -939,9 +939,7 @@ PassRefPtr<Element> createTabSpanElement(Document* document, PassRefPtr<Node> pr
if (!tabTextNode)
tabTextNode = document->createEditingTextNode("\t");
ExceptionCode ec = 0;
spanElement->appendChild(tabTextNode.release(), ec);
ASSERT(ec == 0);
spanElement->appendChild(tabTextNode.release(), ASSERT_NO_EXCEPTION);
return spanElement.release();
}
......
......@@ -153,11 +153,8 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
if (style)
result = style->font().primaryFont();
if (nodeToRemove) {
ExceptionCode ec;
nodeToRemove->remove(ec);
ASSERT(!ec);
}
if (nodeToRemove)
nodeToRemove->remove(ASSERT_NO_EXCEPTION);
return result;
}
......@@ -242,11 +239,8 @@ NSDictionary* Editor::fontAttributesForSelectionStart() const
if (decoration & UNDERLINE)
[result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
if (nodeToRemove) {
ExceptionCode ec = 0;
nodeToRemove->remove(ec);
ASSERT(ec == 0);
}
if (nodeToRemove)
nodeToRemove->remove(ASSERT_NO_EXCEPTION);
return result;
}
......
......@@ -564,13 +564,10 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
if (deleteButton)
deleteButton->disable();
ExceptionCode ec = 0;
bool collapsed = updatedRange->collapsed(ec);
ASSERT(!ec);
bool collapsed = updatedRange->collapsed(ASSERT_NO_EXCEPTION);
if (collapsed)
return "";
Node* commonAncestor = updatedRange->commonAncestorContainer(ec);
ASSERT(!ec);
Node* commonAncestor = updatedRange->commonAncestorContainer(ASSERT_NO_EXCEPTION);
if (!commonAncestor)
return "";
......@@ -598,14 +595,11 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
accumulator.appendString(interchangeNewlineString);
startNode = visibleStart.next().deepEquivalent().deprecatedNode();
ExceptionCode ec = 0;
if (pastEnd && Range::compareBoundaryPoints(startNode, 0, pastEnd, 0, ec) >= 0) {
ASSERT(!ec);
if (pastEnd && Range::compareBoundaryPoints(startNode, 0, pastEnd, 0, ASSERT_NO_EXCEPTION) >= 0) {
if (deleteButton)
deleteButton->enable();
return interchangeNewlineString;
}
ASSERT(!ec);
}
Node* lastClosed = accumulator.serializeNodes(startNode, pastEnd);
......@@ -693,7 +687,6 @@ static bool findNodesSurroundingContext(Document* document, RefPtr<Node>& nodeBe
static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, Node* nodeAfterContext)
{
ExceptionCode ec = 0;
RefPtr<Node> next;
for (RefPtr<Node> node = fragment->firstChild(); node; node = next) {
if (nodeBeforeContext->isDescendantOf(node.get())) {
......@@ -702,7 +695,7 @@ static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No
}
next = NodeTraversal::nextSkippingChildren(node.get());
ASSERT(!node->contains(nodeAfterContext));
node->parentNode()->removeChild(node.get(), ec);
node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION);
if (nodeBeforeContext == node)
break;
}
......@@ -710,8 +703,7 @@ static void trimFragment(DocumentFragment* fragment, Node* nodeBeforeContext, No
ASSERT(nodeAfterContext->parentNode());
for (RefPtr<Node> node = nodeAfterContext; node; node = next) {
next = NodeTraversal::nextSkippingChildren(node.get());
node->parentNode()->removeChild(node.get(), ec);
ASSERT(!ec);
node->parentNode()->removeChild(node.get(), ASSERT_NO_EXCEPTION);
}
}
......@@ -741,19 +733,16 @@ PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document* docum
positionAfterNode(nodeBeforeContext.get()).parentAnchoredEquivalent(),
positionBeforeNode(nodeAfterContext.get()).parentAnchoredEquivalent());
ExceptionCode ec = 0;
Node* commonAncestor = range->commonAncestorContainer(ec);
ASSERT(!ec);
Node* commonAncestor = range->commonAncestorContainer(ASSERT_NO_EXCEPTION);
Node* specialCommonAncestor = ancestorToRetainStructureAndAppearanceWithNoRenderer(commonAncestor);
// When there's a special common ancestor outside of the fragment, we must include it as well to
// preserve the structure and appearance of the fragment. For example, if the fragment contains
// TD, we need to include the enclosing TABLE tag as well.
RefPtr<DocumentFragment> fragment = DocumentFragment::create(document);
if (specialCommonAncestor) {
fragment->appendChild(specialCommonAncestor, ec);
ASSERT(!ec);
} else
if (specialCommonAncestor)
fragment->appendChild(specialCommonAncestor, ASSERT_NO_EXCEPTION);
else
fragment->takeAllChildrenFrom(static_cast<ContainerNode*>(commonAncestor));
trimFragment(fragment.get(), nodeBeforeContext.get(), nodeAfterContext.get());
......@@ -781,10 +770,8 @@ static void fillContainerFromString(ContainerNode* paragraph, const String& stri
{
Document* document = paragraph->document();
ExceptionCode ec = 0;
if (string.isEmpty()) {
paragraph->appendChild(createBlockPlaceholderElement(document), ec);
ASSERT(!ec);
paragraph->appendChild(createBlockPlaceholderElement(document), ASSERT_NO_EXCEPTION);
return;
}
......@@ -801,24 +788,20 @@ static void fillContainerFromString(ContainerNode* paragraph, const String& stri
// append the non-tab textual part
if (!s.isEmpty()) {
if (!tabText.isEmpty()) {
paragraph->appendChild(createTabSpanElement(document, tabText), ec);
ASSERT(!ec);
paragraph->appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
tabText = emptyString();
}
RefPtr<Node> textNode = document->createTextNode(stringWithRebalancedWhitespace(s, first, i + 1 == numEntries));
paragraph->appendChild(textNode.release(), ec);
ASSERT(!ec);
paragraph->appendChild(textNode.release(), ASSERT_NO_EXCEPTION);
}
// there is a tab after every entry, except the last entry
// (if the last character is a tab, the list gets an extra empty entry)
if (i + 1 != numEntries)
tabText.append('\t');
else if (!tabText.isEmpty()) {
paragraph->appendChild(createTabSpanElement(document, tabText), ec);
ASSERT(!ec);
}
else if (!tabText.isEmpty())
paragraph->appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
first = false;
}
}
......@@ -856,16 +839,13 @@ PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String
string.replace("\r\n", "\n");
string.replace('\r', '\n');
ExceptionCode ec = 0;
RenderObject* renderer = styleNode->renderer();
if (renderer && renderer->style()->preserveNewline()) {
fragment->appendChild(document->createTextNode(string), ec);
ASSERT(!ec);
fragment->appendChild(document->createTextNode(string), ASSERT_NO_EXCEPTION);
if (string.endsWith('\n')) {
RefPtr<Element> element = createBreakElement(document);
element->setAttribute(classAttr, AppleInterchangeNewline);
fragment->appendChild(element.release(), ec);
ASSERT(!ec);
fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION);
}
return fragment.release();
}
......@@ -907,8 +887,7 @@ PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String
element = createDefaultParagraphElement(document);
fillContainerFromString(element.get(), s);
}
fragment->appendChild(element.release(), ec);
ASSERT(!ec);
fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION);
}
return fragment.release();
}
......@@ -924,14 +903,11 @@ PassRefPtr<DocumentFragment> createFragmentFromNodes(Document *document, const V
RefPtr<DocumentFragment> fragment = document->createDocumentFragment();
ExceptionCode ec = 0;
size_t size = nodes.size();
for (size_t i = 0; i < size; ++i) {
RefPtr<Element> element = createDefaultParagraphElement(document);
element->appendChild(nodes[i], ec);
ASSERT(!ec);
fragment->appendChild(element.release(), ec);
ASSERT(!ec);
element->appendChild(nodes[i], ASSERT_NO_EXCEPTION);
fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION);
}
if (document->frame())
......
......@@ -126,11 +126,8 @@ void ColorInputType::createShadowSubtree()
wrapperElement->setPseudo(AtomicString("-webkit-color-swatch-wrapper", AtomicString::ConstructFromLiteral));
RefPtr<HTMLDivElement> colorSwatch = HTMLDivElement::create(document);
colorSwatch->setPseudo(AtomicString("-webkit-color-swatch", AtomicString::ConstructFromLiteral));
ExceptionCode ec = 0;
wrapperElement->appendChild(colorSwatch.release(), ec);
ASSERT(!ec);
element()->userAgentShadowRoot()->appendChild(wrapperElement.release(), ec);
ASSERT(!ec);
wrapperElement->appendChild(colorSwatch.release(), ASSERT_NO_EXCEPTION);
element()->userAgentShadowRoot()->appendChild(wrapperElement.release(), ASSERT_NO_EXCEPTION);
updateColorSwatch();
}
......
......@@ -65,7 +65,7 @@ void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index
else
select->add(newOption, static_cast<HTMLOptionElement*>(item(index