Is an element private and we are including private elements, or element is
protected and we are including protected elements.

@param ProgramElementDoc element The element to check
@return bool
183124
public function _includeElements(&$element)
    {
        if ($element->isGlobal() && !$element->isFinal() && !$this->_globals) {
            return FALSE;
        } elseif ($element->isGlobal() && $element->isFinal() && !$this->_constants) {
            return FALSE;
        } elseif (!$this->_private && $element->isPrivate()) {
            return FALSE;
        } elseif ($this->_private) {
            return TRUE;
        } elseif ($this->_protected && ($element->isPublic() || $element->isProtected())) {
            return TRUE;
        } elseif ($this->_public && $element->isPublic()) {
            return TRUE;
        }

        return FALSE;
    }
781990
private boolean isNsAware(Element mathNode) {
        Field field;
        Document document = mathNode.getOwnerDocument();
        try {
            field = document.getClass().getDeclaredField("fNamespacesEnabled");
            field.setAccessible(true);
            return (boolean) field.get(document);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            logger.debug("Possible performance issue: Can not determine if node document is namespace aware.", e);
            return false;
        }
    }
107475
function getElementRect(elem) {
  const docElem = elem.ownerDocument.documentElement;

  // FF 2, Safari 3 and Opera 9.5- do not support getBoundingClientRect().
  // IE9- will throw if the element is not in the document.
  if (!('getBoundingClientRect' in elem) || !containsNode(docElem, elem)) {
    return {
      left:   0,
      right:  0,
      top:    0,
      bottom: 0
    };
  }

  // Subtracts clientTop/Left because IE8- added a 2px border to the
  // <html> element (see http://fburl.com/1493213). IE 7 in
  // Quicksmode does not report clientLeft/clientTop so there
  // will be an unaccounted offset of 2px when in quirksmode
  const rect = elem.getBoundingClientRect();

  return {
    left:   Math.round(rect.left) - docElem.clientLeft,
    right:  Math.round(rect.right) - docElem.clientLeft,
    top:    Math.round(rect.top) - docElem.clientTop,
    bottom: Math.round(rect.bottom) - docElem.clientTop
  };
}
321951
private List<ProgramElementDoc> getInheritedPackagePrivateMethods(Configuration configuration) {
        List<ProgramElementDoc> results = new ArrayList<>();
        for (ClassDoc currentClass : visibleClasses) {
            if (currentClass != classdoc &&
                currentClass.isPackagePrivate() &&
                !utils.isLinkable(currentClass, configuration)) {
                // Document these members in the child class because
                // the parent is inaccessible.
                results.addAll(getMembersFor(currentClass));
            }
        }
        return results;
    }
512594
public function isTrustedTag($tag_name, $compiler)
    {
        // check for internal always required tags
        if (in_array($tag_name, array('assign', 'call', 'private_filter', 'private_block_plugin',
                                      'private_function_plugin', 'private_object_block_function',
                                      'private_object_function', 'private_registered_function',
                                      'private_registered_block', 'private_special_variable',
                                      'private_print_expression', 'private_modifier'))) {
            return true;
        }
        // check security settings
        if (empty($this->allowed_tags)) {
            if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) {
                return true;
            } else {
                $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true);
            }
        } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) {
            return true;
        } else {
            $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true);
        }

        return false; // should not, but who knows what happens to the compiler in the future?
    }
1183450
private function _checkDocBlockParameters() {

		// For anonymous functions, we don't check the docblock
		$isAnonymous = $this->statementStack->getCurrentStackItem()->visibility === 'ANONYMOUS';

		if ($this->_isActive('docBlocks') && !$isAnonymous && !$this->_config->isException('docBlocks', $this->_currentFunctionName) && !$this->statementStack->getParentStackItem()->docblocInheritDoc) {

			// If the function is not private and we check the doc
			$isPrivateExcluded = $this->_config->getTestProperty('docBlocks', 'excludePrivateMembers');
			if (!($isPrivateExcluded && $this->_functionVisibility === 'PRIVATE')) {

				// Check the docblock @return
				if (($this->_config->getTestProperty('docBlocks', 'testReturn') !== 'false')) {

					if ($this->_functionReturns && ($this->statementStack->getParentStackItem()->docblocNbReturns === 0)) {
						$msg = $this->_getMessage('DOCBLOCK_RETURN', $this->_currentFunctionName);
						$this->_writeError('docBlocks', $msg);
					}
				}

				// Check the docblock @param
				if (($this->_config->getTestProperty('docBlocks', 'testParam') !== 'false')) {
					if ($this->_nbFunctionParameters !== $this->statementStack->getParentStackItem()->docblocNbParams) {
						$msg = $this->_getMessage('DOCBLOCK_PARAM', $this->_currentFunctionName);
						$this->_writeError('docBlocks', $msg);
					}
				}

				// Check the docblock @throw
				if (($this->_config->getTestProperty('docBlocks', 'testThrow') !== 'false')) {

					if ($this->_functionThrows && ($this->statementStack->getParentStackItem()->docblocNbThrows === 0)) {
						$msg = $this->_getMessage('DOCBLOCK_THROW', $this->_currentFunctionName);
						$this->_writeError('docBlocks', $msg);
					}
				}
			}
		}
	}
