| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 r.setToShadowHostIfInUserAgentShadowRoot(); | 159 r.setToShadowHostIfInUserAgentShadowRoot(); |
| 160 | 160 |
| 161 LocalFrame* selectedFrame = r.innerNodeFrame(); | 161 LocalFrame* selectedFrame = r.innerNodeFrame(); |
| 162 | 162 |
| 163 WebContextMenuData data; | 163 WebContextMenuData data; |
| 164 data.mousePosition = selectedFrame->view()->contentsToViewport( | 164 data.mousePosition = selectedFrame->view()->contentsToViewport( |
| 165 r.roundedPointInInnerNodeFrame()); | 165 r.roundedPointInInnerNodeFrame()); |
| 166 | 166 |
| 167 // Compute edit flags. | 167 // Compute edit flags. |
| 168 data.editFlags = WebContextMenuData::CanDoNone; | 168 data.editFlags = WebContextMenuData::CanDoNone; |
| 169 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo()) | 169 if (selectedFrame->document()->isHTMLDocument() || |
| 170 data.editFlags |= WebContextMenuData::CanUndo; | 170 selectedFrame->document()->isXHTMLDocument()) { |
| 171 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo()) | 171 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canUndo()) |
| 172 data.editFlags |= WebContextMenuData::CanRedo; | 172 data.editFlags |= WebContextMenuData::CanUndo; |
| 173 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut()) | 173 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canRedo()) |
| 174 data.editFlags |= WebContextMenuData::CanCut; | 174 data.editFlags |= WebContextMenuData::CanRedo; |
| 175 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy()) | 175 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCut()) |
| 176 data.editFlags |= WebContextMenuData::CanCopy; | 176 data.editFlags |= WebContextMenuData::CanCut; |
| 177 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste()) | 177 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canCopy()) |
| 178 data.editFlags |= WebContextMenuData::CanPaste; | 178 data.editFlags |= WebContextMenuData::CanCopy; |
| 179 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete()) | 179 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canPaste()) |
| 180 data.editFlags |= WebContextMenuData::CanDelete; | 180 data.editFlags |= WebContextMenuData::CanPaste; |
| 181 // We can always select all... | 181 if (toLocalFrame(m_webView->focusedCoreFrame())->editor().canDelete()) |
| 182 data.editFlags |= WebContextMenuData::CanSelectAll; | 182 data.editFlags |= WebContextMenuData::CanDelete; |
| 183 data.editFlags |= WebContextMenuData::CanTranslate; | 183 if (selectedFrame->document()->queryCommandEnabled("selectAll", |
| 184 ASSERT_NO_EXCEPTION)) |
| 185 data.editFlags |= WebContextMenuData::CanSelectAll; |
| 186 data.editFlags |= WebContextMenuData::CanTranslate; |
| 187 } |
| 184 | 188 |
| 185 // Links, Images, Media tags, and Image/Media-Links take preference over | 189 // Links, Images, Media tags, and Image/Media-Links take preference over |
| 186 // all else. | 190 // all else. |
| 187 data.linkURL = r.absoluteLinkURL(); | 191 data.linkURL = r.absoluteLinkURL(); |
| 188 | 192 |
| 189 if (r.innerNode()->isHTMLElement()) { | 193 if (r.innerNode()->isHTMLElement()) { |
| 190 HTMLElement* htmlElement = toHTMLElement(r.innerNode()); | 194 HTMLElement* htmlElement = toHTMLElement(r.innerNode()); |
| 191 if (!htmlElement->title().isEmpty()) { | 195 if (!htmlElement->title().isEmpty()) { |
| 192 data.titleText = htmlElement->title(); | 196 data.titleText = htmlElement->title(); |
| 193 } else { | 197 } else { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 subMenuItems.swap(outputItems); | 452 subMenuItems.swap(outputItems); |
| 449 } | 453 } |
| 450 | 454 |
| 451 void ContextMenuClientImpl::populateCustomMenuItems( | 455 void ContextMenuClientImpl::populateCustomMenuItems( |
| 452 const ContextMenu* defaultMenu, | 456 const ContextMenu* defaultMenu, |
| 453 WebContextMenuData* data) { | 457 WebContextMenuData* data) { |
| 454 populateSubMenuItems(defaultMenu->items(), data->customItems); | 458 populateSubMenuItems(defaultMenu->items(), data->customItems); |
| 455 } | 459 } |
| 456 | 460 |
| 457 } // namespace blink | 461 } // namespace blink |
| OLD | NEW |