Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigating by line in Microsoft Edge is now up to 3x faster in the Windows 10 Creaters Update #6994

Merged
merged 10 commits into from Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
465 changes: 289 additions & 176 deletions source/NVDAObjects/UIA/__init__.py

Large diffs are not rendered by default.

272 changes: 144 additions & 128 deletions source/NVDAObjects/UIA/edge.py

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion source/NVDAObjects/UIA/wordDocument.py
Expand Up @@ -14,6 +14,9 @@

class WordDocumentTextInfo(UIATextInfo):

def _get_controlFieldNVDAObjectClass(self):
return WordDocumentNode

# UIA text range comparison for bookmarks works okay in this MS Word implementation
# Thus __ne__ is useful
def __ne__(self,other):
Expand Down Expand Up @@ -66,7 +69,7 @@ def _get_isCollapsed(self):
# Therefore class a range as collapsed if it has no text
return not bool(self.text)

def getTextWithFields(self,formatConfig=None):
def old_getTextWithFields(self,formatConfig=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer needed? If not, it should be removed.

fields=super(WordDocumentTextInfo,self).getTextWithFields(formatConfig=formatConfig)
# MS Word can sometimes return a higher ancestor in its textRange's children.
# E.g. a table inside a table header.
Expand Down
3 changes: 2 additions & 1 deletion source/UIAHandler.py
@@ -1,5 +1,5 @@
import winVersion
import comtypes
from comtypes import COMError
import config
from logHandler import log

Expand All @@ -13,6 +13,7 @@
from _UIAHandler import *
isUIAAvailable=True
except ImportError:
log.debugWarning("Unable to import _UIAHandler",exc_info=True)
pass

def initialize():
Expand Down
69 changes: 69 additions & 0 deletions source/UIAUtils.py
Expand Up @@ -4,6 +4,7 @@
#See the file COPYING for more details.

from comtypes import COMError
import ctypes
import UIAHandler

def createUIAMultiPropertyCondition(*dicts):
Expand Down Expand Up @@ -119,3 +120,71 @@ def iterUIARangeByUnit(rangeObj,unit):
if tempRange.CompareEndpoints(UIAHandler.TextPatternRangeEndpoint_End,rangeObj,UIAHandler.TextPatternRangeEndpoint_End)<0:
tempRange.MoveEndpointByRange(UIAHandler.TextPatternRangeEndpoint_End,rangeObj,UIAHandler.TextPatternRangeEndpoint_End)
yield tempRange.clone()

def getEnclosingElementWithCacheFromUIATextRange(textRange,cacheRequest):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a docstring would be good here. Only has to point out that it uses getEnclosingElementBuildCache or falls back to getting the element and then building the cache if getEnclosingElementBuildCache is not supported.

if not isinstance(textRange,UIAHandler.IUIAutomationTextRange):
raise ValueError("%s is not a text range"%textRange)
try:
textRange=textRange.QueryInterface(UIAHandler.IUIAutomationTextRange3)
except (COMError,AttributeError):
e=textRange.getEnclosingElement()
if e:
e=e.buildUpdatedCache(cacheRequest)
return e
return textRange.getEnclosingElementBuildCache(cacheRequest)

class CacheableUIAElementArray(object):

def __init__(self,elementArray,cacheRequest=None):
self._elementArray=elementArray
self._cacheRequest=cacheRequest

@property
def length(self):
return self._elementArray.length if self._elementArray else 0

def getElement(self,index):
e=self._elementArray.getElement(index)
if e and self._cacheRequest:
e=e.buildUpdatedCache(self._cacheRequest)
return e

def getChildrenWithCacheFromUIATextRange(textRange,cacheRequest):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring as above.

if not isinstance(textRange,UIAHandler.IUIAutomationTextRange):
raise ValueError("%s is not a text range"%textRange)
try:
textRange=textRange.QueryInterface(UIAHandler.IUIAutomationTextRange3)
except (COMError,AttributeError):
c=textRange.getChildren()
c=CacheableUIAElementArray(c,cacheRequest)
return c
c=textRange.getChildrenBuildCache(cacheRequest)
c=CacheableUIAElementArray(c)
return c

class UIATextRangeAttributeValueFetcher(object):

def __init__(self,textRange):
self.textRange=textRange

def getValue(self,ID,ignoreMixedValues=False):
val=self.textRange.getAttributeValue(ID)
if not ignoreMixedValues and val==UIAHandler.handler.ReservedMixedAttributeValue:
raise UIAMixedAttributeError
return val

class BulkUIATextRangeAttributeValueFetcher(UIATextRangeAttributeValueFetcher):

def __init__(self,textRange,IDs):
IDs=list(IDs)
self.IDsToValues={}
super(BulkUIATextRangeAttributeValueFetcher,self).__init__(textRange)
IDsArray=(ctypes.c_long*len(IDs))(*IDs)
values=textRange.GetAttributeValues(IDsArray,len(IDsArray))
self.IDsToValues={IDs[x]:values[x] for x in xrange(len(IDs))}

def getValue(self,ID,ignoreMixedValues=False):
val=self.IDsToValues[ID]
if not ignoreMixedValues and val==UIAHandler.handler.ReservedMixedAttributeValue:
raise UIAMixedAttributeError
return val
1 change: 1 addition & 0 deletions source/_UIAHandler.py
Expand Up @@ -18,6 +18,7 @@

from comtypes.gen.UIAutomationClient import *


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous blank line.

#Some new win8 UIA constants that could be missing
UIA_StyleIdAttributeId=40034
UIA_AnnotationAnnotationTypeIdPropertyId=30113
Expand Down
3 changes: 3 additions & 0 deletions source/comInterfaces/UIAutomationClient.py
@@ -0,0 +1,3 @@
from comtypes.gen import _944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0
globals().update(_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.__dict__)
__name__ = 'comtypes.gen.UIAutomationClient'