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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 Document* document = contextDocument(); | 332 Document* document = contextDocument(); |
333 if (enabled) | 333 if (enabled) |
334 document->ensureStyleResolver().enableStats(StyleResolver::ReportSlowSta
ts); | 334 document->ensureStyleResolver().enableStats(StyleResolver::ReportSlowSta
ts); |
335 else | 335 else |
336 document->ensureStyleResolver().disableStats(); | 336 document->ensureStyleResolver().disableStats(); |
337 } | 337 } |
338 | 338 |
339 String Internals::styleResolverStatsReport(ExceptionState& exceptionState) const | 339 String Internals::styleResolverStatsReport(ExceptionState& exceptionState) const |
340 { | 340 { |
341 Document* document = contextDocument(); | 341 Document* document = contextDocument(); |
| 342 if (!document) { |
| 343 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); |
| 344 return String(); |
| 345 } |
342 if (!document->ensureStyleResolver().stats()) { | 346 if (!document->ensureStyleResolver().stats()) { |
343 exceptionState.throwDOMException(InvalidStateError, "Style resolver stat
s not enabled"); | 347 exceptionState.throwDOMException(InvalidStateError, "Style resolver stat
s not enabled"); |
344 return String(); | 348 return String(); |
345 } | 349 } |
346 return document->ensureStyleResolver().stats()->report(); | 350 return document->ensureStyleResolver().stats()->report(); |
347 } | 351 } |
348 | 352 |
349 String Internals::styleResolverStatsTotalsReport(ExceptionState& exceptionState)
const | 353 String Internals::styleResolverStatsTotalsReport(ExceptionState& exceptionState)
const |
350 { | 354 { |
351 Document* document = contextDocument(); | 355 Document* document = contextDocument(); |
| 356 if (!document) { |
| 357 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); |
| 358 return String(); |
| 359 } |
352 if (!document->ensureStyleResolver().statsTotals()) { | 360 if (!document->ensureStyleResolver().statsTotals()) { |
353 exceptionState.throwDOMException(InvalidStateError, "Style resolver stat
s not enabled"); | 361 exceptionState.throwDOMException(InvalidStateError, "Style resolver stat
s not enabled"); |
354 return String(); | 362 return String(); |
355 } | 363 } |
356 return document->ensureStyleResolver().statsTotals()->report(); | 364 return document->ensureStyleResolver().statsTotals()->report(); |
357 } | 365 } |
358 | 366 |
359 bool Internals::isSharingStyle(Element* element1, Element* element2, ExceptionSt
ate& exceptionState) const | 367 bool Internals::isSharingStyle(Element* element1, Element* element2) const |
360 { | 368 { |
361 if (!element1 || !element2) { | 369 ASSERT(element1 && element2); |
362 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(element1 ? 2 : 1, "Element")); | |
363 return false; | |
364 } | |
365 return element1->renderStyle() == element2->renderStyle(); | 370 return element1->renderStyle() == element2->renderStyle(); |
366 } | 371 } |
367 | 372 |
368 bool Internals::isValidContentSelect(Element* insertionPoint, ExceptionState& ex
ceptionState) | 373 bool Internals::isValidContentSelect(Element* insertionPoint, ExceptionState& ex
ceptionState) |
369 { | 374 { |
370 if (!insertionPoint || !insertionPoint->isInsertionPoint()) { | 375 ASSERT(insertionPoint); |
371 exceptionState.throwDOMException(InvalidAccessError, "The insertion poin
t provided is invalid."); | 376 if (!insertionPoint->isInsertionPoint()) { |
| 377 exceptionState.throwDOMException(InvalidAccessError, "The element is not
an insertion point."); |
372 return false; | 378 return false; |
373 } | 379 } |
374 | 380 |
375 return isHTMLContentElement(*insertionPoint) && toHTMLContentElement(*insert
ionPoint).isSelectValid(); | 381 return isHTMLContentElement(*insertionPoint) && toHTMLContentElement(*insert
ionPoint).isSelectValid(); |
376 } | 382 } |
377 | 383 |
378 Node* Internals::treeScopeRootNode(Node* node, ExceptionState& exceptionState) | 384 Node* Internals::treeScopeRootNode(Node* node) |
379 { | 385 { |
380 if (!node) { | 386 ASSERT(node); |
381 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
382 return 0; | |
383 } | |
384 | |
385 return &node->treeScope().rootNode(); | 387 return &node->treeScope().rootNode(); |
386 } | 388 } |
387 | 389 |
388 Node* Internals::parentTreeScope(Node* node, ExceptionState& exceptionState) | 390 Node* Internals::parentTreeScope(Node* node) |
389 { | 391 { |
390 if (!node) { | 392 ASSERT(node); |
391 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
392 return 0; | |
393 } | |
394 const TreeScope* parentTreeScope = node->treeScope().parentTreeScope(); | 393 const TreeScope* parentTreeScope = node->treeScope().parentTreeScope(); |
395 return parentTreeScope ? &parentTreeScope->rootNode() : 0; | 394 return parentTreeScope ? &parentTreeScope->rootNode() : 0; |
396 } | 395 } |
397 | 396 |
398 bool Internals::hasSelectorForIdInShadow(Element* host, const AtomicString& idVa
lue, ExceptionState& exceptionState) | 397 bool Internals::hasSelectorForIdInShadow(Element* host, const AtomicString& idVa
lue, ExceptionState& exceptionState) |
399 { | 398 { |
400 if (!host || !host->shadow()) { | 399 ASSERT(host); |
401 exceptionState.throwDOMException(InvalidAccessError, "The host element p
rovided is invalid, or does not have a shadow."); | 400 if (!host->shadow()) { |
| 401 exceptionState.throwDOMException(InvalidAccessError, "The host element d
oes not have a shadow."); |
402 return 0; | 402 return 0; |
403 } | 403 } |
404 | 404 |
405 return host->shadow()->ensureSelectFeatureSet().hasSelectorForId(idValue); | 405 return host->shadow()->ensureSelectFeatureSet().hasSelectorForId(idValue); |
406 } | 406 } |
407 | 407 |
408 bool Internals::hasSelectorForClassInShadow(Element* host, const AtomicString& c
lassName, ExceptionState& exceptionState) | 408 bool Internals::hasSelectorForClassInShadow(Element* host, const AtomicString& c
lassName, ExceptionState& exceptionState) |
409 { | 409 { |
410 if (!host || !host->shadow()) { | 410 ASSERT(host); |
411 exceptionState.throwDOMException(InvalidAccessError, "The host element p
rovided is invalid, or does not have a shadow."); | 411 if (!host->shadow()) { |
| 412 exceptionState.throwDOMException(InvalidAccessError, "The host element d
oes not have a shadow."); |
412 return 0; | 413 return 0; |
413 } | 414 } |
414 | 415 |
415 return host->shadow()->ensureSelectFeatureSet().hasSelectorForClass(classNam
e); | 416 return host->shadow()->ensureSelectFeatureSet().hasSelectorForClass(classNam
e); |
416 } | 417 } |
417 | 418 |
418 bool Internals::hasSelectorForAttributeInShadow(Element* host, const AtomicStrin
g& attributeName, ExceptionState& exceptionState) | 419 bool Internals::hasSelectorForAttributeInShadow(Element* host, const AtomicStrin
g& attributeName, ExceptionState& exceptionState) |
419 { | 420 { |
420 if (!host || !host->shadow()) { | 421 ASSERT(host); |
421 exceptionState.throwDOMException(InvalidAccessError, "The host element p
rovided is invalid, or does not have a shadow."); | 422 if (!host->shadow()) { |
| 423 exceptionState.throwDOMException(InvalidAccessError, "The host element d
oes not have a shadow."); |
422 return 0; | 424 return 0; |
423 } | 425 } |
424 | 426 |
425 return host->shadow()->ensureSelectFeatureSet().hasSelectorForAttribute(attr
ibuteName); | 427 return host->shadow()->ensureSelectFeatureSet().hasSelectorForAttribute(attr
ibuteName); |
426 } | 428 } |
427 | 429 |
428 bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& p
seudoClass, ExceptionState& exceptionState) | 430 bool Internals::hasSelectorForPseudoClassInShadow(Element* host, const String& p
seudoClass, ExceptionState& exceptionState) |
429 { | 431 { |
430 if (!host || !host->shadow()) { | 432 ASSERT(host); |
431 exceptionState.throwDOMException(InvalidAccessError, "The host element p
rovided is invalid, or does not have a shadow."); | 433 if (!host->shadow()) { |
| 434 exceptionState.throwDOMException(InvalidAccessError, "The host element d
oes not have a shadow."); |
432 return 0; | 435 return 0; |
433 } | 436 } |
434 | 437 |
435 const SelectRuleFeatureSet& featureSet = host->shadow()->ensureSelectFeature
Set(); | 438 const SelectRuleFeatureSet& featureSet = host->shadow()->ensureSelectFeature
Set(); |
436 if (pseudoClass == "checked") | 439 if (pseudoClass == "checked") |
437 return featureSet.hasSelectorForChecked(); | 440 return featureSet.hasSelectorForChecked(); |
438 if (pseudoClass == "enabled") | 441 if (pseudoClass == "enabled") |
439 return featureSet.hasSelectorForEnabled(); | 442 return featureSet.hasSelectorForEnabled(); |
440 if (pseudoClass == "disabled") | 443 if (pseudoClass == "disabled") |
441 return featureSet.hasSelectorForDisabled(); | 444 return featureSet.hasSelectorForDisabled(); |
442 if (pseudoClass == "indeterminate") | 445 if (pseudoClass == "indeterminate") |
443 return featureSet.hasSelectorForIndeterminate(); | 446 return featureSet.hasSelectorForIndeterminate(); |
444 if (pseudoClass == "link") | 447 if (pseudoClass == "link") |
445 return featureSet.hasSelectorForLink(); | 448 return featureSet.hasSelectorForLink(); |
446 if (pseudoClass == "target") | 449 if (pseudoClass == "target") |
447 return featureSet.hasSelectorForTarget(); | 450 return featureSet.hasSelectorForTarget(); |
448 if (pseudoClass == "visited") | 451 if (pseudoClass == "visited") |
449 return featureSet.hasSelectorForVisited(); | 452 return featureSet.hasSelectorForVisited(); |
450 | 453 |
451 ASSERT_NOT_REACHED(); | 454 ASSERT_NOT_REACHED(); |
452 return false; | 455 return false; |
453 } | 456 } |
454 | 457 |
455 unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node
* node2, ExceptionState& exceptionState) const | 458 unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node
* node2, ExceptionState& exceptionState) const |
456 { | 459 { |
457 if (!node1 || !node2) { | 460 ASSERT(node1 && node2); |
458 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(node1 ? 2 : 1, "Node")); | |
459 return 0; | |
460 } | |
461 const TreeScope* treeScope1 = node1->isDocumentNode() ? static_cast<const Tr
eeScope*>(toDocument(node1)) : | 461 const TreeScope* treeScope1 = node1->isDocumentNode() ? static_cast<const Tr
eeScope*>(toDocument(node1)) : |
462 node1->isShadowRoot() ? static_cast<const TreeScope*>(toShadowRoot(node1
)) : 0; | 462 node1->isShadowRoot() ? static_cast<const TreeScope*>(toShadowRoot(node1
)) : 0; |
463 const TreeScope* treeScope2 = node2->isDocumentNode() ? static_cast<const Tr
eeScope*>(toDocument(node2)) : | 463 const TreeScope* treeScope2 = node2->isDocumentNode() ? static_cast<const Tr
eeScope*>(toDocument(node2)) : |
464 node2->isShadowRoot() ? static_cast<const TreeScope*>(toShadowRoot(node2
)) : 0; | 464 node2->isShadowRoot() ? static_cast<const TreeScope*>(toShadowRoot(node2
)) : 0; |
465 if (!treeScope1 || !treeScope2) { | 465 if (!treeScope1 || !treeScope2) { |
466 exceptionState.throwDOMException(InvalidAccessError, String::format("The
%s node is neither a document node, nor a shadow root.", treeScope1 ? "second"
: "first")); | 466 exceptionState.throwDOMException(InvalidAccessError, String::format("The
%s node is neither a document node, nor a shadow root.", treeScope1 ? "second"
: "first")); |
467 return 0; | 467 return 0; |
468 } | 468 } |
469 return treeScope1->comparePosition(*treeScope2); | 469 return treeScope1->comparePosition(*treeScope2); |
470 } | 470 } |
471 | 471 |
472 void Internals::pauseAnimations(double pauseTime, ExceptionState& exceptionState
) | 472 void Internals::pauseAnimations(double pauseTime, ExceptionState& exceptionState
) |
473 { | 473 { |
474 if (pauseTime < 0) { | 474 if (pauseTime < 0) { |
475 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
indexExceedsMinimumBound("pauseTime", pauseTime, 0.0)); | 475 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
indexExceedsMinimumBound("pauseTime", pauseTime, 0.0)); |
476 return; | 476 return; |
477 } | 477 } |
478 | 478 |
479 frame()->view()->updateLayoutAndStyleForPainting(); | 479 frame()->view()->updateLayoutAndStyleForPainting(); |
480 frame()->document()->timeline().pauseAnimationsForTesting(pauseTime); | 480 frame()->document()->timeline().pauseAnimationsForTesting(pauseTime); |
481 } | 481 } |
482 | 482 |
483 bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionState& except
ionState) const | 483 bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionState& except
ionState) const |
484 { | 484 { |
485 if (root && root->isShadowRoot()) | 485 ASSERT(root); |
486 return toShadowRoot(root)->containsShadowElements(); | 486 if (!root->isShadowRoot()) { |
487 | 487 exceptionState.throwDOMException(InvalidAccessError, "The node argument
is not a shadow root."); |
488 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argu
mentNullOrIncorrectType(1, "Node")); | 488 return 0; |
489 return 0; | 489 } |
| 490 return toShadowRoot(root)->containsShadowElements(); |
490 } | 491 } |
491 | 492 |
492 bool Internals::hasContentElement(const Node* root, ExceptionState& exceptionSta
te) const | 493 bool Internals::hasContentElement(const Node* root, ExceptionState& exceptionSta
te) const |
493 { | 494 { |
494 if (root && root->isShadowRoot()) | 495 ASSERT(root); |
495 return toShadowRoot(root)->containsContentElements(); | 496 if (!root->isShadowRoot()) { |
496 | 497 exceptionState.throwDOMException(InvalidAccessError, "The node argument
is not a shadow root."); |
497 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::argu
mentNullOrIncorrectType(1, "Node")); | 498 return 0; |
498 return 0; | 499 } |
| 500 return toShadowRoot(root)->containsContentElements(); |
499 } | 501 } |
500 | 502 |
501 size_t Internals::countElementShadow(const Node* root, ExceptionState& exception
State) const | 503 size_t Internals::countElementShadow(const Node* root, ExceptionState& exception
State) const |
502 { | 504 { |
503 if (!root || !root->isShadowRoot()) { | 505 ASSERT(root); |
504 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | 506 if (!root->isShadowRoot()) { |
| 507 exceptionState.throwDOMException(InvalidAccessError, "The node argument
is not a shadow root."); |
505 return 0; | 508 return 0; |
506 } | 509 } |
507 return toShadowRoot(root)->childShadowRootCount(); | 510 return toShadowRoot(root)->childShadowRootCount(); |
508 } | 511 } |
509 | 512 |
510 Node* Internals::nextSiblingByWalker(Node* node, ExceptionState& exceptionState) | 513 Node* Internals::nextSiblingByWalker(Node* node) |
511 { | 514 { |
512 if (!node) { | 515 ASSERT(node); |
513 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
514 return 0; | |
515 } | |
516 ComposedTreeWalker walker(node); | 516 ComposedTreeWalker walker(node); |
517 walker.nextSibling(); | 517 walker.nextSibling(); |
518 return walker.get(); | 518 return walker.get(); |
519 } | 519 } |
520 | 520 |
521 Node* Internals::firstChildByWalker(Node* node, ExceptionState& exceptionState) | 521 Node* Internals::firstChildByWalker(Node* node) |
522 { | 522 { |
523 if (!node) { | 523 ASSERT(node); |
524 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
525 return 0; | |
526 } | |
527 ComposedTreeWalker walker(node); | 524 ComposedTreeWalker walker(node); |
528 walker.firstChild(); | 525 walker.firstChild(); |
529 return walker.get(); | 526 return walker.get(); |
530 } | 527 } |
531 | 528 |
532 Node* Internals::lastChildByWalker(Node* node, ExceptionState& exceptionState) | 529 Node* Internals::lastChildByWalker(Node* node) |
533 { | 530 { |
534 if (!node) { | 531 ASSERT(node); |
535 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
536 return 0; | |
537 } | |
538 ComposedTreeWalker walker(node); | 532 ComposedTreeWalker walker(node); |
539 walker.lastChild(); | 533 walker.lastChild(); |
540 return walker.get(); | 534 return walker.get(); |
541 } | 535 } |
542 | 536 |
543 Node* Internals::nextNodeByWalker(Node* node, ExceptionState& exceptionState) | 537 Node* Internals::nextNodeByWalker(Node* node) |
544 { | 538 { |
545 if (!node) { | 539 ASSERT(node); |
546 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
547 return 0; | |
548 } | |
549 ComposedTreeWalker walker(node); | 540 ComposedTreeWalker walker(node); |
550 walker.next(); | 541 walker.next(); |
551 return walker.get(); | 542 return walker.get(); |
552 } | 543 } |
553 | 544 |
554 Node* Internals::previousNodeByWalker(Node* node, ExceptionState& exceptionState
) | 545 Node* Internals::previousNodeByWalker(Node* node) |
555 { | 546 { |
556 if (!node) { | 547 ASSERT(node); |
557 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
558 return 0; | |
559 } | |
560 ComposedTreeWalker walker(node); | 548 ComposedTreeWalker walker(node); |
561 walker.previous(); | 549 walker.previous(); |
562 return walker.get(); | 550 return walker.get(); |
563 } | 551 } |
564 | 552 |
565 String Internals::elementRenderTreeAsText(Element* element, ExceptionState& exce
ptionState) | 553 String Internals::elementRenderTreeAsText(Element* element, ExceptionState& exce
ptionState) |
566 { | 554 { |
567 if (!element) { | 555 ASSERT(element); |
568 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
569 return String(); | |
570 } | |
571 | |
572 String representation = externalRepresentation(element); | 556 String representation = externalRepresentation(element); |
573 if (representation.isEmpty()) { | 557 if (representation.isEmpty()) { |
574 exceptionState.throwDOMException(InvalidAccessError, "The element provid
ed has no external representation."); | 558 exceptionState.throwDOMException(InvalidAccessError, "The element provid
ed has no external representation."); |
575 return String(); | 559 return String(); |
576 } | 560 } |
577 | 561 |
578 return representation; | 562 return representation; |
579 } | 563 } |
580 | 564 |
581 PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> Internals::computedStyleIncl
udingVisitedInfo(Node* node, ExceptionState& exceptionState) const | 565 PassRefPtrWillBeRawPtr<CSSStyleDeclaration> Internals::computedStyleIncludingVis
itedInfo(Node* node) const |
582 { | 566 { |
583 if (!node) { | 567 ASSERT(node); |
584 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
585 return nullptr; | |
586 } | |
587 | |
588 bool allowVisitedStyle = true; | 568 bool allowVisitedStyle = true; |
589 return CSSComputedStyleDeclaration::create(node, allowVisitedStyle); | 569 return CSSComputedStyleDeclaration::create(node, allowVisitedStyle); |
590 } | 570 } |
591 | 571 |
592 ShadowRoot* Internals::shadowRoot(Element* host, ExceptionState& exceptionState) | 572 ShadowRoot* Internals::shadowRoot(Element* host) |
593 { | 573 { |
594 // FIXME: Internals::shadowRoot() in tests should be converted to youngestSh
adowRoot() or oldestShadowRoot(). | 574 // FIXME: Internals::shadowRoot() in tests should be converted to youngestSh
adowRoot() or oldestShadowRoot(). |
595 // https://bugs.webkit.org/show_bug.cgi?id=78465 | 575 // https://bugs.webkit.org/show_bug.cgi?id=78465 |
596 return youngestShadowRoot(host, exceptionState); | 576 return youngestShadowRoot(host); |
597 } | 577 } |
598 | 578 |
599 ShadowRoot* Internals::youngestShadowRoot(Element* host, ExceptionState& excepti
onState) | 579 ShadowRoot* Internals::youngestShadowRoot(Element* host) |
600 { | 580 { |
601 if (!host) { | 581 ASSERT(host); |
602 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
603 return 0; | |
604 } | |
605 | |
606 if (ElementShadow* shadow = host->shadow()) | 582 if (ElementShadow* shadow = host->shadow()) |
607 return shadow->youngestShadowRoot(); | 583 return shadow->youngestShadowRoot(); |
608 return 0; | 584 return 0; |
609 } | 585 } |
610 | 586 |
611 ShadowRoot* Internals::oldestShadowRoot(Element* host, ExceptionState& exception
State) | 587 ShadowRoot* Internals::oldestShadowRoot(Element* host) |
612 { | 588 { |
613 if (!host) { | 589 ASSERT(host); |
614 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
615 return 0; | |
616 } | |
617 | |
618 if (ElementShadow* shadow = host->shadow()) | 590 if (ElementShadow* shadow = host->shadow()) |
619 return shadow->oldestShadowRoot(); | 591 return shadow->oldestShadowRoot(); |
620 return 0; | 592 return 0; |
621 } | 593 } |
622 | 594 |
623 ShadowRoot* Internals::youngerShadowRoot(Node* shadow, ExceptionState& exception
State) | 595 ShadowRoot* Internals::youngerShadowRoot(Node* shadow, ExceptionState& exception
State) |
624 { | 596 { |
625 if (!shadow || !shadow->isShadowRoot()) { | 597 ASSERT(shadow); |
626 exceptionState.throwDOMException(InvalidAccessError, "The node provided
is not a valid shadow root."); | 598 if (!shadow->isShadowRoot()) { |
| 599 exceptionState.throwDOMException(InvalidAccessError, "The node provided
is not a shadow root."); |
627 return 0; | 600 return 0; |
628 } | 601 } |
629 | 602 |
630 return toShadowRoot(shadow)->youngerShadowRoot(); | 603 return toShadowRoot(shadow)->youngerShadowRoot(); |
631 } | 604 } |
632 | 605 |
633 String Internals::shadowRootType(const Node* root, ExceptionState& exceptionStat
e) const | 606 String Internals::shadowRootType(const Node* root, ExceptionState& exceptionStat
e) const |
634 { | 607 { |
635 if (!root || !root->isShadowRoot()) { | 608 ASSERT(root); |
636 exceptionState.throwDOMException(InvalidAccessError, "The node provided
is not a valid shadow root."); | 609 if (!root->isShadowRoot()) { |
| 610 exceptionState.throwDOMException(InvalidAccessError, "The node provided
is not a shadow root."); |
637 return String(); | 611 return String(); |
638 } | 612 } |
639 | 613 |
640 switch (toShadowRoot(root)->type()) { | 614 switch (toShadowRoot(root)->type()) { |
641 case ShadowRoot::UserAgentShadowRoot: | 615 case ShadowRoot::UserAgentShadowRoot: |
642 return String("UserAgentShadowRoot"); | 616 return String("UserAgentShadowRoot"); |
643 case ShadowRoot::AuthorShadowRoot: | 617 case ShadowRoot::AuthorShadowRoot: |
644 return String("AuthorShadowRoot"); | 618 return String("AuthorShadowRoot"); |
645 default: | 619 default: |
646 ASSERT_NOT_REACHED(); | 620 ASSERT_NOT_REACHED(); |
647 return String("Unknown"); | 621 return String("Unknown"); |
648 } | 622 } |
649 } | 623 } |
650 | 624 |
651 const AtomicString& Internals::shadowPseudoId(Element* element, ExceptionState&
exceptionState) | 625 const AtomicString& Internals::shadowPseudoId(Element* element) |
652 { | 626 { |
653 if (!element) { | 627 ASSERT(element); |
654 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
655 return nullAtom; | |
656 } | |
657 | |
658 return element->shadowPseudoId(); | 628 return element->shadowPseudoId(); |
659 } | 629 } |
660 | 630 |
661 void Internals::setShadowPseudoId(Element* element, const AtomicString& id, Exce
ptionState& exceptionState) | 631 void Internals::setShadowPseudoId(Element* element, const AtomicString& id) |
662 { | 632 { |
663 if (!element) { | 633 ASSERT(element); |
664 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
665 return; | |
666 } | |
667 | |
668 return element->setShadowPseudoId(id); | 634 return element->setShadowPseudoId(id); |
669 } | 635 } |
670 | 636 |
671 String Internals::visiblePlaceholder(Element* element) | 637 String Internals::visiblePlaceholder(Element* element) |
672 { | 638 { |
673 if (element && isHTMLTextFormControlElement(*element)) { | 639 if (element && isHTMLTextFormControlElement(*element)) { |
674 if (toHTMLTextFormControlElement(element)->placeholderShouldBeVisible()) | 640 if (toHTMLTextFormControlElement(element)->placeholderShouldBeVisible()) |
675 return toHTMLTextFormControlElement(element)->placeholderElement()->
textContent(); | 641 return toHTMLTextFormControlElement(element)->placeholderElement()->
textContent(); |
676 } | 642 } |
677 | 643 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 { | 723 { |
758 Document* document = contextDocument(); | 724 Document* document = contextDocument(); |
759 if (!document || !document->frame()) { | 725 if (!document || !document->frame()) { |
760 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "No context document can be obtained."); | 726 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "No context document can be obtained."); |
761 return ClientRect::create(); | 727 return ClientRect::create(); |
762 } | 728 } |
763 | 729 |
764 return ClientRect::create(document->frame()->selection().absoluteCaretBounds
()); | 730 return ClientRect::create(document->frame()->selection().absoluteCaretBounds
()); |
765 } | 731 } |
766 | 732 |
767 PassRefPtrWillBeRawPtr<ClientRect> Internals::boundingBox(Element* element, Exce
ptionState& exceptionState) | 733 PassRefPtrWillBeRawPtr<ClientRect> Internals::boundingBox(Element* element) |
768 { | 734 { |
769 if (!element) { | 735 ASSERT(element); |
770 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
771 return ClientRect::create(); | |
772 } | |
773 | 736 |
774 element->document().updateLayoutIgnorePendingStylesheets(); | 737 element->document().updateLayoutIgnorePendingStylesheets(); |
775 RenderObject* renderer = element->renderer(); | 738 RenderObject* renderer = element->renderer(); |
776 if (!renderer) | 739 if (!renderer) |
777 return ClientRect::create(); | 740 return ClientRect::create(); |
778 return ClientRect::create(renderer->absoluteBoundingBoxRectIgnoringTransform
s()); | 741 return ClientRect::create(renderer->absoluteBoundingBoxRectIgnoringTransform
s()); |
779 } | 742 } |
780 | 743 |
781 unsigned Internals::markerCountForNode(Node* node, const String& markerType, Exc
eptionState& exceptionState) | 744 unsigned Internals::markerCountForNode(Node* node, const String& markerType, Exc
eptionState& exceptionState) |
782 { | 745 { |
783 if (!node) { | 746 ASSERT(node); |
784 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
785 return 0; | |
786 } | |
787 | |
788 DocumentMarker::MarkerTypes markerTypes = 0; | 747 DocumentMarker::MarkerTypes markerTypes = 0; |
789 if (!markerTypesFrom(markerType, markerTypes)) { | 748 if (!markerTypesFrom(markerType, markerTypes)) { |
790 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); | 749 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); |
791 return 0; | 750 return 0; |
792 } | 751 } |
793 | 752 |
794 return node->document().markers().markersFor(node, markerTypes).size(); | 753 return node->document().markers().markersFor(node, markerTypes).size(); |
795 } | 754 } |
796 | 755 |
797 unsigned Internals::activeMarkerCountForNode(Node* node, ExceptionState& excepti
onState) | 756 unsigned Internals::activeMarkerCountForNode(Node* node) |
798 { | 757 { |
799 if (!node) { | 758 ASSERT(node); |
800 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
801 return 0; | |
802 } | |
803 | 759 |
804 // Only TextMatch markers can be active. | 760 // Only TextMatch markers can be active. |
805 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; | 761 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; |
806 DocumentMarkerVector markers = node->document().markers().markersFor(node, m
arkerType); | 762 DocumentMarkerVector markers = node->document().markers().markersFor(node, m
arkerType); |
807 | 763 |
808 unsigned activeMarkerCount = 0; | 764 unsigned activeMarkerCount = 0; |
809 for (DocumentMarkerVector::iterator iter = markers.begin(); iter != markers.
end(); ++iter) { | 765 for (DocumentMarkerVector::iterator iter = markers.begin(); iter != markers.
end(); ++iter) { |
810 if ((*iter)->activeMatch()) | 766 if ((*iter)->activeMatch()) |
811 activeMarkerCount++; | 767 activeMarkerCount++; |
812 } | 768 } |
813 | 769 |
814 return activeMarkerCount; | 770 return activeMarkerCount; |
815 } | 771 } |
816 | 772 |
817 DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsign
ed index, ExceptionState& exceptionState) | 773 DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsign
ed index, ExceptionState& exceptionState) |
818 { | 774 { |
819 if (!node) { | 775 ASSERT(node); |
820 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
821 return 0; | |
822 } | |
823 | |
824 DocumentMarker::MarkerTypes markerTypes = 0; | 776 DocumentMarker::MarkerTypes markerTypes = 0; |
825 if (!markerTypesFrom(markerType, markerTypes)) { | 777 if (!markerTypesFrom(markerType, markerTypes)) { |
826 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); | 778 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); |
827 return 0; | 779 return 0; |
828 } | 780 } |
829 | 781 |
830 DocumentMarkerVector markers = node->document().markers().markersFor(node, m
arkerTypes); | 782 DocumentMarkerVector markers = node->document().markers().markersFor(node, m
arkerTypes); |
831 if (markers.size() <= index) | 783 if (markers.size() <= index) |
832 return 0; | 784 return 0; |
833 return markers[index]; | 785 return markers[index]; |
834 } | 786 } |
835 | 787 |
836 PassRefPtrWillBeRawPtr<Range> Internals::markerRangeForNode(Node* node, const St
ring& markerType, unsigned index, ExceptionState& exceptionState) | 788 PassRefPtrWillBeRawPtr<Range> Internals::markerRangeForNode(Node* node, const St
ring& markerType, unsigned index, ExceptionState& exceptionState) |
837 { | 789 { |
| 790 ASSERT(node); |
838 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); | 791 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); |
839 if (!marker) | 792 if (!marker) |
840 return nullptr; | 793 return nullptr; |
841 return Range::create(node->document(), node, marker->startOffset(), node, ma
rker->endOffset()); | 794 return Range::create(node->document(), node, marker->startOffset(), node, ma
rker->endOffset()); |
842 } | 795 } |
843 | 796 |
844 String Internals::markerDescriptionForNode(Node* node, const String& markerType,
unsigned index, ExceptionState& exceptionState) | 797 String Internals::markerDescriptionForNode(Node* node, const String& markerType,
unsigned index, ExceptionState& exceptionState) |
845 { | 798 { |
846 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); | 799 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); |
847 if (!marker) | 800 if (!marker) |
848 return String(); | 801 return String(); |
849 return marker->description(); | 802 return marker->description(); |
850 } | 803 } |
851 | 804 |
852 void Internals::addTextMatchMarker(const Range* range, bool isActive) | 805 void Internals::addTextMatchMarker(const Range* range, bool isActive) |
853 { | 806 { |
| 807 ASSERT(range); |
854 range->ownerDocument().updateLayoutIgnorePendingStylesheets(); | 808 range->ownerDocument().updateLayoutIgnorePendingStylesheets(); |
855 range->ownerDocument().markers().addTextMatchMarker(range, isActive); | 809 range->ownerDocument().markers().addTextMatchMarker(range, isActive); |
856 } | 810 } |
857 | 811 |
858 void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endO
ffset, bool active, ExceptionState& exceptionState) | 812 void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endO
ffset, bool active) |
859 { | 813 { |
860 if (!node) { | 814 ASSERT(node); |
861 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | |
862 return; | |
863 } | |
864 | |
865 node->document().markers().setMarkersActive(node, startOffset, endOffset, ac
tive); | 815 node->document().markers().setMarkersActive(node, startOffset, endOffset, ac
tive); |
866 } | 816 } |
867 | 817 |
868 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, bool high
light, ExceptionState&) | 818 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, bool high
light) |
869 { | 819 { |
870 if (!document || !document->frame()) | 820 if (!document || !document->frame()) |
871 return; | 821 return; |
872 | 822 |
873 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); | 823 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); |
874 } | 824 } |
875 | 825 |
876 void Internals::setScrollViewPosition(Document* document, long x, long y, Except
ionState& exceptionState) | 826 void Internals::setScrollViewPosition(Document* document, long x, long y, Except
ionState& exceptionState) |
877 { | 827 { |
878 if (!document || !document->view()) { | 828 ASSERT(document); |
879 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's view cannot be retrieved." : "The document provided is invalid."); | 829 if (!document->view()) { |
| 830 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
880 return; | 831 return; |
881 } | 832 } |
882 | 833 |
883 FrameView* frameView = document->view(); | 834 FrameView* frameView = document->view(); |
884 bool constrainsScrollingToContentEdgeOldValue = frameView->constrainsScrolli
ngToContentEdge(); | 835 bool constrainsScrollingToContentEdgeOldValue = frameView->constrainsScrolli
ngToContentEdge(); |
885 bool scrollbarsSuppressedOldValue = frameView->scrollbarsSuppressed(); | 836 bool scrollbarsSuppressedOldValue = frameView->scrollbarsSuppressed(); |
886 | 837 |
887 frameView->setConstrainsScrollingToContentEdge(false); | 838 frameView->setConstrainsScrollingToContentEdge(false); |
888 frameView->setScrollbarsSuppressed(false); | 839 frameView->setScrollbarsSuppressed(false); |
889 frameView->setScrollOffsetFromInternals(IntPoint(x, y)); | 840 frameView->setScrollOffsetFromInternals(IntPoint(x, y)); |
890 frameView->setScrollbarsSuppressed(scrollbarsSuppressedOldValue); | 841 frameView->setScrollbarsSuppressed(scrollbarsSuppressedOldValue); |
891 frameView->setConstrainsScrollingToContentEdge(constrainsScrollingToContentE
dgeOldValue); | 842 frameView->setConstrainsScrollingToContentEdge(constrainsScrollingToContentE
dgeOldValue); |
892 } | 843 } |
893 | 844 |
894 String Internals::viewportAsText(Document* document, float, int availableWidth,
int availableHeight, ExceptionState& exceptionState) | 845 String Internals::viewportAsText(Document* document, float, int availableWidth,
int availableHeight, ExceptionState& exceptionState) |
895 { | 846 { |
896 if (!document || !document->page()) { | 847 ASSERT(document); |
897 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's page cannot be retrieved." : "The document provided is invalid."); | 848 if (!document->page()) { |
| 849 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
898 return String(); | 850 return String(); |
899 } | 851 } |
900 | 852 |
901 document->updateLayoutIgnorePendingStylesheets(); | 853 document->updateLayoutIgnorePendingStylesheets(); |
902 | 854 |
903 Page* page = document->page(); | 855 Page* page = document->page(); |
904 | 856 |
905 // Update initial viewport size. | 857 // Update initial viewport size. |
906 IntSize initialViewportSize(availableWidth, availableHeight); | 858 IntSize initialViewportSize(availableWidth, availableHeight); |
907 document->page()->deprecatedLocalMainFrame()->view()->setFrameRect(IntRect(I
ntPoint::zero(), initialViewportSize)); | 859 document->page()->deprecatedLocalMainFrame()->view()->setFrameRect(IntRect(I
ntPoint::zero(), initialViewportSize)); |
(...skipping 18 matching lines...) Expand all Loading... |
926 builder.append(String::number(constraints.maximumScale)); | 878 builder.append(String::number(constraints.maximumScale)); |
927 | 879 |
928 builder.appendLiteral("] and userScalable "); | 880 builder.appendLiteral("] and userScalable "); |
929 builder.append(description.userZoom ? "true" : "false"); | 881 builder.append(description.userZoom ? "true" : "false"); |
930 | 882 |
931 return builder.toString(); | 883 return builder.toString(); |
932 } | 884 } |
933 | 885 |
934 bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionState& except
ionState) | 886 bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionState& except
ionState) |
935 { | 887 { |
936 if (!textField) { | 888 ASSERT(textField); |
937 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
938 return false; | |
939 } | |
940 | |
941 if (isHTMLInputElement(*textField)) | 889 if (isHTMLInputElement(*textField)) |
942 return toHTMLInputElement(*textField).lastChangeWasUserEdit(); | 890 return toHTMLInputElement(*textField).lastChangeWasUserEdit(); |
943 | 891 |
944 if (isHTMLTextAreaElement(*textField)) | 892 if (isHTMLTextAreaElement(*textField)) |
945 return toHTMLTextAreaElement(*textField).lastChangeWasUserEdit(); | 893 return toHTMLTextAreaElement(*textField).lastChangeWasUserEdit(); |
946 | 894 |
947 exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided
is not a TEXTAREA."); | 895 exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided
is not a TEXTAREA."); |
948 return false; | 896 return false; |
949 } | 897 } |
950 | 898 |
951 bool Internals::elementShouldAutoComplete(Element* element, ExceptionState& exce
ptionState) | 899 bool Internals::elementShouldAutoComplete(Element* element, ExceptionState& exce
ptionState) |
952 { | 900 { |
953 if (!element) { | 901 ASSERT(element); |
954 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
955 return false; | |
956 } | |
957 | |
958 if (isHTMLInputElement(*element)) | 902 if (isHTMLInputElement(*element)) |
959 return toHTMLInputElement(*element).shouldAutocomplete(); | 903 return toHTMLInputElement(*element).shouldAutocomplete(); |
960 | 904 |
961 exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided
is not an INPUT."); | 905 exceptionState.throwDOMException(InvalidNodeTypeError, "The element provided
is not an INPUT."); |
962 return false; | 906 return false; |
963 } | 907 } |
964 | 908 |
965 String Internals::suggestedValue(Element* element, ExceptionState& exceptionStat
e) | 909 String Internals::suggestedValue(Element* element, ExceptionState& exceptionStat
e) |
966 { | 910 { |
967 if (!element) { | 911 ASSERT(element); |
968 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
969 return String(); | |
970 } | |
971 | |
972 if (!element->isFormControlElement()) { | 912 if (!element->isFormControlElement()) { |
973 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not a form control element."); | 913 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not a form control element."); |
974 return String(); | 914 return String(); |
975 } | 915 } |
976 | 916 |
977 String suggestedValue; | 917 String suggestedValue; |
978 if (isHTMLInputElement(*element)) | 918 if (isHTMLInputElement(*element)) |
979 suggestedValue = toHTMLInputElement(*element).suggestedValue(); | 919 suggestedValue = toHTMLInputElement(*element).suggestedValue(); |
980 | 920 |
981 if (isHTMLTextAreaElement(*element)) | 921 if (isHTMLTextAreaElement(*element)) |
982 suggestedValue = toHTMLTextAreaElement(*element).suggestedValue(); | 922 suggestedValue = toHTMLTextAreaElement(*element).suggestedValue(); |
983 | 923 |
984 if (isHTMLSelectElement(*element)) | 924 if (isHTMLSelectElement(*element)) |
985 suggestedValue = toHTMLSelectElement(*element).suggestedValue(); | 925 suggestedValue = toHTMLSelectElement(*element).suggestedValue(); |
986 | 926 |
987 return suggestedValue; | 927 return suggestedValue; |
988 } | 928 } |
989 | 929 |
990 void Internals::setSuggestedValue(Element* element, const String& value, Excepti
onState& exceptionState) | 930 void Internals::setSuggestedValue(Element* element, const String& value, Excepti
onState& exceptionState) |
991 { | 931 { |
992 if (!element) { | 932 ASSERT(element); |
993 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
994 return; | |
995 } | |
996 | |
997 if (!element->isFormControlElement()) { | 933 if (!element->isFormControlElement()) { |
998 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not a form control element."); | 934 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not a form control element."); |
999 return; | 935 return; |
1000 } | 936 } |
1001 | 937 |
1002 if (isHTMLInputElement(*element)) | 938 if (isHTMLInputElement(*element)) |
1003 toHTMLInputElement(*element).setSuggestedValue(value); | 939 toHTMLInputElement(*element).setSuggestedValue(value); |
1004 | 940 |
1005 if (isHTMLTextAreaElement(*element)) | 941 if (isHTMLTextAreaElement(*element)) |
1006 toHTMLTextAreaElement(*element).setSuggestedValue(value); | 942 toHTMLTextAreaElement(*element).setSuggestedValue(value); |
1007 | 943 |
1008 if (isHTMLSelectElement(*element)) | 944 if (isHTMLSelectElement(*element)) |
1009 toHTMLSelectElement(*element).setSuggestedValue(value); | 945 toHTMLSelectElement(*element).setSuggestedValue(value); |
1010 } | 946 } |
1011 | 947 |
1012 void Internals::setEditingValue(Element* element, const String& value, Exception
State& exceptionState) | 948 void Internals::setEditingValue(Element* element, const String& value, Exception
State& exceptionState) |
1013 { | 949 { |
1014 if (!element) { | 950 ASSERT(element); |
1015 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
1016 return; | |
1017 } | |
1018 | |
1019 if (!isHTMLInputElement(*element)) { | 951 if (!isHTMLInputElement(*element)) { |
1020 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not an INPUT."); | 952 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not an INPUT."); |
1021 return; | 953 return; |
1022 } | 954 } |
1023 | 955 |
1024 toHTMLInputElement(*element).setEditingValue(value); | 956 toHTMLInputElement(*element).setEditingValue(value); |
1025 } | 957 } |
1026 | 958 |
1027 void Internals::setAutofilled(Element* element, bool enabled, ExceptionState& ex
ceptionState) | 959 void Internals::setAutofilled(Element* element, bool enabled, ExceptionState& ex
ceptionState) |
1028 { | 960 { |
| 961 ASSERT(element); |
1029 if (!element->isFormControlElement()) { | 962 if (!element->isFormControlElement()) { |
1030 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not a form control element."); | 963 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not a form control element."); |
1031 return; | 964 return; |
1032 } | 965 } |
1033 toHTMLFormControlElement(element)->setAutofilled(enabled); | 966 toHTMLFormControlElement(element)->setAutofilled(enabled); |
1034 } | 967 } |
1035 | 968 |
1036 void Internals::scrollElementToRect(Element* element, long x, long y, long w, lo
ng h, ExceptionState& exceptionState) | 969 void Internals::scrollElementToRect(Element* element, long x, long y, long w, lo
ng h, ExceptionState& exceptionState) |
1037 { | 970 { |
1038 if (!element || !element->document().view()) { | 971 ASSERT(element); |
| 972 if (!element->document().view()) { |
1039 exceptionState.throwDOMException(InvalidNodeTypeError, element ? "No vie
w can be obtained from the provided element's document." : ExceptionMessages::ar
gumentNullOrIncorrectType(1, "Element")); | 973 exceptionState.throwDOMException(InvalidNodeTypeError, element ? "No vie
w can be obtained from the provided element's document." : ExceptionMessages::ar
gumentNullOrIncorrectType(1, "Element")); |
1040 return; | 974 return; |
1041 } | 975 } |
1042 FrameView* frameView = element->document().view(); | 976 FrameView* frameView = element->document().view(); |
1043 frameView->scrollElementToRect(element, IntRect(x, y, w, h)); | 977 frameView->scrollElementToRect(element, IntRect(x, y, w, h)); |
1044 } | 978 } |
1045 | 979 |
1046 PassRefPtrWillBeRawPtr<Range> Internals::rangeFromLocationAndLength(Element* sco
pe, int rangeLocation, int rangeLength, ExceptionState& exceptionState) | 980 PassRefPtrWillBeRawPtr<Range> Internals::rangeFromLocationAndLength(Element* sco
pe, int rangeLocation, int rangeLength) |
1047 { | 981 { |
1048 if (!scope) { | 982 ASSERT(scope); |
1049 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
1050 return nullptr; | |
1051 } | |
1052 | 983 |
1053 // TextIterator depends on Layout information, make sure layout it up to dat
e. | 984 // TextIterator depends on Layout information, make sure layout it up to dat
e. |
1054 scope->document().updateLayoutIgnorePendingStylesheets(); | 985 scope->document().updateLayoutIgnorePendingStylesheets(); |
1055 | 986 |
1056 return PlainTextRange(rangeLocation, rangeLocation + rangeLength).createRang
e(*scope); | 987 return PlainTextRange(rangeLocation, rangeLocation + rangeLength).createRang
e(*scope); |
1057 } | 988 } |
1058 | 989 |
1059 unsigned Internals::locationFromRange(Element* scope, const Range* range, Except
ionState& exceptionState) | 990 unsigned Internals::locationFromRange(Element* scope, const Range* range) |
1060 { | 991 { |
1061 if (!scope || !range) { | 992 ASSERT(scope && range); |
1062 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(scope ? 2 : 1, scope ? "Range" : "Element")); | |
1063 return 0; | |
1064 } | |
1065 | |
1066 // PlainTextRange depends on Layout information, make sure layout it up to d
ate. | 993 // PlainTextRange depends on Layout information, make sure layout it up to d
ate. |
1067 scope->document().updateLayoutIgnorePendingStylesheets(); | 994 scope->document().updateLayoutIgnorePendingStylesheets(); |
1068 | 995 |
1069 return PlainTextRange::create(*scope, *range).start(); | 996 return PlainTextRange::create(*scope, *range).start(); |
1070 } | 997 } |
1071 | 998 |
1072 unsigned Internals::lengthFromRange(Element* scope, const Range* range, Exceptio
nState& exceptionState) | 999 unsigned Internals::lengthFromRange(Element* scope, const Range* range) |
1073 { | 1000 { |
1074 if (!scope || !range) { | 1001 ASSERT(scope && range); |
1075 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(scope ? 2 : 1, scope ? "Range" : "Element")); | |
1076 return 0; | |
1077 } | |
1078 | |
1079 // PlainTextRange depends on Layout information, make sure layout it up to d
ate. | 1002 // PlainTextRange depends on Layout information, make sure layout it up to d
ate. |
1080 scope->document().updateLayoutIgnorePendingStylesheets(); | 1003 scope->document().updateLayoutIgnorePendingStylesheets(); |
1081 | 1004 |
1082 return PlainTextRange::create(*scope, *range).length(); | 1005 return PlainTextRange::create(*scope, *range).length(); |
1083 } | 1006 } |
1084 | 1007 |
1085 String Internals::rangeAsText(const Range* range, ExceptionState& exceptionState
) | 1008 String Internals::rangeAsText(const Range* range) |
1086 { | 1009 { |
1087 if (!range) { | 1010 ASSERT(range); |
1088 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Range")); | |
1089 return String(); | |
1090 } | |
1091 | |
1092 return range->text(); | 1011 return range->text(); |
1093 } | 1012 } |
1094 | 1013 |
1095 // FIXME: The next four functions are very similar - combine them once | 1014 // FIXME: The next four functions are very similar - combine them once |
1096 // bestClickableNode/bestContextMenuNode have been combined.. | 1015 // bestClickableNode/bestContextMenuNode have been combined.. |
1097 | 1016 |
1098 PassRefPtrWillBeRawPtr<WebKitPoint> Internals::touchPositionAdjustedToBestClicka
bleNode(long x, long y, long width, long height, Document* document, ExceptionSt
ate& exceptionState) | 1017 PassRefPtrWillBeRawPtr<WebKitPoint> Internals::touchPositionAdjustedToBestClicka
bleNode(long x, long y, long width, long height, Document* document, ExceptionSt
ate& exceptionState) |
1099 { | 1018 { |
1100 if (!document || !document->frame()) { | 1019 ASSERT(document); |
1101 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1020 if (!document->frame()) { |
| 1021 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1102 return nullptr; | 1022 return nullptr; |
1103 } | 1023 } |
1104 | 1024 |
1105 document->updateLayout(); | 1025 document->updateLayout(); |
1106 | 1026 |
1107 IntSize radius(width / 2, height / 2); | 1027 IntSize radius(width / 2, height / 2); |
1108 IntPoint point(x + radius.width(), y + radius.height()); | 1028 IntPoint point(x + radius.width(), y + radius.height()); |
1109 | 1029 |
1110 EventHandler& eventHandler = document->frame()->eventHandler(); | 1030 EventHandler& eventHandler = document->frame()->eventHandler(); |
1111 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); | 1031 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); |
1112 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); | 1032 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); |
1113 | 1033 |
1114 Node* targetNode; | 1034 Node* targetNode; |
1115 IntPoint adjustedPoint; | 1035 IntPoint adjustedPoint; |
1116 | 1036 |
1117 bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adju
stedPoint, targetNode); | 1037 bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adju
stedPoint, targetNode); |
1118 if (foundNode) | 1038 if (foundNode) |
1119 return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y()); | 1039 return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y()); |
1120 | 1040 |
1121 return nullptr; | 1041 return nullptr; |
1122 } | 1042 } |
1123 | 1043 |
1124 Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width
, long height, Document* document, ExceptionState& exceptionState) | 1044 Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width
, long height, Document* document, ExceptionState& exceptionState) |
1125 { | 1045 { |
1126 if (!document || !document->frame()) { | 1046 ASSERT(document); |
1127 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1047 if (!document->frame()) { |
| 1048 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1128 return 0; | 1049 return 0; |
1129 } | 1050 } |
1130 | 1051 |
1131 document->updateLayout(); | 1052 document->updateLayout(); |
1132 | 1053 |
1133 IntSize radius(width / 2, height / 2); | 1054 IntSize radius(width / 2, height / 2); |
1134 IntPoint point(x + radius.width(), y + radius.height()); | 1055 IntPoint point(x + radius.width(), y + radius.height()); |
1135 | 1056 |
1136 EventHandler& eventHandler = document->frame()->eventHandler(); | 1057 EventHandler& eventHandler = document->frame()->eventHandler(); |
1137 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); | 1058 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); |
1138 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); | 1059 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); |
1139 | 1060 |
1140 Node* targetNode; | 1061 Node* targetNode; |
1141 IntPoint adjustedPoint; | 1062 IntPoint adjustedPoint; |
1142 document->frame()->eventHandler().bestClickableNodeForHitTestResult(result,
adjustedPoint, targetNode); | 1063 document->frame()->eventHandler().bestClickableNodeForHitTestResult(result,
adjustedPoint, targetNode); |
1143 return targetNode; | 1064 return targetNode; |
1144 } | 1065 } |
1145 | 1066 |
1146 PassRefPtrWillBeRawPtr<WebKitPoint> Internals::touchPositionAdjustedToBestContex
tMenuNode(long x, long y, long width, long height, Document* document, Exception
State& exceptionState) | 1067 PassRefPtrWillBeRawPtr<WebKitPoint> Internals::touchPositionAdjustedToBestContex
tMenuNode(long x, long y, long width, long height, Document* document, Exception
State& exceptionState) |
1147 { | 1068 { |
1148 if (!document || !document->frame()) { | 1069 ASSERT(document); |
1149 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1070 if (!document->frame()) { |
| 1071 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1150 return nullptr; | 1072 return nullptr; |
1151 } | 1073 } |
1152 | 1074 |
1153 document->updateLayout(); | 1075 document->updateLayout(); |
1154 | 1076 |
1155 IntSize radius(width / 2, height / 2); | 1077 IntSize radius(width / 2, height / 2); |
1156 IntPoint point(x + radius.width(), y + radius.height()); | 1078 IntPoint point(x + radius.width(), y + radius.height()); |
1157 | 1079 |
1158 EventHandler& eventHandler = document->frame()->eventHandler(); | 1080 EventHandler& eventHandler = document->frame()->eventHandler(); |
1159 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); | 1081 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); |
1160 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); | 1082 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); |
1161 | 1083 |
1162 Node* targetNode = 0; | 1084 Node* targetNode = 0; |
1163 IntPoint adjustedPoint; | 1085 IntPoint adjustedPoint; |
1164 | 1086 |
1165 bool foundNode = eventHandler.bestContextMenuNodeForHitTestResult(result, ad
justedPoint, targetNode); | 1087 bool foundNode = eventHandler.bestContextMenuNodeForHitTestResult(result, ad
justedPoint, targetNode); |
1166 if (foundNode) | 1088 if (foundNode) |
1167 return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y()); | 1089 return WebKitPoint::create(adjustedPoint.x(), adjustedPoint.y()); |
1168 | 1090 |
1169 return WebKitPoint::create(x, y); | 1091 return WebKitPoint::create(x, y); |
1170 } | 1092 } |
1171 | 1093 |
1172 Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long wid
th, long height, Document* document, ExceptionState& exceptionState) | 1094 Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long wid
th, long height, Document* document, ExceptionState& exceptionState) |
1173 { | 1095 { |
1174 if (!document || !document->frame()) { | 1096 ASSERT(document); |
1175 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1097 if (!document->frame()) { |
| 1098 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1176 return 0; | 1099 return 0; |
1177 } | 1100 } |
1178 | 1101 |
1179 document->updateLayout(); | 1102 document->updateLayout(); |
1180 | 1103 |
1181 IntSize radius(width / 2, height / 2); | 1104 IntSize radius(width / 2, height / 2); |
1182 IntPoint point(x + radius.width(), y + radius.height()); | 1105 IntPoint point(x + radius.width(), y + radius.height()); |
1183 | 1106 |
1184 EventHandler& eventHandler = document->frame()->eventHandler(); | 1107 EventHandler& eventHandler = document->frame()->eventHandler(); |
1185 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); | 1108 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point); |
1186 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); | 1109 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe
stRequest::ReadOnly | HitTestRequest::Active, radius); |
1187 | 1110 |
1188 Node* targetNode = 0; | 1111 Node* targetNode = 0; |
1189 IntPoint adjustedPoint; | 1112 IntPoint adjustedPoint; |
1190 eventHandler.bestContextMenuNodeForHitTestResult(result, adjustedPoint, targ
etNode); | 1113 eventHandler.bestContextMenuNodeForHitTestResult(result, adjustedPoint, targ
etNode); |
1191 return targetNode; | 1114 return targetNode; |
1192 } | 1115 } |
1193 | 1116 |
1194 PassRefPtrWillBeRawPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long
x, long y, long width, long height, Document* document, ExceptionState& excepti
onState) | 1117 PassRefPtrWillBeRawPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long
x, long y, long width, long height, Document* document, ExceptionState& excepti
onState) |
1195 { | 1118 { |
1196 if (!document || !document->frame()) { | 1119 ASSERT(document); |
1197 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1120 if (!document->frame()) { |
| 1121 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1198 return nullptr; | 1122 return nullptr; |
1199 } | 1123 } |
1200 | 1124 |
1201 document->updateLayout(); | 1125 document->updateLayout(); |
1202 | 1126 |
1203 IntSize radius(width / 2, height / 2); | 1127 IntSize radius(width / 2, height / 2); |
1204 IntPoint point(x + radius.width(), y + radius.height()); | 1128 IntPoint point(x + radius.width(), y + radius.height()); |
1205 | 1129 |
1206 Node* targetNode; | 1130 Node* targetNode; |
1207 IntRect zoomableArea; | 1131 IntRect zoomableArea; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 // Optimally, the bindings generator would pass a Vector<AtomicString> here but | 1169 // Optimally, the bindings generator would pass a Vector<AtomicString> here but |
1246 // this is not supported yet. | 1170 // this is not supported yet. |
1247 void Internals::setUserPreferredLanguages(const Vector<String>& languages) | 1171 void Internals::setUserPreferredLanguages(const Vector<String>& languages) |
1248 { | 1172 { |
1249 Vector<AtomicString> atomicLanguages; | 1173 Vector<AtomicString> atomicLanguages; |
1250 for (size_t i = 0; i < languages.size(); ++i) | 1174 for (size_t i = 0; i < languages.size(); ++i) |
1251 atomicLanguages.append(AtomicString(languages[i])); | 1175 atomicLanguages.append(AtomicString(languages[i])); |
1252 blink::overrideUserPreferredLanguages(atomicLanguages); | 1176 blink::overrideUserPreferredLanguages(atomicLanguages); |
1253 } | 1177 } |
1254 | 1178 |
1255 unsigned Internals::activeDOMObjectCount(Document* document, ExceptionState& exc
eptionState) | 1179 unsigned Internals::activeDOMObjectCount(Document* document) |
1256 { | 1180 { |
1257 if (!document) { | 1181 ASSERT(document); |
1258 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
1259 return 0; | |
1260 } | |
1261 | |
1262 return document->activeDOMObjectCount(); | 1182 return document->activeDOMObjectCount(); |
1263 } | 1183 } |
1264 | 1184 |
1265 static unsigned eventHandlerCount(Document& document, EventHandlerRegistry::Even
tHandlerClass handlerClass) | 1185 static unsigned eventHandlerCount(Document& document, EventHandlerRegistry::Even
tHandlerClass handlerClass) |
1266 { | 1186 { |
1267 if (!document.frameHost()) | 1187 if (!document.frameHost()) |
1268 return 0; | 1188 return 0; |
1269 EventHandlerRegistry* registry = &document.frameHost()->eventHandlerRegistry
(); | 1189 EventHandlerRegistry* registry = &document.frameHost()->eventHandlerRegistry
(); |
1270 unsigned count = 0; | 1190 unsigned count = 0; |
1271 const EventTargetSet* targets = registry->eventHandlerTargets(handlerClass); | 1191 const EventTargetSet* targets = registry->eventHandlerTargets(handlerClass); |
1272 if (targets) { | 1192 if (targets) { |
1273 for (EventTargetSet::const_iterator iter = targets->begin(); iter != tar
gets->end(); ++iter) | 1193 for (EventTargetSet::const_iterator iter = targets->begin(); iter != tar
gets->end(); ++iter) |
1274 count += iter->value; | 1194 count += iter->value; |
1275 } | 1195 } |
1276 return count; | 1196 return count; |
1277 } | 1197 } |
1278 | 1198 |
1279 unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& e
xceptionState) | 1199 unsigned Internals::wheelEventHandlerCount(Document* document) |
1280 { | 1200 { |
1281 if (!document) { | 1201 ASSERT(document); |
1282 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
1283 return 0; | |
1284 } | |
1285 | |
1286 return eventHandlerCount(*document, EventHandlerRegistry::WheelEvent); | 1202 return eventHandlerCount(*document, EventHandlerRegistry::WheelEvent); |
1287 } | 1203 } |
1288 | 1204 |
1289 unsigned Internals::scrollEventHandlerCount(Document* document, ExceptionState&
exceptionState) | 1205 unsigned Internals::scrollEventHandlerCount(Document* document) |
1290 { | 1206 { |
1291 if (!document) { | 1207 ASSERT(document); |
1292 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
1293 return 0; | |
1294 } | |
1295 | |
1296 return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent); | 1208 return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent); |
1297 } | 1209 } |
1298 | 1210 |
1299 unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& e
xceptionState) | 1211 unsigned Internals::touchEventHandlerCount(Document* document) |
1300 { | 1212 { |
1301 if (!document) { | 1213 ASSERT(document); |
1302 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
1303 return 0; | |
1304 } | |
1305 | |
1306 const TouchEventTargetSet* touchHandlers = document->touchEventTargets(); | 1214 const TouchEventTargetSet* touchHandlers = document->touchEventTargets(); |
1307 if (!touchHandlers) | 1215 if (!touchHandlers) |
1308 return 0; | 1216 return 0; |
1309 | 1217 |
1310 unsigned count = 0; | 1218 unsigned count = 0; |
1311 for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter
!= touchHandlers->end(); ++iter) | 1219 for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter
!= touchHandlers->end(); ++iter) |
1312 count += iter->value; | 1220 count += iter->value; |
1313 return count; | 1221 return count; |
1314 } | 1222 } |
1315 | 1223 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 } | 1338 } |
1431 } | 1339 } |
1432 | 1340 |
1433 size_t numChildren = graphicsLayer->children().size(); | 1341 size_t numChildren = graphicsLayer->children().size(); |
1434 for (size_t i = 0; i < numChildren; ++i) | 1342 for (size_t i = 0; i < numChildren; ++i) |
1435 accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects)
; | 1343 accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects)
; |
1436 } | 1344 } |
1437 | 1345 |
1438 PassRefPtrWillBeRawPtr<LayerRectList> Internals::touchEventTargetLayerRects(Docu
ment* document, ExceptionState& exceptionState) | 1346 PassRefPtrWillBeRawPtr<LayerRectList> Internals::touchEventTargetLayerRects(Docu
ment* document, ExceptionState& exceptionState) |
1439 { | 1347 { |
1440 if (!document || !document->view() || !document->page() || document != conte
xtDocument()) { | 1348 ASSERT(document); |
| 1349 if (!document->view() || !document->page() || document != contextDocument())
{ |
1441 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); | 1350 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1442 return nullptr; | 1351 return nullptr; |
1443 } | 1352 } |
1444 | 1353 |
1445 // Do any pending layout and compositing update (which may call touchEventTa
rgetRectsChange) to ensure this | 1354 // Do any pending layout and compositing update (which may call touchEventTa
rgetRectsChange) to ensure this |
1446 // really takes any previous changes into account. | 1355 // really takes any previous changes into account. |
1447 forceCompositingUpdate(document, exceptionState); | 1356 forceCompositingUpdate(document, exceptionState); |
1448 if (exceptionState.hadException()) | 1357 if (exceptionState.hadException()) |
1449 return nullptr; | 1358 return nullptr; |
1450 | 1359 |
1451 if (RenderView* view = document->renderView()) { | 1360 if (RenderView* view = document->renderView()) { |
1452 if (RenderLayerCompositor* compositor = view->compositor()) { | 1361 if (RenderLayerCompositor* compositor = view->compositor()) { |
1453 if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) { | 1362 if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) { |
1454 RefPtrWillBeRawPtr<LayerRectList> rects = LayerRectList::create(
); | 1363 RefPtrWillBeRawPtr<LayerRectList> rects = LayerRectList::create(
); |
1455 accumulateLayerRectList(compositor, rootLayer, rects.get()); | 1364 accumulateLayerRectList(compositor, rootLayer, rects.get()); |
1456 return rects; | 1365 return rects; |
1457 } | 1366 } |
1458 } | 1367 } |
1459 } | 1368 } |
1460 | 1369 |
1461 return nullptr; | 1370 return nullptr; |
1462 } | 1371 } |
1463 | 1372 |
1464 PassRefPtrWillBeRawPtr<StaticNodeList> Internals::nodesFromRect(Document* docume
nt, int centerX, int centerY, unsigned topPadding, unsigned rightPadding, | 1373 PassRefPtrWillBeRawPtr<StaticNodeList> Internals::nodesFromRect(Document* docume
nt, int centerX, int centerY, unsigned topPadding, unsigned rightPadding, |
1465 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo
wChildFrameContent, ExceptionState& exceptionState) const | 1374 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo
wChildFrameContent, ExceptionState& exceptionState) const |
1466 { | 1375 { |
1467 if (!document || !document->frame() || !document->frame()->view()) { | 1376 ASSERT(document); |
| 1377 if (!document->frame() || !document->frame()->view()) { |
1468 exceptionState.throwDOMException(InvalidAccessError, "No view can be obt
ained from the provided document."); | 1378 exceptionState.throwDOMException(InvalidAccessError, "No view can be obt
ained from the provided document."); |
1469 return nullptr; | 1379 return nullptr; |
1470 } | 1380 } |
1471 | 1381 |
1472 LocalFrame* frame = document->frame(); | 1382 LocalFrame* frame = document->frame(); |
1473 FrameView* frameView = document->view(); | 1383 FrameView* frameView = document->view(); |
1474 RenderView* renderView = document->renderView(); | 1384 RenderView* renderView = document->renderView(); |
1475 | 1385 |
1476 if (!renderView) | 1386 if (!renderView) |
1477 return nullptr; | 1387 return nullptr; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 void Internals::emitInspectorDidBeginFrame(int frameId) | 1426 void Internals::emitInspectorDidBeginFrame(int frameId) |
1517 { | 1427 { |
1518 contextDocument()->page()->inspectorController().didBeginFrame(frameId); | 1428 contextDocument()->page()->inspectorController().didBeginFrame(frameId); |
1519 } | 1429 } |
1520 | 1430 |
1521 void Internals::emitInspectorDidCancelFrame() | 1431 void Internals::emitInspectorDidCancelFrame() |
1522 { | 1432 { |
1523 contextDocument()->page()->inspectorController().didCancelFrame(); | 1433 contextDocument()->page()->inspectorController().didCancelFrame(); |
1524 } | 1434 } |
1525 | 1435 |
1526 bool Internals::hasSpellingMarker(Document* document, int from, int length, Exce
ptionState&) | 1436 bool Internals::hasSpellingMarker(Document* document, int from, int length) |
1527 { | 1437 { |
1528 if (!document || !document->frame()) | 1438 ASSERT(document); |
| 1439 if (!document->frame()) |
1529 return 0; | 1440 return 0; |
1530 | 1441 |
1531 return document->frame()->spellChecker().selectionStartHasMarkerFor(Document
Marker::Spelling, from, length); | 1442 return document->frame()->spellChecker().selectionStartHasMarkerFor(Document
Marker::Spelling, from, length); |
1532 } | 1443 } |
1533 | 1444 |
1534 void Internals::setContinuousSpellCheckingEnabled(bool enabled, ExceptionState&) | 1445 void Internals::setContinuousSpellCheckingEnabled(bool enabled) |
1535 { | 1446 { |
1536 if (!contextDocument() || !contextDocument()->frame()) | 1447 if (!contextDocument() || !contextDocument()->frame()) |
1537 return; | 1448 return; |
1538 | 1449 |
1539 if (enabled != contextDocument()->frame()->spellChecker().isContinuousSpellC
heckingEnabled()) | 1450 if (enabled != contextDocument()->frame()->spellChecker().isContinuousSpellC
heckingEnabled()) |
1540 contextDocument()->frame()->spellChecker().toggleContinuousSpellChecking
(); | 1451 contextDocument()->frame()->spellChecker().toggleContinuousSpellChecking
(); |
1541 } | 1452 } |
1542 | 1453 |
1543 bool Internals::isOverwriteModeEnabled(Document* document, ExceptionState&) | 1454 bool Internals::isOverwriteModeEnabled(Document* document) |
1544 { | 1455 { |
1545 if (!document || !document->frame()) | 1456 ASSERT(document); |
| 1457 if (!document->frame()) |
1546 return 0; | 1458 return 0; |
1547 | 1459 |
1548 return document->frame()->editor().isOverwriteModeEnabled(); | 1460 return document->frame()->editor().isOverwriteModeEnabled(); |
1549 } | 1461 } |
1550 | 1462 |
1551 void Internals::toggleOverwriteModeEnabled(Document* document, ExceptionState&) | 1463 void Internals::toggleOverwriteModeEnabled(Document* document) |
1552 { | 1464 { |
1553 if (!document || !document->frame()) | 1465 ASSERT(document); |
| 1466 if (!document->frame()) |
1554 return; | 1467 return; |
1555 | 1468 |
1556 document->frame()->editor().toggleOverwriteModeEnabled(); | 1469 document->frame()->editor().toggleOverwriteModeEnabled(); |
1557 } | 1470 } |
1558 | 1471 |
1559 unsigned Internals::numberOfLiveNodes() const | 1472 unsigned Internals::numberOfLiveNodes() const |
1560 { | 1473 { |
1561 return InspectorCounters::counterValue(InspectorCounters::NodeCounter); | 1474 return InspectorCounters::counterValue(InspectorCounters::NodeCounter); |
1562 } | 1475 } |
1563 | 1476 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 void Internals::setInspectorResourcesDataSizeLimits(int maximumResourcesContentS
ize, int maximumSingleResourceContentSize, ExceptionState& exceptionState) | 1512 void Internals::setInspectorResourcesDataSizeLimits(int maximumResourcesContentS
ize, int maximumSingleResourceContentSize, ExceptionState& exceptionState) |
1600 { | 1513 { |
1601 Page* page = contextDocument()->frame()->page(); | 1514 Page* page = contextDocument()->frame()->page(); |
1602 if (!page) { | 1515 if (!page) { |
1603 exceptionState.throwDOMException(InvalidAccessError, "No page can be obt
ained from the current context document."); | 1516 exceptionState.throwDOMException(InvalidAccessError, "No page can be obt
ained from the current context document."); |
1604 return; | 1517 return; |
1605 } | 1518 } |
1606 page->inspectorController().setResourcesDataSizeLimitsFromInternals(maximumR
esourcesContentSize, maximumSingleResourceContentSize); | 1519 page->inspectorController().setResourcesDataSizeLimitsFromInternals(maximumR
esourcesContentSize, maximumSingleResourceContentSize); |
1607 } | 1520 } |
1608 | 1521 |
1609 bool Internals::hasGrammarMarker(Document* document, int from, int length, Excep
tionState&) | 1522 bool Internals::hasGrammarMarker(Document* document, int from, int length) |
1610 { | 1523 { |
1611 if (!document || !document->frame()) | 1524 ASSERT(document); |
| 1525 if (!document->frame()) |
1612 return 0; | 1526 return 0; |
1613 | 1527 |
1614 return document->frame()->spellChecker().selectionStartHasMarkerFor(Document
Marker::Grammar, from, length); | 1528 return document->frame()->spellChecker().selectionStartHasMarkerFor(Document
Marker::Grammar, from, length); |
1615 } | 1529 } |
1616 | 1530 |
1617 unsigned Internals::numberOfScrollableAreas(Document* document, ExceptionState&) | 1531 unsigned Internals::numberOfScrollableAreas(Document* document) |
1618 { | 1532 { |
1619 if (!document || !document->frame()) | 1533 ASSERT(document); |
| 1534 if (!document->frame()) |
1620 return 0; | 1535 return 0; |
1621 | 1536 |
1622 unsigned count = 0; | 1537 unsigned count = 0; |
1623 LocalFrame* frame = document->frame(); | 1538 LocalFrame* frame = document->frame(); |
1624 if (frame->view()->scrollableAreas()) | 1539 if (frame->view()->scrollableAreas()) |
1625 count += frame->view()->scrollableAreas()->size(); | 1540 count += frame->view()->scrollableAreas()->size(); |
1626 | 1541 |
1627 for (Frame* child = frame->tree().firstChild(); child; child = child->tree()
.nextSibling()) { | 1542 for (Frame* child = frame->tree().firstChild(); child; child = child->tree()
.nextSibling()) { |
1628 if (child->isLocalFrame() && toLocalFrame(child)->view() && toLocalFrame
(child)->view()->scrollableAreas()) | 1543 if (child->isLocalFrame() && toLocalFrame(child)->view() && toLocalFrame
(child)->view()->scrollableAreas()) |
1629 count += toLocalFrame(child)->view()->scrollableAreas()->size(); | 1544 count += toLocalFrame(child)->view()->scrollableAreas()->size(); |
1630 } | 1545 } |
1631 | 1546 |
1632 return count; | 1547 return count; |
1633 } | 1548 } |
1634 | 1549 |
1635 bool Internals::isPageBoxVisible(Document* document, int pageNumber, ExceptionSt
ate& exceptionState) | 1550 bool Internals::isPageBoxVisible(Document* document, int pageNumber) |
1636 { | 1551 { |
1637 if (!document) { | 1552 ASSERT(document); |
1638 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
1639 return false; | |
1640 } | |
1641 | |
1642 return document->isPageBoxVisible(pageNumber); | 1553 return document->isPageBoxVisible(pageNumber); |
1643 } | 1554 } |
1644 | 1555 |
1645 String Internals::layerTreeAsText(Document* document, ExceptionState& exceptionS
tate) const | 1556 String Internals::layerTreeAsText(Document* document, ExceptionState& exceptionS
tate) const |
1646 { | 1557 { |
1647 return layerTreeAsText(document, 0, exceptionState); | 1558 return layerTreeAsText(document, 0, exceptionState); |
1648 } | 1559 } |
1649 | 1560 |
1650 String Internals::elementLayerTreeAsText(Element* element, ExceptionState& excep
tionState) const | 1561 String Internals::elementLayerTreeAsText(Element* element, ExceptionState& excep
tionState) const |
1651 { | 1562 { |
1652 if (!element) { | 1563 ASSERT(element); |
1653 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
1654 return String(); | |
1655 } | |
1656 | |
1657 FrameView* frameView = element->document().view(); | 1564 FrameView* frameView = element->document().view(); |
1658 frameView->updateLayoutAndStyleForPainting(); | 1565 frameView->updateLayoutAndStyleForPainting(); |
1659 | 1566 |
1660 return elementLayerTreeAsText(element, 0, exceptionState); | 1567 return elementLayerTreeAsText(element, 0, exceptionState); |
1661 } | 1568 } |
1662 | 1569 |
1663 bool Internals::scrollsWithRespectTo(Element* element1, Element* element2, Excep
tionState& exceptionState) | 1570 bool Internals::scrollsWithRespectTo(Element* element1, Element* element2, Excep
tionState& exceptionState) |
1664 { | 1571 { |
1665 if (!element1 || !element2) { | 1572 ASSERT(element1 && element2); |
1666 exceptionState.throwDOMException(InvalidAccessError, String::format("The
%s element provided is invalid.", element1 ? "second" : "first")); | |
1667 return 0; | |
1668 } | |
1669 | |
1670 element1->document().view()->updateLayoutAndStyleForPainting(); | 1573 element1->document().view()->updateLayoutAndStyleForPainting(); |
1671 | 1574 |
1672 RenderObject* renderer1 = element1->renderer(); | 1575 RenderObject* renderer1 = element1->renderer(); |
1673 RenderObject* renderer2 = element2->renderer(); | 1576 RenderObject* renderer2 = element2->renderer(); |
1674 if (!renderer1 || !renderer1->isBox()) { | 1577 if (!renderer1 || !renderer1->isBox()) { |
1675 exceptionState.throwDOMException(InvalidAccessError, renderer1 ? "The fi
rst provided element's renderer is not a box." : "The first provided element has
no renderer."); | 1578 exceptionState.throwDOMException(InvalidAccessError, renderer1 ? "The fi
rst provided element's renderer is not a box." : "The first provided element has
no renderer."); |
1676 return 0; | 1579 return 0; |
1677 } | 1580 } |
1678 if (!renderer2 || !renderer2->isBox()) { | 1581 if (!renderer2 || !renderer2->isBox()) { |
1679 exceptionState.throwDOMException(InvalidAccessError, renderer2 ? "The se
cond provided element's renderer is not a box." : "The second provided element h
as no renderer."); | 1582 exceptionState.throwDOMException(InvalidAccessError, renderer2 ? "The se
cond provided element's renderer is not a box." : "The second provided element h
as no renderer."); |
1680 return 0; | 1583 return 0; |
1681 } | 1584 } |
1682 | 1585 |
1683 RenderLayer* layer1 = toRenderBox(renderer1)->layer(); | 1586 RenderLayer* layer1 = toRenderBox(renderer1)->layer(); |
1684 RenderLayer* layer2 = toRenderBox(renderer2)->layer(); | 1587 RenderLayer* layer2 = toRenderBox(renderer2)->layer(); |
1685 if (!layer1 || !layer2) { | 1588 if (!layer1 || !layer2) { |
1686 exceptionState.throwDOMException(InvalidAccessError, String::format("No
render layer can be obtained from the %s provided element.", layer1 ? "second" :
"first")); | 1589 exceptionState.throwDOMException(InvalidAccessError, String::format("No
render layer can be obtained from the %s provided element.", layer1 ? "second" :
"first")); |
1687 return 0; | 1590 return 0; |
1688 } | 1591 } |
1689 | 1592 |
1690 return layer1->scrollsWithRespectTo(layer2); | 1593 return layer1->scrollsWithRespectTo(layer2); |
1691 } | 1594 } |
1692 | 1595 |
1693 bool Internals::isUnclippedDescendant(Element* element, ExceptionState& exceptio
nState) | 1596 bool Internals::isUnclippedDescendant(Element* element, ExceptionState& exceptio
nState) |
1694 { | 1597 { |
1695 if (!element) { | 1598 ASSERT(element); |
1696 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
1697 return 0; | |
1698 } | |
1699 | |
1700 element->document().view()->updateLayoutAndStyleForPainting(); | 1599 element->document().view()->updateLayoutAndStyleForPainting(); |
1701 | 1600 |
1702 RenderObject* renderer = element->renderer(); | 1601 RenderObject* renderer = element->renderer(); |
1703 if (!renderer || !renderer->isBox()) { | 1602 if (!renderer || !renderer->isBox()) { |
1704 exceptionState.throwDOMException(InvalidAccessError, renderer ? "The pro
vided element's renderer is not a box." : "The provided element has no renderer.
"); | 1603 exceptionState.throwDOMException(InvalidAccessError, renderer ? "The pro
vided element's renderer is not a box." : "The provided element has no renderer.
"); |
1705 return 0; | 1604 return 0; |
1706 } | 1605 } |
1707 | 1606 |
1708 RenderLayer* layer = toRenderBox(renderer)->layer(); | 1607 RenderLayer* layer = toRenderBox(renderer)->layer(); |
1709 if (!layer) { | 1608 if (!layer) { |
1710 exceptionState.throwDOMException(InvalidAccessError, "No render layer ca
n be obtained from the provided element."); | 1609 exceptionState.throwDOMException(InvalidAccessError, "No render layer ca
n be obtained from the provided element."); |
1711 return 0; | 1610 return 0; |
1712 } | 1611 } |
1713 | 1612 |
1714 // We used to compute isUnclippedDescendant only when acceleratedCompositing
ForOverflowScrollEnabled, | 1613 // We used to compute isUnclippedDescendant only when acceleratedCompositing
ForOverflowScrollEnabled, |
1715 // but now we compute it all the time. | 1614 // but now we compute it all the time. |
1716 // FIXME: Remove this if statement and rebaseline the tests that make this a
ssumption. | 1615 // FIXME: Remove this if statement and rebaseline the tests that make this a
ssumption. |
1717 if (!layer->compositor()->acceleratedCompositingForOverflowScrollEnabled()) | 1616 if (!layer->compositor()->acceleratedCompositingForOverflowScrollEnabled()) |
1718 return false; | 1617 return false; |
1719 | 1618 |
1720 return layer->isUnclippedDescendant(); | 1619 return layer->isUnclippedDescendant(); |
1721 } | 1620 } |
1722 | 1621 |
1723 String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionS
tate& exceptionState) const | 1622 String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionS
tate& exceptionState) const |
1724 { | 1623 { |
1725 if (!document || !document->frame()) { | 1624 ASSERT(document); |
1726 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1625 if (!document->frame()) { |
| 1626 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1727 return String(); | 1627 return String(); |
1728 } | 1628 } |
1729 | 1629 |
1730 document->view()->updateLayoutAndStyleForPainting(); | 1630 document->view()->updateLayoutAndStyleForPainting(); |
1731 | 1631 |
1732 return document->frame()->layerTreeAsText(flags); | 1632 return document->frame()->layerTreeAsText(flags); |
1733 } | 1633 } |
1734 | 1634 |
1735 String Internals::elementLayerTreeAsText(Element* element, unsigned flags, Excep
tionState& exceptionState) const | 1635 String Internals::elementLayerTreeAsText(Element* element, unsigned flags, Excep
tionState& exceptionState) const |
1736 { | 1636 { |
1737 if (!element) { | 1637 ASSERT(element); |
1738 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
1739 return String(); | |
1740 } | |
1741 | |
1742 element->document().updateLayout(); | 1638 element->document().updateLayout(); |
1743 | 1639 |
1744 RenderObject* renderer = element->renderer(); | 1640 RenderObject* renderer = element->renderer(); |
1745 if (!renderer || !renderer->isBox()) { | 1641 if (!renderer || !renderer->isBox()) { |
1746 exceptionState.throwDOMException(InvalidAccessError, renderer ? "The pro
vided element's renderer is not a box." : "The provided element has no renderer.
"); | 1642 exceptionState.throwDOMException(InvalidAccessError, renderer ? "The pro
vided element's renderer is not a box." : "The provided element has no renderer.
"); |
1747 return String(); | 1643 return String(); |
1748 } | 1644 } |
1749 | 1645 |
1750 RenderLayer* layer = toRenderBox(renderer)->layer(); | 1646 RenderLayer* layer = toRenderBox(renderer)->layer(); |
1751 if (!layer | 1647 if (!layer |
1752 || !layer->hasCompositedLayerMapping() | 1648 || !layer->hasCompositedLayerMapping() |
1753 || !layer->compositedLayerMapping()->mainGraphicsLayer()) { | 1649 || !layer->compositedLayerMapping()->mainGraphicsLayer()) { |
1754 // Don't raise exception in these cases which may be normally used in te
sts. | 1650 // Don't raise exception in these cases which may be normally used in te
sts. |
1755 return String(); | 1651 return String(); |
1756 } | 1652 } |
1757 | 1653 |
1758 return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText
(flags); | 1654 return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText
(flags); |
1759 } | 1655 } |
1760 | 1656 |
1761 String Internals::scrollingStateTreeAsText(Document* document, ExceptionState& e
xceptionState) const | 1657 String Internals::scrollingStateTreeAsText(Document*) const |
1762 { | 1658 { |
1763 return String(); | 1659 return String(); |
1764 } | 1660 } |
1765 | 1661 |
1766 String Internals::mainThreadScrollingReasons(Document* document, ExceptionState&
exceptionState) const | 1662 String Internals::mainThreadScrollingReasons(Document* document, ExceptionState&
exceptionState) const |
1767 { | 1663 { |
1768 if (!document || !document->frame()) { | 1664 ASSERT(document); |
1769 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1665 if (!document->frame()) { |
| 1666 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1770 return String(); | 1667 return String(); |
1771 } | 1668 } |
1772 | 1669 |
1773 document->frame()->view()->updateLayoutAndStyleForPainting(); | 1670 document->frame()->view()->updateLayoutAndStyleForPainting(); |
1774 | 1671 |
1775 Page* page = document->page(); | 1672 Page* page = document->page(); |
1776 if (!page) | 1673 if (!page) |
1777 return String(); | 1674 return String(); |
1778 | 1675 |
1779 return page->mainThreadScrollingReasonsAsText(); | 1676 return page->mainThreadScrollingReasonsAsText(); |
1780 } | 1677 } |
1781 | 1678 |
1782 PassRefPtrWillBeRawPtr<ClientRectList> Internals::nonFastScrollableRects(Documen
t* document, ExceptionState& exceptionState) const | 1679 PassRefPtrWillBeRawPtr<ClientRectList> Internals::nonFastScrollableRects(Documen
t* document, ExceptionState& exceptionState) const |
1783 { | 1680 { |
1784 if (!document || !document->frame()) { | 1681 ASSERT(document); |
1785 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1682 if (!document->frame()) { |
| 1683 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1786 return nullptr; | 1684 return nullptr; |
1787 } | 1685 } |
1788 | 1686 |
1789 Page* page = document->page(); | 1687 Page* page = document->page(); |
1790 if (!page) | 1688 if (!page) |
1791 return nullptr; | 1689 return nullptr; |
1792 | 1690 |
1793 return page->nonFastScrollableRects(document->frame()); | 1691 return page->nonFastScrollableRects(document->frame()); |
1794 } | 1692 } |
1795 | 1693 |
1796 void Internals::garbageCollectDocumentResources(Document* document, ExceptionSta
te& exceptionState) const | 1694 void Internals::garbageCollectDocumentResources(Document* document) const |
1797 { | 1695 { |
1798 if (!document) { | 1696 ASSERT(document); |
1799 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
1800 return; | |
1801 } | |
1802 ResourceFetcher* fetcher = document->fetcher(); | 1697 ResourceFetcher* fetcher = document->fetcher(); |
1803 if (!fetcher) | 1698 if (!fetcher) |
1804 return; | 1699 return; |
1805 fetcher->garbageCollectDocumentResources(); | 1700 fetcher->garbageCollectDocumentResources(); |
1806 } | 1701 } |
1807 | 1702 |
1808 void Internals::evictAllResources() const | 1703 void Internals::evictAllResources() const |
1809 { | 1704 { |
1810 memoryCache()->evictResources(); | 1705 memoryCache()->evictResources(); |
1811 } | 1706 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 if (!document || !document->page()) { | 1777 if (!document || !document->page()) { |
1883 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's page cannot be retrieved." : "No context document can be obtained."); | 1778 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's page cannot be retrieved." : "No context document can be obtained."); |
1884 return; | 1779 return; |
1885 } | 1780 } |
1886 Page* page = document->page(); | 1781 Page* page = document->page(); |
1887 page->setDeviceScaleFactor(scaleFactor); | 1782 page->setDeviceScaleFactor(scaleFactor); |
1888 } | 1783 } |
1889 | 1784 |
1890 void Internals::setIsCursorVisible(Document* document, bool isVisible, Exception
State& exceptionState) | 1785 void Internals::setIsCursorVisible(Document* document, bool isVisible, Exception
State& exceptionState) |
1891 { | 1786 { |
1892 if (!document || !document->page()) { | 1787 ASSERT(document); |
1893 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's page cannot be retrieved." : "No context document can be obtained."); | 1788 if (!document->page()) { |
| 1789 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t can be obtained."); |
1894 return; | 1790 return; |
1895 } | 1791 } |
1896 document->page()->setIsCursorVisible(isVisible); | 1792 document->page()->setIsCursorVisible(isVisible); |
1897 } | 1793 } |
1898 | 1794 |
1899 void Internals::mediaPlayerRequestFullscreen(HTMLMediaElement* mediaElement) | 1795 void Internals::mediaPlayerRequestFullscreen(HTMLMediaElement* mediaElement) |
1900 { | 1796 { |
1901 mediaElement->mediaPlayerRequestFullscreen(); | 1797 mediaElement->mediaPlayerRequestFullscreen(); |
1902 } | 1798 } |
1903 | 1799 |
(...skipping 17 matching lines...) Expand all Loading... |
1921 return PrivateScriptTest::create(frame()); | 1817 return PrivateScriptTest::create(frame()); |
1922 } | 1818 } |
1923 | 1819 |
1924 Vector<String> Internals::getReferencedFilePaths() const | 1820 Vector<String> Internals::getReferencedFilePaths() const |
1925 { | 1821 { |
1926 return frame()->loader().currentItem()->getReferencedFilePaths(); | 1822 return frame()->loader().currentItem()->getReferencedFilePaths(); |
1927 } | 1823 } |
1928 | 1824 |
1929 void Internals::startTrackingRepaints(Document* document, ExceptionState& except
ionState) | 1825 void Internals::startTrackingRepaints(Document* document, ExceptionState& except
ionState) |
1930 { | 1826 { |
1931 if (!document || !document->view()) { | 1827 ASSERT(document); |
1932 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's view cannot be retrieved." : "The document provided is invalid."); | 1828 if (!document->view()) { |
| 1829 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1933 return; | 1830 return; |
1934 } | 1831 } |
1935 | 1832 |
1936 FrameView* frameView = document->view(); | 1833 FrameView* frameView = document->view(); |
1937 frameView->updateLayoutAndStyleForPainting(); | 1834 frameView->updateLayoutAndStyleForPainting(); |
1938 frameView->setTracksPaintInvalidations(true); | 1835 frameView->setTracksPaintInvalidations(true); |
1939 } | 1836 } |
1940 | 1837 |
1941 void Internals::stopTrackingRepaints(Document* document, ExceptionState& excepti
onState) | 1838 void Internals::stopTrackingRepaints(Document* document, ExceptionState& excepti
onState) |
1942 { | 1839 { |
1943 if (!document || !document->view()) { | 1840 ASSERT(document); |
1944 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's view cannot be retrieved." : "The document provided is invalid."); | 1841 if (!document->view()) { |
| 1842 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1945 return; | 1843 return; |
1946 } | 1844 } |
1947 | 1845 |
1948 FrameView* frameView = document->view(); | 1846 FrameView* frameView = document->view(); |
1949 frameView->updateLayoutAndStyleForPainting(); | 1847 frameView->updateLayoutAndStyleForPainting(); |
1950 frameView->setTracksPaintInvalidations(false); | 1848 frameView->setTracksPaintInvalidations(false); |
1951 } | 1849 } |
1952 | 1850 |
1953 void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Except
ionState& exceptionState) | 1851 void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Except
ionState& exceptionState) |
1954 { | 1852 { |
(...skipping 11 matching lines...) Expand all Loading... |
1966 document = toHTMLIFrameElement(*node).contentDocument(); | 1864 document = toHTMLIFrameElement(*node).contentDocument(); |
1967 } else { | 1865 } else { |
1968 exceptionState.throwTypeError("The node provided is neither a document n
or an IFrame."); | 1866 exceptionState.throwTypeError("The node provided is neither a document n
or an IFrame."); |
1969 return; | 1867 return; |
1970 } | 1868 } |
1971 document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksS
ynchronously); | 1869 document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksS
ynchronously); |
1972 } | 1870 } |
1973 | 1871 |
1974 void Internals::forceFullRepaint(Document* document, ExceptionState& exceptionSt
ate) | 1872 void Internals::forceFullRepaint(Document* document, ExceptionState& exceptionSt
ate) |
1975 { | 1873 { |
1976 if (!document || !document->view()) { | 1874 ASSERT(document); |
1977 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's view cannot be retrieved." : "The document provided is invalid."); | 1875 if (!document->view()) { |
| 1876 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1978 return; | 1877 return; |
1979 } | 1878 } |
1980 | 1879 |
1981 if (RenderView *renderView = document->renderView()) | 1880 if (RenderView *renderView = document->renderView()) |
1982 renderView->invalidatePaintForViewAndCompositedLayers(); | 1881 renderView->invalidatePaintForViewAndCompositedLayers(); |
1983 } | 1882 } |
1984 | 1883 |
1985 PassRefPtrWillBeRawPtr<ClientRectList> Internals::draggableRegions(Document* doc
ument, ExceptionState& exceptionState) | 1884 PassRefPtrWillBeRawPtr<ClientRectList> Internals::draggableRegions(Document* doc
ument, ExceptionState& exceptionState) |
1986 { | 1885 { |
1987 return annotatedRegions(document, true, exceptionState); | 1886 return annotatedRegions(document, true, exceptionState); |
1988 } | 1887 } |
1989 | 1888 |
1990 PassRefPtrWillBeRawPtr<ClientRectList> Internals::nonDraggableRegions(Document*
document, ExceptionState& exceptionState) | 1889 PassRefPtrWillBeRawPtr<ClientRectList> Internals::nonDraggableRegions(Document*
document, ExceptionState& exceptionState) |
1991 { | 1890 { |
1992 return annotatedRegions(document, false, exceptionState); | 1891 return annotatedRegions(document, false, exceptionState); |
1993 } | 1892 } |
1994 | 1893 |
1995 PassRefPtrWillBeRawPtr<ClientRectList> Internals::annotatedRegions(Document* doc
ument, bool draggable, ExceptionState& exceptionState) | 1894 PassRefPtrWillBeRawPtr<ClientRectList> Internals::annotatedRegions(Document* doc
ument, bool draggable, ExceptionState& exceptionState) |
1996 { | 1895 { |
1997 if (!document || !document->view()) { | 1896 ASSERT(document); |
1998 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's view cannot be retrieved." : "The document provided is invalid."); | 1897 if (!document->view()) { |
| 1898 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1999 return ClientRectList::create(); | 1899 return ClientRectList::create(); |
2000 } | 1900 } |
2001 | 1901 |
2002 document->updateLayout(); | 1902 document->updateLayout(); |
2003 document->view()->updateAnnotatedRegions(); | 1903 document->view()->updateAnnotatedRegions(); |
2004 Vector<AnnotatedRegionValue> regions = document->annotatedRegions(); | 1904 Vector<AnnotatedRegionValue> regions = document->annotatedRegions(); |
2005 | 1905 |
2006 Vector<FloatQuad> quads; | 1906 Vector<FloatQuad> quads; |
2007 for (size_t i = 0; i < regions.size(); ++i) { | 1907 for (size_t i = 0; i < regions.size(); ++i) { |
2008 if (regions[i].draggable == draggable) | 1908 if (regions[i].draggable == draggable) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 case Cursor::Grabbing: return "Grabbing"; | 1959 case Cursor::Grabbing: return "Grabbing"; |
2060 case Cursor::Custom: return "Custom"; | 1960 case Cursor::Custom: return "Custom"; |
2061 } | 1961 } |
2062 | 1962 |
2063 ASSERT_NOT_REACHED(); | 1963 ASSERT_NOT_REACHED(); |
2064 return "UNKNOWN"; | 1964 return "UNKNOWN"; |
2065 } | 1965 } |
2066 | 1966 |
2067 String Internals::getCurrentCursorInfo(Document* document, ExceptionState& excep
tionState) | 1967 String Internals::getCurrentCursorInfo(Document* document, ExceptionState& excep
tionState) |
2068 { | 1968 { |
2069 if (!document || !document->frame()) { | 1969 ASSERT(document); |
2070 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "The document provided is invalid."); | 1970 if (!document->frame()) { |
| 1971 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
2071 return String(); | 1972 return String(); |
2072 } | 1973 } |
2073 | 1974 |
2074 Cursor cursor = document->frame()->eventHandler().currentMouseCursor(); | 1975 Cursor cursor = document->frame()->eventHandler().currentMouseCursor(); |
2075 | 1976 |
2076 StringBuilder result; | 1977 StringBuilder result; |
2077 result.append("type="); | 1978 result.append("type="); |
2078 result.append(cursorTypeToString(cursor.type())); | 1979 result.append(cursorTypeToString(cursor.type())); |
2079 result.append(" hotSpot="); | 1980 result.append(" hotSpot="); |
2080 result.appendNumber(cursor.hotSpot().x()); | 1981 result.appendNumber(cursor.hotSpot().x()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 { | 2020 { |
2120 Document* document = contextDocument(); | 2021 Document* document = contextDocument(); |
2121 if (!document || !document->frame()) { | 2022 if (!document || !document->frame()) { |
2122 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "No context document can be obtained."); | 2023 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's frame cannot be retrieved." : "No context document can be obtained."); |
2123 return nullptr; | 2024 return nullptr; |
2124 } | 2025 } |
2125 | 2026 |
2126 return ClientRect::create(document->frame()->selection().bounds()); | 2027 return ClientRect::create(document->frame()->selection().bounds()); |
2127 } | 2028 } |
2128 | 2029 |
2129 String Internals::markerTextForListItem(Element* element, ExceptionState& except
ionState) | 2030 String Internals::markerTextForListItem(Element* element) |
2130 { | 2031 { |
2131 if (!element) { | 2032 ASSERT(element); |
2132 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
2133 return String(); | |
2134 } | |
2135 return blink::markerTextForListItem(element); | 2033 return blink::markerTextForListItem(element); |
2136 } | 2034 } |
2137 | 2035 |
2138 String Internals::getImageSourceURL(Element* element, ExceptionState& exceptionS
tate) | 2036 String Internals::getImageSourceURL(Element* element) |
2139 { | 2037 { |
2140 if (!element) { | 2038 ASSERT(element); |
2141 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | |
2142 return String(); | |
2143 } | |
2144 return element->imageSourceURL(); | 2039 return element->imageSourceURL(); |
2145 } | 2040 } |
2146 | 2041 |
2147 String Internals::baseURL(Document* document, ExceptionState& exceptionState) | 2042 String Internals::baseURL(Document* document) |
2148 { | 2043 { |
2149 if (!document) { | 2044 ASSERT(document); |
2150 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
2151 return String(); | |
2152 } | |
2153 | |
2154 return document->baseURL().string(); | 2045 return document->baseURL().string(); |
2155 } | 2046 } |
2156 | 2047 |
2157 bool Internals::isSelectPopupVisible(Node* node) | 2048 bool Internals::isSelectPopupVisible(Node* node) |
2158 { | 2049 { |
2159 ASSERT(node); | 2050 ASSERT(node); |
2160 if (!isHTMLSelectElement(*node)) | 2051 if (!isHTMLSelectElement(*node)) |
2161 return false; | 2052 return false; |
2162 | 2053 |
2163 HTMLSelectElement& select = toHTMLSelectElement(*node); | 2054 HTMLSelectElement& select = toHTMLSelectElement(*node); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 sharedContext->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_EXT, GL_INNOCENT_
CONTEXT_RESET_EXT); | 2102 sharedContext->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_EXT, GL_INNOCENT_
CONTEXT_RESET_EXT); |
2212 // To prevent tests that call loseSharedGraphicsContext3D from being | 2103 // To prevent tests that call loseSharedGraphicsContext3D from being |
2213 // flaky, we call finish so that the context is guaranteed to be lost | 2104 // flaky, we call finish so that the context is guaranteed to be lost |
2214 // synchronously (i.e. before returning). | 2105 // synchronously (i.e. before returning). |
2215 sharedContext->finish(); | 2106 sharedContext->finish(); |
2216 return true; | 2107 return true; |
2217 } | 2108 } |
2218 | 2109 |
2219 void Internals::forceCompositingUpdate(Document* document, ExceptionState& excep
tionState) | 2110 void Internals::forceCompositingUpdate(Document* document, ExceptionState& excep
tionState) |
2220 { | 2111 { |
2221 if (!document || !document->renderView()) { | 2112 ASSERT(document); |
2222 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc
ument's render view cannot be retrieved." : "The document provided is invalid.")
; | 2113 if (!document->renderView()) { |
| 2114 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
2223 return; | 2115 return; |
2224 } | 2116 } |
2225 | 2117 |
2226 document->frame()->view()->updateLayoutAndStyleForPainting(); | 2118 document->frame()->view()->updateLayoutAndStyleForPainting(); |
2227 } | 2119 } |
2228 | 2120 |
2229 void Internals::setZoomFactor(float factor) | 2121 void Internals::setZoomFactor(float factor) |
2230 { | 2122 { |
2231 frame()->setPageZoomFactor(factor); | 2123 frame()->setPageZoomFactor(factor); |
2232 } | 2124 } |
2233 | 2125 |
2234 void Internals::setShouldRevealPassword(Element* element, bool reveal, Exception
State& exceptionState) | 2126 void Internals::setShouldRevealPassword(Element* element, bool reveal, Exception
State& exceptionState) |
2235 { | 2127 { |
| 2128 ASSERT(element); |
2236 if (!isHTMLInputElement(element)) { | 2129 if (!isHTMLInputElement(element)) { |
2237 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Element")); | 2130 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov
ided is not an INPUT."); |
2238 return; | 2131 return; |
2239 } | 2132 } |
2240 | 2133 |
2241 return toHTMLInputElement(*element).setShouldRevealPassword(reveal); | 2134 return toHTMLInputElement(*element).setShouldRevealPassword(reveal); |
2242 } | 2135 } |
2243 | 2136 |
2244 namespace { | 2137 namespace { |
2245 | 2138 |
2246 class AddOneFunction : public ScriptFunction { | 2139 class AddOneFunction : public ScriptFunction { |
2247 public: | 2140 public: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 blink::WebPoint point(x, y); | 2200 blink::WebPoint point(x, y); |
2308 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo
rPoint(static_cast<IntPoint>(point))).deepEquivalent().parentAnchoredEquivalent(
), maxLength); | 2201 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo
rPoint(static_cast<IntPoint>(point))).deepEquivalent().parentAnchoredEquivalent(
), maxLength); |
2309 return surroundingText.content(); | 2202 return surroundingText.content(); |
2310 } | 2203 } |
2311 | 2204 |
2312 void Internals::setFocused(bool focused) | 2205 void Internals::setFocused(bool focused) |
2313 { | 2206 { |
2314 frame()->page()->focusController().setFocused(focused); | 2207 frame()->page()->focusController().setFocused(focused); |
2315 } | 2208 } |
2316 | 2209 |
2317 bool Internals::ignoreLayoutWithPendingStylesheets(Document* document, Exception
State& exceptionState) | 2210 bool Internals::ignoreLayoutWithPendingStylesheets(Document* document) |
2318 { | 2211 { |
2319 if (!document) { | 2212 ASSERT(document); |
2320 exceptionState.throwDOMException(InvalidAccessError, "No context documen
t is available."); | |
2321 return false; | |
2322 } | |
2323 | |
2324 return document->ignoreLayoutWithPendingStylesheets(); | 2213 return document->ignoreLayoutWithPendingStylesheets(); |
2325 } | 2214 } |
2326 | 2215 |
2327 void Internals::setNetworkStateNotifierTestOnly(bool testOnly) | 2216 void Internals::setNetworkStateNotifierTestOnly(bool testOnly) |
2328 { | 2217 { |
2329 networkStateNotifier().setTestUpdatesOnly(testOnly); | 2218 networkStateNotifier().setTestUpdatesOnly(testOnly); |
2330 } | 2219 } |
2331 | 2220 |
2332 void Internals::setNetworkConnectionInfo(const String& type, ExceptionState& exc
eptionState) | 2221 void Internals::setNetworkConnectionInfo(const String& type, ExceptionState& exc
eptionState) |
2333 { | 2222 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 | 2254 |
2366 StringBuilder markup; | 2255 StringBuilder markup; |
2367 Vector<Document::TransitionElementData>::iterator iter = elementData.begin()
; | 2256 Vector<Document::TransitionElementData>::iterator iter = elementData.begin()
; |
2368 for (; iter != elementData.end(); ++iter) | 2257 for (; iter != elementData.end(); ++iter) |
2369 markup.append(iter->markup); | 2258 markup.append(iter->markup); |
2370 | 2259 |
2371 return markup.toString(); | 2260 return markup.toString(); |
2372 } | 2261 } |
2373 | 2262 |
2374 } // namespace blink | 2263 } // namespace blink |
OLD | NEW |