Exemplo n.º 1
0
  /**
   * Tests whether this StyleSheet matches the specified variants. Returns a number indicating the
   * specificity of the match. Zero means there is no match. Larger numbers indicate better matches.
   * The value returned by compareVariants is used to sort style sheets according to precedence.
   *
   * @param mode
   */
  public int compareVariants(
      Locale locale,
      int direction,
      TrinidadAgent agent,
      int mode,
      AccessibilityProfile accessibilityProfile) {
    int localeMatch = _compareLocale(locale);
    if (localeMatch == 0) return 0;

    int directionMatch = _compareDirection(direction);
    if (directionMatch == 0) return 0;

    int browser = agent.getAgentApplication();

    int browserAndVersionMatch = _compareBrowserAndVersion(browser, agent);
    if (browserAndVersionMatch == 0) return 0;
    int modeMatch = _compareMode(mode);
    if (modeMatch == 0) return 0;

    int osMatch = _compareOS(agent.getAgentOS());
    if (osMatch == 0) return 0;

    int accessibilityMatch = _compareAccessibility(accessibilityProfile);
    if (accessibilityMatch == 0) return 0;

    return (localeMatch | browserAndVersionMatch | osMatch | accessibilityMatch);
  }