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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2171493003: [Editing][DOM][CodeHealth] Make Node::hasEditableStyle global functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 // Get to the <iframe> or <frame> (or even <object>) element in the parent f rame. 788 // Get to the <iframe> or <frame> (or even <object>) element in the parent f rame.
789 // FIXME: Doesn't work for OOPI. 789 // FIXME: Doesn't work for OOPI.
790 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 790 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
791 if (!ownerElement) 791 if (!ownerElement)
792 return; 792 return;
793 ContainerNode* ownerElementParent = ownerElement->parentNode(); 793 ContainerNode* ownerElementParent = ownerElement->parentNode();
794 if (!ownerElementParent) 794 if (!ownerElementParent)
795 return; 795 return;
796 796
797 // This method's purpose is it to make it easier to select iframes (in order to delete them). Don't do anything if the iframe isn't deletable. 797 // This method's purpose is it to make it easier to select iframes (in order to delete them). Don't do anything if the iframe isn't deletable.
798 if (!ownerElementParent->hasEditableStyle()) 798 if (!blink::hasEditableStyle(*ownerElementParent))
799 return; 799 return;
800 800
801 // Create compute positions before and after the element. 801 // Create compute positions before and after the element.
802 unsigned ownerElementNodeIndex = ownerElement->nodeIndex(); 802 unsigned ownerElementNodeIndex = ownerElement->nodeIndex();
803 VisiblePosition beforeOwnerElement = createVisiblePosition(Position(ownerEle mentParent, ownerElementNodeIndex)); 803 VisiblePosition beforeOwnerElement = createVisiblePosition(Position(ownerEle mentParent, ownerElementNodeIndex));
804 VisiblePosition afterOwnerElement = createVisiblePosition(Position(ownerElem entParent, ownerElementNodeIndex + 1), VP_UPSTREAM_IF_POSSIBLE); 804 VisiblePosition afterOwnerElement = createVisiblePosition(Position(ownerElem entParent, ownerElementNodeIndex + 1), VP_UPSTREAM_IF_POSSIBLE);
805 805
806 // Focus on the parent frame, and then select from before this element to af ter. 806 // Focus on the parent frame, and then select from before this element to af ter.
807 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement); 807 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement);
808 page->focusController().setFocusedFrame(parent); 808 page->focusController().setFocusedFrame(parent);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 } 1178 }
1179 } 1179 }
1180 1180
1181 void FrameSelection::setSelectionFromNone() 1181 void FrameSelection::setSelectionFromNone()
1182 { 1182 {
1183 // Put a caret inside the body if the entire frame is editable (either the 1183 // Put a caret inside the body if the entire frame is editable (either the
1184 // entire WebView is editable or designMode is on for this document). 1184 // entire WebView is editable or designMode is on for this document).
1185 1185
1186 Document* document = m_frame->document(); 1186 Document* document = m_frame->document();
1187 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi ngEnabled(); 1187 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi ngEnabled();
1188 if (!isNone() || !(document->hasEditableStyle() || caretBrowsing)) 1188 if (!isNone() || !(blink::hasEditableStyle(*document) || caretBrowsing))
1189 return; 1189 return;
1190 1190
1191 Element* documentElement = document->documentElement(); 1191 Element* documentElement = document->documentElement();
1192 if (!documentElement) 1192 if (!documentElement)
1193 return; 1193 return;
1194 if (HTMLBodyElement* body = Traversal<HTMLBodyElement>::firstChild(*document Element)) 1194 if (HTMLBodyElement* body = Traversal<HTMLBodyElement>::firstChild(*document Element))
1195 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), TextAff inity::Downstream)); 1195 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), TextAff inity::Downstream));
1196 } 1196 }
1197 1197
1198 // TODO(yoichio): We should have LocalFrame having FrameCaret, 1198 // TODO(yoichio): We should have LocalFrame having FrameCaret,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 1381
1382 void showTree(const blink::FrameSelection* sel) 1382 void showTree(const blink::FrameSelection* sel)
1383 { 1383 {
1384 if (sel) 1384 if (sel)
1385 sel->showTreeForThis(); 1385 sel->showTreeForThis();
1386 else 1386 else
1387 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 1387 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
1388 } 1388 }
1389 1389
1390 #endif 1390 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698