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
Changes from 3 commits
fa76884
5091313
f66ce5d
f55b431
bb400d0
46cd6e6
996ddb5
41c1473
a30c217
0357e92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
#See the file COPYING for more details. | ||
|
||
from comtypes import COMError | ||
import ctypes | ||
import UIAHandler | ||
|
||
def createUIAMultiPropertyCondition(*dicts): | ||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
from comtypes.gen.UIAutomationClient import * | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
There was a problem hiding this comment.
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.