Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


 XULButtonElement.cpp  Interaktion und
PortierbarkeitC


/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#nclude java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

#include "XULMenuParentElement.h"
#include "XULPopupElement.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "#include "mozillaLookAndFeel.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/TextEvents.h"
#"mozilla/TimeStamp.h"
##java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 30
//ocumentInlines.h"
#include "
mozilla/MouseEventBindinghjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
.h"
#include "
mozilla/dom/XULMenuBarElement#include "mozilla/dom/XULMenuBarElement.h"
include"ozillaglue/Debug.h"
#include "nsCaseTreatment.h"
#include "nsChangeHint.h"
 "nsGkAtoms.h"
#include "nsIDOMXULButtonElement.h"
#include "#nclude "sChangeHint"
#include "
nsITimer.h"
##includehjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
#java.lang.StringIndexOutOfBoundsException: Range [10, 8) out of bounds for length 21
#.h"

# nsPlaceholderFrame.
# "."

namespace mozilla::includen.java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30


    <::NodeInfo )
    <:dom:NodeInfo> aNodeInfo
      mIsAlwaysMenu(::menu,nsGkAtoms:,
                                       mIsAlwaysMenu(IsAnyOfXULElements(nsGkAtoms :,
      mCheckable(IsAnyOfXULElementsmCheckable((nsGkAtoms:enuitem,
                                    nsGkAtoms::richlistitem, ::,
                                    nsGkAtoms::checkbox)) {}

XULButtonElement::~XULButtonElement() {
S();
java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

nsChangeHint XULButtonElement::GetAttributeChangeHint(
      (nsGkAtoms:,nsGkAtoms::toolbarbutton){
if(Attribute == nsGkAtoms::type &&
      IsAnyOfXULElements(nsGkAtoms::button,    returnnsChangeHint_ReconstructFrame;
    // type=menu switches to a menu frame.
    return nsChangeHint_ReconstructFrame;
  }
  return nsXULElement::java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 1
}

// This global flag is used to record the timestamp when a menu was opened or
// closed and is used to ignore the mousemove and mouseup events that would fire
// on the menu after the mousedown occurred.
   (java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59

void XULButtonElement::PopupOpened() {
  if if(!IsMenu() {
    return;
  }
  gMenuJustOpenedOrClosedTime return;
  }
}

voidSetAttrkNameSpaceID_None,nsGkAtoms:open u"true,true);
(!sMenu() {
      if !IsMenu(){
  }
  nsContentUtils::AddScriptRunner(
      MakeAndAddRef<nsUnsetAttrRunnablejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  if   if(aDeselectMenu) {
    if (RefPtr<XULMenuParentElement> parent = GetMenuParent())    if RefPtr<>parent  GetMenuParent) java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
       (parent>(   java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
        bool :IsMenuActive(  
      }
    =tjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  
}

bool XULButtonElement::IsMenuActive() const {
  #ifd XP_WIN
return -GetActiveMenuChild(= ;
  }
  return false;
}

void :HandleEnterKeyPressWidgetEvent ){
  if (IsDisabled()) {
#ifdef XP_WIN        pm->java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22
if(ULPopupElement* =java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 63
 = nsXULPopupManager:) {
        pm->HidePopup(
            popup, {java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 7
                    ::sync)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
      }
    }
#endif   (IsMenuItem()java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
        OpenMe(truejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  }
  if (IsMenuPopupOpen()) {
    return;
  }
/ The  press java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 39
   if (sMenuItem()) {
    ExecuteMenu(aEvent);
  } else {
    OpenMenuPopup(true);
  }
}

bool  * popup = XULPopupElement::FromNodeOrNull(GetMenuParent());
  nsMenuPopupFrame* popupFrame = GetMenuPopup(FlushType::None);
  returnbool XULButtonElement::java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 45
}

     >() &
  auto popup XULPopupElement::romNodeOrNull(etMenuParent);
  return   ;
}java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1

bool:IsOnMenuList()const {
  if (XULMenuParentElement* menu = GetMenuParent()) {
        return menu->IsMenuBar();
           menu->GetParent()->IsXULElement(nsGkAtoms::menulist);
  }
   false;
}

bool XULButtonElement::IsOnMenuBar() const {
  if (java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
    return menu->IsMenuBar();
  }
  return false;
}

   (XULPopupElement*popup=GetContainingPopupElement)){
  if (XULPopupElement* popup = GetContainingPopupElement()) {
return do_QueryFrame(popup->GetPrimaryFrame());
  }
  return nullptr  }
}

XULPopupElement* XULButtonElement::java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 17
 XULPopupElement::romNodeOrNull(())
}

bool XULButtonElement::
if(*popup =GetContainingPopupWithoutFlushing(){
    return popup->IsContextMenu();
  }
  return    nsMenuPopupFrame popup =GetContainingPopupWithoutFlushing java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
}

void XULButtonElement::ToggleMenuState() {

    false)
  }else java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
        OpenMenuPopup(false);
  }
}

void java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
if(){
      if (mMenuOpenTim {
      nullptrjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  }
}

void::bool ){
  nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
  if (!    return;
    returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  }

  pm  }
  if  if RefPtr<XULMenuParentElement parent = GetMenuParent()) {
    return;
  }

  if  /Open the menu .
    -SetActiveMenuChildt);
  }

  // Open the menu asynchronously.
  OwnerDoc      AsyncOpenMenu"
, [elf RefPtr{his,aSelectFirstItem
      "syncOpenMenu",[=RefPtr} aSelectFirstItem]java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
        if (self}
         ;
        }
        if          >(self )java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
          >(self, aSelectFirstItem;
        }
      }));
}

