[Webkit-unassigned] [Bug 25898] [Gtk] object:text-changed events should be emitted for entries and password text

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Sep 7 10:27:41 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=25898





--- Comment #69 from Enrica Casucci <enrica at apple.com>  2010-09-07 10:27:41 PST ---
(From update of attachment 66367)
> +// Calculate global offset (in the whole text, not just in the current node)
> +static unsigned calculateGlobalOffset(AccessibilityRenderObject* object, unsigned offset)
> +{
> +    Node* node = object->node();
> +    unsigned globalOffset = offset;
> +    for (Node* n = node->parentNode()->firstChild(); n && (n != node); n = n->nextSibling()) {
> +        if (n->isTextNode())
> +            globalOffset += n->nodeValue().length();
> +    }
> +    return globalOffset;
> +}
> +
This is not the right way to do it. You should use the TextIterator class for this purpose. Your function doesn't take into account visibility of the text.

> +void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityRenderObject* object, AXTextChange textChange, unsigned offset, unsigned count)
> +{
> +    // Sanity check
> +    if (!object || count < 1)
> +        return;
> +
> +    unsigned globalOffset = calculateGlobalOffset(object, offset);

There is no need to declare a variable here. You call emitTextChanged calling calculateGlobalOffset.
> +    emitTextChanged(object, textChange, globalOffset, count);
> +}
> +

>  
>  } // namespace WebCore
> diff --git a/WebCore/editing/DeleteSelectionCommand.cpp b/WebCore/editing/DeleteSelectionCommand.cpp
> index e57895c..71595f1 100644
> --- a/WebCore/editing/DeleteSelectionCommand.cpp
> +++ b/WebCore/editing/DeleteSelectionCommand.cpp
> @@ -443,11 +443,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
>          return;
>  
>      if (startNode == m_downstreamEnd.node()) {
> -        // The selection to delete is all in one node.
> -        if (!startNode->renderer() || (startOffset == 0 && m_downstreamEnd.atLastEditingPositionForNode())) {
> -            // just delete
> -            removeNode(startNode);
> -        } else if (m_downstreamEnd.deprecatedEditingOffset() - startOffset > 0) {
> +        if (m_downstreamEnd.deprecatedEditingOffset() - startOffset > 0) {
>              if (startNode->isTextNode()) {
>                  // in a text node that needs to be trimmed
>                  Text* text = static_cast<Text*>(startNode);
> @@ -457,6 +453,10 @@ void DeleteSelectionCommand::handleGeneralDelete()
>                  m_endingPosition = m_upstreamStart;
>              }
>          }
> +
> +        // The selection to delete is all in one node.
> +        if (!startNode->renderer() || (!startOffset && m_downstreamEnd.atLastEditingPositionForNode()))
> +            removeNode(startNode);
>      }
>      else {
>          bool startNodeWasDescendantOfEndNode = m_upstreamStart.node()->isDescendantOf(m_downstreamEnd.node());
> @@ -472,6 +472,9 @@ void DeleteSelectionCommand::handleGeneralDelete()
>              } else {
>                  node = startNode->childNode(startOffset);
>              }
> +        } else if (startNode == m_upstreamEnd.node() && startNode->isTextNode()) {
> +            Text* text = static_cast<Text*>(m_upstreamEnd.node());
> +            deleteTextFromNode(text, 0, m_upstreamEnd.deprecatedEditingOffset());
>          }
>          
This is not clear to me. Could you explain what you're trying to do here? Maybe some additional comments would help.

  }
> diff --git a/WebCore/editing/InsertNodeBeforeCommand.cpp b/WebCore/editing/InsertNodeBeforeCommand.cpp
> index 2ce9846..6f16e08 100644
> --- a/WebCore/editing/InsertNodeBeforeCommand.cpp
> +++ b/WebCore/editing/InsertNodeBeforeCommand.cpp
> @@ -26,6 +26,7 @@
>  #include "config.h"
>  #include "InsertNodeBeforeCommand.h"
>  
> +#include "AXObjectCache.h"
>  #include "htmlediting.h"
>  
>  namespace WebCore {
> @@ -51,6 +52,11 @@ void InsertNodeBeforeCommand::doApply()
>  
>      ExceptionCode ec;
>      parent->insertBefore(m_insertChild.get(), m_refChild.get(), ec);
> +
> +    if (AXObjectCache::accessibilityEnabled()) {
> +        unsigned len = m_insertChild->nodeValue().length();

No need to declare len.
> +        document()->axObjectCache()->nodeTextChangeNotification(m_insertChild->renderer(), AXObjectCache::AXTextInserted, 0, len);
> +    }
>  }
>  
>  void InsertNodeBeforeCommand::doUnapply()
> @@ -58,6 +64,12 @@ void InsertNodeBeforeCommand::doUnapply()
>      if (!m_insertChild->isContentEditable())
>          return;
>          
> +    // Need to notify this before actually deleting the text
> +    if (AXObjectCache::accessibilityEnabled()) {
> +        unsigned len = m_insertChild->nodeValue().length();

Same as above.

> +        document()->axObjectCache()->nodeTextChangeNotification(m_insertChild->renderer(), AXObjectCache::AXTextDeleted, 0, len);
> +    }
> +
>      ExceptionCode ec;
>      m_insertChild->remove(ec);
>  }
> -- 
> 1.7.0.4
>

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list