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

Side by Side Diff: sky/engine/core/editing/VisibleUnits.cpp

Issue 928393003: Remove the concept of document.documentElement (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/core/editing/VisibleSelection.cpp ('k') | sky/engine/core/editing/htmlediting.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) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isE ditablePosition(p))->renderer(); 928 RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isE ditablePosition(p))->renderer();
929 Node* node = renderer.node(); 929 Node* node = renderer.node();
930 if (node && editingIgnoresContent(node)) 930 if (node && editingIgnoresContent(node))
931 return VisiblePosition(positionInParentBeforeNode(*node)); 931 return VisiblePosition(positionInParentBeforeNode(*node));
932 return VisiblePosition(renderer.positionForPoint(pointInLine)); 932 return VisiblePosition(renderer.positionForPoint(pointInLine));
933 } 933 }
934 934
935 // Could not find a previous line. This means we must already be on the firs t line. 935 // Could not find a previous line. This means we must already be on the firs t line.
936 // Move to the start of the content in this block, which effectively moves u s 936 // Move to the start of the content in this block, which effectively moves u s
937 // to the start of the line we're on. 937 // to the start of the line we're on.
938 Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEdit ableElement(editableType) : node->document().documentElement(); 938 ContainerNode* rootContainer = &node->document();
939 if (!rootElement) 939 if (node->hasEditableStyle(editableType))
940 rootContainer = node->rootEditableElement(editableType);
941 if (!rootContainer)
940 return VisiblePosition(); 942 return VisiblePosition();
941 return VisiblePosition(firstPositionInNode(rootElement), DOWNSTREAM); 943 return VisiblePosition(firstPositionInNode(rootContainer), DOWNSTREAM);
942 } 944 }
943 945
944 VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin eDirectionPoint, EditableType editableType) 946 VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin eDirectionPoint, EditableType editableType)
945 { 947 {
946 Position p = visiblePosition.deepEquivalent(); 948 Position p = visiblePosition.deepEquivalent();
947 Node* node = p.deprecatedNode(); 949 Node* node = p.deprecatedNode();
948 950
949 if (!node) 951 if (!node)
950 return VisiblePosition(); 952 return VisiblePosition();
951 953
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isE ditablePosition(p))->renderer(); 988 RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isE ditablePosition(p))->renderer();
987 Node* node = renderer.node(); 989 Node* node = renderer.node();
988 if (node && editingIgnoresContent(node)) 990 if (node && editingIgnoresContent(node))
989 return VisiblePosition(positionInParentBeforeNode(*node)); 991 return VisiblePosition(positionInParentBeforeNode(*node));
990 return VisiblePosition(renderer.positionForPoint(pointInLine)); 992 return VisiblePosition(renderer.positionForPoint(pointInLine));
991 } 993 }
992 994
993 // Could not find a next line. This means we must already be on the last lin e. 995 // Could not find a next line. This means we must already be on the last lin e.
994 // Move to the end of the content in this block, which effectively moves us 996 // Move to the end of the content in this block, which effectively moves us
995 // to the end of the line we're on. 997 // to the end of the line we're on.
996 Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEdit ableElement(editableType) : node->document().documentElement(); 998 ContainerNode* rootContainer = &node->document();
997 if (!rootElement) 999 if (node->hasEditableStyle(editableType))
1000 rootContainer = node->rootEditableElement(editableType);
1001 if (!rootContainer)
998 return VisiblePosition(); 1002 return VisiblePosition();
999 return VisiblePosition(lastPositionInNode(rootElement), DOWNSTREAM); 1003 return VisiblePosition(lastPositionInNode(rootContainer), DOWNSTREAM);
1000 } 1004 }
1001 1005
1002 // --------- 1006 // ---------
1003 1007
1004 static unsigned startSentenceBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&) 1008 static unsigned startSentenceBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&)
1005 { 1009 {
1006 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); 1010 TextBreakIterator* iterator = sentenceBreakIterator(characters, length);
1007 // FIXME: The following function can return -1; we don't handle that. 1011 // FIXME: The following function can return -1; we don't handle that.
1008 return iterator->preceding(length); 1012 return iterator->preceding(length);
1009 } 1013 }
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 1281
1278 bool isEndOfBlock(const VisiblePosition &pos) 1282 bool isEndOfBlock(const VisiblePosition &pos)
1279 { 1283 {
1280 return pos.isNotNull() && pos == endOfBlock(pos, CanCrossEditingBoundary); 1284 return pos.isNotNull() && pos == endOfBlock(pos, CanCrossEditingBoundary);
1281 } 1285 }
1282 1286
1283 // --------- 1287 // ---------
1284 1288
1285 VisiblePosition startOfDocument(const Node* node) 1289 VisiblePosition startOfDocument(const Node* node)
1286 { 1290 {
1287 if (!node || !node->document().documentElement()) 1291 if (!node)
1288 return VisiblePosition(); 1292 return VisiblePosition();
1289 1293
1290 return VisiblePosition(firstPositionInNode(node->document().documentElement( )), DOWNSTREAM); 1294 return VisiblePosition(firstPositionInNode(&node->document()), DOWNSTREAM);
1291 } 1295 }
1292 1296
1293 VisiblePosition startOfDocument(const VisiblePosition &c) 1297 VisiblePosition startOfDocument(const VisiblePosition &c)
1294 { 1298 {
1295 return startOfDocument(c.deepEquivalent().deprecatedNode()); 1299 return startOfDocument(c.deepEquivalent().deprecatedNode());
1296 } 1300 }
1297 1301
1298 VisiblePosition endOfDocument(const Node* node) 1302 VisiblePosition endOfDocument(const Node* node)
1299 { 1303 {
1300 if (!node || !node->document().documentElement()) 1304 if (!node)
1301 return VisiblePosition(); 1305 return VisiblePosition();
1302 1306
1303 Element* doc = node->document().documentElement(); 1307 return VisiblePosition(lastPositionInNode(&node->document()), DOWNSTREAM);
1304 return VisiblePosition(lastPositionInNode(doc), DOWNSTREAM);
1305 } 1308 }
1306 1309
1307 VisiblePosition endOfDocument(const VisiblePosition &c) 1310 VisiblePosition endOfDocument(const VisiblePosition &c)
1308 { 1311 {
1309 return endOfDocument(c.deepEquivalent().deprecatedNode()); 1312 return endOfDocument(c.deepEquivalent().deprecatedNode());
1310 } 1313 }
1311 1314
1312 bool isStartOfDocument(const VisiblePosition &p) 1315 bool isStartOfDocument(const VisiblePosition &p)
1313 { 1316 {
1314 return p.isNotNull() && p.previous(CanCrossEditingBoundary).isNull(); 1317 return p.isNotNull() && p.previous(CanCrossEditingBoundary).isNull();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 int caretOffset; 1373 int caretOffset;
1371 position.position().getInlineBoxAndOffset(position.affinity(), inlineBox, ca retOffset); 1374 position.position().getInlineBoxAndOffset(position.affinity(), inlineBox, ca retOffset);
1372 1375
1373 if (inlineBox) 1376 if (inlineBox)
1374 renderer = &inlineBox->renderer(); 1377 renderer = &inlineBox->renderer();
1375 1378
1376 return renderer->localCaretRect(inlineBox, caretOffset); 1379 return renderer->localCaretRect(inlineBox, caretOffset);
1377 } 1380 }
1378 1381
1379 } 1382 }
OLDNEW
« no previous file with comments | « sky/engine/core/editing/VisibleSelection.cpp ('k') | sky/engine/core/editing/htmlediting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698