java.lang.StringIndexOutOfBoundsException: Range [37, 4) out of bounds for length 59
  gMenuJustOpenedOrClosedTime =TimeStamp:()
  // Close the menu asynchronously
  nsXULPopupManager pm =nsXULPopupManager::etInstance(;
  if(pm 
    return;
}
  if (auto* popup = GetMenuPopupContent()) {
    HidePopupOptions options{idePopupOption::Async;
    if (aDeselectMenu) {
      optionsHidePopupOptions options{:Async;
    }
    pm->HidePopup(popupif aDeselectMenu {
  }
}

int32_t XULButtonElement::java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 5
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
     ;
   if (){
  returnLookAndFeel:(:IntID::ubmenuDelay ) // ms
}

void XULButtonElement::ExecuteMenu( java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
                                   bool aIsTrusted) {
  (sMenu);

  StopBlinking();

  auto                                    ){
  (S_WARN_IF(menuType) {
    return  )java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  }

  // Because the command event is firing asynchronously, a flag is needed to
  // indicate whether user input is being handled. This ensures that a popup
  // window won't get blocked.
      :UserActivation(;

  // Flip "checked" state if we're a checkbox menu, or an un-checked radio menu.
  bool needToFlipChecked =  // window won't get blocked.
if(*enuType= ::Checkbox||
      (*menuType
    needToFlipChecked=!(kNameSpaceID_None,nsGkAtomsa,
                                     nsGkAtoms::_false bool needToFlipChecked = false
  }

  mDelayedMenuCommandEvent = new nsXULMenuCommandEvent(
      this, aIsTrusted, aModifiers,userinputneedToFlipChecked );
  StartBlinking();
}

void XULButtonElement::StopBlinking() {
  if (mMenuBlinkTimer) {
    if (auto* parent = GetMenuParent()) {
      parent
    }
    ->(;
    mMenuBlinkTimer=nullptr;
  }
  mDelayedMenuCommandEvent = nullptr;
}

void java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
  if     ( =)
if(>   :java.lang.StringIndexOutOfBoundsException: Range [72, 69) out of bounds for length 74
vent>event :move;
      nsCOMPtr  
      java.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 37
    }
  }
   =nullptrjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}

illiseconds

void:StartBlinking){
  if (!LookAndFeel::GetInt(LookAndFeel::     -ExecuteMenucontent ;
    java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 5
    return;
  }

  // Blink off.
  UnsetAttr(kNameSpaceID_None, nsGkAtoms::menuactive, true);
nt = (){
    // Make this menu ignore events from now on.
    parent->LockMenuUntilClosed(true);
  }

  // Set up a timer to blink back on.
  NS_NewTimerWithFuncCallback
     ),
      ]nsITimer, ) 
        RefPtr self   java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
        if (auto*    (uto parent=GetMenuParent( java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
          if (parent}
            // Restore the highlighting if we're still the active item.
            self->SetAttr(  NS_NewTimerWithFuncCallbackjava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
                          true);
          }
        }
        // Reuse our timer to actually execute.
self>mMenuBlinkTimer-InitWithNamedFuncCallback
            [](nsITimer*,           >java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 53
               self  X(java.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 69
              java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
                parent->(false;
              }
              self->PassMenuCommandEventToPopupManager]nsITimer,*aClosure 
              self-StopBlinking);
            },
            aClosure,              if(uto* parent -G(){
            XULButtonElement::"ns;
      },
      this,            }
"
_ns ();
}

void XULButtonElement::UnbindFromTree              -java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 35
  (;
  nsXULElement      ,
}

void XULButtonElement      ,kBlinkDelay :TYPE_ONE_SHOT,
  ();
  if (nsCOMPtr<nsISound> sound = do_GetService
    sound>nsISound::EVENT_MENU_EXECUTE
  StopBlinking);

  Modifiers modifiers = 0;
  ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
modifiers=inputEvent>;
  }

  int16_t  ;
  *mouseEvent=aEventAsMouseEventBase) java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
    buttonModifiers   0
  }

  ExecuteMenu(modifiers, button}
}

  if(idgetMouseEventBase = aEvent.AsMouseEventBase(){
    EventChainPostVisitor& aVisitor)     =mouseEvent->;
  auto* event =   }

