| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame*
frame) | 252 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame*
frame) |
| 253 { | 253 { |
| 254 if (!frame) | 254 if (!frame) |
| 255 return 0; | 255 return 0; |
| 256 if (!frame->document() || !frame->document()->isPluginDocument()) | 256 if (!frame->document() || !frame->document()->isPluginDocument()) |
| 257 return 0; | 257 return 0; |
| 258 PluginDocument* pluginDocument = toPluginDocument(frame->document()); | 258 PluginDocument* pluginDocument = toPluginDocument(frame->document()); |
| 259 return toWebPluginContainerImpl(pluginDocument->pluginWidget()); | 259 return toWebPluginContainerImpl(pluginDocument->pluginWidget()); |
| 260 } | 260 } |
| 261 | 261 |
| 262 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromNode(LocalFrame* f
rame, const WebNode& node) | 262 WebPluginContainerImpl* WebLocalFrameImpl::currentPluginContainer(LocalFrame* fr
ame, Node* node) |
| 263 { | 263 { |
| 264 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame); | 264 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame); |
| 265 if (pluginContainer) | 265 if (pluginContainer) |
| 266 return pluginContainer; | 266 return pluginContainer; |
| 267 return toWebPluginContainerImpl(node.pluginContainer()); | 267 |
| 268 if (!node) { |
| 269 DCHECK(frame->document()); |
| 270 node = frame->document()->focusedElement(); |
| 271 } |
| 272 return toWebPluginContainerImpl(WebNode::pluginContainerFromNode(node)); |
| 268 } | 273 } |
| 269 | 274 |
| 270 // Simple class to override some of PrintContext behavior. Some of the methods | 275 // Simple class to override some of PrintContext behavior. Some of the methods |
| 271 // made virtual so that they can be overridden by ChromePluginPrintContext. | 276 // made virtual so that they can be overridden by ChromePluginPrintContext. |
| 272 class ChromePrintContext : public PrintContext { | 277 class ChromePrintContext : public PrintContext { |
| 273 WTF_MAKE_NONCOPYABLE(ChromePrintContext); | 278 WTF_MAKE_NONCOPYABLE(ChromePrintContext); |
| 274 public: | 279 public: |
| 275 ChromePrintContext(LocalFrame* frame) | 280 ChromePrintContext(LocalFrame* frame) |
| 276 : PrintContext(frame) | 281 : PrintContext(frame) |
| 277 , m_printedPageWidth(0) | 282 , m_printedPageWidth(0) |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 IntPoint point = frame()->view()->viewportToContents(pointInViewport); | 1009 IntPoint point = frame()->view()->viewportToContents(pointInViewport); |
| 1005 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active); | 1010 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active); |
| 1006 const EphemeralRange range = frame()->rangeForPoint(result.roundedPointInInn
erNodeFrame()); | 1011 const EphemeralRange range = frame()->rangeForPoint(result.roundedPointInInn
erNodeFrame()); |
| 1007 if (range.isNull()) | 1012 if (range.isNull()) |
| 1008 return kNotFound; | 1013 return kNotFound; |
| 1009 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1014 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
| 1010 DCHECK(editable); | 1015 DCHECK(editable); |
| 1011 return PlainTextRange::create(*editable, range).start(); | 1016 return PlainTextRange::create(*editable, range).start(); |
| 1012 } | 1017 } |
| 1013 | 1018 |
| 1014 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) | 1019 bool WebLocalFrameImpl::executeCommand(const WebString& name) |
| 1015 { | 1020 { |
| 1016 DCHECK(frame()); | 1021 DCHECK(frame()); |
| 1017 | 1022 |
| 1018 if (name.length() <= 2) | 1023 if (name.length() <= 2) |
| 1019 return false; | 1024 return false; |
| 1020 | 1025 |
| 1021 // Since we don't have NSControl, we will convert the format of command | 1026 // Since we don't have NSControl, we will convert the format of command |
| 1022 // string and call the function on Editor directly. | 1027 // string and call the function on Editor directly. |
| 1023 String command = name; | 1028 String command = name; |
| 1024 | 1029 |
| 1025 // Make sure the first letter is upper case. | 1030 // Make sure the first letter is upper case. |
| 1026 command.replace(0, 1, command.substring(0, 1).upper()); | 1031 command.replace(0, 1, command.substring(0, 1).upper()); |
| 1027 | 1032 |
| 1028 // Remove the trailing ':' if existing. | 1033 // Remove the trailing ':' if existing. |
| 1029 if (command[command.length() - 1] == UChar(':')) | 1034 if (command[command.length() - 1] == UChar(':')) |
| 1030 command = command.substring(0, command.length() - 1); | 1035 command = command.substring(0, command.length() - 1); |
| 1031 | 1036 |
| 1032 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); | 1037 Node* pluginLookupContextNode = m_contextMenuNode && name == "Copy" ? m_cont
extMenuNode : nullptr; |
| 1038 WebPluginContainerImpl* pluginContainer = currentPluginContainer(frame(), pl
uginLookupContextNode); |
| 1033 if (pluginContainer && pluginContainer->executeEditCommand(name)) | 1039 if (pluginContainer && pluginContainer->executeEditCommand(name)) |
| 1034 return true; | 1040 return true; |
| 1035 | 1041 |
| 1036 return frame()->editor().executeCommand(command); | 1042 return frame()->editor().executeCommand(command); |
| 1037 } | 1043 } |
| 1038 | 1044 |
| 1039 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebString& v
alue, const WebNode& node) | 1045 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebString& v
alue) |
| 1040 { | 1046 { |
| 1041 DCHECK(frame()); | 1047 DCHECK(frame()); |
| 1042 | 1048 |
| 1043 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); | 1049 WebPluginContainerImpl* pluginContainer = currentPluginContainer(frame()); |
| 1044 if (pluginContainer && pluginContainer->executeEditCommand(name, value)) | 1050 if (pluginContainer && pluginContainer->executeEditCommand(name, value)) |
| 1045 return true; | 1051 return true; |
| 1046 | 1052 |
| 1047 return frame()->editor().executeCommand(name, value); | 1053 return frame()->editor().executeCommand(name, value); |
| 1048 } | 1054 } |
| 1049 | 1055 |
| 1050 bool WebLocalFrameImpl::isCommandEnabled(const WebString& name) const | 1056 bool WebLocalFrameImpl::isCommandEnabled(const WebString& name) const |
| 1051 { | 1057 { |
| 1052 DCHECK(frame()); | 1058 DCHECK(frame()); |
| 1053 return frame()->editor().createCommand(name).isEnabled(); | 1059 return frame()->editor().createCommand(name).isEnabled(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 frame()->selection().setCaretVisible(visible); | 1223 frame()->selection().setCaretVisible(visible); |
| 1218 } | 1224 } |
| 1219 | 1225 |
| 1220 VisiblePosition WebLocalFrameImpl::visiblePositionForViewportPoint(const WebPoin
t& pointInViewport) | 1226 VisiblePosition WebLocalFrameImpl::visiblePositionForViewportPoint(const WebPoin
t& pointInViewport) |
| 1221 { | 1227 { |
| 1222 return visiblePositionForContentsPoint(frame()->view()->viewportToContents(p
ointInViewport), frame()); | 1228 return visiblePositionForContentsPoint(frame()->view()->viewportToContents(p
ointInViewport), frame()); |
| 1223 } | 1229 } |
| 1224 | 1230 |
| 1225 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() | 1231 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() |
| 1226 { | 1232 { |
| 1227 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo
de(frame(), WebNode(frame()->document()->focusedElement())); | 1233 WebPluginContainerImpl* container = WebLocalFrameImpl::currentPluginContaine
r(frame()); |
| 1228 if (container && container->supportsInputMethod()) | 1234 if (container && container->supportsInputMethod()) |
| 1229 return container->plugin(); | 1235 return container->plugin(); |
| 1230 return 0; | 1236 return 0; |
| 1231 } | 1237 } |
| 1232 | 1238 |
| 1233 int WebLocalFrameImpl::printBegin(const WebPrintParams& printParams, const WebNo
de& constrainToNode) | 1239 int WebLocalFrameImpl::printBegin(const WebPrintParams& printParams, const WebNo
de& constrainToNode) |
| 1234 { | 1240 { |
| 1235 DCHECK(!frame()->document()->isFrameSet()); | 1241 DCHECK(!frame()->document()->isFrameSet()); |
| 1236 WebPluginContainerImpl* pluginContainer = nullptr; | 1242 WebPluginContainerImpl* pluginContainer = nullptr; |
| 1237 if (constrainToNode.isNull()) { | 1243 if (constrainToNode.isNull()) { |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 return WebSandboxFlags::None; | 2106 return WebSandboxFlags::None; |
| 2101 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); | 2107 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); |
| 2102 } | 2108 } |
| 2103 | 2109 |
| 2104 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) | 2110 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) |
| 2105 { | 2111 { |
| 2106 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); | 2112 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); |
| 2107 } | 2113 } |
| 2108 | 2114 |
| 2109 } // namespace blink | 2115 } // namespace blink |
| OLD | NEW |