1181550
private boolean isValidTemplateElement(String template, String element) {

        List elements = new ArrayList(getTemplateElements(template));
        Iterator i = elements.iterator();
        while (i.hasNext()) {
            CmsDialogElement currElement = (CmsDialogElement)i.next();
            if (element.equals(currElement.getName())) {
                return true;
            }
        }

        return false;
    }
1170417
private ImmutableList<Element> getNodeListForTagElement(Document dom,
			CrawlElement crawlElement,
			EventableConditionChecker eventableConditionChecker) {

		Builder<Element> result = ImmutableList.builder();

		if (crawlElement.getTagName() == null) {
			return result.build();
		}

		EventableCondition eventableCondition =
				eventableConditionChecker.getEventableCondition(crawlElement.getId());
		// TODO Stefan; this part of the code should be re-factored, Hack-ed it this way to prevent
		// performance problems.
		ImmutableList<String> expressions = getFullXpathForGivenXpath(dom, eventableCondition);

		NodeList nodeList = dom.getElementsByTagName(crawlElement.getTagName());

		for (int k = 0; k < nodeList.getLength(); k++) {

			Element element = (Element) nodeList.item(k);
			boolean matchesXpath =
					elementMatchesXpath(eventableConditionChecker, eventableCondition,
							expressions, element);
			LOG.debug("Element {} matches Xpath={}", DomUtils.getElementString(element),
					matchesXpath);
			/*
			 * TODO Stefan This is a possible Thread-Interleaving problem, as / isChecked can return
			 * false and when needed to add it can return true. / check if element is a candidate
			 */
			String id = element.getNodeName() + ": " + DomUtils.getAllElementAttributes(element);
			if (matchesXpath && !checkedElements.isChecked(id)
					&& !isExcluded(dom, element, eventableConditionChecker)) {
				addElement(element, result, crawlElement);
			} else {
				LOG.debug("Element {} was not added", element);
			}
		}
		return result.build();
	}
466238
private boolean isToIgnore(CtElement element) {
		if (element instanceof CtStatementList && !(element instanceof CtCase)) {
			if (element.getRoleInParent() == CtRole.ELSE || element.getRoleInParent() == CtRole.THEN) {
				return false;
			}
			return true;
		}
		return element.isImplicit() || element instanceof CtReference;
	}
508688
private void checkNameVisibility(Scope scope, Node name) {
    if (!name.isName()) {
      return;
    }

    Var var = scope.getVar(name.getString());
    if (var == null) {
      return;
    }

    Visibility v = checkPrivateNameConvention(
        AccessControlUtils.getEffectiveNameVisibility(
            name, var, defaultVisibilityForFiles), name);

    switch (v) {
      case PACKAGE:
        if (!isPackageAccessAllowed(var, name)) {
          compiler.report(
              JSError.make(
                  name,
                  BAD_PACKAGE_PROPERTY_ACCESS,
                  name.getString(),
                  var.getSourceFile().getName()));
        }
        break;
      case PRIVATE:
        if (!isPrivateAccessAllowed(var, name)) {
          compiler.report(
              JSError.make(
                  name,
                  BAD_PRIVATE_GLOBAL_ACCESS,
                  name.getString(),
                  var.getSourceFile().getName()));
        }
        break;
      default:
        // Nothing to do for PUBLIC and PROTECTED
        // (which is irrelevant for names).
        break;
    }
  }
