Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: Source/core/editing/Editor.cpp

Issue 196683003: Use new is*Element() helper functions more in editing code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/EditingStyle.cpp ('k') | Source/core/editing/FormatBlockCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "core/html/HTMLInputElement.h" 73 #include "core/html/HTMLInputElement.h"
74 #include "core/html/HTMLTextAreaElement.h" 74 #include "core/html/HTMLTextAreaElement.h"
75 #include "core/html/parser/HTMLParserIdioms.h" 75 #include "core/html/parser/HTMLParserIdioms.h"
76 #include "core/loader/EmptyClients.h" 76 #include "core/loader/EmptyClients.h"
77 #include "core/page/EditorClient.h" 77 #include "core/page/EditorClient.h"
78 #include "core/page/EventHandler.h" 78 #include "core/page/EventHandler.h"
79 #include "core/page/FocusController.h" 79 #include "core/page/FocusController.h"
80 #include "core/page/Page.h" 80 #include "core/page/Page.h"
81 #include "core/rendering/HitTestResult.h" 81 #include "core/rendering/HitTestResult.h"
82 #include "core/rendering/RenderImage.h" 82 #include "core/rendering/RenderImage.h"
83 #include "core/svg/SVGImageElement.h"
83 #include "platform/KillRing.h" 84 #include "platform/KillRing.h"
84 #include "platform/weborigin/KURL.h" 85 #include "platform/weborigin/KURL.h"
85 #include "wtf/unicode/CharacterNames.h" 86 #include "wtf/unicode/CharacterNames.h"
86 87
87 namespace WebCore { 88 namespace WebCore {
88 89
89 using namespace std; 90 using namespace std;
90 using namespace HTMLNames; 91 using namespace HTMLNames;
91 using namespace WTF; 92 using namespace WTF;
92 using namespace Unicode; 93 using namespace Unicode;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (!document) 218 if (!document)
218 return 0; 219 return 0;
219 if (!document->isImageDocument()) 220 if (!document->isImageDocument())
220 return 0; 221 return 0;
221 222
222 HTMLElement* body = document->body(); 223 HTMLElement* body = document->body();
223 if (!body) 224 if (!body)
224 return 0; 225 return 0;
225 226
226 Node* node = body->firstChild(); 227 Node* node = body->firstChild();
227 if (!node) 228 if (!isHTMLImageElement(node))
228 return 0;
229 if (!node->hasTagName(imgTag))
230 return 0; 229 return 0;
231 return toHTMLImageElement(node); 230 return toHTMLImageElement(node);
232 } 231 }
233 232
234 bool Editor::canCopy() const 233 bool Editor::canCopy() const
235 { 234 {
236 if (imageElementFromImageDocument(m_frame.document())) 235 if (imageElementFromImageDocument(m_frame.document()))
237 return true; 236 return true;
238 FrameSelection& selection = m_frame.selection(); 237 FrameSelection& selection = m_frame.selection();
239 return selection.isRange() && !selection.isInPasswordField(); 238 return selection.isRange() && !selection.isInPasswordField();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 432
434 RenderImage* renderer = toRenderImage(node->renderer()); 433 RenderImage* renderer = toRenderImage(node->renderer());
435 ImageResource* cachedImage = renderer->cachedImage(); 434 ImageResource* cachedImage = renderer->cachedImage();
436 if (!cachedImage || cachedImage->errorOccurred()) 435 if (!cachedImage || cachedImage->errorOccurred())
437 return; 436 return;
438 Image* image = cachedImage->imageForRenderer(renderer); 437 Image* image = cachedImage->imageForRenderer(renderer);
439 ASSERT(image); 438 ASSERT(image);
440 439
441 // FIXME: This should probably be reconciled with HitTestResult::absoluteIma geURL. 440 // FIXME: This should probably be reconciled with HitTestResult::absoluteIma geURL.
442 AtomicString urlString; 441 AtomicString urlString;
443 if (node->hasTagName(imgTag) || node->hasTagName(inputTag)) 442 if (isHTMLImageElement(*node) || isHTMLInputElement(*node))
444 urlString = toElement(node)->getAttribute(srcAttr); 443 urlString = toElement(node)->getAttribute(srcAttr);
445 else if (node->hasTagName(SVGNames::imageTag)) 444 else if (isSVGImageElement(*node))
446 urlString = toElement(node)->getAttribute(XLinkNames::hrefAttr); 445 urlString = toElement(node)->getAttribute(XLinkNames::hrefAttr);
447 else if (node->hasTagName(embedTag) || node->hasTagName(objectTag)) 446 else if (isHTMLEmbedElement(*node) || isHTMLObjectElement(*node))
448 urlString = toElement(node)->imageSourceURL(); 447 urlString = toElement(node)->imageSourceURL();
449 KURL url = urlString.isEmpty() ? KURL() : node->document().completeURL(strip LeadingAndTrailingHTMLSpaces(urlString)); 448 KURL url = urlString.isEmpty() ? KURL() : node->document().completeURL(strip LeadingAndTrailingHTMLSpaces(urlString));
450 449
451 pasteboard->writeImage(image, url, title); 450 pasteboard->writeImage(image, url, title);
452 } 451 }
453 452
454 // Returns whether caller should continue with "the default processing", which i s the same as 453 // Returns whether caller should continue with "the default processing", which i s the same as
455 // the event handler NOT setting the return value to false 454 // the event handler NOT setting the return value to false
456 bool Editor::dispatchCPPEvent(const AtomicString &eventType, ClipboardAccessPoli cy policy, PasteMode pasteMode) 455 bool Editor::dispatchCPPEvent(const AtomicString &eventType, ClipboardAccessPoli cy policy, PasteMode pasteMode)
457 { 456 {
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 return m_frame.spellChecker(); 1230 return m_frame.spellChecker();
1232 } 1231 }
1233 1232
1234 void Editor::toggleOverwriteModeEnabled() 1233 void Editor::toggleOverwriteModeEnabled()
1235 { 1234 {
1236 m_overwriteModeEnabled = !m_overwriteModeEnabled; 1235 m_overwriteModeEnabled = !m_overwriteModeEnabled;
1237 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 1236 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
1238 } 1237 }
1239 1238
1240 } // namespace WebCore 1239 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/EditingStyle.cpp ('k') | Source/core/editing/FormatBlockCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698