Commit d7447926 authored by yosin's avatar yosin Committed by Commit bot

Make ExceptionState parameter of ContainerNode::querySelector() as an optional parameter

This patch makes |ExceptionState| parameter of |ContainerNode::querySelector()|
as an optional parameter to reduce source code size for improving code
readability and ease of writing tests, since there are lots of call of
|querySelector()| with |ASSERT_NO_EXCEPTION| in Blink unit tests.

BUG=n/a
TEST=n/a; no behavior changes

Review-Url: https://codereview.chromium.org/2178243002
Cr-Commit-Position: refs/heads/master@{#407723}
parent 7fff7c5c
......@@ -83,7 +83,7 @@ public:
unsigned countChildren() const;
Element* querySelector(const AtomicString& selectors, ExceptionState&);
Element* querySelector(const AtomicString& selectors, ExceptionState& = ASSERT_NO_EXCEPTION);
StaticElementList* querySelectorAll(const AtomicString& selectors, ExceptionState&);
Node* insertBefore(Node* newChild, Node* refChild, ExceptionState& = ASSERT_NO_EXCEPTION);
......
......@@ -31,7 +31,7 @@ TEST_F(TextTest, RemoveFirstLetterPseudoElementWhenNoLetter)
{
setBodyContent("<style>*::first-letter{font:icon;}</style><pre>AB\n</pre>");
Element* pre = document().querySelector("pre", ASSERT_NO_EXCEPTION);
Element* pre = document().querySelector("pre");
Text* text = toText(pre->firstChild());
Range* range = Range::create(document(), text, 0, text, 2);
......
......@@ -15,8 +15,8 @@ class RelocatablePositionTest : public EditingTestBase {
TEST_F(RelocatablePositionTest, position)
{
setBodyContent("<b>foo</b><textarea>bar</textarea>");
Node* boldface = document().querySelector("b", ASSERT_NO_EXCEPTION);
Node* textarea = document().querySelector("textarea", ASSERT_NO_EXCEPTION);
Node* boldface = document().querySelector("b");
Node* textarea = document().querySelector("textarea");
RelocatablePosition relocatablePosition(Position(textarea, PositionAnchorType::BeforeAnchor));
textarea->remove();
......
......@@ -20,10 +20,10 @@ TEST_F(VisiblePositionTest, ShadowV0DistributedNodes)
ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
Element* body = document().body();
Element* one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
Element* two = body->querySelector("#two", ASSERT_NO_EXCEPTION);
Element* four = shadowRoot->querySelector("#s4", ASSERT_NO_EXCEPTION);
Element* five = shadowRoot->querySelector("#s5", ASSERT_NO_EXCEPTION);
Element* one = body->querySelector("#one");
Element* two = body->querySelector("#two");
Element* four = shadowRoot->querySelector("#s4");
Element* five = shadowRoot->querySelector("#s5");
EXPECT_EQ(Position(one->firstChild(), 0), canonicalPositionOf(Position(one, 0)));
EXPECT_EQ(Position(one->firstChild(), 0), createVisiblePosition(Position(one, 0)).deepEquivalent());
......
......@@ -174,9 +174,9 @@ TEST_F(VisibleSelectionTest, ShadowCrossing)
ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
Element* body = document().body();
Element* host = body->querySelector("#host", ASSERT_NO_EXCEPTION);
Element* one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
Element* six = shadowRoot->querySelector("#s6", ASSERT_NO_EXCEPTION);
Element* host = body->querySelector("#host");
Element* one = body->querySelector("#one");
Element* six = shadowRoot->querySelector("#s6");
VisibleSelection selection(Position::firstPositionInNode(one), Position::lastPositionInNode(shadowRoot));
VisibleSelectionInFlatTree selectionInFlatTree(PositionInFlatTree::firstPositionInNode(one), PositionInFlatTree::lastPositionInNode(host));
......@@ -195,9 +195,9 @@ TEST_F(VisibleSelectionTest, ShadowV0DistributedNodes)
ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
Element* body = document().body();
Element* one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
Element* two = body->querySelector("#two", ASSERT_NO_EXCEPTION);
Element* five = shadowRoot->querySelector("#s5", ASSERT_NO_EXCEPTION);
Element* one = body->querySelector("#one");
Element* two = body->querySelector("#two");
Element* five = shadowRoot->querySelector("#s5");
VisibleSelection selection(Position::firstPositionInNode(one), Position::lastPositionInNode(two));
VisibleSelectionInFlatTree selectionInFlatTree(PositionInFlatTree::firstPositionInNode(one), PositionInFlatTree::lastPositionInNode(two));
......@@ -226,9 +226,9 @@ TEST_F(VisibleSelectionTest, ShadowNested)
// <span id="s6">66</span>
// </p>
Element* body = document().body();
Element* host = body->querySelector("#host", ASSERT_NO_EXCEPTION);
Element* one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
Element* eight = shadowRoot2->querySelector("#s8", ASSERT_NO_EXCEPTION);
Element* host = body->querySelector("#host");
Element* one = body->querySelector("#one");
Element* eight = shadowRoot2->querySelector("#s8");
VisibleSelection selection(Position::firstPositionInNode(one), Position::lastPositionInNode(shadowRoot2));
VisibleSelectionInFlatTree selectionInFlatTree(PositionInFlatTree::firstPositionInNode(one), PositionInFlatTree::afterNode(eight));
......
......@@ -56,7 +56,7 @@ TEST_F(VisibleUnitsTest, absoluteCaretBoundsOf)
setShadowContent(shadowContent, "host");
Element* body = document().body();
Element* one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
Element* one = body->querySelector("#one");
IntRect boundsInDOMTree = absoluteCaretBoundsOf(createVisiblePosition(Position(one, 0)));
IntRect boundsInFlatTree = absoluteCaretBoundsOf(createVisiblePosition(PositionInFlatTree(one, 0)));
......@@ -164,10 +164,10 @@ TEST_F(VisibleUnitsTest, canonicalPositionOfWithHTMLHtmlElement)
const char* bodyContent = "<html><div id=one contenteditable>1</div><span id=two contenteditable=false>22</span><span id=three contenteditable=false>333</span><span id=four contenteditable=false>333</span></html>";
setBodyContent(bodyContent);
Node* one = document().querySelector("#one", ASSERT_NO_EXCEPTION);
Node* two = document().querySelector("#two", ASSERT_NO_EXCEPTION);
Node* three = document().querySelector("#three", ASSERT_NO_EXCEPTION);
Node* four = document().querySelector("#four", ASSERT_NO_EXCEPTION);
Node* one = document().querySelector("#one");
Node* two = document().querySelector("#two");
Node* three = document().querySelector("#three");
Node* four = document().querySelector("#four");
Element* html = document().createElement("html", ASSERT_NO_EXCEPTION);
// Move two, three and four into second html element.
html->appendChild(two);
......@@ -579,10 +579,10 @@ TEST_F(VisibleUnitsTest, inSameLine)
ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
Element* body = document().body();
Element* one = body->querySelector("#one", ASSERT_NO_EXCEPTION);
Element* two = body->querySelector("#two", ASSERT_NO_EXCEPTION);
Element* four = shadowRoot->querySelector("#s4", ASSERT_NO_EXCEPTION);
Element* five = shadowRoot->querySelector("#s5", ASSERT_NO_EXCEPTION);
Element* one = body->querySelector("#one");
Element* two = body->querySelector("#two");
Element* four = shadowRoot->querySelector("#s4");
Element* five = shadowRoot->querySelector("#s5");
EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one, 0), positionWithAffinityInDOMTree(*two, 0)));
EXPECT_TRUE(inSameLine(positionWithAffinityInDOMTree(*one->firstChild(), 0), positionWithAffinityInDOMTree(*two->firstChild(), 0)));
......@@ -705,10 +705,10 @@ TEST_F(VisibleUnitsTest, isVisuallyEquivalentCandidateWithHTMLHtmlElement)
const char* bodyContent = "<html><div id=one contenteditable>1</div><span id=two contenteditable=false>22</span><span id=three contenteditable=false>333</span><span id=four contenteditable=false>333</span></html>";
setBodyContent(bodyContent);
Node* one = document().querySelector("#one", ASSERT_NO_EXCEPTION);
Node* two = document().querySelector("#two", ASSERT_NO_EXCEPTION);
Node* three = document().querySelector("#three", ASSERT_NO_EXCEPTION);
Node* four = document().querySelector("#four", ASSERT_NO_EXCEPTION);
Node* one = document().querySelector("#one");
Node* two = document().querySelector("#two");
Node* three = document().querySelector("#three");
Node* four = document().querySelector("#four");
Element* html = document().createElement("html", ASSERT_NO_EXCEPTION);
// Move two, three and four into second html element.
html->appendChild(two);
......@@ -1307,7 +1307,7 @@ TEST_F(VisibleUnitsTest, endsOfNodeAreVisuallyDistinctPositionsWithInvisibleChil
const char* bodyContent = "<button> </button><script>document.designMode = 'on'</script>";
setBodyContent(bodyContent);
Node* button = document().querySelector("button", ASSERT_NO_EXCEPTION);
Node* button = document().querySelector("button");
EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button));
}
......@@ -1317,7 +1317,7 @@ TEST_F(VisibleUnitsTest, endsOfNodeAreVisuallyDistinctPositionsWithEmptyLayoutCh
const char* bodyContent = "<button><rt><script>document.designMode = 'on'</script></rt></button>";
setBodyContent(bodyContent);
Node* button = document().querySelector("button", ASSERT_NO_EXCEPTION);
Node* button = document().querySelector("button");
EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button));
}
......
......@@ -18,7 +18,7 @@ TEST_F(SpellCheckerTest, AdvanceToNextMisspellingWithEmptyInputNoCrash)
{
setBodyContent("<input placeholder='placeholder'>abc");
updateAllLifecyclePhases();
Element* input = document().querySelector("input", ASSERT_NO_EXCEPTION);
Element* input = document().querySelector("input");
input->focus();
document().settings()->setUnifiedTextCheckerEnabled(true);
// Do not crash in AdvanceToNextMisspelling command.
......
......@@ -62,7 +62,7 @@ protected:
Document& document = this->document();
document.write("<video>");
HTMLVideoElement& video = toHTMLVideoElement(*document.querySelector("video", ASSERT_NO_EXCEPTION));
HTMLVideoElement& video = toHTMLVideoElement(*document.querySelector("video"));
m_mediaControls = video.mediaControls();
// If scripts are not enabled, controls will always be shown.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment