Chromium Code Reviews| 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 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1348 return hasSelection() ? WebRect(IntRect(frame()->selection().bounds())) : We bRect(); | 1349 return hasSelection() ? WebRect(IntRect(frame()->selection().bounds())) : We bRect(); |
| 1349 } | 1350 } |
| 1350 | 1351 |
| 1351 bool WebLocalFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const | 1352 bool WebLocalFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const |
| 1352 { | 1353 { |
| 1353 if (!frame()) | 1354 if (!frame()) |
| 1354 return false; | 1355 return false; |
| 1355 return frame()->spellChecker().selectionStartHasSpellingMarkerFor(from, leng th); | 1356 return frame()->spellChecker().selectionStartHasSpellingMarkerFor(from, leng th); |
| 1356 } | 1357 } |
| 1357 | 1358 |
| 1359 void WebLocalFrameImpl::copyImageAt(const WebPoint& posInViewport) | |
| 1360 { | |
| 1361 HitTestResult result = hitTestResultForVisualViewportPos(posInViewport); | |
| 1362 if (!isHTMLCanvasElement(result.innerNodeOrImageMapImage()) && result.absolu teImageURL().isEmpty()) { | |
| 1363 // There isn't actually an image at these coordinates. Might be because | |
| 1364 // the window scrolled while the context menu was open or because the pa ge | |
| 1365 // changed itself between when we thought there was an image here and wh en | |
| 1366 // we actually tried to retreive the image. | |
| 1367 // | |
| 1368 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving | |
| 1369 // to do two hit tests. | |
| 1370 return; | |
| 1371 } | |
| 1372 | |
| 1373 frame()->editor().copyImage(result); | |
| 1374 } | |
| 1375 | |
| 1376 void WebLocalFrameImpl::saveImageAt(const WebPoint& posInViewport) | |
| 1377 { | |
| 1378 Node* node = hitTestResultForVisualViewportPos(posInViewport).innerNodeOrIma geMapImage(); | |
| 1379 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node))) | |
| 1380 return; | |
| 1381 | |
| 1382 String url = toElement(*node).imageSourceURL(); | |
| 1383 if (!KURL(KURL(), url).protocolIsData()) | |
| 1384 return; | |
| 1385 | |
| 1386 m_client->saveImageFromDataURL(url); | |
| 1387 } | |
| 1388 | |
| 1358 WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const | 1389 WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const |
| 1359 { | 1390 { |
| 1360 if (!frame()) | 1391 if (!frame()) |
| 1361 return WebString(); | 1392 return WebString(); |
| 1362 | 1393 |
| 1363 return WebString(frame()->layerTreeAsText(showDebugInfo ? LayerTreeIncludesD ebugInfo : LayerTreeNormal)); | 1394 return WebString(frame()->layerTreeAsText(showDebugInfo ? LayerTreeIncludesD ebugInfo : LayerTreeNormal)); |
| 1364 } | 1395 } |
| 1365 | 1396 |
| 1366 // WebLocalFrameImpl public ---------------------------------------------------- ----- | 1397 // WebLocalFrameImpl public ---------------------------------------------------- ----- |
| 1367 | 1398 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1751 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1782 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 1752 v8::HandleScope handleScope(toIsolate(frame())); | 1783 v8::HandleScope handleScope(toIsolate(frame())); |
| 1753 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR eturnValue(ScriptSourceCode(script)); | 1784 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR eturnValue(ScriptSourceCode(script)); |
| 1754 if (result.IsEmpty() || !result->IsString()) | 1785 if (result.IsEmpty() || !result->IsString()) |
| 1755 return; | 1786 return; |
| 1756 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); | 1787 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); |
| 1757 if (!frame()->navigationScheduler().locationChangePending()) | 1788 if (!frame()->navigationScheduler().locationChangePending()) |
| 1758 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul t, ownerDocument); | 1789 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul t, ownerDocument); |
| 1759 } | 1790 } |
| 1760 | 1791 |
| 1792 HitTestResult WebLocalFrameImpl::hitTestResultForVisualViewportPos(const IntPoin t& posInViewport) | |
| 1793 { | |
| 1794 IntPoint rootFramePoint(frame()->host()->visualViewport().viewportToRootFram e(posInViewport)); | |
|
dcheng
2016/06/08 16:00:35
+bokan, is this the right thing to do for a local
bokan
2016/06/08 16:13:27
Hmm...I'm not sure how VisualViewport behaves in O
alexmos
2016/06/08 16:40:33
Note that I recently did some work to sync the Vis
brettw
2016/06/09 23:41:01
I didn't make any changes here. If I should change
| |
| 1795 IntPoint docPoint(frame()->view()->rootFrameToContents(rootFramePoint)); | |
| 1796 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(docPoint , HitTestRequest::ReadOnly | HitTestRequest::Active); | |
| 1797 result.setToShadowHostIfInUserAgentShadowRoot(); | |
| 1798 return result; | |
| 1799 } | |
| 1800 | |
| 1761 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader) | 1801 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader) |
| 1762 { | 1802 { |
| 1763 // Internally, Blink uses CommittedMultipleRealLoads to track whether the | 1803 // Internally, Blink uses CommittedMultipleRealLoads to track whether the |
| 1764 // next commit should create a new history item or not. Ensure we have | 1804 // next commit should create a new history item or not. Ensure we have |
| 1765 // reached that state. | 1805 // reached that state. |
| 1766 if (frameLoader.stateMachine()->committedMultipleRealLoads()) | 1806 if (frameLoader.stateMachine()->committedMultipleRealLoads()) |
| 1767 return; | 1807 return; |
| 1768 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult ipleRealLoads); | 1808 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult ipleRealLoads); |
| 1769 } | 1809 } |
| 1770 | 1810 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |