chromium/third_party/blink/renderer/core/page/focusgroup_controller_utils.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/page/focusgroup_controller_utils.h"

#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/flat_tree_traversal.h"
#include "third_party/blink/renderer/core/dom/focusgroup_flags.h"
#include "third_party/blink/renderer/core/events/keyboard_event.h"
#include "third_party/blink/renderer/core/keywords.h"
#include "third_party/blink/renderer/core/layout/table/layout_table.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_cell.h"
#include "third_party/blink/renderer/core/page/grid_focusgroup_structure_info.h"

namespace blink {

FocusgroupDirection FocusgroupControllerUtils::FocusgroupDirectionForEvent(
    KeyboardEvent* event) {}

bool FocusgroupControllerUtils::IsDirectionForward(
    FocusgroupDirection direction) {}

bool FocusgroupControllerUtils::IsDirectionBackward(
    FocusgroupDirection direction) {}

bool FocusgroupControllerUtils::IsDirectionInline(
    FocusgroupDirection direction) {}

bool FocusgroupControllerUtils::IsDirectionBlock(
    FocusgroupDirection direction) {}

bool FocusgroupControllerUtils::IsAxisSupported(FocusgroupFlags flags,
                                                FocusgroupDirection direction) {}

bool FocusgroupControllerUtils::WrapsInDirection(
    FocusgroupFlags flags,
    FocusgroupDirection direction) {}

bool FocusgroupControllerUtils::FocusgroupExtendsInAxis(
    FocusgroupFlags extending_focusgroup,
    FocusgroupFlags focusgroup,
    FocusgroupDirection direction) {}

Element* FocusgroupControllerUtils::FindNearestFocusgroupAncestor(
    const Element* element,
    FocusgroupType type) {}

Element* FocusgroupControllerUtils::NextElement(const Element* current,
                                                bool skip_subtree) {}

Element* FocusgroupControllerUtils::PreviousElement(const Element* current) {}

Element* FocusgroupControllerUtils::LastElementWithin(const Element* current) {}

bool FocusgroupControllerUtils::IsFocusgroupItem(const Element* element) {}

// This function is called whenever the |element| passed by parameter has fallen
// into a subtree while navigating backward. Its objective is to prevent
// |element| from having descended into a non-extending focusgroup. When it
// detects its the case, it returns |element|'s first ancestor who is still part
// of the same focusgroup as |stop_ancestor|. The returned element is
// necessarily an element part of the previous focusgroup, but not necessarily a
// focusgroup item.
//
// |stop_ancestor| might be a focusgroup root itself or be a descendant of one.
// Regardless, given the assumption that |stop_ancestor| is always part of the
// previous focusgroup, we can stop going up |element|'s ancestors chain as soon
// as we reached it.
//
// Let's consider this example:
//           fg1
//      ______|_____
//      |          |
//      a1       a2
//      |
//     fg2
//    __|__
//    |   |
//    b1  b2
//
// where |fg2| is a focusgroup that doesn't extend the focusgroup |fg1|. While
// |fg2| is part of the focusgroup |fg1|, its subtree isn't. If the focus is on
// |a2|, the second item of the top-most focusgroup, and we go backward using
// the arrow keys, the focus should move to |fg2|. It shouldn't go inside of
// |fg2|, since it's a different focusgroup that doesn't extend its parent
// focusgroup.
//
// However, the previous element in preorder traversal from |a2| is |b2|, which
// isn't part of the same focusgroup. This function aims at fixing this by
// moving the current element to its parent, which is part of the previous
// focusgroup we were in (when we were on |a2|), |fg1|.
Element* FocusgroupControllerUtils::AdjustElementOutOfUnrelatedFocusgroup(
    Element* element,
    Element* stop_ancestor,
    FocusgroupDirection direction) {}

bool FocusgroupControllerUtils::IsGridFocusgroupItem(const Element* element) {}

GridFocusgroupStructureInfo*
FocusgroupControllerUtils::CreateGridFocusgroupStructureInfoForGridRoot(
    Element* root) {}

}  // namespace blink