OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 #include "core/editing/serializers/Serialization.h" | 113 #include "core/editing/serializers/Serialization.h" |
114 #include "core/editing/spellcheck/SpellChecker.h" | 114 #include "core/editing/spellcheck/SpellChecker.h" |
115 #include "core/fetch/ResourceFetcher.h" | 115 #include "core/fetch/ResourceFetcher.h" |
116 #include "core/fetch/SubstituteData.h" | 116 #include "core/fetch/SubstituteData.h" |
117 #include "core/frame/LocalDOMWindow.h" | 117 #include "core/frame/LocalDOMWindow.h" |
118 #include "core/frame/FrameHost.h" | 118 #include "core/frame/FrameHost.h" |
119 #include "core/frame/FrameView.h" | 119 #include "core/frame/FrameView.h" |
120 #include "core/frame/RemoteFrame.h" | 120 #include "core/frame/RemoteFrame.h" |
121 #include "core/frame/Settings.h" | 121 #include "core/frame/Settings.h" |
122 #include "core/frame/UseCounter.h" | 122 #include "core/frame/UseCounter.h" |
| 123 #include "core/frame/VisualViewport.h" |
123 #include "core/html/HTMLAnchorElement.h" | 124 #include "core/html/HTMLAnchorElement.h" |
124 #include "core/html/HTMLCollection.h" | 125 #include "core/html/HTMLCollection.h" |
125 #include "core/html/HTMLFormElement.h" | 126 #include "core/html/HTMLFormElement.h" |
126 #include "core/html/HTMLFrameElementBase.h" | 127 #include "core/html/HTMLFrameElementBase.h" |
127 #include "core/html/HTMLFrameOwnerElement.h" | 128 #include "core/html/HTMLFrameOwnerElement.h" |
128 #include "core/html/HTMLHeadElement.h" | 129 #include "core/html/HTMLHeadElement.h" |
129 #include "core/html/HTMLImageElement.h" | 130 #include "core/html/HTMLImageElement.h" |
130 #include "core/html/HTMLInputElement.h" | 131 #include "core/html/HTMLInputElement.h" |
131 #include "core/html/HTMLLinkElement.h" | 132 #include "core/html/HTMLLinkElement.h" |
132 #include "core/html/PluginDocument.h" | 133 #include "core/html/PluginDocument.h" |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1752 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
1752 v8::HandleScope handleScope(toIsolate(frame())); | 1753 v8::HandleScope handleScope(toIsolate(frame())); |
1753 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR
eturnValue(ScriptSourceCode(script)); | 1754 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR
eturnValue(ScriptSourceCode(script)); |
1754 if (result.IsEmpty() || !result->IsString()) | 1755 if (result.IsEmpty() || !result->IsString()) |
1755 return; | 1756 return; |
1756 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); | 1757 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); |
1757 if (!frame()->navigationScheduler().locationChangePending()) | 1758 if (!frame()->navigationScheduler().locationChangePending()) |
1758 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul
t, ownerDocument); | 1759 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul
t, ownerDocument); |
1759 } | 1760 } |
1760 | 1761 |
| 1762 HitTestResult WebLocalFrameImpl::hitTestResultForVisualViewportPos(const IntPoin
t& posInViewport) |
| 1763 { |
| 1764 IntPoint rootFramePoint(frame()->host()->visualViewport().viewportToRootFram
e(posInViewport)); |
| 1765 IntPoint docPoint(frame()->view()->rootFrameToContents(rootFramePoint)); |
| 1766 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(docPoint
, HitTestRequest::ReadOnly | HitTestRequest::Active); |
| 1767 result.setToShadowHostIfInUserAgentShadowRoot(); |
| 1768 return result; |
| 1769 } |
| 1770 |
1761 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader) | 1771 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader) |
1762 { | 1772 { |
1763 // Internally, Blink uses CommittedMultipleRealLoads to track whether the | 1773 // Internally, Blink uses CommittedMultipleRealLoads to track whether the |
1764 // next commit should create a new history item or not. Ensure we have | 1774 // next commit should create a new history item or not. Ensure we have |
1765 // reached that state. | 1775 // reached that state. |
1766 if (frameLoader.stateMachine()->committedMultipleRealLoads()) | 1776 if (frameLoader.stateMachine()->committedMultipleRealLoads()) |
1767 return; | 1777 return; |
1768 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult
ipleRealLoads); | 1778 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult
ipleRealLoads); |
1769 } | 1779 } |
1770 | 1780 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 void WebLocalFrameImpl::setFrameWidget(WebFrameWidget* frameWidget) | 2106 void WebLocalFrameImpl::setFrameWidget(WebFrameWidget* frameWidget) |
2097 { | 2107 { |
2098 m_frameWidget = frameWidget; | 2108 m_frameWidget = frameWidget; |
2099 } | 2109 } |
2100 | 2110 |
2101 WebFrameWidget* WebLocalFrameImpl::frameWidget() const | 2111 WebFrameWidget* WebLocalFrameImpl::frameWidget() const |
2102 { | 2112 { |
2103 return m_frameWidget; | 2113 return m_frameWidget; |
2104 } | 2114 } |
2105 | 2115 |
| 2116 void WebLocalFrameImpl::copyImageAt(const WebPoint& posInViewport) |
| 2117 { |
| 2118 HitTestResult result = hitTestResultForVisualViewportPos(posInViewport); |
| 2119 if (!isHTMLCanvasElement(result.innerNodeOrImageMapImage()) && result.absolu
teImageURL().isEmpty()) { |
| 2120 // There isn't actually an image at these coordinates. Might be because |
| 2121 // the window scrolled while the context menu was open or because the pa
ge |
| 2122 // changed itself between when we thought there was an image here and wh
en |
| 2123 // we actually tried to retreive the image. |
| 2124 // |
| 2125 // FIXME: implement a cache of the most recent HitTestResult to avoid ha
ving |
| 2126 // to do two hit tests. |
| 2127 return; |
| 2128 } |
| 2129 |
| 2130 frame()->editor().copyImage(result); |
| 2131 } |
| 2132 |
| 2133 void WebLocalFrameImpl::saveImageAt(const WebPoint& posInViewport) |
| 2134 { |
| 2135 Node* node = hitTestResultForVisualViewportPos(posInViewport).innerNodeOrIma
geMapImage(); |
| 2136 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node))) |
| 2137 return; |
| 2138 |
| 2139 String url = toElement(*node).imageSourceURL(); |
| 2140 if (!KURL(KURL(), url).protocolIsData()) |
| 2141 return; |
| 2142 |
| 2143 m_client->saveImageFromDataURL(url); |
| 2144 } |
| 2145 |
2106 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const | 2146 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const |
2107 { | 2147 { |
2108 if (!frame()) | 2148 if (!frame()) |
2109 return WebSandboxFlags::None; | 2149 return WebSandboxFlags::None; |
2110 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); | 2150 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); |
2111 } | 2151 } |
2112 | 2152 |
2113 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) | 2153 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) |
2114 { | 2154 { |
2115 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); | 2155 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); |
2116 } | 2156 } |
2117 | 2157 |
2118 void WebLocalFrameImpl::clearActiveFindMatch() | 2158 void WebLocalFrameImpl::clearActiveFindMatch() |
2119 { | 2159 { |
2120 ensureTextFinder().clearActiveFindMatch(); | 2160 ensureTextFinder().clearActiveFindMatch(); |
2121 } | 2161 } |
2122 | 2162 |
2123 } // namespace blink | 2163 } // namespace blink |
OLD | NEW |