OSDN Git Service

MSHTML VBufBackend: improve the code that tries to strip unneeded whitespace that...
authorMichael Curran <mick@kulgan.net>
Wed, 20 Jul 2011 03:16:23 +0000 (13:16 +1000)
committerMichael Curran <mick@kulgan.net>
Wed, 20 Jul 2011 03:16:23 +0000 (13:16 +1000)
This means it will no longer incorrectly remove the space that appears in a sentence straight after a link. The code however will always still collapse all remaining whitespace down to one single space, and also completely remove content that only has whitespace and nothing else.
The example document that showed this problem was: http://en.wikipedia.org/wiki/Big_Joe_Turner
The problem is in the intro paragraph.

nvdaHelper/vbufBackends/mshtml/mshtml.cpp
nvdaHelper/vbufBase/storage.h
user_docs/en/changes.t2t

index 6caab86..c44e616 100755 (executable)
@@ -298,7 +298,7 @@ inline int getIDFromHTMLDOMNode(IHTMLDOMNode* pHTMLDOMNode) {
        return ID;\r
 }\r
 \r
-inline wstring getTextFromHTMLDOMNode(IHTMLDOMNode* pHTMLDOMNode, bool allowPreformattedText) {\r
+inline wstring getTextFromHTMLDOMNode(IHTMLDOMNode* pHTMLDOMNode, bool allowPreformattedText, bool isStartOfBlock) {\r
        int res=0;\r
        IHTMLDOMTextNode* pHTMLDOMTextNode=NULL;\r
        LOG_DEBUG(L"Trying to get an IHTMLDOMTextNode interface pointer");\r
@@ -316,22 +316,26 @@ inline wstring getTextFromHTMLDOMNode(IHTMLDOMNode* pHTMLDOMNode, bool allowPref
        }\r
        LOG_DEBUG(L"Got data from IHTMLDOMTextNode");\r
        wstring s;\r
+       bool notAllWhitespace=false;\r
        if(allowPreformattedText) {\r
                s.append(data);\r
        } else {\r
                bool lastNotWhitespace=false;\r
+               bool strippingLeft=isStartOfBlock;\r
                for(wchar_t* c=data;*c;++c) {\r
                        if(!iswspace(*c)) {\r
                                s+=*c;\r
                                lastNotWhitespace=TRUE;\r
-                       } else if(lastNotWhitespace) {\r
+                               notAllWhitespace=true;\r
+                               strippingLeft=false;\r
+                       } else if(lastNotWhitespace||!strippingLeft) {\r
                                s+=L' ';\r
                                lastNotWhitespace=FALSE;\r
                        } \r
                }\r
        }\r
        SysFreeString(data);\r
-       return s;\r
+       return notAllWhitespace?s:L"";\r
 }\r
 \r
 #define macro_addHTMLCurrentStyleToNodeAttrs(styleName,attrName,node,currentStyleObj,tempBSTR) {\\r
@@ -645,7 +649,7 @@ VBufStorage_fieldNode_t* MshtmlVBufBackend_t::fillVBuf(VBufStorage_buffer_t* buf
 \r
        //Handle text nodes\r
        { \r
-               wstring s=getTextFromHTMLDOMNode(pHTMLDOMNode,allowPreformattedText);\r
+               wstring s=getTextFromHTMLDOMNode(pHTMLDOMNode,allowPreformattedText,(parentNode&&parentNode->getIsBlock()&&!previousNode));\r
                if(!s.empty()) {\r
                        LOG_DEBUG(L"Got text from node");\r
                        VBufStorage_textFieldNode_t* textNode=buffer->addTextFieldNode(parentNode,previousNode,s);\r
index 436f98c..bef2efd 100644 (file)
@@ -286,6 +286,13 @@ class VBufStorage_fieldNode_t {
        void setIsBlock(bool isBlock);\r
 \r
 /**\r
+ * Getter for isBlock\r
+ */\r
+       bool getIsBlock() {\r
+               return isBlock;\r
+       }\r
+\r
+/**\r
  * Retreave the length of this node.\r
  */\r
        int getLength();\r
index c3c10bf..b3d6700 100644 (file)
@@ -112,6 +112,7 @@ Highlights of this release include major improvements concerning punctuation and
 - NVDA no longer temporarily freezes or refuses to speak when in the Move to / Copy to dialogs in Windows Live Mail. (#574)\r
 - In Outlook 2010, NVDA will now correctly track the focus in the message list. (#1285)\r
 - Some USB connection issues have been resolved with the MDV Lilli braille display. (#241)\r
+- In Internet explorer and other MSHTML controls, spaces are no longer ignored in browse mode in certain cases (e.g. after a link).\r
 \r
 \r
 == Changes for Developers ==\r