WebKit/chromium/public/WebWidget.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2009 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 are
       
     6  * met:
       
     7  *
       
     8  *     * Redistributions of source code must retain the above copyright
       
     9  * notice, this list of conditions and the following disclaimer.
       
    10  *     * Redistributions in binary form must reproduce the above
       
    11  * copyright notice, this list of conditions and the following disclaimer
       
    12  * in the documentation and/or other materials provided with the
       
    13  * distribution.
       
    14  *     * Neither the name of Google Inc. nor the names of its
       
    15  * contributors may be used to endorse or promote products derived from
       
    16  * this software without specific prior written permission.
       
    17  *
       
    18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
       
    19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
       
    20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
       
    21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
       
    22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
       
    23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
       
    24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
       
    25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
       
    26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    29  */
       
    30 
       
    31 #ifndef WebWidget_h
       
    32 #define WebWidget_h
       
    33 
       
    34 #include "WebCanvas.h"
       
    35 #include "WebCommon.h"
       
    36 #include "WebCompositionUnderline.h"
       
    37 #include "WebTextInputType.h"
       
    38 #include "WebTextDirection.h"
       
    39 
       
    40 namespace WebKit {
       
    41 
       
    42 class WebInputEvent;
       
    43 class WebString;
       
    44 struct WebRect;
       
    45 struct WebSize;
       
    46 template <typename T> class WebVector;
       
    47 
       
    48 class WebWidget {
       
    49 public:
       
    50     // This method closes and deletes the WebWidget.
       
    51     virtual void close() = 0;
       
    52 
       
    53     // Returns the current size of the WebWidget.
       
    54     virtual WebSize size() = 0;
       
    55 
       
    56     // Called to resize the WebWidget.
       
    57     virtual void resize(const WebSize&) = 0;
       
    58 
       
    59     // Called to layout the WebWidget.  This MUST be called before Paint,
       
    60     // and it may result in calls to WebWidgetClient::didInvalidateRect.
       
    61     virtual void layout() = 0;
       
    62 
       
    63     // Called to paint the specified region of the WebWidget onto the given
       
    64     // canvas.  You MUST call Layout before calling this method.  It is
       
    65     // okay to call paint multiple times once layout has been called,
       
    66     // assuming no other changes are made to the WebWidget (e.g., once
       
    67     // events are processed, it should be assumed that another call to
       
    68     // layout is warranted before painting again).
       
    69     virtual void paint(WebCanvas*, const WebRect&) = 0;
       
    70 
       
    71     // Called to inform the WebWidget of an input event.  Returns true if
       
    72     // the event has been processed, false otherwise.
       
    73     virtual bool handleInputEvent(const WebInputEvent&) = 0;
       
    74 
       
    75     // Called to inform the WebWidget that mouse capture was lost.
       
    76     virtual void mouseCaptureLost() = 0;
       
    77 
       
    78     // Called to inform the WebWidget that it has gained or lost keyboard focus.
       
    79     virtual void setFocus(bool) = 0;
       
    80 
       
    81     // Called to inform the WebWidget of a new composition text.
       
    82     // If selectionStart and selectionEnd has the same value, then it indicates
       
    83     // the input caret position. If the text is empty, then the existing
       
    84     // composition text will be cancelled.
       
    85     // Returns true if the composition text was set successfully.
       
    86     virtual bool setComposition(
       
    87         const WebString& text,
       
    88         const WebVector<WebCompositionUnderline>& underlines,
       
    89         int selectionStart,
       
    90         int selectionEnd) = 0;
       
    91 
       
    92     // Called to inform the WebWidget to confirm an ongoing composition.
       
    93     // Returns true if there is an ongoing composition.
       
    94     virtual bool confirmComposition() = 0;
       
    95 
       
    96     // Returns the current text input type of this WebWidget.
       
    97     virtual WebTextInputType textInputType() = 0;
       
    98 
       
    99     // Returns the current caret bounds of this WebWidget. The selection bounds
       
   100     // will be returned if a selection range is available.
       
   101     virtual WebRect caretOrSelectionBounds() = 0;
       
   102 
       
   103     // Changes the text direction of the selected input node.
       
   104     virtual void setTextDirection(WebTextDirection) = 0;
       
   105 
       
   106     // Returns true if the WebWidget uses GPU accelerated compositing
       
   107     // to render its contents.
       
   108     virtual bool isAcceleratedCompositingActive() const = 0;
       
   109 
       
   110 protected:
       
   111     ~WebWidget() { }
       
   112 };
       
   113 
       
   114 } // namespace WebKit
       
   115 
       
   116 #endif