1015953
function isElementInViewport(el) {
    var eap;
    var rect = el.getBoundingClientRect();
    var docEl = document.documentElement;
    var vWidth = window.innerWidth || docEl.clientWidth;
    var vHeight = window.innerHeight || docEl.clientHeight;
    var efp = function (x, y) { return document.elementFromPoint(x, y); };
    var contains = el.contains ? (function (node) { return el.contains(node); }) : (function (node) { return el.compareDocumentPosition(node) == 0x10; });
    // Return false if it's not in the viewport
    if (rect.right < 0 || rect.bottom < 0
        || rect.left > vWidth || rect.top > vHeight)
        return false;
    // Return true if any of its four corners are visible
    return ((eap = efp(rect.left, rect.top)) == el || contains(eap)
        || (eap = efp(rect.right, rect.top)) == el || contains(eap)
        || (eap = efp(rect.right, rect.bottom)) == el || contains(eap)
        || (eap = efp(rect.left, rect.bottom)) == el || contains(eap));
}
653236
static Class<?> getElementTypeFromEnumSet(Object enumSet)
    {
        if (__elementTypeFromEnumSet == null)
        {
            throw new RuntimeException(
                    "Could not access (reflection) the private "
                            + "field *elementType* (enumClass) from: class java.util.EnumSet");
        }

        try
        {
            return (Class<?>) __elementTypeFromEnumSet.get(enumSet);
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }
1229477
int[] impliedElements(int anc, int desc) {
    // <style> and <script> are allowed anywhere.
    if (desc == SCRIPT_TAG || desc == STYLE_TAG) {
      return ZERO_INTS;
    }

    // It's dangerous to allow free <li> tags because of the way an <li>
    // implies a </li> if there is an <li> on the parse stack without a
    // LIST_SCOPE element in the middle.

    // Since we don't control the context in which sanitized HTML is embedded,
    // we can't assume that there isn't a containing <li> tag before parsing
    // starts, so we make sure we never produce an <li> or <td> without a
    // corresponding LIST or TABLE scope element on the stack.
    // <select> is not a scope for <option> elements, but we do that too for
    // symmetry and as an extra degree of safety against future spec changes.
    FreeWrapper wrapper = desc != TEXT_NODE && desc < FREE_WRAPPERS.length
        ? FREE_WRAPPERS[desc] : null;
    if (wrapper != null) {
      if (anc < wrapper.allowedContainers.length
          && !wrapper.allowedContainers[anc]) {
        return wrapper.implied;
      }
    }

    if (desc != TEXT_NODE) {
      int[] implied = impliedElements.getElementIndexList(anc, desc);
      // This handles the table case at least
      if (implied.length != 0) { return implied; }
    }

    // If we require above that all <li>s appear in a <ul> or <ol> then
    // for symmetry, we require here that all content of a <ul> or <ol> appear
    // nested in a <li>.
    // This does not have the same security implications as the above, but is
    // symmetric.
    int[] oneImplied = null;
    if (anc == OL_TAG || anc == UL_TAG) {
      oneImplied = LI_TAG_ARR;
    } else if (anc == SELECT_TAG) {
      oneImplied = OPTION_TAG_ARR;
    }
    if (oneImplied != null) {
      if (desc != oneImplied[0]) {
        return LI_TAG_ARR;
      }
    }
    // TODO: why are we dropping OPTION_AG_ARR?
    return ZERO_INTS;
  }
1251315
private void addModifier(Element member, Content code) {
        if (utils.isProtected(member)) {
            code.addContent("protected ");
        } else if (utils.isPrivate(member)) {
            code.addContent("private ");
        } else if (!utils.isPublic(member)) { // Package private
            code.addContent(configuration.getText("doclet.Package_private"));
            code.addContent(" ");
        }
        boolean isAnnotatedTypeElement = utils.isAnnotationType(member.getEnclosingElement());
        if (!isAnnotatedTypeElement && utils.isMethod(member)) {
            if (!utils.isInterface(member.getEnclosingElement()) && utils.isAbstract(member)) {
                code.addContent("abstract ");
            }
            if (utils.isDefault(member)) {
                code.addContent("default ");
            }
        }
        if (utils.isStatic(member)) {
            code.addContent("static ");
        }
    }
1100977
public static boolean serialInclude(Utils utils, Element element) {
        if (element == null) {
            return false;
        }
        return utils.isClass(element)
                ? serialClassInclude(utils, (TypeElement)element)
                : serialDocInclude(utils, element);
    }
1291727
protected boolean isOverride(TypeElement typeElement, ExecutableElement methodElement) {
    TypeElement currentTypeElement = typeElement;
    do {
      if (currentTypeElement != typeElement) {
        List<? extends Element> enclosedElements = currentTypeElement.getEnclosedElements();
        for (Element enclosedElement : enclosedElements) {
          if (enclosedElement.getSimpleName().equals(methodElement.getSimpleName())
              && enclosedElement.getAnnotation(Inject.class) != null
              && enclosedElement.getKind() == ElementKind.METHOD) {
            return true;
          }
        }
      }
      TypeMirror superclass = currentTypeElement.getSuperclass();
      if (superclass.getKind() == TypeKind.DECLARED) {
        DeclaredType superType = (DeclaredType) superclass;
        currentTypeElement = (TypeElement) superType.asElement();
      } else {
        currentTypeElement = null;
      }
    } while (currentTypeElement != null);
    return false;
  }
127668
private static Element toDom(final org.jdom.Element element) {
        return toDom(element.getDocument()).getDocumentElement();
    }