Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2011 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1.  Redistributions of source code must retain the above copyright
      8  *     notice, this list of conditions and the following disclaimer.
      9  * 2.  Redistributions in binary form must reproduce the above copyright
     10  *     notice, this list of conditions and the following disclaimer in the
     11  *     documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     18  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
     20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     22  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     23  */
     24 
     25 #ifndef WebDOMTextContentWalker_h
     26 #define WebDOMTextContentWalker_h
     27 
     28 #include "../WebPrivateOwnPtr.h"
     29 #include "../WebRange.h"
     30 #include "../WebString.h"
     31 
     32 namespace WebCore {
     33 class DOMTextContentWalker;
     34 class Node;
     35 }
     36 
     37 namespace WebKit {
     38 
     39 class WebHitTestInfo;
     40 
     41 class WebDOMTextContentWalker {
     42 public:
     43     WebDOMTextContentWalker();
     44     ~WebDOMTextContentWalker();
     45 
     46     // Creates a new text content walker centered in the position described by the hit test.
     47     // The maximum length of the contents retrieved by the walker is defined by maxLength.
     48     WEBKIT_API WebDOMTextContentWalker(const WebHitTestInfo&, size_t maxLength);
     49 
     50     // Creates a new text content walker centered in the selected offset of the given text node.
     51     // The maximum length of the contents retrieved by the walker is defined by maxLength.
     52     WEBKIT_API WebDOMTextContentWalker(WebCore::Node* textNode, size_t offset, size_t maxLength);
     53 
     54     // Text content retrieved by the walker.
     55     WEBKIT_API WebString content() const;
     56 
     57     // Position of the initial text node offset in the content string.
     58     WEBKIT_API size_t hitOffsetInContent() const;
     59 
     60     // Convert start/end positions in the content text string into a WebKit text range.
     61     WEBKIT_API WebRange contentOffsetsToRange(size_t startInContent, size_t endInContent);
     62 
     63 protected:
     64     WebPrivateOwnPtr<WebCore::DOMTextContentWalker> m_private;
     65 };
     66 
     67 } // namespace WebKit
     68 
     69 #endif
     70