OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/html/HTMLFrameletElement.h" |
| 6 |
| 7 #include "core/CSSPropertyNames.h" |
| 8 #include "core/HTMLNames.h" |
| 9 #include "core/frame/Framelet.h" |
| 10 #include "core/html/HTMLDocument.h" |
| 11 #include "core/html/parser/HTMLParserIdioms.h" |
| 12 #include "core/layout/LayoutFramelet.h" |
| 13 #include "core/loader/FrameLoaderClient.h" |
| 14 #include "platform/graphics/GraphicsLayer.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 using namespace HTMLNames; |
| 19 |
| 20 inline HTMLFrameletElement::HTMLFrameletElement(Document& document) |
| 21 : HTMLFrameOwnerElement(frameletTag, document) |
| 22 , m_webLayer(nullptr) |
| 23 , m_framelet(nullptr) |
| 24 { |
| 25 } |
| 26 |
| 27 DEFINE_NODE_FACTORY(HTMLFrameletElement) |
| 28 |
| 29 HTMLFrameletElement::~HTMLFrameletElement() |
| 30 { |
| 31 } |
| 32 |
| 33 void HTMLFrameletElement::setURL(const String& str) |
| 34 { |
| 35 if (framelet()) |
| 36 return; |
| 37 |
| 38 m_URL = document().completeURL(str); |
| 39 |
| 40 if (!m_URL.isEmpty() && inDocument()) |
| 41 document().frame()->loader().client()->createFramelet(m_URL, this); |
| 42 } |
| 43 |
| 44 void HTMLFrameletElement::collectStyleForPresentationAttribute(const QualifiedNa
me& name, const AtomicString& value, MutableStylePropertySet* style) |
| 45 { |
| 46 if (name == widthAttr) { |
| 47 addHTMLLengthToStyle(style, CSSPropertyWidth, value); |
| 48 } else if (name == heightAttr) { |
| 49 addHTMLLengthToStyle(style, CSSPropertyHeight, value); |
| 50 } else if (name == alignAttr) { |
| 51 applyAlignmentAttributeToStyle(value, style); |
| 52 } else if (name == frameborderAttr) { |
| 53 // LocalFrame border doesn't really match the HTML4 spec definition for
iframes. It simply adds |
| 54 // a presentational hint that the border should be off if set to zero. |
| 55 if (!value.toInt()) { |
| 56 // Add a rule that nulls out our border width. |
| 57 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidt
h, 0, CSSPrimitiveValue::UnitType::Pixels); |
| 58 } |
| 59 } else { |
| 60 HTMLElement::collectStyleForPresentationAttribute(name, value, style); |
| 61 } |
| 62 } |
| 63 |
| 64 void HTMLFrameletElement::parseAttribute(const QualifiedName& name, const Atomic
String& oldValue, const AtomicString& value) |
| 65 { |
| 66 if (name == srcAttr) { |
| 67 setURL(stripLeadingAndTrailingHTMLSpaces(value)); |
| 68 } else { |
| 69 HTMLElement::parseAttribute(name, oldValue, value); |
| 70 } |
| 71 } |
| 72 |
| 73 bool HTMLFrameletElement::layoutObjectIsNeeded(const ComputedStyle& style) |
| 74 { |
| 75 return HTMLElement::layoutObjectIsNeeded(style); |
| 76 } |
| 77 |
| 78 LayoutObject* HTMLFrameletElement::createLayoutObject(const ComputedStyle&) |
| 79 { |
| 80 return new LayoutFramelet(this); |
| 81 } |
| 82 |
| 83 Node::InsertionNotificationRequest HTMLFrameletElement::insertedInto(ContainerNo
de* insertionPoint) |
| 84 { |
| 85 HTMLElement::insertedInto(insertionPoint); |
| 86 return InsertionShouldCallDidNotifySubtreeInsertions; |
| 87 } |
| 88 |
| 89 void HTMLFrameletElement::didNotifySubtreeInsertionsToDocument() |
| 90 { |
| 91 setURL(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(srcAttr))); |
| 92 } |
| 93 |
| 94 void HTMLFrameletElement::setWebLayer(WebLayer* webLayer) |
| 95 { |
| 96 if (m_webLayer) |
| 97 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
| 98 m_webLayer = webLayer; |
| 99 if (m_webLayer) |
| 100 GraphicsLayer::registerContentsLayer(m_webLayer); |
| 101 |
| 102 setNeedsCompositingUpdate(); |
| 103 } |
| 104 |
| 105 void HTMLFrameletElement::setFramelet(Framelet* framelet) |
| 106 { |
| 107 m_framelet = framelet; |
| 108 } |
| 109 |
| 110 void HTMLFrameletElement::attach(const AttachContext& context) |
| 111 { |
| 112 if (framelet()) |
| 113 framelet()->didAttach(); |
| 114 HTMLFrameOwnerElement::attach(context); |
| 115 } |
| 116 |
| 117 // FIXME: Remove this code once we have input routing in the browser |
| 118 // process. See http://crbug.com/339659. |
| 119 void HTMLFrameletElement::defaultEventHandler(Event* event) |
| 120 { |
| 121 // We don't have a framelet object until initial navigation. |
| 122 if (framelet()) |
| 123 framelet()->forwardInputEvent(event); |
| 124 HTMLFrameOwnerElement::defaultEventHandler(event); |
| 125 } |
| 126 |
| 127 void HTMLFrameletElement::detach(const AttachContext& context) |
| 128 { |
| 129 if (framelet()) |
| 130 framelet()->didDetach(); |
| 131 setWidget(nullptr); |
| 132 HTMLFrameOwnerElement::detach(context); |
| 133 } |
| 134 |
| 135 |
| 136 bool HTMLFrameletElement::isKeyboardFocusable() const |
| 137 { |
| 138 return true; |
| 139 } |
| 140 |
| 141 bool HTMLFrameletElement::supportsFocus() const |
| 142 { |
| 143 return true; |
| 144 } |
| 145 } |
OLD | NEW |