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

Side by Side Diff: Source/core/editing/EditingStyle.cpp

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/EditingStyle.h ('k') | Source/core/editing/EditorCommand.cpp » ('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) 2007, 2008, 2009 Apple Computer, Inc. 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc.
3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2010, 2011 Google 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 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/editing/ApplyStyleCommand.h" 49 #include "core/editing/ApplyStyleCommand.h"
50 #include "core/editing/Editor.h" 50 #include "core/editing/Editor.h"
51 #include "core/editing/FrameSelection.h" 51 #include "core/editing/FrameSelection.h"
52 #include "core/editing/HTMLInterchange.h" 52 #include "core/editing/HTMLInterchange.h"
53 #include "core/editing/htmlediting.h" 53 #include "core/editing/htmlediting.h"
54 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
55 #include "core/html/HTMLFontElement.h" 55 #include "core/html/HTMLFontElement.h"
56 #include "core/html/HTMLSpanElement.h" 56 #include "core/html/HTMLSpanElement.h"
57 #include "core/layout/LayoutBox.h" 57 #include "core/layout/LayoutBox.h"
58 #include "core/layout/LayoutObject.h" 58 #include "core/layout/LayoutObject.h"
59 #include "core/layout/style/LayoutStyle.h" 59 #include "core/layout/style/ComputedStyle.h"
60 60
61 namespace blink { 61 namespace blink {
62 62
63 static const CSSPropertyID& textDecorationPropertyForEditing() 63 static const CSSPropertyID& textDecorationPropertyForEditing()
64 { 64 {
65 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; 65 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration;
66 return property; 66 return property;
67 } 67 }
68 68
69 // Editing style properties must be preserved during editing operation. 69 // Editing style properties must be preserved during editing operation.
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS SComputedStyleDeclaration::create(node); 464 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS SComputedStyleDeclaration::create(node);
465 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition); 465 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition);
466 466
467 if (propertiesToInclude == EditingPropertiesInEffect) { 467 if (propertiesToInclude == EditingPropertiesInEffect) {
468 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node)) 468 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node))
469 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt()); 469 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt());
470 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) 470 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect))
471 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t()); 471 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t());
472 } 472 }
473 473
474 if (node && node->computedStyle()) { 474 if (node && node->ensureComputedStyle()) {
475 const LayoutStyle* layoutStyle = node->computedStyle(); 475 const ComputedStyle* computedStyle = node->ensureComputedStyle();
476 removeTextFillAndStrokeColorsIfNeeded(layoutStyle); 476 removeTextFillAndStrokeColorsIfNeeded(computedStyle);
477 replaceFontSizeByKeywordIfPossible(layoutStyle, computedStyleAtPosition. get()); 477 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio n.get());
478 } 478 }
479 479
480 m_fixedPitchFontType = computedStyleAtPosition->fixedPitchFontType(); 480 m_fixedPitchFontType = computedStyleAtPosition->fixedPitchFontType();
481 extractFontSizeDelta(); 481 extractFontSizeDelta();
482 } 482 }
483 483
484 void EditingStyle::removeTextFillAndStrokeColorsIfNeeded(const LayoutStyle* layo utStyle) 484 void EditingStyle::removeTextFillAndStrokeColorsIfNeeded(const ComputedStyle* co mputedStyle)
485 { 485 {
486 // If a node's text fill color is currentColor, then its children use 486 // If a node's text fill color is currentColor, then its children use
487 // their font-color as their text fill color (they don't 487 // their font-color as their text fill color (they don't
488 // inherit it). Likewise for stroke color. 488 // inherit it). Likewise for stroke color.
489 if (layoutStyle->textFillColor().isCurrentColor()) 489 if (computedStyle->textFillColor().isCurrentColor())
490 m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor); 490 m_mutableStyle->removeProperty(CSSPropertyWebkitTextFillColor);
491 if (layoutStyle->textStrokeColor().isCurrentColor()) 491 if (computedStyle->textStrokeColor().isCurrentColor())
492 m_mutableStyle->removeProperty(CSSPropertyWebkitTextStrokeColor); 492 m_mutableStyle->removeProperty(CSSPropertyWebkitTextStrokeColor);
493 } 493 }
494 494
495 void EditingStyle::setProperty(CSSPropertyID propertyID, const String& value, bo ol important) 495 void EditingStyle::setProperty(CSSPropertyID propertyID, const String& value, bo ol important)
496 { 496 {
497 if (!m_mutableStyle) 497 if (!m_mutableStyle)
498 m_mutableStyle = MutableStylePropertySet::create(); 498 m_mutableStyle = MutableStylePropertySet::create();
499 499
500 m_mutableStyle->setProperty(propertyID, value, important); 500 m_mutableStyle->setProperty(propertyID, value, important);
501 } 501 }
502 502
503 void EditingStyle::replaceFontSizeByKeywordIfPossible(const LayoutStyle* layoutS tyle, CSSComputedStyleDeclaration* computedStyle) 503 void EditingStyle::replaceFontSizeByKeywordIfPossible(const ComputedStyle* compu tedStyle, CSSComputedStyleDeclaration* cssComputedStyle)
504 { 504 {
505 ASSERT(layoutStyle); 505 ASSERT(computedStyle);
506 if (layoutStyle->fontDescription().keywordSize()) 506 if (computedStyle->fontDescription().keywordSize())
507 m_mutableStyle->setProperty(CSSPropertyFontSize, computedStyle->getFontS izeCSSValuePreferringKeyword()->cssText()); 507 m_mutableStyle->setProperty(CSSPropertyFontSize, cssComputedStyle->getFo ntSizeCSSValuePreferringKeyword()->cssText());
508 } 508 }
509 509
510 void EditingStyle::extractFontSizeDelta() 510 void EditingStyle::extractFontSizeDelta()
511 { 511 {
512 if (!m_mutableStyle) 512 if (!m_mutableStyle)
513 return; 513 return;
514 514
515 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) { 515 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) {
516 // Explicit font size overrides any delta. 516 // Explicit font size overrides any delta.
517 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); 517 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 , m_applyItalic(false) 1421 , m_applyItalic(false)
1422 , m_applyUnderline(false) 1422 , m_applyUnderline(false)
1423 , m_applyLineThrough(false) 1423 , m_applyLineThrough(false)
1424 , m_applySubscript(false) 1424 , m_applySubscript(false)
1425 , m_applySuperscript(false) 1425 , m_applySuperscript(false)
1426 { 1426 {
1427 Document* document = position.document(); 1427 Document* document = position.document();
1428 if (!style || !style->style() || !document || !document->frame() || !positio n.element()) 1428 if (!style || !style->style() || !document || !document->frame() || !positio n.element())
1429 return; 1429 return;
1430 1430
1431 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com putedStyle(); 1431 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.ens ureComputedStyle();
1432 // FIXME: take care of background-color in effect 1432 // FIXME: take care of background-color in effect
1433 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI n(style->style(), computedStyle.get()); 1433 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI n(style->style(), computedStyle.get());
1434 ASSERT(mutableStyle); 1434 ASSERT(mutableStyle);
1435 1435
1436 reconcileTextDecorationProperties(mutableStyle.get()); 1436 reconcileTextDecorationProperties(mutableStyle.get());
1437 if (!document->frame()->editor().shouldStyleWithCSS()) 1437 if (!document->frame()->editor().shouldStyleWithCSS())
1438 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc hFontType()); 1438 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc hFontType());
1439 1439
1440 // Changing the whitespace style in a tab span would collapse the tab into a space. 1440 // Changing the whitespace style in a tab span would collapse the tab into a space.
1441 if (isTabHTMLSpanElementTextNode(position.deprecatedNode()) || isTabHTMLSpan Element((position.deprecatedNode()))) 1441 if (isTabHTMLSpanElementTextNode(position.deprecatedNode()) || isTabHTMLSpan Element((position.deprecatedNode())))
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 { 1679 {
1680 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1680 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1681 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); 1681 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor);
1682 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1682 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1683 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1683 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1684 } 1684 }
1685 return nullptr; 1685 return nullptr;
1686 } 1686 }
1687 1687
1688 } 1688 }
OLDNEW
« no previous file with comments | « Source/core/editing/EditingStyle.h ('k') | Source/core/editing/EditorCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698