| OLD | NEW |
| (Empty) |
| 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 SKY_ENGINE_WEB_WEBLOCALFRAMEIMPL_H_ | |
| 32 #define SKY_ENGINE_WEB_WEBLOCALFRAMEIMPL_H_ | |
| 33 | |
| 34 #include "sky/engine/core/frame/LocalFrame.h" | |
| 35 #include "sky/engine/platform/fetcher/MojoFetcher.h" | |
| 36 #include "sky/engine/platform/geometry/FloatRect.h" | |
| 37 #include "sky/engine/public/web/WebLocalFrame.h" | |
| 38 #include "sky/engine/web/FrameLoaderClientImpl.h" | |
| 39 #include "sky/engine/wtf/Compiler.h" | |
| 40 #include "sky/engine/wtf/OwnPtr.h" | |
| 41 #include "sky/engine/wtf/RefCounted.h" | |
| 42 #include "sky/engine/wtf/text/WTFString.h" | |
| 43 | |
| 44 namespace blink { | |
| 45 | |
| 46 class GraphicsContext; | |
| 47 class IntSize; | |
| 48 class KURL; | |
| 49 class Node; | |
| 50 class Range; | |
| 51 class WebFrameClient; | |
| 52 class WebView; | |
| 53 class WebViewImpl; | |
| 54 | |
| 55 template <typename T> class WebVector; | |
| 56 | |
| 57 // Implementation of WebFrame, note that this is a reference counted object. | |
| 58 class WebLocalFrameImpl final | |
| 59 : public WebLocalFrame | |
| 60 , public MojoFetcher::Client | |
| 61 , public RefCounted<WebLocalFrameImpl> { | |
| 62 public: | |
| 63 // WebFrame methods: | |
| 64 virtual bool isWebLocalFrame() const override; | |
| 65 virtual WebLocalFrame* toWebLocalFrame() override; | |
| 66 virtual void close() override; | |
| 67 virtual WebSize contentsSize() const override; | |
| 68 virtual bool hasVisibleContent() const override; | |
| 69 virtual WebRect visibleContentRect() const override; | |
| 70 virtual WebView* view() const override; | |
| 71 virtual WebDocument document() const override; | |
| 72 virtual void executeScript(const WebScriptSource&) override; | |
| 73 virtual void addMessageToConsole(const WebConsoleMessage&) override; | |
| 74 virtual void collectGarbage() override; | |
| 75 virtual void load(const WebURL&); | |
| 76 virtual void loadFromDataPipeWithURL(mojo::ScopedDataPipeConsumerHandle, con
st WebURL&); | |
| 77 virtual void replaceSelection(const WebString&) override; | |
| 78 virtual void insertText(const WebString&) override; | |
| 79 virtual void setMarkedText(const WebString&, unsigned location, unsigned len
gth) override; | |
| 80 virtual void unmarkText() override; | |
| 81 virtual bool hasMarkedText() const override; | |
| 82 virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) ov
erride; | |
| 83 virtual bool executeCommand(const WebString&, const WebString& value, const
WebNode& = WebNode()) override; | |
| 84 virtual bool isCommandEnabled(const WebString&) const override; | |
| 85 virtual void enableContinuousSpellChecking(bool) override; | |
| 86 virtual bool isContinuousSpellCheckingEnabled() const override; | |
| 87 virtual void requestTextChecking(const WebElement&) override; | |
| 88 virtual void replaceMisspelledRange(const WebString&) override; | |
| 89 virtual void removeSpellingMarkers() override; | |
| 90 virtual bool hasSelection() const override; | |
| 91 virtual WebRange selectionRange() const override; | |
| 92 virtual WebString selectionAsText() const override; | |
| 93 virtual bool selectWordAroundCaret() override; | |
| 94 virtual void selectRange(const WebPoint& base, const WebPoint& extent) overr
ide; | |
| 95 virtual void selectRange(const WebRange&) override; | |
| 96 virtual void moveRangeSelection(const WebPoint& base, const WebPoint& extent
) override; | |
| 97 virtual void moveCaretSelection(const WebPoint&) override; | |
| 98 virtual bool setEditableSelectionOffsets(int start, int end) override; | |
| 99 virtual bool setCompositionFromExistingText(int compositionStart, int compos
itionEnd, const WebVector<WebCompositionUnderline>& underlines) override; | |
| 100 virtual void extendSelectionAndDelete(int before, int after) override; | |
| 101 virtual void setCaretVisible(bool) override; | |
| 102 | |
| 103 virtual WebString contentAsText(size_t maxChars) const override; | |
| 104 virtual WebString renderTreeAsText(RenderAsTextControls toShow = RenderAsTex
tNormal) const override; | |
| 105 | |
| 106 virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const
override; | |
| 107 | |
| 108 static WebLocalFrameImpl* create(WebFrameClient*); | |
| 109 virtual ~WebLocalFrameImpl(); | |
| 110 | |
| 111 PassRefPtr<LocalFrame> initializeCoreFrame(FrameHost*); | |
| 112 | |
| 113 void createFrameView(); | |
| 114 | |
| 115 static WebLocalFrameImpl* fromFrame(LocalFrame*); | |
| 116 static WebLocalFrameImpl* fromFrame(LocalFrame&); | |
| 117 | |
| 118 WebViewImpl* viewImpl() const; | |
| 119 | |
| 120 FrameView* frameView() const { return frame() ? frame()->view() : 0; } | |
| 121 | |
| 122 void didFail(const ResourceError&); | |
| 123 | |
| 124 LocalFrame* frame() const { return m_frame.get(); } | |
| 125 WebFrameClient* client() const { return m_client; } | |
| 126 void setClient(WebFrameClient* client) { m_client = client; } | |
| 127 | |
| 128 void setInputEventsTransformForEmulation(const IntSize&, float); | |
| 129 | |
| 130 static void selectWordAroundPosition(LocalFrame*, VisiblePosition); | |
| 131 | |
| 132 // Returns a hit-tested VisiblePosition for the given point | |
| 133 VisiblePosition visiblePositionForWindowPoint(const WebPoint&); | |
| 134 | |
| 135 private: | |
| 136 friend class FrameLoaderClientImpl; | |
| 137 | |
| 138 explicit WebLocalFrameImpl(WebFrameClient*); | |
| 139 | |
| 140 // Sets the local core frame and registers destruction observers. | |
| 141 void setCoreFrame(PassRefPtr<LocalFrame>); | |
| 142 | |
| 143 // MojoFetcher::Client | |
| 144 void OnReceivedResponse(mojo::URLResponsePtr) override; | |
| 145 | |
| 146 FrameLoaderClientImpl m_frameLoaderClientImpl; | |
| 147 | |
| 148 // The embedder retains a reference to the WebCore LocalFrame while it is ac
tive in the DOM. This | |
| 149 // reference is released when the frame is removed from the DOM or the entir
e page is closed. | |
| 150 // FIXME: These will need to change to WebFrame when we introduce WebFramePr
oxy. | |
| 151 RefPtr<LocalFrame> m_frame; | |
| 152 | |
| 153 WebFrameClient* m_client; | |
| 154 OwnPtr<MojoFetcher> m_fetcher; | |
| 155 | |
| 156 // Stores the additional input events offset and scale when device metrics e
mulation is enabled. | |
| 157 IntSize m_inputEventsOffsetForEmulation; | |
| 158 float m_inputEventsScaleFactorForEmulation; | |
| 159 }; | |
| 160 | |
| 161 DEFINE_TYPE_CASTS(WebLocalFrameImpl, WebFrame, frame, frame->isWebLocalFrame(),
frame.isWebLocalFrame()); | |
| 162 | |
| 163 } // namespace blink | |
| 164 | |
| 165 #endif // SKY_ENGINE_WEB_WEBLOCALFRAMEIMPL_H_ | |
| OLD | NEW |