OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 return (renderer && (renderer->isTableCell() || renderer->isTableRow() || re
nderer->isTableSection() || renderer->isRenderTableCol())); | 418 return (renderer && (renderer->isTableCell() || renderer->isTableRow() || re
nderer->isTableSection() || renderer->isRenderTableCol())); |
419 } | 419 } |
420 | 420 |
421 const String& nonBreakingSpaceString() | 421 const String& nonBreakingSpaceString() |
422 { | 422 { |
423 DEFINE_STATIC_LOCAL(String, nonBreakingSpaceString, (&noBreakSpace, 1)); | 423 DEFINE_STATIC_LOCAL(String, nonBreakingSpaceString, (&noBreakSpace, 1)); |
424 return nonBreakingSpaceString; | 424 return nonBreakingSpaceString; |
425 } | 425 } |
426 | 426 |
427 // FIXME: need to dump this | 427 // FIXME: need to dump this |
428 bool isSpecialHTMLElement(const Node* n) | 428 static bool isSpecialHTMLElement(const Node& n) |
429 { | 429 { |
430 if (!n) | 430 if (!n.isHTMLElement()) |
431 return false; | 431 return false; |
432 | 432 |
433 if (!n->isHTMLElement()) | 433 if (n.isLink()) |
434 return false; | |
435 | |
436 if (n->isLink()) | |
437 return true; | 434 return true; |
438 | 435 |
439 RenderObject* renderer = n->renderer(); | 436 RenderObject* renderer = n.renderer(); |
440 if (!renderer) | 437 if (!renderer) |
441 return false; | 438 return false; |
442 | 439 |
443 if (renderer->style()->display() == TABLE || renderer->style()->display() ==
INLINE_TABLE) | 440 if (renderer->style()->display() == TABLE || renderer->style()->display() ==
INLINE_TABLE) |
444 return true; | 441 return true; |
445 | 442 |
446 if (renderer->style()->isFloating()) | 443 if (renderer->style()->isFloating()) |
447 return true; | 444 return true; |
448 | 445 |
449 return false; | 446 return false; |
450 } | 447 } |
451 | 448 |
452 static HTMLElement* firstInSpecialElement(const Position& pos) | 449 static HTMLElement* firstInSpecialElement(const Position& pos) |
453 { | 450 { |
454 Element* rootEditableElement = pos.containerNode()->rootEditableElement(); | 451 Element* rootEditableElement = pos.containerNode()->rootEditableElement(); |
455 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) { | 452 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) { |
456 if (isSpecialHTMLElement(n)) { | 453 if (isSpecialHTMLElement(*n)) { |
457 HTMLElement* specialElement = toHTMLElement(n); | 454 HTMLElement* specialElement = toHTMLElement(n); |
458 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); | 455 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); |
459 VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBe
foreNode(specialElement), DOWNSTREAM); | 456 VisiblePosition firstInElement = VisiblePosition(firstPositionInOrBe
foreNode(specialElement), DOWNSTREAM); |
460 if (isRenderedTableElement(specialElement) && vPos == firstInElement
.next()) | 457 if (isRenderedTableElement(specialElement) && vPos == firstInElement
.next()) |
461 return specialElement; | 458 return specialElement; |
462 if (vPos == firstInElement) | 459 if (vPos == firstInElement) |
463 return specialElement; | 460 return specialElement; |
464 } | 461 } |
465 } | 462 } |
466 return 0; | 463 return 0; |
467 } | 464 } |
468 | 465 |
469 static HTMLElement* lastInSpecialElement(const Position& pos) | 466 static HTMLElement* lastInSpecialElement(const Position& pos) |
470 { | 467 { |
471 Element* rootEditableElement = pos.containerNode()->rootEditableElement(); | 468 Element* rootEditableElement = pos.containerNode()->rootEditableElement(); |
472 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) { | 469 for (Node* n = pos.deprecatedNode(); n && n->rootEditableElement() == rootEd
itableElement; n = n->parentNode()) { |
473 if (isSpecialHTMLElement(n)) { | 470 if (isSpecialHTMLElement(*n)) { |
474 HTMLElement* specialElement = toHTMLElement(n); | 471 HTMLElement* specialElement = toHTMLElement(n); |
475 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); | 472 VisiblePosition vPos = VisiblePosition(pos, DOWNSTREAM); |
476 VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfte
rNode(specialElement), DOWNSTREAM); | 473 VisiblePosition lastInElement = VisiblePosition(lastPositionInOrAfte
rNode(specialElement), DOWNSTREAM); |
477 if (isRenderedTableElement(specialElement) && vPos == lastInElement.
previous()) | 474 if (isRenderedTableElement(specialElement) && vPos == lastInElement.
previous()) |
478 return specialElement; | 475 return specialElement; |
479 if (vPos == lastInElement) | 476 if (vPos == lastInElement) |
480 return specialElement; | 477 return specialElement; |
481 } | 478 } |
482 } | 479 } |
483 return 0; | 480 return 0; |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 // if the selection starts just before a paragraph break, skip over it | 1222 // if the selection starts just before a paragraph break, skip over it |
1226 if (isEndOfParagraph(visiblePosition)) | 1223 if (isEndOfParagraph(visiblePosition)) |
1227 return visiblePosition.next().deepEquivalent().downstream(); | 1224 return visiblePosition.next().deepEquivalent().downstream(); |
1228 | 1225 |
1229 // otherwise, make sure to be at the start of the first selected node, | 1226 // otherwise, make sure to be at the start of the first selected node, |
1230 // instead of possibly at the end of the last node before the selection | 1227 // instead of possibly at the end of the last node before the selection |
1231 return visiblePosition.deepEquivalent().downstream(); | 1228 return visiblePosition.deepEquivalent().downstream(); |
1232 } | 1229 } |
1233 | 1230 |
1234 } // namespace blink | 1231 } // namespace blink |
OLD | NEW |