LCOV - code coverage report
Current view: top level - dom/html - RadioNodeList.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 25 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/RadioNodeList.h"
       8             : 
       9             : #include "mozilla/dom/BindingUtils.h"
      10             : #include "mozilla/dom/RadioNodeListBinding.h"
      11             : #include "js/TypeDecls.h"
      12             : 
      13             : #include "HTMLInputElement.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : /* virtual */ JSObject*
      19           0 : RadioNodeList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      20             : {
      21           0 :   return RadioNodeListBinding::Wrap(aCx, this, aGivenProto);
      22             : }
      23             : 
      24             : HTMLInputElement*
      25           0 : GetAsRadio(nsIContent* node)
      26             : {
      27           0 :   HTMLInputElement* el = HTMLInputElement::FromContent(node);
      28           0 :   if (el && el->ControlType() == NS_FORM_INPUT_RADIO) {
      29           0 :     return el;
      30             :   }
      31           0 :   return nullptr;
      32             : }
      33             : 
      34             : void
      35           0 : RadioNodeList::GetValue(nsString& retval, CallerType aCallerType)
      36             : {
      37           0 :   for (uint32_t i = 0; i < Length(); i++) {
      38           0 :     HTMLInputElement* maybeRadio = GetAsRadio(Item(i));
      39           0 :     if (maybeRadio && maybeRadio->Checked()) {
      40           0 :       maybeRadio->GetValue(retval, aCallerType);
      41           0 :       return;
      42             :     }
      43             :   }
      44           0 :   retval.Truncate();
      45             : }
      46             : 
      47             : void
      48           0 : RadioNodeList::SetValue(const nsAString& value, CallerType aCallerType)
      49             : {
      50           0 :   for (uint32_t i = 0; i < Length(); i++) {
      51             : 
      52           0 :     HTMLInputElement* maybeRadio = GetAsRadio(Item(i));
      53           0 :     if (!maybeRadio) {
      54           0 :       continue;
      55             :     }
      56             : 
      57           0 :     nsString curval = nsString();
      58           0 :     maybeRadio->GetValue(curval, aCallerType);
      59           0 :     if (curval.Equals(value)) {
      60           0 :       maybeRadio->SetChecked(true);
      61           0 :       return;
      62             :     }
      63             : 
      64             :   }
      65             : }
      66             : 
      67           0 : NS_IMPL_ISUPPORTS_INHERITED(RadioNodeList, nsSimpleContentList, RadioNodeList)
      68             : 
      69             : } // namespace dom
      70             : } // namespace mozilla

Generated by: LCOV version 1.13