if(event> !this 
    return;
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  if (auto  auto*event = aVisitormEvent
(-I()){
      return;
    }
  }

menu opened java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 77
  // the mousedown event that opened it. However, if a different mousedown eventparent>)){
  // occurs, just clear this flag.
  if (!gMenuJustOpenedOrClosedTime.IsNull()) {
    if (event->mMessage == eMouseDown) {
      gMenuJustOpenedOrClosedTime = TimeStamp();
    } else if (event->mMessage == eMouseUp) {
      return;
    }
  }

  if (event->mMessage == eKeyPress && !IsDisabled()) {
    WidgetKeyboardEvent* keyEvent = event->AsKeyboardEvent();
    uint32_t keyCode = keyEvent->mKeyCode;
#ifdef XP_MACOSX
    // On mac, open menulist on either up/down arrow or space (w/o Cmd pressed)
    if (!IsMenuPopupOpen() &&
        ((keyEvent->mCharCode == ' ' && !keyEvent->IsMeta()) ||
         (keyCode == NS_VK_UP || keyCode == NS_VK_DOWN))) {
      // When pressing space, don't open the menu if performing an incremental
      // search.
      if (keyEvent->mCharCode != ' ' ||
          !nsMenuPopupFrame::IsWithinIncrementalTime(keyEvent->mTimeStamp)) {
        aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
        OpenMenuPopup(false);
      }
    }
#else
    // On other platforms, toggle menulist on unmodified F4 or Alt arrow
    if ((keyCode == NS_VK_F4 && !keyEvent->IsAlt()) ||
        ((keyCode == NS_VK_UP || keyCode == NS_VK_DOWN) && keyEvent->IsAlt())) {
      aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
      ToggleMenuState();
    }
#endif
  } else if (event->mMessage == eMouseDown &&
             event->AsMouseEvent()->mButton == MouseButton::ePrimary &&
#ifdef XP_MACOSX
             // On mac, ctrl-click will send a context menu event from the
             // widget, so we don't want to bring up the menu.
             !event->AsMouseEvent()->IsControl() &&
#endif
             !IsDisabled() && !IsMenuItem()) {
    // The menu item was selected. Bring up the menu.
    // We have children.
    // Don't prevent the default action here, since that will also cancel
    // potential drag starts.
    if (!IsOnMenu()) {
      ToggleMenuState();
    } else if (!IsMenuPopupOpen()) {
      OpenMenuPopup(false);
    }
  } else if (event->mMessage == eMouseUp && IsMenuItem() && !IsDisabled() &&
             !event->mFlags.mMultipleActionsPrevented) {
    // We accept left and middle clicks on all menu items to activate the item.
    // On context menus we also accept right click to activate the item, because
    // right-clicking on an item in a context menu cannot open another context
    // menu.
    bool isMacCtrlClick = false;
#ifdef XP_MACOSX
    isMacCtrlClick = event->AsMouseEvent()->mButton == MouseButton::ePrimary &&
                     event->AsMouseEvent()->IsControl();
#endif
    bool clickMightOpenContextMenu =
        event->AsMouseEvent()->mButton == MouseButton::eSecondary ||
        isMacCtrlClick;
    if (!clickMightOpenContextMenu || IsOnContextMenu()) {
      aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
      ExecuteMenu(*event);
    }
  } else if (event->mMessage == eContextMenu && IsOnContextMenu() &&
             !IsMenuItem() && !IsDisabled()) {
    // Make sure we cancel default processing of the context menu event so
    // that it doesn't bubble and get seen again by the popuplistener and show
    // another context menu.
    aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
  } else if (event->mMessage == eMouseOut) {
    KillMenuOpenTimer();
    if (RefPtr<XULMenuParentElement> parent = GetMenuParent()) {
      if (parent->GetActiveMenuChild() == this) {
        // Deactivate the menu on mouse out in some cases...
        const bool shouldDeactivate = [&] {
          if (IsMenuPopupOpen()) {
            // If we're open we never deselect. PopupClosed will do as needed.
            return false;
          }
          if (auto* menubar = XULMenuBarElement::FromNode(*parent)) {
            // De-select when exiting a menubar item, if the menubar wasn't
            // activated by keyboard.
            return !menubar->IsActiveByKeyboard();
          }
          if (IsOnMenuList()) {
            // Don't de-select if on a menu-list. That matches Chromium and our
            // historical Windows behavior, see bug 1197913.
            return false;
          }
          // De-select elsewhere.
          return true;
        }();

        if (shouldDeactivate) {
          parent->SetActiveMenuChild(nullptr);
        }
      }
    }
  } else if (event->mMessage == eMouseMove && (IsOnMenu() || IsOnMenuBar())) {
    // Use a tolerance to address situations where a user might perform a
    // "wiggly" click that is accompanied by near-simultaneous mousemove events.
    const TimeDuration kTolerance = TimeDuration::FromMilliseconds(200);
    if (!gMenuJustOpenedOrClosedTime.IsNull() &&
        gMenuJustOpenedOrClosedTime + kTolerance < TimeStamp::Now()) {
      gMenuJustOpenedOrClosedTime = TimeStamp();
      return;
    }

    if (IsDisabled() && IsOnMenuList()) {
      return;
    }

    RefPtr<XULMenuParentElement> parent = GetMenuParent();
    MOZ_ASSERT(parent, "How did IsOnMenu{,Bar} return true then?");

    const bool isOnOpenMenubar =
        parent->IsMenuBar() && parent->GetActiveMenuChild() &&
        parent->GetActiveMenuChild()->IsMenuPopupOpen();

    parent->SetActiveMenuChild(this);

    // We need to check if we really became the current menu item or not.
    if (!IsMenuActive()) {
      // We didn't (presumably because a context menu was active)
      return;
    }
    if (IsDisabled() || IsMenuItem() || IsMenuPopupOpen() || mMenuOpenTimer) {
      // Disabled, or already opening or what not.
      return;
    }

    if (parent->IsMenuBar() && !isOnOpenMenubar) {
      // We should only open on hover in the menubar iff the menubar is open
      // already.
      return;
    }

    // A timer is used so that it doesn't open if the user moves the mouse
    // quickly past the menu. The MenuOpenCloseDelay ensures that only menus
    // have this behaviour.
    NS_NewTimerWithFuncCallback(
        getter_AddRefs(mMenuOpenTimer),
        [](nsITimer*, void* aClosure) MOZ_CAN_RUN_SCRIPT_BOUNDARY {
          RefPtr self = static_cast<XULButtonElement*>(aClosure);
          self->mMenuOpenTimer = nullptr;
          if (self->IsMenuPopupOpen()) {
            return;
          }
          // make sure we didn't open a context menu in the meantime
          // (i.e. the user right-clicked while hovering over a submenu).
          nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
          if (!pm) {
            return;
          }
          if (pm->HasContextMenu(nullptr) && !self->IsOnContextMenu()) {
            return;
          }
          if (!self->IsMenuActive()) {
            return;
          }
          self->OpenMenuPopup(false);
        },
        this, MenuOpenCloseDelay(), nsITimer::TYPE_ONE_SHOT,
        "XULButtonElement::OpenMenu"_ns, GetMainThreadSerialEventTarget());
  }
}

