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

Side by Side Diff: sky/engine/core/dom/Element.cpp

Issue 878303002: Remove more scrolling code from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/dom/Element.h ('k') | sky/engine/core/dom/Element.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (document().documentElement() == this) { 391 if (document().documentElement() == this) {
392 if (FrameView* view = document().view()) 392 if (FrameView* view = document().view())
393 return view->layoutSize().height(); 393 return view->layoutSize().height();
394 } 394 }
395 395
396 if (RenderBox* renderer = renderBox()) 396 if (RenderBox* renderer = renderBox())
397 return renderer->pixelSnappedClientHeight(); 397 return renderer->pixelSnappedClientHeight();
398 return 0; 398 return 0;
399 } 399 }
400 400
401 int Element::scrollLeft()
402 {
403 // FIXME(sky): Remove(scrolling)
404 return 0;
405 }
406
407 int Element::scrollTop()
408 {
409 // FIXME(sky): Remove(scrolling)
410 return 0;
411 }
412
413 void Element::setScrollLeft(int newLeft)
414 {
415 // FIXME(sky): Remove(scrolling)
416 }
417
418 void Element::setScrollLeft(const Dictionary& scrollOptionsHorizontal, Exception State& exceptionState)
419 {
420 // FIXME(sky): Remove(scrolling)
421 }
422
423 void Element::setScrollTop(int newTop)
424 {
425 // FIXME(sky): Remove(scrolling)
426 }
427
428 void Element::setScrollTop(const Dictionary& scrollOptionsVertical, ExceptionSta te& exceptionState)
429 {
430 // FIXME(sky): Remove(scrolling)
431 }
432
433 int Element::scrollWidth()
434 {
435 // FIXME(sky): Remove(scrolling)
436 return 0;
437 }
438
439 int Element::scrollHeight()
440 {
441 // FIXME(sky): Remove(scrolling)
442 return 0;
443 }
444
445 PassRefPtr<ClientRectList> Element::getClientRects() 401 PassRefPtr<ClientRectList> Element::getClientRects()
446 { 402 {
447 document().updateLayout(); 403 document().updateLayout();
448 404
449 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject(); 405 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject();
450 if (!renderBoxModelObject) 406 if (!renderBoxModelObject)
451 return ClientRectList::create(); 407 return ClientRectList::create();
452 408
453 // FIXME: Handle SVG elements. 409 // FIXME: Handle SVG elements.
454 // FIXME: Handle table/inline-table with a caption. 410 // FIXME: Handle table/inline-table with a caption.
455 411
456 Vector<FloatQuad> quads; 412 Vector<FloatQuad> quads;
457 renderBoxModelObject->absoluteQuads(quads); 413 renderBoxModelObject->absoluteQuads(quads);
458 document().adjustFloatQuadsForScroll(quads);
459 return ClientRectList::create(quads); 414 return ClientRectList::create(quads);
460 } 415 }
461 416
462 PassRefPtr<ClientRect> Element::getBoundingClientRect() 417 PassRefPtr<ClientRect> Element::getBoundingClientRect()
463 { 418 {
464 document().updateLayout(); 419 document().updateLayout();
465 420
466 Vector<FloatQuad> quads; 421 Vector<FloatQuad> quads;
467 // Get the bounding rectangle from the box model. 422 // Get the bounding rectangle from the box model.
468 if (renderBoxModelObject()) 423 if (renderBoxModelObject())
469 renderBoxModelObject()->absoluteQuads(quads); 424 renderBoxModelObject()->absoluteQuads(quads);
470 425
471 if (quads.isEmpty()) 426 if (quads.isEmpty())
472 return ClientRect::create(); 427 return ClientRect::create();
473 428
474 FloatRect result = quads[0].boundingBox(); 429 FloatRect result = quads[0].boundingBox();
475 for (size_t i = 1; i < quads.size(); ++i) 430 for (size_t i = 1; i < quads.size(); ++i)
476 result.unite(quads[i].boundingBox()); 431 result.unite(quads[i].boundingBox());
477 432
478 document().adjustFloatRectForScroll(result);
479 return ClientRect::create(result); 433 return ClientRect::create(result);
480 } 434 }
481 435
482 void Element::setAttribute(const AtomicString& localName, const AtomicString& va lue, ExceptionState& exceptionState) 436 void Element::setAttribute(const AtomicString& localName, const AtomicString& va lue, ExceptionState& exceptionState)
483 { 437 {
484 if (!Document::isValidName(localName)) { 438 if (!Document::isValidName(localName)) {
485 exceptionState.throwDOMException(InvalidCharacterError, "'" + localName + "' is not a valid attribute name."); 439 exceptionState.throwDOMException(InvalidCharacterError, "'" + localName + "' is not a valid attribute name.");
486 return; 440 return;
487 } 441 }
488 442
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 664
711 const AtomicString& idValue = getIdAttribute(); 665 const AtomicString& idValue = getIdAttribute();
712 if (!idValue.isNull()) 666 if (!idValue.isNull())
713 updateId(scope, nullAtom, idValue); 667 updateId(scope, nullAtom, idValue);
714 } 668 }
715 669
716 void Element::removedFrom(ContainerNode* insertionPoint) 670 void Element::removedFrom(ContainerNode* insertionPoint)
717 { 671 {
718 bool wasInDocument = insertionPoint->inDocument(); 672 bool wasInDocument = insertionPoint->inDocument();
719 673
720 setSavedLayerScrollOffset(IntSize());
721
722 if (insertionPoint->isInTreeScope() && treeScope() == document()) { 674 if (insertionPoint->isInTreeScope() && treeScope() == document()) {
723 const AtomicString& idValue = getIdAttribute(); 675 const AtomicString& idValue = getIdAttribute();
724 if (!idValue.isNull()) 676 if (!idValue.isNull())
725 updateId(insertionPoint->treeScope(), idValue, nullAtom); 677 updateId(insertionPoint->treeScope(), idValue, nullAtom);
726 } 678 }
727 679
728 ContainerNode::removedFrom(insertionPoint); 680 ContainerNode::removedFrom(insertionPoint);
729 if (wasInDocument) { 681 if (wasInDocument) {
730 if (isUpgradedCustomElement()) 682 if (isUpgradedCustomElement())
731 CustomElement::didDetach(this, insertionPoint->document()); 683 CustomElement::didDetach(this, insertionPoint->document());
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection. 1060 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection.
1109 if (this == frame->selection().rootEditableElement()) 1061 if (this == frame->selection().rootEditableElement())
1110 return; 1062 return;
1111 1063
1112 // FIXME: We should restore the previous selection if there is one. 1064 // FIXME: We should restore the previous selection if there is one.
1113 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore Node(this), DOWNSTREAM); 1065 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore Node(this), DOWNSTREAM);
1114 // Passing DoNotSetFocus as this function is called after FocusControlle r::setFocusedElement() 1066 // Passing DoNotSetFocus as this function is called after FocusControlle r::setFocusedElement()
1115 // and we don't want to change the focus to a new Element. 1067 // and we don't want to change the focus to a new Element.
1116 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); 1068 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus);
1117 frame->selection().revealSelection(); 1069 frame->selection().revealSelection();
1118 } else if (renderer()) 1070 }
1119 renderer()->scrollRectToVisible(boundingBox());
1120 } 1071 }
1121 1072
1122 void Element::blur() 1073 void Element::blur()
1123 { 1074 {
1124 if (treeScope().adjustedFocusedElement() == this) { 1075 if (treeScope().adjustedFocusedElement() == this) {
1125 Document& doc = document(); 1076 Document& doc = document();
1126 if (doc.page()) 1077 if (doc.page())
1127 doc.page()->focusController().setFocusedElement(0, doc.frame()); 1078 doc.page()->focusController().setFocusedElement(0, doc.frame());
1128 else 1079 else
1129 doc.setFocusedElement(nullptr); 1080 doc.setFocusedElement(nullptr);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1352 }
1402 1353
1403 void Element::didMoveToNewDocument(Document& oldDocument) 1354 void Element::didMoveToNewDocument(Document& oldDocument)
1404 { 1355 {
1405 Node::didMoveToNewDocument(oldDocument); 1356 Node::didMoveToNewDocument(oldDocument);
1406 1357
1407 if (needsURLResolutionForInlineStyle(*this, oldDocument, document())) 1358 if (needsURLResolutionForInlineStyle(*this, oldDocument, document()))
1408 reResolveURLsInInlineStyle(document(), ensureMutableInlineStyle()); 1359 reResolveURLsInInlineStyle(document(), ensureMutableInlineStyle());
1409 } 1360 }
1410 1361
1411 IntSize Element::savedLayerScrollOffset() const
1412 {
1413 return hasRareData() ? elementRareData()->savedLayerScrollOffset() : IntSize ();
1414 }
1415
1416 void Element::setSavedLayerScrollOffset(const IntSize& size)
1417 {
1418 if (size.isZero() && !hasRareData())
1419 return;
1420 ensureElementRareData().setSavedLayerScrollOffset(size);
1421 }
1422
1423 void Element::cloneAttributesFromElement(const Element& other) 1362 void Element::cloneAttributesFromElement(const Element& other)
1424 { 1363 {
1425 other.synchronizeAllAttributes(); 1364 other.synchronizeAllAttributes();
1426 if (!other.m_elementData) { 1365 if (!other.m_elementData) {
1427 m_elementData.clear(); 1366 m_elementData.clear();
1428 return; 1367 return;
1429 } 1368 }
1430 1369
1431 const AtomicString& oldID = getIdAttribute(); 1370 const AtomicString& oldID = getIdAttribute();
1432 const AtomicString& newID = other.getIdAttribute(); 1371 const AtomicString& newID = other.getIdAttribute();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 return false; 1587 return false;
1649 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) 1588 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue))
1650 return true; 1589 return true;
1651 // Host rules could also have effects. 1590 // Host rules could also have effects.
1652 if (ShadowRoot* shadowRoot = this->shadowRoot()) 1591 if (ShadowRoot* shadowRoot = this->shadowRoot())
1653 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); 1592 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue);
1654 return false; 1593 return false;
1655 } 1594 }
1656 1595
1657 } // namespace blink 1596 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Element.h ('k') | sky/engine/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698