| OLD | NEW |
| 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 26 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 27 #include "core/SVGNames.h" | 27 #include "core/SVGNames.h" |
| 28 #include "core/css/resolver/StyleResolver.h" | 28 #include "core/css/resolver/StyleResolver.h" |
| 29 #include "core/dom/ExceptionCode.h" | 29 #include "core/dom/ExceptionCode.h" |
| 30 #include "core/dom/LayoutTreeBuilder.h" | 30 #include "core/dom/LayoutTreeBuilder.h" |
| 31 #include "core/dom/LayoutTreeBuilderTraversal.h" | 31 #include "core/dom/LayoutTreeBuilderTraversal.h" |
| 32 #include "core/dom/NodeComputedStyle.h" | 32 #include "core/dom/NodeComputedStyle.h" |
| 33 #include "core/dom/NodeTraversal.h" | 33 #include "core/dom/NodeTraversal.h" |
| 34 #include "core/dom/shadow/ShadowRoot.h" | 34 #include "core/dom/shadow/ShadowRoot.h" |
| 35 #include "core/events/ScopedEventQueue.h" | 35 #include "core/events/ScopedEventQueue.h" |
| 36 #include "core/html/HTMLTableCellElement.h" | |
| 37 #include "core/layout/LayoutText.h" | 36 #include "core/layout/LayoutText.h" |
| 38 #include "core/layout/LayoutTextCombine.h" | 37 #include "core/layout/LayoutTextCombine.h" |
| 39 #include "core/layout/svg/LayoutSVGInlineText.h" | 38 #include "core/layout/svg/LayoutSVGInlineText.h" |
| 40 #include "core/svg/SVGForeignObjectElement.h" | 39 #include "core/svg/SVGForeignObjectElement.h" |
| 41 #include "wtf/text/CString.h" | 40 #include "wtf/text/CString.h" |
| 42 #include "wtf/text/StringBuilder.h" | 41 #include "wtf/text/StringBuilder.h" |
| 43 | 42 |
| 44 namespace blink { | 43 namespace blink { |
| 45 | 44 |
| 46 PassRefPtrWillBeRawPtr<Text> Text::create(Document& document, const String& data
) | 45 PassRefPtrWillBeRawPtr<Text> Text::create(Document& document, const String& data
) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 Node::NodeType Text::nodeType() const | 230 Node::NodeType Text::nodeType() const |
| 232 { | 231 { |
| 233 return TEXT_NODE; | 232 return TEXT_NODE; |
| 234 } | 233 } |
| 235 | 234 |
| 236 PassRefPtrWillBeRawPtr<Node> Text::cloneNode(bool /*deep*/) | 235 PassRefPtrWillBeRawPtr<Node> Text::cloneNode(bool /*deep*/) |
| 237 { | 236 { |
| 238 return cloneWithData(data()); | 237 return cloneWithData(data()); |
| 239 } | 238 } |
| 240 | 239 |
| 241 static inline bool hasGeneratedAnonymousTableCells(const LayoutObject& parent) | |
| 242 { | |
| 243 // We're checking whether the table part has generated anonymous table | |
| 244 // part wrappers to hold its contents, so inspecting its first child will su
ffice. | |
| 245 LayoutObject* child = parent.slowFirstChild(); | |
| 246 if (!child || !child->isAnonymous()) | |
| 247 return false; | |
| 248 if (child->isTableCell()) | |
| 249 return true; | |
| 250 if (child->isTableSection() || child->isTableRow()) | |
| 251 return hasGeneratedAnonymousTableCells(*child); | |
| 252 return false; | |
| 253 } | |
| 254 | |
| 255 static inline bool nodeAllowsAdjacentWhitespace(Node* node) | |
| 256 { | |
| 257 if (!node) | |
| 258 return true; | |
| 259 const ComputedStyle* style = node->ensureComputedStyle(); | |
| 260 return style && style->originalDisplay() != TABLE_CELL && !isHTMLTableCellEl
ement(node); | |
| 261 } | |
| 262 | |
| 263 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Text* t
ext) | 240 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Text* t
ext) |
| 264 { | 241 { |
| 265 // <button> should allow whitespace even though LayoutFlexibleBox doesn't. | 242 // <button> should allow whitespace even though LayoutFlexibleBox doesn't. |
| 266 if (parent.isLayoutButton()) | 243 if (parent.isLayoutButton()) |
| 267 return true; | 244 return true; |
| 268 | 245 |
| 269 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() | 246 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() |
| 270 || parent.isLayoutTableCol() || parent.isFrameSet() | 247 || parent.isLayoutTableCol() || parent.isFrameSet() |
| 271 || parent.isFlexibleBox() || parent.isLayoutGrid() | 248 || parent.isFlexibleBox() || parent.isLayoutGrid() |
| 272 || parent.isSVGRoot() | 249 || parent.isSVGRoot() |
| 273 || parent.isSVGContainer() | 250 || parent.isSVGContainer() |
| 274 || parent.isSVGImage() | 251 || parent.isSVGImage() |
| 275 || parent.isSVGShape()) { | 252 || parent.isSVGShape()) { |
| 276 // Allow whitespace when the text is inside a table, section or row elem
ent that | |
| 277 // has generated anonymous table cells to hold its contents. | |
| 278 if (hasGeneratedAnonymousTableCells(parent)) | |
| 279 return nodeAllowsAdjacentWhitespace(text->previousSibling()) && node
AllowsAdjacentWhitespace(text->nextSibling()); | |
| 280 return false; | 253 return false; |
| 281 } | 254 } |
| 282 return true; | 255 return true; |
| 283 } | 256 } |
| 284 | 257 |
| 285 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje
ct& parent) | 258 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje
ct& parent) |
| 286 { | 259 { |
| 287 if (!parent.canHaveChildren()) | 260 if (!parent.canHaveChildren()) |
| 288 return false; | 261 return false; |
| 289 | 262 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 result.appendLiteral("; "); | 434 result.appendLiteral("; "); |
| 462 result.appendLiteral("value="); | 435 result.appendLiteral("value="); |
| 463 result.append(s); | 436 result.append(s); |
| 464 } | 437 } |
| 465 | 438 |
| 466 strncpy(buffer, result.toString().utf8().data(), length - 1); | 439 strncpy(buffer, result.toString().utf8().data(), length - 1); |
| 467 } | 440 } |
| 468 #endif | 441 #endif |
| 469 | 442 |
| 470 } // namespace blink | 443 } // namespace blink |
| OLD | NEW |