OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
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 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 LayoutObject* layoutObject = node->layoutObject(); | 213 LayoutObject* layoutObject = node->layoutObject(); |
214 if (!layoutObject || !layoutObject->isBox()) | 214 if (!layoutObject || !layoutObject->isBox()) |
215 return nullptr; | 215 return nullptr; |
216 | 216 |
217 return toLayoutBox(layoutObject)->getScrollableArea(); | 217 return toLayoutBox(layoutObject)->getScrollableArea(); |
218 } | 218 } |
219 | 219 |
220 static RuntimeEnabledFeatures::Backup* sFeaturesBackup = nullptr; | 220 static RuntimeEnabledFeatures::Backup* sFeaturesBackup = nullptr; |
221 | 221 |
222 void Internals::resetToConsistentState(Page* page) { | 222 void Internals::resetToConsistentState(Page* page) { |
223 ASSERT(page); | 223 DCHECK(page); |
224 | 224 |
225 if (!sFeaturesBackup) | 225 if (!sFeaturesBackup) |
226 sFeaturesBackup = new RuntimeEnabledFeatures::Backup; | 226 sFeaturesBackup = new RuntimeEnabledFeatures::Backup; |
227 sFeaturesBackup->restore(); | 227 sFeaturesBackup->restore(); |
228 page->setIsCursorVisible(true); | 228 page->setIsCursorVisible(true); |
229 page->setPageScaleFactor(1); | 229 page->setPageScaleFactor(1); |
230 page->deprecatedLocalMainFrame() | 230 page->deprecatedLocalMainFrame() |
231 ->view() | 231 ->view() |
232 ->layoutViewportScrollableArea() | 232 ->layoutViewportScrollableArea() |
233 ->setScrollOffset(ScrollOffset(), ProgrammaticScroll); | 233 ->setScrollOffset(ScrollOffset(), ProgrammaticScroll); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 String Internals::address(Node* node) { | 280 String Internals::address(Node* node) { |
281 char buf[32]; | 281 char buf[32]; |
282 sprintf(buf, "%p", node); | 282 sprintf(buf, "%p", node); |
283 | 283 |
284 return String(buf); | 284 return String(buf); |
285 } | 285 } |
286 | 286 |
287 GCObservation* Internals::observeGC(ScriptValue scriptValue) { | 287 GCObservation* Internals::observeGC(ScriptValue scriptValue) { |
288 v8::Local<v8::Value> observedValue = scriptValue.v8Value(); | 288 v8::Local<v8::Value> observedValue = scriptValue.v8Value(); |
289 ASSERT(!observedValue.IsEmpty()); | 289 DCHECK(!observedValue.IsEmpty()); |
290 if (observedValue->IsNull() || observedValue->IsUndefined()) { | 290 if (observedValue->IsNull() || observedValue->IsUndefined()) { |
291 V8ThrowException::throwTypeError(v8::Isolate::GetCurrent(), | 291 V8ThrowException::throwTypeError(v8::Isolate::GetCurrent(), |
292 "value to observe is null or undefined"); | 292 "value to observe is null or undefined"); |
293 return nullptr; | 293 return nullptr; |
294 } | 294 } |
295 | 295 |
296 return GCObservation::create(observedValue); | 296 return GCObservation::create(observedValue); |
297 } | 297 } |
298 | 298 |
299 unsigned Internals::updateStyleAndReturnAffectedElementCount( | 299 unsigned Internals::updateStyleAndReturnAffectedElementCount( |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if (!document) | 437 if (!document) |
438 return String(); | 438 return String(); |
439 Resource* resource = document->fetcher()->allResources().get( | 439 Resource* resource = document->fetcher()->allResources().get( |
440 URLTestHelpers::toKURL(url.utf8().data())); | 440 URLTestHelpers::toKURL(url.utf8().data())); |
441 if (!resource) | 441 if (!resource) |
442 return String(); | 442 return String(); |
443 return resource->resourceRequest().httpHeaderField(header.utf8().data()); | 443 return resource->resourceRequest().httpHeaderField(header.utf8().data()); |
444 } | 444 } |
445 | 445 |
446 bool Internals::isSharingStyle(Element* element1, Element* element2) const { | 446 bool Internals::isSharingStyle(Element* element1, Element* element2) const { |
447 ASSERT(element1 && element2); | 447 DCHECK(element1 && element2); |
448 return element1->computedStyle() == element2->computedStyle(); | 448 return element1->computedStyle() == element2->computedStyle(); |
449 } | 449 } |
450 | 450 |
451 bool Internals::isValidContentSelect(Element* insertionPoint, | 451 bool Internals::isValidContentSelect(Element* insertionPoint, |
452 ExceptionState& exceptionState) { | 452 ExceptionState& exceptionState) { |
453 ASSERT(insertionPoint); | 453 DCHECK(insertionPoint); |
454 if (!insertionPoint->isInsertionPoint()) { | 454 if (!insertionPoint->isInsertionPoint()) { |
455 exceptionState.throwDOMException(InvalidAccessError, | 455 exceptionState.throwDOMException(InvalidAccessError, |
456 "The element is not an insertion point."); | 456 "The element is not an insertion point."); |
457 return false; | 457 return false; |
458 } | 458 } |
459 | 459 |
460 return isHTMLContentElement(*insertionPoint) && | 460 return isHTMLContentElement(*insertionPoint) && |
461 toHTMLContentElement(*insertionPoint).isSelectValid(); | 461 toHTMLContentElement(*insertionPoint).isSelectValid(); |
462 } | 462 } |
463 | 463 |
464 Node* Internals::treeScopeRootNode(Node* node) { | 464 Node* Internals::treeScopeRootNode(Node* node) { |
465 ASSERT(node); | 465 DCHECK(node); |
466 return &node->treeScope().rootNode(); | 466 return &node->treeScope().rootNode(); |
467 } | 467 } |
468 | 468 |
469 Node* Internals::parentTreeScope(Node* node) { | 469 Node* Internals::parentTreeScope(Node* node) { |
470 ASSERT(node); | 470 DCHECK(node); |
471 const TreeScope* parentTreeScope = node->treeScope().parentTreeScope(); | 471 const TreeScope* parentTreeScope = node->treeScope().parentTreeScope(); |
472 return parentTreeScope ? &parentTreeScope->rootNode() : 0; | 472 return parentTreeScope ? &parentTreeScope->rootNode() : 0; |
473 } | 473 } |
474 | 474 |
475 bool Internals::hasSelectorForIdInShadow(Element* host, | 475 bool Internals::hasSelectorForIdInShadow(Element* host, |
476 const AtomicString& idValue, | 476 const AtomicString& idValue, |
477 ExceptionState& exceptionState) { | 477 ExceptionState& exceptionState) { |
478 ASSERT(host); | 478 DCHECK(host); |
479 if (!host->shadow() || host->shadow()->isV1()) { | 479 if (!host->shadow() || host->shadow()->isV1()) { |
480 exceptionState.throwDOMException( | 480 exceptionState.throwDOMException( |
481 InvalidAccessError, "The host element does not have a v0 shadow."); | 481 InvalidAccessError, "The host element does not have a v0 shadow."); |
482 return false; | 482 return false; |
483 } | 483 } |
484 | 484 |
485 return host->shadow()->v0().ensureSelectFeatureSet().hasSelectorForId( | 485 return host->shadow()->v0().ensureSelectFeatureSet().hasSelectorForId( |
486 idValue); | 486 idValue); |
487 } | 487 } |
488 | 488 |
489 bool Internals::hasSelectorForClassInShadow(Element* host, | 489 bool Internals::hasSelectorForClassInShadow(Element* host, |
490 const AtomicString& className, | 490 const AtomicString& className, |
491 ExceptionState& exceptionState) { | 491 ExceptionState& exceptionState) { |
492 ASSERT(host); | 492 DCHECK(host); |
493 if (!host->shadow() || host->shadow()->isV1()) { | 493 if (!host->shadow() || host->shadow()->isV1()) { |
494 exceptionState.throwDOMException( | 494 exceptionState.throwDOMException( |
495 InvalidAccessError, "The host element does not have a v0 shadow."); | 495 InvalidAccessError, "The host element does not have a v0 shadow."); |
496 return false; | 496 return false; |
497 } | 497 } |
498 | 498 |
499 return host->shadow()->v0().ensureSelectFeatureSet().hasSelectorForClass( | 499 return host->shadow()->v0().ensureSelectFeatureSet().hasSelectorForClass( |
500 className); | 500 className); |
501 } | 501 } |
502 | 502 |
503 bool Internals::hasSelectorForAttributeInShadow( | 503 bool Internals::hasSelectorForAttributeInShadow( |
504 Element* host, | 504 Element* host, |
505 const AtomicString& attributeName, | 505 const AtomicString& attributeName, |
506 ExceptionState& exceptionState) { | 506 ExceptionState& exceptionState) { |
507 ASSERT(host); | 507 DCHECK(host); |
508 if (!host->shadow() || host->shadow()->isV1()) { | 508 if (!host->shadow() || host->shadow()->isV1()) { |
509 exceptionState.throwDOMException( | 509 exceptionState.throwDOMException( |
510 InvalidAccessError, "The host element does not have a v0 shadow."); | 510 InvalidAccessError, "The host element does not have a v0 shadow."); |
511 return false; | 511 return false; |
512 } | 512 } |
513 | 513 |
514 return host->shadow()->v0().ensureSelectFeatureSet().hasSelectorForAttribute( | 514 return host->shadow()->v0().ensureSelectFeatureSet().hasSelectorForAttribute( |
515 attributeName); | 515 attributeName); |
516 } | 516 } |
517 | 517 |
518 unsigned short Internals::compareTreeScopePosition( | 518 unsigned short Internals::compareTreeScopePosition( |
519 const Node* node1, | 519 const Node* node1, |
520 const Node* node2, | 520 const Node* node2, |
521 ExceptionState& exceptionState) const { | 521 ExceptionState& exceptionState) const { |
522 ASSERT(node1 && node2); | 522 DCHECK(node1 && node2); |
523 const TreeScope* treeScope1 = | 523 const TreeScope* treeScope1 = |
524 node1->isDocumentNode() | 524 node1->isDocumentNode() |
525 ? static_cast<const TreeScope*>(toDocument(node1)) | 525 ? static_cast<const TreeScope*>(toDocument(node1)) |
526 : node1->isShadowRoot() | 526 : node1->isShadowRoot() |
527 ? static_cast<const TreeScope*>(toShadowRoot(node1)) | 527 ? static_cast<const TreeScope*>(toShadowRoot(node1)) |
528 : 0; | 528 : 0; |
529 const TreeScope* treeScope2 = | 529 const TreeScope* treeScope2 = |
530 node2->isDocumentNode() | 530 node2->isDocumentNode() |
531 ? static_cast<const TreeScope*>(toDocument(node2)) | 531 ? static_cast<const TreeScope*>(toDocument(node2)) |
532 : node2->isShadowRoot() | 532 : node2->isShadowRoot() |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 animation->disableCompositedAnimationForTesting(); | 567 animation->disableCompositedAnimationForTesting(); |
568 } | 568 } |
569 | 569 |
570 void Internals::disableCSSAdditiveAnimations() { | 570 void Internals::disableCSSAdditiveAnimations() { |
571 RuntimeEnabledFeatures::setCSSAdditiveAnimationsEnabled(false); | 571 RuntimeEnabledFeatures::setCSSAdditiveAnimationsEnabled(false); |
572 } | 572 } |
573 | 573 |
574 void Internals::advanceTimeForImage(Element* image, | 574 void Internals::advanceTimeForImage(Element* image, |
575 double deltaTimeInSeconds, | 575 double deltaTimeInSeconds, |
576 ExceptionState& exceptionState) { | 576 ExceptionState& exceptionState) { |
577 ASSERT(image); | 577 DCHECK(image); |
578 if (deltaTimeInSeconds < 0) { | 578 if (deltaTimeInSeconds < 0) { |
579 exceptionState.throwDOMException( | 579 exceptionState.throwDOMException( |
580 InvalidAccessError, ExceptionMessages::indexExceedsMinimumBound( | 580 InvalidAccessError, ExceptionMessages::indexExceedsMinimumBound( |
581 "deltaTimeInSeconds", deltaTimeInSeconds, 0.0)); | 581 "deltaTimeInSeconds", deltaTimeInSeconds, 0.0)); |
582 return; | 582 return; |
583 } | 583 } |
584 | 584 |
585 ImageResourceContent* resource = nullptr; | 585 ImageResourceContent* resource = nullptr; |
586 if (isHTMLImageElement(*image)) { | 586 if (isHTMLImageElement(*image)) { |
587 resource = toHTMLImageElement(*image).cachedImage(); | 587 resource = toHTMLImageElement(*image).cachedImage(); |
(...skipping 16 matching lines...) Expand all Loading... |
604 exceptionState.throwDOMException( | 604 exceptionState.throwDOMException( |
605 InvalidAccessError, "The image resource is not a BitmapImage type."); | 605 InvalidAccessError, "The image resource is not a BitmapImage type."); |
606 return; | 606 return; |
607 } | 607 } |
608 | 608 |
609 imageData->advanceTime(deltaTimeInSeconds); | 609 imageData->advanceTime(deltaTimeInSeconds); |
610 } | 610 } |
611 | 611 |
612 void Internals::advanceImageAnimation(Element* image, | 612 void Internals::advanceImageAnimation(Element* image, |
613 ExceptionState& exceptionState) { | 613 ExceptionState& exceptionState) { |
614 ASSERT(image); | 614 DCHECK(image); |
615 | 615 |
616 ImageResourceContent* resource = nullptr; | 616 ImageResourceContent* resource = nullptr; |
617 if (isHTMLImageElement(*image)) { | 617 if (isHTMLImageElement(*image)) { |
618 resource = toHTMLImageElement(*image).cachedImage(); | 618 resource = toHTMLImageElement(*image).cachedImage(); |
619 } else if (isSVGImageElement(*image)) { | 619 } else if (isSVGImageElement(*image)) { |
620 resource = toSVGImageElement(*image).cachedImage(); | 620 resource = toSVGImageElement(*image).cachedImage(); |
621 } else { | 621 } else { |
622 exceptionState.throwDOMException( | 622 exceptionState.throwDOMException( |
623 InvalidAccessError, "The element provided is not a image element."); | 623 InvalidAccessError, "The element provided is not a image element."); |
624 return; | 624 return; |
625 } | 625 } |
626 | 626 |
627 if (!resource || !resource->hasImage()) { | 627 if (!resource || !resource->hasImage()) { |
628 exceptionState.throwDOMException(InvalidAccessError, | 628 exceptionState.throwDOMException(InvalidAccessError, |
629 "The image resource is not available."); | 629 "The image resource is not available."); |
630 return; | 630 return; |
631 } | 631 } |
632 | 632 |
633 Image* imageData = resource->getImage(); | 633 Image* imageData = resource->getImage(); |
634 imageData->advanceAnimationForTesting(); | 634 imageData->advanceAnimationForTesting(); |
635 } | 635 } |
636 | 636 |
637 bool Internals::hasShadowInsertionPoint(const Node* root, | 637 bool Internals::hasShadowInsertionPoint(const Node* root, |
638 ExceptionState& exceptionState) const { | 638 ExceptionState& exceptionState) const { |
639 ASSERT(root); | 639 DCHECK(root); |
640 if (!root->isShadowRoot()) { | 640 if (!root->isShadowRoot()) { |
641 exceptionState.throwDOMException(InvalidAccessError, | 641 exceptionState.throwDOMException(InvalidAccessError, |
642 "The node argument is not a shadow root."); | 642 "The node argument is not a shadow root."); |
643 return false; | 643 return false; |
644 } | 644 } |
645 return toShadowRoot(root)->containsShadowElements(); | 645 return toShadowRoot(root)->containsShadowElements(); |
646 } | 646 } |
647 | 647 |
648 bool Internals::hasContentElement(const Node* root, | 648 bool Internals::hasContentElement(const Node* root, |
649 ExceptionState& exceptionState) const { | 649 ExceptionState& exceptionState) const { |
650 ASSERT(root); | 650 DCHECK(root); |
651 if (!root->isShadowRoot()) { | 651 if (!root->isShadowRoot()) { |
652 exceptionState.throwDOMException(InvalidAccessError, | 652 exceptionState.throwDOMException(InvalidAccessError, |
653 "The node argument is not a shadow root."); | 653 "The node argument is not a shadow root."); |
654 return false; | 654 return false; |
655 } | 655 } |
656 return toShadowRoot(root)->containsContentElements(); | 656 return toShadowRoot(root)->containsContentElements(); |
657 } | 657 } |
658 | 658 |
659 size_t Internals::countElementShadow(const Node* root, | 659 size_t Internals::countElementShadow(const Node* root, |
660 ExceptionState& exceptionState) const { | 660 ExceptionState& exceptionState) const { |
661 ASSERT(root); | 661 DCHECK(root); |
662 if (!root->isShadowRoot()) { | 662 if (!root->isShadowRoot()) { |
663 exceptionState.throwDOMException(InvalidAccessError, | 663 exceptionState.throwDOMException(InvalidAccessError, |
664 "The node argument is not a shadow root."); | 664 "The node argument is not a shadow root."); |
665 return 0; | 665 return 0; |
666 } | 666 } |
667 return toShadowRoot(root)->childShadowRootCount(); | 667 return toShadowRoot(root)->childShadowRootCount(); |
668 } | 668 } |
669 | 669 |
670 Node* Internals::nextSiblingInFlatTree(Node* node, | 670 Node* Internals::nextSiblingInFlatTree(Node* node, |
671 ExceptionState& exceptionState) { | 671 ExceptionState& exceptionState) { |
672 ASSERT(node); | 672 DCHECK(node); |
673 if (!node->canParticipateInFlatTree()) { | 673 if (!node->canParticipateInFlatTree()) { |
674 exceptionState.throwDOMException( | 674 exceptionState.throwDOMException( |
675 InvalidAccessError, | 675 InvalidAccessError, |
676 "The node argument doesn't particite in the flat tree."); | 676 "The node argument doesn't particite in the flat tree."); |
677 return 0; | 677 return 0; |
678 } | 678 } |
679 return FlatTreeTraversal::nextSibling(*node); | 679 return FlatTreeTraversal::nextSibling(*node); |
680 } | 680 } |
681 | 681 |
682 Node* Internals::firstChildInFlatTree(Node* node, | 682 Node* Internals::firstChildInFlatTree(Node* node, |
683 ExceptionState& exceptionState) { | 683 ExceptionState& exceptionState) { |
684 ASSERT(node); | 684 DCHECK(node); |
685 if (!node->canParticipateInFlatTree()) { | 685 if (!node->canParticipateInFlatTree()) { |
686 exceptionState.throwDOMException( | 686 exceptionState.throwDOMException( |
687 InvalidAccessError, | 687 InvalidAccessError, |
688 "The node argument doesn't particite in the flat tree"); | 688 "The node argument doesn't particite in the flat tree"); |
689 return 0; | 689 return 0; |
690 } | 690 } |
691 return FlatTreeTraversal::firstChild(*node); | 691 return FlatTreeTraversal::firstChild(*node); |
692 } | 692 } |
693 | 693 |
694 Node* Internals::lastChildInFlatTree(Node* node, | 694 Node* Internals::lastChildInFlatTree(Node* node, |
695 ExceptionState& exceptionState) { | 695 ExceptionState& exceptionState) { |
696 ASSERT(node); | 696 DCHECK(node); |
697 if (!node->canParticipateInFlatTree()) { | 697 if (!node->canParticipateInFlatTree()) { |
698 exceptionState.throwDOMException( | 698 exceptionState.throwDOMException( |
699 InvalidAccessError, | 699 InvalidAccessError, |
700 "The node argument doesn't particite in the flat tree."); | 700 "The node argument doesn't particite in the flat tree."); |
701 return 0; | 701 return 0; |
702 } | 702 } |
703 return FlatTreeTraversal::lastChild(*node); | 703 return FlatTreeTraversal::lastChild(*node); |
704 } | 704 } |
705 | 705 |
706 Node* Internals::nextInFlatTree(Node* node, ExceptionState& exceptionState) { | 706 Node* Internals::nextInFlatTree(Node* node, ExceptionState& exceptionState) { |
707 ASSERT(node); | 707 DCHECK(node); |
708 if (!node->canParticipateInFlatTree()) { | 708 if (!node->canParticipateInFlatTree()) { |
709 exceptionState.throwDOMException( | 709 exceptionState.throwDOMException( |
710 InvalidAccessError, | 710 InvalidAccessError, |
711 "The node argument doesn't particite in the flat tree."); | 711 "The node argument doesn't particite in the flat tree."); |
712 return 0; | 712 return 0; |
713 } | 713 } |
714 return FlatTreeTraversal::next(*node); | 714 return FlatTreeTraversal::next(*node); |
715 } | 715 } |
716 | 716 |
717 Node* Internals::previousInFlatTree(Node* node, | 717 Node* Internals::previousInFlatTree(Node* node, |
718 ExceptionState& exceptionState) { | 718 ExceptionState& exceptionState) { |
719 ASSERT(node); | 719 DCHECK(node); |
720 if (!node->canParticipateInFlatTree()) { | 720 if (!node->canParticipateInFlatTree()) { |
721 exceptionState.throwDOMException( | 721 exceptionState.throwDOMException( |
722 InvalidAccessError, | 722 InvalidAccessError, |
723 "The node argument doesn't particite in the flat tree."); | 723 "The node argument doesn't particite in the flat tree."); |
724 return 0; | 724 return 0; |
725 } | 725 } |
726 return FlatTreeTraversal::previous(*node); | 726 return FlatTreeTraversal::previous(*node); |
727 } | 727 } |
728 | 728 |
729 String Internals::elementLayoutTreeAsText(Element* element, | 729 String Internals::elementLayoutTreeAsText(Element* element, |
730 ExceptionState& exceptionState) { | 730 ExceptionState& exceptionState) { |
731 ASSERT(element); | 731 DCHECK(element); |
732 element->document().view()->updateAllLifecyclePhases(); | 732 element->document().view()->updateAllLifecyclePhases(); |
733 | 733 |
734 String representation = externalRepresentation(element); | 734 String representation = externalRepresentation(element); |
735 if (representation.isEmpty()) { | 735 if (representation.isEmpty()) { |
736 exceptionState.throwDOMException( | 736 exceptionState.throwDOMException( |
737 InvalidAccessError, | 737 InvalidAccessError, |
738 "The element provided has no external representation."); | 738 "The element provided has no external representation."); |
739 return String(); | 739 return String(); |
740 } | 740 } |
741 | 741 |
742 return representation; | 742 return representation; |
743 } | 743 } |
744 | 744 |
745 CSSStyleDeclaration* Internals::computedStyleIncludingVisitedInfo( | 745 CSSStyleDeclaration* Internals::computedStyleIncludingVisitedInfo( |
746 Node* node) const { | 746 Node* node) const { |
747 ASSERT(node); | 747 DCHECK(node); |
748 bool allowVisitedStyle = true; | 748 bool allowVisitedStyle = true; |
749 return CSSComputedStyleDeclaration::create(node, allowVisitedStyle); | 749 return CSSComputedStyleDeclaration::create(node, allowVisitedStyle); |
750 } | 750 } |
751 | 751 |
752 ShadowRoot* Internals::createUserAgentShadowRoot(Element* host) { | 752 ShadowRoot* Internals::createUserAgentShadowRoot(Element* host) { |
753 ASSERT(host); | 753 DCHECK(host); |
754 return &host->ensureUserAgentShadowRoot(); | 754 return &host->ensureUserAgentShadowRoot(); |
755 } | 755 } |
756 | 756 |
757 ShadowRoot* Internals::shadowRoot(Element* host) { | 757 ShadowRoot* Internals::shadowRoot(Element* host) { |
758 // FIXME: Internals::shadowRoot() in tests should be converted to | 758 // FIXME: Internals::shadowRoot() in tests should be converted to |
759 // youngestShadowRoot() or oldestShadowRoot(). | 759 // youngestShadowRoot() or oldestShadowRoot(). |
760 // https://bugs.webkit.org/show_bug.cgi?id=78465 | 760 // https://bugs.webkit.org/show_bug.cgi?id=78465 |
761 return youngestShadowRoot(host); | 761 return youngestShadowRoot(host); |
762 } | 762 } |
763 | 763 |
764 ShadowRoot* Internals::youngestShadowRoot(Element* host) { | 764 ShadowRoot* Internals::youngestShadowRoot(Element* host) { |
765 ASSERT(host); | 765 DCHECK(host); |
766 if (ElementShadow* shadow = host->shadow()) | 766 if (ElementShadow* shadow = host->shadow()) |
767 return &shadow->youngestShadowRoot(); | 767 return &shadow->youngestShadowRoot(); |
768 return 0; | 768 return 0; |
769 } | 769 } |
770 | 770 |
771 ShadowRoot* Internals::oldestShadowRoot(Element* host) { | 771 ShadowRoot* Internals::oldestShadowRoot(Element* host) { |
772 ASSERT(host); | 772 DCHECK(host); |
773 if (ElementShadow* shadow = host->shadow()) | 773 if (ElementShadow* shadow = host->shadow()) |
774 return &shadow->oldestShadowRoot(); | 774 return &shadow->oldestShadowRoot(); |
775 return 0; | 775 return 0; |
776 } | 776 } |
777 | 777 |
778 ShadowRoot* Internals::youngerShadowRoot(Node* shadow, | 778 ShadowRoot* Internals::youngerShadowRoot(Node* shadow, |
779 ExceptionState& exceptionState) { | 779 ExceptionState& exceptionState) { |
780 ASSERT(shadow); | 780 DCHECK(shadow); |
781 if (!shadow->isShadowRoot()) { | 781 if (!shadow->isShadowRoot()) { |
782 exceptionState.throwDOMException(InvalidAccessError, | 782 exceptionState.throwDOMException(InvalidAccessError, |
783 "The node provided is not a shadow root."); | 783 "The node provided is not a shadow root."); |
784 return 0; | 784 return 0; |
785 } | 785 } |
786 | 786 |
787 return toShadowRoot(shadow)->youngerShadowRoot(); | 787 return toShadowRoot(shadow)->youngerShadowRoot(); |
788 } | 788 } |
789 | 789 |
790 String Internals::shadowRootType(const Node* root, | 790 String Internals::shadowRootType(const Node* root, |
791 ExceptionState& exceptionState) const { | 791 ExceptionState& exceptionState) const { |
792 ASSERT(root); | 792 DCHECK(root); |
793 if (!root->isShadowRoot()) { | 793 if (!root->isShadowRoot()) { |
794 exceptionState.throwDOMException(InvalidAccessError, | 794 exceptionState.throwDOMException(InvalidAccessError, |
795 "The node provided is not a shadow root."); | 795 "The node provided is not a shadow root."); |
796 return String(); | 796 return String(); |
797 } | 797 } |
798 | 798 |
799 switch (toShadowRoot(root)->type()) { | 799 switch (toShadowRoot(root)->type()) { |
800 case ShadowRootType::UserAgent: | 800 case ShadowRootType::UserAgent: |
801 return String("UserAgentShadowRoot"); | 801 return String("UserAgentShadowRoot"); |
802 case ShadowRootType::V0: | 802 case ShadowRootType::V0: |
803 return String("V0ShadowRoot"); | 803 return String("V0ShadowRoot"); |
804 case ShadowRootType::Open: | 804 case ShadowRootType::Open: |
805 return String("OpenShadowRoot"); | 805 return String("OpenShadowRoot"); |
806 case ShadowRootType::Closed: | 806 case ShadowRootType::Closed: |
807 return String("ClosedShadowRoot"); | 807 return String("ClosedShadowRoot"); |
808 default: | 808 default: |
809 ASSERT_NOT_REACHED(); | 809 ASSERT_NOT_REACHED(); |
810 return String("Unknown"); | 810 return String("Unknown"); |
811 } | 811 } |
812 } | 812 } |
813 | 813 |
814 const AtomicString& Internals::shadowPseudoId(Element* element) { | 814 const AtomicString& Internals::shadowPseudoId(Element* element) { |
815 ASSERT(element); | 815 DCHECK(element); |
816 return element->shadowPseudoId(); | 816 return element->shadowPseudoId(); |
817 } | 817 } |
818 | 818 |
819 String Internals::visiblePlaceholder(Element* element) { | 819 String Internals::visiblePlaceholder(Element* element) { |
820 if (element && isTextControlElement(*element)) { | 820 if (element && isTextControlElement(*element)) { |
821 const TextControlElement& textControlElement = | 821 const TextControlElement& textControlElement = |
822 toTextControlElement(*element); | 822 toTextControlElement(*element); |
823 if (!textControlElement.isPlaceholderVisible()) | 823 if (!textControlElement.isPlaceholderVisible()) |
824 return String(); | 824 return String(); |
825 if (HTMLElement* placeholderElement = | 825 if (HTMLElement* placeholderElement = |
826 textControlElement.placeholderElement()) | 826 textControlElement.placeholderElement()) |
827 return placeholderElement->textContent(); | 827 return placeholderElement->textContent(); |
828 } | 828 } |
829 | 829 |
830 return String(); | 830 return String(); |
831 } | 831 } |
832 | 832 |
833 void Internals::selectColorInColorChooser(Element* element, | 833 void Internals::selectColorInColorChooser(Element* element, |
834 const String& colorValue) { | 834 const String& colorValue) { |
835 ASSERT(element); | 835 DCHECK(element); |
836 if (!isHTMLInputElement(*element)) | 836 if (!isHTMLInputElement(*element)) |
837 return; | 837 return; |
838 Color color; | 838 Color color; |
839 if (!color.setFromString(colorValue)) | 839 if (!color.setFromString(colorValue)) |
840 return; | 840 return; |
841 toHTMLInputElement(*element).selectColorInColorChooser(color); | 841 toHTMLInputElement(*element).selectColorInColorChooser(color); |
842 } | 842 } |
843 | 843 |
844 void Internals::endColorChooser(Element* element) { | 844 void Internals::endColorChooser(Element* element) { |
845 ASSERT(element); | 845 DCHECK(element); |
846 if (!isHTMLInputElement(*element)) | 846 if (!isHTMLInputElement(*element)) |
847 return; | 847 return; |
848 toHTMLInputElement(*element).endColorChooser(); | 848 toHTMLInputElement(*element).endColorChooser(); |
849 } | 849 } |
850 | 850 |
851 bool Internals::hasAutofocusRequest(Document* document) { | 851 bool Internals::hasAutofocusRequest(Document* document) { |
852 if (!document) | 852 if (!document) |
853 document = m_document; | 853 document = m_document; |
854 return document->autofocusElement(); | 854 return document->autofocusElement(); |
855 } | 855 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 exceptionState.throwDOMException( | 899 exceptionState.throwDOMException( |
900 InvalidAccessError, "The document's frame cannot be retrieved."); | 900 InvalidAccessError, "The document's frame cannot be retrieved."); |
901 return ClientRect::create(); | 901 return ClientRect::create(); |
902 } | 902 } |
903 | 903 |
904 m_document->updateStyleAndLayoutIgnorePendingStylesheets(); | 904 m_document->updateStyleAndLayoutIgnorePendingStylesheets(); |
905 return ClientRect::create(frame()->selection().absoluteCaretBounds()); | 905 return ClientRect::create(frame()->selection().absoluteCaretBounds()); |
906 } | 906 } |
907 | 907 |
908 ClientRect* Internals::boundingBox(Element* element) { | 908 ClientRect* Internals::boundingBox(Element* element) { |
909 ASSERT(element); | 909 DCHECK(element); |
910 | 910 |
911 element->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 911 element->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
912 LayoutObject* layoutObject = element->layoutObject(); | 912 LayoutObject* layoutObject = element->layoutObject(); |
913 if (!layoutObject) | 913 if (!layoutObject) |
914 return ClientRect::create(); | 914 return ClientRect::create(); |
915 return ClientRect::create( | 915 return ClientRect::create( |
916 layoutObject->absoluteBoundingBoxRectIgnoringTransforms()); | 916 layoutObject->absoluteBoundingBoxRectIgnoringTransforms()); |
917 } | 917 } |
918 | 918 |
919 void Internals::setMarker(Document* document, | 919 void Internals::setMarker(Document* document, |
(...skipping 15 matching lines...) Expand all Loading... |
935 } | 935 } |
936 | 936 |
937 document->updateStyleAndLayoutIgnorePendingStylesheets(); | 937 document->updateStyleAndLayoutIgnorePendingStylesheets(); |
938 document->markers().addMarker(range->startPosition(), range->endPosition(), | 938 document->markers().addMarker(range->startPosition(), range->endPosition(), |
939 type.value()); | 939 type.value()); |
940 } | 940 } |
941 | 941 |
942 unsigned Internals::markerCountForNode(Node* node, | 942 unsigned Internals::markerCountForNode(Node* node, |
943 const String& markerType, | 943 const String& markerType, |
944 ExceptionState& exceptionState) { | 944 ExceptionState& exceptionState) { |
945 ASSERT(node); | 945 DCHECK(node); |
946 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes = | 946 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes = |
947 markerTypesFrom(markerType); | 947 markerTypesFrom(markerType); |
948 if (!markerTypes) { | 948 if (!markerTypes) { |
949 exceptionState.throwDOMException( | 949 exceptionState.throwDOMException( |
950 SyntaxError, | 950 SyntaxError, |
951 "The marker type provided ('" + markerType + "') is invalid."); | 951 "The marker type provided ('" + markerType + "') is invalid."); |
952 return 0; | 952 return 0; |
953 } | 953 } |
954 | 954 |
955 return node->document() | 955 return node->document() |
956 .markers() | 956 .markers() |
957 .markersFor(node, markerTypes.value()) | 957 .markersFor(node, markerTypes.value()) |
958 .size(); | 958 .size(); |
959 } | 959 } |
960 | 960 |
961 unsigned Internals::activeMarkerCountForNode(Node* node) { | 961 unsigned Internals::activeMarkerCountForNode(Node* node) { |
962 ASSERT(node); | 962 DCHECK(node); |
963 | 963 |
964 // Only TextMatch markers can be active. | 964 // Only TextMatch markers can be active. |
965 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; | 965 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; |
966 DocumentMarkerVector markers = | 966 DocumentMarkerVector markers = |
967 node->document().markers().markersFor(node, markerType); | 967 node->document().markers().markersFor(node, markerType); |
968 | 968 |
969 unsigned activeMarkerCount = 0; | 969 unsigned activeMarkerCount = 0; |
970 for (const auto& marker : markers) { | 970 for (const auto& marker : markers) { |
971 if (marker->activeMatch()) | 971 if (marker->activeMatch()) |
972 activeMarkerCount++; | 972 activeMarkerCount++; |
973 } | 973 } |
974 | 974 |
975 return activeMarkerCount; | 975 return activeMarkerCount; |
976 } | 976 } |
977 | 977 |
978 DocumentMarker* Internals::markerAt(Node* node, | 978 DocumentMarker* Internals::markerAt(Node* node, |
979 const String& markerType, | 979 const String& markerType, |
980 unsigned index, | 980 unsigned index, |
981 ExceptionState& exceptionState) { | 981 ExceptionState& exceptionState) { |
982 ASSERT(node); | 982 DCHECK(node); |
983 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes = | 983 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes = |
984 markerTypesFrom(markerType); | 984 markerTypesFrom(markerType); |
985 if (!markerTypes) { | 985 if (!markerTypes) { |
986 exceptionState.throwDOMException( | 986 exceptionState.throwDOMException( |
987 SyntaxError, | 987 SyntaxError, |
988 "The marker type provided ('" + markerType + "') is invalid."); | 988 "The marker type provided ('" + markerType + "') is invalid."); |
989 return 0; | 989 return 0; |
990 } | 990 } |
991 | 991 |
992 DocumentMarkerVector markers = | 992 DocumentMarkerVector markers = |
993 node->document().markers().markersFor(node, markerTypes.value()); | 993 node->document().markers().markersFor(node, markerTypes.value()); |
994 if (markers.size() <= index) | 994 if (markers.size() <= index) |
995 return 0; | 995 return 0; |
996 return markers[index]; | 996 return markers[index]; |
997 } | 997 } |
998 | 998 |
999 Range* Internals::markerRangeForNode(Node* node, | 999 Range* Internals::markerRangeForNode(Node* node, |
1000 const String& markerType, | 1000 const String& markerType, |
1001 unsigned index, | 1001 unsigned index, |
1002 ExceptionState& exceptionState) { | 1002 ExceptionState& exceptionState) { |
1003 ASSERT(node); | 1003 DCHECK(node); |
1004 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); | 1004 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); |
1005 if (!marker) | 1005 if (!marker) |
1006 return nullptr; | 1006 return nullptr; |
1007 return Range::create(node->document(), node, marker->startOffset(), node, | 1007 return Range::create(node->document(), node, marker->startOffset(), node, |
1008 marker->endOffset()); | 1008 marker->endOffset()); |
1009 } | 1009 } |
1010 | 1010 |
1011 String Internals::markerDescriptionForNode(Node* node, | 1011 String Internals::markerDescriptionForNode(Node* node, |
1012 const String& markerType, | 1012 const String& markerType, |
1013 unsigned index, | 1013 unsigned index, |
1014 ExceptionState& exceptionState) { | 1014 ExceptionState& exceptionState) { |
1015 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); | 1015 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); |
1016 if (!marker) | 1016 if (!marker) |
1017 return String(); | 1017 return String(); |
1018 return marker->description(); | 1018 return marker->description(); |
1019 } | 1019 } |
1020 | 1020 |
1021 void Internals::addTextMatchMarker(const Range* range, bool isActive) { | 1021 void Internals::addTextMatchMarker(const Range* range, bool isActive) { |
1022 ASSERT(range); | 1022 DCHECK(range); |
1023 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets(); | 1023 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets(); |
1024 range->ownerDocument().markers().addTextMatchMarker(EphemeralRange(range), | 1024 range->ownerDocument().markers().addTextMatchMarker(EphemeralRange(range), |
1025 isActive); | 1025 isActive); |
1026 | 1026 |
1027 // This simulates what the production code does after | 1027 // This simulates what the production code does after |
1028 // DocumentMarkerController::addTextMatchMarker(). | 1028 // DocumentMarkerController::addTextMatchMarker(). |
1029 range->ownerDocument().view()->invalidatePaintForTickmarks(); | 1029 range->ownerDocument().view()->invalidatePaintForTickmarks(); |
1030 } | 1030 } |
1031 | 1031 |
1032 static bool parseColor(const String& value, | 1032 static bool parseColor(const String& value, |
(...skipping 24 matching lines...) Expand all Loading... |
1057 range->ownerDocument().markers().addCompositionMarker( | 1057 range->ownerDocument().markers().addCompositionMarker( |
1058 range->startPosition(), range->endPosition(), underlineColor, thick, | 1058 range->startPosition(), range->endPosition(), underlineColor, thick, |
1059 backgroundColor); | 1059 backgroundColor); |
1060 } | 1060 } |
1061 } | 1061 } |
1062 | 1062 |
1063 void Internals::setMarkersActive(Node* node, | 1063 void Internals::setMarkersActive(Node* node, |
1064 unsigned startOffset, | 1064 unsigned startOffset, |
1065 unsigned endOffset, | 1065 unsigned endOffset, |
1066 bool active) { | 1066 bool active) { |
1067 ASSERT(node); | 1067 DCHECK(node); |
1068 node->document().markers().setMarkersActive(node, startOffset, endOffset, | 1068 node->document().markers().setMarkersActive(node, startOffset, endOffset, |
1069 active); | 1069 active); |
1070 } | 1070 } |
1071 | 1071 |
1072 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, | 1072 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, |
1073 bool highlight) { | 1073 bool highlight) { |
1074 if (!document || !document->frame()) | 1074 if (!document || !document->frame()) |
1075 return; | 1075 return; |
1076 | 1076 |
1077 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); | 1077 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); |
1078 } | 1078 } |
1079 | 1079 |
1080 void Internals::setFrameViewPosition(Document* document, | 1080 void Internals::setFrameViewPosition(Document* document, |
1081 long x, | 1081 long x, |
1082 long y, | 1082 long y, |
1083 ExceptionState& exceptionState) { | 1083 ExceptionState& exceptionState) { |
1084 ASSERT(document); | 1084 DCHECK(document); |
1085 if (!document->view()) { | 1085 if (!document->view()) { |
1086 exceptionState.throwDOMException(InvalidAccessError, | 1086 exceptionState.throwDOMException(InvalidAccessError, |
1087 "The document provided is invalid."); | 1087 "The document provided is invalid."); |
1088 return; | 1088 return; |
1089 } | 1089 } |
1090 | 1090 |
1091 FrameView* frameView = document->view(); | 1091 FrameView* frameView = document->view(); |
1092 bool scrollbarsSuppressedOldValue = frameView->scrollbarsSuppressed(); | 1092 bool scrollbarsSuppressedOldValue = frameView->scrollbarsSuppressed(); |
1093 | 1093 |
1094 frameView->setScrollbarsSuppressed(false); | 1094 frameView->setScrollbarsSuppressed(false); |
1095 frameView->updateScrollOffsetFromInternals(IntSize(x, y)); | 1095 frameView->updateScrollOffsetFromInternals(IntSize(x, y)); |
1096 frameView->setScrollbarsSuppressed(scrollbarsSuppressedOldValue); | 1096 frameView->setScrollbarsSuppressed(scrollbarsSuppressedOldValue); |
1097 } | 1097 } |
1098 | 1098 |
1099 String Internals::viewportAsText(Document* document, | 1099 String Internals::viewportAsText(Document* document, |
1100 float, | 1100 float, |
1101 int availableWidth, | 1101 int availableWidth, |
1102 int availableHeight, | 1102 int availableHeight, |
1103 ExceptionState& exceptionState) { | 1103 ExceptionState& exceptionState) { |
1104 ASSERT(document); | 1104 DCHECK(document); |
1105 if (!document->page()) { | 1105 if (!document->page()) { |
1106 exceptionState.throwDOMException(InvalidAccessError, | 1106 exceptionState.throwDOMException(InvalidAccessError, |
1107 "The document provided is invalid."); | 1107 "The document provided is invalid."); |
1108 return String(); | 1108 return String(); |
1109 } | 1109 } |
1110 | 1110 |
1111 document->updateStyleAndLayoutIgnorePendingStylesheets(); | 1111 document->updateStyleAndLayoutIgnorePendingStylesheets(); |
1112 | 1112 |
1113 Page* page = document->page(); | 1113 Page* page = document->page(); |
1114 | 1114 |
(...skipping 25 matching lines...) Expand all Loading... |
1140 builder.append(String::number(constraints.maximumScale)); | 1140 builder.append(String::number(constraints.maximumScale)); |
1141 | 1141 |
1142 builder.append("] and userScalable "); | 1142 builder.append("] and userScalable "); |
1143 builder.append(description.userZoom ? "true" : "false"); | 1143 builder.append(description.userZoom ? "true" : "false"); |
1144 | 1144 |
1145 return builder.toString(); | 1145 return builder.toString(); |
1146 } | 1146 } |
1147 | 1147 |
1148 bool Internals::elementShouldAutoComplete(Element* element, | 1148 bool Internals::elementShouldAutoComplete(Element* element, |
1149 ExceptionState& exceptionState) { | 1149 ExceptionState& exceptionState) { |
1150 ASSERT(element); | 1150 DCHECK(element); |
1151 if (isHTMLInputElement(*element)) | 1151 if (isHTMLInputElement(*element)) |
1152 return toHTMLInputElement(*element).shouldAutocomplete(); | 1152 return toHTMLInputElement(*element).shouldAutocomplete(); |
1153 | 1153 |
1154 exceptionState.throwDOMException(InvalidNodeTypeError, | 1154 exceptionState.throwDOMException(InvalidNodeTypeError, |
1155 "The element provided is not an INPUT."); | 1155 "The element provided is not an INPUT."); |
1156 return false; | 1156 return false; |
1157 } | 1157 } |
1158 | 1158 |
1159 String Internals::suggestedValue(Element* element, | 1159 String Internals::suggestedValue(Element* element, |
1160 ExceptionState& exceptionState) { | 1160 ExceptionState& exceptionState) { |
1161 ASSERT(element); | 1161 DCHECK(element); |
1162 if (!element->isFormControlElement()) { | 1162 if (!element->isFormControlElement()) { |
1163 exceptionState.throwDOMException( | 1163 exceptionState.throwDOMException( |
1164 InvalidNodeTypeError, | 1164 InvalidNodeTypeError, |
1165 "The element provided is not a form control element."); | 1165 "The element provided is not a form control element."); |
1166 return String(); | 1166 return String(); |
1167 } | 1167 } |
1168 | 1168 |
1169 String suggestedValue; | 1169 String suggestedValue; |
1170 if (isHTMLInputElement(*element)) | 1170 if (isHTMLInputElement(*element)) |
1171 suggestedValue = toHTMLInputElement(*element).suggestedValue(); | 1171 suggestedValue = toHTMLInputElement(*element).suggestedValue(); |
1172 | 1172 |
1173 if (isHTMLTextAreaElement(*element)) | 1173 if (isHTMLTextAreaElement(*element)) |
1174 suggestedValue = toHTMLTextAreaElement(*element).suggestedValue(); | 1174 suggestedValue = toHTMLTextAreaElement(*element).suggestedValue(); |
1175 | 1175 |
1176 if (isHTMLSelectElement(*element)) | 1176 if (isHTMLSelectElement(*element)) |
1177 suggestedValue = toHTMLSelectElement(*element).suggestedValue(); | 1177 suggestedValue = toHTMLSelectElement(*element).suggestedValue(); |
1178 | 1178 |
1179 return suggestedValue; | 1179 return suggestedValue; |
1180 } | 1180 } |
1181 | 1181 |
1182 void Internals::setSuggestedValue(Element* element, | 1182 void Internals::setSuggestedValue(Element* element, |
1183 const String& value, | 1183 const String& value, |
1184 ExceptionState& exceptionState) { | 1184 ExceptionState& exceptionState) { |
1185 ASSERT(element); | 1185 DCHECK(element); |
1186 if (!element->isFormControlElement()) { | 1186 if (!element->isFormControlElement()) { |
1187 exceptionState.throwDOMException( | 1187 exceptionState.throwDOMException( |
1188 InvalidNodeTypeError, | 1188 InvalidNodeTypeError, |
1189 "The element provided is not a form control element."); | 1189 "The element provided is not a form control element."); |
1190 return; | 1190 return; |
1191 } | 1191 } |
1192 | 1192 |
1193 if (isHTMLInputElement(*element)) | 1193 if (isHTMLInputElement(*element)) |
1194 toHTMLInputElement(*element).setSuggestedValue(value); | 1194 toHTMLInputElement(*element).setSuggestedValue(value); |
1195 | 1195 |
1196 if (isHTMLTextAreaElement(*element)) | 1196 if (isHTMLTextAreaElement(*element)) |
1197 toHTMLTextAreaElement(*element).setSuggestedValue(value); | 1197 toHTMLTextAreaElement(*element).setSuggestedValue(value); |
1198 | 1198 |
1199 if (isHTMLSelectElement(*element)) | 1199 if (isHTMLSelectElement(*element)) |
1200 toHTMLSelectElement(*element).setSuggestedValue(value); | 1200 toHTMLSelectElement(*element).setSuggestedValue(value); |
1201 } | 1201 } |
1202 | 1202 |
1203 void Internals::setEditingValue(Element* element, | 1203 void Internals::setEditingValue(Element* element, |
1204 const String& value, | 1204 const String& value, |
1205 ExceptionState& exceptionState) { | 1205 ExceptionState& exceptionState) { |
1206 ASSERT(element); | 1206 DCHECK(element); |
1207 if (!isHTMLInputElement(*element)) { | 1207 if (!isHTMLInputElement(*element)) { |
1208 exceptionState.throwDOMException(InvalidNodeTypeError, | 1208 exceptionState.throwDOMException(InvalidNodeTypeError, |
1209 "The element provided is not an INPUT."); | 1209 "The element provided is not an INPUT."); |
1210 return; | 1210 return; |
1211 } | 1211 } |
1212 | 1212 |
1213 toHTMLInputElement(*element).setEditingValue(value); | 1213 toHTMLInputElement(*element).setEditingValue(value); |
1214 } | 1214 } |
1215 | 1215 |
1216 void Internals::setAutofilled(Element* element, | 1216 void Internals::setAutofilled(Element* element, |
1217 bool enabled, | 1217 bool enabled, |
1218 ExceptionState& exceptionState) { | 1218 ExceptionState& exceptionState) { |
1219 ASSERT(element); | 1219 DCHECK(element); |
1220 if (!element->isFormControlElement()) { | 1220 if (!element->isFormControlElement()) { |
1221 exceptionState.throwDOMException( | 1221 exceptionState.throwDOMException( |
1222 InvalidNodeTypeError, | 1222 InvalidNodeTypeError, |
1223 "The element provided is not a form control element."); | 1223 "The element provided is not a form control element."); |
1224 return; | 1224 return; |
1225 } | 1225 } |
1226 toHTMLFormControlElement(element)->setAutofilled(enabled); | 1226 toHTMLFormControlElement(element)->setAutofilled(enabled); |
1227 } | 1227 } |
1228 | 1228 |
1229 Range* Internals::rangeFromLocationAndLength(Element* scope, | 1229 Range* Internals::rangeFromLocationAndLength(Element* scope, |
1230 int rangeLocation, | 1230 int rangeLocation, |
1231 int rangeLength) { | 1231 int rangeLength) { |
1232 ASSERT(scope); | 1232 DCHECK(scope); |
1233 | 1233 |
1234 // TextIterator depends on Layout information, make sure layout it up to date. | 1234 // TextIterator depends on Layout information, make sure layout it up to date. |
1235 scope->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 1235 scope->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
1236 | 1236 |
1237 return createRange(PlainTextRange(rangeLocation, rangeLocation + rangeLength) | 1237 return createRange(PlainTextRange(rangeLocation, rangeLocation + rangeLength) |
1238 .createRange(*scope)); | 1238 .createRange(*scope)); |
1239 } | 1239 } |
1240 | 1240 |
1241 unsigned Internals::locationFromRange(Element* scope, const Range* range) { | 1241 unsigned Internals::locationFromRange(Element* scope, const Range* range) { |
1242 ASSERT(scope && range); | 1242 DCHECK(scope && range); |
1243 // PlainTextRange depends on Layout information, make sure layout it up to | 1243 // PlainTextRange depends on Layout information, make sure layout it up to |
1244 // date. | 1244 // date. |
1245 scope->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 1245 scope->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
1246 | 1246 |
1247 return PlainTextRange::create(*scope, *range).start(); | 1247 return PlainTextRange::create(*scope, *range).start(); |
1248 } | 1248 } |
1249 | 1249 |
1250 unsigned Internals::lengthFromRange(Element* scope, const Range* range) { | 1250 unsigned Internals::lengthFromRange(Element* scope, const Range* range) { |
1251 ASSERT(scope && range); | 1251 DCHECK(scope && range); |
1252 // PlainTextRange depends on Layout information, make sure layout it up to | 1252 // PlainTextRange depends on Layout information, make sure layout it up to |
1253 // date. | 1253 // date. |
1254 scope->document().updateStyleAndLayoutIgnorePendingStylesheets(); | 1254 scope->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
1255 | 1255 |
1256 return PlainTextRange::create(*scope, *range).length(); | 1256 return PlainTextRange::create(*scope, *range).length(); |
1257 } | 1257 } |
1258 | 1258 |
1259 String Internals::rangeAsText(const Range* range) { | 1259 String Internals::rangeAsText(const Range* range) { |
1260 ASSERT(range); | 1260 DCHECK(range); |
1261 // Clean layout is required by plain text extraction. | 1261 // Clean layout is required by plain text extraction. |
1262 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets(); | 1262 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets(); |
1263 | 1263 |
1264 return range->text(); | 1264 return range->text(); |
1265 } | 1265 } |
1266 | 1266 |
1267 // FIXME: The next four functions are very similar - combine them once | 1267 // FIXME: The next four functions are very similar - combine them once |
1268 // bestClickableNode/bestContextMenuNode have been combined.. | 1268 // bestClickableNode/bestContextMenuNode have been combined.. |
1269 | 1269 |
1270 DOMPoint* Internals::touchPositionAdjustedToBestClickableNode( | 1270 DOMPoint* Internals::touchPositionAdjustedToBestClickableNode( |
1271 long x, | 1271 long x, |
1272 long y, | 1272 long y, |
1273 long width, | 1273 long width, |
1274 long height, | 1274 long height, |
1275 Document* document, | 1275 Document* document, |
1276 ExceptionState& exceptionState) { | 1276 ExceptionState& exceptionState) { |
1277 ASSERT(document); | 1277 DCHECK(document); |
1278 if (!document->frame()) { | 1278 if (!document->frame()) { |
1279 exceptionState.throwDOMException(InvalidAccessError, | 1279 exceptionState.throwDOMException(InvalidAccessError, |
1280 "The document provided is invalid."); | 1280 "The document provided is invalid."); |
1281 return 0; | 1281 return 0; |
1282 } | 1282 } |
1283 | 1283 |
1284 document->updateStyleAndLayout(); | 1284 document->updateStyleAndLayout(); |
1285 | 1285 |
1286 IntSize radius(width / 2, height / 2); | 1286 IntSize radius(width / 2, height / 2); |
1287 IntPoint point(x + radius.width(), y + radius.height()); | 1287 IntPoint point(x + radius.width(), y + radius.height()); |
(...skipping 16 matching lines...) Expand all Loading... |
1304 return 0; | 1304 return 0; |
1305 } | 1305 } |
1306 | 1306 |
1307 Node* Internals::touchNodeAdjustedToBestClickableNode( | 1307 Node* Internals::touchNodeAdjustedToBestClickableNode( |
1308 long x, | 1308 long x, |
1309 long y, | 1309 long y, |
1310 long width, | 1310 long width, |
1311 long height, | 1311 long height, |
1312 Document* document, | 1312 Document* document, |
1313 ExceptionState& exceptionState) { | 1313 ExceptionState& exceptionState) { |
1314 ASSERT(document); | 1314 DCHECK(document); |
1315 if (!document->frame()) { | 1315 if (!document->frame()) { |
1316 exceptionState.throwDOMException(InvalidAccessError, | 1316 exceptionState.throwDOMException(InvalidAccessError, |
1317 "The document provided is invalid."); | 1317 "The document provided is invalid."); |
1318 return 0; | 1318 return 0; |
1319 } | 1319 } |
1320 | 1320 |
1321 document->updateStyleAndLayout(); | 1321 document->updateStyleAndLayout(); |
1322 | 1322 |
1323 IntSize radius(width / 2, height / 2); | 1323 IntSize radius(width / 2, height / 2); |
1324 IntPoint point(x + radius.width(), y + radius.height()); | 1324 IntPoint point(x + radius.width(), y + radius.height()); |
(...skipping 12 matching lines...) Expand all Loading... |
1337 return targetNode; | 1337 return targetNode; |
1338 } | 1338 } |
1339 | 1339 |
1340 DOMPoint* Internals::touchPositionAdjustedToBestContextMenuNode( | 1340 DOMPoint* Internals::touchPositionAdjustedToBestContextMenuNode( |
1341 long x, | 1341 long x, |
1342 long y, | 1342 long y, |
1343 long width, | 1343 long width, |
1344 long height, | 1344 long height, |
1345 Document* document, | 1345 Document* document, |
1346 ExceptionState& exceptionState) { | 1346 ExceptionState& exceptionState) { |
1347 ASSERT(document); | 1347 DCHECK(document); |
1348 if (!document->frame()) { | 1348 if (!document->frame()) { |
1349 exceptionState.throwDOMException(InvalidAccessError, | 1349 exceptionState.throwDOMException(InvalidAccessError, |
1350 "The document provided is invalid."); | 1350 "The document provided is invalid."); |
1351 return 0; | 1351 return 0; |
1352 } | 1352 } |
1353 | 1353 |
1354 document->updateStyleAndLayout(); | 1354 document->updateStyleAndLayout(); |
1355 | 1355 |
1356 IntSize radius(width / 2, height / 2); | 1356 IntSize radius(width / 2, height / 2); |
1357 IntPoint point(x + radius.width(), y + radius.height()); | 1357 IntPoint point(x + radius.width(), y + radius.height()); |
(...skipping 16 matching lines...) Expand all Loading... |
1374 return DOMPoint::create(x, y); | 1374 return DOMPoint::create(x, y); |
1375 } | 1375 } |
1376 | 1376 |
1377 Node* Internals::touchNodeAdjustedToBestContextMenuNode( | 1377 Node* Internals::touchNodeAdjustedToBestContextMenuNode( |
1378 long x, | 1378 long x, |
1379 long y, | 1379 long y, |
1380 long width, | 1380 long width, |
1381 long height, | 1381 long height, |
1382 Document* document, | 1382 Document* document, |
1383 ExceptionState& exceptionState) { | 1383 ExceptionState& exceptionState) { |
1384 ASSERT(document); | 1384 DCHECK(document); |
1385 if (!document->frame()) { | 1385 if (!document->frame()) { |
1386 exceptionState.throwDOMException(InvalidAccessError, | 1386 exceptionState.throwDOMException(InvalidAccessError, |
1387 "The document provided is invalid."); | 1387 "The document provided is invalid."); |
1388 return 0; | 1388 return 0; |
1389 } | 1389 } |
1390 | 1390 |
1391 document->updateStyleAndLayout(); | 1391 document->updateStyleAndLayout(); |
1392 | 1392 |
1393 IntSize radius(width / 2, height / 2); | 1393 IntSize radius(width / 2, height / 2); |
1394 IntPoint point(x + radius.width(), y + radius.height()); | 1394 IntPoint point(x + radius.width(), y + radius.height()); |
(...skipping 12 matching lines...) Expand all Loading... |
1407 return targetNode; | 1407 return targetNode; |
1408 } | 1408 } |
1409 | 1409 |
1410 ClientRect* Internals::bestZoomableAreaForTouchPoint( | 1410 ClientRect* Internals::bestZoomableAreaForTouchPoint( |
1411 long x, | 1411 long x, |
1412 long y, | 1412 long y, |
1413 long width, | 1413 long width, |
1414 long height, | 1414 long height, |
1415 Document* document, | 1415 Document* document, |
1416 ExceptionState& exceptionState) { | 1416 ExceptionState& exceptionState) { |
1417 ASSERT(document); | 1417 DCHECK(document); |
1418 if (!document->frame()) { | 1418 if (!document->frame()) { |
1419 exceptionState.throwDOMException(InvalidAccessError, | 1419 exceptionState.throwDOMException(InvalidAccessError, |
1420 "The document provided is invalid."); | 1420 "The document provided is invalid."); |
1421 return nullptr; | 1421 return nullptr; |
1422 } | 1422 } |
1423 | 1423 |
1424 document->updateStyleAndLayout(); | 1424 document->updateStyleAndLayout(); |
1425 | 1425 |
1426 IntSize radius(width / 2, height / 2); | 1426 IntSize radius(width / 2, height / 2); |
1427 IntPoint point(x + radius.width(), y + radius.height()); | 1427 IntPoint point(x + radius.width(), y + radius.height()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 // Optimally, the bindings generator would pass a Vector<AtomicString> here but | 1472 // Optimally, the bindings generator would pass a Vector<AtomicString> here but |
1473 // this is not supported yet. | 1473 // this is not supported yet. |
1474 void Internals::setUserPreferredLanguages(const Vector<String>& languages) { | 1474 void Internals::setUserPreferredLanguages(const Vector<String>& languages) { |
1475 Vector<AtomicString> atomicLanguages; | 1475 Vector<AtomicString> atomicLanguages; |
1476 for (size_t i = 0; i < languages.size(); ++i) | 1476 for (size_t i = 0; i < languages.size(); ++i) |
1477 atomicLanguages.append(AtomicString(languages[i])); | 1477 atomicLanguages.append(AtomicString(languages[i])); |
1478 overrideUserPreferredLanguages(atomicLanguages); | 1478 overrideUserPreferredLanguages(atomicLanguages); |
1479 } | 1479 } |
1480 | 1480 |
1481 unsigned Internals::activeDOMObjectCount(Document* document) { | 1481 unsigned Internals::activeDOMObjectCount(Document* document) { |
1482 ASSERT(document); | 1482 DCHECK(document); |
1483 return document->activeDOMObjectCount(); | 1483 return document->activeDOMObjectCount(); |
1484 } | 1484 } |
1485 | 1485 |
1486 static unsigned eventHandlerCount( | 1486 static unsigned eventHandlerCount( |
1487 Document& document, | 1487 Document& document, |
1488 EventHandlerRegistry::EventHandlerClass handlerClass) { | 1488 EventHandlerRegistry::EventHandlerClass handlerClass) { |
1489 if (!document.frameHost()) | 1489 if (!document.frameHost()) |
1490 return 0; | 1490 return 0; |
1491 EventHandlerRegistry* registry = | 1491 EventHandlerRegistry* registry = |
1492 &document.frameHost()->eventHandlerRegistry(); | 1492 &document.frameHost()->eventHandlerRegistry(); |
1493 unsigned count = 0; | 1493 unsigned count = 0; |
1494 const EventTargetSet* targets = registry->eventHandlerTargets(handlerClass); | 1494 const EventTargetSet* targets = registry->eventHandlerTargets(handlerClass); |
1495 if (targets) { | 1495 if (targets) { |
1496 for (const auto& target : *targets) | 1496 for (const auto& target : *targets) |
1497 count += target.value; | 1497 count += target.value; |
1498 } | 1498 } |
1499 return count; | 1499 return count; |
1500 } | 1500 } |
1501 | 1501 |
1502 unsigned Internals::wheelEventHandlerCount(Document* document) { | 1502 unsigned Internals::wheelEventHandlerCount(Document* document) { |
1503 ASSERT(document); | 1503 DCHECK(document); |
1504 return eventHandlerCount(*document, EventHandlerRegistry::WheelEventBlocking); | 1504 return eventHandlerCount(*document, EventHandlerRegistry::WheelEventBlocking); |
1505 } | 1505 } |
1506 | 1506 |
1507 unsigned Internals::scrollEventHandlerCount(Document* document) { | 1507 unsigned Internals::scrollEventHandlerCount(Document* document) { |
1508 ASSERT(document); | 1508 DCHECK(document); |
1509 return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent); | 1509 return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent); |
1510 } | 1510 } |
1511 | 1511 |
1512 unsigned Internals::touchStartOrMoveEventHandlerCount(Document* document) { | 1512 unsigned Internals::touchStartOrMoveEventHandlerCount(Document* document) { |
1513 ASSERT(document); | 1513 DCHECK(document); |
1514 return eventHandlerCount( | 1514 return eventHandlerCount( |
1515 *document, EventHandlerRegistry::TouchStartOrMoveEventBlocking) + | 1515 *document, EventHandlerRegistry::TouchStartOrMoveEventBlocking) + |
1516 eventHandlerCount(*document, | 1516 eventHandlerCount(*document, |
1517 EventHandlerRegistry::TouchStartOrMoveEventPassive); | 1517 EventHandlerRegistry::TouchStartOrMoveEventPassive); |
1518 } | 1518 } |
1519 | 1519 |
1520 unsigned Internals::touchEndOrCancelEventHandlerCount(Document* document) { | 1520 unsigned Internals::touchEndOrCancelEventHandlerCount(Document* document) { |
1521 ASSERT(document); | 1521 DCHECK(document); |
1522 return eventHandlerCount( | 1522 return eventHandlerCount( |
1523 *document, EventHandlerRegistry::TouchEndOrCancelEventBlocking) + | 1523 *document, EventHandlerRegistry::TouchEndOrCancelEventBlocking) + |
1524 eventHandlerCount(*document, | 1524 eventHandlerCount(*document, |
1525 EventHandlerRegistry::TouchEndOrCancelEventPassive); | 1525 EventHandlerRegistry::TouchEndOrCancelEventPassive); |
1526 } | 1526 } |
1527 | 1527 |
1528 static PaintLayer* findLayerForGraphicsLayer(PaintLayer* searchRoot, | 1528 static PaintLayer* findLayerForGraphicsLayer(PaintLayer* searchRoot, |
1529 GraphicsLayer* graphicsLayer, | 1529 GraphicsLayer* graphicsLayer, |
1530 IntSize* layerOffset, | 1530 IntSize* layerOffset, |
1531 String* layerType) { | 1531 String* layerType) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 } | 1698 } |
1699 | 1699 |
1700 size_t numChildren = graphicsLayer->children().size(); | 1700 size_t numChildren = graphicsLayer->children().size(); |
1701 for (size_t i = 0; i < numChildren; ++i) | 1701 for (size_t i = 0; i < numChildren; ++i) |
1702 accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects); | 1702 accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects); |
1703 } | 1703 } |
1704 | 1704 |
1705 LayerRectList* Internals::touchEventTargetLayerRects( | 1705 LayerRectList* Internals::touchEventTargetLayerRects( |
1706 Document* document, | 1706 Document* document, |
1707 ExceptionState& exceptionState) { | 1707 ExceptionState& exceptionState) { |
1708 ASSERT(document); | 1708 DCHECK(document); |
1709 if (!document->view() || !document->page() || document != m_document) { | 1709 if (!document->view() || !document->page() || document != m_document) { |
1710 exceptionState.throwDOMException(InvalidAccessError, | 1710 exceptionState.throwDOMException(InvalidAccessError, |
1711 "The document provided is invalid."); | 1711 "The document provided is invalid."); |
1712 return nullptr; | 1712 return nullptr; |
1713 } | 1713 } |
1714 | 1714 |
1715 if (ScrollingCoordinator* scrollingCoordinator = | 1715 if (ScrollingCoordinator* scrollingCoordinator = |
1716 document->page()->scrollingCoordinator()) | 1716 document->page()->scrollingCoordinator()) |
1717 scrollingCoordinator->updateAfterCompositingChangeIfNeeded(); | 1717 scrollingCoordinator->updateAfterCompositingChangeIfNeeded(); |
1718 | 1718 |
1719 LayoutViewItem view = document->layoutViewItem(); | 1719 LayoutViewItem view = document->layoutViewItem(); |
1720 if (!view.isNull()) { | 1720 if (!view.isNull()) { |
1721 if (PaintLayerCompositor* compositor = view.compositor()) { | 1721 if (PaintLayerCompositor* compositor = view.compositor()) { |
1722 if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) { | 1722 if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) { |
1723 LayerRectList* rects = LayerRectList::create(); | 1723 LayerRectList* rects = LayerRectList::create(); |
1724 accumulateLayerRectList(compositor, rootLayer, rects); | 1724 accumulateLayerRectList(compositor, rootLayer, rects); |
1725 return rects; | 1725 return rects; |
1726 } | 1726 } |
1727 } | 1727 } |
1728 } | 1728 } |
1729 | 1729 |
1730 return nullptr; | 1730 return nullptr; |
1731 } | 1731 } |
1732 | 1732 |
1733 bool Internals::executeCommand(Document* document, | 1733 bool Internals::executeCommand(Document* document, |
1734 const String& name, | 1734 const String& name, |
1735 const String& value, | 1735 const String& value, |
1736 ExceptionState& exceptionState) { | 1736 ExceptionState& exceptionState) { |
1737 ASSERT(document); | 1737 DCHECK(document); |
1738 if (!document->frame()) { | 1738 if (!document->frame()) { |
1739 exceptionState.throwDOMException(InvalidAccessError, | 1739 exceptionState.throwDOMException(InvalidAccessError, |
1740 "The document provided is invalid."); | 1740 "The document provided is invalid."); |
1741 return false; | 1741 return false; |
1742 } | 1742 } |
1743 | 1743 |
1744 LocalFrame* frame = document->frame(); | 1744 LocalFrame* frame = document->frame(); |
1745 return frame->editor().executeCommand(name, value); | 1745 return frame->editor().executeCommand(name, value); |
1746 } | 1746 } |
1747 | 1747 |
(...skipping 26 matching lines...) Expand all Loading... |
1774 StaticNodeList* Internals::nodesFromRect(Document* document, | 1774 StaticNodeList* Internals::nodesFromRect(Document* document, |
1775 int centerX, | 1775 int centerX, |
1776 int centerY, | 1776 int centerY, |
1777 unsigned topPadding, | 1777 unsigned topPadding, |
1778 unsigned rightPadding, | 1778 unsigned rightPadding, |
1779 unsigned bottomPadding, | 1779 unsigned bottomPadding, |
1780 unsigned leftPadding, | 1780 unsigned leftPadding, |
1781 bool ignoreClipping, | 1781 bool ignoreClipping, |
1782 bool allowChildFrameContent, | 1782 bool allowChildFrameContent, |
1783 ExceptionState& exceptionState) const { | 1783 ExceptionState& exceptionState) const { |
1784 ASSERT(document); | 1784 DCHECK(document); |
1785 if (!document->frame() || !document->frame()->view()) { | 1785 if (!document->frame() || !document->frame()->view()) { |
1786 exceptionState.throwDOMException( | 1786 exceptionState.throwDOMException( |
1787 InvalidAccessError, | 1787 InvalidAccessError, |
1788 "No view can be obtained from the provided document."); | 1788 "No view can be obtained from the provided document."); |
1789 return nullptr; | 1789 return nullptr; |
1790 } | 1790 } |
1791 | 1791 |
1792 LocalFrame* frame = document->frame(); | 1792 LocalFrame* frame = document->frame(); |
1793 FrameView* frameView = document->view(); | 1793 FrameView* frameView = document->view(); |
1794 LayoutViewItem layoutViewItem = document->layoutViewItem(); | 1794 LayoutViewItem layoutViewItem = document->layoutViewItem(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 bool Internals::canHyphenate(const AtomicString& locale) { | 1873 bool Internals::canHyphenate(const AtomicString& locale) { |
1874 return LayoutLocale::valueOrDefault(LayoutLocale::get(locale)) | 1874 return LayoutLocale::valueOrDefault(LayoutLocale::get(locale)) |
1875 .getHyphenation(); | 1875 .getHyphenation(); |
1876 } | 1876 } |
1877 | 1877 |
1878 void Internals::setMockHyphenation(const AtomicString& locale) { | 1878 void Internals::setMockHyphenation(const AtomicString& locale) { |
1879 LayoutLocale::setHyphenationForTesting(locale, adoptRef(new MockHyphenation)); | 1879 LayoutLocale::setHyphenationForTesting(locale, adoptRef(new MockHyphenation)); |
1880 } | 1880 } |
1881 | 1881 |
1882 bool Internals::isOverwriteModeEnabled(Document* document) { | 1882 bool Internals::isOverwriteModeEnabled(Document* document) { |
1883 ASSERT(document); | 1883 DCHECK(document); |
1884 if (!document->frame()) | 1884 if (!document->frame()) |
1885 return false; | 1885 return false; |
1886 | 1886 |
1887 return document->frame()->editor().isOverwriteModeEnabled(); | 1887 return document->frame()->editor().isOverwriteModeEnabled(); |
1888 } | 1888 } |
1889 | 1889 |
1890 void Internals::toggleOverwriteModeEnabled(Document* document) { | 1890 void Internals::toggleOverwriteModeEnabled(Document* document) { |
1891 ASSERT(document); | 1891 DCHECK(document); |
1892 if (!document->frame()) | 1892 if (!document->frame()) |
1893 return; | 1893 return; |
1894 | 1894 |
1895 document->frame()->editor().toggleOverwriteModeEnabled(); | 1895 document->frame()->editor().toggleOverwriteModeEnabled(); |
1896 } | 1896 } |
1897 | 1897 |
1898 unsigned Internals::numberOfLiveNodes() const { | 1898 unsigned Internals::numberOfLiveNodes() const { |
1899 return InstanceCounters::counterValue(InstanceCounters::NodeCounter); | 1899 return InstanceCounters::counterValue(InstanceCounters::NodeCounter); |
1900 } | 1900 } |
1901 | 1901 |
(...skipping 15 matching lines...) Expand all Loading... |
1917 "No frame can be obtained from the provided document."); | 1917 "No frame can be obtained from the provided document."); |
1918 return false; | 1918 return false; |
1919 } | 1919 } |
1920 | 1920 |
1921 document->updateStyleAndLayoutIgnorePendingStylesheets(); | 1921 document->updateStyleAndLayoutIgnorePendingStylesheets(); |
1922 return document->frame()->spellChecker().selectionStartHasMarkerFor( | 1922 return document->frame()->spellChecker().selectionStartHasMarkerFor( |
1923 DocumentMarker::Grammar, from, length); | 1923 DocumentMarker::Grammar, from, length); |
1924 } | 1924 } |
1925 | 1925 |
1926 unsigned Internals::numberOfScrollableAreas(Document* document) { | 1926 unsigned Internals::numberOfScrollableAreas(Document* document) { |
1927 ASSERT(document); | 1927 DCHECK(document); |
1928 if (!document->frame()) | 1928 if (!document->frame()) |
1929 return 0; | 1929 return 0; |
1930 | 1930 |
1931 unsigned count = 0; | 1931 unsigned count = 0; |
1932 LocalFrame* frame = document->frame(); | 1932 LocalFrame* frame = document->frame(); |
1933 if (frame->view()->scrollableAreas()) | 1933 if (frame->view()->scrollableAreas()) |
1934 count += frame->view()->scrollableAreas()->size(); | 1934 count += frame->view()->scrollableAreas()->size(); |
1935 | 1935 |
1936 for (Frame* child = frame->tree().firstChild(); child; | 1936 for (Frame* child = frame->tree().firstChild(); child; |
1937 child = child->tree().nextSibling()) { | 1937 child = child->tree().nextSibling()) { |
1938 if (child->isLocalFrame() && toLocalFrame(child)->view() && | 1938 if (child->isLocalFrame() && toLocalFrame(child)->view() && |
1939 toLocalFrame(child)->view()->scrollableAreas()) | 1939 toLocalFrame(child)->view()->scrollableAreas()) |
1940 count += toLocalFrame(child)->view()->scrollableAreas()->size(); | 1940 count += toLocalFrame(child)->view()->scrollableAreas()->size(); |
1941 } | 1941 } |
1942 | 1942 |
1943 return count; | 1943 return count; |
1944 } | 1944 } |
1945 | 1945 |
1946 bool Internals::isPageBoxVisible(Document* document, int pageNumber) { | 1946 bool Internals::isPageBoxVisible(Document* document, int pageNumber) { |
1947 ASSERT(document); | 1947 DCHECK(document); |
1948 return document->isPageBoxVisible(pageNumber); | 1948 return document->isPageBoxVisible(pageNumber); |
1949 } | 1949 } |
1950 | 1950 |
1951 String Internals::layerTreeAsText(Document* document, | 1951 String Internals::layerTreeAsText(Document* document, |
1952 ExceptionState& exceptionState) const { | 1952 ExceptionState& exceptionState) const { |
1953 return layerTreeAsText(document, 0, exceptionState); | 1953 return layerTreeAsText(document, 0, exceptionState); |
1954 } | 1954 } |
1955 | 1955 |
1956 String Internals::elementLayerTreeAsText(Element* element, | 1956 String Internals::elementLayerTreeAsText(Element* element, |
1957 ExceptionState& exceptionState) const { | 1957 ExceptionState& exceptionState) const { |
1958 ASSERT(element); | 1958 DCHECK(element); |
1959 FrameView* frameView = element->document().view(); | 1959 FrameView* frameView = element->document().view(); |
1960 frameView->updateAllLifecyclePhases(); | 1960 frameView->updateAllLifecyclePhases(); |
1961 | 1961 |
1962 return elementLayerTreeAsText(element, 0, exceptionState); | 1962 return elementLayerTreeAsText(element, 0, exceptionState); |
1963 } | 1963 } |
1964 | 1964 |
1965 bool Internals::scrollsWithRespectTo(Element* element1, | 1965 bool Internals::scrollsWithRespectTo(Element* element1, |
1966 Element* element2, | 1966 Element* element2, |
1967 ExceptionState& exceptionState) { | 1967 ExceptionState& exceptionState) { |
1968 ASSERT(element1 && element2); | 1968 DCHECK(element1 && element2); |
1969 element1->document().view()->updateAllLifecyclePhases(); | 1969 element1->document().view()->updateAllLifecyclePhases(); |
1970 | 1970 |
1971 LayoutObject* layoutObject1 = element1->layoutObject(); | 1971 LayoutObject* layoutObject1 = element1->layoutObject(); |
1972 LayoutObject* layoutObject2 = element2->layoutObject(); | 1972 LayoutObject* layoutObject2 = element2->layoutObject(); |
1973 if (!layoutObject1 || !layoutObject1->isBox()) { | 1973 if (!layoutObject1 || !layoutObject1->isBox()) { |
1974 exceptionState.throwDOMException( | 1974 exceptionState.throwDOMException( |
1975 InvalidAccessError, | 1975 InvalidAccessError, |
1976 layoutObject1 | 1976 layoutObject1 |
1977 ? "The first provided element's layoutObject is not a box." | 1977 ? "The first provided element's layoutObject is not a box." |
1978 : "The first provided element has no layoutObject."); | 1978 : "The first provided element has no layoutObject."); |
(...skipping 18 matching lines...) Expand all Loading... |
1997 layer1 ? "second" : "first")); | 1997 layer1 ? "second" : "first")); |
1998 return false; | 1998 return false; |
1999 } | 1999 } |
2000 | 2000 |
2001 return layer1->scrollsWithRespectTo(layer2); | 2001 return layer1->scrollsWithRespectTo(layer2); |
2002 } | 2002 } |
2003 | 2003 |
2004 String Internals::layerTreeAsText(Document* document, | 2004 String Internals::layerTreeAsText(Document* document, |
2005 unsigned flags, | 2005 unsigned flags, |
2006 ExceptionState& exceptionState) const { | 2006 ExceptionState& exceptionState) const { |
2007 ASSERT(document); | 2007 DCHECK(document); |
2008 if (!document->frame()) { | 2008 if (!document->frame()) { |
2009 exceptionState.throwDOMException(InvalidAccessError, | 2009 exceptionState.throwDOMException(InvalidAccessError, |
2010 "The document provided is invalid."); | 2010 "The document provided is invalid."); |
2011 return String(); | 2011 return String(); |
2012 } | 2012 } |
2013 | 2013 |
2014 document->view()->updateAllLifecyclePhases(); | 2014 document->view()->updateAllLifecyclePhases(); |
2015 | 2015 |
2016 return document->frame()->layerTreeAsText(flags); | 2016 return document->frame()->layerTreeAsText(flags); |
2017 } | 2017 } |
2018 | 2018 |
2019 String Internals::elementLayerTreeAsText(Element* element, | 2019 String Internals::elementLayerTreeAsText(Element* element, |
2020 unsigned flags, | 2020 unsigned flags, |
2021 ExceptionState& exceptionState) const { | 2021 ExceptionState& exceptionState) const { |
2022 ASSERT(element); | 2022 DCHECK(element); |
2023 element->document().updateStyleAndLayout(); | 2023 element->document().updateStyleAndLayout(); |
2024 | 2024 |
2025 LayoutObject* layoutObject = element->layoutObject(); | 2025 LayoutObject* layoutObject = element->layoutObject(); |
2026 if (!layoutObject || !layoutObject->isBox()) { | 2026 if (!layoutObject || !layoutObject->isBox()) { |
2027 exceptionState.throwDOMException( | 2027 exceptionState.throwDOMException( |
2028 InvalidAccessError, | 2028 InvalidAccessError, |
2029 layoutObject ? "The provided element's layoutObject is not a box." | 2029 layoutObject ? "The provided element's layoutObject is not a box." |
2030 : "The provided element has no layoutObject."); | 2030 : "The provided element has no layoutObject."); |
2031 return String(); | 2031 return String(); |
2032 } | 2032 } |
2033 | 2033 |
2034 PaintLayer* layer = toLayoutBox(layoutObject)->layer(); | 2034 PaintLayer* layer = toLayoutBox(layoutObject)->layer(); |
2035 if (!layer || !layer->hasCompositedLayerMapping() || | 2035 if (!layer || !layer->hasCompositedLayerMapping() || |
2036 !layer->compositedLayerMapping()->mainGraphicsLayer()) { | 2036 !layer->compositedLayerMapping()->mainGraphicsLayer()) { |
2037 // Don't raise exception in these cases which may be normally used in tests. | 2037 // Don't raise exception in these cases which may be normally used in tests. |
2038 return String(); | 2038 return String(); |
2039 } | 2039 } |
2040 | 2040 |
2041 return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText( | 2041 return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText( |
2042 flags); | 2042 flags); |
2043 } | 2043 } |
2044 | 2044 |
2045 String Internals::scrollingStateTreeAsText(Document*) const { | 2045 String Internals::scrollingStateTreeAsText(Document*) const { |
2046 return String(); | 2046 return String(); |
2047 } | 2047 } |
2048 | 2048 |
2049 String Internals::mainThreadScrollingReasons( | 2049 String Internals::mainThreadScrollingReasons( |
2050 Document* document, | 2050 Document* document, |
2051 ExceptionState& exceptionState) const { | 2051 ExceptionState& exceptionState) const { |
2052 ASSERT(document); | 2052 DCHECK(document); |
2053 if (!document->frame()) { | 2053 if (!document->frame()) { |
2054 exceptionState.throwDOMException(InvalidAccessError, | 2054 exceptionState.throwDOMException(InvalidAccessError, |
2055 "The document provided is invalid."); | 2055 "The document provided is invalid."); |
2056 return String(); | 2056 return String(); |
2057 } | 2057 } |
2058 | 2058 |
2059 document->frame()->view()->updateAllLifecyclePhases(); | 2059 document->frame()->view()->updateAllLifecyclePhases(); |
2060 | 2060 |
2061 Page* page = document->page(); | 2061 Page* page = document->page(); |
2062 if (!page) | 2062 if (!page) |
2063 return String(); | 2063 return String(); |
2064 | 2064 |
2065 return page->mainThreadScrollingReasonsAsText(); | 2065 return page->mainThreadScrollingReasonsAsText(); |
2066 } | 2066 } |
2067 | 2067 |
2068 ClientRectList* Internals::nonFastScrollableRects( | 2068 ClientRectList* Internals::nonFastScrollableRects( |
2069 Document* document, | 2069 Document* document, |
2070 ExceptionState& exceptionState) const { | 2070 ExceptionState& exceptionState) const { |
2071 ASSERT(document); | 2071 DCHECK(document); |
2072 if (!document->frame()) { | 2072 if (!document->frame()) { |
2073 exceptionState.throwDOMException(InvalidAccessError, | 2073 exceptionState.throwDOMException(InvalidAccessError, |
2074 "The document provided is invalid."); | 2074 "The document provided is invalid."); |
2075 return nullptr; | 2075 return nullptr; |
2076 } | 2076 } |
2077 | 2077 |
2078 Page* page = document->page(); | 2078 Page* page = document->page(); |
2079 if (!page) | 2079 if (!page) |
2080 return nullptr; | 2080 return nullptr; |
2081 | 2081 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2217 if (!frame()) | 2217 if (!frame()) |
2218 return false; | 2218 return false; |
2219 | 2219 |
2220 return frame()->host()->visualViewport().magnifyScaleAroundAnchor( | 2220 return frame()->host()->visualViewport().magnifyScaleAroundAnchor( |
2221 scaleFactor, FloatPoint(x, y)); | 2221 scaleFactor, FloatPoint(x, y)); |
2222 } | 2222 } |
2223 | 2223 |
2224 void Internals::setIsCursorVisible(Document* document, | 2224 void Internals::setIsCursorVisible(Document* document, |
2225 bool isVisible, | 2225 bool isVisible, |
2226 ExceptionState& exceptionState) { | 2226 ExceptionState& exceptionState) { |
2227 ASSERT(document); | 2227 DCHECK(document); |
2228 if (!document->page()) { | 2228 if (!document->page()) { |
2229 exceptionState.throwDOMException(InvalidAccessError, | 2229 exceptionState.throwDOMException(InvalidAccessError, |
2230 "No context document can be obtained."); | 2230 "No context document can be obtained."); |
2231 return; | 2231 return; |
2232 } | 2232 } |
2233 document->page()->setIsCursorVisible(isVisible); | 2233 document->page()->setIsCursorVisible(isVisible); |
2234 } | 2234 } |
2235 | 2235 |
2236 String Internals::effectivePreload(HTMLMediaElement* mediaElement) { | 2236 String Internals::effectivePreload(HTMLMediaElement* mediaElement) { |
2237 ASSERT(mediaElement); | 2237 DCHECK(mediaElement); |
2238 return mediaElement->effectivePreload(); | 2238 return mediaElement->effectivePreload(); |
2239 } | 2239 } |
2240 | 2240 |
2241 void Internals::mediaPlayerRemoteRouteAvailabilityChanged( | 2241 void Internals::mediaPlayerRemoteRouteAvailabilityChanged( |
2242 HTMLMediaElement* mediaElement, | 2242 HTMLMediaElement* mediaElement, |
2243 bool available) { | 2243 bool available) { |
2244 ASSERT(mediaElement); | 2244 DCHECK(mediaElement); |
2245 mediaElement->remoteRouteAvailabilityChanged( | 2245 mediaElement->remoteRouteAvailabilityChanged( |
2246 available ? WebRemotePlaybackAvailability::DeviceAvailable | 2246 available ? WebRemotePlaybackAvailability::DeviceAvailable |
2247 : WebRemotePlaybackAvailability::SourceNotSupported); | 2247 : WebRemotePlaybackAvailability::SourceNotSupported); |
2248 } | 2248 } |
2249 | 2249 |
2250 void Internals::mediaPlayerPlayingRemotelyChanged( | 2250 void Internals::mediaPlayerPlayingRemotelyChanged( |
2251 HTMLMediaElement* mediaElement, | 2251 HTMLMediaElement* mediaElement, |
2252 bool remote) { | 2252 bool remote) { |
2253 ASSERT(mediaElement); | 2253 DCHECK(mediaElement); |
2254 if (remote) | 2254 if (remote) |
2255 mediaElement->connectedToRemoteDevice(); | 2255 mediaElement->connectedToRemoteDevice(); |
2256 else | 2256 else |
2257 mediaElement->disconnectedFromRemoteDevice(); | 2257 mediaElement->disconnectedFromRemoteDevice(); |
2258 } | 2258 } |
2259 | 2259 |
2260 void Internals::registerURLSchemeAsBypassingContentSecurityPolicy( | 2260 void Internals::registerURLSchemeAsBypassingContentSecurityPolicy( |
2261 const String& scheme) { | 2261 const String& scheme) { |
2262 SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(scheme); | 2262 SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(scheme); |
2263 } | 2263 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 return CallbackFunctionTest::create(); | 2302 return CallbackFunctionTest::create(); |
2303 } | 2303 } |
2304 | 2304 |
2305 Vector<String> Internals::getReferencedFilePaths() const { | 2305 Vector<String> Internals::getReferencedFilePaths() const { |
2306 if (!frame()) | 2306 if (!frame()) |
2307 return Vector<String>(); | 2307 return Vector<String>(); |
2308 | 2308 |
2309 return frame()->loader().currentItem()->getReferencedFilePaths(); | 2309 return frame()->loader().currentItem()->getReferencedFilePaths(); |
2310 } | 2310 } |
2311 | 2311 |
| 2312 void Internals::startStoringCompositedLayerDebugInfo( |
| 2313 Document* document, |
| 2314 ExceptionState& exceptionState) { |
| 2315 DCHECK(document); |
| 2316 if (!document->view()) { |
| 2317 exceptionState.throwDOMException(InvalidAccessError, |
| 2318 "The document provided is invalid."); |
| 2319 return; |
| 2320 } |
| 2321 |
| 2322 FrameView* frameView = document->view(); |
| 2323 frameView->setIsStoringCompositedLayerDebugInfo(true); |
| 2324 frameView->updateAllLifecyclePhases(); |
| 2325 } |
| 2326 |
| 2327 void Internals::stopStoringCompositedLayerDebugInfo( |
| 2328 Document* document, |
| 2329 ExceptionState& exceptionState) { |
| 2330 DCHECK(document); |
| 2331 if (!document->view()) { |
| 2332 exceptionState.throwDOMException(InvalidAccessError, |
| 2333 "The document provided is invalid."); |
| 2334 return; |
| 2335 } |
| 2336 |
| 2337 FrameView* frameView = document->view(); |
| 2338 frameView->setIsStoringCompositedLayerDebugInfo(false); |
| 2339 frameView->updateAllLifecyclePhases(); |
| 2340 } |
| 2341 |
2312 void Internals::startTrackingRepaints(Document* document, | 2342 void Internals::startTrackingRepaints(Document* document, |
2313 ExceptionState& exceptionState) { | 2343 ExceptionState& exceptionState) { |
2314 ASSERT(document); | 2344 DCHECK(document); |
2315 if (!document->view()) { | 2345 if (!document->view()) { |
2316 exceptionState.throwDOMException(InvalidAccessError, | 2346 exceptionState.throwDOMException(InvalidAccessError, |
2317 "The document provided is invalid."); | 2347 "The document provided is invalid."); |
2318 return; | 2348 return; |
2319 } | 2349 } |
2320 | 2350 |
2321 FrameView* frameView = document->view(); | 2351 FrameView* frameView = document->view(); |
2322 frameView->updateAllLifecyclePhases(); | 2352 frameView->updateAllLifecyclePhases(); |
2323 frameView->setTracksPaintInvalidations(true); | 2353 frameView->setTracksPaintInvalidations(true); |
2324 } | 2354 } |
2325 | 2355 |
2326 void Internals::stopTrackingRepaints(Document* document, | 2356 void Internals::stopTrackingRepaints(Document* document, |
2327 ExceptionState& exceptionState) { | 2357 ExceptionState& exceptionState) { |
2328 ASSERT(document); | 2358 DCHECK(document); |
2329 if (!document->view()) { | 2359 if (!document->view()) { |
2330 exceptionState.throwDOMException(InvalidAccessError, | 2360 exceptionState.throwDOMException(InvalidAccessError, |
2331 "The document provided is invalid."); | 2361 "The document provided is invalid."); |
2332 return; | 2362 return; |
2333 } | 2363 } |
2334 | 2364 |
2335 FrameView* frameView = document->view(); | 2365 FrameView* frameView = document->view(); |
2336 frameView->updateAllLifecyclePhases(); | 2366 frameView->updateAllLifecyclePhases(); |
2337 frameView->setTracksPaintInvalidations(false); | 2367 frameView->setTracksPaintInvalidations(false); |
2338 } | 2368 } |
(...skipping 14 matching lines...) Expand all Loading... |
2353 exceptionState.throwTypeError( | 2383 exceptionState.throwTypeError( |
2354 "The node provided is neither a document nor an IFrame."); | 2384 "The node provided is neither a document nor an IFrame."); |
2355 return; | 2385 return; |
2356 } | 2386 } |
2357 document->updateStyleAndLayoutIgnorePendingStylesheets( | 2387 document->updateStyleAndLayoutIgnorePendingStylesheets( |
2358 Document::RunPostLayoutTasksSynchronously); | 2388 Document::RunPostLayoutTasksSynchronously); |
2359 } | 2389 } |
2360 | 2390 |
2361 void Internals::forceFullRepaint(Document* document, | 2391 void Internals::forceFullRepaint(Document* document, |
2362 ExceptionState& exceptionState) { | 2392 ExceptionState& exceptionState) { |
2363 ASSERT(document); | 2393 DCHECK(document); |
2364 if (!document->view()) { | 2394 if (!document->view()) { |
2365 exceptionState.throwDOMException(InvalidAccessError, | 2395 exceptionState.throwDOMException(InvalidAccessError, |
2366 "The document provided is invalid."); | 2396 "The document provided is invalid."); |
2367 return; | 2397 return; |
2368 } | 2398 } |
2369 | 2399 |
2370 LayoutViewItem layoutViewItem = document->layoutViewItem(); | 2400 LayoutViewItem layoutViewItem = document->layoutViewItem(); |
2371 if (!layoutViewItem.isNull()) | 2401 if (!layoutViewItem.isNull()) |
2372 layoutViewItem.invalidatePaintForViewAndCompositedLayers(); | 2402 layoutViewItem.invalidatePaintForViewAndCompositedLayers(); |
2373 } | 2403 } |
2374 | 2404 |
2375 ClientRectList* Internals::draggableRegions(Document* document, | 2405 ClientRectList* Internals::draggableRegions(Document* document, |
2376 ExceptionState& exceptionState) { | 2406 ExceptionState& exceptionState) { |
2377 return annotatedRegions(document, true, exceptionState); | 2407 return annotatedRegions(document, true, exceptionState); |
2378 } | 2408 } |
2379 | 2409 |
2380 ClientRectList* Internals::nonDraggableRegions(Document* document, | 2410 ClientRectList* Internals::nonDraggableRegions(Document* document, |
2381 ExceptionState& exceptionState) { | 2411 ExceptionState& exceptionState) { |
2382 return annotatedRegions(document, false, exceptionState); | 2412 return annotatedRegions(document, false, exceptionState); |
2383 } | 2413 } |
2384 | 2414 |
2385 ClientRectList* Internals::annotatedRegions(Document* document, | 2415 ClientRectList* Internals::annotatedRegions(Document* document, |
2386 bool draggable, | 2416 bool draggable, |
2387 ExceptionState& exceptionState) { | 2417 ExceptionState& exceptionState) { |
2388 ASSERT(document); | 2418 DCHECK(document); |
2389 if (!document->view()) { | 2419 if (!document->view()) { |
2390 exceptionState.throwDOMException(InvalidAccessError, | 2420 exceptionState.throwDOMException(InvalidAccessError, |
2391 "The document provided is invalid."); | 2421 "The document provided is invalid."); |
2392 return ClientRectList::create(); | 2422 return ClientRectList::create(); |
2393 } | 2423 } |
2394 | 2424 |
2395 document->updateStyleAndLayout(); | 2425 document->updateStyleAndLayout(); |
2396 document->view()->updateDocumentAnnotatedRegions(); | 2426 document->view()->updateDocumentAnnotatedRegions(); |
2397 Vector<AnnotatedRegionValue> regions = document->annotatedRegions(); | 2427 Vector<AnnotatedRegionValue> regions = document->annotatedRegions(); |
2398 | 2428 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 if (!frame()) { | 2595 if (!frame()) { |
2566 exceptionState.throwDOMException( | 2596 exceptionState.throwDOMException( |
2567 InvalidAccessError, "The document's frame cannot be retrieved."); | 2597 InvalidAccessError, "The document's frame cannot be retrieved."); |
2568 return nullptr; | 2598 return nullptr; |
2569 } | 2599 } |
2570 | 2600 |
2571 return ClientRect::create(FloatRect(frame()->selection().bounds())); | 2601 return ClientRect::create(FloatRect(frame()->selection().bounds())); |
2572 } | 2602 } |
2573 | 2603 |
2574 String Internals::markerTextForListItem(Element* element) { | 2604 String Internals::markerTextForListItem(Element* element) { |
2575 ASSERT(element); | 2605 DCHECK(element); |
2576 return blink::markerTextForListItem(element); | 2606 return blink::markerTextForListItem(element); |
2577 } | 2607 } |
2578 | 2608 |
2579 String Internals::getImageSourceURL(Element* element) { | 2609 String Internals::getImageSourceURL(Element* element) { |
2580 ASSERT(element); | 2610 DCHECK(element); |
2581 return element->imageSourceURL(); | 2611 return element->imageSourceURL(); |
2582 } | 2612 } |
2583 | 2613 |
2584 String Internals::selectMenuListText(HTMLSelectElement* select) { | 2614 String Internals::selectMenuListText(HTMLSelectElement* select) { |
2585 ASSERT(select); | 2615 DCHECK(select); |
2586 LayoutObject* layoutObject = select->layoutObject(); | 2616 LayoutObject* layoutObject = select->layoutObject(); |
2587 if (!layoutObject || !layoutObject->isMenuList()) | 2617 if (!layoutObject || !layoutObject->isMenuList()) |
2588 return String(); | 2618 return String(); |
2589 | 2619 |
2590 LayoutMenuListItem menuListItem = | 2620 LayoutMenuListItem menuListItem = |
2591 LayoutMenuListItem(toLayoutMenuList(layoutObject)); | 2621 LayoutMenuListItem(toLayoutMenuList(layoutObject)); |
2592 return menuListItem.text(); | 2622 return menuListItem.text(); |
2593 } | 2623 } |
2594 | 2624 |
2595 bool Internals::isSelectPopupVisible(Node* node) { | 2625 bool Internals::isSelectPopupVisible(Node* node) { |
2596 ASSERT(node); | 2626 DCHECK(node); |
2597 if (!isHTMLSelectElement(*node)) | 2627 if (!isHTMLSelectElement(*node)) |
2598 return false; | 2628 return false; |
2599 return toHTMLSelectElement(*node).popupIsVisible(); | 2629 return toHTMLSelectElement(*node).popupIsVisible(); |
2600 } | 2630 } |
2601 | 2631 |
2602 bool Internals::selectPopupItemStyleIsRtl(Node* node, int itemIndex) { | 2632 bool Internals::selectPopupItemStyleIsRtl(Node* node, int itemIndex) { |
2603 if (!node || !isHTMLSelectElement(*node)) | 2633 if (!node || !isHTMLSelectElement(*node)) |
2604 return false; | 2634 return false; |
2605 | 2635 |
2606 HTMLSelectElement& select = toHTMLSelectElement(*node); | 2636 HTMLSelectElement& select = toHTMLSelectElement(*node); |
(...skipping 18 matching lines...) Expand all Loading... |
2625 | 2655 |
2626 if (itemStyle) { | 2656 if (itemStyle) { |
2627 const SimpleFontData* fontData = itemStyle->font().primaryFont(); | 2657 const SimpleFontData* fontData = itemStyle->font().primaryFont(); |
2628 DCHECK(fontData); | 2658 DCHECK(fontData); |
2629 return fontData ? fontData->getFontMetrics().height() : 0; | 2659 return fontData ? fontData->getFontMetrics().height() : 0; |
2630 } | 2660 } |
2631 return 0; | 2661 return 0; |
2632 } | 2662 } |
2633 | 2663 |
2634 void Internals::resetTypeAheadSession(HTMLSelectElement* select) { | 2664 void Internals::resetTypeAheadSession(HTMLSelectElement* select) { |
2635 ASSERT(select); | 2665 DCHECK(select); |
2636 select->resetTypeAheadSessionForTesting(); | 2666 select->resetTypeAheadSessionForTesting(); |
2637 } | 2667 } |
2638 | 2668 |
2639 bool Internals::loseSharedGraphicsContext3D() { | 2669 bool Internals::loseSharedGraphicsContext3D() { |
2640 std::unique_ptr<WebGraphicsContext3DProvider> sharedProvider = | 2670 std::unique_ptr<WebGraphicsContext3DProvider> sharedProvider = |
2641 WTF::wrapUnique(Platform::current() | 2671 WTF::wrapUnique(Platform::current() |
2642 ->createSharedOffscreenGraphicsContext3DProvider()); | 2672 ->createSharedOffscreenGraphicsContext3DProvider()); |
2643 if (!sharedProvider) | 2673 if (!sharedProvider) |
2644 return false; | 2674 return false; |
2645 gpu::gles2::GLES2Interface* sharedGL = sharedProvider->contextGL(); | 2675 gpu::gles2::GLES2Interface* sharedGL = sharedProvider->contextGL(); |
2646 sharedGL->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_EXT, | 2676 sharedGL->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_EXT, |
2647 GL_INNOCENT_CONTEXT_RESET_EXT); | 2677 GL_INNOCENT_CONTEXT_RESET_EXT); |
2648 // To prevent tests that call loseSharedGraphicsContext3D from being | 2678 // To prevent tests that call loseSharedGraphicsContext3D from being |
2649 // flaky, we call finish so that the context is guaranteed to be lost | 2679 // flaky, we call finish so that the context is guaranteed to be lost |
2650 // synchronously (i.e. before returning). | 2680 // synchronously (i.e. before returning). |
2651 sharedGL->Finish(); | 2681 sharedGL->Finish(); |
2652 return true; | 2682 return true; |
2653 } | 2683 } |
2654 | 2684 |
2655 void Internals::forceCompositingUpdate(Document* document, | 2685 void Internals::forceCompositingUpdate(Document* document, |
2656 ExceptionState& exceptionState) { | 2686 ExceptionState& exceptionState) { |
2657 ASSERT(document); | 2687 DCHECK(document); |
2658 if (document->layoutViewItem().isNull()) { | 2688 if (document->layoutViewItem().isNull()) { |
2659 exceptionState.throwDOMException(InvalidAccessError, | 2689 exceptionState.throwDOMException(InvalidAccessError, |
2660 "The document provided is invalid."); | 2690 "The document provided is invalid."); |
2661 return; | 2691 return; |
2662 } | 2692 } |
2663 | 2693 |
2664 document->frame()->view()->updateAllLifecyclePhases(); | 2694 document->frame()->view()->updateAllLifecyclePhases(); |
2665 } | 2695 } |
2666 | 2696 |
2667 void Internals::setZoomFactor(float factor) { | 2697 void Internals::setZoomFactor(float factor) { |
2668 if (!frame()) | 2698 if (!frame()) |
2669 return; | 2699 return; |
2670 | 2700 |
2671 frame()->setPageZoomFactor(factor); | 2701 frame()->setPageZoomFactor(factor); |
2672 } | 2702 } |
2673 | 2703 |
2674 void Internals::setShouldRevealPassword(Element* element, | 2704 void Internals::setShouldRevealPassword(Element* element, |
2675 bool reveal, | 2705 bool reveal, |
2676 ExceptionState& exceptionState) { | 2706 ExceptionState& exceptionState) { |
2677 ASSERT(element); | 2707 DCHECK(element); |
2678 if (!isHTMLInputElement(element)) { | 2708 if (!isHTMLInputElement(element)) { |
2679 exceptionState.throwDOMException(InvalidNodeTypeError, | 2709 exceptionState.throwDOMException(InvalidNodeTypeError, |
2680 "The element provided is not an INPUT."); | 2710 "The element provided is not an INPUT."); |
2681 return; | 2711 return; |
2682 } | 2712 } |
2683 | 2713 |
2684 return toHTMLInputElement(*element).setShouldRevealPassword(reveal); | 2714 return toHTMLInputElement(*element).setShouldRevealPassword(reveal); |
2685 } | 2715 } |
2686 | 2716 |
2687 namespace { | 2717 namespace { |
2688 | 2718 |
2689 class AddOneFunction : public ScriptFunction { | 2719 class AddOneFunction : public ScriptFunction { |
2690 public: | 2720 public: |
2691 static v8::Local<v8::Function> createFunction(ScriptState* scriptState) { | 2721 static v8::Local<v8::Function> createFunction(ScriptState* scriptState) { |
2692 AddOneFunction* self = new AddOneFunction(scriptState); | 2722 AddOneFunction* self = new AddOneFunction(scriptState); |
2693 return self->bindToV8Function(); | 2723 return self->bindToV8Function(); |
2694 } | 2724 } |
2695 | 2725 |
2696 private: | 2726 private: |
2697 explicit AddOneFunction(ScriptState* scriptState) | 2727 explicit AddOneFunction(ScriptState* scriptState) |
2698 : ScriptFunction(scriptState) {} | 2728 : ScriptFunction(scriptState) {} |
2699 | 2729 |
2700 ScriptValue call(ScriptValue value) override { | 2730 ScriptValue call(ScriptValue value) override { |
2701 v8::Local<v8::Value> v8Value = value.v8Value(); | 2731 v8::Local<v8::Value> v8Value = value.v8Value(); |
2702 ASSERT(v8Value->IsNumber()); | 2732 DCHECK(v8Value->IsNumber()); |
2703 int intValue = v8Value.As<v8::Integer>()->Value(); | 2733 int intValue = v8Value.As<v8::Integer>()->Value(); |
2704 return ScriptValue( | 2734 return ScriptValue( |
2705 getScriptState(), | 2735 getScriptState(), |
2706 v8::Integer::New(getScriptState()->isolate(), intValue + 1)); | 2736 v8::Integer::New(getScriptState()->isolate(), intValue + 1)); |
2707 } | 2737 } |
2708 }; | 2738 }; |
2709 | 2739 |
2710 } // namespace | 2740 } // namespace |
2711 | 2741 |
2712 ScriptPromise Internals::createResolvedPromise(ScriptState* scriptState, | 2742 ScriptPromise Internals::createResolvedPromise(ScriptState* scriptState, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2824 void Internals::setInitialFocus(bool reverse) { | 2854 void Internals::setInitialFocus(bool reverse) { |
2825 if (!frame()) | 2855 if (!frame()) |
2826 return; | 2856 return; |
2827 | 2857 |
2828 frame()->document()->clearFocusedElement(); | 2858 frame()->document()->clearFocusedElement(); |
2829 frame()->page()->focusController().setInitialFocus( | 2859 frame()->page()->focusController().setInitialFocus( |
2830 reverse ? WebFocusTypeBackward : WebFocusTypeForward); | 2860 reverse ? WebFocusTypeBackward : WebFocusTypeForward); |
2831 } | 2861 } |
2832 | 2862 |
2833 bool Internals::ignoreLayoutWithPendingStylesheets(Document* document) { | 2863 bool Internals::ignoreLayoutWithPendingStylesheets(Document* document) { |
2834 ASSERT(document); | 2864 DCHECK(document); |
2835 return document->ignoreLayoutWithPendingStylesheets(); | 2865 return document->ignoreLayoutWithPendingStylesheets(); |
2836 } | 2866 } |
2837 | 2867 |
2838 void Internals::setNetworkConnectionInfoOverride( | 2868 void Internals::setNetworkConnectionInfoOverride( |
2839 bool onLine, | 2869 bool onLine, |
2840 const String& type, | 2870 const String& type, |
2841 double downlinkMaxMbps, | 2871 double downlinkMaxMbps, |
2842 ExceptionState& exceptionState) { | 2872 ExceptionState& exceptionState) { |
2843 WebConnectionType webtype; | 2873 WebConnectionType webtype; |
2844 if (type == "cellular2g") { | 2874 if (type == "cellular2g") { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3016 | 3046 |
3017 double Internals::monotonicTimeToZeroBasedDocumentTime( | 3047 double Internals::monotonicTimeToZeroBasedDocumentTime( |
3018 double platformTime, | 3048 double platformTime, |
3019 ExceptionState& exceptionState) { | 3049 ExceptionState& exceptionState) { |
3020 return m_document->loader()->timing().monotonicTimeToZeroBasedDocumentTime( | 3050 return m_document->loader()->timing().monotonicTimeToZeroBasedDocumentTime( |
3021 platformTime); | 3051 platformTime); |
3022 } | 3052 } |
3023 | 3053 |
3024 void Internals::setMediaElementNetworkState(HTMLMediaElement* mediaElement, | 3054 void Internals::setMediaElementNetworkState(HTMLMediaElement* mediaElement, |
3025 int state) { | 3055 int state) { |
3026 ASSERT(mediaElement); | 3056 DCHECK(mediaElement); |
3027 ASSERT(state >= WebMediaPlayer::NetworkState::NetworkStateEmpty); | 3057 DCHECK(state >= WebMediaPlayer::NetworkState::NetworkStateEmpty); |
3028 ASSERT(state <= WebMediaPlayer::NetworkState::NetworkStateDecodeError); | 3058 DCHECK(state <= WebMediaPlayer::NetworkState::NetworkStateDecodeError); |
3029 mediaElement->setNetworkState( | 3059 mediaElement->setNetworkState( |
3030 static_cast<WebMediaPlayer::NetworkState>(state)); | 3060 static_cast<WebMediaPlayer::NetworkState>(state)); |
3031 } | 3061 } |
3032 | 3062 |
3033 String Internals::getScrollAnimationState(Node* node) const { | 3063 String Internals::getScrollAnimationState(Node* node) const { |
3034 if (ScrollableArea* scrollableArea = scrollableAreaForNode(node)) | 3064 if (ScrollableArea* scrollableArea = scrollableAreaForNode(node)) |
3035 return scrollableArea->scrollAnimator().runStateAsText(); | 3065 return scrollableArea->scrollAnimator().runStateAsText(); |
3036 return String(); | 3066 return String(); |
3037 } | 3067 } |
3038 | 3068 |
(...skipping 12 matching lines...) Expand all Loading... |
3051 | 3081 |
3052 void Internals::crash() { | 3082 void Internals::crash() { |
3053 CHECK(false) << "Intentional crash"; | 3083 CHECK(false) << "Intentional crash"; |
3054 } | 3084 } |
3055 | 3085 |
3056 void Internals::setIsLowEndDevice(bool isLowEndDevice) { | 3086 void Internals::setIsLowEndDevice(bool isLowEndDevice) { |
3057 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); | 3087 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); |
3058 } | 3088 } |
3059 | 3089 |
3060 } // namespace blink | 3090 } // namespace blink |
OLD | NEW |