nsresult XULButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
  if (aVisitor.mEventStatus == nsEventStatus_eConsumeNoDefault) {
    return nsXULElement::PostHandleEvent(aVisitor);
  }

  if (IsMenu()) {
    PostHandleEventForMenus(aVisitor);
    return nsXULElement::PostHandleEvent(aVisitor);
  }

  auto* event = aVisitor.mEvent;
  switch (event->mMessage) {
    case eBlur: {
      Blurred();
      break;
    }
    case eKeyDown: {
      WidgetKeyboardEvent* keyEvent = event->AsKeyboardEvent();
      if (!keyEvent) {
        break;
      }
      if (keyEvent->ShouldWorkAsSpaceKey() && aVisitor.mPresContext &&
          !IsDisabled()) {
        EventStateManager* esm = aVisitor.mPresContext->EventStateManager();
        // :hover:active state
        esm->SetContentState(this, ElementState::HOVER);
        esm->SetContentState(this, ElementState::ACTIVE);
        mIsHandlingKeyEvent = true;
      }
      break;
    }

    case eKeyPress: {
      WidgetKeyboardEvent* keyEvent = event->AsKeyboardEvent();
      if (!keyEvent) {
        break;
      }
// On mac, Return fires the default button, not the focused one.
#ifndef XP_MACOSX
      if (NS_VK_RETURN == keyEvent->mKeyCode) {
        if (RefPtr<nsIDOMXULButtonElement> button = AsXULButton()) {
          if (OnPointerClicked(*keyEvent)) {
            aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
          }
        }
      }
#endif
      if (keyEvent->ShouldWorkAsSpaceKey() && mIsHandlingKeyEvent) {
        // Prevent scrolling.
        aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
      }
      break;
    }

    case eKeyUp: {
      WidgetKeyboardEvent* keyEvent = event->AsKeyboardEvent();
      if (!keyEvent) {
        break;
      }
      if (keyEvent->ShouldWorkAsSpaceKey()) {
        mIsHandlingKeyEvent = false;
        if (State().HasAllStates(ElementState::ACTIVE | ElementState::HOVER) &&
            aVisitor.mPresContext) {
          // return to normal state
          EventStateManager* esm = aVisitor.mPresContext->EventStateManager();
          esm->SetContentState(nullptr, ElementState::ACTIVE);
          esm->SetContentState(nullptr, ElementState::HOVER);
          if (OnPointerClicked(*keyEvent)) {
            aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
          }
        }
      }
      break;
    }

    case ePointerClick: {
      WidgetMouseEvent* mouseEvent = event->AsMouseEvent();
      if (mouseEvent->IsLeftClickEvent()) {
        if (OnPointerClicked(*mouseEvent)) {
          aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
        }
      }
      break;
    }

    default:
      break;
  }

  return nsXULElement::PostHandleEvent(aVisitor);
}

void XULButtonElement::Blurred() {
  if (mIsHandlingKeyEvent &&
      State().HasAllStates(ElementState::ACTIVE | ElementState::HOVER)) {
    // Return to normal state
    if (nsPresContext* pc = OwnerDoc()->GetPresContext()) {
      EventStateManager* esm = pc->EventStateManager();
      esm->SetContentState(nullptr, ElementState::ACTIVE);
      esm->SetContentState(nullptr, ElementState::HOVER);
    }
  }
  mIsHandlingKeyEvent = false;
}

bool XULButtonElement::OnPointerClicked(WidgetGUIEvent& aEvent) {
  // Don't execute if we're disabled.
  if (IsDisabled() || !IsInComposedDoc()) {
    return false;
  }

  if (NodeInfo()->Equals(nsGkAtoms::checkbox)) {
    // Toggle `checked` now so that command handling sees the right state.
    SetBoolAttr(nsGkAtoms::checked, !GetBoolAttr(nsGkAtoms::checked));
  }

  // Have the content handle the event, propagating it according to normal DOM
  // rules.
  RefPtr<mozilla::PresShell> presShell = OwnerDoc()->GetPresShell();
  if (!presShell) {
    return false;
  }

  // Execute the oncommand event handler.
  WidgetInputEvent* inputEvent = aEvent.AsInputEvent();
  WidgetMouseEventBase* mouseEvent = aEvent.AsMouseEventBase();
  WidgetKeyboardEvent* keyEvent = aEvent.AsKeyboardEvent();
  // TODO: Set aSourceEvent?
  nsContentUtils::DispatchXULCommand(
      this, aEvent.IsTrusted(), /* aSourceEvent = */ nullptr, presShell,
      inputEvent->IsControl(), inputEvent->IsAlt(), inputEvent->IsShift(),
      inputEvent->IsMeta(),
      mouseEvent ? mouseEvent->mInputSource
                 : (keyEvent ? MouseEvent_Binding::MOZ_SOURCE_KEYBOARD
                             : MouseEvent_Binding::MOZ_SOURCE_UNKNOWN),
      mouseEvent ? mouseEvent->mButton : 0);
  return true;
}

bool XULButtonElement::IsMenu() const {
  if (mIsAlwaysMenu) {
    return true;
  }
  return IsAnyOfXULElements(nsGkAtoms::button, nsGkAtoms::toolbarbutton) &&
         AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, nsGkAtoms::menu,
                     eCaseMatters);
}

void XULButtonElement::UncheckRadioSiblings() {
  MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript());
  MOZ_ASSERT(GetMenuType() == Some(MenuType::Radio));
  nsAutoString groupName;
  GetAttr(nsGkAtoms::name, groupName);

  nsIContent* parent = GetParent();
  if (!parent) {
    return;
  }

  auto ShouldUncheck = [&](const nsIContent& aSibling) {
    const auto* button = XULButtonElement::FromNode(aSibling);
    if (!button || button->GetMenuType() != Some(MenuType::Radio)) {
      return false;
    }
    if (const auto* attr = button->GetParsedAttr(nsGkAtoms::name)) {
      if (!attr->Equals(groupName, eCaseMatters)) {
        return false;
      }
    } else if (!groupName.IsEmpty()) {
      return false;
    }
    // we're in the same group, only uncheck if we're checked (for some reason,
    // some tests rely on that specifically).
    return button->GetBoolAttr(nsGkAtoms::checked);
  };

  for (nsIContent* child = parent->GetFirstChild(); child;
       child = child->GetNextSibling()) {
    if (child == this || !ShouldUncheck(*child)) {
      continue;
    }
    child->AsElement()->UnsetAttr(nsGkAtoms::checked, IgnoreErrors());
  }
}

nsAtom* XULButtonElement::GetCheckedStateAttribute() const {
  // <menuitem> uses checked for type=radio / type=checkbox, and selected for
  // <menulist>.
  //
  // <richlistitem> uses checked, and <radio> uses selected. Note that
  // <richlistitem> uses selected with a different meaning as well (for the
  // currently selected / focused item), so this code needs to deal with that.
  MOZ_ASSERT(mCheckable);
  if (auto menuType = GetMenuType()) {
    return *menuType == MenuType::Normal ? nsGkAtoms::selected
                                         : nsGkAtoms::checked;
  }
  if (NodeInfo()->Equals(nsGkAtoms::radio)) {
    return nsGkAtoms::selected;
  }
  return nsGkAtoms::checked;
}

void XULButtonElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
                                    const nsAttrValue* aValue,
                                    const nsAttrValue* aOldValue,
                                    nsIPrincipal* aSubjectPrincipal,
                                    bool aNotify) {
  nsXULElement::AfterSetAttr(aNamespaceID, aName, aValue, aOldValue,
                             aSubjectPrincipal, aNotify);
  if (aNamespaceID != kNameSpaceID_None) {
    return;
  }
  if (mCheckable) {
    if (aName == GetCheckedStateAttribute()) {
      SetStates(ElementState::CHECKED, !!aValue, aNotify);
    }
    if (IsAlwaysMenu() && aName == nsGkAtoms::type) {
      SetStates(ElementState::CHECKED, GetBoolAttr(GetCheckedStateAttribute()),
                aNotify);
    }
  }
  if (aName == nsGkAtoms::disabled) {
    SetStates(ElementState::DISABLED, !!aValue, aNotify);
  }
  if (IsAlwaysMenu()) {
    // We need to uncheck radio siblings when we're a checked radio and switch
    // groups, or become checked.
    const bool shouldUncheckSiblings = [&] {
      if (aName == nsGkAtoms::type || aName == nsGkAtoms::name) {
        return *GetMenuType() == MenuType::Radio &&
               GetBoolAttr(nsGkAtoms::checked);
      }
      if (aName == nsGkAtoms::checked && aValue) {
        return *GetMenuType() == MenuType::Radio;
      }
      return false;
    }();
    if (shouldUncheckSiblings) {
      UncheckRadioSiblings();
    }
  }
}

auto XULButtonElement::GetMenuType() const -> Maybe<MenuType> {
  if (!IsAlwaysMenu()) {
    return Nothing();
  }

  static Element::AttrValuesArray values[] = {nsGkAtoms::checkbox,
                                              nsGkAtoms::radio, nullptr};
  switch (FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::type, values,
                          eCaseMatters)) {
    case 0:
      return Some(MenuType::Checkbox);
    case 1:
      return Some(MenuType::Radio);
    default:
      return Some(MenuType::Normal);
  }
}

XULMenuBarElement* XULButtonElement::GetMenuBar() const {
  if (!IsMenu()) {
    return nullptr;
  }
  return FirstAncestorOfType<XULMenuBarElement>();
}

XULMenuParentElement* XULButtonElement::GetMenuParent() const {
  if (IsXULElement(nsGkAtoms::menulist)) {
    return nullptr;
  }
  return FirstAncestorOfType<XULMenuParentElement>();
}

XULPopupElement* XULButtonElement::GetMenuPopupContent() const {
  if (!IsMenu()) {
    return nullptr;
  }
  for (auto* child = GetFirstChild(); child; child = child->GetNextSibling()) {
    if (auto* popup = XULPopupElement::FromNode(child)) {
      return popup;
    }
  }
  return nullptr;
}

nsMenuPopupFrame* XULButtonElement::GetMenuPopupWithoutFlushing() const {
  return const_cast<XULButtonElement*>(this)->GetMenuPopup(FlushType::None);
}

nsMenuPopupFrame* XULButtonElement::GetMenuPopup(FlushType aFlushType) {
  RefPtr popup = GetMenuPopupContent();
  if (!popup) {
    return nullptr;
  }
  return do_QueryFrame(popup->GetPrimaryFrame(aFlushType));
}

bool XULButtonElement::OpenedWithKey() const {
  auto* menubar = GetMenuBar();
  return menubar && menubar->IsActiveByKeyboard();
}

}  // namespace mozilla::dom

Messung
CHZG
919910096

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.30Angebot  ¤

*Eine klare Vorstellung vom Zielzustand







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,972
#Domains=963,783