public void InitMouseEvent(string type, bool canBubble, bool cancelable, GeckoWindow view, int detail,
                            int screenX, int screenY, int clientX, int clientY,
                            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
                            ushort button, DomEventTarget target)
 {
     using (var typeArg = new nsAString(type))
     {
         _domMouseEvent.InitMouseEvent(typeArg, canBubble, cancelable, view.DomWindow, detail, screenX, screenY,
                                       clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, target.NativeObject);
     }
 }
Beispiel #2
0
        public static bool ParseDomEventTargetAsGeckoElement(DomEventTarget domEventTarget, out GeckoElement geckoElement)
        {
            geckoElement = null;
            if (domEventTarget == null)
            {
                return(false);
            }

            geckoElement = domEventTarget.CastToGeckoElement();
            return(geckoElement != null);
        }
 public void InitMouseScrollEvent(string type, bool canBubble, bool cancelable, GeckoWindow view, int detail,
                                  int screenX, int screenY, int clientX, int clientY,
                                  bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
                                  ushort button, DomEventTarget target, int axis
                                  )
 {
     using (var typeArg = new nsAString(type))
     {
         throw new NotImplementedException();
         //_mouseScrollEvent.InitMouseScrollEvent(typeArg, canBubble, cancelable, view.DomWindow, detail, screenX,
         //    screenY,
         //    clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button,
         //    target.NativeObject, axis);
     }
 }
        private bool DetermineSplitLocation(DomEventTarget target)
        {
            var selection = m_blocksDisplayBrowser.Window.Selection;
            var newOffset = selection.AnchorOffset;

            if (!m_blocksDisplayBrowser.Visible || target == null)
            {
                return(false);
            }

            var geckoElement  = target.CastToGeckoElement();
            var targetElement = geckoElement as GeckoDivElement;

            if (targetElement == null)
            {
                var geckoHtmlElement = geckoElement as GeckoHtmlElement;
                if (geckoHtmlElement != null)
                {
                    targetElement = geckoHtmlElement.Parent as GeckoDivElement;
                    if (targetElement == null)
                    {
                        return(false);
                    }

                    if (geckoElement.TagName == "SUP")
                    {
                        if (newOffset != 0)
                        {
                            return(false);
                        }
                        if (!targetElement.InnerHtml.StartsWith(geckoHtmlElement.OuterHtml))
                        {
                            return(DetermineSplitLocationAtStartOfVerse(targetElement, geckoHtmlElement.InnerHtml));
                        }
                    }
                    else
                    {
                        newOffset = 0;
                    }
                }
                else
                {
                    return(false);
                }
            }

            int blockIndex;

            if (targetElement.ClassName == "block")
            {
                blockIndex = int.Parse(targetElement.Id);
                if (newOffset > 0)
                {
                    // For simplicity, make it so a split at the end of a block is really a split at the start of the following block.
                    if (++blockIndex == m_originalBlocks.Count)
                    {
                        return(false);                        // Can't split at very end of last verse in last block
                    }
                    newOffset = 0;
                }
                else if (blockIndex == 0)
                {
                    return(false);                   // Can't split at start of first block.
                }
                VerseToSplit = null;                 // We're actually splitting between blocks of a multi-block quote
            }
            else if (targetElement.ClassName == "scripttext")
            {
                if (newOffset == 0)
                {
                    var indexInBlock = targetElement.ParentElement.ChildNodes.IndexOf(targetElement);
                    if (indexInBlock > 0)
                    {
                        return(false);
                    }
                    blockIndex = int.Parse(targetElement.Parent.Id);
                    if (blockIndex == 0)
                    {
                        return(false);                        // Can't split at start of first block.
                    }
                    VerseToSplit = null;
                }
                else
                {
                    blockIndex = int.Parse(targetElement.Parent.Id);

                    if (blockIndex == m_originalBlocks.Count - 1 && newOffset == selection.AnchorNode.NodeValue.Length)
                    {
                        return(false);                        // Can't split at very end of last verse in last block
                    }
                    VerseToSplit = targetElement.Id;
                    var childNodes = selection.AnchorNode.ParentNode.ChildNodes;

                    if (childNodes.Length == 3 && selection.AnchorNode.Equals(childNodes[2]))
                    {
                        newOffset += childNodes[0].NodeValue.Length;
                    }
                }
            }
            else
            {
                return(false);
            }

            BlockToSplit           = m_originalBlocks[blockIndex];
            CharacterOffsetToSplit = newOffset;
            return(true);
        }