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 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1343 return hasSelection() ? WebRect(IntRect(frame()->selection().bounds())) : We bRect(); | 1343 return hasSelection() ? WebRect(IntRect(frame()->selection().bounds())) : We bRect(); |
1344 } | 1344 } |
1345 | 1345 |
1346 bool WebLocalFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const | 1346 bool WebLocalFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const |
1347 { | 1347 { |
1348 if (!frame()) | 1348 if (!frame()) |
1349 return false; | 1349 return false; |
1350 return frame()->spellChecker().selectionStartHasSpellingMarkerFor(from, leng th); | 1350 return frame()->spellChecker().selectionStartHasSpellingMarkerFor(from, leng th); |
1351 } | 1351 } |
1352 | 1352 |
1353 void WebLocalFrameImpl::copyImageAt(const WebPoint& posInViewport) | |
1354 { | |
1355 if (!frame()) | |
dcheng
2016/05/24 07:18:08
Can this actually happen in practice?
brettw
2016/05/25 19:10:20
No idea, I just copied some other code in this fil
| |
1356 return; | |
1357 | |
1358 HitTestResult result = hitTestResultForVisualViewportPos(posInViewport); | |
1359 if (!isHTMLCanvasElement(result.innerNodeOrImageMapImage()) && result.absolu teImageURL().isEmpty()) { | |
1360 // There isn't actually an image at these coordinates. Might be because | |
1361 // the window scrolled while the context menu was open or because the pa ge | |
1362 // changed itself between when we thought there was an image here and wh en | |
1363 // we actually tried to retreive the image. | |
1364 // | |
1365 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving | |
1366 // to do two hit tests. | |
1367 return; | |
1368 } | |
1369 | |
1370 frame()->editor().copyImage(result); | |
1371 } | |
1372 | |
1373 void WebLocalFrameImpl::saveImageAt(const WebPoint& posInViewport) | |
1374 { | |
1375 if (!frame() || !m_client) | |
dcheng
2016/05/24 07:18:08
Ditto: can this actually happen? //content is call
| |
1376 return; | |
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 | |
1353 WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const | 1389 WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const |
1354 { | 1390 { |
1355 if (!frame()) | 1391 if (!frame()) |
1356 return WebString(); | 1392 return WebString(); |
1357 | 1393 |
1358 return WebString(frame()->layerTreeAsText(showDebugInfo ? LayerTreeIncludesD ebugInfo : LayerTreeNormal)); | 1394 return WebString(frame()->layerTreeAsText(showDebugInfo ? LayerTreeIncludesD ebugInfo : LayerTreeNormal)); |
1359 } | 1395 } |
1360 | 1396 |
1361 // WebLocalFrameImpl public ---------------------------------------------------- ----- | 1397 // WebLocalFrameImpl public ---------------------------------------------------- ----- |
1362 | 1398 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1798 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
1763 v8::HandleScope handleScope(toIsolate(frame())); | 1799 v8::HandleScope handleScope(toIsolate(frame())); |
1764 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR eturnValue(ScriptSourceCode(script)); | 1800 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR eturnValue(ScriptSourceCode(script)); |
1765 if (result.IsEmpty() || !result->IsString()) | 1801 if (result.IsEmpty() || !result->IsString()) |
1766 return; | 1802 return; |
1767 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); | 1803 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); |
1768 if (!frame()->navigationScheduler().locationChangePending()) | 1804 if (!frame()->navigationScheduler().locationChangePending()) |
1769 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul t, ownerDocument); | 1805 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResul t, ownerDocument); |
1770 } | 1806 } |
1771 | 1807 |
1808 HitTestResult WebLocalFrameImpl::hitTestResultForVisualViewportPos(const IntPoin t& posInViewport) | |
1809 { | |
1810 IntPoint rootFramePoint(frame()->host()->visualViewport().viewportToRootFram e(posInViewport)); | |
1811 IntPoint docPoint(frame()->view()->rootFrameToContents(rootFramePoint)); | |
1812 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(docPoint , HitTestRequest::ReadOnly | HitTestRequest::Active); | |
1813 result.setToShadowHostIfInUserAgentShadowRoot(); | |
1814 return result; | |
1815 } | |
1816 | |
1772 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader) | 1817 static void ensureFrameLoaderHasCommitted(FrameLoader& frameLoader) |
1773 { | 1818 { |
1774 // Internally, Blink uses CommittedMultipleRealLoads to track whether the | 1819 // Internally, Blink uses CommittedMultipleRealLoads to track whether the |
1775 // next commit should create a new history item or not. Ensure we have | 1820 // next commit should create a new history item or not. Ensure we have |
1776 // reached that state. | 1821 // reached that state. |
1777 if (frameLoader.stateMachine()->committedMultipleRealLoads()) | 1822 if (frameLoader.stateMachine()->committedMultipleRealLoads()) |
1778 return; | 1823 return; |
1779 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult ipleRealLoads); | 1824 frameLoader.stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedMult ipleRealLoads); |
1780 } | 1825 } |
1781 | 1826 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2106 return WebSandboxFlags::None; | 2151 return WebSandboxFlags::None; |
2107 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); | 2152 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); |
2108 } | 2153 } |
2109 | 2154 |
2110 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) | 2155 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) |
2111 { | 2156 { |
2112 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); | 2157 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); |
2113 } | 2158 } |
2114 | 2159 |
2115 } // namespace blink | 2160 } // namespace blink |
OLD | NEW |